diff --git a/compiler/rustc_ast/src/attr/mod.rs b/compiler/rustc_ast/src/attr/mod.rs index 5f17008bdc2b0..927d7c6aaf6a4 100644 --- a/compiler/rustc_ast/src/attr/mod.rs +++ b/compiler/rustc_ast/src/attr/mod.rs @@ -62,7 +62,7 @@ impl NestedMetaItem { self.meta_item().and_then(|meta_item| meta_item.ident()) } pub fn name_or_empty(&self) -> Symbol { - self.ident().unwrap_or_else(Ident::invalid).name + self.ident().unwrap_or_else(Ident::empty).name } /// Gets the string value if `self` is a `MetaItem` and the `MetaItem` is a @@ -131,7 +131,7 @@ impl Attribute { } } pub fn name_or_empty(&self) -> Symbol { - self.ident().unwrap_or_else(Ident::invalid).name + self.ident().unwrap_or_else(Ident::empty).name } pub fn value_str(&self) -> Option { @@ -166,7 +166,7 @@ impl MetaItem { if self.path.segments.len() == 1 { Some(self.path.segments[0].ident) } else { None } } pub fn name_or_empty(&self) -> Symbol { - self.ident().unwrap_or_else(Ident::invalid).name + self.ident().unwrap_or_else(Ident::empty).name } // Example: diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index ba86036577ac5..f673ab2f3efde 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -1060,7 +1060,7 @@ pub fn noop_visit_crate(krate: &mut Crate, vis: &mut T) { let item_vis = Visibility { kind: VisibilityKind::Public, span: span.shrink_to_lo(), tokens: None }; let item = P(Item { - ident: Ident::invalid(), + ident: Ident::empty(), attrs, id: DUMMY_NODE_ID, vis: item_vis, diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 245199e375113..92b482e90ee2f 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1435,7 +1435,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { trace!("registering opaque type with id {:#?}", opaque_ty_id); let opaque_ty_item = hir::Item { def_id: opaque_ty_id, - ident: Ident::invalid(), + ident: Ident::empty(), kind: opaque_ty_item_kind, vis: respan(self.lower_span(span.shrink_to_lo()), hir::VisibilityKind::Inherited), span: self.lower_span(opaque_ty_span), diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index 246d2e3208cf2..d5ff4c6766f0f 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -45,12 +45,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { let item_msg; let reason; let mut opt_source = None; - let access_place_desc = self.describe_place(access_place.as_ref()); + let access_place_desc = self.describe_any_place(access_place.as_ref()); debug!("report_mutability_error: access_place_desc={:?}", access_place_desc); match the_place_err { PlaceRef { local, projection: [] } => { - item_msg = format!("`{}`", access_place_desc.unwrap()); + item_msg = access_place_desc; if access_place.as_local().is_some() { reason = ", as it is not declared as mutable".to_string(); } else { @@ -83,7 +83,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { // If we deref an immutable ref then the suggestion here doesn't help. return; } else { - item_msg = format!("`{}`", access_place_desc.unwrap()); + item_msg = access_place_desc; if self.is_upvar_field_projection(access_place.as_ref()).is_some() { reason = ", as it is not declared as mutable".to_string(); } else { @@ -96,17 +96,17 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { PlaceRef { local, projection: [ProjectionElem::Deref] } if self.body.local_decls[local].is_ref_for_guard() => { - item_msg = format!("`{}`", access_place_desc.unwrap()); + item_msg = access_place_desc; reason = ", as it is immutable for the pattern guard".to_string(); } PlaceRef { local, projection: [ProjectionElem::Deref] } if self.body.local_decls[local].is_ref_to_static() => { if access_place.projection.len() == 1 { - item_msg = format!("immutable static item `{}`", access_place_desc.unwrap()); + item_msg = format!("immutable static item {}", access_place_desc); reason = String::new(); } else { - item_msg = format!("`{}`", access_place_desc.unwrap()); + item_msg = access_place_desc; let local_info = &self.body.local_decls[local].local_info; if let Some(box LocalInfo::StaticRef { def_id, .. }) = *local_info { let static_name = &self.infcx.tcx.item_name(def_id); @@ -121,7 +121,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { && proj_base.is_empty() && !self.upvars.is_empty() { - item_msg = format!("`{}`", access_place_desc.unwrap()); + item_msg = access_place_desc; debug_assert!( self.body.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty.is_region_ptr() ); @@ -147,7 +147,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { }); let pointer_type = source.describe_for_immutable_place(self.infcx.tcx); opt_source = Some(source); - if let Some(desc) = access_place_desc { + if let Some(desc) = self.describe_place(access_place.as_ref()) { item_msg = format!("`{}`", desc); reason = match error_access { AccessKind::Mutate => format!(", which is behind {}", pointer_type), diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs index c032364c008f3..198287f608e39 100644 --- a/compiler/rustc_builtin_macros/src/asm.rs +++ b/compiler/rustc_builtin_macros/src/asm.rs @@ -812,7 +812,7 @@ pub fn expand_global_asm<'cx>( Ok(args) => { if let Some(inline_asm) = expand_preparsed_asm(ecx, args) { MacEager::items(smallvec![P(ast::Item { - ident: Ident::invalid(), + ident: Ident::empty(), attrs: Vec::new(), id: ast::DUMMY_NODE_ID, kind: ast::ItemKind::GlobalAsm(inline_asm), diff --git a/compiler/rustc_builtin_macros/src/derive.rs b/compiler/rustc_builtin_macros/src/derive.rs index 241c90c157125..31a35b9b7b45e 100644 --- a/compiler/rustc_builtin_macros/src/derive.rs +++ b/compiler/rustc_builtin_macros/src/derive.rs @@ -85,7 +85,7 @@ impl MultiItemModifier for Expander { fn dummy_annotatable() -> Annotatable { Annotatable::GenericParam(ast::GenericParam { id: ast::DUMMY_NODE_ID, - ident: Ident::invalid(), + ident: Ident::empty(), attrs: Default::default(), bounds: Default::default(), is_placeholder: false, diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index cd78c016caa4f..a225b328ab6a4 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -724,7 +724,7 @@ impl<'a> TraitDef<'a> { cx.item( self.span, - Ident::invalid(), + Ident::empty(), a, ast::ItemKind::Impl(Box::new(ast::ImplKind { unsafety, diff --git a/compiler/rustc_builtin_macros/src/deriving/mod.rs b/compiler/rustc_builtin_macros/src/deriving/mod.rs index bcf95719db56b..fa389a5111578 100644 --- a/compiler/rustc_builtin_macros/src/deriving/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/mod.rs @@ -178,7 +178,7 @@ fn inject_impl_of_structural_trait( let newitem = cx.item( span, - Ident::invalid(), + Ident::empty(), attrs, ItemKind::Impl(Box::new(ImplKind { unsafety: ast::Unsafe::No, diff --git a/compiler/rustc_builtin_macros/src/standard_library_imports.rs b/compiler/rustc_builtin_macros/src/standard_library_imports.rs index e0d57267525d9..e106f6014a31d 100644 --- a/compiler/rustc_builtin_macros/src/standard_library_imports.rs +++ b/compiler/rustc_builtin_macros/src/standard_library_imports.rs @@ -77,7 +77,7 @@ pub fn inject( let use_item = cx.item( span, - Ident::invalid(), + Ident::empty(), vec![cx.attribute(cx.meta_word(span, sym::prelude_import))], ast::ItemKind::Use(ast::UseTree { prefix: cx.path(span, import_path), diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index f548e2848a771..65f0719ba99c2 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -383,7 +383,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { Unsafe::No, ModKind::Loaded(krate.items, Inline::Yes, krate.span) ), - ident: Ident::invalid(), + ident: Ident::empty(), id: ast::DUMMY_NODE_ID, vis: ast::Visibility { span: krate.span.shrink_to_lo(), @@ -1426,7 +1426,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { _ => unreachable!(), }) } - ast::ItemKind::Mod(_, ref mut mod_kind) if ident != Ident::invalid() => { + ast::ItemKind::Mod(_, ref mut mod_kind) if ident != Ident::empty() => { let (file_path, dir_path, dir_ownership) = match mod_kind { ModKind::Loaded(_, inline, _) => { // Inline `mod foo { ... }`, but we still need to push directories. @@ -1508,7 +1508,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { _ => { item.attrs = attrs; // The crate root is special - don't assign an ID to it. - if !(matches!(item.kind, ast::ItemKind::Mod(..)) && ident == Ident::invalid()) { + if !(matches!(item.kind, ast::ItemKind::Mod(..)) && ident == Ident::empty()) { assign_id!(self, &mut item.id, || noop_flat_map_item(item, self)) } else { noop_flat_map_item(item, self) diff --git a/compiler/rustc_expand/src/mbe/quoted.rs b/compiler/rustc_expand/src/mbe/quoted.rs index 363cc72b52c3e..dedc6c618b9a4 100644 --- a/compiler/rustc_expand/src/mbe/quoted.rs +++ b/compiler/rustc_expand/src/mbe/quoted.rs @@ -204,7 +204,7 @@ fn parse_tree( pprust::token_to_string(&token), ); sess.span_diagnostic.span_err(token.span, &msg); - TokenTree::MetaVar(token.span, Ident::invalid()) + TokenTree::MetaVar(token.span, Ident::empty()) } // There are no more tokens. Just return the `$` we already have. diff --git a/compiler/rustc_expand/src/placeholders.rs b/compiler/rustc_expand/src/placeholders.rs index 8e78fcbb8dbc1..12b6bc7bbe768 100644 --- a/compiler/rustc_expand/src/placeholders.rs +++ b/compiler/rustc_expand/src/placeholders.rs @@ -23,7 +23,7 @@ pub fn placeholder( } } - let ident = Ident::invalid(); + let ident = Ident::empty(); let attrs = Vec::new(); let vis = vis.unwrap_or(ast::Visibility { span: DUMMY_SP, diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 11d0178e93ba4..f0ee21645f3c1 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -121,7 +121,7 @@ impl LifetimeName { match *self { LifetimeName::ImplicitObjectLifetimeDefault | LifetimeName::Implicit - | LifetimeName::Error => Ident::invalid(), + | LifetimeName::Error => Ident::empty(), LifetimeName::Underscore => Ident::with_dummy_span(kw::UnderscoreLifetime), LifetimeName::Static => Ident::with_dummy_span(kw::StaticLifetime), LifetimeName::Param(param_name) => param_name.ident(), @@ -233,7 +233,7 @@ impl<'hir> PathSegment<'hir> { } pub fn invalid() -> Self { - Self::from_ident(Ident::invalid()) + Self::from_ident(Ident::empty()) } pub fn args(&self) -> &GenericArgs<'hir> { @@ -310,7 +310,7 @@ impl GenericArg<'_> { } pub fn is_synthetic(&self) -> bool { - matches!(self, GenericArg::Lifetime(lifetime) if lifetime.name.ident() == Ident::invalid()) + matches!(self, GenericArg::Lifetime(lifetime) if lifetime.name.ident() == Ident::empty()) } pub fn descr(&self) -> &'static str { diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 57c1c8f3ecb5c..c228ecb03fdec 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -657,6 +657,24 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc { return; } + // If the method is an impl for an item with docs_hidden, don't doc. + if method_context(cx, impl_item.hir_id()) == MethodLateContext::PlainImpl { + let parent = cx.tcx.hir().get_parent_did(impl_item.hir_id()); + let impl_ty = cx.tcx.type_of(parent); + let outerdef = match impl_ty.kind() { + ty::Adt(def, _) => Some(def.did), + ty::Foreign(def_id) => Some(*def_id), + _ => None, + }; + let is_hidden = match outerdef { + Some(id) => cx.tcx.is_doc_hidden(id), + None => false, + }; + if is_hidden { + return; + } + } + let (article, desc) = cx.tcx.article_and_description(impl_item.def_id.to_def_id()); self.check_missing_docs_attrs(cx, impl_item.def_id, impl_item.span, article, desc); } diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index a93d18950dba9..f35ca2659fd65 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -1957,7 +1957,7 @@ declare_lint! { /// [issue #50504]: https://github.com/rust-lang/rust/issues/50504 /// [future-incompatible]: ../index.md#future-incompatible-lints pub PROC_MACRO_DERIVE_RESOLUTION_FALLBACK, - Warn, + Deny, "detects proc macro derives using inaccessible names from parent modules", @future_incompatible = FutureIncompatibleInfo { reference: "issue #83583 ", @@ -3253,7 +3253,7 @@ declare_lint! { /// [issue #83125]: https://github.com/rust-lang/rust/issues/83125 /// [future-incompatible]: ../index.md#future-incompatible-lints pub PROC_MACRO_BACK_COMPAT, - Warn, + Deny, "detects usage of old versions of certain proc-macro crates", @future_incompatible = FutureIncompatibleInfo { reference: "issue #83125 ", diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index e6f56b0be9303..c30ab4c957a19 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -443,7 +443,7 @@ impl<'hir> Map<'hir> { pub fn body_param_names(&self, id: BodyId) -> impl Iterator + 'hir { self.body(id).params.iter().map(|arg| match arg.pat.kind { PatKind::Binding(_, _, ident, _) => ident, - _ => Ident::new(kw::Empty, rustc_span::DUMMY_SP), + _ => Ident::empty(), }) } diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 624390a406ff2..1d9c3a4f3cf2b 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -216,7 +216,7 @@ impl<'a> Parser<'a> { return Err(e); } - (Ident::invalid(), ItemKind::Use(tree)) + (Ident::empty(), ItemKind::Use(tree)) } else if self.check_fn_front_matter(def_final) { // FUNCTION ITEM let (ident, sig, generics, body) = self.parse_fn(attrs, req_name, lo)?; @@ -287,7 +287,7 @@ impl<'a> Parser<'a> { return Ok(None); } else if macros_allowed && self.check_path() { // MACRO INVOCATION ITEM - (Ident::invalid(), ItemKind::MacCall(self.parse_item_macro(vis)?)) + (Ident::empty(), ItemKind::MacCall(self.parse_item_macro(vis)?)) } else { return Ok(None); }; @@ -586,7 +586,7 @@ impl<'a> Parser<'a> { } }; - Ok((Ident::invalid(), item_kind)) + Ok((Ident::empty(), item_kind)) } fn parse_item_list( @@ -933,7 +933,7 @@ impl<'a> Parser<'a> { let abi = self.parse_abi(); // ABI? let items = self.parse_item_list(attrs, |p| p.parse_foreign_item(ForceCollect::No))?; let module = ast::ForeignMod { unsafety, abi, items }; - Ok((Ident::invalid(), ItemKind::ForeignMod(module))) + Ok((Ident::empty(), ItemKind::ForeignMod(module))) } /// Parses a foreign item (one in an `extern { ... }` block). diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index c4569c07db476..01e751ea8b5bf 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -16,7 +16,7 @@ use rustc_ast::{ }; use rustc_ast::{Block, BlockCheckMode, Expr, ExprKind, Local, Stmt}; use rustc_ast::{StmtKind, DUMMY_NODE_ID}; -use rustc_errors::{Applicability, PResult}; +use rustc_errors::{Applicability, DiagnosticBuilder, PResult}; use rustc_span::source_map::{BytePos, Span}; use rustc_span::symbol::{kw, sym}; @@ -300,6 +300,12 @@ impl<'a> Parser<'a> { None => LocalKind::Decl, Some(init) => { if self.eat_keyword(kw::Else) { + if self.token.is_keyword(kw::If) { + // `let...else if`. Emit the same error that `parse_block()` would, + // but explicitly point out that this pattern is not allowed. + let msg = "conditional `else if` is not supported for `let...else`"; + return Err(self.error_block_no_opening_brace_msg(msg)); + } let els = self.parse_block()?; self.check_let_else_init_bool_expr(&init); self.check_let_else_init_trailing_brace(&init); @@ -392,10 +398,9 @@ impl<'a> Parser<'a> { Ok(block) } - fn error_block_no_opening_brace(&mut self) -> PResult<'a, T> { + fn error_block_no_opening_brace_msg(&mut self, msg: &str) -> DiagnosticBuilder<'a> { let sp = self.token.span; - let tok = super::token_descr(&self.token); - let mut e = self.struct_span_err(sp, &format!("expected `{{`, found {}", tok)); + let mut e = self.struct_span_err(sp, msg); let do_not_suggest_help = self.token.is_keyword(kw::In) || self.token == token::Colon; // Check to see if the user has written something like @@ -435,7 +440,13 @@ impl<'a> Parser<'a> { _ => {} } e.span_label(sp, "expected `{`"); - Err(e) + e + } + + fn error_block_no_opening_brace(&mut self) -> PResult<'a, T> { + let tok = super::token_descr(&self.token); + let msg = format!("expected `{{`, found {}", tok); + Err(self.error_block_no_opening_brace_msg(&msg)) } /// Parses a block. Inner attributes are allowed. diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 05675e086d777..38fb1c760bd4e 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1327,7 +1327,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> { if fst.ident.span.rust_2018() && !fst.ident.is_path_segment_keyword() => { // Insert a placeholder that's later replaced by `self`/`super`/etc. - path.insert(0, Segment::from_ident(Ident::invalid())); + path.insert(0, Segment::from_ident(Ident::empty())); } _ => return None, } diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 515b2c3fd2790..936ab81914a99 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -978,7 +978,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> { // HACK(eddyb) `lint_if_path_starts_with_module` needs at least // 2 segments, so the `resolve_path` above won't trigger it. let mut full_path = import.module_path.clone(); - full_path.push(Segment::from_ident(Ident::invalid())); + full_path.push(Segment::from_ident(Ident::empty())); self.r.lint_if_path_starts_with_module( import.crate_lint(), &full_path, diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 9563325796538..a52dbe4f54024 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -7,7 +7,7 @@ use RibKind::*; -use crate::{path_names_to_string, BindingError, CrateLint, LexicalScopeBinding}; +use crate::{path_names_to_string, BindingError, CrateLint, NameBinding, ToNameBinding}; use crate::{Module, ModuleOrUniformRoot, ParentScope, PathResult}; use crate::{ResolutionError, Resolver, Segment, UseError}; @@ -21,27 +21,22 @@ use rustc_hir::def::Namespace::{self, *}; use rustc_hir::def::{self, CtorKind, DefKind, PartialRes, PerNS}; use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX}; use rustc_hir::{PrimTy, TraitCandidate}; -use rustc_middle::{bug, span_bug}; +use rustc_middle::{bug, span_bug, ty}; use rustc_session::lint; +use rustc_span::source_map::{respan, Spanned}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; -use rustc_span::Span; +use rustc_span::{Span, DUMMY_SP}; use smallvec::{smallvec, SmallVec}; +use tracing::debug; -use rustc_span::source_map::{respan, Spanned}; use std::collections::{hash_map::Entry, BTreeSet}; use std::mem::{replace, take}; -use tracing::debug; mod diagnostics; crate mod lifetimes; type Res = def::Res; -type IdentMap = FxHashMap; - -/// Map from the name in a pattern to its binding mode. -type BindingMap = IdentMap; - #[derive(Copy, Clone, Debug)] struct BindingInfo { span: Span, @@ -172,8 +167,8 @@ impl RibKind<'_> { /// The resolution keeps a separate stack of ribs as it traverses the AST for each namespace. When /// resolving, the name is looked up from inside out. #[derive(Debug)] -crate struct Rib<'a, R = Res> { - pub bindings: IdentMap, +crate struct Rib<'a, R = &'a NameBinding<'a>> { + pub bindings: FxHashMap, pub kind: RibKind<'a>, } @@ -567,12 +562,12 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> { GenericParamKind::Type { .. } => { forward_ty_ban_rib .bindings - .insert(Ident::with_dummy_span(param.ident.name), Res::Err); + .insert(Ident::with_dummy_span(param.ident.name), self.r.dummy_binding); } GenericParamKind::Const { .. } => { forward_const_ban_rib .bindings - .insert(Ident::with_dummy_span(param.ident.name), Res::Err); + .insert(Ident::with_dummy_span(param.ident.name), self.r.dummy_binding); } GenericParamKind::Lifetime => {} } @@ -589,7 +584,9 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> { // such as in the case of `trait Add`.) if self.diagnostic_metadata.current_self_item.is_some() { // (`Some` if + only if we are in ADT's generics.) - forward_ty_ban_rib.bindings.insert(Ident::with_dummy_span(kw::SelfUpper), Res::Err); + forward_ty_ban_rib + .bindings + .insert(Ident::with_dummy_span(kw::SelfUpper), self.r.dummy_binding); } for param in &generics.params { @@ -737,15 +734,17 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { ns: Namespace, record_used_id: Option, path_span: Span, - ) -> Option> { - self.r.resolve_ident_in_lexical_scope( - ident, - ns, - &self.parent_scope, - record_used_id, - path_span, - &self.ribs[ns], - ) + ) -> Option<&'a NameBinding<'a>> { + self.r + .resolve_ident_in_lexical_scope( + ident, + ns, + &self.parent_scope, + record_used_id, + path_span, + &self.ribs[ns], + ) + .ok() } fn resolve_path( @@ -903,6 +902,10 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { } fn future_proof_import(&mut self, use_tree: &UseTree) { + if !self.should_report_errs() { + return; + } + let segments = &use_tree.prefix.segments; if !segments.is_empty() { let ident = segments[0].ident; @@ -914,31 +917,42 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { UseTreeKind::Simple(..) if segments.len() == 1 => &[TypeNS, ValueNS][..], _ => &[TypeNS], }; + + let from_ribs = |binding: &NameBinding<'_>| { + matches!( + binding.res(), + Res::Local(..) + | Res::SelfTy(..) + | Res::Def(DefKind::TyParam | DefKind::ConstParam, ..) + ) + }; let report_error = |this: &Self, ns| { let what = if ns == TypeNS { "type parameters" } else { "local variables" }; - if this.should_report_errs() { - this.r - .session - .span_err(ident.span, &format!("imports cannot refer to {}", what)); - } + let msg = format!("imports cannot refer to {what}"); + this.r.session.span_err(ident.span, &msg); }; for &ns in nss { - match self.resolve_ident_in_lexical_scope(ident, ns, None, use_tree.prefix.span) { - Some(LexicalScopeBinding::Res(..)) => { + if let Some(binding) = + self.resolve_ident_in_lexical_scope(ident, ns, None, use_tree.prefix.span) + { + if from_ribs(binding) { report_error(self, ns); - } - Some(LexicalScopeBinding::Item(binding)) => { + } else { let orig_unusable_binding = replace(&mut self.r.unusable_binding, Some(binding)); - if let Some(LexicalScopeBinding::Res(..)) = self - .resolve_ident_in_lexical_scope(ident, ns, None, use_tree.prefix.span) - { - report_error(self, ns); + if let Some(binding) = self.resolve_ident_in_lexical_scope( + ident, + ns, + None, + use_tree.prefix.span, + ) { + if from_ribs(binding) { + report_error(self, ns); + } } self.r.unusable_binding = orig_unusable_binding; } - None => {} } } } else if let UseTreeKind::Nested(use_trees) = &use_tree.kind { @@ -1135,8 +1149,12 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { _ => unreachable!(), }; let res = Res::Def(def_kind, self.r.local_def_id(param.id).to_def_id()); + let binding = + (res, ty::Visibility::Invisible, param.ident.span, self.parent_scope.expansion) + .to_name_binding(self.r.arenas); + self.r.record_partial_res(param.id, PartialRes::new(res)); - rib.bindings.insert(ident, res); + rib.bindings.insert(ident, binding); } self.ribs[ValueNS].push(function_value_rib); @@ -1256,10 +1274,12 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { } fn with_self_rib_ns(&mut self, ns: Namespace, self_res: Res, f: impl FnOnce(&mut Self)) { + let binding = (self_res, ty::Visibility::Invisible, DUMMY_SP, self.parent_scope.expansion) + .to_name_binding(self.r.arenas); let mut self_type_rib = Rib::new(NormalRibKind); // Plain insert (no renaming, since types are not currently hygienic) - self_type_rib.bindings.insert(Ident::with_dummy_span(kw::SelfUpper), self_res); + self_type_rib.bindings.insert(Ident::with_dummy_span(kw::SelfUpper), binding); self.ribs[ns].push(self_type_rib); f(self); self.ribs[ns].pop(); @@ -1470,7 +1490,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { /// this is done hygienically. This could arise for a macro /// that expands into an or-pattern where one 'x' was from the /// user and one 'x' came from the macro. - fn binding_mode_map(&mut self, pat: &Pat) -> BindingMap { + fn binding_mode_map(&mut self, pat: &Pat) -> FxHashMap { let mut binding_map = FxHashMap::default(); pat.walk(&mut |pat| { @@ -1503,7 +1523,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { /// Checks that all of the arms in an or-pattern have exactly the /// same set of bindings, with the same binding modes for each. - fn check_consistent_bindings(&mut self, pats: &[P]) -> Vec { + fn check_consistent_bindings(&mut self, pats: &[P]) -> Vec> { let mut missing_vars = FxHashMap::default(); let mut inconsistent_vars = FxHashMap::default(); @@ -1645,7 +1665,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { .try_resolve_as_non_binding(pat_src, pat, bmode, ident, has_sub) .unwrap_or_else(|| self.fresh_binding(ident, pat.id, pat_src, bindings)); self.r.record_partial_res(pat.id, PartialRes::new(res)); - self.r.record_pat_span(pat.id, pat.span); } PatKind::TupleStruct(ref qself, ref path, ref sub_patterns) => { self.smart_resolve_path( @@ -1735,18 +1754,24 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { if already_bound_or { // `Variant1(a) | Variant2(a)`, ok // Reuse definition from the first `a`. - self.innermost_rib_bindings(ValueNS)[&ident] + self.innermost_rib_bindings(ValueNS)[&ident].res() } else { let res = Res::Local(pat_id); if ident_valid { // A completely fresh binding add to the set if it's valid. - self.innermost_rib_bindings(ValueNS).insert(ident, res); + let binding = + (res, ty::Visibility::Invisible, ident.span, self.parent_scope.expansion) + .to_name_binding(self.r.arenas); + self.innermost_rib_bindings(ValueNS).insert(ident, binding); } res } } - fn innermost_rib_bindings(&mut self, ns: Namespace) -> &mut IdentMap { + fn innermost_rib_bindings( + &mut self, + ns: Namespace, + ) -> &mut FxHashMap> { &mut self.ribs[ns].last_mut().unwrap().bindings } @@ -1763,22 +1788,17 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { // also be interpreted as a path to e.g. a constant, variant, etc. let is_syntactic_ambiguity = !has_sub && bm == BindingMode::ByValue(Mutability::Not); - let ls_binding = self.resolve_ident_in_lexical_scope(ident, ValueNS, None, pat.span)?; - let (res, binding) = match ls_binding { - LexicalScopeBinding::Item(binding) - if is_syntactic_ambiguity && binding.is_ambiguity() => - { - // For ambiguous bindings we don't know all their definitions and cannot check - // whether they can be shadowed by fresh bindings or not, so force an error. - // issues/33118#issuecomment-233962221 (see below) still applies here, - // but we have to ignore it for backward compatibility. - self.r.record_use(ident, binding, false); - return None; - } - LexicalScopeBinding::Item(binding) => (binding.res(), Some(binding)), - LexicalScopeBinding::Res(res) => (res, None), - }; + let binding = self.resolve_ident_in_lexical_scope(ident, ValueNS, None, pat.span)?; + if is_syntactic_ambiguity && binding.is_ambiguity() { + // For ambiguous bindings we don't know all their definitions and cannot check + // whether they can be shadowed by fresh bindings or not, so force an error. + // issues/33118#issuecomment-233962221 (see below) still applies here, + // but we have to ignore it for backward compatibility. + self.r.record_use(ident, binding, false); + return None; + } + let res = binding.res(); match res { Res::SelfCtor(_) // See #70549. | Res::Def( @@ -1786,9 +1806,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { _, ) if is_syntactic_ambiguity => { // Disambiguate in favor of a unit struct/variant or constant pattern. - if let Some(binding) = binding { - self.r.record_use(ident, binding, false); - } + self.r.record_use(ident, binding, false); Some(res) } Res::Def(DefKind::Ctor(..) | DefKind::Const | DefKind::Static, _) => { @@ -1797,7 +1815,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { // to something unusable as a pattern (e.g., constructor function), // but we still conservatively report an error, see // issues/33118#issuecomment-233962221 for one reason why. - let binding = binding.expect("no binding for a ctor or static"); self.report_error( ident.span, ResolutionError::BindingShadowsSomethingUnacceptable { @@ -2037,19 +2054,15 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { } fn self_type_is_available(&mut self, span: Span) -> bool { - let binding = self.resolve_ident_in_lexical_scope( - Ident::with_dummy_span(kw::SelfUpper), - TypeNS, - None, - span, - ); - if let Some(LexicalScopeBinding::Res(res)) = binding { res != Res::Err } else { false } + let ident = Ident::with_dummy_span(kw::SelfUpper); + self.resolve_ident_in_lexical_scope(ident, TypeNS, None, span) + .map_or(false, |binding| binding.res() != Res::Err) } fn self_value_is_available(&mut self, self_span: Span, path_span: Span) -> bool { let ident = Ident::new(kw::SelfLower, self_span); - let binding = self.resolve_ident_in_lexical_scope(ident, ValueNS, None, path_span); - if let Some(LexicalScopeBinding::Res(res)) = binding { res != Res::Err } else { false } + self.resolve_ident_in_lexical_scope(ident, ValueNS, None, path_span) + .map_or(false, |binding| binding.res() != Res::Err) } /// A wrapper around [`Resolver::report_error`]. diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 1748a9be8e13e..506f154975383 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -1294,7 +1294,8 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { // Walk backwards up the ribs in scope and collect candidates. for rib in self.ribs[ns].iter().rev() { // Locals and type parameters - for (ident, &res) in &rib.bindings { + for (ident, binding) in &rib.bindings { + let res = binding.res(); if filter_fn(res) { names.push(TypoSuggestion::typo_from_res(ident.name, res)); } diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 9652c483686f0..859a4c6f15509 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -1,5 +1,3 @@ -// ignore-tidy-filelength - //! This crate is responsible for the part of name resolution that doesn't require type checker. //! //! Module structure of the crate is built here. @@ -371,26 +369,6 @@ impl<'tcx> Visitor<'tcx> for UsePlacementFinder { } } -/// An intermediate resolution result. -/// -/// This refers to the thing referred by a name. The difference between `Res` and `Item` is that -/// items are visible in their whole block, while `Res`es only from the place they are defined -/// forward. -#[derive(Debug)] -enum LexicalScopeBinding<'a> { - Item(&'a NameBinding<'a>), - Res(Res), -} - -impl<'a> LexicalScopeBinding<'a> { - fn res(self) -> Res { - match self { - LexicalScopeBinding::Item(binding) => binding.res(), - LexicalScopeBinding::Res(res) => res, - } - } -} - #[derive(Copy, Clone, Debug)] enum ModuleOrUniformRoot<'a> { /// Regular module. @@ -916,10 +894,6 @@ pub struct Resolver<'a> { /// "self-confirming" import resolutions during import validation. unusable_binding: Option<&'a NameBinding<'a>>, - // Spans for local variables found during pattern resolution. - // Used for suggestions during error reporting. - pat_span_map: NodeMap, - /// Resolutions for nodes that have a single resolution. partial_res_map: NodeMap, /// Resolutions for import nodes, which have multiple resolutions in different namespaces. @@ -1357,7 +1331,6 @@ impl<'a> Resolver<'a> { last_import_segment: false, unusable_binding: None, - pat_span_map: Default::default(), partial_res_map: Default::default(), import_res_map: Default::default(), label_res_map: Default::default(), @@ -1383,13 +1356,8 @@ impl<'a> Resolver<'a> { macro_expanded_macro_export_errors: BTreeSet::new(), arenas, - dummy_binding: arenas.alloc_name_binding(NameBinding { - kind: NameBindingKind::Res(Res::Err, false), - ambiguity: None, - expansion: LocalExpnId::ROOT, - span: DUMMY_SP, - vis: ty::Visibility::Public, - }), + dummy_binding: (Res::Err, ty::Visibility::Public, DUMMY_SP, LocalExpnId::ROOT) + .to_name_binding(arenas), crate_loader: CrateLoader::new(session, metadata_loader, crate_name), macro_names: FxHashSet::default(), @@ -1953,11 +1921,11 @@ impl<'a> Resolver<'a> { record_used_id: Option, path_span: Span, ribs: &[Rib<'a>], - ) -> Option> { + ) -> Result<&'a NameBinding<'a>, Determinacy> { assert!(ns == TypeNS || ns == ValueNS); let orig_ident = ident; if ident.name == kw::Empty { - return Some(LexicalScopeBinding::Res(Res::Err)); + return Ok(self.dummy_binding); } let (general_span, normalized_span) = if ident.name == kw::SelfUpper { // FIXME(jseyfried) improve `Self` hygiene @@ -1980,18 +1948,30 @@ impl<'a> Resolver<'a> { // Use the rib kind to determine whether we are resolving parameters // (macro 2.0 hygiene) or local variables (`macro_rules` hygiene). let rib_ident = if ribs[i].kind.contains_params() { normalized_ident } else { ident }; - if let Some((original_rib_ident_def, res)) = ribs[i].bindings.get_key_value(&rib_ident) + if let Some((&original_rib_ident_def, &binding)) = + ribs[i].bindings.get_key_value(&rib_ident) { // The ident resolves to a type parameter or local variable. - return Some(LexicalScopeBinding::Res(self.validate_res_from_ribs( + let res = self.validate_res_from_ribs( i, rib_ident, - *res, + binding.res(), record_used, path_span, - *original_rib_ident_def, + original_rib_ident_def, ribs, - ))); + ); + + // We have to create a new binding in case of validation errors, + // or in case of const generic hack changing the resolution. + return Ok(if res != binding.res() { + self.arenas.alloc_name_binding(NameBinding { + kind: NameBindingKind::Res(res, false), + ..binding.clone() + }) + } else { + binding + }); } module = match ribs[i].kind { @@ -2010,7 +1990,7 @@ impl<'a> Resolver<'a> { _ => break, } - let item = self.resolve_ident_in_module_unadjusted( + let binding = self.resolve_ident_in_module_unadjusted( ModuleOrUniformRoot::Module(module), ident, ns, @@ -2018,9 +1998,9 @@ impl<'a> Resolver<'a> { record_used, path_span, ); - if let Ok(binding) = item { + if binding.is_ok() { // The ident resolves to an item. - return Some(LexicalScopeBinding::Item(binding)); + return binding; } } self.early_resolve_ident_in_lexical_scope( @@ -2031,8 +2011,6 @@ impl<'a> Resolver<'a> { record_used, path_span, ) - .ok() - .map(LexicalScopeBinding::Item) } fn hygienic_lexical_parent( @@ -2257,16 +2235,6 @@ impl<'a> Resolver<'a> { for (i, &Segment { ident, id, has_generic_args: _ }) in path.iter().enumerate() { debug!("resolve_path ident {} {:?} {:?}", i, ident, id); - let record_segment_res = |this: &mut Self, res| { - if record_used { - if let Some(id) = id { - if !this.partial_res_map.contains_key(&id) { - assert!(id != ast::DUMMY_NODE_ID, "Trying to resolve dummy id"); - this.record_partial_res(id, PartialRes::new(res)); - } - } - } - }; let is_last = i == path.len() - 1; let ns = if is_last { opt_ns.unwrap_or(TypeNS) } else { TypeNS }; @@ -2345,12 +2313,8 @@ impl<'a> Resolver<'a> { }; } - enum FindBindingResult<'a> { - Binding(Result<&'a NameBinding<'a>, Determinacy>), - PathResult(PathResult<'a>), - } let find_binding_in_ns = |this: &mut Self, ns| { - let binding = if let Some(module) = module { + if let Some(module) = module { this.resolve_ident_in_module( module, ident, @@ -2375,44 +2339,34 @@ impl<'a> Resolver<'a> { } else { None }; - match this.resolve_ident_in_lexical_scope( + this.resolve_ident_in_lexical_scope( ident, ns, parent_scope, record_used_id, path_span, &ribs.unwrap()[ns], - ) { - // we found a locally-imported or available item/module - Some(LexicalScopeBinding::Item(binding)) => Ok(binding), - // we found a local variable or type param - Some(LexicalScopeBinding::Res(res)) - if opt_ns == Some(TypeNS) || opt_ns == Some(ValueNS) => - { - record_segment_res(this, res); - return FindBindingResult::PathResult(PathResult::NonModule( - PartialRes::with_unresolved_segments(res, path.len() - 1), - )); - } - _ => Err(Determinacy::determined(record_used)), - } - }; - FindBindingResult::Binding(binding) - }; - let binding = match find_binding_in_ns(self, ns) { - FindBindingResult::PathResult(x) => return x, - FindBindingResult::Binding(binding) => binding, + ) + } }; - match binding { + + match find_binding_in_ns(self, ns) { Ok(binding) => { if i == 1 { second_binding = Some(binding); } let res = binding.res(); + if record_used { + if let Some(id) = id { + if !self.partial_res_map.contains_key(&id) { + assert!(id != ast::DUMMY_NODE_ID, "Trying to resolve dummy id"); + self.record_partial_res(id, PartialRes::new(res)); + } + } + } let maybe_assoc = opt_ns != Some(MacroNS) && PathSource::Type.is_expected(res); if let Some(next_module) = binding.module() { module = Some(ModuleOrUniformRoot::Module(next_module)); - record_segment_res(self, res); } else if res == Res::ToolMod && i + 1 != path.len() { if binding.is_import() { self.session @@ -2502,56 +2456,25 @@ impl<'a> Resolver<'a> { .map_or(false, |c| c.is_ascii_uppercase()) { // Check whether the name refers to an item in the value namespace. - let suggestion = if ribs.is_some() { - let match_span = match self.resolve_ident_in_lexical_scope( - ident, - ValueNS, - parent_scope, - None, - path_span, - &ribs.unwrap()[ValueNS], - ) { - // Name matches a local variable. For example: - // ``` - // fn f() { - // let Foo: &str = ""; - // println!("{}", Foo::Bar); // Name refers to local - // // variable `Foo`. - // } - // ``` - Some(LexicalScopeBinding::Res(Res::Local(id))) => { - Some(*self.pat_span_map.get(&id).unwrap()) - } - - // Name matches item from a local name binding - // created by `use` declaration. For example: - // ``` - // pub Foo: &str = ""; - // - // mod submod { - // use super::Foo; - // println!("{}", Foo::Bar); // Name refers to local - // // binding `Foo`. - // } - // ``` - Some(LexicalScopeBinding::Item(name_binding)) => { - Some(name_binding.span) - } - _ => None, - }; - - if let Some(span) = match_span { - Some(( - vec![(span, String::from(""))], + let suggestion = ribs + .and_then(|ribs| { + self.resolve_ident_in_lexical_scope( + ident, + ValueNS, + parent_scope, + None, + path_span, + &ribs[ValueNS], + ) + .ok() + }) + .map(|binding| { + ( + vec![(binding.span, String::from(""))], format!("`{}` is defined here, but is not a type", ident), Applicability::MaybeIncorrect, - )) - } else { - None - } - } else { - None - }; + ) + }); (format!("use of undeclared type `{}`", ident), suggestion) } else { @@ -2589,9 +2512,7 @@ impl<'a> Resolver<'a> { let mut msg = format!("could not find `{}` in {}", ident, parent); if ns == TypeNS || ns == ValueNS { let ns_to_try = if ns == TypeNS { ValueNS } else { TypeNS }; - if let FindBindingResult::Binding(Ok(binding)) = - find_binding_in_ns(self, ns_to_try) - { + if let Ok(binding) = find_binding_in_ns(self, ns_to_try) { let mut found = |what| { msg = format!( "expected {}, found {} `{}` in {}", @@ -2933,11 +2854,6 @@ impl<'a> Resolver<'a> { } } - fn record_pat_span(&mut self, node: NodeId, span: Span) { - debug!("(recording pat) recording {:?} for {:?}", node, span); - self.pat_span_map.insert(node, span); - } - fn is_accessible_from(&self, vis: ty::Visibility, module: Module<'a>) -> bool { vis.is_accessible_from(module.nearest_parent_mod(), self) } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index fddb225345f49..ae148624a9068 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1453,7 +1453,7 @@ impl Ident { } #[inline] - pub fn invalid() -> Ident { + pub fn empty() -> Ident { Ident::with_dummy_span(kw::Empty) } diff --git a/src/test/ui/hidden-doc-associated-item.rs b/src/test/ui/hidden-doc-associated-item.rs new file mode 100644 index 0000000000000..d431f9e899c02 --- /dev/null +++ b/src/test/ui/hidden-doc-associated-item.rs @@ -0,0 +1,15 @@ +// check-pass +// See issue #85526. +// This test should produce no warnings. + +#![deny(missing_docs)] +//! Crate docs + +#[doc(hidden)] +pub struct Foo; + +impl Foo { + pub fn bar() {} +} + +fn main() {} diff --git a/src/test/ui/let-else/issue-89960.rs b/src/test/ui/let-else/issue-89960.rs new file mode 100644 index 0000000000000..8fd55adbfd428 --- /dev/null +++ b/src/test/ui/let-else/issue-89960.rs @@ -0,0 +1,7 @@ +#![feature(let_else)] + +fn main() { + // FIXME: more precise diagnostics + let Some(ref mut meow) = Some(()) else { return }; + //~^ ERROR: cannot borrow value as mutable, as `val` is not declared as mutable +} diff --git a/src/test/ui/let-else/issue-89960.stderr b/src/test/ui/let-else/issue-89960.stderr new file mode 100644 index 0000000000000..697f04d6d2735 --- /dev/null +++ b/src/test/ui/let-else/issue-89960.stderr @@ -0,0 +1,12 @@ +error[E0596]: cannot borrow value as mutable, as `val` is not declared as mutable + --> $DIR/issue-89960.rs:5:14 + | +LL | let Some(ref mut meow) = Some(()) else { return }; + | ---------^^^^^^^^^^^^----------------------------- + | | | + | | cannot borrow as mutable + | help: consider changing this to be mutable: `mut val` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/let-else/let-else-if.rs b/src/test/ui/let-else/let-else-if.rs new file mode 100644 index 0000000000000..c3a17330d6e2f --- /dev/null +++ b/src/test/ui/let-else/let-else-if.rs @@ -0,0 +1,10 @@ +#![feature(let_else)] + +fn main() { + let Some(_) = Some(()) else if true { + //~^ ERROR conditional `else if` is not supported for `let...else` + return; + } else { + return; + }; +} diff --git a/src/test/ui/let-else/let-else-if.stderr b/src/test/ui/let-else/let-else-if.stderr new file mode 100644 index 0000000000000..38c739fd85072 --- /dev/null +++ b/src/test/ui/let-else/let-else-if.stderr @@ -0,0 +1,18 @@ +error: conditional `else if` is not supported for `let...else` + --> $DIR/let-else-if.rs:4:33 + | +LL | let Some(_) = Some(()) else if true { + | ^^ expected `{` + | +help: try placing this code inside a block + | +LL ~ let Some(_) = Some(()) else { if true { +LL + +LL + return; +LL + } else { +LL + return; +LL ~ } }; + | + +error: aborting due to previous error + diff --git a/src/test/ui/proc-macro/generate-mod.rs b/src/test/ui/proc-macro/generate-mod.rs index e5f967416c922..471f317edf964 100644 --- a/src/test/ui/proc-macro/generate-mod.rs +++ b/src/test/ui/proc-macro/generate-mod.rs @@ -13,15 +13,15 @@ generate_mod::check!(); //~ ERROR cannot find type `FromOutside` in this scope //~| ERROR cannot find type `OuterAttr` in this scope struct S; -#[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside` in this scope - //~| WARN cannot find type `OuterDerive` in this scope +#[derive(generate_mod::CheckDerive)] //~ ERROR cannot find type `FromOutside` in this scope + //~| ERROR cannot find type `OuterDerive` in this scope //~| WARN this was previously accepted //~| WARN this was previously accepted struct Z; fn inner_block() { - #[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside` in this scope - //~| WARN cannot find type `OuterDerive` in this scope + #[derive(generate_mod::CheckDerive)] //~ ERROR cannot find type `FromOutside` in this scope + //~| ERROR cannot find type `OuterDerive` in this scope //~| WARN this was previously accepted //~| WARN this was previously accepted struct InnerZ; diff --git a/src/test/ui/proc-macro/generate-mod.stderr b/src/test/ui/proc-macro/generate-mod.stderr index be58cc40ed299..74e12a48f532c 100644 --- a/src/test/ui/proc-macro/generate-mod.stderr +++ b/src/test/ui/proc-macro/generate-mod.stderr @@ -38,18 +38,18 @@ LL | #[generate_mod::check_attr] OuterAttr = note: this error originates in the attribute macro `generate_mod::check_attr` (in Nightly builds, run with -Z macro-backtrace for more info) -warning: cannot find type `FromOutside` in this scope +error: cannot find type `FromOutside` in this scope --> $DIR/generate-mod.rs:16:10 | LL | #[derive(generate_mod::CheckDerive)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import | - = note: `#[warn(proc_macro_derive_resolution_fallback)]` on by default + = note: `#[deny(proc_macro_derive_resolution_fallback)]` on by default = 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 #83583 - = note: this warning originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) -warning: cannot find type `OuterDerive` in this scope +error: cannot find type `OuterDerive` in this scope --> $DIR/generate-mod.rs:16:10 | LL | #[derive(generate_mod::CheckDerive)] @@ -57,9 +57,9 @@ LL | #[derive(generate_mod::CheckDerive)] | = 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 #83583 - = note: this warning originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) -warning: cannot find type `FromOutside` in this scope +error: cannot find type `FromOutside` in this scope --> $DIR/generate-mod.rs:23:14 | LL | #[derive(generate_mod::CheckDerive)] @@ -67,9 +67,9 @@ LL | #[derive(generate_mod::CheckDerive)] | = 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 #83583 - = note: this warning originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) -warning: cannot find type `OuterDerive` in this scope +error: cannot find type `OuterDerive` in this scope --> $DIR/generate-mod.rs:23:14 | LL | #[derive(generate_mod::CheckDerive)] @@ -77,9 +77,9 @@ LL | #[derive(generate_mod::CheckDerive)] | = 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 #83583 - = note: this warning originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 4 previous errors; 4 warnings emitted +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0412`. Future incompatibility report: Future breakage diagnostic: diff --git a/src/test/ui/proc-macro/group-compat-hack/group-compat-hack.rs b/src/test/ui/proc-macro/group-compat-hack/group-compat-hack.rs index 2b742771d6f2c..3a2a6fa2253fa 100644 --- a/src/test/ui/proc-macro/group-compat-hack/group-compat-hack.rs +++ b/src/test/ui/proc-macro/group-compat-hack/group-compat-hack.rs @@ -1,4 +1,3 @@ -// check-pass // aux-build:pin-project-internal-0.4.0.rs // compile-flags: -Z span-debug @@ -24,7 +23,7 @@ mod no_version { } struct Foo; - impl_macros!(Foo); //~ WARN using an old version + impl_macros!(Foo); //~ ERROR using an old version //~| WARN this was previously arrays!(Foo); other!(Foo); @@ -41,9 +40,9 @@ mod with_version { } struct Foo; - impl_macros!(Foo); //~ WARN using an old version + impl_macros!(Foo); //~ ERROR using an old version //~| WARN this was previously - arrays!(Foo); //~ WARN using an old version + arrays!(Foo); //~ ERROR using an old version //~| WARN this was previously other!(Foo); } @@ -52,7 +51,7 @@ mod actix_web_test { include!("actix-web/src/extract.rs"); struct Foo; - tuple_from_req!(Foo); //~ WARN using an old version + tuple_from_req!(Foo); //~ ERROR using an old version //~| WARN this was previously } @@ -60,7 +59,7 @@ mod actix_web_version_test { include!("actix-web-2.0.0/src/extract.rs"); struct Foo; - tuple_from_req!(Foo); //~ WARN using an old version + tuple_from_req!(Foo); //~ ERROR using an old version //~| WARN this was previously } diff --git a/src/test/ui/proc-macro/group-compat-hack/group-compat-hack.stderr b/src/test/ui/proc-macro/group-compat-hack/group-compat-hack.stderr index 1a56291896c76..bd9ba6a09fce5 100644 --- a/src/test/ui/proc-macro/group-compat-hack/group-compat-hack.stderr +++ b/src/test/ui/proc-macro/group-compat-hack/group-compat-hack.stderr @@ -1,27 +1,27 @@ -warning: using an old version of `time-macros-impl` +error: using an old version of `time-macros-impl` --> $DIR/time-macros-impl/src/lib.rs:5:32 | LL | #[my_macro] struct One($name); | ^^^^^ | - ::: $DIR/group-compat-hack.rs:27:5 + ::: $DIR/group-compat-hack.rs:26:5 | LL | impl_macros!(Foo); | ----------------- in this macro invocation | - = note: `#[warn(proc_macro_back_compat)]` on by default + = note: `#[deny(proc_macro_back_compat)]` on by default = 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 = note: the `time-macros-impl` crate will stop compiling in futures version of Rust. Please update to the latest version of the `time` crate to avoid breakage - = note: this warning originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info) -warning: using an old version of `time-macros-impl` +error: using an old version of `time-macros-impl` --> $DIR/time-macros-impl-0.1.0/src/lib.rs:5:32 | LL | #[my_macro] struct One($name); | ^^^^^ | - ::: $DIR/group-compat-hack.rs:44:5 + ::: $DIR/group-compat-hack.rs:43:5 | LL | impl_macros!(Foo); | ----------------- in this macro invocation @@ -29,15 +29,15 @@ LL | impl_macros!(Foo); = 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 = note: the `time-macros-impl` crate will stop compiling in futures version of Rust. Please update to the latest version of the `time` crate to avoid breakage - = note: this warning originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info) -warning: using an old version of `js-sys` +error: using an old version of `js-sys` --> $DIR/js-sys-0.3.17/src/lib.rs:5:32 | LL | #[my_macro] struct Two($name); | ^^^^^ | - ::: $DIR/group-compat-hack.rs:46:5 + ::: $DIR/group-compat-hack.rs:45:5 | LL | arrays!(Foo); | ------------ in this macro invocation @@ -45,15 +45,15 @@ LL | arrays!(Foo); = 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 = note: older versions of the `js-sys` crate will stop compiling in future versions of Rust; please update to `js-sys` v0.3.40 or above - = note: this warning originates in the macro `arrays` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `arrays` (in Nightly builds, run with -Z macro-backtrace for more info) -warning: using an old version of `actix-web` +error: using an old version of `actix-web` --> $DIR/actix-web/src/extract.rs:5:34 | LL | #[my_macro] struct Three($T); | ^^ | - ::: $DIR/group-compat-hack.rs:55:5 + ::: $DIR/group-compat-hack.rs:54:5 | LL | tuple_from_req!(Foo); | -------------------- in this macro invocation @@ -61,15 +61,15 @@ LL | tuple_from_req!(Foo); = 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 = note: the version of `actix-web` you are using might stop compiling in future versions of Rust; please update to the latest version of the `actix-web` crate to avoid breakage - = note: this warning originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info) -warning: using an old version of `actix-web` +error: using an old version of `actix-web` --> $DIR/actix-web-2.0.0/src/extract.rs:5:34 | LL | #[my_macro] struct Three($T); | ^^ | - ::: $DIR/group-compat-hack.rs:63:5 + ::: $DIR/group-compat-hack.rs:62:5 | LL | tuple_from_req!(Foo); | -------------------- in this macro invocation @@ -77,36 +77,36 @@ LL | tuple_from_req!(Foo); = 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 = note: the version of `actix-web` you are using might stop compiling in future versions of Rust; please update to the latest version of the `actix-web` crate to avoid breakage - = note: this warning originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info) -warning: 5 warnings emitted +error: aborting due to 5 previous errors Future incompatibility report: Future breakage diagnostic: -warning: using an old version of `time-macros-impl` +error: using an old version of `time-macros-impl` --> $DIR/time-macros-impl/src/lib.rs:5:32 | LL | #[my_macro] struct One($name); | ^^^^^ | - ::: $DIR/group-compat-hack.rs:27:5 + ::: $DIR/group-compat-hack.rs:26:5 | LL | impl_macros!(Foo); | ----------------- in this macro invocation | - = note: `#[warn(proc_macro_back_compat)]` on by default + = note: `#[deny(proc_macro_back_compat)]` on by default = 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 = note: the `time-macros-impl` crate will stop compiling in futures version of Rust. Please update to the latest version of the `time` crate to avoid breakage - = note: this warning originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info) Future breakage diagnostic: -warning: using an old version of `time-macros-impl` +error: using an old version of `time-macros-impl` --> $DIR/time-macros-impl-0.1.0/src/lib.rs:5:32 | LL | #[my_macro] struct One($name); | ^^^^^ | - ::: $DIR/group-compat-hack.rs:44:5 + ::: $DIR/group-compat-hack.rs:43:5 | LL | impl_macros!(Foo); | ----------------- in this macro invocation @@ -114,16 +114,16 @@ LL | impl_macros!(Foo); = 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 = note: the `time-macros-impl` crate will stop compiling in futures version of Rust. Please update to the latest version of the `time` crate to avoid breakage - = note: this warning originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info) Future breakage diagnostic: -warning: using an old version of `js-sys` +error: using an old version of `js-sys` --> $DIR/js-sys-0.3.17/src/lib.rs:5:32 | LL | #[my_macro] struct Two($name); | ^^^^^ | - ::: $DIR/group-compat-hack.rs:46:5 + ::: $DIR/group-compat-hack.rs:45:5 | LL | arrays!(Foo); | ------------ in this macro invocation @@ -131,16 +131,16 @@ LL | arrays!(Foo); = 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 = note: older versions of the `js-sys` crate will stop compiling in future versions of Rust; please update to `js-sys` v0.3.40 or above - = note: this warning originates in the macro `arrays` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `arrays` (in Nightly builds, run with -Z macro-backtrace for more info) Future breakage diagnostic: -warning: using an old version of `actix-web` +error: using an old version of `actix-web` --> $DIR/actix-web/src/extract.rs:5:34 | LL | #[my_macro] struct Three($T); | ^^ | - ::: $DIR/group-compat-hack.rs:55:5 + ::: $DIR/group-compat-hack.rs:54:5 | LL | tuple_from_req!(Foo); | -------------------- in this macro invocation @@ -148,16 +148,16 @@ LL | tuple_from_req!(Foo); = 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 = note: the version of `actix-web` you are using might stop compiling in future versions of Rust; please update to the latest version of the `actix-web` crate to avoid breakage - = note: this warning originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info) Future breakage diagnostic: -warning: using an old version of `actix-web` +error: using an old version of `actix-web` --> $DIR/actix-web-2.0.0/src/extract.rs:5:34 | LL | #[my_macro] struct Three($T); | ^^ | - ::: $DIR/group-compat-hack.rs:63:5 + ::: $DIR/group-compat-hack.rs:62:5 | LL | tuple_from_req!(Foo); | -------------------- in this macro invocation @@ -165,5 +165,5 @@ LL | tuple_from_req!(Foo); = 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 = note: the version of `actix-web` you are using might stop compiling in future versions of Rust; please update to the latest version of the `actix-web` crate to avoid breakage - = note: this warning originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/proc-macro/group-compat-hack/group-compat-hack.stdout b/src/test/ui/proc-macro/group-compat-hack/group-compat-hack.stdout index 82d6bc33bf95b..51312b10ad176 100644 --- a/src/test/ui/proc-macro/group-compat-hack/group-compat-hack.stdout +++ b/src/test/ui/proc-macro/group-compat-hack/group-compat-hack.stdout @@ -1,11 +1,11 @@ -Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/time-macros-impl/src/lib.rs:5:21: 5:27 (#6) }, Ident { ident: "One", span: $DIR/time-macros-impl/src/lib.rs:5:28: 5:31 (#6) }, Group { delimiter: Parenthesis, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:27:18: 27:21 (#0) }], span: $DIR/time-macros-impl/src/lib.rs:5:31: 5:38 (#6) }, Punct { ch: ';', spacing: Alone, span: $DIR/time-macros-impl/src/lib.rs:5:38: 5:39 (#6) }] -Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/js-sys/src/lib.rs:5:21: 5:27 (#10) }, Ident { ident: "Two", span: $DIR/js-sys/src/lib.rs:5:28: 5:31 (#10) }, Group { delimiter: Parenthesis, stream: TokenStream [Group { delimiter: None, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:29:13: 29:16 (#0) }], span: $DIR/js-sys/src/lib.rs:5:32: 5:37 (#10) }], span: $DIR/js-sys/src/lib.rs:5:31: 5:38 (#10) }, Punct { ch: ';', spacing: Alone, span: $DIR/js-sys/src/lib.rs:5:38: 5:39 (#10) }] -Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/group-compat-hack.rs:22:25: 22:31 (#14) }, Ident { ident: "Three", span: $DIR/group-compat-hack.rs:22:32: 22:37 (#14) }, Group { delimiter: Parenthesis, stream: TokenStream [Group { delimiter: None, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:30:12: 30:15 (#0) }], span: $DIR/group-compat-hack.rs:22:38: 22:43 (#14) }], span: $DIR/group-compat-hack.rs:22:37: 22:44 (#14) }, Punct { ch: ';', spacing: Alone, span: $DIR/group-compat-hack.rs:22:44: 22:45 (#14) }] -Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/time-macros-impl-0.1.0/src/lib.rs:5:21: 5:27 (#20) }, Ident { ident: "One", span: $DIR/time-macros-impl-0.1.0/src/lib.rs:5:28: 5:31 (#20) }, Group { delimiter: Parenthesis, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:44:18: 44:21 (#0) }], span: $DIR/time-macros-impl-0.1.0/src/lib.rs:5:31: 5:38 (#20) }, Punct { ch: ';', spacing: Alone, span: $DIR/time-macros-impl-0.1.0/src/lib.rs:5:38: 5:39 (#20) }] -Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/js-sys-0.3.17/src/lib.rs:5:21: 5:27 (#24) }, Ident { ident: "Two", span: $DIR/js-sys-0.3.17/src/lib.rs:5:28: 5:31 (#24) }, Group { delimiter: Parenthesis, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:46:13: 46:16 (#0) }], span: $DIR/js-sys-0.3.17/src/lib.rs:5:31: 5:38 (#24) }, Punct { ch: ';', spacing: Alone, span: $DIR/js-sys-0.3.17/src/lib.rs:5:38: 5:39 (#24) }] -Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/group-compat-hack.rs:39:25: 39:31 (#28) }, Ident { ident: "Three", span: $DIR/group-compat-hack.rs:39:32: 39:37 (#28) }, Group { delimiter: Parenthesis, stream: TokenStream [Group { delimiter: None, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:48:12: 48:15 (#0) }], span: $DIR/group-compat-hack.rs:39:38: 39:43 (#28) }], span: $DIR/group-compat-hack.rs:39:37: 39:44 (#28) }, Punct { ch: ';', spacing: Alone, span: $DIR/group-compat-hack.rs:39:44: 39:45 (#28) }] -Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/actix-web/src/extract.rs:5:21: 5:27 (#33) }, Ident { ident: "Three", span: $DIR/actix-web/src/extract.rs:5:28: 5:33 (#33) }, Group { delimiter: Parenthesis, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:55:21: 55:24 (#0) }], span: $DIR/actix-web/src/extract.rs:5:33: 5:37 (#33) }, Punct { ch: ';', spacing: Alone, span: $DIR/actix-web/src/extract.rs:5:37: 5:38 (#33) }] -Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/actix-web-2.0.0/src/extract.rs:5:21: 5:27 (#38) }, Ident { ident: "Three", span: $DIR/actix-web-2.0.0/src/extract.rs:5:28: 5:33 (#38) }, Group { delimiter: Parenthesis, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:63:21: 63:24 (#0) }], span: $DIR/actix-web-2.0.0/src/extract.rs:5:33: 5:37 (#38) }, Punct { ch: ';', spacing: Alone, span: $DIR/actix-web-2.0.0/src/extract.rs:5:37: 5:38 (#38) }] -Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/actori-web/src/extract.rs:5:21: 5:27 (#43) }, Ident { ident: "Four", span: $DIR/actori-web/src/extract.rs:5:28: 5:32 (#43) }, Group { delimiter: Parenthesis, stream: TokenStream [Group { delimiter: None, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:71:21: 71:24 (#0) }], span: $DIR/actori-web/src/extract.rs:5:33: 5:35 (#43) }], span: $DIR/actori-web/src/extract.rs:5:32: 5:36 (#43) }, Punct { ch: ';', spacing: Alone, span: $DIR/actori-web/src/extract.rs:5:36: 5:37 (#43) }] -Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/actori-web-2.0.0/src/extract.rs:5:21: 5:27 (#48) }, Ident { ident: "Four", span: $DIR/actori-web-2.0.0/src/extract.rs:5:28: 5:32 (#48) }, Group { delimiter: Parenthesis, stream: TokenStream [Group { delimiter: None, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:78:21: 78:24 (#0) }], span: $DIR/actori-web-2.0.0/src/extract.rs:5:33: 5:35 (#48) }], span: $DIR/actori-web-2.0.0/src/extract.rs:5:32: 5:36 (#48) }, Punct { ch: ';', spacing: Alone, span: $DIR/actori-web-2.0.0/src/extract.rs:5:36: 5:37 (#48) }] -Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/js-sys-0.3.40/src/lib.rs:5:21: 5:27 (#53) }, Ident { ident: "Two", span: $DIR/js-sys-0.3.40/src/lib.rs:5:28: 5:31 (#53) }, Group { delimiter: Parenthesis, stream: TokenStream [Group { delimiter: None, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:84:13: 84:16 (#0) }], span: $DIR/js-sys-0.3.40/src/lib.rs:5:32: 5:37 (#53) }], span: $DIR/js-sys-0.3.40/src/lib.rs:5:31: 5:38 (#53) }, Punct { ch: ';', spacing: Alone, span: $DIR/js-sys-0.3.40/src/lib.rs:5:38: 5:39 (#53) }] +Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/time-macros-impl/src/lib.rs:5:21: 5:27 (#6) }, Ident { ident: "One", span: $DIR/time-macros-impl/src/lib.rs:5:28: 5:31 (#6) }, Group { delimiter: Parenthesis, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:26:18: 26:21 (#0) }], span: $DIR/time-macros-impl/src/lib.rs:5:31: 5:38 (#6) }, Punct { ch: ';', spacing: Alone, span: $DIR/time-macros-impl/src/lib.rs:5:38: 5:39 (#6) }] +Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/js-sys/src/lib.rs:5:21: 5:27 (#10) }, Ident { ident: "Two", span: $DIR/js-sys/src/lib.rs:5:28: 5:31 (#10) }, Group { delimiter: Parenthesis, stream: TokenStream [Group { delimiter: None, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:28:13: 28:16 (#0) }], span: $DIR/js-sys/src/lib.rs:5:32: 5:37 (#10) }], span: $DIR/js-sys/src/lib.rs:5:31: 5:38 (#10) }, Punct { ch: ';', spacing: Alone, span: $DIR/js-sys/src/lib.rs:5:38: 5:39 (#10) }] +Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/group-compat-hack.rs:21:25: 21:31 (#14) }, Ident { ident: "Three", span: $DIR/group-compat-hack.rs:21:32: 21:37 (#14) }, Group { delimiter: Parenthesis, stream: TokenStream [Group { delimiter: None, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:29:12: 29:15 (#0) }], span: $DIR/group-compat-hack.rs:21:38: 21:43 (#14) }], span: $DIR/group-compat-hack.rs:21:37: 21:44 (#14) }, Punct { ch: ';', spacing: Alone, span: $DIR/group-compat-hack.rs:21:44: 21:45 (#14) }] +Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/time-macros-impl-0.1.0/src/lib.rs:5:21: 5:27 (#20) }, Ident { ident: "One", span: $DIR/time-macros-impl-0.1.0/src/lib.rs:5:28: 5:31 (#20) }, Group { delimiter: Parenthesis, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:43:18: 43:21 (#0) }], span: $DIR/time-macros-impl-0.1.0/src/lib.rs:5:31: 5:38 (#20) }, Punct { ch: ';', spacing: Alone, span: $DIR/time-macros-impl-0.1.0/src/lib.rs:5:38: 5:39 (#20) }] +Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/js-sys-0.3.17/src/lib.rs:5:21: 5:27 (#24) }, Ident { ident: "Two", span: $DIR/js-sys-0.3.17/src/lib.rs:5:28: 5:31 (#24) }, Group { delimiter: Parenthesis, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:45:13: 45:16 (#0) }], span: $DIR/js-sys-0.3.17/src/lib.rs:5:31: 5:38 (#24) }, Punct { ch: ';', spacing: Alone, span: $DIR/js-sys-0.3.17/src/lib.rs:5:38: 5:39 (#24) }] +Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/group-compat-hack.rs:38:25: 38:31 (#28) }, Ident { ident: "Three", span: $DIR/group-compat-hack.rs:38:32: 38:37 (#28) }, Group { delimiter: Parenthesis, stream: TokenStream [Group { delimiter: None, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:47:12: 47:15 (#0) }], span: $DIR/group-compat-hack.rs:38:38: 38:43 (#28) }], span: $DIR/group-compat-hack.rs:38:37: 38:44 (#28) }, Punct { ch: ';', spacing: Alone, span: $DIR/group-compat-hack.rs:38:44: 38:45 (#28) }] +Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/actix-web/src/extract.rs:5:21: 5:27 (#33) }, Ident { ident: "Three", span: $DIR/actix-web/src/extract.rs:5:28: 5:33 (#33) }, Group { delimiter: Parenthesis, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:54:21: 54:24 (#0) }], span: $DIR/actix-web/src/extract.rs:5:33: 5:37 (#33) }, Punct { ch: ';', spacing: Alone, span: $DIR/actix-web/src/extract.rs:5:37: 5:38 (#33) }] +Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/actix-web-2.0.0/src/extract.rs:5:21: 5:27 (#38) }, Ident { ident: "Three", span: $DIR/actix-web-2.0.0/src/extract.rs:5:28: 5:33 (#38) }, Group { delimiter: Parenthesis, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:62:21: 62:24 (#0) }], span: $DIR/actix-web-2.0.0/src/extract.rs:5:33: 5:37 (#38) }, Punct { ch: ';', spacing: Alone, span: $DIR/actix-web-2.0.0/src/extract.rs:5:37: 5:38 (#38) }] +Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/actori-web/src/extract.rs:5:21: 5:27 (#43) }, Ident { ident: "Four", span: $DIR/actori-web/src/extract.rs:5:28: 5:32 (#43) }, Group { delimiter: Parenthesis, stream: TokenStream [Group { delimiter: None, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:70:21: 70:24 (#0) }], span: $DIR/actori-web/src/extract.rs:5:33: 5:35 (#43) }], span: $DIR/actori-web/src/extract.rs:5:32: 5:36 (#43) }, Punct { ch: ';', spacing: Alone, span: $DIR/actori-web/src/extract.rs:5:36: 5:37 (#43) }] +Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/actori-web-2.0.0/src/extract.rs:5:21: 5:27 (#48) }, Ident { ident: "Four", span: $DIR/actori-web-2.0.0/src/extract.rs:5:28: 5:32 (#48) }, Group { delimiter: Parenthesis, stream: TokenStream [Group { delimiter: None, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:77:21: 77:24 (#0) }], span: $DIR/actori-web-2.0.0/src/extract.rs:5:33: 5:35 (#48) }], span: $DIR/actori-web-2.0.0/src/extract.rs:5:32: 5:36 (#48) }, Punct { ch: ';', spacing: Alone, span: $DIR/actori-web-2.0.0/src/extract.rs:5:36: 5:37 (#48) }] +Called proc_macro_hack with TokenStream [Ident { ident: "struct", span: $DIR/js-sys-0.3.40/src/lib.rs:5:21: 5:27 (#53) }, Ident { ident: "Two", span: $DIR/js-sys-0.3.40/src/lib.rs:5:28: 5:31 (#53) }, Group { delimiter: Parenthesis, stream: TokenStream [Group { delimiter: None, stream: TokenStream [Ident { ident: "Foo", span: $DIR/group-compat-hack.rs:83:13: 83:16 (#0) }], span: $DIR/js-sys-0.3.40/src/lib.rs:5:32: 5:37 (#53) }], span: $DIR/js-sys-0.3.40/src/lib.rs:5:31: 5:38 (#53) }, Punct { ch: ';', spacing: Alone, span: $DIR/js-sys-0.3.40/src/lib.rs:5:38: 5:39 (#53) }] 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 abc3d2691a307..113235051b2b9 100644 --- a/src/test/ui/proc-macro/issue-73933-procedural-masquerade.rs +++ b/src/test/ui/proc-macro/issue-73933-procedural-masquerade.rs @@ -1,11 +1,10 @@ -// check-pass // aux-build:test-macros.rs #[macro_use] extern crate test_macros; #[derive(Print)] -enum ProceduralMasqueradeDummyType { //~ WARN using +enum ProceduralMasqueradeDummyType { //~ 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 4d6edab08e2cf..dff71c9eacd4d 100644 --- a/src/test/ui/proc-macro/issue-73933-procedural-masquerade.stderr +++ b/src/test/ui/proc-macro/issue-73933-procedural-masquerade.stderr @@ -1,24 +1,24 @@ -warning: using `procedural-masquerade` crate - --> $DIR/issue-73933-procedural-masquerade.rs:8:6 +error: using `procedural-masquerade` crate + --> $DIR/issue-73933-procedural-masquerade.rs:7:6 | LL | enum ProceduralMasqueradeDummyType { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#[warn(proc_macro_back_compat)]` on by default + = note: `#[deny(proc_macro_back_compat)]` on by default = 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 = 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. -warning: 1 warning emitted +error: aborting due to previous error Future incompatibility report: Future breakage diagnostic: -warning: using `procedural-masquerade` crate - --> $DIR/issue-73933-procedural-masquerade.rs:8:6 +error: using `procedural-masquerade` crate + --> $DIR/issue-73933-procedural-masquerade.rs:7:6 | LL | enum ProceduralMasqueradeDummyType { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `#[warn(proc_macro_back_compat)]` on by default + = note: `#[deny(proc_macro_back_compat)]` on by default = 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 = 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 8edd68f8a3b84..8a8fbf0682470 100644 --- a/src/test/ui/proc-macro/issue-73933-procedural-masquerade.stdout +++ b/src/test/ui/proc-macro/issue-73933-procedural-masquerade.stdout @@ -3,20 +3,20 @@ PRINT-DERIVE RE-COLLECTED (DISPLAY): enum ProceduralMasqueradeDummyType { Input PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "enum", - span: #0 bytes(100..104), + span: #0 bytes(86..90), }, Ident { ident: "ProceduralMasqueradeDummyType", - span: #0 bytes(105..134), + span: #0 bytes(91..120), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "Input", - span: #0 bytes(186..191), + span: #0 bytes(173..178), }, ], - span: #0 bytes(135..193), + span: #0 bytes(121..180), }, ] diff --git a/src/tools/clippy/tests/ui-internal/unnecessary_symbol_str.fixed b/src/tools/clippy/tests/ui-internal/unnecessary_symbol_str.fixed index 2ec0efe4c10a5..95b8c6dfe89ee 100644 --- a/src/tools/clippy/tests/ui-internal/unnecessary_symbol_str.fixed +++ b/src/tools/clippy/tests/ui-internal/unnecessary_symbol_str.fixed @@ -11,6 +11,6 @@ fn main() { Symbol::intern("foo") == rustc_span::sym::clippy; Symbol::intern("foo") == rustc_span::symbol::kw::SelfLower; Symbol::intern("foo") != rustc_span::symbol::kw::SelfUpper; - Ident::invalid().name == rustc_span::sym::clippy; - rustc_span::sym::clippy == Ident::invalid().name; + Ident::empty().name == rustc_span::sym::clippy; + rustc_span::sym::clippy == Ident::empty().name; } diff --git a/src/tools/clippy/tests/ui-internal/unnecessary_symbol_str.rs b/src/tools/clippy/tests/ui-internal/unnecessary_symbol_str.rs index 87e1b3a2ee76a..ad6937cf60a65 100644 --- a/src/tools/clippy/tests/ui-internal/unnecessary_symbol_str.rs +++ b/src/tools/clippy/tests/ui-internal/unnecessary_symbol_str.rs @@ -11,6 +11,6 @@ fn main() { Symbol::intern("foo").as_str() == "clippy"; Symbol::intern("foo").to_string() == "self"; Symbol::intern("foo").to_ident_string() != "Self"; - &*Ident::invalid().as_str() == "clippy"; - "clippy" == Ident::invalid().to_string(); + &*Ident::empty().as_str() == "clippy"; + "clippy" == Ident::empty().to_string(); } diff --git a/src/tools/clippy/tests/ui-internal/unnecessary_symbol_str.stderr b/src/tools/clippy/tests/ui-internal/unnecessary_symbol_str.stderr index b1284b7c8ffd0..8e04d447fbcaa 100644 --- a/src/tools/clippy/tests/ui-internal/unnecessary_symbol_str.stderr +++ b/src/tools/clippy/tests/ui-internal/unnecessary_symbol_str.stderr @@ -26,14 +26,13 @@ LL | Symbol::intern("foo").to_ident_string() != "Self"; error: unnecessary `Symbol` to string conversion --> $DIR/unnecessary_symbol_str.rs:14:5 | -LL | &*Ident::invalid().as_str() == "clippy"; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Ident::invalid().name == rustc_span::sym::clippy` +LL | &*Ident::empty().as_str() == "clippy"; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Ident::empty().name == rustc_span::sym::clippy` error: unnecessary `Symbol` to string conversion --> $DIR/unnecessary_symbol_str.rs:15:5 | -LL | "clippy" == Ident::invalid().to_string(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::clippy == Ident::invalid().name` +LL | "clippy" == Ident::empty().to_string(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::clippy == Ident::empty().name` error: aborting due to 5 previous errors -