Skip to content

Rollup of 8 pull requests #68503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c775927
Suggest borrowing `Vec<NonCopy>` in for loop
estebank Jan 21, 2020
4ee4287
Account for non-types in substs for opaque type error messages
Aaron1011 Jan 21, 2020
0cc71b2
Normalise diagnostics with respect to "the X is declared/defined here"
varkor Jan 22, 2020
9d3e844
Avoid overflow in `std::iter::Skip::count`
ollie27 Jan 22, 2020
4210409
Enable ASan on Fuchsia
nopsledder Jan 15, 2020
192650a
Fix tidy warnings
nopsledder Jan 22, 2020
d26366a
Normalise notes with the/is
varkor Jan 22, 2020
6f7e89f
unused-parens: implement for block return values
Tyg13 Jan 23, 2020
06064b9
Add my (@flip1995) name to .mailmap
flip1995 Jan 23, 2020
6eaf59d
use `diagnostic_item` and modify wording
estebank Jan 23, 2020
1cbb5d8
Clear out std, not std tools
Mark-Simulacrum Jan 24, 2020
2370109
Rollup merge of #68080 - varkor:declared-here, r=petrochenkov
tmandry Jan 24, 2020
f741f5e
Rollup merge of #68424 - estebank:suggest-borrow-for-non-copy-vec, r=…
tmandry Jan 24, 2020
42458d9
Rollup merge of #68438 - Aaron1011:fix/tait-non-defining, r=estebank
tmandry Jan 24, 2020
60fa729
Rollup merge of #68469 - ollie27:skip_count, r=sfackler
tmandry Jan 24, 2020
6cbf4d6
Rollup merge of #68473 - nopsledder:rust_sanitizer_fuchsia, r=alexcri…
tmandry Jan 24, 2020
3ece812
Rollup merge of #68479 - Tyg13:unused_parens_return, r=Centril
tmandry Jan 24, 2020
1ce6658
Rollup merge of #68483 - flip1995:mailmap, r=Dylan-DPC
tmandry Jan 24, 2020
ac737d6
Rollup merge of #68500 - Mark-Simulacrum:fix-bootstrap-clearing, r=al…
tmandry Jan 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ Peter Liniker <[email protected]>
Phil Dawes <[email protected]> Phil Dawes <[email protected]>
Philipp Brüschweiler <[email protected]> <[email protected]>
Philipp Brüschweiler <[email protected]> <[email protected]>
Philipp Krones <[email protected]> flip1995 <[email protected]>
Philipp Matthias Schäfer <[email protected]>
Przemysław Wesołek <[email protected]> Przemek Wesołek <[email protected]>
Rafael Ávila de Espíndola <[email protected]> Rafael Avila de Espindola <espindola@dream.(none)>
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ impl<'a> Builder<'a> {
//
// Only clear out the directory if we're compiling std; otherwise, we
// should let Cargo take care of things for us (via depdep info)
if !self.config.dry_run && mode == Mode::ToolStd && cmd == "build" {
if !self.config.dry_run && mode == Mode::Std && cmd == "build" {
self.clear_if_dirty(&out_dir, &self.rustc(compiler));
}

Expand Down
18 changes: 18 additions & 0 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,24 @@ fn supported_sanitizers(out_dir: &Path, target: Interned<String>) -> Vec<Sanitiz
});
}
}
"x86_64-fuchsia" => {
for s in &["asan"] {
result.push(SanitizerRuntime {
cmake_target: format!("clang_rt.{}-x86_64", s),
path: out_dir.join(&format!("build/lib/fuchsia/libclang_rt.{}-x86_64.a", s)),
name: format!("librustc_rt.{}.a", s),
});
}
}
"aarch64-fuchsia" => {
for s in &["asan"] {
result.push(SanitizerRuntime {
cmake_target: format!("clang_rt.{}-aarch64", s),
path: out_dir.join(&format!("build/lib/fuchsia/libclang_rt.{}-aarch64.a", s)),
name: format!("librustc_rt.{}.a", s),
});
}
}
_ => {}
}
result
Expand Down
10 changes: 8 additions & 2 deletions src/libcore/iter/adapters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1815,8 +1815,14 @@ where
}

#[inline]
fn count(self) -> usize {
self.iter.count().saturating_sub(self.n)
fn count(mut self) -> usize {
if self.n > 0 {
// nth(n) skips n+1
if self.iter.nth(self.n - 1).is_none() {
return 0;
}
}
self.iter.count()
}

#[inline]
Expand Down
1 change: 1 addition & 0 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ use crate::{

/// The `Option` type. See [the module level documentation](index.html) for more.
#[derive(Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
#[rustc_diagnostic_item = "option_type"]
#[stable(feature = "rust1", since = "1.0.0")]
pub enum Option<T> {
/// No value
Expand Down
1 change: 1 addition & 0 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ use crate::ops::{self, Deref, DerefMut};
/// [`Err`]: enum.Result.html#variant.Err
#[derive(Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
#[must_use = "this `Result` may be an `Err` variant, which should be handled"]
#[rustc_diagnostic_item = "result_type"]
#[stable(feature = "rust1", since = "1.0.0")]
pub enum Result<T, E> {
/// Contains the success value
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ pub fn struct_lint_level<'a>(
&mut err,
DiagnosticMessageId::from(lint),
src,
"lint level defined here",
"the lint level is defined here",
);
if lint_attr_name.as_str() != name {
let level_str = level.as_str();
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,17 @@ impl LanguageItemCollector<'tcx> {
},
};
if let Some(span) = self.tcx.hir().span_if_local(original_def_id) {
err.span_note(span, "first defined here");
err.span_note(span, "the lang item is first defined here");
} else {
match self.tcx.extern_crate(original_def_id) {
Some(ExternCrate {dependency_of, ..}) => {
err.note(&format!(
"first defined in crate `{}` (which `{}` depends on)",
"the lang item is first defined in crate `{}` (which `{}` depends on)",
self.tcx.crate_name(original_def_id.krate),
self.tcx.crate_name(*dependency_of)));
},
_ => {
err.note(&format!("first defined in crate `{}`.",
err.note(&format!("the lang item is first defined in crate `{}`.",
self.tcx.crate_name(original_def_id.krate)));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2410,7 +2410,7 @@ impl<'tcx> AdtDef {

#[inline]
pub fn variant_range(&self) -> Range<VariantIdx> {
(VariantIdx::new(0)..VariantIdx::new(self.variants.len()))
VariantIdx::new(0)..VariantIdx::new(self.variants.len())
}

/// Computes the discriminant value used by a specific variant.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ impl<'tcx> GeneratorSubsts<'tcx> {
pub fn variant_range(&self, def_id: DefId, tcx: TyCtxt<'tcx>) -> Range<VariantIdx> {
// FIXME requires optimized MIR
let num_variants = tcx.generator_layout(def_id).variant_fields.len();
(VariantIdx::new(0)..VariantIdx::new(num_variants))
VariantIdx::new(0)..VariantIdx::new(num_variants)
}

/// The discriminant for the given variant. Panics if the `variant_index` is
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ fn link_sanitizer_runtime(sess: &Session, crate_type: config::CrateType, linker:
linker.args(&["-Wl,-rpath".into(), "-Xlinker".into(), rpath.into()]);
linker.link_dylib(Symbol::intern(&libname));
}
"x86_64-unknown-linux-gnu" => {
"x86_64-unknown-linux-gnu" | "x86_64-fuchsia" | "aarch64-fuchsia" => {
let filename = format!("librustc_rt.{}.a", name);
let path = default_tlib.join(&filename);
linker.link_whole_rlib(&path);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_data_structures/sorted_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<K: Ord, V> SortedMap<K, V> {
R: RangeBounds<K>,
{
let (start, end) = self.range_slice_indices(range);
(&self.data[start..end])
&self.data[start..end]
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
diag.note(note);
if let ty::Adt(def, _) = ty.kind {
if let Some(sp) = self.cx.tcx.hir().span_if_local(def.did) {
diag.span_note(sp, "type defined here");
diag.span_note(sp, "the type is defined here");
}
}
diag.emit();
Expand Down
16 changes: 12 additions & 4 deletions src/librustc_lint/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,12 +544,20 @@ impl EarlyLintPass for UnusedParens {
}

fn check_stmt(&mut self, cx: &EarlyContext<'_>, s: &ast::Stmt) {
if let ast::StmtKind::Local(ref local) = s.kind {
self.check_unused_parens_pat(cx, &local.pat, false, false);
use ast::StmtKind::*;

if let Some(ref value) = local.init {
self.check_unused_parens_expr(cx, &value, "assigned value", false, None, None);
match s.kind {
Local(ref local) => {
self.check_unused_parens_pat(cx, &local.pat, false, false);

if let Some(ref value) = local.init {
self.check_unused_parens_expr(cx, &value, "assigned value", false, None, None);
}
}
Expr(ref expr) => {
self.check_unused_parens_expr(cx, &expr, "block return value", false, None, None);
}
_ => {}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ impl<'a> CrateLoader<'a> {
self.sess
.struct_span_err(*span2, "cannot define multiple global allocators")
.span_label(*span2, "cannot define a new global allocator")
.span_label(*span1, "previous global allocator is defined here")
.span_label(*span1, "previous global allocator defined here")
.emit();
true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {

err.span_label(
upvar_span,
format!("`{}` is declared here, outside of the {} body", upvar_name, escapes_from),
format!("`{}` declared here, outside of the {} body", upvar_name, escapes_from),
);

err.span_label(borrow_span, format!("borrow is only valid in the {} body", escapes_from));
Expand Down
29 changes: 25 additions & 4 deletions src/librustc_mir/borrow_check/diagnostics/move_errors.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use rustc::mir::*;
use rustc::ty;
use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_span::Span;
use rustc_span::source_map::DesugaringKind;
use rustc_span::{Span, Symbol};

use crate::borrow_check::diagnostics::UseSpans;
use crate::borrow_check::prefixes::PrefixSet;
Expand Down Expand Up @@ -383,10 +384,20 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
}
}
};
let move_ty = format!("{:?}", move_place.ty(*self.body, self.infcx.tcx).ty,);
if let Ok(snippet) = self.infcx.tcx.sess.source_map().span_to_snippet(span) {
let is_option = move_ty.starts_with("std::option::Option");
let is_result = move_ty.starts_with("std::result::Result");
let def_id = match move_place.ty(*self.body, self.infcx.tcx).ty.kind {
ty::Adt(self_def, _) => self_def.did,
ty::Foreign(def_id)
| ty::FnDef(def_id, _)
| ty::Closure(def_id, _)
| ty::Generator(def_id, ..)
| ty::Opaque(def_id, _) => def_id,
_ => return err,
};
let is_option =
self.infcx.tcx.is_diagnostic_item(Symbol::intern("option_type"), def_id);
let is_result =
self.infcx.tcx.is_diagnostic_item(Symbol::intern("result_type"), def_id);
if (is_option || is_result) && use_spans.map_or(true, |v| !v.for_closure()) {
err.span_suggestion(
span,
Expand All @@ -397,6 +408,16 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
format!("{}.as_ref()", snippet),
Applicability::MaybeIncorrect,
);
} else if span.is_desugaring(DesugaringKind::ForLoop)
&& self.infcx.tcx.is_diagnostic_item(Symbol::intern("vec_type"), def_id)
{
// FIXME: suggest for anything that implements `IntoIterator`.
err.span_suggestion(
span,
"consider iterating over a slice of the `Vec<_>`'s content",
format!("&{}", snippet),
Applicability::MaybeIncorrect,
);
}
}
err
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
diag.span_label(
outlived_fr_span,
format!(
"`{}` is declared here, outside of the {} body",
"`{}` declared here, outside of the {} body",
outlived_fr_name, escapes_from
),
);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/check_consts/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ fn check_short_circuiting_in_const_local(item: &Item<'_, 'tcx>) {
}
for local in locals {
let span = body.local_decls[local].source_info.span;
error.span_note(span, "more locals defined here");
error.span_note(span, "more locals are defined here");
}
error.emit();
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/hair/pattern/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1530,7 +1530,7 @@ impl<'tcx> IntRange<'tcx> {
// 2 -------- // 2 -------
let (lo, hi) = self.boundaries();
let (other_lo, other_hi) = other.boundaries();
(lo == other_hi || hi == other_lo)
lo == other_hi || hi == other_lo
}

fn to_pat(&self, tcx: TyCtxt<'tcx>) -> Pat<'tcx> {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_passes/diagnostic_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ fn collect_item(
)),
};
if let Some(span) = tcx.hir().span_if_local(original_def_id) {
err.span_note(span, "first defined here");
err.span_note(span, "the diagnostic item is first defined here");
} else {
err.note(&format!(
"first defined in crate `{}`.",
"the diagnostic item is first defined in crate `{}`.",
tcx.crate_name(original_def_id.krate)
));
}
Expand Down
8 changes: 6 additions & 2 deletions src/librustc_session/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1127,8 +1127,12 @@ fn validate_commandline_args_with_session_available(sess: &Session) {

// Sanitizers can only be used on some tested platforms.
if let Some(ref sanitizer) = sess.opts.debugging_opts.sanitizer {
const ASAN_SUPPORTED_TARGETS: &[&str] =
&["x86_64-unknown-linux-gnu", "x86_64-apple-darwin"];
const ASAN_SUPPORTED_TARGETS: &[&str] = &[
"x86_64-unknown-linux-gnu",
"x86_64-apple-darwin",
"x86_64-fuchsia",
"aarch64-fuchsia",
];
const TSAN_SUPPORTED_TARGETS: &[&str] =
&["x86_64-unknown-linux-gnu", "x86_64-apple-darwin"];
const LSAN_SUPPORTED_TARGETS: &[&str] =
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_span/source_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,10 +774,10 @@ impl SourceMap {
// searching forwards for boundaries we've got somewhere to search.
let snippet = if let Some(ref src) = local_begin.sf.src {
let len = src.len();
(&src[start_index..len])
&src[start_index..len]
} else if let Some(src) = src.get_source() {
let len = src.len();
(&src[start_index..len])
&src[start_index..len]
} else {
return 1;
};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2220,7 +2220,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {

let mut could_refer_to = |kind: DefKind, def_id, also| {
let note_msg = format!(
"`{}` could{} refer to {} defined here",
"`{}` could{} refer to the {} defined here",
assoc_ident,
also,
kind.descr(def_id)
Expand Down
11 changes: 9 additions & 2 deletions src/librustc_typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1673,8 +1673,15 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
ty::Param(_) => true,
_ => false,
};
let bad_substs: Vec<_> =
substs.types().enumerate().filter(|(_, ty)| !is_param(ty)).collect();
let bad_substs: Vec<_> = substs
.iter()
.enumerate()
.filter_map(|(i, k)| {
if let GenericArgKind::Type(ty) = k.unpack() { Some((i, ty)) } else { None }
})
.filter(|(_, ty)| !is_param(ty))
.collect();

if !bad_substs.is_empty() {
let identity_substs = InternalSubsts::identity_for_item(self.tcx, self.def_id);
for (i, bad_subst) in bad_substs {
Expand Down
6 changes: 1 addition & 5 deletions src/libsyntax/print/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,11 +548,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
let st = match style {
ast::StrStyle::Cooked => (format!("\"{}\"", st.escape_debug())),
ast::StrStyle::Raw(n) => {
(format!(
"r{delim}\"{string}\"{delim}",
delim = "#".repeat(n as usize),
string = st
))
format!("r{delim}\"{string}\"{delim}", delim = "#".repeat(n as usize), string = st)
}
};
self.word(st)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error: `[v2]` cannot be resolved, ignoring it.
LL | /// [v2]
| ^^ cannot be resolved, ignoring
|
note: lint level defined here
note: the lint level is defined here
--> $DIR/deny-intra-link-resolution-failure.rs:1:9
|
LL | #![deny(intra_doc_link_resolution_failure)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/deny-missing-docs-crate.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LL | |
LL | | pub struct Foo;
| |_______________^
|
note: lint level defined here
note: the lint level is defined here
--> $DIR/deny-missing-docs-crate.rs:1:9
|
LL | #![deny(missing_docs)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/deny-missing-docs-macro.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error: missing documentation for macro
LL | macro_rules! foo {
| ^^^^^^^^^^^^^^^^
|
note: lint level defined here
note: the lint level is defined here
--> $DIR/deny-missing-docs-macro.rs:3:9
|
LL | #![deny(missing_docs)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/doc-without-codeblock.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LL | | pub fn bar() {}
LL | | }
| |_^
|
note: lint level defined here
note: the lint level is defined here
--> $DIR/doc-without-codeblock.rs:1:9
|
LL | #![deny(missing_doc_code_examples)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/intra-doc-alias-ice.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error: `[TypeAlias::hoge]` cannot be resolved, ignoring it.
LL | /// [broken cross-reference](TypeAlias::hoge)
| ^^^^^^^^^^^^^^^ cannot be resolved, ignoring
|
note: lint level defined here
note: the lint level is defined here
--> $DIR/intra-doc-alias-ice.rs:1:9
|
LL | #![deny(intra_doc_link_resolution_failure)]
Expand Down
Loading