diff options
62 files changed, 581 insertions, 186 deletions
diff --git a/Cargo.lock b/Cargo.lock index da34271a2b4..aa942065845 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -379,7 +379,7 @@ dependencies = [ "tar", "tempfile", "termcolor", - "toml", + "toml_edit", "unicode-width", "unicode-xid", "url 2.2.2", @@ -465,7 +465,7 @@ dependencies = [ "serde_json", "tar", "termcolor", - "toml", + "toml_edit", "url 2.2.2", ] @@ -732,6 +732,16 @@ dependencies = [ ] [[package]] +name = "combine" +version = "4.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50b727aacc797f9fc28e355d21f34709ac4fc9adecfe470ad07b8f4464f53062" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] name = "commoncrypto" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1954,6 +1964,15 @@ dependencies = [ ] [[package]] +name = "kstring" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b310ccceade8121d7d77fee406160e457c2f4e7c7982d589da3499bc7ea4526" +dependencies = [ + "serde", +] + +[[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -5224,6 +5243,19 @@ dependencies = [ ] [[package]] +name = "toml_edit" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b80ac5e1b91e3378c63dab121962472b5ca20cf9ab1975e3d588548717807a8" +dependencies = [ + "combine", + "indexmap", + "itertools 0.10.1", + "kstring", + "serde", +] + +[[package]] name = "topological-sort" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index 8f4e574fbd6..8ed50075ecb 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -798,7 +798,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { .map(|assoc_items| { assoc_items .in_definition_order() - .map(|assoc_item_def| assoc_item_def.ident) + .map(|assoc_item_def| assoc_item_def.ident(self.infcx.tcx)) .filter(|&ident| { let original_method_ident = path_segment.ident; original_method_ident != ident diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 14ab635a2ae..1eb8190bd7d 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -2650,7 +2650,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { infer::LateBoundRegion(_, br, infer::AssocTypeProjection(def_id)) => format!( " for lifetime parameter {}in trait containing associated type `{}`", br_string(br), - self.tcx.associated_item(def_id).ident + self.tcx.associated_item(def_id).name ), infer::EarlyBoundRegion(_, name) => format!(" for lifetime parameter `{}`", name), infer::UpvarRegion(ref upvar_id, _) => { diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs index 412a077959d..0a9f59fbc97 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -70,7 +70,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { .map(|s| format!("`{}`", s)) .unwrap_or_else(|| "`fn` parameter".to_string()), lifetime, - ctxt.assoc_item.ident, + ctxt.assoc_item.name, ); err.span_label(param.param_ty_span, &format!("this data with {}...", lifetime)); err.span_label( @@ -231,7 +231,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { // Handle case of `impl Foo for dyn Bar { fn qux(&self) {} }` introducing a // `'static` lifetime when called as a method on a binding: `bar.qux()`. if self.find_impl_on_dyn_trait(&mut err, param.param_ty, &ctxt) { - override_error_code = Some(ctxt.assoc_item.ident); + override_error_code = Some(ctxt.assoc_item.name); } } } @@ -252,7 +252,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { self.get_impl_ident_and_self_ty_from_trait(*item_def_id, &v.0) { if self.suggest_constrain_dyn_trait_in_impl(&mut err, &v.0, ident, self_ty) { - override_error_code = Some(ident); + override_error_code = Some(ident.name); } } } diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 97f6df51f88..3b5d636124d 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -282,7 +282,7 @@ pub enum ExternDepSpec { // This could be a closure, but then implementing derive trait // becomes hacky (and it gets allocated). -#[derive(PartialEq, Debug)] +#[derive(Debug)] pub enum BuiltinLintDiagnostics { Normal, AbsPathWithModule(Span), @@ -309,7 +309,6 @@ pub enum BuiltinLintDiagnostics { /// Lints that are buffered up early on in the `Session` before the /// `LintLevels` is calculated. -#[derive(PartialEq)] pub struct BufferedEarlyLint { /// The span of code that we are linting on. pub span: MultiSpan, @@ -336,9 +335,7 @@ pub struct LintBuffer { impl LintBuffer { pub fn add_early_lint(&mut self, early_lint: BufferedEarlyLint) { let arr = self.map.entry(early_lint.node_id).or_default(); - if !arr.contains(&early_lint) { - arr.push(early_lint); - } + arr.push(early_lint); } pub fn add_lint( diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index a074a0bff52..fb1c71fb8cd 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1279,7 +1279,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { }; ty::AssocItem { - ident, + name: ident.name, kind, vis: self.get_visibility(id), defaultness: container.defaultness(), diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 809e5ee2c64..3fae652ee2e 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1291,7 +1291,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { record!(self.tables.kind[def_id] <- EntryKind::AssocType(container)); } } - self.encode_ident_span(def_id, impl_item.ident); + self.encode_ident_span(def_id, impl_item.ident(self.tcx)); self.encode_item_type(def_id); if let Some(trait_item_def_id) = impl_item.trait_item_def_id { record!(self.tables.trait_item_def_id[def_id] <- trait_item_def_id); diff --git a/compiler/rustc_middle/src/ty/assoc.rs b/compiler/rustc_middle/src/ty/assoc.rs index 2776370ba6f..c23d4eae1a4 100644 --- a/compiler/rustc_middle/src/ty/assoc.rs +++ b/compiler/rustc_middle/src/ty/assoc.rs @@ -44,8 +44,7 @@ impl AssocItemContainer { #[derive(Copy, Clone, Debug, PartialEq, HashStable, Eq, Hash)] pub struct AssocItem { pub def_id: DefId, - #[stable_hasher(project(name))] - pub ident: Ident, + pub name: Symbol, pub kind: AssocKind, pub vis: Visibility, pub defaultness: hir::Defaultness, @@ -61,6 +60,10 @@ pub struct AssocItem { } impl AssocItem { + pub fn ident(&self, tcx: TyCtxt<'_>) -> Ident { + Ident::new(self.name, tcx.def_ident_span(self.def_id).unwrap()) + } + pub fn signature(&self, tcx: TyCtxt<'_>) -> String { match self.kind { ty::AssocKind::Fn => { @@ -70,9 +73,9 @@ impl AssocItem { // regions just fine, showing `fn(&MyType)`. tcx.fn_sig(self.def_id).skip_binder().to_string() } - ty::AssocKind::Type => format!("type {};", self.ident), + ty::AssocKind::Type => format!("type {};", self.name), ty::AssocKind::Const => { - format!("const {}: {:?};", self.ident, tcx.type_of(self.def_id)) + format!("const {}: {:?};", self.name, tcx.type_of(self.def_id)) } } } @@ -115,7 +118,7 @@ pub struct AssocItems<'tcx> { impl<'tcx> AssocItems<'tcx> { /// Constructs an `AssociatedItems` map from a series of `ty::AssocItem`s in definition order. pub fn new(items_in_def_order: impl IntoIterator<Item = &'tcx ty::AssocItem>) -> Self { - let items = items_in_def_order.into_iter().map(|item| (item.ident.name, item)).collect(); + let items = items_in_def_order.into_iter().map(|item| (item.name, item)).collect(); AssocItems { items } } @@ -149,7 +152,7 @@ impl<'tcx> AssocItems<'tcx> { ) -> Option<&ty::AssocItem> { self.filter_by_name_unhygienic(ident.name) .filter(|item| item.kind == kind) - .find(|item| tcx.hygienic_eq(ident, item.ident, parent_def_id)) + .find(|item| tcx.hygienic_eq(ident, item.ident(tcx), parent_def_id)) } /// Returns the associated item with the given name and any of `AssocKind`, if one exists. @@ -162,7 +165,7 @@ impl<'tcx> AssocItems<'tcx> { ) -> Option<&ty::AssocItem> { self.filter_by_name_unhygienic(ident.name) .filter(|item| kinds.contains(&item.kind)) - .find(|item| tcx.hygienic_eq(ident, item.ident, parent_def_id)) + .find(|item| tcx.hygienic_eq(ident, item.ident(tcx), parent_def_id)) } /// Returns the associated item with the given name in the given `Namespace`, if one exists. @@ -175,6 +178,6 @@ impl<'tcx> AssocItems<'tcx> { ) -> Option<&ty::AssocItem> { self.filter_by_name_unhygienic(ident.name) .filter(|item| item.kind.namespace() == ns) - .find(|item| tcx.hygienic_eq(ident, item.ident, parent_def_id)) + .find(|item| tcx.hygienic_eq(ident, item.ident(tcx), parent_def_id)) } } diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs index 5bb687512f3..5c4a4cdde25 100644 --- a/compiler/rustc_middle/src/ty/error.rs +++ b/compiler/rustc_middle/src/ty/error.rs @@ -972,10 +972,10 @@ fn foo(&self) -> Self::T { String::new() } let (span, sugg) = if has_params { let pos = span.hi() - BytePos(1); let span = Span::new(pos, pos, span.ctxt(), span.parent()); - (span, format!(", {} = {}", assoc.ident, ty)) + (span, format!(", {} = {}", assoc.ident(self), ty)) } else { let item_args = self.format_generic_args(assoc_substs); - (span.shrink_to_hi(), format!("<{}{} = {}>", assoc.ident, item_args, ty)) + (span.shrink_to_hi(), format!("<{}{} = {}>", assoc.ident(self), item_args, ty)) }; db.span_suggestion_verbose(span, msg, sugg, MaybeIncorrect); return true; diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index bbdaf248a9e..00a1256d684 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -908,7 +908,7 @@ pub trait PrettyPrinter<'tcx>: if !first { p!(", "); } - p!(write("{} = ", self.tcx().associated_item(assoc_item_def_id).ident)); + p!(write("{} = ", self.tcx().associated_item(assoc_item_def_id).name)); match term.skip_binder() { Term::Ty(ty) => { @@ -2455,7 +2455,7 @@ define_print_and_forward_display! { } ty::ExistentialProjection<'tcx> { - let name = cx.tcx().associated_item(self.item_def_id).ident; + let name = cx.tcx().associated_item(self.item_def_id).name; p!(write("{} = ", name), print(self.term)) } diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index c41f2d3299b..17bac362ec8 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -731,28 +731,22 @@ impl<'a> Parser<'a> { match x { Ok((_, _, false)) => { if self.eat(&token::Gt) { - let turbo_err = e.span_suggestion_verbose( + e.span_suggestion_verbose( binop.span.shrink_to_lo(), TURBOFISH_SUGGESTION_STR, "::".to_string(), Applicability::MaybeIncorrect, - ); - if self.check(&TokenKind::Semi) { - turbo_err.emit(); - *expr = self.mk_expr_err(expr.span); - return Ok(()); - } else { - match self.parse_expr() { - Ok(_) => { - turbo_err.emit(); - *expr = self - .mk_expr_err(expr.span.to(self.prev_token.span)); - return Ok(()); - } - Err(mut err) => { - turbo_err.cancel(); - err.cancel(); - } + ) + .emit(); + match self.parse_expr() { + Ok(_) => { + *expr = + self.mk_expr_err(expr.span.to(self.prev_token.span)); + return Ok(()); + } + Err(mut err) => { + *expr = self.mk_expr_err(expr.span); + err.cancel(); } } } diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 26284728ff2..693dd0051da 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1458,7 +1458,7 @@ impl<'a> Parser<'a> { self.parse_block_expr(label, lo, BlockCheckMode::Default, attrs) } else if !ate_colon && (self.check(&TokenKind::Comma) || self.check(&TokenKind::Gt)) { // We're probably inside of a `Path<'a>` that needs a turbofish, so suppress the - // "must be followed by a colon" error. + // "must be followed by a colon" error, and the "expected one of" error. self.diagnostic().delay_span_bug(lo, "this label wasn't parsed correctly"); consume_colon = false; Ok(self.mk_expr_err(lo)) diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index 0d51f7779e1..f8e8e15e78c 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -556,7 +556,7 @@ impl<'tcx> Printer<'tcx> for &mut SymbolMangler<'tcx> { cx = cx.print_def_path(trait_ref.def_id, trait_ref.substs)?; } ty::ExistentialPredicate::Projection(projection) => { - let name = cx.tcx.associated_item(projection.item_def_id).ident; + let name = cx.tcx.associated_item(projection.item_def_id).name; cx.push("p"); cx.push_ident(name.as_str()); cx = match projection.term { diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 0760f626851..8552aa78a82 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -1353,6 +1353,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { .map(|id| (trait_assoc_item, id)) }) .and_then(|(trait_assoc_item, id)| { + let trait_assoc_ident = trait_assoc_item.ident(self.tcx); self.tcx.find_map_relevant_impl( id, proj.projection_ty.self_ty(), @@ -1360,7 +1361,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> { self.tcx .associated_items(did) .in_definition_order() - .filter(|assoc| assoc.ident == trait_assoc_item.ident) + .filter(|assoc| assoc.ident(self.tcx) == trait_assoc_ident) .next() }, ) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 3fb42a2ec4a..056f813f0dd 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -1367,7 +1367,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { err.span_suggestion( span, "use the fully qualified path to an implementation", - format!("<Type as {}>::{}", self.tcx.def_path_str(trait_ref), assoc_item.ident), + format!("<Type as {}>::{}", self.tcx.def_path_str(trait_ref), assoc_item.name), Applicability::HasPlaceholders, ); } diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs index 7bfedecbdc7..7818053218d 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs @@ -89,7 +89,7 @@ fn object_safety_violations_for_trait( .filter(|item| item.kind == ty::AssocKind::Fn) .filter_map(|item| { object_safety_violation_for_method(tcx, trait_def_id, &item) - .map(|(code, span)| ObjectSafetyViolation::Method(item.ident.name, code, span)) + .map(|(code, span)| ObjectSafetyViolation::Method(item.name, code, span)) }) .filter(|violation| { if let ObjectSafetyViolation::Method( @@ -125,7 +125,10 @@ fn object_safety_violations_for_trait( tcx.associated_items(trait_def_id) .in_definition_order() .filter(|item| item.kind == ty::AssocKind::Const) - .map(|item| ObjectSafetyViolation::AssocConst(item.ident.name, item.ident.span)), + .map(|item| { + let ident = item.ident(tcx); + ObjectSafetyViolation::AssocConst(ident.name, ident.span) + }), ); violations.extend( @@ -133,7 +136,10 @@ fn object_safety_violations_for_trait( .in_definition_order() .filter(|item| item.kind == ty::AssocKind::Type) .filter(|item| !tcx.generics_of(item.def_id).params.is_empty()) - .map(|item| ObjectSafetyViolation::GAT(item.ident.name, item.ident.span)), + .map(|item| { + let ident = item.ident(tcx); + ObjectSafetyViolation::GAT(ident.name, ident.span) + }), ); debug!( @@ -367,15 +373,15 @@ fn object_safety_violation_for_method( (MethodViolationCode::ReferencesSelfInput(arg), Some(node)) => node .fn_decl() .and_then(|decl| decl.inputs.get(arg + 1)) - .map_or(method.ident.span, |arg| arg.span), + .map_or(method.ident(tcx).span, |arg| arg.span), (MethodViolationCode::UndispatchableReceiver, Some(node)) => node .fn_decl() .and_then(|decl| decl.inputs.get(0)) - .map_or(method.ident.span, |arg| arg.span), + .map_or(method.ident(tcx).span, |arg| arg.span), (MethodViolationCode::ReferencesSelfOutput, Some(node)) => { - node.fn_decl().map_or(method.ident.span, |decl| decl.output.span()) + node.fn_decl().map_or(method.ident(tcx).span, |decl| decl.output.span()) } - _ => method.ident.span, + _ => method.ident(tcx).span, }; (v, span) }) @@ -404,10 +410,10 @@ fn virtual_call_violation_for_method<'tcx>( ); // Get the span pointing at where the `self` receiver should be. let sm = tcx.sess.source_map(); - let self_span = method.ident.span.to(tcx + let self_span = method.ident(tcx).span.to(tcx .hir() .span_if_local(method.def_id) - .unwrap_or_else(|| sm.next_point(method.ident.span)) + .unwrap_or_else(|| sm.next_point(method.ident(tcx).span)) .shrink_to_hi()); let self_span = sm.span_through_char(self_span, '(').shrink_to_hi(); return Some(MethodViolationCode::StaticMethod( diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index f49f53351aa..e8b46e88a42 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -1600,7 +1600,7 @@ fn confirm_generator_candidate<'cx, 'tcx>( gen_sig, ) .map_bound(|(trait_ref, yield_ty, return_ty)| { - let name = tcx.associated_item(obligation.predicate.item_def_id).ident.name; + let name = tcx.associated_item(obligation.predicate.item_def_id).name; let ty = if name == sym::Return { return_ty } else if name == sym::Yield { @@ -1842,7 +1842,7 @@ fn confirm_impl_candidate<'cx, 'tcx>( // just return Error. debug!( "confirm_impl_candidate: no associated type {:?} for {:?}", - assoc_ty.item.ident, obligation.predicate + assoc_ty.item.name, obligation.predicate ); return Progress { ty: tcx.ty_error(), obligations: nested }; } diff --git a/compiler/rustc_ty_utils/src/assoc.rs b/compiler/rustc_ty_utils/src/assoc.rs index 781a639b09e..4142c999ca7 100644 --- a/compiler/rustc_ty_utils/src/assoc.rs +++ b/compiler/rustc_ty_utils/src/assoc.rs @@ -100,7 +100,7 @@ fn associated_item_from_trait_item_ref( }; ty::AssocItem { - ident: trait_item_ref.ident, + name: trait_item_ref.ident.name, kind, vis: tcx.visibility(def_id), defaultness: trait_item_ref.defaultness, @@ -124,7 +124,7 @@ fn associated_item_from_impl_item_ref( }; ty::AssocItem { - ident: impl_item_ref.ident, + name: impl_item_ref.ident.name, kind, vis: tcx.visibility(def_id), defaultness: impl_item_ref.defaultness, diff --git a/compiler/rustc_typeck/src/astconv/errors.rs b/compiler/rustc_typeck/src/astconv/errors.rs index b532c41642c..a49d6e24f26 100644 --- a/compiler/rustc_typeck/src/astconv/errors.rs +++ b/compiler/rustc_typeck/src/astconv/errors.rs @@ -214,7 +214,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { .map(|r| self.tcx().associated_items(r.def_id()).in_definition_order()) .flatten() .filter_map( - |item| if item.kind == ty::AssocKind::Type { Some(item.ident.name) } else { None }, + |item| if item.kind == ty::AssocKind::Type { Some(item.name) } else { None }, ) .collect(); @@ -270,7 +270,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let trait_def_id = assoc_item.container.id(); names.push(format!( "`{}` (from trait `{}`)", - assoc_item.ident, + assoc_item.name, tcx.def_path_str(trait_def_id), )); } @@ -327,11 +327,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let mut names: FxHashMap<_, usize> = FxHashMap::default(); for item in assoc_items { types_count += 1; - *names.entry(item.ident.name).or_insert(0) += 1; + *names.entry(item.name).or_insert(0) += 1; } let mut dupes = false; for item in assoc_items { - let prefix = if names[&item.ident.name] > 1 { + let prefix = if names[&item.name] > 1 { let trait_def_id = item.container.id(); dupes = true; format!("{}::", tcx.def_path_str(trait_def_id)) @@ -339,7 +339,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { String::new() }; if let Some(sp) = tcx.hir().span_if_local(item.def_id) { - err.span_label(sp, format!("`{}{}` defined here", prefix, item.ident)); + err.span_label(sp, format!("`{}{}` defined here", prefix, item.name)); } } if potential_assoc_types.len() == assoc_items.len() { @@ -350,14 +350,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { // `Iterator<Item = isize>`. for (potential, item) in iter::zip(&potential_assoc_types, assoc_items) { if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(*potential) { - suggestions.push((*potential, format!("{} = {}", item.ident, snippet))); + suggestions.push((*potential, format!("{} = {}", item.name, snippet))); } } } else if let (Ok(snippet), false) = (tcx.sess.source_map().span_to_snippet(*span), dupes) { let types: Vec<_> = - assoc_items.iter().map(|item| format!("{} = Type", item.ident)).collect(); + assoc_items.iter().map(|item| format!("{} = Type", item.name)).collect(); let code = if snippet.ends_with('>') { // The user wrote `Trait<'a>` or similar and we don't have a type we can // suggest, but at least we can clue them to the correct syntax @@ -388,17 +388,17 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let mut names: FxHashMap<_, usize> = FxHashMap::default(); for item in assoc_items { types_count += 1; - *names.entry(item.ident.name).or_insert(0) += 1; + *names.entry(item.name).or_insert(0) += 1; } let mut label = vec![]; for item in assoc_items { - let postfix = if names[&item.ident.name] > 1 { + let postfix = if names[&item.name] > 1 { let trait_def_id = item.container.id(); format!(" (from trait `{}`)", tcx.def_path_str(trait_def_id)) } else { String::new() }; - label.push(format!("`{}`{}", item.ident, postfix)); + label.push(format!("`{}`{}", item.name, postfix)); } if !label.is_empty() { err.span_label( diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs index d9b3f51b5bd..4cf8ddcb8f0 100644 --- a/compiler/rustc_typeck/src/astconv/mod.rs +++ b/compiler/rustc_typeck/src/astconv/mod.rs @@ -1137,7 +1137,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { .filter_by_name_unhygienic(assoc_ident.name) .find(|i| { (i.kind == ty::AssocKind::Type || i.kind == ty::AssocKind::Const) - && i.ident.normalize_to_macros_2_0() == assoc_ident + && i.ident(tcx).normalize_to_macros_2_0() == assoc_ident }) .expect("missing associated type"); // FIXME(associated_const_equality): need to handle assoc_consts here as well. @@ -1176,7 +1176,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { // Include substitutions for generic parameters of associated types let projection_ty = candidate.map_bound(|trait_ref| { - let ident = Ident::new(assoc_ty.ident.name, binding.item_name.span); + let ident = Ident::new(assoc_ty.name, binding.item_name.span); let item_segment = hir::PathSegment { ident, hir_id: Some(binding.hir_id), @@ -1868,7 +1868,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { .in_definition_order() .find(|i| { i.kind.namespace() == Namespace::TypeNS - && i.ident.normalize_to_macros_2_0() == assoc_ident + && i.ident(tcx).normalize_to_macros_2_0() == assoc_ident }) .expect("missing associated type"); diff --git a/compiler/rustc_typeck/src/check/check.rs b/compiler/rustc_typeck/src/check/check.rs index eb49cc0233d..18a0a8767d4 100644 --- a/compiler/rustc_typeck/src/check/check.rs +++ b/compiler/rustc_typeck/src/check/check.rs @@ -999,7 +999,7 @@ fn check_impl_items_against_trait<'tcx>( if is_implemented_here { let trait_item = tcx.associated_item(trait_item_id); - if required_items.contains(&trait_item.ident) { + if required_items.contains(&trait_item.ident(tcx)) { must_implement_one_of = None; } } diff --git a/compiler/rustc_typeck/src/check/compare_method.rs b/compiler/rustc_typeck/src/check/compare_method.rs index 94648d5702c..74910234b7e 100644 --- a/compiler/rustc_typeck/src/check/compare_method.rs +++ b/compiler/rustc_typeck/src/check/compare_method.rs @@ -300,7 +300,7 @@ fn compare_predicate_entailment<'tcx>( cause.span(tcx), E0053, "method `{}` has an incompatible type for trait", - trait_m.ident + trait_m.name ); match &terr { TypeError::ArgumentMutability(0) | TypeError::ArgumentSorts(_, 0) @@ -452,7 +452,7 @@ fn check_region_bounds_on_impl_item<'tcx>( tcx.sess.emit_err(LifetimesOrBoundsMismatchOnTrait { span, item_kind, - ident: impl_m.ident, + ident: impl_m.ident(tcx), generics_span, }); return Err(ErrorReported); @@ -540,14 +540,14 @@ fn compare_self_type<'tcx>( impl_m_span, E0185, "method `{}` has a `{}` declaration in the impl, but not in the trait", - trait_m.ident, + trait_m.name, self_descr ); err.span_label(impl_m_span, format!("`{}` used in impl", self_descr)); if let Some(span) = tcx.hir().span_if_local(trait_m.def_id) { err.span_label(span, format!("trait method declared without `{}`", self_descr)); } else { - err.note_trait_signature(trait_m.ident.to_string(), trait_m.signature(tcx)); + err.note_trait_signature(trait_m.name.to_string(), trait_m.signature(tcx)); } err.emit(); return Err(ErrorReported); @@ -560,14 +560,14 @@ fn compare_self_type<'tcx>( impl_m_span, E0186, "method `{}` has a `{}` declaration in the trait, but not in the impl", - trait_m.ident, + trait_m.name, self_descr ); err.span_label(impl_m_span, format!("expected `{}` in impl", self_descr)); if let Some(span) = tcx.hir().span_if_local(trait_m.def_id) { err.span_label(span, format!("`{}` used in trait", self_descr)); } else { - err.note_trait_signature(trait_m.ident.to_string(), trait_m.signature(tcx)); + err.note_trait_signature(trait_m.name.to_string(), trait_m.signature(tcx)); } err.emit(); return Err(ErrorReported); @@ -640,7 +640,7 @@ fn compare_number_of_generics<'tcx>( "{} `{}` has {} {kind} parameter{} but its trait \ declaration has {} {kind} parameter{}", item_kind, - trait_.ident, + trait_.name, impl_count, pluralize!(impl_count), trait_count, @@ -747,7 +747,7 @@ fn compare_number_of_method_arguments<'tcx>( impl_span, E0050, "method `{}` has {} but the declaration in trait `{}` has {}", - trait_m.ident, + trait_m.name, potentially_plural_count(impl_number_args, "parameter"), tcx.def_path_str(trait_m.def_id), trait_number_args @@ -761,7 +761,7 @@ fn compare_number_of_method_arguments<'tcx>( ), ); } else { - err.note_trait_signature(trait_m.ident.to_string(), trait_m.signature(tcx)); + err.note_trait_signature(trait_m.name.to_string(), trait_m.signature(tcx)); } err.span_label( impl_span, @@ -811,7 +811,7 @@ fn compare_synthetic_generics<'tcx>( impl_span, E0643, "method `{}` has incompatible signature for trait", - trait_m.ident + trait_m.name ); err.span_label(trait_span, "declaration in trait here"); match (impl_synthetic, trait_synthetic) { @@ -965,7 +965,7 @@ fn compare_const_param_types<'tcx>( *impl_span, E0053, "method `{}` has an incompatible const parameter type for trait", - trait_m.ident + trait_m.name ); err.span_note( trait_span.map_or_else(|| trait_item_span.unwrap_or(*impl_span), |span| *span), @@ -1053,7 +1053,7 @@ crate fn compare_const_impl<'tcx>( cause.span, E0326, "implemented const `{}` has an incompatible type for trait", - trait_c.ident + trait_c.name ); let trait_c_span = trait_c.def_id.as_local().map(|trait_c_def_id| { diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs b/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs index be4c9ec99b9..86cf850d723 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs @@ -237,7 +237,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Ok(expr_text) = self.sess().source_map().span_to_snippet(expr.span) { let mut suggestions = iter::zip(iter::repeat(&expr_text), &methods) .filter_map(|(receiver, method)| { - let method_call = format!(".{}()", method.ident); + let method_call = format!(".{}()", method.name); if receiver.ends_with(&method_call) { None // do not suggest code that is already there (#53348) } else { diff --git a/compiler/rustc_typeck/src/check/method/probe.rs b/compiler/rustc_typeck/src/check/method/probe.rs index 86f3568d2e3..9efaa37633e 100644 --- a/compiler/rustc_typeck/src/check/method/probe.rs +++ b/compiler/rustc_typeck/src/check/method/probe.rs @@ -1033,7 +1033,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { true } }) - .map(|candidate| candidate.item.ident) + .map(|candidate| candidate.item.ident(self.tcx)) .filter(|&name| set.insert(name)) .collect(); @@ -1438,7 +1438,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { "<{} as {}>::{}", stable_pick.self_ty, self.tcx.def_path_str(def_id), - stable_pick.item.ident + stable_pick.item.name ), Applicability::MachineApplicable, ); @@ -1748,14 +1748,12 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { let best_name = { let names = applicable_close_candidates .iter() - .map(|cand| cand.ident.name) + .map(|cand| cand.name) .collect::<Vec<Symbol>>(); find_best_match_for_name(&names, self.method_name.unwrap().name, None) } .unwrap(); - Ok(applicable_close_candidates - .into_iter() - .find(|method| method.ident.name == best_name)) + Ok(applicable_close_candidates.into_iter().find(|method| method.name == best_name)) } }) } @@ -1906,7 +1904,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { .associated_items(def_id) .in_definition_order() .filter(|x| { - let dist = lev_distance(name.as_str(), x.ident.as_str()); + let dist = lev_distance(name.as_str(), x.name.as_str()); x.kind.namespace() == Namespace::ValueNS && dist > 0 && dist <= max_dist }) .copied() diff --git a/compiler/rustc_typeck/src/check/method/suggest.rs b/compiler/rustc_typeck/src/check/method/suggest.rs index 96ab800afaf..6b440325095 100644 --- a/compiler/rustc_typeck/src/check/method/suggest.rs +++ b/compiler/rustc_typeck/src/check/method/suggest.rs @@ -1025,7 +1025,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { def_kind.article(), def_kind.descr(lev_candidate.def_id), ), - lev_candidate.ident.to_string(), + lev_candidate.name.to_string(), Applicability::MaybeIncorrect, ); } @@ -1480,7 +1480,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let skip = skippable.contains(&did); if pick.autoderefs == 0 && !skip { err.span_label( - pick.item.ident.span, + pick.item.ident(self.tcx).span, &format!("the method is available for `{}` here", rcvr_ty), ); } @@ -1514,7 +1514,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // an autoderef to `&self` if pick.autoderefs == 0 && !skip { err.span_label( - pick.item.ident.span, + pick.item.ident(self.tcx).span, &format!("the method is available for `{}` here", new_rcvr_t), ); err.multipart_suggestion( diff --git a/compiler/rustc_typeck/src/check/mod.rs b/compiler/rustc_typeck/src/check/mod.rs index 34caabe44d6..6e0b902a00b 100644 --- a/compiler/rustc_typeck/src/check/mod.rs +++ b/compiler/rustc_typeck/src/check/mod.rs @@ -599,7 +599,7 @@ fn missing_items_err( ) { let missing_items_msg = missing_items .iter() - .map(|trait_item| trait_item.ident.to_string()) + .map(|trait_item| trait_item.name.to_string()) .collect::<Vec<_>>() .join("`, `"); @@ -628,7 +628,7 @@ fn missing_items_err( let msg = format!("implement the missing item: `{}`", snippet); let appl = Applicability::HasPlaceholders; if let Some(span) = tcx.hir().span_if_local(trait_item.def_id) { - err.span_label(span, format!("`{}` from trait", trait_item.ident)); + err.span_label(span, format!("`{}` from trait", trait_item.name)); err.tool_only_span_suggestion(sugg_sp, &msg, code, appl); } else { err.span_suggestion_hidden(sugg_sp, &msg, code, appl); @@ -805,16 +805,16 @@ fn suggestion_signature(assoc: &ty::AssocItem, tcx: TyCtxt<'_>) -> String { fn_sig_suggestion( tcx, tcx.fn_sig(assoc.def_id).skip_binder(), - assoc.ident, + assoc.ident(tcx), tcx.predicates_of(assoc.def_id), assoc, ) } - ty::AssocKind::Type => format!("type {} = Type;", assoc.ident), + ty::AssocKind::Type => format!("type {} = Type;", assoc.name), ty::AssocKind::Const => { let ty = tcx.type_of(assoc.def_id); let val = expr::ty_kind_suggestion(ty).unwrap_or("value"); - format!("const {}: {} = {};", assoc.ident, ty, val) + format!("const {}: {} = {};", assoc.name, ty, val) } } } diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index aa1a521d532..71f45320e49 100644 --- a/compiler/rustc_typeck/src/check/wfcheck.rs +++ b/compiler/rustc_typeck/src/check/wfcheck.rs @@ -864,7 +864,7 @@ fn check_associated_item( let hir_sig = sig_if_method.expect("bad signature for method"); check_fn_or_method( fcx, - item.ident.span, + item.ident(fcx.tcx).span, sig, hir_sig.decl, item.def_id, diff --git a/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs b/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs index 59f211bd2c3..a409201372b 100644 --- a/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs +++ b/compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs @@ -36,7 +36,7 @@ impl<'tcx> InherentOverlapChecker<'tcx> { for item1 in impl_items1.in_definition_order() { let collision = impl_items2 - .filter_by_name_unhygienic(item1.ident.name) + .filter_by_name_unhygienic(item1.name) .any(|item2| self.compare_hygienically(item1, item2)); if collision { @@ -50,7 +50,8 @@ impl<'tcx> InherentOverlapChecker<'tcx> { fn compare_hygienically(&self, item1: &ty::AssocItem, item2: &ty::AssocItem) -> bool { // Symbols and namespace match, compare hygienically. item1.kind.namespace() == item2.kind.namespace() - && item1.ident.normalize_to_macros_2_0() == item2.ident.normalize_to_macros_2_0() + && item1.ident(self.tcx).normalize_to_macros_2_0() + == item2.ident(self.tcx).normalize_to_macros_2_0() } fn check_for_common_items_in_impls( @@ -64,11 +65,11 @@ impl<'tcx> InherentOverlapChecker<'tcx> { for item1 in impl_items1.in_definition_order() { let collision = impl_items2 - .filter_by_name_unhygienic(item1.ident.name) + .filter_by_name_unhygienic(item1.name) .find(|item2| self.compare_hygienically(item1, item2)); if let Some(item2) = collision { - let name = item1.ident.normalize_to_macros_2_0(); + let name = item1.ident(self.tcx).normalize_to_macros_2_0(); let mut err = struct_span_err!( self.tcx.sess, self.tcx.span_of_impl(item1.def_id).unwrap(), @@ -181,11 +182,11 @@ impl<'tcx> ItemLikeVisitor<'_> for InherentOverlapChecker<'tcx> { let mut ids = impl_items .in_definition_order() .filter_map(|item| { - let entry = connected_region_ids.entry(item.ident.name); + let entry = connected_region_ids.entry(item.name); if let Entry::Occupied(e) = &entry { Some(*e.get()) } else { - idents_to_add.push(item.ident.name); + idents_to_add.push(item.name); None } }) diff --git a/library/std/src/sys/windows/mod.rs b/library/std/src/sys/windows/mod.rs index 084af4325e7..ad4492f9d1f 100644 --- a/library/std/src/sys/windows/mod.rs +++ b/library/std/src/sys/windows/mod.rs @@ -285,6 +285,7 @@ pub fn dur2timeout(dur: Duration) -> c::DWORD { #[allow(unreachable_code)] pub fn abort_internal() -> ! { const FAST_FAIL_FATAL_APP_EXIT: usize = 7; + #[cfg(not(miri))] // inline assembly does not work in Miri unsafe { cfg_if::cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index e759baa0458..33612c80654 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -387,7 +387,7 @@ impl<'tcx> Clean<Type> for ty::ProjectionTy<'tcx> { let trait_ = lifted.trait_ref(cx.tcx).clean(cx); let self_type = self.self_ty().clean(cx); Type::QPath { - name: cx.tcx.associated_item(self.item_def_id).ident.name, + name: cx.tcx.associated_item(self.item_def_id).name, self_def_id: self_type.def_id(&cx.cache), self_type: box self_type, trait_, @@ -1131,7 +1131,7 @@ impl Clean<Item> for ty::AssocItem { } } ty::AssocKind::Type => { - let my_name = self.ident.name; + let my_name = self.name; if let ty::TraitContainer(_) = self.container { let bounds = tcx.explicit_item_bounds(self.def_id); @@ -1197,7 +1197,7 @@ impl Clean<Item> for ty::AssocItem { } }; - Item::from_def_id_and_parts(self.def_id, Some(self.ident.name), kind, cx) + Item::from_def_id_and_parts(self.def_id, Some(self.name), kind, cx) } } @@ -1521,7 +1521,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> { let mut bindings = vec![]; for pb in obj.projection_bounds() { bindings.push(TypeBinding { - name: cx.tcx.associated_item(pb.item_def_id()).ident.name, + name: cx.tcx.associated_item(pb.item_def_id()).name, kind: TypeBindingKind::Equality { term: pb.skip_binder().term.clean(cx).into(), }, @@ -1592,7 +1592,6 @@ impl<'tcx> Clean<Type> for Ty<'tcx> { name: cx .tcx .associated_item(proj.projection_ty.item_def_id) - .ident .name, kind: TypeBindingKind::Equality { term: proj.term.clean(cx), diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 0c0787c6b2f..d34c2dba0b0 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -5,7 +5,7 @@ use std::lazy::SyncOnceCell as OnceCell; use std::path::PathBuf; use std::rc::Rc; use std::sync::Arc; -use std::{slice, vec}; +use std::vec; use arrayvec::ArrayVec; @@ -733,43 +733,12 @@ crate struct Module { crate span: Span, } -crate struct ListAttributesIter<'a> { - attrs: slice::Iter<'a, ast::Attribute>, - current_list: vec::IntoIter<ast::NestedMetaItem>, - name: Symbol, -} - -impl<'a> Iterator for ListAttributesIter<'a> { - type Item = ast::NestedMetaItem; - - fn next(&mut self) -> Option<Self::Item> { - if let Some(nested) = self.current_list.next() { - return Some(nested); - } - - for attr in &mut self.attrs { - if let Some(list) = attr.meta_item_list() { - if attr.has_name(self.name) { - self.current_list = list.into_iter(); - if let Some(nested) = self.current_list.next() { - return Some(nested); - } - } - } - } - - None - } - - fn size_hint(&self) -> (usize, Option<usize>) { - let lower = self.current_list.len(); - (lower, None) - } -} - crate trait AttributesExt { - /// Finds an attribute as List and returns the list of attributes nested inside. - fn lists(&self, name: Symbol) -> ListAttributesIter<'_>; + type AttributeIterator<'a>: Iterator<Item = ast::NestedMetaItem> + where + Self: 'a; + + fn lists<'a>(&'a self, name: Symbol) -> Self::AttributeIterator<'a>; fn span(&self) -> Option<rustc_span::Span>; @@ -781,8 +750,13 @@ crate trait AttributesExt { } impl AttributesExt for [ast::Attribute] { - fn lists(&self, name: Symbol) -> ListAttributesIter<'_> { - ListAttributesIter { attrs: self.iter(), current_list: Vec::new().into_iter(), name } + type AttributeIterator<'a> = impl Iterator<Item = ast::NestedMetaItem> + 'a; + + fn lists<'a>(&'a self, name: Symbol) -> Self::AttributeIterator<'a> { + self.iter() + .filter(move |attr| attr.has_name(name)) + .filter_map(ast::Attribute::meta_item_list) + .flatten() } /// Return the span of the first doc-comment, if it exists. @@ -902,12 +876,9 @@ crate trait NestedAttributesExt { fn get_word_attr(self, word: Symbol) -> Option<ast::NestedMetaItem>; } -impl<I> NestedAttributesExt for I -where - I: IntoIterator<Item = ast::NestedMetaItem>, -{ - fn get_word_attr(self, word: Symbol) -> Option<ast::NestedMetaItem> { - self.into_iter().find(|attr| attr.is_word() && attr.has_name(word)) +impl<I: Iterator<Item = ast::NestedMetaItem>> NestedAttributesExt for I { + fn get_word_attr(mut self, word: Symbol) -> Option<ast::NestedMetaItem> { + self.find(|attr| attr.is_word() && attr.has_name(word)) } } @@ -1015,7 +986,7 @@ crate struct Attributes { } impl Attributes { - crate fn lists(&self, name: Symbol) -> ListAttributesIter<'_> { + crate fn lists(&self, name: Symbol) -> impl Iterator<Item = ast::NestedMetaItem> + '_ { self.other_attrs.lists(name) } @@ -2223,7 +2194,7 @@ impl Impl { self.trait_ .as_ref() .map(|t| t.def_id()) - .map(|did| tcx.provided_trait_methods(did).map(|meth| meth.ident.name).collect()) + .map(|did| tcx.provided_trait_methods(did).map(|meth| meth.name).collect()) .unwrap_or_default() } } diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 645c0aba6ac..4c79218f62a 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -484,6 +484,10 @@ nav.sub { overflow: hidden; } +.sidebar-links a { + white-space: nowrap; +} + .sidebar h2 { border-bottom: none; font-weight: 500; diff --git a/src/librustdoc/html/static/css/themes/light.css b/src/librustdoc/html/static/css/themes/light.css index c1fbbd02ec2..edb346c23b4 100644 --- a/src/librustdoc/html/static/css/themes/light.css +++ b/src/librustdoc/html/static/css/themes/light.css @@ -167,7 +167,7 @@ a.result-keyword:focus { background-color: #afc6e4; } .sidebar a.current.traitalias { color: #4b349e; } .sidebar a.current.fn, .sidebar a.current.method, -.sidebar a.current.tymethod { color: #32d479; } +.sidebar a.current.tymethod { color: #a67736; } .sidebar a.current.keyword { color: #356da4; } nav.main .current { diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index d854aa86b3a..a7c3c0bb606 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -16,6 +16,8 @@ #![feature(once_cell)] #![feature(type_ascription)] #![feature(iter_intersperse)] +#![feature(type_alias_impl_trait)] +#![feature(generic_associated_types)] #![recursion_limit = "256"] #![warn(rustc::internal)] #![allow(clippy::collapsible_if, clippy::collapsible_else_if)] diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 1d34e868781..e1747f3e392 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -427,7 +427,7 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> { .inherent_impls(did) .iter() .flat_map(|imp| tcx.associated_items(*imp).in_definition_order()) - .any(|item| item.ident.name == variant_name) + .any(|item| item.name == variant_name) { // This is just to let `fold_item` know that this shouldn't be considered; // it's a bug for the error to make it to the user diff --git a/src/test/rustdoc-gui/sidebar.goml b/src/test/rustdoc-gui/sidebar.goml index ae198e41742..ef3a92ad7a6 100644 --- a/src/test/rustdoc-gui/sidebar.goml +++ b/src/test/rustdoc-gui/sidebar.goml @@ -74,3 +74,7 @@ assert-text: (".sidebar > .location", "Module sub_sub_module") assert-false: ".sidebar-elems .crate" assert-text: (".sidebar-elems .items > ul > li:nth-child(1)", "Functions") assert-text: ("#functions + .item-table .item-left > a", "foo") + +// Links to trait implementations in the sidebar should not wrap even if they are long. +goto: file://|DOC_PATH|/lib2/struct.HasALongTraitWithParams.html +assert-property: (".sidebar-links a", {"offsetHeight": 29}) diff --git a/src/test/rustdoc-gui/src/lib2/lib.rs b/src/test/rustdoc-gui/src/lib2/lib.rs index 73013c9778f..5b6d236e8e0 100644 --- a/src/test/rustdoc-gui/src/lib2/lib.rs +++ b/src/test/rustdoc-gui/src/lib2/lib.rs @@ -114,3 +114,9 @@ pub mod too_long { pub fn foo(&self) {} } } + +pub struct HasALongTraitWithParams {} + +pub trait LongTraitWithParamsBananaBananaBanana<T> {} + +impl LongTraitWithParamsBananaBananaBanana<usize> for HasALongTraitWithParams {} diff --git a/src/test/ui/cfg/future-compat-crate-attributes-using-cfg_attr.rs b/src/test/ui/cfg/future-compat-crate-attributes-using-cfg_attr.rs index ef12b05fab2..6cb2ff9d813 100644 --- a/src/test/ui/cfg/future-compat-crate-attributes-using-cfg_attr.rs +++ b/src/test/ui/cfg/future-compat-crate-attributes-using-cfg_attr.rs @@ -5,8 +5,12 @@ #![cfg_attr(foo, crate_type="bin")] //~^ERROR `crate_type` within //~| WARN this was previously accepted +//~|ERROR `crate_type` within +//~| WARN this was previously accepted #![cfg_attr(foo, crate_name="bar")] //~^ERROR `crate_name` within //~| WARN this was previously accepted +//~|ERROR `crate_name` within +//~| WARN this was previously accepted fn main() {} diff --git a/src/test/ui/cfg/future-compat-crate-attributes-using-cfg_attr.stderr b/src/test/ui/cfg/future-compat-crate-attributes-using-cfg_attr.stderr index 5df2eacc96e..5609f8e9d9f 100644 --- a/src/test/ui/cfg/future-compat-crate-attributes-using-cfg_attr.stderr +++ b/src/test/ui/cfg/future-compat-crate-attributes-using-cfg_attr.stderr @@ -14,7 +14,7 @@ LL | #![deny(warnings)] = note: for more information, see issue #91632 <https://github.com/rust-lang/rust/issues/91632> error: `crate_name` within an `#![cfg_attr] attribute is deprecated` - --> $DIR/future-compat-crate-attributes-using-cfg_attr.rs:8:18 + --> $DIR/future-compat-crate-attributes-using-cfg_attr.rs:10:18 | LL | #![cfg_attr(foo, crate_name="bar")] | ^^^^^^^^^^^^^^^^ @@ -22,5 +22,23 @@ LL | #![cfg_attr(foo, crate_name="bar")] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #91632 <https://github.com/rust-lang/rust/issues/91632> -error: aborting due to 2 previous errors +error: `crate_type` within an `#![cfg_attr] attribute is deprecated` + --> $DIR/future-compat-crate-attributes-using-cfg_attr.rs:5:18 + | +LL | #![cfg_attr(foo, crate_type="bin")] + | ^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #91632 <https://github.com/rust-lang/rust/issues/91632> + +error: `crate_name` within an `#![cfg_attr] attribute is deprecated` + --> $DIR/future-compat-crate-attributes-using-cfg_attr.rs:10:18 + | +LL | #![cfg_attr(foo, crate_name="bar")] + | ^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #91632 <https://github.com/rust-lang/rust/issues/91632> + +error: aborting due to 4 previous errors diff --git a/src/test/ui/parser/issues/issue-93282.rs b/src/test/ui/parser/issues/issue-93282.rs new file mode 100644 index 00000000000..7be8b25363e --- /dev/null +++ b/src/test/ui/parser/issues/issue-93282.rs @@ -0,0 +1,4 @@ +fn main() { + f<'a,> + //~^ ERROR expected +} diff --git a/src/test/ui/parser/issues/issue-93282.stderr b/src/test/ui/parser/issues/issue-93282.stderr new file mode 100644 index 00000000000..20e6c3ed8a8 --- /dev/null +++ b/src/test/ui/parser/issues/issue-93282.stderr @@ -0,0 +1,13 @@ +error: expected one of `.`, `:`, `;`, `?`, `for`, `loop`, `while`, `{`, `}`, or an operator, found `,` + --> $DIR/issue-93282.rs:2:9 + | +LL | f<'a,> + | ^ expected one of 10 possible tokens + | +help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments + | +LL | f::<'a,> + | ++ + +error: aborting due to previous error + diff --git a/src/test/ui/proc-macro/issue-73933-procedural-masquerade.rs b/src/test/ui/proc-macro/issue-73933-procedural-masquerade.rs index 113235051b2..0c1c51c01a8 100644 --- a/src/test/ui/proc-macro/issue-73933-procedural-masquerade.rs +++ b/src/test/ui/proc-macro/issue-73933-procedural-masquerade.rs @@ -4,7 +4,14 @@ extern crate test_macros; #[derive(Print)] -enum ProceduralMasqueradeDummyType { //~ ERROR using +enum ProceduralMasqueradeDummyType { +//~^ ERROR using +//~| WARN this was previously +//~| ERROR using +//~| WARN this was previously +//~| ERROR using +//~| WARN this was previously +//~| ERROR using //~| WARN this was previously Input } diff --git a/src/test/ui/proc-macro/issue-73933-procedural-masquerade.stderr b/src/test/ui/proc-macro/issue-73933-procedural-masquerade.stderr index dff71c9eacd..554613be65a 100644 --- a/src/test/ui/proc-macro/issue-73933-procedural-masquerade.stderr +++ b/src/test/ui/proc-macro/issue-73933-procedural-masquerade.stderr @@ -9,7 +9,37 @@ LL | enum ProceduralMasqueradeDummyType { = note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125> = note: The `procedural-masquerade` crate has been unnecessary since Rust 1.30.0. Versions of this crate below 0.1.7 will eventually stop compiling. -error: aborting due to previous error +error: using `procedural-masquerade` crate + --> $DIR/issue-73933-procedural-masquerade.rs:7:6 + | +LL | enum ProceduralMasqueradeDummyType { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125> + = note: The `procedural-masquerade` crate has been unnecessary since Rust 1.30.0. Versions of this crate below 0.1.7 will eventually stop compiling. + +error: using `procedural-masquerade` crate + --> $DIR/issue-73933-procedural-masquerade.rs:7:6 + | +LL | enum ProceduralMasqueradeDummyType { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125> + = note: The `procedural-masquerade` crate has been unnecessary since Rust 1.30.0. Versions of this crate below 0.1.7 will eventually stop compiling. + +error: using `procedural-masquerade` crate + --> $DIR/issue-73933-procedural-masquerade.rs:7:6 + | +LL | enum ProceduralMasqueradeDummyType { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125> + = note: The `procedural-masquerade` crate has been unnecessary since Rust 1.30.0. Versions of this crate below 0.1.7 will eventually stop compiling. + +error: aborting due to 4 previous errors Future incompatibility report: Future breakage diagnostic: error: using `procedural-masquerade` crate @@ -23,3 +53,36 @@ LL | enum ProceduralMasqueradeDummyType { = note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125> = note: The `procedural-masquerade` crate has been unnecessary since Rust 1.30.0. Versions of this crate below 0.1.7 will eventually stop compiling. +Future breakage diagnostic: +error: using `procedural-masquerade` crate + --> $DIR/issue-73933-procedural-masquerade.rs:7:6 + | +LL | enum ProceduralMasqueradeDummyType { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125> + = note: The `procedural-masquerade` crate has been unnecessary since Rust 1.30.0. Versions of this crate below 0.1.7 will eventually stop compiling. + +Future breakage diagnostic: +error: using `procedural-masquerade` crate + --> $DIR/issue-73933-procedural-masquerade.rs:7:6 + | +LL | enum ProceduralMasqueradeDummyType { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125> + = note: The `procedural-masquerade` crate has been unnecessary since Rust 1.30.0. Versions of this crate below 0.1.7 will eventually stop compiling. + +Future breakage diagnostic: +error: using `procedural-masquerade` crate + --> $DIR/issue-73933-procedural-masquerade.rs:7:6 + | +LL | enum ProceduralMasqueradeDummyType { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125> + = note: The `procedural-masquerade` crate has been unnecessary since Rust 1.30.0. Versions of this crate below 0.1.7 will eventually stop compiling. + diff --git a/src/test/ui/proc-macro/issue-73933-procedural-masquerade.stdout b/src/test/ui/proc-macro/issue-73933-procedural-masquerade.stdout index 8a8fbf06824..50334589d0b 100644 --- a/src/test/ui/proc-macro/issue-73933-procedural-masquerade.stdout +++ b/src/test/ui/proc-macro/issue-73933-procedural-masquerade.stdout @@ -14,9 +14,9 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ stream: TokenStream [ Ident { ident: "Input", - span: #0 bytes(173..178), + span: #0 bytes(315..320), }, ], - span: #0 bytes(121..180), + span: #0 bytes(121..322), }, ] diff --git a/src/test/ui/proc-macro/issue-75930-derive-cfg.stderr b/src/test/ui/proc-macro/issue-75930-derive-cfg.stderr index 25f36108001..69d72b55cdf 100644 --- a/src/test/ui/proc-macro/issue-75930-derive-cfg.stderr +++ b/src/test/ui/proc-macro/issue-75930-derive-cfg.stderr @@ -11,5 +11,17 @@ LL | #[derive(Print)] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202> -warning: 1 warning emitted +warning: derive helper attribute is used before it is introduced + --> $DIR/issue-75930-derive-cfg.rs:19:3 + | +LL | #[print_helper(a)] + | ^^^^^^^^^^^^ +... +LL | #[derive(Print)] + | ----- the attribute is introduced here + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202> + +warning: 2 warnings emitted diff --git a/src/test/ui/rust-2018/edition-lint-nested-empty-paths.fixed b/src/test/ui/rust-2018/edition-lint-nested-empty-paths.fixed index 03d15cea280..acb0aa420ab 100644 --- a/src/test/ui/rust-2018/edition-lint-nested-empty-paths.fixed +++ b/src/test/ui/rust-2018/edition-lint-nested-empty-paths.fixed @@ -17,14 +17,28 @@ crate mod foo { use crate::foo::{bar::{baz::{}}}; //~^ ERROR absolute paths must start with //~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition use crate::foo::{bar::{XX, baz::{}}}; //~^ ERROR absolute paths must start with //~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition use crate::foo::{bar::{baz::{}, baz1::{}}}; //~^ ERROR absolute paths must start with //~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition fn main() { } diff --git a/src/test/ui/rust-2018/edition-lint-nested-empty-paths.rs b/src/test/ui/rust-2018/edition-lint-nested-empty-paths.rs index d898daaba59..4825528e97f 100644 --- a/src/test/ui/rust-2018/edition-lint-nested-empty-paths.rs +++ b/src/test/ui/rust-2018/edition-lint-nested-empty-paths.rs @@ -17,14 +17,28 @@ crate mod foo { use foo::{bar::{baz::{}}}; //~^ ERROR absolute paths must start with //~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition use foo::{bar::{XX, baz::{}}}; //~^ ERROR absolute paths must start with //~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition use foo::{bar::{baz::{}, baz1::{}}}; //~^ ERROR absolute paths must start with //~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| WARN this is accepted in the current edition fn main() { } diff --git a/src/test/ui/rust-2018/edition-lint-nested-empty-paths.stderr b/src/test/ui/rust-2018/edition-lint-nested-empty-paths.stderr index 54a4fed5cf9..8a3113729b4 100644 --- a/src/test/ui/rust-2018/edition-lint-nested-empty-paths.stderr +++ b/src/test/ui/rust-2018/edition-lint-nested-empty-paths.stderr @@ -13,7 +13,16 @@ LL | #![deny(absolute_paths_not_starting_with_crate)] = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-nested-empty-paths.rs:21:5 + --> $DIR/edition-lint-nested-empty-paths.rs:17:5 + | +LL | use foo::{bar::{baz::{}}}; + | ^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}}}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-empty-paths.rs:23:5 | LL | use foo::{bar::{XX, baz::{}}}; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}` @@ -22,7 +31,61 @@ LL | use foo::{bar::{XX, baz::{}}}; = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-nested-empty-paths.rs:25:5 + --> $DIR/edition-lint-nested-empty-paths.rs:23:5 + | +LL | use foo::{bar::{XX, baz::{}}}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-empty-paths.rs:23:5 + | +LL | use foo::{bar::{XX, baz::{}}}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-empty-paths.rs:23:5 + | +LL | use foo::{bar::{XX, baz::{}}}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-empty-paths.rs:33:5 + | +LL | use foo::{bar::{baz::{}, baz1::{}}}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-empty-paths.rs:33:5 + | +LL | use foo::{bar::{baz::{}, baz1::{}}}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-empty-paths.rs:33:5 + | +LL | use foo::{bar::{baz::{}, baz1::{}}}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-empty-paths.rs:33:5 | LL | use foo::{bar::{baz::{}, baz1::{}}}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}` @@ -30,5 +93,5 @@ LL | use foo::{bar::{baz::{}, baz1::{}}}; = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> -error: aborting due to 3 previous errors +error: aborting due to 10 previous errors diff --git a/src/test/ui/rust-2018/edition-lint-nested-paths.fixed b/src/test/ui/rust-2018/edition-lint-nested-paths.fixed index 7c6e4a71a37..4eb1184cb6d 100644 --- a/src/test/ui/rust-2018/edition-lint-nested-paths.fixed +++ b/src/test/ui/rust-2018/edition-lint-nested-paths.fixed @@ -6,6 +6,12 @@ use crate::foo::{a, b}; //~^ ERROR absolute paths must start with //~| this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| this is accepted in the current edition mod foo { crate fn a() {} @@ -21,6 +27,10 @@ fn main() { use crate::foo::{self as x, c}; //~^ ERROR absolute paths must start with //~| this is accepted in the current edition + //~| ERROR absolute paths must start with + //~| this is accepted in the current edition + //~| ERROR absolute paths must start with + //~| this is accepted in the current edition x::a(); c(); } diff --git a/src/test/ui/rust-2018/edition-lint-nested-paths.rs b/src/test/ui/rust-2018/edition-lint-nested-paths.rs index 3925f76391a..2a358224d9b 100644 --- a/src/test/ui/rust-2018/edition-lint-nested-paths.rs +++ b/src/test/ui/rust-2018/edition-lint-nested-paths.rs @@ -6,6 +6,12 @@ use foo::{a, b}; //~^ ERROR absolute paths must start with //~| this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| this is accepted in the current edition +//~| ERROR absolute paths must start with +//~| this is accepted in the current edition mod foo { crate fn a() {} @@ -21,6 +27,10 @@ fn main() { use foo::{self as x, c}; //~^ ERROR absolute paths must start with //~| this is accepted in the current edition + //~| ERROR absolute paths must start with + //~| this is accepted in the current edition + //~| ERROR absolute paths must start with + //~| this is accepted in the current edition x::a(); c(); } diff --git a/src/test/ui/rust-2018/edition-lint-nested-paths.stderr b/src/test/ui/rust-2018/edition-lint-nested-paths.stderr index c2f91e342f5..3d596022b0a 100644 --- a/src/test/ui/rust-2018/edition-lint-nested-paths.stderr +++ b/src/test/ui/rust-2018/edition-lint-nested-paths.stderr @@ -13,7 +13,52 @@ LL | #![deny(absolute_paths_not_starting_with_crate)] = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-nested-paths.rs:21:13 + --> $DIR/edition-lint-nested-paths.rs:6:5 + | +LL | use foo::{a, b}; + | ^^^^^^^^^^^ help: use `crate`: `crate::foo::{a, b}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-paths.rs:6:5 + | +LL | use foo::{a, b}; + | ^^^^^^^^^^^ help: use `crate`: `crate::foo::{a, b}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-paths.rs:6:5 + | +LL | use foo::{a, b}; + | ^^^^^^^^^^^ help: use `crate`: `crate::foo::{a, b}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-paths.rs:27:13 + | +LL | use foo::{self as x, c}; + | ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-paths.rs:27:13 + | +LL | use foo::{self as x, c}; + | ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-nested-paths.rs:27:13 | LL | use foo::{self as x, c}; | ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}` @@ -21,5 +66,5 @@ LL | use foo::{self as x, c}; = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> -error: aborting due to 2 previous errors +error: aborting due to 7 previous errors diff --git a/src/test/ui/rust-2018/edition-lint-paths.fixed b/src/test/ui/rust-2018/edition-lint-paths.fixed index f91405929ee..46adf02a391 100644 --- a/src/test/ui/rust-2018/edition-lint-paths.fixed +++ b/src/test/ui/rust-2018/edition-lint-paths.fixed @@ -12,17 +12,25 @@ pub mod foo { use crate::bar::Bar; //~^ ERROR absolute //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition + use super::bar::Bar2; use crate::bar::Bar3; use crate::bar; //~^ ERROR absolute //~| WARN this is accepted in the current edition + use crate::bar as something_else; use crate::{main, Bar as SomethingElse}; //~^ ERROR absolute //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition use crate::{main as another_main, Bar as SomethingElse2}; @@ -34,6 +42,8 @@ pub mod foo { use crate::bar::Bar; //~^ ERROR absolute //~| WARN this is accepted in the current edition +//~| ERROR absolute +//~| WARN this is accepted in the current edition pub mod bar { use edition_lint_paths as foo; @@ -51,11 +61,14 @@ mod baz { impl crate::foo::SomeTrait for u32 {} //~^ ERROR absolute //~| WARN this is accepted in the current edition +//~| ERROR absolute +//~| WARN this is accepted in the current edition fn main() { let x = crate::bar::Bar; //~^ ERROR absolute //~| WARN this is accepted in the current edition + let x = bar::Bar; let x = crate::bar::Bar; let x = self::bar::Bar; diff --git a/src/test/ui/rust-2018/edition-lint-paths.rs b/src/test/ui/rust-2018/edition-lint-paths.rs index 52c97c7a253..f70bf90d681 100644 --- a/src/test/ui/rust-2018/edition-lint-paths.rs +++ b/src/test/ui/rust-2018/edition-lint-paths.rs @@ -12,17 +12,25 @@ pub mod foo { use bar::Bar; //~^ ERROR absolute //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition + use super::bar::Bar2; use crate::bar::Bar3; use bar; //~^ ERROR absolute //~| WARN this is accepted in the current edition + use crate::bar as something_else; use {main, Bar as SomethingElse}; //~^ ERROR absolute //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition + //~| ERROR absolute + //~| WARN this is accepted in the current edition use crate::{main as another_main, Bar as SomethingElse2}; @@ -34,6 +42,8 @@ pub mod foo { use bar::Bar; //~^ ERROR absolute //~| WARN this is accepted in the current edition +//~| ERROR absolute +//~| WARN this is accepted in the current edition pub mod bar { use edition_lint_paths as foo; @@ -51,11 +61,14 @@ mod baz { impl ::foo::SomeTrait for u32 {} //~^ ERROR absolute //~| WARN this is accepted in the current edition +//~| ERROR absolute +//~| WARN this is accepted in the current edition fn main() { let x = ::bar::Bar; //~^ ERROR absolute //~| WARN this is accepted in the current edition + let x = bar::Bar; let x = crate::bar::Bar; let x = self::bar::Bar; diff --git a/src/test/ui/rust-2018/edition-lint-paths.stderr b/src/test/ui/rust-2018/edition-lint-paths.stderr index 23deeda14a4..481c68e1033 100644 --- a/src/test/ui/rust-2018/edition-lint-paths.stderr +++ b/src/test/ui/rust-2018/edition-lint-paths.stderr @@ -13,7 +13,16 @@ LL | #![deny(absolute_paths_not_starting_with_crate)] = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:18:9 + --> $DIR/edition-lint-paths.rs:12:9 + | +LL | use bar::Bar; + | ^^^^^^^^ help: use `crate`: `crate::bar::Bar` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-paths.rs:21:9 | LL | use bar; | ^^^ help: use `crate`: `crate::bar` @@ -22,7 +31,7 @@ LL | use bar; = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:23:9 + --> $DIR/edition-lint-paths.rs:27:9 | LL | use {main, Bar as SomethingElse}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` @@ -31,7 +40,34 @@ LL | use {main, Bar as SomethingElse}; = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:34:5 + --> $DIR/edition-lint-paths.rs:27:9 + | +LL | use {main, Bar as SomethingElse}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-paths.rs:27:9 + | +LL | use {main, Bar as SomethingElse}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-paths.rs:42:5 + | +LL | use bar::Bar; + | ^^^^^^^^ help: use `crate`: `crate::bar::Bar` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-paths.rs:42:5 | LL | use bar::Bar; | ^^^^^^^^ help: use `crate`: `crate::bar::Bar` @@ -40,7 +76,7 @@ LL | use bar::Bar; = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:46:9 + --> $DIR/edition-lint-paths.rs:56:9 | LL | use *; | ^ help: use `crate`: `crate::*` @@ -49,7 +85,16 @@ LL | use *; = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:51:6 + --> $DIR/edition-lint-paths.rs:61:6 + | +LL | impl ::foo::SomeTrait for u32 {} + | ^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::SomeTrait` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-paths.rs:61:6 | LL | impl ::foo::SomeTrait for u32 {} | ^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::SomeTrait` @@ -58,7 +103,7 @@ LL | impl ::foo::SomeTrait for u32 {} = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-paths.rs:56:13 + --> $DIR/edition-lint-paths.rs:68:13 | LL | let x = ::bar::Bar; | ^^^^^^^^^^ help: use `crate`: `crate::bar::Bar` @@ -66,5 +111,5 @@ LL | let x = ::bar::Bar; = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> -error: aborting due to 7 previous errors +error: aborting due to 12 previous errors diff --git a/src/test/ui/rust-2018/extern-crate-rename.fixed b/src/test/ui/rust-2018/extern-crate-rename.fixed index ea832ef3e7d..05b881a9b08 100644 --- a/src/test/ui/rust-2018/extern-crate-rename.fixed +++ b/src/test/ui/rust-2018/extern-crate-rename.fixed @@ -12,6 +12,8 @@ extern crate edition_lint_paths as my_crate; use crate::my_crate::foo; //~^ ERROR absolute paths must start //~| WARNING this is accepted in the current edition +//~| ERROR absolute paths must start +//~| WARNING this is accepted in the current edition fn main() { foo(); diff --git a/src/test/ui/rust-2018/extern-crate-rename.rs b/src/test/ui/rust-2018/extern-crate-rename.rs index b1f617dd884..6e327be193b 100644 --- a/src/test/ui/rust-2018/extern-crate-rename.rs +++ b/src/test/ui/rust-2018/extern-crate-rename.rs @@ -12,6 +12,8 @@ extern crate edition_lint_paths as my_crate; use my_crate::foo; //~^ ERROR absolute paths must start //~| WARNING this is accepted in the current edition +//~| ERROR absolute paths must start +//~| WARNING this is accepted in the current edition fn main() { foo(); diff --git a/src/test/ui/rust-2018/extern-crate-rename.stderr b/src/test/ui/rust-2018/extern-crate-rename.stderr index 4bccbc51223..f2f379ca396 100644 --- a/src/test/ui/rust-2018/extern-crate-rename.stderr +++ b/src/test/ui/rust-2018/extern-crate-rename.stderr @@ -12,5 +12,14 @@ LL | #![deny(absolute_paths_not_starting_with_crate)] = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> -error: aborting due to previous error +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/extern-crate-rename.rs:12:5 + | +LL | use my_crate::foo; + | ^^^^^^^^^^^^^ help: use `crate`: `crate::my_crate::foo` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: aborting due to 2 previous errors diff --git a/src/test/ui/rust-2018/extern-crate-submod.fixed b/src/test/ui/rust-2018/extern-crate-submod.fixed index 9b0b0dd8ee1..fdbd893abed 100644 --- a/src/test/ui/rust-2018/extern-crate-submod.fixed +++ b/src/test/ui/rust-2018/extern-crate-submod.fixed @@ -19,6 +19,9 @@ mod m { use crate::m::edition_lint_paths::foo; //~^ ERROR absolute paths must start //~| WARNING this is accepted in the current edition +//~| ERROR absolute paths must start +//~| WARNING this is accepted in the current edition + fn main() { foo(); diff --git a/src/test/ui/rust-2018/extern-crate-submod.rs b/src/test/ui/rust-2018/extern-crate-submod.rs index dfce9128c51..c2b915849f0 100644 --- a/src/test/ui/rust-2018/extern-crate-submod.rs +++ b/src/test/ui/rust-2018/extern-crate-submod.rs @@ -19,6 +19,9 @@ mod m { use m::edition_lint_paths::foo; //~^ ERROR absolute paths must start //~| WARNING this is accepted in the current edition +//~| ERROR absolute paths must start +//~| WARNING this is accepted in the current edition + fn main() { foo(); diff --git a/src/test/ui/rust-2018/extern-crate-submod.stderr b/src/test/ui/rust-2018/extern-crate-submod.stderr index 3c75319aeda..c4c3168bc97 100644 --- a/src/test/ui/rust-2018/extern-crate-submod.stderr +++ b/src/test/ui/rust-2018/extern-crate-submod.stderr @@ -12,5 +12,14 @@ LL | #![deny(absolute_paths_not_starting_with_crate)] = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> -error: aborting due to previous error +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/extern-crate-submod.rs:19:5 + | +LL | use m::edition_lint_paths::foo; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::m::edition_lint_paths::foo` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: aborting due to 2 previous errors diff --git a/src/tools/cargo b/src/tools/cargo -Subproject 95bb3c92bf516017e812e7f1c14c2dea3845b30 +Subproject 1c034752de0df744fcd7788fcbca158830b8bf8 diff --git a/src/tools/clippy/clippy_lints/src/same_name_method.rs b/src/tools/clippy/clippy_lints/src/same_name_method.rs index 1bbaa104e60..22b45896955 100644 --- a/src/tools/clippy/clippy_lints/src/same_name_method.rs +++ b/src/tools/clippy/clippy_lints/src/same_name_method.rs @@ -87,7 +87,7 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod { .filter(|assoc_item| { matches!(assoc_item.kind, AssocKind::Fn) }) - .map(|assoc_item| assoc_item.ident.name) + .map(|assoc_item| assoc_item.name) .collect() }else{ BTreeSet::new() |
