From 685984a780041b8e5dc51a83439db81b3f5e3151 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 11 May 2026 08:53:22 +0200 Subject: [PATCH 01/25] Merge two functions always called after each other --- compiler/rustc_resolve/src/late.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index fb8de90d28aca..dfea0f45ec7dd 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -27,7 +27,7 @@ use rustc_errors::{ use rustc_hir::def::Namespace::{self, *}; use rustc_hir::def::{CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS}; use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LOCAL_CRATE, LocalDefId}; -use rustc_hir::{MissingLifetimeKind, PrimTy, TraitCandidate}; +use rustc_hir::{MissingLifetimeKind, PrimTy}; use rustc_middle::middle::resolve_bound_vars::Set1; use rustc_middle::ty::{AssocTag, DelegationInfo, Visibility}; use rustc_middle::{bug, span_bug}; @@ -4780,8 +4780,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { // it needs to be added to the trait map. if ns == ValueNS { let item_name = path.last().unwrap().ident; - let traits = self.traits_in_scope(item_name, ns); - self.r.trait_map.insert(node_id, traits); + self.record_traits_in_scope(node_id, item_name); } if PrimTy::from_name(path[0].ident.name).is_some() { @@ -5382,13 +5381,11 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { // we need to add any trait methods we find that match the // field name so that we can do some nice error reporting // later on in typeck. - let traits = self.traits_in_scope(ident, ValueNS); - self.r.trait_map.insert(expr.id, traits); + self.record_traits_in_scope(expr.id, ident); } ExprKind::MethodCall(ref call) => { debug!("(recording candidate traits for expr) recording traits for {}", expr.id); - let traits = self.traits_in_scope(call.seg.ident, ValueNS); - self.r.trait_map.insert(expr.id, traits); + self.record_traits_in_scope(expr.id, call.seg.ident); } _ => { // Nothing to do. @@ -5396,13 +5393,14 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } } - fn traits_in_scope(&mut self, ident: Ident, ns: Namespace) -> &'tcx [TraitCandidate<'tcx>] { - self.r.traits_in_scope( + fn record_traits_in_scope(&mut self, node_id: NodeId, ident: Ident) { + let traits = self.r.traits_in_scope( self.current_trait_ref.as_ref().map(|(module, _)| *module), &self.parent_scope, ident.span, - Some((ident.name, ns)), - ) + Some((ident.name, ValueNS)), + ); + self.r.trait_map.insert(node_id, traits); } fn resolve_and_cache_rustdoc_path(&mut self, path_str: &str, ns: Namespace) -> Option { From ed8e3ba2782c602e6c3c9e1e47bd7dd6df2ab7fa Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 11 May 2026 09:39:54 +0200 Subject: [PATCH 02/25] Remove an unnecessary generic --- compiler/rustc_resolve/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index f5f4c9e6e2580..22c4f4576d44b 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -822,7 +822,7 @@ impl<'ra> Module<'ra> { } /// This modifies `self` in place. The traits will be stored in `self.traits`. - fn ensure_traits<'tcx>(self, resolver: &impl AsRef>) { + fn ensure_traits<'tcx>(self, resolver: &Resolver<'ra, 'tcx>) { let mut traits = self.traits.borrow_mut(resolver.as_ref()); if traits.is_none() { let mut collected_traits = Vec::new(); From 31a054c51b7965345a320b505805f1ad6951dd61 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 12 May 2026 12:31:24 +0200 Subject: [PATCH 03/25] Add a dedicated method for error lifetime recording --- compiler/rustc_resolve/src/late.rs | 84 ++++++++++-------------------- 1 file changed, 28 insertions(+), 56 deletions(-) diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index dfea0f45ec7dd..9e26acfe249e3 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -781,8 +781,7 @@ pub(crate) struct DiagMetadata<'ast> { /// Accumulate the errors due to missed lifetime elision, /// and report them all at once for each function. - current_elision_failures: - Vec<(MissingLifetime, LifetimeElisionCandidate, Either>)>, + current_elision_failures: Vec<(MissingLifetime, Either>)>, } struct LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { @@ -1831,20 +1830,12 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { LifetimeRibKind::Item => break, LifetimeRibKind::ConstParamTy => { let guar = self.emit_non_static_lt_in_const_param_ty_error(lifetime); - self.record_lifetime_res( - lifetime.id, - LifetimeRes::Error(guar), - LifetimeElisionCandidate::Ignore, - ); + self.record_lifetime_err(lifetime.id, guar); return; } LifetimeRibKind::ConcreteAnonConst(cause) => { let guar = self.emit_forbidden_non_static_lifetime_error(cause, lifetime); - self.record_lifetime_res( - lifetime.id, - LifetimeRes::Error(guar), - LifetimeElisionCandidate::Ignore, - ); + self.record_lifetime_err(lifetime.id, guar); return; } LifetimeRibKind::AnonymousCreateParameter { .. } @@ -1862,11 +1853,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { .find_map(|rib| rib.bindings.get_key_value(&normalized_ident).map(|(&outer, _)| outer)); let guar = self.emit_undeclared_lifetime_error(lifetime, outer_res); - self.record_lifetime_res( - lifetime.id, - LifetimeRes::Error(guar), - LifetimeElisionCandidate::Named, - ); + self.record_lifetime_err(lifetime.id, guar); } #[instrument(level = "debug", skip(self))] @@ -2015,11 +2002,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { span: lifetime.ident.span, }) }; - self.record_lifetime_res( - lifetime.id, - LifetimeRes::Error(guar), - elision_candidate, - ); + self.record_lifetime_err(lifetime.id, guar); return; } LifetimeRibKind::Elided(res) => { @@ -2027,11 +2010,9 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { return; } LifetimeRibKind::ElisionFailure => { - self.diag_metadata.current_elision_failures.push(( - missing_lifetime, - elision_candidate, - Either::Left(lifetime.id), - )); + self.diag_metadata + .current_elision_failures + .push((missing_lifetime, Either::Left(lifetime.id))); return; } LifetimeRibKind::Item => break, @@ -2045,7 +2026,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } } let guar = self.report_missing_lifetime_specifiers([&missing_lifetime], None); - self.record_lifetime_res(lifetime.id, LifetimeRes::Error(guar), elision_candidate); + self.record_lifetime_err(lifetime.id, guar); } fn point_at_impl_lifetimes(&mut self, err: &mut Diag<'_>, i: usize, lifetime: Span) { @@ -2311,11 +2292,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { should_lint = false; for id in node_ids { - self.record_lifetime_res( - id, - LifetimeRes::Error(guar), - LifetimeElisionCandidate::Named, - ); + self.record_lifetime_err(id, guar); } break; } @@ -2345,11 +2322,9 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { break; } LifetimeRibKind::ElisionFailure => { - self.diag_metadata.current_elision_failures.push(( - missing_lifetime, - LifetimeElisionCandidate::Ignore, - Either::Right(node_ids), - )); + self.diag_metadata + .current_elision_failures + .push((missing_lifetime, Either::Right(node_ids))); break; } // `LifetimeRes::Error`, which would usually be used in the case of @@ -2360,11 +2335,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { let guar = self.report_missing_lifetime_specifiers([&missing_lifetime], None); for id in node_ids { - self.record_lifetime_res( - id, - LifetimeRes::Error(guar), - LifetimeElisionCandidate::Ignore, - ); + self.record_lifetime_err(id, guar); } break; } @@ -2412,9 +2383,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { res: LifetimeRes, candidate: LifetimeElisionCandidate, ) { - if let Some(prev_res) = self.r.lifetimes_res_map.insert(id, res) { - panic!("lifetime {id:?} resolved multiple times ({prev_res:?} before, {res:?} now)") - } + self.record_lifetime_param(id, res); match res { LifetimeRes::Param { .. } | LifetimeRes::Fresh { .. } | LifetimeRes::Static { .. } => { @@ -2426,6 +2395,11 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } } + #[instrument(level = "debug", skip(self))] + fn record_lifetime_err(&mut self, id: NodeId, guar: ErrorGuaranteed) { + self.record_lifetime_param(id, LifetimeRes::Error(guar)); + } + #[instrument(level = "debug", skip(self))] fn record_lifetime_param(&mut self, id: NodeId, res: LifetimeRes) { if let Some(prev_res) = self.r.lifetimes_res_map.insert(id, res) { @@ -2470,15 +2444,13 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { elision_failures.iter().map(|(missing_lifetime, ..)| missing_lifetime), Some(failure_info), ); - let mut record_res = |lifetime, candidate| { - this.record_lifetime_res(lifetime, LifetimeRes::Error(guar), candidate) - }; - for (_, candidate, nodes) in elision_failures { + let mut record_res = |lifetime| this.record_lifetime_err(lifetime, guar); + for (_, nodes) in elision_failures { match nodes { - Either::Left(node_id) => record_res(node_id, candidate), + Either::Left(node_id) => record_res(node_id), Either::Right(node_ids) => { for lifetime in node_ids { - record_res(lifetime, candidate) + record_res(lifetime) } } } @@ -3146,7 +3118,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { param.ident, ); // Record lifetime res, so lowering knows there is something fishy. - self.record_lifetime_param(param.id, LifetimeRes::Error(guar)); + self.record_lifetime_err(param.id, guar); continue; } @@ -3158,7 +3130,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { let rib = match param.kind { GenericParamKind::Lifetime => { // Record lifetime res, so lowering knows there is something fishy. - self.record_lifetime_param(param.id, LifetimeRes::Error(guar)); + self.record_lifetime_err(param.id, guar); continue; } GenericParamKind::Type { .. } => &mut function_type_rib, @@ -3193,7 +3165,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { .create_err(errors::UnderscoreLifetimeIsReserved { span: param.ident.span }) .emit_unless_delay(is_raw_underscore_lifetime); // Record lifetime res, so lowering knows there is something fishy. - self.record_lifetime_param(param.id, LifetimeRes::Error(guar)); + self.record_lifetime_err(param.id, guar); continue; } @@ -3203,7 +3175,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { lifetime: param.ident, }); // Record lifetime res, so lowering knows there is something fishy. - self.record_lifetime_param(param.id, LifetimeRes::Error(guar)); + self.record_lifetime_err(param.id, guar); continue; } From d8cddda134d970e81ad95ee4be548cf6cdd6f3fc Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 26 May 2026 13:14:02 +0200 Subject: [PATCH 04/25] Rename and document some methods --- compiler/rustc_resolve/src/late.rs | 36 +++++++++++++++++------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 9e26acfe249e3..1b3da5b9dcbb1 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -1748,7 +1748,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { let ident = lifetime.ident; if ident.name == kw::StaticLifetime { - self.record_lifetime_res( + self.record_lifetime_use( lifetime.id, LifetimeRes::Static, LifetimeElisionCandidate::Named, @@ -1764,7 +1764,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { while let Some(rib) = lifetime_rib_iter.next() { let normalized_ident = ident.normalize_to_macros_2_0(); if let Some(&(_, res)) = rib.bindings.get(&normalized_ident) { - self.record_lifetime_res(lifetime.id, res, LifetimeElisionCandidate::Named); + self.record_lifetime_use(lifetime.id, res, LifetimeElisionCandidate::Named); if let LifetimeRes::Param { param, binder } = res { match self.lifetime_uses.entry(param) { @@ -1880,7 +1880,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { match rib.kind { LifetimeRibKind::AnonymousCreateParameter { binder, .. } => { let res = self.create_fresh_lifetime(lifetime.ident, binder, kind); - self.record_lifetime_res(lifetime.id, res, elision_candidate); + self.record_lifetime_use(lifetime.id, res, elision_candidate); return; } LifetimeRibKind::StaticIfNoLifetimeInScope { lint_id: node_id, emit_lint } => { @@ -1898,7 +1898,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } } if lifetimes_in_scope.is_empty() { - self.record_lifetime_res( + self.record_lifetime_use( lifetime.id, LifetimeRes::Static, elision_candidate, @@ -2006,7 +2006,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { return; } LifetimeRibKind::Elided(res) => { - self.record_lifetime_res(lifetime.id, res, elision_candidate); + self.record_lifetime_use(lifetime.id, res, elision_candidate); return; } LifetimeRibKind::ElisionFailure => { @@ -2123,7 +2123,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { let id = self.r.next_node_id(); let lt = Lifetime { id, ident: Ident::new(kw::UnderscoreLifetime, span) }; - self.record_lifetime_res( + self.record_lifetime_use( anchor_id, LifetimeRes::ElidedAnchor { start: id, end: id + 1 }, LifetimeElisionCandidate::Ignore, @@ -2144,7 +2144,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { // Leave the responsibility to create the `LocalDefId` to lowering. let param = self.r.next_node_id(); let res = LifetimeRes::Fresh { param, binder, kind }; - self.record_lifetime_param(param, res); + self.record_lifetime_def(param, res); // Record the created lifetime parameter so lowering can pick it up and add it to HIR. self.r @@ -2207,7 +2207,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } let node_ids = self.r.next_node_ids(expected_lifetimes); - self.record_lifetime_res( + self.record_lifetime_use( segment_id, LifetimeRes::ElidedAnchor { start: node_ids.start, end: node_ids.end }, LifetimeElisionCandidate::Ignore, @@ -2233,7 +2233,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { // Do not create a parameter for patterns and expressions: type checking can infer // the appropriate lifetime for us. for id in node_ids { - self.record_lifetime_res( + self.record_lifetime_use( id, LifetimeRes::Infer, LifetimeElisionCandidate::Named, @@ -2302,7 +2302,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { let mut candidate = LifetimeElisionCandidate::Missing(missing_lifetime); for id in node_ids { let res = self.create_fresh_lifetime(ident, binder, kind); - self.record_lifetime_res( + self.record_lifetime_use( id, res, replace(&mut candidate, LifetimeElisionCandidate::Named), @@ -2313,7 +2313,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { LifetimeRibKind::Elided(res) => { let mut candidate = LifetimeElisionCandidate::Missing(missing_lifetime); for id in node_ids { - self.record_lifetime_res( + self.record_lifetime_use( id, res, replace(&mut candidate, LifetimeElisionCandidate::Ignore), @@ -2376,14 +2376,15 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } } + /// Register a use of an already defined lifetime. #[instrument(level = "debug", skip(self))] - fn record_lifetime_res( + fn record_lifetime_use( &mut self, id: NodeId, res: LifetimeRes, candidate: LifetimeElisionCandidate, ) { - self.record_lifetime_param(id, res); + self.record_lifetime_def(id, res); match res { LifetimeRes::Param { .. } | LifetimeRes::Fresh { .. } | LifetimeRes::Static { .. } => { @@ -2395,13 +2396,16 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } } + /// Can be used for both definitions and uses of lifetimes, as an error + /// has already been reported. #[instrument(level = "debug", skip(self))] fn record_lifetime_err(&mut self, id: NodeId, guar: ErrorGuaranteed) { - self.record_lifetime_param(id, LifetimeRes::Error(guar)); + self.record_lifetime_def(id, LifetimeRes::Error(guar)); } + /// Define a new lifetime (e.g. in generics) #[instrument(level = "debug", skip(self))] - fn record_lifetime_param(&mut self, id: NodeId, res: LifetimeRes) { + fn record_lifetime_def(&mut self, id: NodeId, res: LifetimeRes) { if let Some(prev_res) = self.r.lifetimes_res_map.insert(id, res) { panic!( "lifetime parameter {id:?} resolved multiple times ({prev_res:?} before, {res:?} now)" @@ -3189,7 +3193,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } GenericParamKind::Lifetime => { let res = LifetimeRes::Param { param: def_id, binder }; - self.record_lifetime_param(param.id, res); + self.record_lifetime_def(param.id, res); function_lifetime_rib.bindings.insert(ident, (param.id, res)); continue; } From bf5045cae0ce9af1632f610f376264ada78b45f0 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 12 May 2026 12:38:57 +0200 Subject: [PATCH 05/25] Drop an unused distinction (in diagnostics code) between anonymous and named lifetimes --- compiler/rustc_resolve/src/late.rs | 12 +++++------- compiler/rustc_resolve/src/late/diagnostics.rs | 4 +--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 1b3da5b9dcbb1..2a06244fd117a 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -1751,7 +1751,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { self.record_lifetime_use( lifetime.id, LifetimeRes::Static, - LifetimeElisionCandidate::Named, + LifetimeElisionCandidate::Ignore, ); return; } @@ -1764,7 +1764,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { while let Some(rib) = lifetime_rib_iter.next() { let normalized_ident = ident.normalize_to_macros_2_0(); if let Some(&(_, res)) = rib.bindings.get(&normalized_ident) { - self.record_lifetime_use(lifetime.id, res, LifetimeElisionCandidate::Named); + self.record_lifetime_use(lifetime.id, res, LifetimeElisionCandidate::Ignore); if let LifetimeRes::Param { param, binder } = res { match self.lifetime_uses.entry(param) { @@ -2236,7 +2236,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { self.record_lifetime_use( id, LifetimeRes::Infer, - LifetimeElisionCandidate::Named, + LifetimeElisionCandidate::Ignore, ); } continue; @@ -2305,7 +2305,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { self.record_lifetime_use( id, res, - replace(&mut candidate, LifetimeElisionCandidate::Named), + replace(&mut candidate, LifetimeElisionCandidate::Ignore), ); } break; @@ -2529,9 +2529,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { }); all_candidates.extend(candidates.into_iter().filter_map(|(_, candidate)| { match candidate { - LifetimeElisionCandidate::Ignore | LifetimeElisionCandidate::Named => { - None - } + LifetimeElisionCandidate::Ignore => None, LifetimeElisionCandidate::Missing(missing) => Some(missing), } })); diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 419a47b126980..423c13ff87d37 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -149,10 +149,8 @@ pub(super) struct ElisionFnParameter { /// This is used to suggest introducing an explicit lifetime. #[derive(Clone, Copy, Debug)] pub(super) enum LifetimeElisionCandidate { - /// This is not a real lifetime. + /// This is not a real lifetime, or it is a named lifetime, in which case we won't suggest anything. Ignore, - /// There is a named lifetime, we won't suggest anything. - Named, Missing(MissingLifetime), } From c0819ffeca08e91b720d3f9feadc7550c17d9276 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 12 May 2026 15:19:31 +0200 Subject: [PATCH 06/25] Remove some dead code --- compiler/rustc_ast_lowering/src/item.rs | 2 +- compiler/rustc_ast_lowering/src/lib.rs | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index e38415caaa222..89052a19f57b6 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1928,7 +1928,7 @@ impl<'hir> LoweringContext<'_, 'hir> { // Introduce extra lifetimes if late resolution tells us to. let extra_lifetimes = self.resolver.extra_lifetime_params(parent_node_id); - params.extend(extra_lifetimes.into_iter().filter_map(|&(ident, node_id, res)| { + params.extend(extra_lifetimes.into_iter().map(|&(ident, node_id, res)| { self.lifetime_res_to_generic_param( ident, node_id, diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index a916ee1f143bd..8d973ad3f1889 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -950,11 +950,8 @@ impl<'hir> LoweringContext<'_, 'hir> { node_id: NodeId, res: LifetimeRes, source: hir::GenericParamSource, - ) -> Option> { + ) -> hir::GenericParam<'hir> { let (name, kind) = match res { - LifetimeRes::Param { .. } => { - (hir::ParamName::Plain(ident), hir::LifetimeParamKind::Explicit) - } LifetimeRes::Fresh { param, kind, .. } => { // Late resolution delegates to us the creation of the `LocalDefId`. let _def_id = self.create_def( @@ -967,7 +964,6 @@ impl<'hir> LoweringContext<'_, 'hir> { (hir::ParamName::Fresh, hir::LifetimeParamKind::Elided(kind)) } - LifetimeRes::Static { .. } | LifetimeRes::Error(..) => return None, res => panic!( "Unexpected lifetime resolution {:?} for {:?} at {:?}", res, ident, ident.span @@ -975,7 +971,7 @@ impl<'hir> LoweringContext<'_, 'hir> { }; let hir_id = self.lower_node_id(node_id); let def_id = self.local_def_id(node_id); - Some(hir::GenericParam { + hir::GenericParam { hir_id, def_id, name, @@ -984,7 +980,7 @@ impl<'hir> LoweringContext<'_, 'hir> { kind: hir::GenericParamKind::Lifetime { kind }, colon_span: None, source, - }) + } } /// Lowers a lifetime binder that defines `generic_params`, returning the corresponding HIR @@ -1005,7 +1001,7 @@ impl<'hir> LoweringContext<'_, 'hir> { debug!(?extra_lifetimes); let extra_lifetimes: Vec<_> = extra_lifetimes .iter() - .filter_map(|&(ident, node_id, res)| { + .map(|&(ident, node_id, res)| { self.lifetime_res_to_generic_param( ident, node_id, From 87f9c4f5b592a1cba95d406b1431c46a98fec5e2 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 12 May 2026 15:37:28 +0200 Subject: [PATCH 07/25] Remove an unused field --- compiler/rustc_hir/src/def.rs | 2 -- compiler/rustc_resolve/src/late.rs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index ad5d6b1509dfd..d275d5a28b88a 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -991,8 +991,6 @@ pub enum LifetimeRes { /// /// Creating the associated `LocalDefId` is the responsibility of lowering. param: NodeId, - /// Id of the introducing place. See `Param`. - binder: NodeId, /// Kind of elided lifetime kind: hir::MissingLifetimeKind, }, diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 2a06244fd117a..91464f768cea9 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -2143,7 +2143,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { // Leave the responsibility to create the `LocalDefId` to lowering. let param = self.r.next_node_id(); - let res = LifetimeRes::Fresh { param, binder, kind }; + let res = LifetimeRes::Fresh { param, kind }; self.record_lifetime_def(param, res); // Record the created lifetime parameter so lowering can pick it up and add it to HIR. From 19a5af7d86f19668e8b73f341c86adb2fa17fe2e Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 12 May 2026 15:39:25 +0200 Subject: [PATCH 08/25] extra_lifetime_params_map can only ever contain `LifetimeRes::Fresh`, so just encode the fields we need --- compiler/rustc_ast_lowering/src/item.rs | 4 +-- compiler/rustc_ast_lowering/src/lib.rs | 35 +++++++++---------------- compiler/rustc_middle/src/ty/mod.rs | 5 ++-- compiler/rustc_resolve/src/late.rs | 2 +- compiler/rustc_resolve/src/lib.rs | 4 +-- 5 files changed, 20 insertions(+), 30 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 89052a19f57b6..0a50d9fffe775 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1928,11 +1928,11 @@ impl<'hir> LoweringContext<'_, 'hir> { // Introduce extra lifetimes if late resolution tells us to. let extra_lifetimes = self.resolver.extra_lifetime_params(parent_node_id); - params.extend(extra_lifetimes.into_iter().map(|&(ident, node_id, res)| { + params.extend(extra_lifetimes.into_iter().map(|&(ident, node_id, kind)| { self.lifetime_res_to_generic_param( ident, node_id, - res, + kind, hir::GenericParamSource::Generics, ) })); diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 8d973ad3f1889..2366cb8db462d 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -55,7 +55,7 @@ use rustc_hir::definitions::PerParentDisambiguatorState; use rustc_hir::lints::DelayedLint; use rustc_hir::{ self as hir, AngleBrackets, ConstArg, GenericArg, HirId, ItemLocalMap, LifetimeSource, - LifetimeSyntax, ParamName, Target, TraitCandidate, find_attr, + LifetimeSyntax, MissingLifetimeKind, ParamName, Target, TraitCandidate, find_attr, }; use rustc_index::{Idx, IndexSlice, IndexVec}; use rustc_macros::extension; @@ -310,7 +310,7 @@ impl<'tcx> ResolverAstLowering<'tcx> { /// /// The extra lifetimes that appear from the parenthesized `Fn`-trait desugaring /// should appear at the enclosing `PolyTraitRef`. - fn extra_lifetime_params(&self, id: NodeId) -> &[(Ident, NodeId, LifetimeRes)] { + fn extra_lifetime_params(&self, id: NodeId) -> &[(Ident, NodeId, MissingLifetimeKind)] { self.extra_lifetime_params_map.get(&id).map_or(&[], |v| &v[..]) } @@ -948,36 +948,27 @@ impl<'hir> LoweringContext<'_, 'hir> { &mut self, ident: Ident, node_id: NodeId, - res: LifetimeRes, + kind: MissingLifetimeKind, source: hir::GenericParamSource, ) -> hir::GenericParam<'hir> { - let (name, kind) = match res { - LifetimeRes::Fresh { param, kind, .. } => { - // Late resolution delegates to us the creation of the `LocalDefId`. - let _def_id = self.create_def( - param, - Some(kw::UnderscoreLifetime), - DefKind::LifetimeParam, - ident.span, - ); - debug!(?_def_id); + // Late resolution delegates to us the creation of the `LocalDefId`. + let _def_id = self.create_def( + node_id, + Some(kw::UnderscoreLifetime), + DefKind::LifetimeParam, + ident.span, + ); + debug!(?_def_id); - (hir::ParamName::Fresh, hir::LifetimeParamKind::Elided(kind)) - } - res => panic!( - "Unexpected lifetime resolution {:?} for {:?} at {:?}", - res, ident, ident.span - ), - }; let hir_id = self.lower_node_id(node_id); let def_id = self.local_def_id(node_id); hir::GenericParam { hir_id, def_id, - name, + name: hir::ParamName::Fresh, span: self.lower_span(ident.span), pure_wrt_drop: false, - kind: hir::GenericParamKind::Lifetime { kind }, + kind: hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Elided(kind) }, colon_span: None, source, } diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 74f9e75fb48c0..2958b2d5cd590 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -37,12 +37,11 @@ use rustc_data_structures::stable_hash::{StableHash, StableHashCtxt, StableHashe use rustc_data_structures::steal::Steal; use rustc_data_structures::unord::{UnordMap, UnordSet}; use rustc_errors::{Diag, ErrorGuaranteed, LintBuffer}; -use rustc_hir as hir; use rustc_hir::attrs::StrippedCfgItem; use rustc_hir::def::{CtorKind, CtorOf, DefKind, DocLinkResMap, LifetimeRes, Res}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap}; use rustc_hir::definitions::PerParentDisambiguatorState; -use rustc_hir::{LangItem, attrs as attr, find_attr}; +use rustc_hir::{self as hir, LangItem, MissingLifetimeKind, attrs as attr, find_attr}; use rustc_index::IndexVec; use rustc_index::bit_set::BitMatrix; use rustc_macros::{ @@ -232,7 +231,7 @@ pub struct ResolverAstLowering<'tcx> { /// Resolutions for lifetimes. pub lifetimes_res_map: NodeMap, /// Lifetime parameters that lowering will have to introduce. - pub extra_lifetime_params_map: NodeMap>, + pub extra_lifetime_params_map: NodeMap>, pub next_node_id: ast::NodeId, diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 91464f768cea9..5c709998cfe32 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -2151,7 +2151,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { .extra_lifetime_params_map .entry(binder) .or_insert_with(Vec::new) - .push((ident, param, res)); + .push((ident, param, kind)); res } diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 22c4f4576d44b..2ce50b23ac5ed 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -58,7 +58,7 @@ use rustc_hir::def::{ }; use rustc_hir::def_id::{CRATE_DEF_ID, CrateNum, DefId, LOCAL_CRATE, LocalDefId, LocalDefIdMap}; use rustc_hir::definitions::{PerParentDisambiguatorState, PerParentDisambiguatorsMap}; -use rustc_hir::{PrimTy, TraitCandidate, find_attr}; +use rustc_hir::{MissingLifetimeKind, PrimTy, TraitCandidate, find_attr}; use rustc_index::bit_set::DenseBitSet; use rustc_metadata::creader::CStore; use rustc_middle::metadata::{AmbigModChild, ModChild, Reexport}; @@ -1385,7 +1385,7 @@ pub struct Resolver<'ra, 'tcx> { /// Resolutions for lifetimes. lifetimes_res_map: NodeMap = Default::default(), /// Lifetime parameters that lowering will have to introduce. - extra_lifetime_params_map: NodeMap> = Default::default(), + extra_lifetime_params_map: NodeMap> = Default::default(), /// `CrateNum` resolutions of `extern crate` items. extern_crate_map: UnordMap = Default::default(), From c8aba3e9889c9f501300f519c0d8dc4075bf402f Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Thu, 28 May 2026 13:12:34 +0000 Subject: [PATCH 09/25] Stabilize Path::is_empty --- library/std/src/path.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 222bf77996c7f..3ff591b1907d3 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -2854,7 +2854,6 @@ impl Path { /// # Examples /// /// ``` - /// #![feature(path_is_empty)] /// use std::path::Path; /// /// let path = Path::new(""); @@ -2866,7 +2865,7 @@ impl Path { /// let path = Path::new("."); /// assert!(!path.is_empty()); /// ``` - #[unstable(feature = "path_is_empty", issue = "148494")] + #[stable(feature = "path_is_empty", since = "CURRENT_RUSTC_VERSION")] pub fn is_empty(&self) -> bool { self.as_os_str().is_empty() } From 420566f17095a6c138f2f2ec58b7a799859365f9 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 28 May 2026 16:17:04 +0200 Subject: [PATCH 10/25] Remove a hack introduced back when unwinding through extern "C" was UB --- library/proc_macro/src/bridge/client.rs | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/library/proc_macro/src/bridge/client.rs b/library/proc_macro/src/bridge/client.rs index 696cd4ee3d887..0e37d05d08571 100644 --- a/library/proc_macro/src/bridge/client.rs +++ b/library/proc_macro/src/bridge/client.rs @@ -250,7 +250,7 @@ fn run_client Decode<'a, 's, ()>, R: Encode<()>>( ) -> Buffer { let BridgeConfig { input: mut buf, dispatch, force_show_panics, .. } = config; - panic::catch_unwind(panic::AssertUnwindSafe(|| { + let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { maybe_install_panic_hook(force_show_panics); // Make sure the symbol store is empty before decoding inputs. @@ -267,23 +267,12 @@ fn run_client Decode<'a, 's, ()>, R: Encode<()>>( // Take the `cached_buffer` back out, for the output value. buf = RefCell::into_inner(state).cached_buffer; - // HACK(eddyb) Separate encoding a success value (`Ok(output)`) - // from encoding a panic (`Err(e: PanicMessage)`) to avoid - // having handles outside the `bridge.enter(|| ...)` scope, and - // to catch panics that could happen while encoding the success. - // - // Note that panics should be impossible beyond this point, but - // this is defensively trying to avoid any accidental panicking - // reaching the `extern "C"` (which should `abort` but might not - // at the moment, so this is also potentially preventing UB). - buf.clear(); - Ok::<_, ()>(output).encode(&mut buf, &mut ()); - })) - .map_err(PanicMessage::from) - .unwrap_or_else(|e| { - buf.clear(); - Err::<(), _>(e).encode(&mut buf, &mut ()); - }); + output + })); + + // Serialize response of type `Result`. + buf.clear(); + res.map_err(PanicMessage::from).encode(&mut buf, &mut ()); // Now that a response has been serialized, invalidate all symbols // registered with the interner. From 32615f248aabb8094405378a8ca7a4dbfd423a95 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 28 May 2026 16:19:49 +0200 Subject: [PATCH 11/25] Implement Encode and Decode for proc_macro::TokenStream wrapper type --- library/proc_macro/src/bridge/client.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/library/proc_macro/src/bridge/client.rs b/library/proc_macro/src/bridge/client.rs index 0e37d05d08571..70f9da89427cc 100644 --- a/library/proc_macro/src/bridge/client.rs +++ b/library/proc_macro/src/bridge/client.rs @@ -47,6 +47,18 @@ impl Decode<'_, '_, S> for TokenStream { } } +impl Encode<()> for crate::TokenStream { + fn encode(self, w: &mut Buffer, s: &mut ()) { + self.0.encode(w, s) + } +} + +impl Decode<'_, '_, ()> for crate::TokenStream { + fn decode(r: &mut &[u8], s: &mut ()) -> Self { + crate::TokenStream(Some(Decode::decode(r, s))) + } +} + #[derive(Copy, Clone, PartialEq, Eq, Hash)] pub(crate) struct Span { handle: handle::Handle, @@ -244,9 +256,9 @@ fn maybe_install_panic_hook(force_show_panics: bool) { /// Client-side helper for handling client panics, entering the bridge, /// deserializing input and serializing output. // FIXME(eddyb) maybe replace `Bridge::enter` with this? -fn run_client Decode<'a, 's, ()>, R: Encode<()>>( +fn run_client Decode<'a, 's, ()>>( config: BridgeConfig<'_>, - f: impl FnOnce(A) -> R, + f: impl FnOnce(A) -> crate::TokenStream, ) -> Buffer { let BridgeConfig { input: mut buf, dispatch, force_show_panics, .. } = config; @@ -285,7 +297,7 @@ impl Client { Client { handle_counters: &COUNTERS, run: super::selfless_reify::reify_to_extern_c_fn_hrt_bridge(move |bridge| { - run_client(bridge, |input| f(crate::TokenStream(Some(input))).0) + run_client(bridge, |input| f(input)) }), _marker: PhantomData, } @@ -299,9 +311,7 @@ impl Client<(crate::TokenStream, crate::TokenStream), crate::TokenStream> { Client { handle_counters: &COUNTERS, run: super::selfless_reify::reify_to_extern_c_fn_hrt_bridge(move |bridge| { - run_client(bridge, |(input, input2)| { - f(crate::TokenStream(Some(input)), crate::TokenStream(Some(input2))).0 - }) + run_client(bridge, |(input, input2)| f(input, input2)) }), _marker: PhantomData, } From 53b4acd60aaca7bff177d310257b7faec8ef2008 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 28 May 2026 17:09:02 +0200 Subject: [PATCH 12/25] Remove outdated comment --- library/proc_macro/src/bridge/client.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/library/proc_macro/src/bridge/client.rs b/library/proc_macro/src/bridge/client.rs index 70f9da89427cc..40f4052472617 100644 --- a/library/proc_macro/src/bridge/client.rs +++ b/library/proc_macro/src/bridge/client.rs @@ -255,7 +255,6 @@ fn maybe_install_panic_hook(force_show_panics: bool) { /// Client-side helper for handling client panics, entering the bridge, /// deserializing input and serializing output. -// FIXME(eddyb) maybe replace `Bridge::enter` with this? fn run_client Decode<'a, 's, ()>>( config: BridgeConfig<'_>, f: impl FnOnce(A) -> crate::TokenStream, From 5c56e618df39aebbaa4a6c5c1c04f44b896d0d69 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 28 May 2026 17:45:32 +0200 Subject: [PATCH 13/25] Remove unused proc_macro table from crate metadata --- compiler/rustc_metadata/src/rmeta/encoder.rs | 1 - compiler/rustc_metadata/src/rmeta/mod.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index a0db004b7f4c4..261bf935b5a3b 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -2034,7 +2034,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { let def_id = id.to_def_id(); self.tables.def_kind.set_some(def_id.index, DefKind::Macro(macro_kind.into())); - self.tables.proc_macro.set_some(def_id.index, macro_kind); self.encode_attrs(id); record!(self.tables.def_keys[def_id] <- def_key); record!(self.tables.def_ident_span[def_id] <- span); diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index a3645a5556bf3..6a396faf914cc 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -464,7 +464,6 @@ define_tables! { variant_data: Table>, assoc_container: Table>, macro_definition: Table>, - proc_macro: Table, deduced_param_attrs: Table>, collect_return_position_impl_trait_in_trait_tys: Table>>>>, doc_link_resolutions: Table>, From bde798a604dbe12b4913b4676eb427dfc3f2bffd Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 28 May 2026 18:54:06 +0200 Subject: [PATCH 14/25] Use platform independent encoding for integers in proc-macro RPC This makes the proc-macro RPC protocol platform independent as necessary for running proc macros and rustc on different architectures. --- library/proc_macro/src/bridge/rpc.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/library/proc_macro/src/bridge/rpc.rs b/library/proc_macro/src/bridge/rpc.rs index 2ada18205673e..8804cf8459abf 100644 --- a/library/proc_macro/src/bridge/rpc.rs +++ b/library/proc_macro/src/bridge/rpc.rs @@ -15,20 +15,30 @@ pub(super) trait Decode<'a, 's, S>: Sized { } macro_rules! rpc_encode_decode { - (le $ty:ty) => { + (le $ty:ident $size:literal) => { impl Encode for $ty { fn encode(self, w: &mut Buffer, _: &mut S) { - w.extend_from_array(&self.to_le_bytes()); + const N: usize = size_of::<$ty>(); + + // We can pad with zeros without changing the value because of + // little endian encoding. + let mut bytes = [0; $size]; + bytes[..N].copy_from_slice(&self.to_le_bytes()); + + w.extend_from_array(&bytes); } } impl Decode<'_, '_, S> for $ty { fn decode(r: &mut &[u8], _: &mut S) -> Self { const N: usize = size_of::<$ty>(); + const { + assert!(N <= $size); + } let mut bytes = [0; N]; bytes.copy_from_slice(&r[..N]); - *r = &r[N..]; + *r = &r[$size..]; Self::from_le_bytes(bytes) } @@ -108,8 +118,8 @@ impl Decode<'_, '_, S> for u8 { } } -rpc_encode_decode!(le u32); -rpc_encode_decode!(le usize); +rpc_encode_decode!(le u32 4); +rpc_encode_decode!(le usize 8); impl Encode for bool { fn encode(self, w: &mut Buffer, s: &mut S) { From d31c7316c65c3953473b75d31ca3fd9b76c65df9 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 28 May 2026 21:41:24 +0200 Subject: [PATCH 15/25] Move handle counters to the server side This shrinks the proc-macro ABI a bit. Nothing on the client side needs to allocate handles. This will share the counters between proc-macros, which may cause us to run out of handles earlier, but 4 bilion handles per process is still a lot. Rust-analyzer might run out at some point, but it can recover by restarting the proc-macro-server, and it could already run out before this change anyway, --- library/proc_macro/src/bridge/client.rs | 14 ------------ library/proc_macro/src/bridge/server.rs | 29 ++++++++++--------------- 2 files changed, 12 insertions(+), 31 deletions(-) diff --git a/library/proc_macro/src/bridge/client.rs b/library/proc_macro/src/bridge/client.rs index 40f4052472617..3d8ad719f7176 100644 --- a/library/proc_macro/src/bridge/client.rs +++ b/library/proc_macro/src/bridge/client.rs @@ -2,19 +2,9 @@ use std::cell::RefCell; use std::marker::PhantomData; -use std::sync::atomic::AtomicU32; use super::*; -#[repr(C)] -pub(super) struct HandleCounters { - pub(super) token_stream: AtomicU32, - pub(super) span: AtomicU32, -} - -static COUNTERS: HandleCounters = - HandleCounters { token_stream: AtomicU32::new(1), span: AtomicU32::new(1) }; - pub(crate) struct TokenStream { handle: handle::Handle, } @@ -221,8 +211,6 @@ pub(crate) fn is_available() -> bool { /// and forcing the use of APIs that take/return `S::TokenStream`, server-side. #[repr(C)] pub struct Client { - pub(super) handle_counters: &'static HandleCounters, - pub(super) run: extern "C" fn(BridgeConfig<'_>) -> Buffer, pub(super) _marker: PhantomData O>, @@ -294,7 +282,6 @@ fn run_client Decode<'a, 's, ()>>( impl Client { pub const fn expand1(f: impl Fn(crate::TokenStream) -> crate::TokenStream + Copy) -> Self { Client { - handle_counters: &COUNTERS, run: super::selfless_reify::reify_to_extern_c_fn_hrt_bridge(move |bridge| { run_client(bridge, |input| f(input)) }), @@ -308,7 +295,6 @@ impl Client<(crate::TokenStream, crate::TokenStream), crate::TokenStream> { f: impl Fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream + Copy, ) -> Self { Client { - handle_counters: &COUNTERS, run: super::selfless_reify::reify_to_extern_c_fn_hrt_bridge(move |bridge| { run_client(bridge, |(input, input2)| f(input, input2)) }), diff --git a/library/proc_macro/src/bridge/server.rs b/library/proc_macro/src/bridge/server.rs index 1151798fccf40..6a739da7641d1 100644 --- a/library/proc_macro/src/bridge/server.rs +++ b/library/proc_macro/src/bridge/server.rs @@ -1,6 +1,7 @@ //! Server-side traits. use std::cell::Cell; +use std::sync::atomic::AtomicU32; use std::sync::mpsc; use super::*; @@ -11,10 +12,13 @@ pub(super) struct HandleStore { } impl HandleStore { - fn new(handle_counters: &'static client::HandleCounters) -> Self { + fn new() -> Self { + static TOKEN_STREAM: AtomicU32 = AtomicU32::new(1); + static SPAN: AtomicU32 = AtomicU32::new(1); + HandleStore { - token_stream: handle::OwnedStore::new(&handle_counters.token_stream), - span: handle::InternedStore::new(&handle_counters.span), + token_stream: handle::OwnedStore::new(&TOKEN_STREAM), + span: handle::InternedStore::new(&SPAN), } } } @@ -246,13 +250,12 @@ fn run_server< O: for<'a, 's> Decode<'a, 's, HandleStore>, >( strategy: &impl ExecutionStrategy, - handle_counters: &'static client::HandleCounters, server: S, input: I, run_client: extern "C" fn(BridgeConfig<'_>) -> Buffer, force_show_panics: bool, ) -> Result { - let mut dispatcher = Dispatcher { handle_store: HandleStore::new(handle_counters), server }; + let mut dispatcher = Dispatcher { handle_store: HandleStore::new(), server }; let globals = dispatcher.server.globals(); @@ -276,16 +279,9 @@ impl client::Client { where S: Server, { - let client::Client { handle_counters, run, _marker } = *self; - run_server( - strategy, - handle_counters, - server, - >::mark(input), - run, - force_show_panics, - ) - .map(|s| >>::unmark(s).unwrap_or_default()) + let client::Client { run, _marker } = *self; + run_server(strategy, server, >::mark(input), run, force_show_panics) + .map(|s| >>::unmark(s).unwrap_or_default()) } } @@ -301,10 +297,9 @@ impl client::Client<(crate::TokenStream, crate::TokenStream), crate::TokenStream where S: Server, { - let client::Client { handle_counters, run, _marker } = *self; + let client::Client { run, _marker } = *self; run_server( strategy, - handle_counters, server, (>::mark(input), >::mark(input2)), run, From fade967190f81699cabd98f72a8db212008e7bf9 Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Sat, 4 Apr 2026 16:39:41 -0700 Subject: [PATCH 16/25] Give variables passed to Omp/Offload nice names on LLVM-IR level --- .../src/builder/gpu_offload.rs | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs b/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs index 73822eb7ec50c..cea9b81f96534 100644 --- a/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs +++ b/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs @@ -319,25 +319,25 @@ impl KernelArgsTy { geps: [&'ll Value; 3], workgroup_dims: &'ll Value, thread_dims: &'ll Value, - ) -> [(Align, &'ll Value); 13] { + ) -> [(Align, &'ll str, &'ll Value); 13] { let four = Align::from_bytes(4).expect("4 Byte alignment should work"); let eight = Align::EIGHT; [ - (four, cx.get_const_i32(KernelArgsTy::OFFLOAD_VERSION)), - (four, cx.get_const_i32(num_args)), - (eight, geps[0]), - (eight, geps[1]), - (eight, geps[2]), - (eight, memtransfer_types), + (four, "Version", cx.get_const_i32(KernelArgsTy::OFFLOAD_VERSION)), + (four, "NumArgs", cx.get_const_i32(num_args)), + (eight, "ArgBasePtrs", geps[0]), + (eight, "ArgPtrs", geps[1]), + (eight, "ArgSizes", geps[2]), + (eight, "ArgTypes", memtransfer_types), // The next two are debug infos. FIXME(offload): set them - (eight, cx.const_null(cx.type_ptr())), // dbg - (eight, cx.const_null(cx.type_ptr())), // dbg - (eight, cx.get_const_i64(KernelArgsTy::TRIPCOUNT)), - (eight, cx.get_const_i64(KernelArgsTy::FLAGS)), - (four, workgroup_dims), - (four, thread_dims), - (four, cx.get_const_i32(0)), + (eight, "ArgNames", cx.const_null(cx.type_ptr())), // dbg + (eight, "ArgMappers", cx.const_null(cx.type_ptr())), // dbg + (eight, "Tripcount", cx.get_const_i64(KernelArgsTy::TRIPCOUNT)), + (eight, "Flags", cx.get_const_i64(KernelArgsTy::FLAGS)), + (four, "NumTeams", workgroup_dims), + (four, "ThreadLimit", thread_dims), + (four, "DynCGroupMem", cx.get_const_i32(0)), ] } } @@ -760,7 +760,10 @@ pub(crate) fn gen_call_handling<'ll, 'tcx>( // Here we fill the KernelArgsTy, see the documentation above for (i, value) in values.iter().enumerate() { let ptr = builder.inbounds_gep(tgt_kernel_decl, a5, &[i32_0, cx.get_const_i32(i as u64)]); - builder.store(value.1, ptr, value.0); + let name = std::ffi::CString::new(value.1).unwrap(); + llvm::set_value_name(ptr, &name.as_bytes()); + + builder.store(value.2, ptr, value.0); } let args = vec![ From c01bfdc4052d9566188b3a85f32a698a3eddede2 Mon Sep 17 00:00:00 2001 From: Manuel Drehwald Date: Thu, 28 May 2026 14:55:38 -0700 Subject: [PATCH 17/25] Enable requesting shared-memory at kernel launch-time via offload --- .../src/builder/gpu_offload.rs | 15 ++++++++++++--- compiler/rustc_codegen_llvm/src/intrinsic.rs | 17 +++++++++++++++-- .../rustc_hir_analysis/src/check/intrinsic.rs | 1 + library/core/src/intrinsics/mod.rs | 1 + tests/codegen-llvm/gpu_offload/control_flow.rs | 3 ++- tests/codegen-llvm/gpu_offload/gpu_host.rs | 10 +++++----- tests/codegen-llvm/gpu_offload/scalar_host.rs | 10 +++++----- tests/codegen-llvm/gpu_offload/slice_host.rs | 4 ++-- 8 files changed, 43 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs b/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs index cea9b81f96534..0b009321802cf 100644 --- a/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs +++ b/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs @@ -319,6 +319,7 @@ impl KernelArgsTy { geps: [&'ll Value; 3], workgroup_dims: &'ll Value, thread_dims: &'ll Value, + dyn_cache: &'ll Value, ) -> [(Align, &'ll str, &'ll Value); 13] { let four = Align::from_bytes(4).expect("4 Byte alignment should work"); let eight = Align::EIGHT; @@ -337,7 +338,7 @@ impl KernelArgsTy { (eight, "Flags", cx.get_const_i64(KernelArgsTy::FLAGS)), (four, "NumTeams", workgroup_dims), (four, "ThreadLimit", thread_dims), - (four, "DynCGroupMem", cx.get_const_i32(0)), + (four, "DynCGroupMem", dyn_cache), ] } } @@ -589,6 +590,7 @@ pub(crate) fn gen_call_handling<'ll, 'tcx>( metadata: &[OffloadMetadata], offload_globals: &OffloadGlobals<'ll>, offload_dims: &OffloadKernelDims<'ll>, + dyn_cache: &'ll Value, ) { let cx = builder.cx; let OffloadKernelGlobals { @@ -753,8 +755,15 @@ pub(crate) fn gen_call_handling<'ll, 'tcx>( num_args, s_ident_t, ); - let values = - KernelArgsTy::new(&cx, num_args, memtransfer_kernel, geps, workgroup_dims, thread_dims); + let values = KernelArgsTy::new( + &cx, + num_args, + memtransfer_kernel, + geps, + workgroup_dims, + thread_dims, + dyn_cache, + ); // Step 3) // Here we fill the KernelArgsTy, see the documentation above diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 957ea23b9167c..577f8624af95c 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -1937,7 +1937,11 @@ fn codegen_offload<'ll, 'tcx>( }; let offload_dims = OffloadKernelDims::from_operands(bx, &args[1], &args[2]); - let args = get_args_from_tuple(bx, args[3], fn_target); + let dyn_cache = match args[3].val { + OperandValue::Immediate(val) => val, + _ => panic!("unparsable"), + }; + let args = get_args_from_tuple(bx, args[4], fn_target); let target_symbol = symbol_name_for_instance_in_crate(tcx, fn_target, LOCAL_CRATE); let sig = tcx.fn_sig(fn_target.def_id()).skip_binder(); @@ -1969,7 +1973,16 @@ fn codegen_offload<'ll, 'tcx>( }; register_offload(cx); let offload_data = gen_define_handling(&cx, &metadata, target_symbol, offload_globals); - gen_call_handling(bx, &offload_data, &args, &types, &metadata, offload_globals, &offload_dims); + gen_call_handling( + bx, + &offload_data, + &args, + &types, + &metadata, + offload_globals, + &offload_dims, + &dyn_cache, + ); } fn get_args_from_tuple<'ll, 'tcx>( diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs index c1edbb4fc520d..e366a2f982247 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs @@ -356,6 +356,7 @@ pub(crate) fn check_intrinsic_type( param(0), Ty::new_array_with_const_len(tcx, tcx.types.u32, Const::from_target_usize(tcx, 3)), Ty::new_array_with_const_len(tcx, tcx.types.u32, Const::from_target_usize(tcx, 3)), + tcx.types.u32, param(1), ], param(2), diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index 82a7e3be9228e..68fbd8c31e768 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -3569,6 +3569,7 @@ pub const fn offload( f: F, workgroup_dim: [u32; 3], thread_dim: [u32; 3], + dyn_cache: u32, args: T, ) -> R; diff --git a/tests/codegen-llvm/gpu_offload/control_flow.rs b/tests/codegen-llvm/gpu_offload/control_flow.rs index 503e9e4221cdc..605a6f08843c3 100644 --- a/tests/codegen-llvm/gpu_offload/control_flow.rs +++ b/tests/codegen-llvm/gpu_offload/control_flow.rs @@ -19,7 +19,7 @@ // CHECK-NOT define // CHECK: bb3 // CHECK: call void @__tgt_target_data_begin_mapper(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 1, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull @.offload_sizes.foo, ptr nonnull @.offload_maptypes.foo.begin, ptr null, ptr null) -// CHECK: %10 = call i32 @__tgt_target_kernel(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 256, i32 32, ptr nonnull @.foo.region_id, ptr nonnull %kernel_args) +// CHECK: = call i32 @__tgt_target_kernel(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 256, i32 32, ptr nonnull @.foo.region_id, ptr nonnull %kernel_args) // CHECK-NEXT: call void @__tgt_target_data_end_mapper(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 1, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull @.offload_sizes.foo, ptr nonnull @.offload_maptypes.foo.end, ptr null, ptr null) #[unsafe(no_mangle)] unsafe fn main() { @@ -30,6 +30,7 @@ unsafe fn main() { foo, [256, 1, 1], [32, 1, 1], + 0, (A.as_ptr() as *const [f32; 6],), ); } diff --git a/tests/codegen-llvm/gpu_offload/gpu_host.rs b/tests/codegen-llvm/gpu_offload/gpu_host.rs index 8179d868da95f..2bfaf89b45590 100644 --- a/tests/codegen-llvm/gpu_offload/gpu_host.rs +++ b/tests/codegen-llvm/gpu_offload/gpu_host.rs @@ -21,7 +21,7 @@ fn main() { } pub fn kernel_1(x: &mut [f32; 256], y: &[f32; 256]) { - core::intrinsics::offload(_kernel_1, [256, 1, 1], [32, 1, 1], (x, y)) + core::intrinsics::offload(_kernel_1, [256, 1, 1], [32, 1, 1], 0, (x, y)) } #[inline(never)] @@ -52,8 +52,8 @@ pub fn _kernel_1(x: &mut [f32; 256], y: &[f32; 256]) { // CHECK-LABEL: define{{( dso_local)?}} void @main() // CHECK-NEXT: start: -// CHECK-NEXT: %0 = alloca [8 x i8], align 8 -// CHECK-NEXT: %1 = alloca [8 x i8], align 8 +// CHECK-NEXT: {{%[^ ]+}} = alloca [8 x i8], align 8 +// CHECK-NEXT: {{%[^ ]+}} = alloca [8 x i8], align 8 // CHECK-NEXT: %y = alloca [1024 x i8], align 16 // CHECK-NEXT: %x = alloca [1024 x i8], align 16 // CHECK-NEXT: %.offload_baseptrs = alloca [2 x ptr], align 8 @@ -61,9 +61,9 @@ pub fn _kernel_1(x: &mut [f32; 256], y: &[f32; 256]) { // CHECK-NEXT: %kernel_args = alloca %struct.__tgt_kernel_arguments, align 8 // CHECK: store ptr %x, ptr %.offload_baseptrs, align 8 // CHECK-NEXT: store ptr %x, ptr %.offload_ptrs, align 8 -// CHECK-NEXT: [[BPTRS_1:%.*]] = getelementptr inbounds nuw i8, ptr %.offload_baseptrs, i64 8 +// CHECK-NEXT: [[BPTRS_1:%[^ ]+]] = getelementptr inbounds nuw i8, ptr %.offload_baseptrs, i64 8 // CHECK-NEXT: store ptr %y, ptr [[BPTRS_1]], align 8 -// CHECK-NEXT: [[PTRS_1:%.*]] = getelementptr inbounds nuw i8, ptr %.offload_ptrs, i64 8 +// CHECK-NEXT: [[PTRS_1:%[^ ]+]] = getelementptr inbounds nuw i8, ptr %.offload_ptrs, i64 8 // CHECK-NEXT: store ptr %y, ptr [[PTRS_1]], align 8 // CHECK-NEXT: call void @__tgt_target_data_begin_mapper(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 2, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull @.offload_sizes.[[K]], ptr nonnull @.offload_maptypes.[[K]].begin, ptr null, ptr null) // CHECK-NEXT: store i32 3, ptr %kernel_args, align 8 diff --git a/tests/codegen-llvm/gpu_offload/scalar_host.rs b/tests/codegen-llvm/gpu_offload/scalar_host.rs index d5b40fb0a26db..3470761be06c8 100644 --- a/tests/codegen-llvm/gpu_offload/scalar_host.rs +++ b/tests/codegen-llvm/gpu_offload/scalar_host.rs @@ -13,11 +13,11 @@ // CHECK: define{{( dso_local)?}} void @main() // CHECK-NOT: define // CHECK: %addr = alloca i64, align 8 -// CHECK: store double 4.200000e+01, ptr %0, align 8 -// CHECK: %_0.i = load double, ptr %0, align 8 -// CHECK: store double %_0.i, ptr %addr, align 8 +// CHECK: store double 4.200000e+01, ptr [[TMP:%[^,]+]], align 8 +// CHECK: [[VAL:%[0-9]+]] = load double, ptr [[TMP]], align 8 +// CHECK: store double [[VAL]], ptr %addr, align 8 // CHECK: %1 = getelementptr inbounds nuw i8, ptr %.offload_baseptrs, i64 8 -// CHECK-NEXT: store double %_0.i, ptr %1, align 8 +// CHECK-NEXT: store double [[VAL]], ptr %1, align 8 // CHECK-NEXT: %2 = getelementptr inbounds nuw i8, ptr %.offload_ptrs, i64 8 // CHECK-NEXT: store ptr %addr, ptr %2, align 8 // CHECK-NEXT: call void @__tgt_target_data_begin_mapper @@ -27,7 +27,7 @@ fn main() { let mut x = 0.0; let k = core::hint::black_box(42.0); - core::intrinsics::offload::<_, _, ()>(foo, [1, 1, 1], [1, 1, 1], (&mut x, k)); + core::intrinsics::offload::<_, _, ()>(foo, [1, 1, 1], [1, 1, 1], 0, (&mut x, k)); } unsafe extern "C" { diff --git a/tests/codegen-llvm/gpu_offload/slice_host.rs b/tests/codegen-llvm/gpu_offload/slice_host.rs index 62f12da079d82..d4157d24e03dd 100644 --- a/tests/codegen-llvm/gpu_offload/slice_host.rs +++ b/tests/codegen-llvm/gpu_offload/slice_host.rs @@ -21,13 +21,13 @@ // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr {{.*}} %.offload_sizes, ptr {{.*}} @.offload_sizes.foo, i64 16, i1 false) // CHECK: store i64 16, ptr %.offload_sizes, align 8 // CHECK: call void @__tgt_target_data_begin_mapper(ptr nonnull @anon.[[ID]].1, i64 -1, i32 2, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull %.offload_sizes, ptr nonnull @.offload_maptypes.[[K]].begin, ptr null, ptr null) -// CHECK: %11 = call i32 @__tgt_target_kernel(ptr nonnull @anon.[[ID]].1, i64 -1, i32 1, i32 1, ptr nonnull @.foo.region_id, ptr nonnull %kernel_args) +// CHECK: call i32 @__tgt_target_kernel(ptr nonnull @anon.[[ID]].1, i64 -1, i32 1, i32 1, ptr nonnull @.foo.region_id, ptr nonnull %kernel_args) // CHECK-NEXT: call void @__tgt_target_data_end_mapper(ptr nonnull @anon.[[ID]].1, i64 -1, i32 2, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull %.offload_sizes, ptr nonnull @.offload_maptypes.[[K]].end, ptr null, ptr null) #[unsafe(no_mangle)] fn main() { let mut x = [0.0, 0.0, 0.0, 0.0]; - core::intrinsics::offload::<_, _, ()>(foo, [1, 1, 1], [1, 1, 1], ((&mut x) as &mut [f64],)); + core::intrinsics::offload::<_, _, ()>(foo, [1, 1, 1], [1, 1, 1], 0, ((&mut x) as &mut [f64],)); } unsafe extern "C" { From a1d4ad104f0a1b7cda7a07973faa185364f5105e Mon Sep 17 00:00:00 2001 From: Aria Givens Date: Thu, 28 May 2026 12:56:58 -0400 Subject: [PATCH 18/25] Suggest using NameValue syntax for malformed deprecated attribute --- .../rustc_attr_parsing/src/attributes/deprecation.rs | 10 ++++++++++ tests/ui/deprecation/deprecation-sanity.stderr | 6 ++++++ tests/ui/error-codes/E0565-1.stderr | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/compiler/rustc_attr_parsing/src/attributes/deprecation.rs b/compiler/rustc_attr_parsing/src/attributes/deprecation.rs index 3b6dd7a67ed17..fd8616c4e9ea0 100644 --- a/compiler/rustc_attr_parsing/src/attributes/deprecation.rs +++ b/compiler/rustc_attr_parsing/src/attributes/deprecation.rs @@ -76,6 +76,16 @@ impl SingleAttributeParser for DeprecatedParser { // ok } ArgParser::List(list) => { + // If the argument list contains a single string literal, suggest using NameValue syntax + if let Some(elem) = list.as_single() && let Some(lit) = elem.as_lit() && lit.kind.is_str() { + let mut adcx = cx.adcx(); + if let Some(span) = args.span() { + adcx.push_suggestion(String::from("try using `=` instead"), span, format!(" = {}", lit.kind)); + } + adcx.expected_not_literal(elem.span()); + return None; + } + for param in list.mixed() { let Some(param) = param.meta_item() else { cx.adcx().expected_not_literal(param.span()); diff --git a/tests/ui/deprecation/deprecation-sanity.stderr b/tests/ui/deprecation/deprecation-sanity.stderr index 427d14d89c19f..d0e5a8a3ed4a5 100644 --- a/tests/ui/deprecation/deprecation-sanity.stderr +++ b/tests/ui/deprecation/deprecation-sanity.stderr @@ -55,6 +55,12 @@ LL | #[deprecated("test")] | ^^^^^^^^^^^^^------^^ | | | didn't expect a literal here + | +help: try using `=` instead + | +LL - #[deprecated("test")] +LL + #[deprecated = "test"] + | error: multiple `deprecated` attributes --> $DIR/deprecation-sanity.rs:29:1 diff --git a/tests/ui/error-codes/E0565-1.stderr b/tests/ui/error-codes/E0565-1.stderr index d1aff042e8fb6..0c500d2cbf231 100644 --- a/tests/ui/error-codes/E0565-1.stderr +++ b/tests/ui/error-codes/E0565-1.stderr @@ -5,6 +5,12 @@ LL | #[deprecated("since")] | ^^^^^^^^^^^^^-------^^ | | | didn't expect a literal here + | +help: try using `=` instead + | +LL - #[deprecated("since")] +LL + #[deprecated = "since"] + | error: aborting due to 1 previous error From 9bfbf3426c06fcb7dd90ae20fe3117ccccb95a88 Mon Sep 17 00:00:00 2001 From: Aria Givens Date: Thu, 28 May 2026 14:04:46 -0400 Subject: [PATCH 19/25] Suggest using since field when malformed deprecated attribute value is version shaped --- .../src/attributes/deprecation.rs | 60 ++++++++++++++----- tests/ui/deprecation/deprecation-sanity.rs | 3 + .../ui/deprecation/deprecation-sanity.stderr | 23 +++++-- 3 files changed, 66 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/deprecation.rs b/compiler/rustc_attr_parsing/src/attributes/deprecation.rs index fd8616c4e9ea0..e0adbb0900deb 100644 --- a/compiler/rustc_attr_parsing/src/attributes/deprecation.rs +++ b/compiler/rustc_attr_parsing/src/attributes/deprecation.rs @@ -1,3 +1,4 @@ +use rustc_ast::LitKind; use rustc_hir::attrs::{DeprecatedSince, Deprecation}; use rustc_hir::{RustcVersion, VERSION_PLACEHOLDER}; @@ -76,12 +77,34 @@ impl SingleAttributeParser for DeprecatedParser { // ok } ArgParser::List(list) => { - // If the argument list contains a single string literal, suggest using NameValue syntax - if let Some(elem) = list.as_single() && let Some(lit) = elem.as_lit() && lit.kind.is_str() { + // If the argument list contains a single string literal: + // check whether it may be a version and suggest since field + // otherwise, suggest using NameValue syntax + if let Some(elem) = list.as_single() + && let Some(lit) = elem.as_lit() + && let LitKind::Str(text, _) = lit.kind + { let mut adcx = cx.adcx(); - if let Some(span) = args.span() { - adcx.push_suggestion(String::from("try using `=` instead"), span, format!(" = {}", lit.kind)); - } + + match parse_since(text, true) { + DeprecatedSince::Future | DeprecatedSince::RustcVersion(_) => { + adcx.push_suggestion( + String::from("try specifying a deprecated since version"), + elem.span(), + format!("since = {}", lit.kind), + ); + } + _ => { + if let Some(span) = args.span() { + adcx.push_suggestion( + String::from("try using `=` instead"), + span, + format!(" = {}", lit.kind), + ); + } + } + }; + adcx.expected_not_literal(elem.span()); return None; } @@ -143,18 +166,11 @@ impl SingleAttributeParser for DeprecatedParser { } let since = if let Some(since) = since { - if since.as_str() == "TBD" { - DeprecatedSince::Future - } else if !is_rustc { - DeprecatedSince::NonStandard(since) - } else if since.as_str() == VERSION_PLACEHOLDER { - DeprecatedSince::RustcVersion(RustcVersion::CURRENT) - } else if let Some(version) = parse_version(since) { - DeprecatedSince::RustcVersion(version) - } else { + let since = parse_since(since, is_rustc); + if matches!(since, DeprecatedSince::Err) { cx.emit_err(InvalidSince { span: cx.attr_span }); - DeprecatedSince::Err } + since } else if is_rustc { cx.emit_err(MissingSince { span: cx.attr_span }); DeprecatedSince::Err @@ -173,3 +189,17 @@ impl SingleAttributeParser for DeprecatedParser { }) } } + +fn parse_since(since: Symbol, is_rustc: bool) -> DeprecatedSince { + if since.as_str() == "TBD" { + DeprecatedSince::Future + } else if !is_rustc { + DeprecatedSince::NonStandard(since) + } else if since.as_str() == VERSION_PLACEHOLDER { + DeprecatedSince::RustcVersion(RustcVersion::CURRENT) + } else if let Some(version) = parse_version(since) { + DeprecatedSince::RustcVersion(version) + } else { + DeprecatedSince::Err + } +} diff --git a/tests/ui/deprecation/deprecation-sanity.rs b/tests/ui/deprecation/deprecation-sanity.rs index d1061dc1e170b..0ad491186cc38 100644 --- a/tests/ui/deprecation/deprecation-sanity.rs +++ b/tests/ui/deprecation/deprecation-sanity.rs @@ -23,6 +23,9 @@ mod bogus_attribute_types_1 { #[deprecated("test")] //~ ERROR malformed `deprecated` attribute input [E0565] fn f8() { } + + #[deprecated("1.2.3")] //~ ERROR malformed `deprecated` attribute input [E0565] + fn f9() { } } #[deprecated(since = "a", note = "b")] diff --git a/tests/ui/deprecation/deprecation-sanity.stderr b/tests/ui/deprecation/deprecation-sanity.stderr index d0e5a8a3ed4a5..2e00b2efea5c5 100644 --- a/tests/ui/deprecation/deprecation-sanity.stderr +++ b/tests/ui/deprecation/deprecation-sanity.stderr @@ -62,20 +62,33 @@ LL - #[deprecated("test")] LL + #[deprecated = "test"] | +error[E0565]: malformed `deprecated` attribute input + --> $DIR/deprecation-sanity.rs:27:5 + | +LL | #[deprecated("1.2.3")] + | ^^^^^^^^^^^^^-------^^ + | | + | didn't expect a literal here + | +help: try specifying a deprecated since version + | +LL | #[deprecated(since = "1.2.3")] + | +++++++ + error: multiple `deprecated` attributes - --> $DIR/deprecation-sanity.rs:29:1 + --> $DIR/deprecation-sanity.rs:32:1 | LL | #[deprecated(since = "a", note = "b")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute | note: attribute also specified here - --> $DIR/deprecation-sanity.rs:28:1 + --> $DIR/deprecation-sanity.rs:31:1 | LL | #[deprecated(since = "a", note = "b")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0538]: malformed `deprecated` attribute input - --> $DIR/deprecation-sanity.rs:32:1 + --> $DIR/deprecation-sanity.rs:35:1 | LL | #[deprecated(since = "a", since = "b", note = "c")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^-----------^^^^^^^^^^^^^^ @@ -83,7 +96,7 @@ LL | #[deprecated(since = "a", since = "b", note = "c")] | found `since` used as a key more than once error: `#[deprecated]` attribute cannot be used on trait impl blocks - --> $DIR/deprecation-sanity.rs:37:1 + --> $DIR/deprecation-sanity.rs:40:1 | LL | #[deprecated = "hello"] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -92,7 +105,7 @@ LL | #[deprecated = "hello"] = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, and use statements = note: `#[deny(useless_deprecated)]` on by default -error: aborting due to 10 previous errors +error: aborting due to 11 previous errors Some errors have detailed explanations: E0538, E0539, E0565. For more information about an error, try `rustc --explain E0538`. From 942ac855dc786a8eb98546d9e96982b2c8ee2e4b Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 28 May 2026 12:25:53 +0200 Subject: [PATCH 20/25] Eagerly resolve delegations in late resolution --- compiler/rustc_ast_lowering/src/delegation.rs | 22 +++++------------ compiler/rustc_middle/src/ty/mod.rs | 7 ++++-- compiler/rustc_resolve/src/late.rs | 24 ++++++++++++++----- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs index df5ea7c3168ff..411b27e0dd9f4 100644 --- a/compiler/rustc_ast_lowering/src/delegation.rs +++ b/compiler/rustc_ast_lowering/src/delegation.rs @@ -124,7 +124,7 @@ impl<'hir> LoweringContext<'_, 'hir> { // Delegation can be unresolved in illegal places such as function bodies in extern blocks (see #151356) let sig_id = if let Some(delegation_info) = self.resolver.delegation_info(self.owner.def_id) { - self.get_sig_id(delegation_info.resolution_node, span) + self.get_sig_id(delegation_info.resolution_id, span) } else { self.dcx().span_delayed_bug( span, @@ -223,22 +223,12 @@ impl<'hir> LoweringContext<'_, 'hir> { .collect::>() } - fn get_sig_id(&self, mut node_id: NodeId, span: Span) -> Result { - let mut visited: FxHashSet = Default::default(); + fn get_sig_id(&self, mut def_id: DefId, span: Span) -> Result { + let mut visited: FxHashSet = Default::default(); let mut path: SmallVec<[DefId; 1]> = Default::default(); loop { - visited.insert(node_id); - - let Some(def_id) = self.get_resolution_id(node_id) else { - return Err(self.tcx.dcx().span_delayed_bug( - span, - format!( - "LoweringContext: couldn't resolve node {:?} in delegation item", - node_id - ), - )); - }; + visited.insert(def_id); path.push(def_id); @@ -248,8 +238,8 @@ impl<'hir> LoweringContext<'_, 'hir> { if let Some(local_id) = def_id.as_local() && let Some(delegation_info) = self.resolver.delegation_info(local_id) { - node_id = delegation_info.resolution_node; - if visited.contains(&node_id) { + def_id = delegation_info.resolution_id; + if visited.contains(&def_id) { // We encountered a cycle in the resolution, or delegation callee refers to non-existent // entity, in this case emit an error. return Err(match visited.len() { diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 74f9e75fb48c0..f4a5e7bc1ff4a 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -253,9 +253,12 @@ pub struct ResolverAstLowering<'tcx> { #[derive(Debug)] pub struct DelegationInfo { - // NodeId (either delegation.id or item_id in case of a trait impl) for signature resolution, + // `DefId` (either the resolution at delegation.id or item_id in case of a trait impl) for signature resolution, // for details see https://github.com/rust-lang/rust/issues/118212#issuecomment-2160686914 - pub resolution_node: ast::NodeId, + /// Refers to the next element in a delegation resolution chain. + /// Usually points to the final resolution, as most "chains" are just + /// one step to a trait or an impl. + pub resolution_id: DefId, } #[derive(Clone, Copy, Debug, StableHash)] diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index fb8de90d28aca..e7ec557243fa1 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -3923,12 +3923,24 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { this.visit_path(&delegation.path); }); - self.r.delegation_infos.insert( - self.r.current_owner.def_id, - DelegationInfo { - resolution_node: if is_in_trait_impl { item_id } else { delegation.id }, - }, - ); + let resolution_id = if is_in_trait_impl { item_id } else { delegation.id }; + let def_id = self + .r + .partial_res_map + .get(&resolution_id) + .and_then(|r| r.expect_full_res().opt_def_id()); + if let Some(resolution_id) = def_id { + self.r + .delegation_infos + .insert(self.r.current_owner.def_id, DelegationInfo { resolution_id }); + } else { + self.r.tcx.dcx().span_delayed_bug( + delegation.path.span, + format!( + "LoweringContext: couldn't resolve node {resolution_id:?} in delegation item", + ), + ); + }; let Some(body) = &delegation.body else { return }; self.with_rib(ValueNS, RibKind::FnOrCoroutine, |this| { From f582193db55de1a111006d6b8e7e307b84950b4b Mon Sep 17 00:00:00 2001 From: Daria Sukhonina Date: Fri, 29 May 2026 12:29:32 +0300 Subject: [PATCH 21/25] Update reproducibly failing tests when parallel frontend is enabled --- .../diagnostics/liveness.rs | 2 +- tests/ui/lint/unused/unused-assign-148960.rs | 1 + .../lint/unused/unused-assign-148960.stderr | 14 +-- tests/ui/liveness/liveness-consts.rs | 1 + tests/ui/liveness/liveness-consts.stderr | 22 ++-- tests/ui/liveness/liveness-dead.rs | 1 + tests/ui/liveness/liveness-dead.stderr | 10 +- tests/ui/liveness/liveness-upvars.rs | 1 + tests/ui/liveness/liveness-upvars.stderr | 50 ++++----- ...signments-diverging-branch-issue-156416.rs | 1 + ...ments-diverging-branch-issue-156416.stderr | 10 +- .../empty-types.exhaustive_patterns.stderr | 100 +++++++++--------- .../usefulness/empty-types.never_pats.stderr | 86 +++++++-------- .../usefulness/empty-types.normal.stderr | 86 +++++++-------- tests/ui/pattern/usefulness/empty-types.rs | 1 + 15 files changed, 196 insertions(+), 190 deletions(-) diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs b/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs index 641066b002273..e5f7ed3a8d774 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs @@ -1,6 +1,6 @@ //@ edition:2021 - //@ check-pass +//@ ignore-parallel-frontend unstable liveness diagnostics #![allow(unreachable_code)] #![warn(unused)] #![allow(dead_code)] diff --git a/tests/ui/lint/unused/unused-assign-148960.rs b/tests/ui/lint/unused/unused-assign-148960.rs index 2e51c01398a37..b7e129a4f2ab7 100644 --- a/tests/ui/lint/unused/unused-assign-148960.rs +++ b/tests/ui/lint/unused/unused-assign-148960.rs @@ -1,4 +1,5 @@ //@ check-fail +//@ ignore-parallel-frontend unstable liveness diagnostics #![deny(unused)] #![allow(dead_code)] diff --git a/tests/ui/lint/unused/unused-assign-148960.stderr b/tests/ui/lint/unused/unused-assign-148960.stderr index aa5326cea6476..60966beb36ab6 100644 --- a/tests/ui/lint/unused/unused-assign-148960.stderr +++ b/tests/ui/lint/unused/unused-assign-148960.stderr @@ -1,5 +1,5 @@ error: value assigned to `value` is never read - --> $DIR/unused-assign-148960.rs:6:21 + --> $DIR/unused-assign-148960.rs:7:21 | LL | let mut value = b"0".to_vec(); | ^^^^^^^^^^^^^ this value is reassigned later and never used @@ -7,14 +7,14 @@ LL | value = b"1".to_vec(); | ----- `value` is overwritten here before the previous value is read | note: the lint level is defined here - --> $DIR/unused-assign-148960.rs:2:9 + --> $DIR/unused-assign-148960.rs:3:9 | LL | #![deny(unused)] | ^^^^^^ = note: `#[deny(unused_assignments)]` implied by `#[deny(unused)]` error: value assigned to `x` is never read - --> $DIR/unused-assign-148960.rs:12:17 + --> $DIR/unused-assign-148960.rs:13:17 | LL | let mut x = 1; | ^ this value is reassigned later and never used @@ -22,7 +22,7 @@ LL | x = 2; | ----- `x` is overwritten here before the previous value is read error: value assigned to `x` is never read - --> $DIR/unused-assign-148960.rs:13:5 + --> $DIR/unused-assign-148960.rs:14:5 | LL | x = 2; | ^^^^^ this value is reassigned later and never used @@ -30,7 +30,7 @@ LL | x = 3; | ----- `x` is overwritten here before the previous value is read error: value assigned to `p` is never read - --> $DIR/unused-assign-148960.rs:24:17 + --> $DIR/unused-assign-148960.rs:25:17 | LL | let mut p = Point { x: 1, y: 1 }; | ^^^^^^^^^^^^^^^^^^^^ this value is reassigned later and never used @@ -38,7 +38,7 @@ LL | p = Point { x: 2, y: 2 }; | ------------------------ `p` is overwritten here before the previous value is read error: variable `foo` is assigned to, but never used - --> $DIR/unused-assign-148960.rs:38:9 + --> $DIR/unused-assign-148960.rs:39:9 | LL | let mut foo = Foo; | ^^^^^^^ @@ -52,7 +52,7 @@ LL + let Foo = Foo; | error: value assigned to `foo` is never read - --> $DIR/unused-assign-148960.rs:39:5 + --> $DIR/unused-assign-148960.rs:40:5 | LL | foo = Foo; | ^^^ diff --git a/tests/ui/liveness/liveness-consts.rs b/tests/ui/liveness/liveness-consts.rs index 7e56bf8c2cda4..b239e12b2e021 100644 --- a/tests/ui/liveness/liveness-consts.rs +++ b/tests/ui/liveness/liveness-consts.rs @@ -1,4 +1,5 @@ //@ check-pass +//@ ignore-parallel-frontend unstable liveness diagnostics #![warn(unused)] #![allow(unreachable_code)] diff --git a/tests/ui/liveness/liveness-consts.stderr b/tests/ui/liveness/liveness-consts.stderr index 6b4acf1c8de9a..f4a5b82725346 100644 --- a/tests/ui/liveness/liveness-consts.stderr +++ b/tests/ui/liveness/liveness-consts.stderr @@ -1,30 +1,30 @@ warning: unused variable: `e` - --> $DIR/liveness-consts.rs:26:13 + --> $DIR/liveness-consts.rs:27:13 | LL | let e = 1; | ^ help: if this is intentional, prefix it with an underscore: `_e` | note: the lint level is defined here - --> $DIR/liveness-consts.rs:2:9 + --> $DIR/liveness-consts.rs:3:9 | LL | #![warn(unused)] | ^^^^^^ = note: `#[warn(unused_variables)]` implied by `#[warn(unused)]` warning: unused variable: `s` - --> $DIR/liveness-consts.rs:35:24 + --> $DIR/liveness-consts.rs:36:24 | LL | pub fn f(x: [u8; { let s = 17; 100 }]) -> [u8; { let z = 18; 100 }] { | ^ help: if this is intentional, prefix it with an underscore: `_s` warning: unused variable: `z` - --> $DIR/liveness-consts.rs:35:55 + --> $DIR/liveness-consts.rs:36:55 | LL | pub fn f(x: [u8; { let s = 17; 100 }]) -> [u8; { let z = 18; 100 }] { | ^ help: if this is intentional, prefix it with an underscore: `_z` warning: variable `a` is assigned to, but never used - --> $DIR/liveness-consts.rs:7:9 + --> $DIR/liveness-consts.rs:8:9 | LL | let mut a = 0; | ^^^^^ @@ -32,7 +32,7 @@ LL | let mut a = 0; = note: consider using `_a` instead warning: value assigned to `a` is never read - --> $DIR/liveness-consts.rs:11:9 + --> $DIR/liveness-consts.rs:12:9 | LL | a += 1; | ^^^^^^ @@ -41,7 +41,7 @@ LL | a += 1; = note: `#[warn(unused_assignments)]` implied by `#[warn(unused)]` warning: value assigned to `b` is never read - --> $DIR/liveness-consts.rs:18:17 + --> $DIR/liveness-consts.rs:19:17 | LL | let mut b = 1; | ^ this value is reassigned later and never used @@ -49,7 +49,7 @@ LL | b += 1; | ------ `b` is overwritten here before the previous value is read warning: value assigned to `b` is never read - --> $DIR/liveness-consts.rs:19:5 + --> $DIR/liveness-consts.rs:20:5 | LL | b += 1; | ^^^^^^ this value is reassigned later and never used @@ -57,13 +57,13 @@ LL | b = 42; | ------ `b` is overwritten here before the previous value is read warning: unused variable: `z` - --> $DIR/liveness-consts.rs:62:13 + --> $DIR/liveness-consts.rs:63:13 | LL | let z = 42; | ^ help: if this is intentional, prefix it with an underscore: `_z` warning: value assigned to `t` is never read - --> $DIR/liveness-consts.rs:44:9 + --> $DIR/liveness-consts.rs:45:9 | LL | t = t + t; | ^^^^^^^^^ @@ -71,7 +71,7 @@ LL | t = t + t; = help: maybe it is overwritten before being read? warning: unused variable: `w` - --> $DIR/liveness-consts.rs:51:13 + --> $DIR/liveness-consts.rs:52:13 | LL | let w = 10; | ^ help: if this is intentional, prefix it with an underscore: `_w` diff --git a/tests/ui/liveness/liveness-dead.rs b/tests/ui/liveness/liveness-dead.rs index 004663c85ee50..c48b28ef74fec 100644 --- a/tests/ui/liveness/liveness-dead.rs +++ b/tests/ui/liveness/liveness-dead.rs @@ -1,3 +1,4 @@ +//@ ignore-parallel-frontend unstable liveness diagnostics #![allow(dead_code)] #![deny(unused_assignments)] diff --git a/tests/ui/liveness/liveness-dead.stderr b/tests/ui/liveness/liveness-dead.stderr index ade0e04d2e7a9..2288fae52091a 100644 --- a/tests/ui/liveness/liveness-dead.stderr +++ b/tests/ui/liveness/liveness-dead.stderr @@ -1,5 +1,5 @@ error: value assigned to `x` is never read - --> $DIR/liveness-dead.rs:9:24 + --> $DIR/liveness-dead.rs:10:24 | LL | let mut x: isize = 3; | ^ this value is reassigned later and never used @@ -7,13 +7,13 @@ LL | x = 4; | ----- `x` is overwritten here before the previous value is read | note: the lint level is defined here - --> $DIR/liveness-dead.rs:2:9 + --> $DIR/liveness-dead.rs:3:9 | LL | #![deny(unused_assignments)] | ^^^^^^^^^^^^^^^^^^ error: value assigned to `x` is never read - --> $DIR/liveness-dead.rs:17:5 + --> $DIR/liveness-dead.rs:18:5 | LL | x = 4; | ^^^^^ @@ -21,7 +21,7 @@ LL | x = 4; = help: maybe it is overwritten before being read? error: value passed to `x` is never read - --> $DIR/liveness-dead.rs:20:7 + --> $DIR/liveness-dead.rs:21:7 | LL | fn f4(mut x: i32) { | ^^^^^ @@ -29,7 +29,7 @@ LL | fn f4(mut x: i32) { = help: maybe it is overwritten before being read? error: value assigned to `x` is never read - --> $DIR/liveness-dead.rs:27:5 + --> $DIR/liveness-dead.rs:28:5 | LL | x = 4; | ^^^^^ diff --git a/tests/ui/liveness/liveness-upvars.rs b/tests/ui/liveness/liveness-upvars.rs index be58b48a40576..1a3d0e5be54ad 100644 --- a/tests/ui/liveness/liveness-upvars.rs +++ b/tests/ui/liveness/liveness-upvars.rs @@ -1,5 +1,6 @@ //@ edition:2018 //@ check-pass +//@ ignore-parallel-frontend unstable liveness diagnostics #![feature(coroutines, stmt_expr_attributes)] #![warn(unused)] #![allow(unreachable_code)] diff --git a/tests/ui/liveness/liveness-upvars.stderr b/tests/ui/liveness/liveness-upvars.stderr index 96a922772c919..b569acdccf8a7 100644 --- a/tests/ui/liveness/liveness-upvars.stderr +++ b/tests/ui/liveness/liveness-upvars.stderr @@ -1,19 +1,19 @@ warning: value captured by `last` is never read - --> $DIR/liveness-upvars.rs:10:9 + --> $DIR/liveness-upvars.rs:11:9 | LL | last = Some(s); | ^^^^ | = help: did you mean to capture by reference instead? note: the lint level is defined here - --> $DIR/liveness-upvars.rs:4:9 + --> $DIR/liveness-upvars.rs:5:9 | LL | #![warn(unused)] | ^^^^^^ = note: `#[warn(unused_assignments)]` implied by `#[warn(unused)]` warning: value assigned to `last` is never read - --> $DIR/liveness-upvars.rs:10:9 + --> $DIR/liveness-upvars.rs:11:9 | LL | last = Some(s); | ^^^^^^^^^^^^^^ @@ -21,7 +21,7 @@ LL | last = Some(s); = help: maybe it is overwritten before being read? warning: value captured by `sum` is never read - --> $DIR/liveness-upvars.rs:22:9 + --> $DIR/liveness-upvars.rs:23:9 | LL | sum += x; | ^^^ @@ -29,7 +29,7 @@ LL | sum += x; = help: did you mean to capture by reference instead? warning: value assigned to `sum` is never read - --> $DIR/liveness-upvars.rs:22:9 + --> $DIR/liveness-upvars.rs:23:9 | LL | sum += x; | ^^^^^^^^ @@ -37,7 +37,7 @@ LL | sum += x; = help: maybe it is overwritten before being read? warning: value assigned to `c` is never read - --> $DIR/liveness-upvars.rs:69:9 + --> $DIR/liveness-upvars.rs:70:9 | LL | c += 1; | ^^^^^^ @@ -45,7 +45,7 @@ LL | c += 1; = help: maybe it is overwritten before being read? warning: value assigned to `c` is never read - --> $DIR/liveness-upvars.rs:63:9 + --> $DIR/liveness-upvars.rs:64:9 | LL | c += 1; | ^^^^^^ @@ -53,7 +53,7 @@ LL | c += 1; = help: maybe it is overwritten before being read? warning: value captured by `c` is never read - --> $DIR/liveness-upvars.rs:49:9 + --> $DIR/liveness-upvars.rs:50:9 | LL | c += 1; | ^ @@ -61,7 +61,7 @@ LL | c += 1; = help: did you mean to capture by reference instead? warning: value assigned to `c` is never read - --> $DIR/liveness-upvars.rs:49:9 + --> $DIR/liveness-upvars.rs:50:9 | LL | c += 1; | ^^^^^^ @@ -69,7 +69,7 @@ LL | c += 1; = help: maybe it is overwritten before being read? warning: value captured by `c` is never read - --> $DIR/liveness-upvars.rs:44:9 + --> $DIR/liveness-upvars.rs:45:9 | LL | c += 1; | ^ @@ -77,7 +77,7 @@ LL | c += 1; = help: did you mean to capture by reference instead? warning: value assigned to `c` is never read - --> $DIR/liveness-upvars.rs:44:9 + --> $DIR/liveness-upvars.rs:45:9 | LL | c += 1; | ^^^^^^ @@ -85,7 +85,7 @@ LL | c += 1; = help: maybe it is overwritten before being read? warning: value captured by `c` is never read - --> $DIR/liveness-upvars.rs:38:9 + --> $DIR/liveness-upvars.rs:39:9 | LL | c = 1; | ^ @@ -93,7 +93,7 @@ LL | c = 1; = help: did you mean to capture by reference instead? warning: value captured by `c` is never read - --> $DIR/liveness-upvars.rs:34:9 + --> $DIR/liveness-upvars.rs:35:9 | LL | c = 1; | ^ @@ -101,7 +101,7 @@ LL | c = 1; = help: did you mean to capture by reference instead? warning: value captured by `e` is never read - --> $DIR/liveness-upvars.rs:82:13 + --> $DIR/liveness-upvars.rs:83:13 | LL | e = Some("e1"); | ^ @@ -109,7 +109,7 @@ LL | e = Some("e1"); = help: did you mean to capture by reference instead? warning: value assigned to `e` is never read - --> $DIR/liveness-upvars.rs:82:13 + --> $DIR/liveness-upvars.rs:83:13 | LL | e = Some("e1"); | ^^^^^^^^^^^^^^ this value is reassigned later and never used @@ -118,7 +118,7 @@ LL | e = Some("e2"); | -------------- `e` is overwritten here before the previous value is read warning: value assigned to `e` is never read - --> $DIR/liveness-upvars.rs:84:13 + --> $DIR/liveness-upvars.rs:85:13 | LL | e = Some("e2"); | ^^^^^^^^^^^^^^ @@ -126,7 +126,7 @@ LL | e = Some("e2"); = help: maybe it is overwritten before being read? warning: value assigned to `d` is never read - --> $DIR/liveness-upvars.rs:78:13 + --> $DIR/liveness-upvars.rs:79:13 | LL | d = Some("d1"); | ^^^^^^^^^^^^^^ this value is reassigned later and never used @@ -134,7 +134,7 @@ LL | d = Some("d2"); | -------------- `d` is overwritten here before the previous value is read warning: value assigned to `v` is never read - --> $DIR/liveness-upvars.rs:92:13 + --> $DIR/liveness-upvars.rs:93:13 | LL | v = T::default(); | ^ @@ -142,7 +142,7 @@ LL | v = T::default(); = help: maybe it is overwritten before being read? warning: value captured by `z` is never read - --> $DIR/liveness-upvars.rs:105:17 + --> $DIR/liveness-upvars.rs:106:17 | LL | z = T::default(); | ^ @@ -150,7 +150,7 @@ LL | z = T::default(); = help: did you mean to capture by reference instead? warning: value assigned to `z` is never read - --> $DIR/liveness-upvars.rs:105:17 + --> $DIR/liveness-upvars.rs:106:17 | LL | z = T::default(); | ^^^^^^^^^^^^^^^^ @@ -158,7 +158,7 @@ LL | z = T::default(); = help: maybe it is overwritten before being read? warning: value captured by `state` is never read - --> $DIR/liveness-upvars.rs:131:9 + --> $DIR/liveness-upvars.rs:132:9 | LL | state = 4; | ^^^^^ @@ -166,7 +166,7 @@ LL | state = 4; = help: did you mean to capture by reference instead? warning: value assigned to `state` is never read - --> $DIR/liveness-upvars.rs:131:9 + --> $DIR/liveness-upvars.rs:132:9 | LL | state = 4; | ^^^^^^^^^ this value is reassigned later and never used @@ -175,7 +175,7 @@ LL | state = 5; | --------- `state` is overwritten here before the previous value is read warning: value assigned to `state` is never read - --> $DIR/liveness-upvars.rs:134:9 + --> $DIR/liveness-upvars.rs:135:9 | LL | state = 5; | ^^^^^^^^^ @@ -183,7 +183,7 @@ LL | state = 5; = help: maybe it is overwritten before being read? warning: value assigned to `s` is never read - --> $DIR/liveness-upvars.rs:143:9 + --> $DIR/liveness-upvars.rs:144:9 | LL | s = 1; | ^^^^^ this value is reassigned later and never used @@ -191,7 +191,7 @@ LL | yield (s = 2); | ------- `s` is overwritten here before the previous value is read warning: value assigned to `s` is never read - --> $DIR/liveness-upvars.rs:145:9 + --> $DIR/liveness-upvars.rs:146:9 | LL | s = yield (); | ^^^^^^^^^^^^ this value is reassigned later and never used diff --git a/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.rs b/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.rs index 08cffa00f752f..d1fb55d874518 100644 --- a/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.rs +++ b/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.rs @@ -1,4 +1,5 @@ //@ run-pass +//@ ignore-parallel-frontend unstable liveness diagnostics #![allow(dead_code)] #![warn(unused_assignments)] diff --git a/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.stderr b/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.stderr index 5afb33626e055..4ec4a3d3839b7 100644 --- a/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.stderr +++ b/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.stderr @@ -1,18 +1,18 @@ warning: value assigned to `x` is never read - --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:10:9 + --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:11:9 | LL | x = 35; | ^^^^^^ | = help: maybe it is overwritten before being read? note: the lint level is defined here - --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:3:9 + --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:4:9 | LL | #![warn(unused_assignments)] | ^^^^^^^^^^^^^^^^^^ warning: value assigned to `x` is never read - --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:21:13 + --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:22:13 | LL | x = 35; | ^^^^^^ @@ -20,7 +20,7 @@ LL | x = 35; = help: maybe it is overwritten before being read? warning: value assigned to `x` is never read - --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:36:9 + --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:37:9 | LL | x = 42; | ^^^^^^ this value is reassigned later and never used @@ -29,7 +29,7 @@ LL | x = 99; | ------ `x` is overwritten here before the previous value is read warning: value assigned to `x` is never read - --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:33:9 + --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:34:9 | LL | x = 35; | ^^^^^^ this value is reassigned later and never used diff --git a/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr index 75a633cd49a3d..d26ba93e72117 100644 --- a/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr @@ -1,5 +1,5 @@ error: unreachable pattern - --> $DIR/empty-types.rs:47:9 + --> $DIR/empty-types.rs:48:9 | LL | _ => {} | ^------ @@ -9,13 +9,13 @@ LL | _ => {} | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here - --> $DIR/empty-types.rs:13:9 + --> $DIR/empty-types.rs:14:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:50:9 + --> $DIR/empty-types.rs:51:9 | LL | _x => {} | ^^------ @@ -26,7 +26,7 @@ LL | _x => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: type `&!` is non-empty - --> $DIR/empty-types.rs:54:11 + --> $DIR/empty-types.rs:55:11 | LL | match ref_never {} | ^^^^^^^^^ @@ -41,7 +41,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:68:9 + --> $DIR/empty-types.rs:69:9 | LL | (_, _) => {} | ^^^^^^------ @@ -52,7 +52,7 @@ LL | (_, _) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:74:9 + --> $DIR/empty-types.rs:75:9 | LL | _ => {} | ^------ @@ -63,7 +63,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:77:9 + --> $DIR/empty-types.rs:78:9 | LL | (_, _) => {} | ^^^^^^------ @@ -74,7 +74,7 @@ LL | (_, _) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:81:9 + --> $DIR/empty-types.rs:82:9 | LL | _ => {} | ^------ @@ -85,7 +85,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: `Ok(_)` not covered - --> $DIR/empty-types.rs:85:11 + --> $DIR/empty-types.rs:86:11 | LL | match res_u32_never {} | ^^^^^^^^^^^^^ pattern `Ok(_)` not covered @@ -104,7 +104,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:92:9 + --> $DIR/empty-types.rs:93:9 | LL | Err(_) => {} | ^^^^^^------ @@ -115,7 +115,7 @@ LL | Err(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:97:9 + --> $DIR/empty-types.rs:98:9 | LL | Err(_) => {} | ^^^^^^------ @@ -126,7 +126,7 @@ LL | Err(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered - --> $DIR/empty-types.rs:94:11 + --> $DIR/empty-types.rs:95:11 | LL | match res_u32_never { | ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered @@ -144,7 +144,7 @@ LL ~ Ok(1_u32..=u32::MAX) => todo!() | error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:100:9 + --> $DIR/empty-types.rs:101:9 | LL | let Ok(_x) = res_u32_never.as_ref(); | ^^^^^^ pattern `Err(_)` not covered @@ -158,7 +158,7 @@ LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() }; | ++++++++++++++++ error: unreachable pattern - --> $DIR/empty-types.rs:110:9 + --> $DIR/empty-types.rs:111:9 | LL | _ => {} | ^------ @@ -169,7 +169,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:113:9 + --> $DIR/empty-types.rs:114:9 | LL | Ok(_) => {} | ^^^^^------ @@ -180,7 +180,7 @@ LL | Ok(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:116:9 + --> $DIR/empty-types.rs:117:9 | LL | Ok(_) => {} | ^^^^^------ @@ -191,7 +191,7 @@ LL | Ok(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:117:9 + --> $DIR/empty-types.rs:118:9 | LL | _ => {} | ^------ @@ -202,7 +202,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:120:9 + --> $DIR/empty-types.rs:121:9 | LL | Ok(_) => {} | ^^^^^------ @@ -213,7 +213,7 @@ LL | Ok(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:121:9 + --> $DIR/empty-types.rs:122:9 | LL | Err(_) => {} | ^^^^^^------ @@ -224,7 +224,7 @@ LL | Err(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:130:13 + --> $DIR/empty-types.rs:131:13 | LL | _ => {} | ^------ @@ -235,7 +235,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:133:13 + --> $DIR/empty-types.rs:134:13 | LL | _ if false => {} | ^--------------- @@ -246,7 +246,7 @@ LL | _ if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:141:13 + --> $DIR/empty-types.rs:142:13 | LL | Some(_) => {} | ^^^^^^^------ @@ -257,7 +257,7 @@ LL | Some(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:145:13 + --> $DIR/empty-types.rs:146:13 | LL | None => {} | ---- matches all the relevant values @@ -265,7 +265,7 @@ LL | _ => {} | ^ no value can reach this error: unreachable pattern - --> $DIR/empty-types.rs:197:13 + --> $DIR/empty-types.rs:198:13 | LL | _ => {} | ^------ @@ -276,7 +276,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:202:13 + --> $DIR/empty-types.rs:203:13 | LL | _ => {} | ^------ @@ -287,7 +287,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:207:13 + --> $DIR/empty-types.rs:208:13 | LL | _ => {} | ^------ @@ -298,7 +298,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:212:13 + --> $DIR/empty-types.rs:213:13 | LL | _ => {} | ^------ @@ -309,7 +309,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:218:13 + --> $DIR/empty-types.rs:219:13 | LL | _ => {} | ^------ @@ -320,7 +320,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:279:9 + --> $DIR/empty-types.rs:280:9 | LL | _ => {} | ^------ @@ -331,7 +331,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:282:9 + --> $DIR/empty-types.rs:283:9 | LL | (_, _) => {} | ^^^^^^------ @@ -342,7 +342,7 @@ LL | (_, _) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:285:9 + --> $DIR/empty-types.rs:286:9 | LL | Ok(_) => {} | ^^^^^------ @@ -353,7 +353,7 @@ LL | Ok(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:286:9 + --> $DIR/empty-types.rs:287:9 | LL | Err(_) => {} | ^^^^^^------ @@ -364,7 +364,7 @@ LL | Err(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty - --> $DIR/empty-types.rs:325:11 + --> $DIR/empty-types.rs:326:11 | LL | match slice_never {} | ^^^^^^^^^^^ @@ -378,7 +378,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: `&[]` not covered - --> $DIR/empty-types.rs:336:11 + --> $DIR/empty-types.rs:337:11 | LL | match slice_never { | ^^^^^^^^^^^ pattern `&[]` not covered @@ -391,7 +391,7 @@ LL + &[] => todo!() | error[E0004]: non-exhaustive patterns: `&[]` not covered - --> $DIR/empty-types.rs:350:11 + --> $DIR/empty-types.rs:351:11 | LL | match slice_never { | ^^^^^^^^^^^ pattern `&[]` not covered @@ -405,7 +405,7 @@ LL + &[] => todo!() | error[E0004]: non-exhaustive patterns: type `[!]` is non-empty - --> $DIR/empty-types.rs:357:11 + --> $DIR/empty-types.rs:358:11 | LL | match *slice_never {} | ^^^^^^^^^^^^ @@ -419,7 +419,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:366:9 + --> $DIR/empty-types.rs:367:9 | LL | _ => {} | ^------ @@ -430,7 +430,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:369:9 + --> $DIR/empty-types.rs:370:9 | LL | [_, _, _] => {} | ^^^^^^^^^------ @@ -441,7 +441,7 @@ LL | [_, _, _] => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:372:9 + --> $DIR/empty-types.rs:373:9 | LL | [_, ..] => {} | ^^^^^^^------ @@ -452,7 +452,7 @@ LL | [_, ..] => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty - --> $DIR/empty-types.rs:386:11 + --> $DIR/empty-types.rs:387:11 | LL | match array_0_never {} | ^^^^^^^^^^^^^ @@ -466,7 +466,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:393:9 + --> $DIR/empty-types.rs:394:9 | LL | [] => {} | -- matches all the relevant values @@ -474,7 +474,7 @@ LL | _ => {} | ^ no value can reach this error[E0004]: non-exhaustive patterns: `[]` not covered - --> $DIR/empty-types.rs:395:11 + --> $DIR/empty-types.rs:396:11 | LL | match array_0_never { | ^^^^^^^^^^^^^ pattern `[]` not covered @@ -488,7 +488,7 @@ LL + [] => todo!() | error: unreachable pattern - --> $DIR/empty-types.rs:414:9 + --> $DIR/empty-types.rs:415:9 | LL | Some(_) => {} | ^^^^^^^------ @@ -499,7 +499,7 @@ LL | Some(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:419:9 + --> $DIR/empty-types.rs:420:9 | LL | Some(_a) => {} | ^^^^^^^^------ @@ -510,7 +510,7 @@ LL | Some(_a) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:424:9 + --> $DIR/empty-types.rs:425:9 | LL | None => {} | ---- matches all the relevant values @@ -519,7 +519,7 @@ LL | _ => {} | ^ no value can reach this error: unreachable pattern - --> $DIR/empty-types.rs:429:9 + --> $DIR/empty-types.rs:430:9 | LL | None => {} | ---- matches all the relevant values @@ -528,7 +528,7 @@ LL | _a => {} | ^^ no value can reach this error: unreachable pattern - --> $DIR/empty-types.rs:601:9 + --> $DIR/empty-types.rs:602:9 | LL | _ => {} | ^------ @@ -539,7 +539,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:604:9 + --> $DIR/empty-types.rs:605:9 | LL | _x => {} | ^^------ @@ -550,7 +550,7 @@ LL | _x => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:607:9 + --> $DIR/empty-types.rs:608:9 | LL | _ if false => {} | ^--------------- @@ -561,7 +561,7 @@ LL | _ if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:610:9 + --> $DIR/empty-types.rs:611:9 | LL | _x if false => {} | ^^--------------- diff --git a/tests/ui/pattern/usefulness/empty-types.never_pats.stderr b/tests/ui/pattern/usefulness/empty-types.never_pats.stderr index 68a1bebf6b132..4dcbe6ce677f9 100644 --- a/tests/ui/pattern/usefulness/empty-types.never_pats.stderr +++ b/tests/ui/pattern/usefulness/empty-types.never_pats.stderr @@ -1,5 +1,5 @@ error: unreachable pattern - --> $DIR/empty-types.rs:47:9 + --> $DIR/empty-types.rs:48:9 | LL | _ => {} | ^------ @@ -9,13 +9,13 @@ LL | _ => {} | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here - --> $DIR/empty-types.rs:13:9 + --> $DIR/empty-types.rs:14:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:50:9 + --> $DIR/empty-types.rs:51:9 | LL | _x => {} | ^^------ @@ -26,7 +26,7 @@ LL | _x => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: type `&!` is non-empty - --> $DIR/empty-types.rs:54:11 + --> $DIR/empty-types.rs:55:11 | LL | match ref_never {} | ^^^^^^^^^ @@ -41,7 +41,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:81:9 + --> $DIR/empty-types.rs:82:9 | LL | _ => {} | ^------ @@ -52,7 +52,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: `Ok(_)` not covered - --> $DIR/empty-types.rs:85:11 + --> $DIR/empty-types.rs:86:11 | LL | match res_u32_never {} | ^^^^^^^^^^^^^ pattern `Ok(_)` not covered @@ -71,7 +71,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered - --> $DIR/empty-types.rs:94:11 + --> $DIR/empty-types.rs:95:11 | LL | match res_u32_never { | ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered @@ -89,7 +89,7 @@ LL ~ Ok(1_u32..=u32::MAX) => todo!() | error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:100:9 + --> $DIR/empty-types.rs:101:9 | LL | let Ok(_x) = res_u32_never.as_ref(); | ^^^^^^ pattern `Err(_)` not covered @@ -103,7 +103,7 @@ LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() }; | ++++++++++++++++ error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:104:9 + --> $DIR/empty-types.rs:105:9 | LL | let Ok(_x) = &res_u32_never; | ^^^^^^ pattern `&Err(!)` not covered @@ -117,7 +117,7 @@ LL | let Ok(_x) = &res_u32_never else { todo!() }; | ++++++++++++++++ error: unreachable pattern - --> $DIR/empty-types.rs:130:13 + --> $DIR/empty-types.rs:131:13 | LL | _ => {} | ^------ @@ -128,7 +128,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:133:13 + --> $DIR/empty-types.rs:134:13 | LL | _ if false => {} | ^--------------- @@ -139,7 +139,7 @@ LL | _ if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: `Some(!)` not covered - --> $DIR/empty-types.rs:154:15 + --> $DIR/empty-types.rs:155:15 | LL | match *ref_opt_void { | ^^^^^^^^^^^^^ pattern `Some(!)` not covered @@ -158,7 +158,7 @@ LL + Some(!) | error: unreachable pattern - --> $DIR/empty-types.rs:197:13 + --> $DIR/empty-types.rs:198:13 | LL | _ => {} | ^------ @@ -169,7 +169,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:202:13 + --> $DIR/empty-types.rs:203:13 | LL | _ => {} | ^------ @@ -180,7 +180,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:207:13 + --> $DIR/empty-types.rs:208:13 | LL | _ => {} | ^------ @@ -191,7 +191,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:212:13 + --> $DIR/empty-types.rs:213:13 | LL | _ => {} | ^------ @@ -202,7 +202,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:218:13 + --> $DIR/empty-types.rs:219:13 | LL | _ => {} | ^------ @@ -213,7 +213,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:279:9 + --> $DIR/empty-types.rs:280:9 | LL | _ => {} | ^------ @@ -224,7 +224,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:295:13 + --> $DIR/empty-types.rs:296:13 | LL | let Ok(_) = *ptr_result_never_err; | ^^^^^ pattern `Err(!)` not covered @@ -238,7 +238,7 @@ LL | if let Ok(_) = *ptr_result_never_err { todo!() }; | ++ +++++++++++ error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty - --> $DIR/empty-types.rs:314:11 + --> $DIR/empty-types.rs:315:11 | LL | match *x {} | ^^ @@ -252,7 +252,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `(!, !)` is non-empty - --> $DIR/empty-types.rs:316:11 + --> $DIR/empty-types.rs:317:11 | LL | match *x {} | ^^ @@ -266,7 +266,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: `Ok(!)` and `Err(!)` not covered - --> $DIR/empty-types.rs:318:11 + --> $DIR/empty-types.rs:319:11 | LL | match *x {} | ^^ patterns `Ok(!)` and `Err(!)` not covered @@ -288,7 +288,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `[!; 3]` is non-empty - --> $DIR/empty-types.rs:320:11 + --> $DIR/empty-types.rs:321:11 | LL | match *x {} | ^^ @@ -302,7 +302,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty - --> $DIR/empty-types.rs:325:11 + --> $DIR/empty-types.rs:326:11 | LL | match slice_never {} | ^^^^^^^^^^^ @@ -316,7 +316,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: `&[!, ..]` not covered - --> $DIR/empty-types.rs:327:11 + --> $DIR/empty-types.rs:328:11 | LL | match slice_never { | ^^^^^^^^^^^ pattern `&[!, ..]` not covered @@ -330,7 +330,7 @@ LL + &[!, ..] | error[E0004]: non-exhaustive patterns: `&[]`, `&[!]` and `&[!, !]` not covered - --> $DIR/empty-types.rs:336:11 + --> $DIR/empty-types.rs:337:11 | LL | match slice_never { | ^^^^^^^^^^^ patterns `&[]`, `&[!]` and `&[!, !]` not covered @@ -343,7 +343,7 @@ LL + &[] | &[!] | &[!, !] => todo!() | error[E0004]: non-exhaustive patterns: `&[]` and `&[!, ..]` not covered - --> $DIR/empty-types.rs:350:11 + --> $DIR/empty-types.rs:351:11 | LL | match slice_never { | ^^^^^^^^^^^ patterns `&[]` and `&[!, ..]` not covered @@ -357,7 +357,7 @@ LL + &[] | &[!, ..] => todo!() | error[E0004]: non-exhaustive patterns: type `[!]` is non-empty - --> $DIR/empty-types.rs:357:11 + --> $DIR/empty-types.rs:358:11 | LL | match *slice_never {} | ^^^^^^^^^^^^ @@ -371,7 +371,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty - --> $DIR/empty-types.rs:386:11 + --> $DIR/empty-types.rs:387:11 | LL | match array_0_never {} | ^^^^^^^^^^^^^ @@ -385,7 +385,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:393:9 + --> $DIR/empty-types.rs:394:9 | LL | [] => {} | -- matches all the relevant values @@ -393,7 +393,7 @@ LL | _ => {} | ^ no value can reach this error[E0004]: non-exhaustive patterns: `[]` not covered - --> $DIR/empty-types.rs:395:11 + --> $DIR/empty-types.rs:396:11 | LL | match array_0_never { | ^^^^^^^^^^^^^ pattern `[]` not covered @@ -407,7 +407,7 @@ LL + [] => todo!() | error[E0004]: non-exhaustive patterns: `&Some(!)` not covered - --> $DIR/empty-types.rs:449:11 + --> $DIR/empty-types.rs:450:11 | LL | match ref_opt_never { | ^^^^^^^^^^^^^ pattern `&Some(!)` not covered @@ -426,7 +426,7 @@ LL + &Some(!) | error[E0004]: non-exhaustive patterns: `Some(!)` not covered - --> $DIR/empty-types.rs:490:11 + --> $DIR/empty-types.rs:491:11 | LL | match *ref_opt_never { | ^^^^^^^^^^^^^^ pattern `Some(!)` not covered @@ -445,7 +445,7 @@ LL + Some(!) | error[E0004]: non-exhaustive patterns: `Err(!)` not covered - --> $DIR/empty-types.rs:538:11 + --> $DIR/empty-types.rs:539:11 | LL | match *ref_res_never { | ^^^^^^^^^^^^^^ pattern `Err(!)` not covered @@ -464,7 +464,7 @@ LL + Err(!) | error[E0004]: non-exhaustive patterns: `Err(!)` not covered - --> $DIR/empty-types.rs:549:11 + --> $DIR/empty-types.rs:550:11 | LL | match *ref_res_never { | ^^^^^^^^^^^^^^ pattern `Err(!)` not covered @@ -483,7 +483,7 @@ LL + Err(!) | error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty - --> $DIR/empty-types.rs:568:11 + --> $DIR/empty-types.rs:569:11 | LL | match *ref_tuple_half_never {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -497,7 +497,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:601:9 + --> $DIR/empty-types.rs:602:9 | LL | _ => {} | ^------ @@ -508,7 +508,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:604:9 + --> $DIR/empty-types.rs:605:9 | LL | _x => {} | ^^------ @@ -519,7 +519,7 @@ LL | _x => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:607:9 + --> $DIR/empty-types.rs:608:9 | LL | _ if false => {} | ^--------------- @@ -530,7 +530,7 @@ LL | _ if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:610:9 + --> $DIR/empty-types.rs:611:9 | LL | _x if false => {} | ^^--------------- @@ -541,7 +541,7 @@ LL | _x if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: `&!` not covered - --> $DIR/empty-types.rs:635:11 + --> $DIR/empty-types.rs:636:11 | LL | match ref_never { | ^^^^^^^^^ pattern `&!` not covered @@ -557,7 +557,7 @@ LL + &! | error[E0004]: non-exhaustive patterns: `Ok(!)` not covered - --> $DIR/empty-types.rs:651:11 + --> $DIR/empty-types.rs:652:11 | LL | match *ref_result_never { | ^^^^^^^^^^^^^^^^^ pattern `Ok(!)` not covered @@ -577,7 +577,7 @@ LL + Ok(!) | error[E0004]: non-exhaustive patterns: `Some(!)` not covered - --> $DIR/empty-types.rs:671:11 + --> $DIR/empty-types.rs:672:11 | LL | match *x { | ^^ pattern `Some(!)` not covered diff --git a/tests/ui/pattern/usefulness/empty-types.normal.stderr b/tests/ui/pattern/usefulness/empty-types.normal.stderr index 320959534e522..a49050cedb4d0 100644 --- a/tests/ui/pattern/usefulness/empty-types.normal.stderr +++ b/tests/ui/pattern/usefulness/empty-types.normal.stderr @@ -1,5 +1,5 @@ error: unreachable pattern - --> $DIR/empty-types.rs:47:9 + --> $DIR/empty-types.rs:48:9 | LL | _ => {} | ^------ @@ -9,13 +9,13 @@ LL | _ => {} | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here - --> $DIR/empty-types.rs:13:9 + --> $DIR/empty-types.rs:14:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:50:9 + --> $DIR/empty-types.rs:51:9 | LL | _x => {} | ^^------ @@ -26,7 +26,7 @@ LL | _x => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: type `&!` is non-empty - --> $DIR/empty-types.rs:54:11 + --> $DIR/empty-types.rs:55:11 | LL | match ref_never {} | ^^^^^^^^^ @@ -41,7 +41,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:81:9 + --> $DIR/empty-types.rs:82:9 | LL | _ => {} | ^------ @@ -52,7 +52,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: `Ok(_)` not covered - --> $DIR/empty-types.rs:85:11 + --> $DIR/empty-types.rs:86:11 | LL | match res_u32_never {} | ^^^^^^^^^^^^^ pattern `Ok(_)` not covered @@ -71,7 +71,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered - --> $DIR/empty-types.rs:94:11 + --> $DIR/empty-types.rs:95:11 | LL | match res_u32_never { | ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered @@ -89,7 +89,7 @@ LL ~ Ok(1_u32..=u32::MAX) => todo!() | error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:100:9 + --> $DIR/empty-types.rs:101:9 | LL | let Ok(_x) = res_u32_never.as_ref(); | ^^^^^^ pattern `Err(_)` not covered @@ -103,7 +103,7 @@ LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() }; | ++++++++++++++++ error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:104:9 + --> $DIR/empty-types.rs:105:9 | LL | let Ok(_x) = &res_u32_never; | ^^^^^^ pattern `&Err(_)` not covered @@ -117,7 +117,7 @@ LL | let Ok(_x) = &res_u32_never else { todo!() }; | ++++++++++++++++ error: unreachable pattern - --> $DIR/empty-types.rs:130:13 + --> $DIR/empty-types.rs:131:13 | LL | _ => {} | ^------ @@ -128,7 +128,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:133:13 + --> $DIR/empty-types.rs:134:13 | LL | _ if false => {} | ^--------------- @@ -139,7 +139,7 @@ LL | _ if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:154:15 + --> $DIR/empty-types.rs:155:15 | LL | match *ref_opt_void { | ^^^^^^^^^^^^^ pattern `Some(_)` not covered @@ -158,7 +158,7 @@ LL + Some(_) => todo!() | error: unreachable pattern - --> $DIR/empty-types.rs:197:13 + --> $DIR/empty-types.rs:198:13 | LL | _ => {} | ^------ @@ -169,7 +169,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:202:13 + --> $DIR/empty-types.rs:203:13 | LL | _ => {} | ^------ @@ -180,7 +180,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:207:13 + --> $DIR/empty-types.rs:208:13 | LL | _ => {} | ^------ @@ -191,7 +191,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:212:13 + --> $DIR/empty-types.rs:213:13 | LL | _ => {} | ^------ @@ -202,7 +202,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:218:13 + --> $DIR/empty-types.rs:219:13 | LL | _ => {} | ^------ @@ -213,7 +213,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:279:9 + --> $DIR/empty-types.rs:280:9 | LL | _ => {} | ^------ @@ -224,7 +224,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:295:13 + --> $DIR/empty-types.rs:296:13 | LL | let Ok(_) = *ptr_result_never_err; | ^^^^^ pattern `Err(_)` not covered @@ -238,7 +238,7 @@ LL | if let Ok(_) = *ptr_result_never_err { todo!() }; | ++ +++++++++++ error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty - --> $DIR/empty-types.rs:314:11 + --> $DIR/empty-types.rs:315:11 | LL | match *x {} | ^^ @@ -252,7 +252,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `(!, !)` is non-empty - --> $DIR/empty-types.rs:316:11 + --> $DIR/empty-types.rs:317:11 | LL | match *x {} | ^^ @@ -266,7 +266,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: `Ok(_)` and `Err(_)` not covered - --> $DIR/empty-types.rs:318:11 + --> $DIR/empty-types.rs:319:11 | LL | match *x {} | ^^ patterns `Ok(_)` and `Err(_)` not covered @@ -288,7 +288,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `[!; 3]` is non-empty - --> $DIR/empty-types.rs:320:11 + --> $DIR/empty-types.rs:321:11 | LL | match *x {} | ^^ @@ -302,7 +302,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty - --> $DIR/empty-types.rs:325:11 + --> $DIR/empty-types.rs:326:11 | LL | match slice_never {} | ^^^^^^^^^^^ @@ -316,7 +316,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered - --> $DIR/empty-types.rs:327:11 + --> $DIR/empty-types.rs:328:11 | LL | match slice_never { | ^^^^^^^^^^^ pattern `&[_, ..]` not covered @@ -330,7 +330,7 @@ LL + &[_, ..] => todo!() | error[E0004]: non-exhaustive patterns: `&[]`, `&[_]` and `&[_, _]` not covered - --> $DIR/empty-types.rs:336:11 + --> $DIR/empty-types.rs:337:11 | LL | match slice_never { | ^^^^^^^^^^^ patterns `&[]`, `&[_]` and `&[_, _]` not covered @@ -343,7 +343,7 @@ LL + &[] | &[_] | &[_, _] => todo!() | error[E0004]: non-exhaustive patterns: `&[]` and `&[_, ..]` not covered - --> $DIR/empty-types.rs:350:11 + --> $DIR/empty-types.rs:351:11 | LL | match slice_never { | ^^^^^^^^^^^ patterns `&[]` and `&[_, ..]` not covered @@ -357,7 +357,7 @@ LL + &[] | &[_, ..] => todo!() | error[E0004]: non-exhaustive patterns: type `[!]` is non-empty - --> $DIR/empty-types.rs:357:11 + --> $DIR/empty-types.rs:358:11 | LL | match *slice_never {} | ^^^^^^^^^^^^ @@ -371,7 +371,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty - --> $DIR/empty-types.rs:386:11 + --> $DIR/empty-types.rs:387:11 | LL | match array_0_never {} | ^^^^^^^^^^^^^ @@ -385,7 +385,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:393:9 + --> $DIR/empty-types.rs:394:9 | LL | [] => {} | -- matches all the relevant values @@ -393,7 +393,7 @@ LL | _ => {} | ^ no value can reach this error[E0004]: non-exhaustive patterns: `[]` not covered - --> $DIR/empty-types.rs:395:11 + --> $DIR/empty-types.rs:396:11 | LL | match array_0_never { | ^^^^^^^^^^^^^ pattern `[]` not covered @@ -407,7 +407,7 @@ LL + [] => todo!() | error[E0004]: non-exhaustive patterns: `&Some(_)` not covered - --> $DIR/empty-types.rs:449:11 + --> $DIR/empty-types.rs:450:11 | LL | match ref_opt_never { | ^^^^^^^^^^^^^ pattern `&Some(_)` not covered @@ -426,7 +426,7 @@ LL + &Some(_) => todo!() | error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:490:11 + --> $DIR/empty-types.rs:491:11 | LL | match *ref_opt_never { | ^^^^^^^^^^^^^^ pattern `Some(_)` not covered @@ -445,7 +445,7 @@ LL + Some(_) => todo!() | error[E0004]: non-exhaustive patterns: `Err(_)` not covered - --> $DIR/empty-types.rs:538:11 + --> $DIR/empty-types.rs:539:11 | LL | match *ref_res_never { | ^^^^^^^^^^^^^^ pattern `Err(_)` not covered @@ -464,7 +464,7 @@ LL + Err(_) => todo!() | error[E0004]: non-exhaustive patterns: `Err(_)` not covered - --> $DIR/empty-types.rs:549:11 + --> $DIR/empty-types.rs:550:11 | LL | match *ref_res_never { | ^^^^^^^^^^^^^^ pattern `Err(_)` not covered @@ -483,7 +483,7 @@ LL + Err(_) => todo!() | error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty - --> $DIR/empty-types.rs:568:11 + --> $DIR/empty-types.rs:569:11 | LL | match *ref_tuple_half_never {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -497,7 +497,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:601:9 + --> $DIR/empty-types.rs:602:9 | LL | _ => {} | ^------ @@ -508,7 +508,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:604:9 + --> $DIR/empty-types.rs:605:9 | LL | _x => {} | ^^------ @@ -519,7 +519,7 @@ LL | _x => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:607:9 + --> $DIR/empty-types.rs:608:9 | LL | _ if false => {} | ^--------------- @@ -530,7 +530,7 @@ LL | _ if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:610:9 + --> $DIR/empty-types.rs:611:9 | LL | _x if false => {} | ^^--------------- @@ -541,7 +541,7 @@ LL | _x if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: `&_` not covered - --> $DIR/empty-types.rs:635:11 + --> $DIR/empty-types.rs:636:11 | LL | match ref_never { | ^^^^^^^^^ pattern `&_` not covered @@ -557,7 +557,7 @@ LL + &_ => todo!() | error[E0004]: non-exhaustive patterns: `Ok(_)` not covered - --> $DIR/empty-types.rs:651:11 + --> $DIR/empty-types.rs:652:11 | LL | match *ref_result_never { | ^^^^^^^^^^^^^^^^^ pattern `Ok(_)` not covered @@ -577,7 +577,7 @@ LL + Ok(_) => todo!() | error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:671:11 + --> $DIR/empty-types.rs:672:11 | LL | match *x { | ^^ pattern `Some(_)` not covered diff --git a/tests/ui/pattern/usefulness/empty-types.rs b/tests/ui/pattern/usefulness/empty-types.rs index d4fdb7c1dd46a..cb0f1813e915b 100644 --- a/tests/ui/pattern/usefulness/empty-types.rs +++ b/tests/ui/pattern/usefulness/empty-types.rs @@ -1,5 +1,6 @@ //@ revisions: normal exhaustive_patterns never_pats //@ edition: 2024 +//@ ignore-parallel-frontend pattern matching error message mismatch // // This tests correct handling of empty types in exhaustiveness checking. // From ec46eac2ad32dfb7387a37a5f8ddb1077d81412b Mon Sep 17 00:00:00 2001 From: Kjetil Kjeka Date: Thu, 28 May 2026 15:30:58 +0200 Subject: [PATCH 22/25] NVPTX: Remove the deprecated ptx linker flavor --- compiler/rustc_codegen_ssa/src/back/link.rs | 4 - compiler/rustc_codegen_ssa/src/back/linker.rs | 79 ------------------- compiler/rustc_target/src/spec/mod.rs | 38 +++------ .../src/spec/targets/nvptx64_nvidia_cuda.rs | 1 - .../src/compiler-flags/codegen-options.md | 2 - src/tools/compiletest/src/runtest/assembly.rs | 3 +- tests/assembly-llvm/nvptx-arch-default.rs | 4 +- tests/assembly-llvm/nvptx-arch-emit-asm.rs | 2 +- tests/assembly-llvm/nvptx-arch-link-arg.rs | 13 --- tests/assembly-llvm/nvptx-arch-target-cpu.rs | 2 +- tests/assembly-llvm/nvptx-atomics.rs | 2 +- tests/assembly-llvm/nvptx-c-abi-arg-v7.rs | 2 +- tests/assembly-llvm/nvptx-c-abi-ret-v7.rs | 2 +- tests/assembly-llvm/nvptx-internalizing.rs | 3 +- .../nvptx-kernel-args-abi-v7.rs | 2 +- tests/assembly-llvm/nvptx-linking-binary.rs | 2 +- tests/assembly-llvm/nvptx-linking-cdylib.rs | 2 +- tests/assembly-llvm/nvptx-safe-naming.rs | 2 +- .../linkage-attr/unstable-flavor.llbc.stderr | 2 + .../linkage-attr/unstable-flavor.ptx.stderr | 2 - tests/ui/linkage-attr/unstable-flavor.rs | 8 +- .../target-feature/implied-features-nvptx.rs | 4 +- 22 files changed, 31 insertions(+), 150 deletions(-) delete mode 100644 tests/assembly-llvm/nvptx-arch-link-arg.rs create mode 100644 tests/ui/linkage-attr/unstable-flavor.llbc.stderr delete mode 100644 tests/ui/linkage-attr/unstable-flavor.ptx.stderr diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index d2c82280ad2ab..532f2d6d6af09 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1530,7 +1530,6 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { } LinkerFlavor::Bpf => "bpf-linker", LinkerFlavor::Llbc => "llvm-bitcode-linker", - LinkerFlavor::Ptx => "rust-ptx-linker", }), flavor, )), @@ -1571,7 +1570,6 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { let linker_flavor = match sess.opts.cg.linker_flavor { // The linker flavors that are non-target specific can be directly translated to LinkerFlavor Some(LinkerFlavorCli::Llbc) => Some(LinkerFlavor::Llbc), - Some(LinkerFlavorCli::Ptx) => Some(LinkerFlavor::Ptx), // The linker flavors that corresponds to targets needs logic that keeps the base LinkerFlavor linker_flavor => { linker_flavor.map(|flavor| sess.target.linker_flavor.with_cli_hints(flavor)) @@ -2764,8 +2762,6 @@ fn add_order_independent_options( if crate_info.target_features.len() > 0 { cmd.link_arg(&format!("--target-feature={}", &crate_info.target_features.join(","))); } - } else if flavor == LinkerFlavor::Ptx { - cmd.link_args(&["--fallback-arch", &crate_info.target_cpu]); } else if flavor == LinkerFlavor::Bpf { cmd.link_args(&["--cpu", &crate_info.target_cpu]); if let Some(feat) = [sess.opts.cg.target_feature.as_str(), &sess.target.options.features] diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index 2155f94a7cfd3..d40340e4d8c09 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -161,7 +161,6 @@ pub(crate) fn get_linker<'a>( LinkerFlavor::EmCc => Box::new(EmLinker { cmd, sess }) as Box, LinkerFlavor::Bpf => Box::new(BpfLinker { cmd, sess }) as Box, LinkerFlavor::Llbc => Box::new(LlbcLinker { cmd, sess }) as Box, - LinkerFlavor::Ptx => Box::new(PtxLinker { cmd, sess }) as Box, } } @@ -283,7 +282,6 @@ generate_arg_methods! { L4Bender<'_> AixLinker<'_> LlbcLinker<'_> - PtxLinker<'_> BpfLinker<'_> dyn Linker + '_ } @@ -1920,83 +1918,6 @@ pub(crate) fn linked_symbols( symbols } -/// Much simplified and explicit CLI for the NVPTX linker. The linker operates -/// with bitcode and uses LLVM backend to generate a PTX assembly. -struct PtxLinker<'a> { - cmd: Command, - sess: &'a Session, -} - -impl<'a> Linker for PtxLinker<'a> { - fn cmd(&mut self) -> &mut Command { - &mut self.cmd - } - - fn set_output_kind( - &mut self, - _output_kind: LinkOutputKind, - _crate_type: CrateType, - _out_filename: &Path, - ) { - } - - fn link_staticlib_by_name(&mut self, _name: &str, _verbatim: bool, _whole_archive: bool) { - panic!("staticlibs not supported") - } - - fn link_staticlib_by_path(&mut self, path: &Path, _whole_archive: bool) { - self.link_arg("--rlib").link_arg(path); - } - - fn debuginfo(&mut self, _strip: Strip, _: &[PathBuf]) { - self.link_arg("--debug"); - } - - fn add_object(&mut self, path: &Path) { - self.link_arg("--bitcode").link_arg(path); - } - - fn optimize(&mut self) { - match self.sess.lto() { - Lto::Thin | Lto::Fat | Lto::ThinLocal => { - self.link_arg("-Olto"); - } - - Lto::No => {} - } - } - - fn full_relro(&mut self) {} - - fn partial_relro(&mut self) {} - - fn no_relro(&mut self) {} - - fn gc_sections(&mut self, _keep_metadata: bool) {} - - fn pgo_gen(&mut self) {} - - fn no_crt_objects(&mut self) {} - - fn no_default_libraries(&mut self) {} - - fn control_flow_guard(&mut self) {} - - fn ehcont_guard(&mut self) {} - - fn export_symbols( - &mut self, - _tmpdir: &Path, - _crate_type: CrateType, - _symbols: &[(String, SymbolExportKind)], - ) { - } - - fn windows_subsystem(&mut self, _subsystem: WindowsSubsystemKind) {} - - fn linker_plugin_lto(&mut self) {} -} - /// The `self-contained` LLVM bitcode linker struct LlbcLinker<'a> { cmd: Command, diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index d6a9e27c46553..37cddf56bcd30 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -132,8 +132,6 @@ pub enum LinkerFlavor { // Below: other linker-like tools with unique interfaces for exotic targets. /// Linker tool for BPF. Bpf, - /// Linker tool for Nvidia PTX. - Ptx, /// LLVM bitcode linker that can be used as a `self-contained` linker Llbc, } @@ -153,7 +151,6 @@ pub enum LinkerFlavorCli { Msvc(Lld), EmCc, Bpf, - Ptx, Llbc, // Legacy stable values @@ -174,8 +171,7 @@ impl LinkerFlavorCli { | LinkerFlavorCli::Msvc(Lld::Yes) | LinkerFlavorCli::EmCc | LinkerFlavorCli::Bpf - | LinkerFlavorCli::Llbc - | LinkerFlavorCli::Ptx => true, + | LinkerFlavorCli::Llbc => true, LinkerFlavorCli::Gcc | LinkerFlavorCli::Ld | LinkerFlavorCli::Lld(..) @@ -211,7 +207,6 @@ impl LinkerFlavor { LinkerFlavorCli::EmCc => LinkerFlavor::EmCc, LinkerFlavorCli::Bpf => LinkerFlavor::Bpf, LinkerFlavorCli::Llbc => LinkerFlavor::Llbc, - LinkerFlavorCli::Ptx => LinkerFlavor::Ptx, // Below: legacy stable values LinkerFlavorCli::Gcc => match lld_flavor { @@ -251,7 +246,6 @@ impl LinkerFlavor { LinkerFlavor::EmCc => LinkerFlavorCli::Em, LinkerFlavor::Bpf => LinkerFlavorCli::Bpf, LinkerFlavor::Llbc => LinkerFlavorCli::Llbc, - LinkerFlavor::Ptx => LinkerFlavorCli::Ptx, } } @@ -266,7 +260,6 @@ impl LinkerFlavor { LinkerFlavor::EmCc => LinkerFlavorCli::EmCc, LinkerFlavor::Bpf => LinkerFlavorCli::Bpf, LinkerFlavor::Llbc => LinkerFlavorCli::Llbc, - LinkerFlavor::Ptx => LinkerFlavorCli::Ptx, } } @@ -279,7 +272,7 @@ impl LinkerFlavor { LinkerFlavorCli::Unix(cc) => (Some(cc), None), LinkerFlavorCli::Msvc(lld) => (Some(Cc::No), Some(lld)), LinkerFlavorCli::EmCc => (Some(Cc::Yes), Some(Lld::Yes)), - LinkerFlavorCli::Bpf | LinkerFlavorCli::Ptx => (None, None), + LinkerFlavorCli::Bpf => (None, None), LinkerFlavorCli::Llbc => (None, None), // Below: legacy stable values @@ -336,7 +329,7 @@ impl LinkerFlavor { LinkerFlavor::WasmLld(cc) => LinkerFlavor::WasmLld(cc_hint.unwrap_or(cc)), LinkerFlavor::Unix(cc) => LinkerFlavor::Unix(cc_hint.unwrap_or(cc)), LinkerFlavor::Msvc(lld) => LinkerFlavor::Msvc(lld_hint.unwrap_or(lld)), - LinkerFlavor::EmCc | LinkerFlavor::Bpf | LinkerFlavor::Llbc | LinkerFlavor::Ptx => self, + LinkerFlavor::EmCc | LinkerFlavor::Bpf | LinkerFlavor::Llbc => self, } } @@ -355,7 +348,7 @@ impl LinkerFlavor { let compatible = |cli| { // The CLI flavor should be compatible with the target if: match (self, cli) { - // 1. they are counterparts: they have the same principal flavor. + // they are counterparts: they have the same principal flavor. (LinkerFlavor::Gnu(..), LinkerFlavorCli::Gnu(..)) | (LinkerFlavor::Darwin(..), LinkerFlavorCli::Darwin(..)) | (LinkerFlavor::WasmLld(..), LinkerFlavorCli::WasmLld(..)) @@ -363,10 +356,7 @@ impl LinkerFlavor { | (LinkerFlavor::Msvc(..), LinkerFlavorCli::Msvc(..)) | (LinkerFlavor::EmCc, LinkerFlavorCli::EmCc) | (LinkerFlavor::Bpf, LinkerFlavorCli::Bpf) - | (LinkerFlavor::Llbc, LinkerFlavorCli::Llbc) - | (LinkerFlavor::Ptx, LinkerFlavorCli::Ptx) => return true, - // 2. The linker flavor is independent of target and compatible - (LinkerFlavor::Ptx, LinkerFlavorCli::Llbc) => return true, + | (LinkerFlavor::Llbc, LinkerFlavorCli::Llbc) => return true, _ => {} } @@ -389,8 +379,7 @@ impl LinkerFlavor { | LinkerFlavor::Unix(..) | LinkerFlavor::EmCc | LinkerFlavor::Bpf - | LinkerFlavor::Llbc - | LinkerFlavor::Ptx => LldFlavor::Ld, + | LinkerFlavor::Llbc => LldFlavor::Ld, LinkerFlavor::Darwin(..) => LldFlavor::Ld64, LinkerFlavor::WasmLld(..) => LldFlavor::Wasm, LinkerFlavor::Msvc(..) => LldFlavor::Link, @@ -415,8 +404,7 @@ impl LinkerFlavor { | LinkerFlavor::Msvc(_) | LinkerFlavor::Unix(_) | LinkerFlavor::Bpf - | LinkerFlavor::Llbc - | LinkerFlavor::Ptx => false, + | LinkerFlavor::Llbc => false, } } @@ -435,8 +423,7 @@ impl LinkerFlavor { | LinkerFlavor::Msvc(_) | LinkerFlavor::Unix(_) | LinkerFlavor::Bpf - | LinkerFlavor::Llbc - | LinkerFlavor::Ptx => false, + | LinkerFlavor::Llbc => false, } } @@ -512,7 +499,6 @@ linker_flavor_cli_impls! { (LinkerFlavorCli::EmCc) "em-cc" (LinkerFlavorCli::Bpf) "bpf" (LinkerFlavorCli::Llbc) "llbc" - (LinkerFlavorCli::Ptx) "ptx" // Legacy stable flavors (LinkerFlavorCli::Gcc) "gcc" @@ -2740,8 +2726,7 @@ fn add_link_args_iter( | LinkerFlavor::Unix(..) | LinkerFlavor::EmCc | LinkerFlavor::Bpf - | LinkerFlavor::Llbc - | LinkerFlavor::Ptx => {} + | LinkerFlavor::Llbc => {} } } @@ -3127,10 +3112,7 @@ impl Target { "mixing MSVC and non-MSVC linker flavors" ); } - LinkerFlavor::EmCc - | LinkerFlavor::Bpf - | LinkerFlavor::Ptx - | LinkerFlavor::Llbc => { + LinkerFlavor::EmCc | LinkerFlavor::Bpf | LinkerFlavor::Llbc => { check_eq!(flavor, self.linker_flavor, "mixing different linker flavors") } } diff --git a/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs b/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs index d8a0bd50ee204..b74aca48bb9ec 100644 --- a/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs +++ b/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs @@ -21,7 +21,6 @@ pub(crate) fn target() -> Target { vendor: "nvidia".into(), linker_flavor: LinkerFlavor::Llbc, - // With `ptx-linker` approach, it can be later overridden via link flags. cpu: "sm_70".into(), // No longer supported architectures diff --git a/src/doc/unstable-book/src/compiler-flags/codegen-options.md b/src/doc/unstable-book/src/compiler-flags/codegen-options.md index f927e5c439c66..efde41040184a 100644 --- a/src/doc/unstable-book/src/compiler-flags/codegen-options.md +++ b/src/doc/unstable-book/src/compiler-flags/codegen-options.md @@ -7,8 +7,6 @@ unstable-options` to be accepted. ## linker-flavor In addition to the stable set of linker flavors, the following unstable values also exist: -- `ptx`: use [`rust-ptx-linker`](https://github.com/denzp/rust-ptx-linker) - for Nvidia NVPTX GPGPU support. - `bpf`: use [`bpf-linker`](https://github.com/alessandrod/bpf-linker) for eBPF support. - `llbc`: for linking in llvm bitcode. Install the preview rustup components`llvm-bitcode-linker` and `llvm-tools` to use as a self-contained linker by passing diff --git a/src/tools/compiletest/src/runtest/assembly.rs b/src/tools/compiletest/src/runtest/assembly.rs index 0d41c29075c43..be2430f006a54 100644 --- a/src/tools/compiletest/src/runtest/assembly.rs +++ b/src/tools/compiletest/src/runtest/assembly.rs @@ -23,7 +23,7 @@ impl TestCx<'_> { fn compile_test_and_save_assembly(&self) -> (ProcRes, Utf8PathBuf) { // This works with both `--emit asm` (as default output name for the assembly) - // and `ptx-linker` because the latter can write output at requested location. + // and `llvm-bitcode-linker` because the latter can write output at requested location. let output_path = self.output_base_name().with_extension("s"); let input_file = &self.testpaths.file; @@ -31,7 +31,6 @@ impl TestCx<'_> { let emit = match self.props.assembly_output.as_deref() { Some("emit-asm") => Emit::Asm, Some("bpf-linker") => Emit::LinkArgsAsm, - Some("ptx-linker") => Emit::None, // No extra flags needed. Some(other) => self.fatal(&format!("unknown 'assembly-output' directive: {other}")), None => self.fatal("missing 'assembly-output' directive"), }; diff --git a/tests/assembly-llvm/nvptx-arch-default.rs b/tests/assembly-llvm/nvptx-arch-default.rs index e71304e453303..a0c2b5387275d 100644 --- a/tests/assembly-llvm/nvptx-arch-default.rs +++ b/tests/assembly-llvm/nvptx-arch-default.rs @@ -1,4 +1,4 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type cdylib //@ only-nvptx64 @@ -7,7 +7,7 @@ //@ aux-build: breakpoint-panic-handler.rs extern crate breakpoint_panic_handler; -// Verify default target arch with ptx-linker. +// Verify default arch with llvm-bitcode-linker. // CHECK: .version 7.0 // CHECK: .target sm_70 // CHECK: .address_size 64 diff --git a/tests/assembly-llvm/nvptx-arch-emit-asm.rs b/tests/assembly-llvm/nvptx-arch-emit-asm.rs index 9266309c6202e..135149679a4d1 100644 --- a/tests/assembly-llvm/nvptx-arch-emit-asm.rs +++ b/tests/assembly-llvm/nvptx-arch-emit-asm.rs @@ -4,7 +4,7 @@ #![no_std] -// Verify default arch without ptx-linker involved. +// Verify default arch without llvm-bitcode-linker involved. // CHECK: .version 7.0 // CHECK: .target sm_70 // CHECK: .address_size 64 diff --git a/tests/assembly-llvm/nvptx-arch-link-arg.rs b/tests/assembly-llvm/nvptx-arch-link-arg.rs deleted file mode 100644 index 3432e6161bf14..0000000000000 --- a/tests/assembly-llvm/nvptx-arch-link-arg.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ assembly-output: ptx-linker -//@ compile-flags: --crate-type cdylib -C link-arg=--arch=sm_60 -//@ only-nvptx64 -//@ ignore-nvptx64 - -#![no_std] - -//@ aux-build: breakpoint-panic-handler.rs -extern crate breakpoint_panic_handler; - -// Verify target arch override via `link-arg`. -// CHECK: .target sm_60 -// CHECK: .address_size 64 diff --git a/tests/assembly-llvm/nvptx-arch-target-cpu.rs b/tests/assembly-llvm/nvptx-arch-target-cpu.rs index b5062f1ba20d7..8e1ef9b13fa40 100644 --- a/tests/assembly-llvm/nvptx-arch-target-cpu.rs +++ b/tests/assembly-llvm/nvptx-arch-target-cpu.rs @@ -1,4 +1,4 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type cdylib -C target-cpu=sm_87 //@ only-nvptx64 diff --git a/tests/assembly-llvm/nvptx-atomics.rs b/tests/assembly-llvm/nvptx-atomics.rs index 52b8c86d8a9c1..5895a731167c6 100644 --- a/tests/assembly-llvm/nvptx-atomics.rs +++ b/tests/assembly-llvm/nvptx-atomics.rs @@ -1,4 +1,4 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type cdylib //@ only-nvptx64 //@ ignore-nvptx64 diff --git a/tests/assembly-llvm/nvptx-c-abi-arg-v7.rs b/tests/assembly-llvm/nvptx-c-abi-arg-v7.rs index 6f5ef792e9b34..2f27988ba3743 100644 --- a/tests/assembly-llvm/nvptx-c-abi-arg-v7.rs +++ b/tests/assembly-llvm/nvptx-c-abi-arg-v7.rs @@ -1,4 +1,4 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type cdylib -C target-cpu=sm_86 //@ only-nvptx64 diff --git a/tests/assembly-llvm/nvptx-c-abi-ret-v7.rs b/tests/assembly-llvm/nvptx-c-abi-ret-v7.rs index 02ec9facee7a8..e7db3108952b1 100644 --- a/tests/assembly-llvm/nvptx-c-abi-ret-v7.rs +++ b/tests/assembly-llvm/nvptx-c-abi-ret-v7.rs @@ -1,4 +1,4 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type cdylib -C target-cpu=sm_86 //@ only-nvptx64 diff --git a/tests/assembly-llvm/nvptx-internalizing.rs b/tests/assembly-llvm/nvptx-internalizing.rs index 0acfd5c244319..b671c876e23a2 100644 --- a/tests/assembly-llvm/nvptx-internalizing.rs +++ b/tests/assembly-llvm/nvptx-internalizing.rs @@ -1,7 +1,6 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type cdylib //@ only-nvptx64 -//@ ignore-nvptx64 #![feature(abi_ptx)] #![no_std] diff --git a/tests/assembly-llvm/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs b/tests/assembly-llvm/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs index 00f6fe9332d94..cb88cfd33ee58 100644 --- a/tests/assembly-llvm/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs +++ b/tests/assembly-llvm/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs @@ -1,4 +1,4 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type cdylib -C target-cpu=sm_86 //@ only-nvptx64 diff --git a/tests/assembly-llvm/nvptx-linking-binary.rs b/tests/assembly-llvm/nvptx-linking-binary.rs index 3b50b472ab10e..4ec9c4a0af0bf 100644 --- a/tests/assembly-llvm/nvptx-linking-binary.rs +++ b/tests/assembly-llvm/nvptx-linking-binary.rs @@ -1,4 +1,4 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type bin //@ only-nvptx64 //@ ignore-nvptx64 diff --git a/tests/assembly-llvm/nvptx-linking-cdylib.rs b/tests/assembly-llvm/nvptx-linking-cdylib.rs index 9742e26fb31a9..82bca1f6c1699 100644 --- a/tests/assembly-llvm/nvptx-linking-cdylib.rs +++ b/tests/assembly-llvm/nvptx-linking-cdylib.rs @@ -1,4 +1,4 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type cdylib //@ only-nvptx64 //@ ignore-nvptx64 diff --git a/tests/assembly-llvm/nvptx-safe-naming.rs b/tests/assembly-llvm/nvptx-safe-naming.rs index 050c3fb9d93b6..69bf71b9a7821 100644 --- a/tests/assembly-llvm/nvptx-safe-naming.rs +++ b/tests/assembly-llvm/nvptx-safe-naming.rs @@ -1,4 +1,4 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type cdylib //@ only-nvptx64 diff --git a/tests/ui/linkage-attr/unstable-flavor.llbc.stderr b/tests/ui/linkage-attr/unstable-flavor.llbc.stderr new file mode 100644 index 0000000000000..796daa4c4e8c2 --- /dev/null +++ b/tests/ui/linkage-attr/unstable-flavor.llbc.stderr @@ -0,0 +1,2 @@ +error: the linker flavor `llbc` is unstable, the `-Z unstable-options` flag must also be passed to use the unstable values + diff --git a/tests/ui/linkage-attr/unstable-flavor.ptx.stderr b/tests/ui/linkage-attr/unstable-flavor.ptx.stderr deleted file mode 100644 index 2ebdc1a903399..0000000000000 --- a/tests/ui/linkage-attr/unstable-flavor.ptx.stderr +++ /dev/null @@ -1,2 +0,0 @@ -error: the linker flavor `ptx` is unstable, the `-Z unstable-options` flag must also be passed to use the unstable values - diff --git a/tests/ui/linkage-attr/unstable-flavor.rs b/tests/ui/linkage-attr/unstable-flavor.rs index 5412e248f341f..adb34a9a80cd8 100644 --- a/tests/ui/linkage-attr/unstable-flavor.rs +++ b/tests/ui/linkage-attr/unstable-flavor.rs @@ -2,14 +2,14 @@ // unique codepath checking all unstable options (see `LinkerFlavorCli::is_unstable` and its // caller). If it passes, all the other unstable options are rejected as well. // -//@ revisions: bpf ptx +//@ revisions: bpf llbc //@ [bpf] compile-flags: --target=bpfel-unknown-none -C linker-flavor=bpf --crate-type=rlib //@ [bpf] needs-llvm-components: bpf -//@ [ptx] compile-flags: --target=nvptx64-nvidia-cuda -C linker-flavor=ptx --crate-type=rlib -//@ [ptx] needs-llvm-components: nvptx +//@ [llbc] compile-flags: --target=nvptx64-nvidia-cuda -C linker-flavor=llbc --crate-type=rlib +//@ [llbc] needs-llvm-components: nvptx #![feature(no_core)] #![no_core] //[bpf]~? ERROR the linker flavor `bpf` is unstable -//[ptx]~? ERROR the linker flavor `ptx` is unstable +//[llbc]~? ERROR the linker flavor `llbc` is unstable diff --git a/tests/ui/target-feature/implied-features-nvptx.rs b/tests/ui/target-feature/implied-features-nvptx.rs index 1550c99f67a8d..a51c22afaf956 100644 --- a/tests/ui/target-feature/implied-features-nvptx.rs +++ b/tests/ui/target-feature/implied-features-nvptx.rs @@ -1,5 +1,5 @@ -//@ assembly-output: ptx-linker -//@ compile-flags: --crate-type cdylib -C target-cpu=sm_80 -Z unstable-options -Clinker-flavor=llbc +//@ assembly-output: emit-asm +//@ compile-flags: --crate-type cdylib -C target-cpu=sm_80 //@ only-nvptx64 //@ build-pass #![no_std] From 2c0f9de513810839717ddb5257a298928995cc04 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 29 May 2026 13:48:33 +0200 Subject: [PATCH 23/25] add ABI check logic for wasm --- compiler/rustc_target/src/spec/mod.rs | 13 +++++++++++++ compiler/rustc_target/src/target_features.rs | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index d6a9e27c46553..0dd2c11e6ff81 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -3582,6 +3582,19 @@ impl Target { "invalid `target_abi` for CSky" ); } + Arch::Wasm32 | Arch::Wasm64 => { + check!( + self.llvm_abiname == LlvmAbi::Unspecified, + "`llvm_abiname` is unused on wasm" + ); + check!(self.llvm_floatabi.is_none(), "`llvm_floatabi` is unused on wasm"); + check!(self.rustc_abi.is_none(), "`rustc_abi` is unused on wasm"); + check_matches!( + self.cfg_abi, + CfgAbi::Unspecified | CfgAbi::Other(_), + "invalid `target_abi` for wasm" + ); + } ref arch => { check!(self.rustc_abi.is_none(), "`rustc_abi` is unused on {arch}"); // Ensure consistency among built-in targets, but give JSON targets the opportunity diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index b009c42eb2302..c27cdc9bf2e9a 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -1312,11 +1312,17 @@ impl Target { } } Arch::Avr => { + // We only support one ABI on AVR at the moment. // SRAM is minimum requirement for C/C++ in both avr-gcc and Clang, // and backends of them only support assembly for devices have no SRAM. // See the discussion in https://github.com/rust-lang/rust/pull/146900 for more. FeatureConstraints { required: &["sram"], incompatible: &[] } } + Arch::Wasm32 | Arch::Wasm64 => { + // We only support one ABI on wasm at the moment. + // No ABI-relevant target features have been identified thus far. + NOTHING + } _ => NOTHING, } } From 77672953f8004c4bafd7fbde676d54392e22e98f Mon Sep 17 00:00:00 2001 From: aerooneqq Date: Fri, 29 May 2026 15:51:45 +0300 Subject: [PATCH 24/25] Remove DefPathTable, use `LocalDefId` instead of `DefIndex` where possible --- compiler/rustc_ast_lowering/src/lib.rs | 2 +- compiler/rustc_hir/src/definitions.rs | 175 ++++++++----------- compiler/rustc_metadata/src/rmeta/encoder.rs | 20 ++- compiler/rustc_middle/src/ty/context.rs | 4 +- 4 files changed, 84 insertions(+), 117 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index a916ee1f143bd..729cc0cc31b3b 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -542,7 +542,7 @@ pub fn lower_to_hir(tcx: TyCtxt<'_>, (): ()) -> mid_hir::Crate<'_> { let ast_index = index_crate(&resolver, &krate); let mut owners = IndexVec::from_fn_n( |_| hir::MaybeOwner::Phantom, - tcx.definitions_untracked().def_index_count(), + tcx.definitions_untracked().num_definitions(), ); let mut lowerer = item::ItemLowerer { diff --git a/compiler/rustc_hir/src/definitions.rs b/compiler/rustc_hir/src/definitions.rs index 70720c6dbd981..97e739a7f3893 100644 --- a/compiler/rustc_hir/src/definitions.rs +++ b/compiler/rustc_hir/src/definitions.rs @@ -20,84 +20,6 @@ pub use crate::def_id::DefPathHash; use crate::def_id::{CRATE_DEF_INDEX, CrateNum, DefIndex, LOCAL_CRATE, LocalDefId, StableCrateId}; use crate::def_path_hash_map::DefPathHashMap; -/// The `DefPathTable` maps `DefIndex`es to `DefKey`s and vice versa. -/// Internally the `DefPathTable` holds a tree of `DefKey`s, where each `DefKey` -/// stores the `DefIndex` of its parent. -/// There is one `DefPathTable` for each crate. -#[derive(Debug)] -pub struct DefPathTable { - stable_crate_id: StableCrateId, - index_to_key: IndexVec, - // We do only store the local hash, as all the definitions are from the current crate. - def_path_hashes: IndexVec, - def_path_hash_to_index: DefPathHashMap, -} - -impl DefPathTable { - fn new(stable_crate_id: StableCrateId) -> DefPathTable { - DefPathTable { - stable_crate_id, - index_to_key: Default::default(), - def_path_hashes: Default::default(), - def_path_hash_to_index: Default::default(), - } - } - - fn allocate(&mut self, key: DefKey, def_path_hash: DefPathHash) -> DefIndex { - // Assert that all DefPathHashes correctly contain the local crate's StableCrateId. - debug_assert_eq!(self.stable_crate_id, def_path_hash.stable_crate_id()); - let local_hash = def_path_hash.local_hash(); - - let index = self.index_to_key.push(key); - debug!("DefPathTable::insert() - {key:?} <-> {index:?}"); - - self.def_path_hashes.push(local_hash); - debug_assert!(self.def_path_hashes.len() == self.index_to_key.len()); - - // Check for hash collisions of DefPathHashes. These should be - // exceedingly rare. - if let Some(existing) = self.def_path_hash_to_index.insert(&local_hash, &index) { - let def_path1 = DefPath::make(LOCAL_CRATE, existing, |idx| self.def_key(idx)); - let def_path2 = DefPath::make(LOCAL_CRATE, index, |idx| self.def_key(idx)); - - // Continuing with colliding DefPathHashes can lead to correctness - // issues. We must abort compilation. - // - // The likelihood of such a collision is very small, so actually - // running into one could be indicative of a poor hash function - // being used. - // - // See the documentation for DefPathHash for more information. - panic!( - "found DefPathHash collision between {def_path1:#?} and {def_path2:#?}. \ - Compilation cannot continue." - ); - } - - index - } - - #[inline(always)] - pub fn def_key(&self, index: DefIndex) -> DefKey { - self.index_to_key[index] - } - - #[instrument(level = "trace", skip(self), ret)] - #[inline(always)] - pub fn def_path_hash(&self, index: DefIndex) -> DefPathHash { - let hash = self.def_path_hashes[index]; - DefPathHash::new(self.stable_crate_id, hash) - } - - pub fn enumerated_keys_and_path_hashes( - &self, - ) -> impl Iterator + ExactSizeIterator { - self.index_to_key - .iter_enumerated() - .map(move |(index, key)| (index, key, self.def_path_hash(index))) - } -} - #[derive(Debug, Default, Clone)] pub struct PerParentDisambiguatorState { #[cfg(debug_assertions)] @@ -123,12 +45,13 @@ impl LocalDefIdMap { } } -/// The definition table containing node definitions. -/// It holds the `DefPathTable` for `LocalDefId`s/`DefPath`s. -/// It also stores mappings to convert `LocalDefId`s to/from `HirId`s. #[derive(Debug)] pub struct Definitions { - table: DefPathTable, + stable_crate_id: StableCrateId, + def_id_to_key: IndexVec, + // We do only store the local hash, as all the definitions are from the current crate. + def_path_hashes: IndexVec, + def_path_hash_to_index: DefPathHashMap, } /// A unique identifier that we can use to lookup a definition @@ -167,7 +90,7 @@ impl DefKey { // Construct the new DefPathHash, making sure that the `crate_id` // portion of the hash is properly copied from the parent. This way the // `crate_id` part will be recursively propagated from the root to all - // DefPathHashes in this DefPathTable. + // DefPathHashes in this Definitions. DefPathHash::new(parent.stable_crate_id(), local_hash) } @@ -324,23 +247,15 @@ pub enum DefPathData { } impl Definitions { - pub fn def_path_table(&self) -> &DefPathTable { - &self.table - } - - /// Gets the number of definitions. - pub fn def_index_count(&self) -> usize { - self.table.index_to_key.len() - } - - #[inline] + #[inline(always)] pub fn def_key(&self, id: LocalDefId) -> DefKey { - self.table.def_key(id.local_def_index) + self.def_id_to_key[id] } + #[instrument(level = "trace", skip(self), ret)] #[inline(always)] pub fn def_path_hash(&self, id: LocalDefId) -> DefPathHash { - self.table.def_path_hash(id.local_def_index) + DefPathHash::new(self.stable_crate_id, self.def_path_hashes[id]) } /// Returns the path from the crate root to `index`. The root @@ -348,6 +263,7 @@ impl Definitions { /// empty vector for the crate root). For an inlined item, this /// will be the path of the item in the external crate (but the /// path will begin with the path to the external crate). + #[inline] pub fn def_path(&self, id: LocalDefId) -> DefPath { DefPath::make(LOCAL_CRATE, id.local_def_index, |index| { self.def_key(LocalDefId { local_def_index: index }) @@ -375,12 +291,62 @@ impl Definitions { let def_path_hash = DefPathHash::new(stable_crate_id, Hash64::new(stable_crate_id.as_u64())); + let mut defs = Definitions { + stable_crate_id, + def_path_hashes: Default::default(), + def_id_to_key: Default::default(), + def_path_hash_to_index: Default::default(), + }; + // Create the root definition. - let mut table = DefPathTable::new(stable_crate_id); - let root = LocalDefId { local_def_index: table.allocate(key, def_path_hash) }; + let root = defs.allocate(key, def_path_hash); assert_eq!(root.local_def_index, CRATE_DEF_INDEX); - Definitions { table } + defs + } + + fn allocate(&mut self, key: DefKey, def_path_hash: DefPathHash) -> LocalDefId { + // Assert that all DefPathHashes correctly contain the local crate's StableCrateId. + debug_assert_eq!(self.stable_crate_id, def_path_hash.stable_crate_id()); + let local_hash = def_path_hash.local_hash(); + + let def_id = self.def_id_to_key.push(key); + debug!("def_id_to_key.push() - {key:?} <-> {:?}", def_id.local_def_index); + + self.def_path_hashes.push(local_hash); + debug_assert!(self.def_path_hashes.len() == self.def_id_to_key.len()); + + // Check for hash collisions of DefPathHashes. These should be + // exceedingly rare. + if let Some(existing) = + self.def_path_hash_to_index.insert(&local_hash, &def_id.local_def_index) + { + let def_path1 = self.def_path(LocalDefId { local_def_index: existing }); + let def_path2 = self.def_path(def_id); + + // Continuing with colliding DefPathHashes can lead to correctness + // issues. We must abort compilation. + // + // The likelihood of such a collision is very small, so actually + // running into one could be indicative of a poor hash function + // being used. + // + // See the documentation for DefPathHash for more information. + panic!( + "found DefPathHash collision between {def_path1:#?} and {def_path2:#?}. \ + Compilation cannot continue." + ); + } + + def_id + } + + pub fn enumerated_keys_and_path_hashes( + &self, + ) -> impl Iterator + ExactSizeIterator { + self.def_id_to_key + .iter_enumerated() + .map(move |(def_id, key)| (def_id.local_def_index, key, self.def_path_hash(def_id))) } /// Creates a definition with a parent definition. @@ -423,13 +389,13 @@ impl Definitions { disambiguated_data: DisambiguatedDefPathData { data, disambiguator }, }; - let parent_hash = self.table.def_path_hash(parent.local_def_index); + let parent_hash = self.def_path_hash(parent); let def_path_hash = key.compute_stable_hash(parent_hash); debug!("create_def: after disambiguation, key = {:?}", key); // Create the definition. - LocalDefId { local_def_index: self.table.allocate(key, def_path_hash) } + self.allocate(key, def_path_hash) } #[inline(always)] @@ -439,19 +405,18 @@ impl Definitions { /// if the `DefPathHash` is from a previous compilation session and /// the def-path does not exist anymore. pub fn local_def_path_hash_to_def_id(&self, hash: DefPathHash) -> Option { - debug_assert!(hash.stable_crate_id() == self.table.stable_crate_id); - self.table - .def_path_hash_to_index + debug_assert!(hash.stable_crate_id() == self.stable_crate_id); + self.def_path_hash_to_index .get(&hash.local_hash()) .map(|local_def_index| LocalDefId { local_def_index }) } pub fn def_path_hash_to_def_index_map(&self) -> &DefPathHashMap { - &self.table.def_path_hash_to_index + &self.def_path_hash_to_index } pub fn num_definitions(&self) -> usize { - self.table.def_path_hashes.len() + self.def_path_hashes.len() } } diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index a0db004b7f4c4..a8befd6d188d2 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -12,7 +12,7 @@ use rustc_data_structures::temp_dir::MaybeTempDir; use rustc_data_structures::thousands::usize_with_underscores; use rustc_hir as hir; use rustc_hir::attrs::{AttributeKind, EncodeCrossCrate}; -use rustc_hir::def_id::{CRATE_DEF_ID, CRATE_DEF_INDEX, LOCAL_CRATE, LocalDefId, LocalDefIdSet}; +use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId, LocalDefIdSet}; use rustc_hir::definitions::DefPathData; use rustc_hir::find_attr; use rustc_hir_pretty::id_to_string; @@ -510,18 +510,20 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { } fn encode_def_path_table(&mut self) { - let table = self.tcx.def_path_table(); + let defs = self.tcx.definitions(); if self.is_proc_macro { - for def_index in std::iter::once(CRATE_DEF_INDEX) - .chain(self.tcx.resolutions(()).proc_macros.iter().map(|p| p.local_def_index)) + for def_id in std::iter::once(CRATE_DEF_ID) + .chain(self.tcx.resolutions(()).proc_macros.iter().copied()) { - let def_key = self.lazy(table.def_key(def_index)); - let def_path_hash = table.def_path_hash(def_index); - self.tables.def_keys.set_some(def_index, def_key); - self.tables.def_path_hashes.set(def_index, def_path_hash.local_hash().as_u64()); + let def_key = self.lazy(defs.def_key(def_id)); + let def_path_hash = defs.def_path_hash(def_id); + self.tables.def_keys.set_some(def_id.local_def_index, def_key); + self.tables + .def_path_hashes + .set(def_id.local_def_index, def_path_hash.local_hash().as_u64()); } } else { - for (def_index, def_key, def_path_hash) in table.enumerated_keys_and_path_hashes() { + for (def_index, def_key, def_path_hash) in defs.enumerated_keys_and_path_hashes() { let def_key = self.lazy(def_key); self.tables.def_keys.set_some(def_index, def_key); self.tables.def_path_hashes.set(def_index, def_path_hash.local_hash().as_u64()); diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index e756277b92d76..993edd5c2a09b 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1343,13 +1343,13 @@ impl<'tcx> TyCtxt<'tcx> { } } - pub fn def_path_table(self) -> &'tcx rustc_hir::definitions::DefPathTable { + pub fn definitions(self) -> &'tcx rustc_hir::definitions::Definitions { // Depend on the `analysis` query to ensure compilation if finished. self.ensure_ok().analysis(()); // Freeze definitions once we start iterating on them, to prevent adding new ones // while iterating. If some query needs to add definitions, it should be `ensure`d above. - self.untracked.definitions.freeze().def_path_table() + self.untracked.definitions.freeze() } pub fn def_path_hash_to_def_index_map( From 15b13982bfa68131fdc5e46ba5f947e478b98eda Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Fri, 21 Nov 2025 21:58:09 +0300 Subject: [PATCH 25/25] resolve: Partially convert `ambiguous_glob_imports` lint into a hard error --- .../build_system/src/test.rs | 2 - compiler/rustc_lint_defs/src/builtin.rs | 27 +-- .../rustc_resolve/src/build_reduced_graph.rs | 9 +- compiler/rustc_resolve/src/diagnostics.rs | 2 +- compiler/rustc_resolve/src/imports.rs | 192 ++++++++++-------- compiler/rustc_resolve/src/lib.rs | 37 +--- tests/ui/imports/ambiguous-1.rs | 6 +- tests/ui/imports/ambiguous-1.stderr | 60 ++---- tests/ui/imports/ambiguous-10.rs | 1 - tests/ui/imports/ambiguous-10.stderr | 30 +-- tests/ui/imports/ambiguous-12.rs | 1 - tests/ui/imports/ambiguous-12.stderr | 30 +-- tests/ui/imports/ambiguous-13.rs | 1 - tests/ui/imports/ambiguous-13.stderr | 30 +-- tests/ui/imports/ambiguous-15.rs | 1 - tests/ui/imports/ambiguous-15.stderr | 30 +-- tests/ui/imports/ambiguous-16.rs | 1 - tests/ui/imports/ambiguous-16.stderr | 30 +-- tests/ui/imports/ambiguous-17.rs | 1 - tests/ui/imports/ambiguous-17.stderr | 44 +--- tests/ui/imports/ambiguous-2.rs | 9 - tests/ui/imports/ambiguous-2.stderr | 49 ----- tests/ui/imports/ambiguous-3.rs | 1 - tests/ui/imports/ambiguous-3.stderr | 34 +--- tests/ui/imports/ambiguous-4-extern.rs | 6 +- tests/ui/imports/ambiguous-4-extern.stderr | 58 ++---- tests/ui/imports/ambiguous-4.rs | 9 - tests/ui/imports/ambiguous-4.stderr | 49 ----- tests/ui/imports/ambiguous-5.rs | 1 - tests/ui/imports/ambiguous-5.stderr | 30 +-- tests/ui/imports/ambiguous-6.rs | 1 - tests/ui/imports/ambiguous-6.stderr | 34 +--- tests/ui/imports/ambiguous-9.rs | 2 - tests/ui/imports/ambiguous-9.stderr | 90 ++------ .../ui/imports/ambiguous-panic-globvsglob.rs | 3 +- .../imports/ambiguous-panic-globvsglob.stderr | 30 +-- .../ui/imports/glob-conflict-cross-crate-3.rs | 1 - .../glob-conflict-cross-crate-3.stderr | 55 ++--- .../imports/unresolved-seg-after-ambiguous.rs | 4 +- .../unresolved-seg-after-ambiguous.stderr | 39 +--- 40 files changed, 225 insertions(+), 815 deletions(-) delete mode 100644 tests/ui/imports/ambiguous-2.rs delete mode 100644 tests/ui/imports/ambiguous-2.stderr delete mode 100644 tests/ui/imports/ambiguous-4.rs delete mode 100644 tests/ui/imports/ambiguous-4.stderr diff --git a/compiler/rustc_codegen_gcc/build_system/src/test.rs b/compiler/rustc_codegen_gcc/build_system/src/test.rs index 3f02df8399554..2475a3a6a7155 100644 --- a/compiler/rustc_codegen_gcc/build_system/src/test.rs +++ b/compiler/rustc_codegen_gcc/build_system/src/test.rs @@ -886,8 +886,6 @@ fn valid_ui_error_pattern_test(file: &str) -> bool { "type-alias-impl-trait/auxiliary/cross_crate_ice.rs", "type-alias-impl-trait/auxiliary/cross_crate_ice2.rs", "macros/rfc-2011-nicer-assert-messages/auxiliary/common.rs", - "imports/ambiguous-1.rs", - "imports/ambiguous-4-extern.rs", "entry-point/auxiliary/bad_main_functions.rs", ] .iter() diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index caa41fd0f6ab3..8ddaf7a630d31 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -4529,28 +4529,21 @@ declare_lint! { /// /// ### Example /// - /// ```rust,compile_fail - /// #![deny(ambiguous_glob_imports)] - /// pub fn foo() -> u32 { - /// use sub::*; - /// C - /// } - /// - /// mod sub { - /// mod mod1 { pub const C: u32 = 1; } - /// mod mod2 { pub const C: u32 = 2; } + /// ```rust,ignore (needs extern crate) + /// // library crate `my_library` + /// mod mod1 { pub const C: u32 = 1; } + /// mod mod2 { pub const C: u32 = 2; } + /// pub use mod1::*; + /// pub use mod2::*; /// - /// pub use mod1::*; - /// pub use mod2::*; - /// } + /// // another crate using `my_library` + /// let c = my_library::C; // `C` is ambiguous /// ``` /// - /// {{produces}} - /// /// ### Explanation /// - /// Previous versions of Rust compile it successfully because it - /// had lost the ambiguity error when resolve `use sub::mod2::*`. + /// Previous versions of Rust compile it successfully because + /// ambiguous glob imports weren't preserved correctly over crate boundaries. /// /// This is a [future-incompatible] lint to transition this to a /// hard error in the future. diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index 43443e0ac3052..4fd98944909dc 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -52,7 +52,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { decl: Decl<'ra>, ) { if let Err(old_decl) = - self.try_plant_decl_into_local_module(ident, orig_ident_span, ns, decl, false) + self.try_plant_decl_into_local_module(ident, orig_ident_span, ns, decl) { self.report_conflict(ident, ns, old_decl, decl); } @@ -87,13 +87,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { vis: Visibility, span: Span, expansion: LocalExpnId, - ambiguity: Option>, + ambiguity: Option<(Decl<'ra>, bool)>, ) { let decl = self.arenas.alloc_decl(DeclData { kind: DeclKind::Def(res), ambiguity: CmCell::new(ambiguity), - // External ambiguities always report the `AMBIGUOUS_GLOB_IMPORTS` lint at the moment. - warn_ambiguity: CmCell::new(true), initial_vis: vis, ambiguity_vis_max: CmCell::new(None), ambiguity_vis_min: CmCell::new(None), @@ -392,7 +390,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { let ModChild { ident: _, res, vis, ref reexport_chain } = *ambig_child; let span = child_span(self, reexport_chain, res); let res = res.expect_non_local(); - self.arenas.new_def_decl(res, vis, span, expansion, Some(parent.to_module())) + // External ambiguities always report the `AMBIGUOUS_GLOB_IMPORTS` lint at the moment. + (self.arenas.new_def_decl(res, vis, span, expansion, Some(parent.to_module())), true) }); // Record primary definitions. diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 85e8d6711e075..d75ae850ca33b 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1188,7 +1188,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { .emit() } - fn def_path_str(&self, mut def_id: DefId) -> String { + pub(crate) fn def_path_str(&self, mut def_id: DefId) -> String { // We can't use `def_path_str` in resolve. let mut path = vec![def_id]; while let Some(parent) = self.tcx.opt_parent(def_id) { diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index c49e0fce630d4..c95799758cd59 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -382,11 +382,9 @@ fn remove_same_import<'ra>(d1: Decl<'ra>, d2: Decl<'ra>) -> (Decl<'ra>, Decl<'ra assert_eq!(d1.span, d2.span); if d1.ambiguity.get() != d2.ambiguity.get() { assert!(d1.ambiguity.get().is_some()); - assert!(d2.ambiguity.get().is_none()); } // Visibility of the new import declaration may be different, // because it already incorporates the visibility of the source binding. - // `warn_ambiguity` of a re-fetched glob can also change in both directions. remove_same_import(d1_next, d2_next) } else { (d1, d2) @@ -450,7 +448,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { self.arenas.alloc_decl(DeclData { kind: DeclKind::Import { source_decl: decl, import }, ambiguity: CmCell::new(None), - warn_ambiguity: CmCell::new(false), span: import.span, initial_vis: vis.to_def_id(), ambiguity_vis_max: CmCell::new(None), @@ -460,14 +457,85 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { }) } + fn is_noise_0_7_0(&self, old_glob_decl: Decl<'ra>, glob_decl: Decl<'ra>) -> bool { + let DeclKind::Import { import: i1, .. } = glob_decl.kind else { unreachable!() }; + let DeclKind::Import { import: i2, .. } = old_glob_decl.kind else { unreachable!() }; + let [seg1, seg2] = &i1.module_path[..] else { return false }; + if seg1.ident.name != kw::SelfLower || seg2.ident.name.as_str() != "perlin_surflet" { + return false; + } + let [seg1, seg2] = &i2.module_path[..] else { return false }; + if seg1.ident.name != kw::SelfLower || seg2.ident.name.as_str() != "perlin" { + return false; + } + let Some(def_id1) = glob_decl.res().opt_def_id() else { return false }; + let Some(def_id2) = old_glob_decl.res().opt_def_id() else { return false }; + self.def_path_str(def_id1).ends_with("noise_fns::generators::perlin_surflet::Perlin") + && self.def_path_str(def_id2).ends_with("noise_fns::generators::perlin::Perlin") + } + + fn is_rustybuzz_0_4_0(&self, old_glob_decl: Decl<'ra>, glob_decl: Decl<'ra>) -> bool { + let DeclKind::Import { import: i1, .. } = glob_decl.kind else { unreachable!() }; + let DeclKind::Import { import: i2, .. } = old_glob_decl.kind else { unreachable!() }; + let [seg1, seg2] = &i1.module_path[..] else { return false }; + if seg1.ident.name != kw::Super || seg2.ident.name.as_str() != "gsubgpos" { + return false; + } + let [seg1] = &i2.module_path[..] else { return false }; + if seg1.ident.name != kw::Super { + return false; + } + let Some(def_id1) = glob_decl.res().opt_def_id() else { return false }; + let Some(def_id2) = old_glob_decl.res().opt_def_id() else { return false }; + self.def_path_str(def_id1).ends_with("tables::gsubgpos::Class") + && self.def_path_str(def_id2).ends_with("ggg::Class") + } + + fn is_pdf_0_9_0(&self, old_glob_decl: Decl<'ra>, glob_decl: Decl<'ra>) -> bool { + let DeclKind::Import { import: i1, .. } = glob_decl.kind else { unreachable!() }; + let DeclKind::Import { import: i2, .. } = old_glob_decl.kind else { unreachable!() }; + let [seg1, seg2] = &i1.module_path[..] else { return false }; + if seg1.ident.name != kw::Crate || seg2.ident.name.as_str() != "content" { + return false; + } + let [seg1, seg2] = &i2.module_path[..] else { return false }; + if seg1.ident.name != kw::Crate || seg2.ident.name.as_str() != "object" { + return false; + } + let Some(def_id1) = glob_decl.res().opt_def_id() else { return false }; + let Some(def_id2) = old_glob_decl.res().opt_def_id() else { return false }; + self.def_path_str(def_id1).ends_with("crate::content::Rect") + && self.def_path_str(def_id2).ends_with("crate::object::types::Rect") + } + + fn is_net2_0_2_39(&self, old_glob_decl: Decl<'ra>, glob_decl: Decl<'ra>) -> bool { + let DeclKind::Import { import: i1, .. } = glob_decl.kind else { unreachable!() }; + let DeclKind::Import { import: i2, .. } = old_glob_decl.kind else { unreachable!() }; + let [seg1, seg2, seg3, seg4] = &i1.module_path[..] else { return false }; + if seg1.ident.name != kw::PathRoot + || seg2.ident.name.as_str() != "winapi" + || seg3.ident.name.as_str() != "shared" + || seg4.ident.name.as_str() != "ws2def" + { + return false; + } + let [seg1, seg2, seg3, seg4] = &i2.module_path[..] else { return false }; + if seg1.ident.name != kw::PathRoot + || seg2.ident.name.as_str() != "winapi" + || seg3.ident.name.as_str() != "um" + || seg4.ident.name.as_str() != "winsock2" + { + return false; + } + let Some(def_id1) = glob_decl.res().opt_def_id() else { return false }; + let Some(def_id2) = old_glob_decl.res().opt_def_id() else { return false }; + self.def_path_str(def_id1).starts_with("winapi::shared::ws2def::") + && self.def_path_str(def_id2).starts_with("winapi::um::winsock2::") + } + /// If `glob_decl` attempts to overwrite `old_glob_decl` in a module, /// decide which one to keep. - fn select_glob_decl( - &self, - old_glob_decl: Decl<'ra>, - glob_decl: Decl<'ra>, - warn_ambiguity: bool, - ) -> Decl<'ra> { + fn select_glob_decl(&self, old_glob_decl: Decl<'ra>, glob_decl: Decl<'ra>) -> Decl<'ra> { assert!(glob_decl.is_glob_import()); assert!(old_glob_decl.is_glob_import()); assert_ne!(glob_decl, old_glob_decl); @@ -476,9 +544,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // all these overwrites will be re-fetched by glob imports importing // from that module without generating new ambiguities. // - A glob decl is overwritten by a non-glob decl arriving later. - // - A glob decl is overwritten by its clone after setting ambiguity in it. - // FIXME: avoid this by removing `warn_ambiguity`, or by triggering glob re-fetch - // with the same decl in some way. // - A glob decl is overwritten by a glob decl re-fetching an // overwritten decl from other module (the recursive case). // Here we are detecting all such re-fetches and overwrite old decls @@ -489,29 +554,21 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { if deep_decl != glob_decl { // Some import layers have been removed, need to overwrite. assert_ne!(old_deep_decl, old_glob_decl); - // FIXME: reenable the asserts when `warn_ambiguity` is removed (#149195). - // assert_ne!(old_deep_decl, deep_decl); - // assert!(old_deep_decl.is_glob_import()); assert!(!deep_decl.is_glob_import()); - if old_glob_decl.ambiguity.get().is_some() && glob_decl.ambiguity.get().is_none() { + if let Some((old_ambig, _)) = old_glob_decl.ambiguity.get() + && glob_decl.ambiguity.get().is_none() + { // Do not lose glob ambiguities when re-fetching the glob. - glob_decl.ambiguity.set_unchecked(old_glob_decl.ambiguity.get()); - } - if glob_decl.is_ambiguity_recursive() { - glob_decl.warn_ambiguity.set_unchecked(true); + glob_decl.ambiguity.set_unchecked(Some((old_ambig, true))); } glob_decl } else if glob_decl.res() != old_glob_decl.res() { - old_glob_decl.ambiguity.set_unchecked(Some(glob_decl)); - old_glob_decl.warn_ambiguity.set_unchecked(warn_ambiguity); - if warn_ambiguity { - old_glob_decl - } else { - // Need a fresh decl so other glob imports importing it could re-fetch it - // and set their own `warn_ambiguity` to true. - // FIXME: remove this when `warn_ambiguity` is removed (#149195). - self.arenas.alloc_decl((*old_glob_decl).clone()) - } + let warning = self.is_noise_0_7_0(old_glob_decl, glob_decl) + || self.is_rustybuzz_0_4_0(old_glob_decl, glob_decl) + || self.is_pdf_0_9_0(old_glob_decl, glob_decl) + || self.is_net2_0_2_39(old_glob_decl, glob_decl); + old_glob_decl.ambiguity.set_unchecked(Some((glob_decl, warning))); + old_glob_decl } else if let old_vis = old_glob_decl.vis() && let vis = glob_decl.vis() && old_vis != vis @@ -529,8 +586,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { old_glob_decl } else if glob_decl.is_ambiguity_recursive() && !old_glob_decl.is_ambiguity_recursive() { // Overwriting a non-ambiguous glob import with an ambiguous glob import. - old_glob_decl.ambiguity.set_unchecked(Some(glob_decl)); - old_glob_decl.warn_ambiguity.set_unchecked(true); + old_glob_decl.ambiguity.set_unchecked(Some((glob_decl, true))); old_glob_decl } else { old_glob_decl @@ -545,9 +601,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { orig_ident_span: Span, ns: Namespace, decl: Decl<'ra>, - warn_ambiguity: bool, ) -> Result<(), Decl<'ra>> { - assert!(!decl.warn_ambiguity.get()); assert!(decl.ambiguity.get().is_none()); assert!(decl.ambiguity_vis_max.get().is_none()); assert!(decl.ambiguity_vis_min.get().is_none()); @@ -562,31 +616,21 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { module.underscore_disambiguator.update_unchecked(|d| d + 1); module.underscore_disambiguator.get() }); - self.update_local_resolution( - module, - key, - orig_ident_span, - warn_ambiguity, - |this, resolution| { - if decl.is_glob_import() { - resolution.glob_decl = Some(match resolution.glob_decl { - Some(old_decl) => this.select_glob_decl( - old_decl, - decl, - warn_ambiguity && resolution.non_glob_decl.is_none(), - ), - None => decl, - }) - } else { - resolution.non_glob_decl = Some(match resolution.non_glob_decl { - Some(old_decl) => return Err(old_decl), - None => decl, - }) - } + self.update_local_resolution(module, key, orig_ident_span, |this, resolution| { + if decl.is_glob_import() { + resolution.glob_decl = Some(match resolution.glob_decl { + Some(old_decl) => this.select_glob_decl(old_decl, decl), + None => decl, + }); + } else { + resolution.non_glob_decl = Some(match resolution.non_glob_decl { + Some(old_decl) => return Err(old_decl), + None => decl, + }) + } - Ok(()) - }, - ) + Ok(()) + }) } // Use `f` to mutate the resolution of the name in the module. @@ -596,7 +640,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { module: LocalModule<'ra>, key: BindingKey, orig_ident_span: Span, - warn_ambiguity: bool, f: F, ) -> T where @@ -604,7 +647,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { { // Ensure that `resolution` isn't borrowed when defining in the module's glob importers, // during which the resolution might end up getting re-defined via a glob cycle. - let (binding, t, warn_ambiguity) = { + let (binding, t) = { let resolution = &mut *self .resolution_or_default(module.to_module(), key, orig_ident_span) .borrow_mut_unchecked(); @@ -616,7 +659,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { if let Some(binding) = resolution.determined_decl() && (old_decl != Some(binding) || old_vis != Some(binding.vis())) { - (binding, t, warn_ambiguity || old_decl.is_some()) + (binding, t) } else { return t; } @@ -639,14 +682,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { }; if self.is_accessible_from(binding.vis(), scope) { let import_decl = self.new_import_decl(binding, *import); - self.try_plant_decl_into_local_module( - ident, - orig_ident_span, - key.ns, - import_decl, - warn_ambiguity, - ) - .expect("planting a glob cannot fail"); + self.try_plant_decl_into_local_module(ident, orig_ident_span, key.ns, import_decl) + .expect("planting a glob cannot fail"); } } @@ -665,13 +702,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { self.per_ns(|this, ns| { let ident = IdentKey::new(target); // This can fail, dummies are inserted only in non-occupied slots. - let _ = this.try_plant_decl_into_local_module( - ident, - target.span, - ns, - dummy_decl, - false, - ); + let _ = this.try_plant_decl_into_local_module(ident, target.span, ns, dummy_decl); // Don't remove underscores from `single_imports`, they were never added. if target.name != kw::Underscore { let key = BindingKey::new(ident, ns); @@ -679,7 +710,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { import.parent_scope.module.expect_local(), key, target.span, - false, |_, resolution| { resolution.single_imports.swap_remove(&import); }, @@ -846,7 +876,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } if let DeclKind::Import { import, .. } = binding.kind - && let Some(amb_binding) = binding.ambiguity.get() + && let Some((amb_binding, _)) = binding.ambiguity.get() && binding.res() != Res::Err && exported_ambiguities.contains(&binding) { @@ -1134,7 +1164,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { parent.expect_local(), key, target.span, - false, |_, resolution| { resolution.single_imports.swap_remove(&import); }, @@ -1820,16 +1849,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { }; if self.is_accessible_from(binding.vis(), scope) { let import_decl = self.new_import_decl(binding, import); - let warn_ambiguity = self - .resolution(import.parent_scope.module, key) - .and_then(|r| r.determined_decl()) - .is_some_and(|binding| binding.warn_ambiguity_recursive()); self.try_plant_decl_into_local_module( key.ident, orig_ident_span, key.ns, import_decl, - warn_ambiguity, ) .expect("planting a glob cannot fail"); } diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index f5f4c9e6e2580..e23e2c1499c94 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -996,10 +996,7 @@ impl<'ra> fmt::Debug for LocalModule<'ra> { #[derive(Clone, Debug)] struct DeclData<'ra> { kind: DeclKind<'ra>, - ambiguity: CmCell>>, - /// Produce a warning instead of an error when reporting ambiguities inside this binding. - /// May apply to indirect ambiguities under imports, so `ambiguity.is_some()` is not required. - warn_ambiguity: CmCell, + ambiguity: CmCell, bool /*warning*/)>>, expansion: LocalExpnId, span: Span, initial_vis: Visibility, @@ -1160,7 +1157,7 @@ impl<'ra> DeclData<'ra> { fn descent_to_ambiguity(self: Decl<'ra>) -> Option<(Decl<'ra>, Decl<'ra>)> { match self.ambiguity.get() { - Some(ambig_binding) => Some((self, ambig_binding)), + Some((ambig_binding, _)) => Some((self, ambig_binding)), None => match self.kind { DeclKind::Import { source_decl, .. } => source_decl.descent_to_ambiguity(), _ => None, @@ -1176,14 +1173,6 @@ impl<'ra> DeclData<'ra> { } } - fn warn_ambiguity_recursive(&self) -> bool { - self.warn_ambiguity.get() - || match self.kind { - DeclKind::Import { source_decl, .. } => source_decl.warn_ambiguity_recursive(), - _ => false, - } - } - fn is_possibly_imported_variant(&self) -> bool { match self.kind { DeclKind::Import { source_decl, .. } => source_decl.is_possibly_imported_variant(), @@ -1595,7 +1584,6 @@ impl<'ra> ResolverArenas<'ra> { self.alloc_decl(DeclData { kind: DeclKind::Def(res), ambiguity: CmCell::new(None), - warn_ambiguity: CmCell::new(false), initial_vis: vis, ambiguity_vis_max: CmCell::new(None), ambiguity_vis_min: CmCell::new(None), @@ -2261,17 +2249,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } fn record_use(&mut self, ident: Ident, used_decl: Decl<'ra>, used: Used) { - self.record_use_inner(ident, used_decl, used, used_decl.warn_ambiguity.get()); - } - - fn record_use_inner( - &mut self, - ident: Ident, - used_decl: Decl<'ra>, - used: Used, - warn_ambiguity: bool, - ) { - if let Some(b2) = used_decl.ambiguity.get() { + if let Some((b2, warning)) = used_decl.ambiguity.get() { let ambiguity_error = AmbiguityError { kind: AmbiguityKind::GlobVsGlob, ambig_vis: None, @@ -2280,7 +2258,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { b2, scope1: Scope::ModuleGlobs(used_decl.parent_module.unwrap(), None), scope2: Scope::ModuleGlobs(b2.parent_module.unwrap(), None), - warning: if warn_ambiguity { Some(AmbiguityWarning::GlobImport) } else { None }, + warning: if warning { Some(AmbiguityWarning::GlobImport) } else { None }, }; if !self.matches_previous_ambiguity_error(&ambiguity_error) { // avoid duplicated span information to be emit out @@ -2330,12 +2308,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { self.used_imports.insert(id); } self.add_to_glob_map(import, ident.name); - self.record_use_inner( - ident, - source_decl, - Used::Other, - warn_ambiguity || source_decl.warn_ambiguity.get(), - ); + self.record_use(ident, source_decl, Used::Other); } } diff --git a/tests/ui/imports/ambiguous-1.rs b/tests/ui/imports/ambiguous-1.rs index 31f39eee62b9a..6c8e7da74f967 100644 --- a/tests/ui/imports/ambiguous-1.rs +++ b/tests/ui/imports/ambiguous-1.rs @@ -1,8 +1,5 @@ -//@ check-pass // https://github.com/rust-lang/rust/pull/112743#issuecomment-1601986883 -#![warn(ambiguous_glob_imports)] - macro_rules! m { () => { pub fn id() {} @@ -27,6 +24,5 @@ pub use openssl::*; fn main() { id(); - //~^ WARNING `id` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~^ ERROR `id` is ambiguous } diff --git a/tests/ui/imports/ambiguous-1.stderr b/tests/ui/imports/ambiguous-1.stderr index 603a8938194b1..b891baafe5710 100644 --- a/tests/ui/imports/ambiguous-1.stderr +++ b/tests/ui/imports/ambiguous-1.stderr @@ -1,68 +1,34 @@ -warning: ambiguous glob re-exports - --> $DIR/ambiguous-1.rs:13:13 - | -LL | pub use self::evp::*; - | ^^^^^^^^^^^^ the name `id` in the value namespace is first re-exported here -LL | -LL | pub use self::handwritten::*; - | -------------------- but the name `id` in the value namespace is also re-exported here - | - = note: `#[warn(ambiguous_glob_reexports)]` on by default - -warning: `id` is ambiguous - --> $DIR/ambiguous-1.rs:29:5 +error[E0659]: `id` is ambiguous + --> $DIR/ambiguous-1.rs:26:5 | LL | id(); | ^^ ambiguous name | = note: ambiguous because of multiple glob imports of a name in the same module note: `id` could refer to the function imported here - --> $DIR/ambiguous-1.rs:13:13 + --> $DIR/ambiguous-1.rs:10:13 | LL | pub use self::evp::*; | ^^^^^^^^^^^^ = help: consider adding an explicit import of `id` to disambiguate note: `id` could also refer to the function imported here - --> $DIR/ambiguous-1.rs:15:13 + --> $DIR/ambiguous-1.rs:12:13 | LL | pub use self::handwritten::*; | ^^^^^^^^^^^^^^^^^^^^ = help: consider adding an explicit import of `id` to disambiguate - = 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 #114095 -note: the lint level is defined here - --> $DIR/ambiguous-1.rs:4:9 - | -LL | #![warn(ambiguous_glob_imports)] - | ^^^^^^^^^^^^^^^^^^^^^^ - -warning: 2 warnings emitted -Future incompatibility report: Future breakage diagnostic: -warning: `id` is ambiguous - --> $DIR/ambiguous-1.rs:29:5 - | -LL | id(); - | ^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `id` could refer to the function imported here - --> $DIR/ambiguous-1.rs:13:13 +warning: ambiguous glob re-exports + --> $DIR/ambiguous-1.rs:10:13 | LL | pub use self::evp::*; - | ^^^^^^^^^^^^ - = help: consider adding an explicit import of `id` to disambiguate -note: `id` could also refer to the function imported here - --> $DIR/ambiguous-1.rs:15:13 - | + | ^^^^^^^^^^^^ the name `id` in the value namespace is first re-exported here +LL | LL | pub use self::handwritten::*; - | ^^^^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `id` to disambiguate - = 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 #114095 -note: the lint level is defined here - --> $DIR/ambiguous-1.rs:4:9 + | -------------------- but the name `id` in the value namespace is also re-exported here | -LL | #![warn(ambiguous_glob_imports)] - | ^^^^^^^^^^^^^^^^^^^^^^ + = note: `#[warn(ambiguous_glob_reexports)]` on by default + +error: aborting due to 1 previous error; 1 warning emitted +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-10.rs b/tests/ui/imports/ambiguous-10.rs index 166b01ede12d3..362633b2cb29c 100644 --- a/tests/ui/imports/ambiguous-10.rs +++ b/tests/ui/imports/ambiguous-10.rs @@ -14,5 +14,4 @@ use crate::a::*; use crate::b::*; fn c(_: Token) {} //~^ ERROR `Token` is ambiguous -//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! fn main() { } diff --git a/tests/ui/imports/ambiguous-10.stderr b/tests/ui/imports/ambiguous-10.stderr index edd787785d9d8..e3f126d338c49 100644 --- a/tests/ui/imports/ambiguous-10.stderr +++ b/tests/ui/imports/ambiguous-10.stderr @@ -1,4 +1,4 @@ -error: `Token` is ambiguous +error[E0659]: `Token` is ambiguous --> $DIR/ambiguous-10.rs:15:9 | LL | fn c(_: Token) {} @@ -17,33 +17,7 @@ note: `Token` could also refer to the enum imported here LL | use crate::b::*; | ^^^^^^^^^^^ = help: consider adding an explicit import of `Token` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error -Future incompatibility report: Future breakage diagnostic: -error: `Token` is ambiguous - --> $DIR/ambiguous-10.rs:15:9 - | -LL | fn c(_: Token) {} - | ^^^^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `Token` could refer to the enum imported here - --> $DIR/ambiguous-10.rs:13:5 - | -LL | use crate::a::*; - | ^^^^^^^^^^^ - = help: consider adding an explicit import of `Token` to disambiguate -note: `Token` could also refer to the enum imported here - --> $DIR/ambiguous-10.rs:14:5 - | -LL | use crate::b::*; - | ^^^^^^^^^^^ - = help: consider adding an explicit import of `Token` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-12.rs b/tests/ui/imports/ambiguous-12.rs index 543396b8dfe5c..54bdf26e88cce 100644 --- a/tests/ui/imports/ambiguous-12.rs +++ b/tests/ui/imports/ambiguous-12.rs @@ -20,5 +20,4 @@ use crate::public::*; fn main() { b(); //~^ ERROR `b` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } diff --git a/tests/ui/imports/ambiguous-12.stderr b/tests/ui/imports/ambiguous-12.stderr index e20eec249965a..099abd66e8a3c 100644 --- a/tests/ui/imports/ambiguous-12.stderr +++ b/tests/ui/imports/ambiguous-12.stderr @@ -1,4 +1,4 @@ -error: `b` is ambiguous +error[E0659]: `b` is ambiguous --> $DIR/ambiguous-12.rs:21:5 | LL | b(); @@ -17,33 +17,7 @@ note: `b` could also refer to the function imported here LL | use crate::public::*; | ^^^^^^^^^^^^^^^^ = help: consider adding an explicit import of `b` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error -Future incompatibility report: Future breakage diagnostic: -error: `b` is ambiguous - --> $DIR/ambiguous-12.rs:21:5 - | -LL | b(); - | ^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `b` could refer to the function imported here - --> $DIR/ambiguous-12.rs:17:5 - | -LL | use crate::ciphertext::*; - | ^^^^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `b` to disambiguate -note: `b` could also refer to the function imported here - --> $DIR/ambiguous-12.rs:18:5 - | -LL | use crate::public::*; - | ^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `b` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-13.rs b/tests/ui/imports/ambiguous-13.rs index 3569dd5d9adc2..7dc617ce48768 100644 --- a/tests/ui/imports/ambiguous-13.rs +++ b/tests/ui/imports/ambiguous-13.rs @@ -17,5 +17,4 @@ use crate::content::*; fn a(_: Rect) {} //~^ ERROR `Rect` is ambiguous -//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! fn main() { } diff --git a/tests/ui/imports/ambiguous-13.stderr b/tests/ui/imports/ambiguous-13.stderr index c1dfac5eb4332..1d105eec0e36f 100644 --- a/tests/ui/imports/ambiguous-13.stderr +++ b/tests/ui/imports/ambiguous-13.stderr @@ -1,4 +1,4 @@ -error: `Rect` is ambiguous +error[E0659]: `Rect` is ambiguous --> $DIR/ambiguous-13.rs:18:9 | LL | fn a(_: Rect) {} @@ -17,33 +17,7 @@ note: `Rect` could also refer to the struct imported here LL | use crate::content::*; | ^^^^^^^^^^^^^^^^^ = help: consider adding an explicit import of `Rect` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error -Future incompatibility report: Future breakage diagnostic: -error: `Rect` is ambiguous - --> $DIR/ambiguous-13.rs:18:9 - | -LL | fn a(_: Rect) {} - | ^^^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `Rect` could refer to the struct imported here - --> $DIR/ambiguous-13.rs:15:5 - | -LL | use crate::object::*; - | ^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `Rect` to disambiguate -note: `Rect` could also refer to the struct imported here - --> $DIR/ambiguous-13.rs:16:5 - | -LL | use crate::content::*; - | ^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `Rect` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-15.rs b/tests/ui/imports/ambiguous-15.rs index 07d8893b2dead..72c2940573c6b 100644 --- a/tests/ui/imports/ambiguous-15.rs +++ b/tests/ui/imports/ambiguous-15.rs @@ -21,6 +21,5 @@ mod t3 { use self::t3::*; fn a(_: E) {} //~^ ERROR `Error` is ambiguous -//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! fn main() {} diff --git a/tests/ui/imports/ambiguous-15.stderr b/tests/ui/imports/ambiguous-15.stderr index cb9f6ebde1fb1..fb3551d76274c 100644 --- a/tests/ui/imports/ambiguous-15.stderr +++ b/tests/ui/imports/ambiguous-15.stderr @@ -1,4 +1,4 @@ -error: `Error` is ambiguous +error[E0659]: `Error` is ambiguous --> $DIR/ambiguous-15.rs:22:9 | LL | fn a(_: E) {} @@ -17,33 +17,7 @@ note: `Error` could also refer to the enum imported here LL | pub use t2::*; | ^^^^^ = help: consider adding an explicit import of `Error` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error -Future incompatibility report: Future breakage diagnostic: -error: `Error` is ambiguous - --> $DIR/ambiguous-15.rs:22:9 - | -LL | fn a(_: E) {} - | ^^^^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `Error` could refer to the trait imported here - --> $DIR/ambiguous-15.rs:21:5 - | -LL | use self::t3::*; - | ^^^^^^^^^^^ - = help: consider adding an explicit import of `Error` to disambiguate -note: `Error` could also refer to the enum imported here - --> $DIR/ambiguous-15.rs:15:9 - | -LL | pub use t2::*; - | ^^^^^ - = help: consider adding an explicit import of `Error` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-16.rs b/tests/ui/imports/ambiguous-16.rs index f31c78d18a380..a20c0e340d601 100644 --- a/tests/ui/imports/ambiguous-16.rs +++ b/tests/ui/imports/ambiguous-16.rs @@ -21,6 +21,5 @@ mod framing { use crate::framing::ConfirmedTranscriptHashInput; //~^ ERROR `ConfirmedTranscriptHashInput` is ambiguous -//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! fn main() { } diff --git a/tests/ui/imports/ambiguous-16.stderr b/tests/ui/imports/ambiguous-16.stderr index cad19b8f7a16b..c18242d4a3cfc 100644 --- a/tests/ui/imports/ambiguous-16.stderr +++ b/tests/ui/imports/ambiguous-16.stderr @@ -1,4 +1,4 @@ -error: `ConfirmedTranscriptHashInput` is ambiguous +error[E0659]: `ConfirmedTranscriptHashInput` is ambiguous --> $DIR/ambiguous-16.rs:22:21 | LL | use crate::framing::ConfirmedTranscriptHashInput; @@ -17,33 +17,7 @@ note: `ConfirmedTranscriptHashInput` could also refer to the struct imported her LL | pub use self::public_message_in::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: consider adding an explicit import of `ConfirmedTranscriptHashInput` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error -Future incompatibility report: Future breakage diagnostic: -error: `ConfirmedTranscriptHashInput` is ambiguous - --> $DIR/ambiguous-16.rs:22:21 - | -LL | use crate::framing::ConfirmedTranscriptHashInput; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `ConfirmedTranscriptHashInput` could refer to the struct imported here - --> $DIR/ambiguous-16.rs:18:13 - | -LL | pub use self::public_message::*; - | ^^^^^^^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `ConfirmedTranscriptHashInput` to disambiguate -note: `ConfirmedTranscriptHashInput` could also refer to the struct imported here - --> $DIR/ambiguous-16.rs:19:13 - | -LL | pub use self::public_message_in::*; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `ConfirmedTranscriptHashInput` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-17.rs b/tests/ui/imports/ambiguous-17.rs index 3a51c156d34ca..5ba51ce714b75 100644 --- a/tests/ui/imports/ambiguous-17.rs +++ b/tests/ui/imports/ambiguous-17.rs @@ -25,5 +25,4 @@ mod handwritten { fn main() { id(); //~^ ERROR `id` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } diff --git a/tests/ui/imports/ambiguous-17.stderr b/tests/ui/imports/ambiguous-17.stderr index 80d152fe53440..b46a9430d2a7c 100644 --- a/tests/ui/imports/ambiguous-17.stderr +++ b/tests/ui/imports/ambiguous-17.stderr @@ -1,14 +1,4 @@ -warning: ambiguous glob re-exports - --> $DIR/ambiguous-17.rs:4:9 - | -LL | pub use evp::*; - | ^^^^^^ the name `id` in the value namespace is first re-exported here -LL | pub use handwritten::*; - | -------------- but the name `id` in the value namespace is also re-exported here - | - = note: `#[warn(ambiguous_glob_reexports)]` on by default - -error: `id` is ambiguous +error[E0659]: `id` is ambiguous --> $DIR/ambiguous-17.rs:26:5 | LL | id(); @@ -27,33 +17,17 @@ note: `id` could also refer to the function imported here LL | pub use handwritten::*; | ^^^^^^^^^^^^^^ = help: consider adding an explicit import of `id` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - -error: aborting due to 1 previous error; 1 warning emitted -Future incompatibility report: Future breakage diagnostic: -error: `id` is ambiguous - --> $DIR/ambiguous-17.rs:26:5 - | -LL | id(); - | ^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `id` could refer to the function imported here +warning: ambiguous glob re-exports --> $DIR/ambiguous-17.rs:4:9 | LL | pub use evp::*; - | ^^^^^^ - = help: consider adding an explicit import of `id` to disambiguate -note: `id` could also refer to the function imported here - --> $DIR/ambiguous-17.rs:5:9 - | + | ^^^^^^ the name `id` in the value namespace is first re-exported here LL | pub use handwritten::*; - | ^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `id` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default + | -------------- but the name `id` in the value namespace is also re-exported here + | + = note: `#[warn(ambiguous_glob_reexports)]` on by default + +error: aborting due to 1 previous error; 1 warning emitted +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-2.rs b/tests/ui/imports/ambiguous-2.rs deleted file mode 100644 index 65c971c00b9ac..0000000000000 --- a/tests/ui/imports/ambiguous-2.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ aux-build: ../ambiguous-1.rs -// https://github.com/rust-lang/rust/pull/113099#issuecomment-1633574396 - -extern crate ambiguous_1; - -fn main() { - ambiguous_1::id(); //~ ERROR `id` is ambiguous - //~| WARN this was previously accepted -} diff --git a/tests/ui/imports/ambiguous-2.stderr b/tests/ui/imports/ambiguous-2.stderr deleted file mode 100644 index a07f09c41475b..0000000000000 --- a/tests/ui/imports/ambiguous-2.stderr +++ /dev/null @@ -1,49 +0,0 @@ -error: `id` is ambiguous - --> $DIR/ambiguous-2.rs:7:18 - | -LL | ambiguous_1::id(); - | ^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `id` could refer to the function defined here - --> $DIR/auxiliary/../ambiguous-1.rs:13:13 - | -LL | pub use self::evp::*; - | ^^^^^^^^^ - = help: consider updating this dependency to resolve this error - = help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate -note: `id` could also refer to the function defined here - --> $DIR/auxiliary/../ambiguous-1.rs:15:13 - | -LL | pub use self::handwritten::*; - | ^^^^^^^^^^^^^^^^^ - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - -error: aborting due to 1 previous error - -Future incompatibility report: Future breakage diagnostic: -error: `id` is ambiguous - --> $DIR/ambiguous-2.rs:7:18 - | -LL | ambiguous_1::id(); - | ^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `id` could refer to the function defined here - --> $DIR/auxiliary/../ambiguous-1.rs:13:13 - | -LL | pub use self::evp::*; - | ^^^^^^^^^ - = help: consider updating this dependency to resolve this error - = help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate -note: `id` could also refer to the function defined here - --> $DIR/auxiliary/../ambiguous-1.rs:15:13 - | -LL | pub use self::handwritten::*; - | ^^^^^^^^^^^^^^^^^ - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - diff --git a/tests/ui/imports/ambiguous-3.rs b/tests/ui/imports/ambiguous-3.rs index ff0dcc221ec05..4919d9fbac63d 100644 --- a/tests/ui/imports/ambiguous-3.rs +++ b/tests/ui/imports/ambiguous-3.rs @@ -4,7 +4,6 @@ fn main() { use a::*; x(); //~^ ERROR `x` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } mod a { diff --git a/tests/ui/imports/ambiguous-3.stderr b/tests/ui/imports/ambiguous-3.stderr index 1e4aad83d985b..6c3031a9807aa 100644 --- a/tests/ui/imports/ambiguous-3.stderr +++ b/tests/ui/imports/ambiguous-3.stderr @@ -1,4 +1,4 @@ -error: `x` is ambiguous +error[E0659]: `x` is ambiguous --> $DIR/ambiguous-3.rs:5:5 | LL | x(); @@ -6,44 +6,18 @@ LL | x(); | = note: ambiguous because of multiple glob imports of a name in the same module note: `x` could refer to the function imported here - --> $DIR/ambiguous-3.rs:18:13 + --> $DIR/ambiguous-3.rs:17:13 | LL | pub use self::b::*; | ^^^^^^^^^^ = help: consider adding an explicit import of `x` to disambiguate note: `x` could also refer to the function imported here - --> $DIR/ambiguous-3.rs:19:13 + --> $DIR/ambiguous-3.rs:18:13 | LL | pub use self::c::*; | ^^^^^^^^^^ = help: consider adding an explicit import of `x` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error -Future incompatibility report: Future breakage diagnostic: -error: `x` is ambiguous - --> $DIR/ambiguous-3.rs:5:5 - | -LL | x(); - | ^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `x` could refer to the function imported here - --> $DIR/ambiguous-3.rs:18:13 - | -LL | pub use self::b::*; - | ^^^^^^^^^^ - = help: consider adding an explicit import of `x` to disambiguate -note: `x` could also refer to the function imported here - --> $DIR/ambiguous-3.rs:19:13 - | -LL | pub use self::c::*; - | ^^^^^^^^^^ - = help: consider adding an explicit import of `x` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-4-extern.rs b/tests/ui/imports/ambiguous-4-extern.rs index 125612dea03e5..a062b38df617e 100644 --- a/tests/ui/imports/ambiguous-4-extern.rs +++ b/tests/ui/imports/ambiguous-4-extern.rs @@ -1,9 +1,6 @@ //@ edition:2015 -//@ check-pass // https://github.com/rust-lang/rust/pull/112743#issuecomment-1601986883 -#![warn(ambiguous_glob_imports)] - macro_rules! m { () => { pub fn id() {} @@ -24,6 +21,5 @@ mod handwritten { fn main() { id(); - //~^ WARNING `id` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~^ ERROR `id` is ambiguous } diff --git a/tests/ui/imports/ambiguous-4-extern.stderr b/tests/ui/imports/ambiguous-4-extern.stderr index 4658071363e91..dae8432118f45 100644 --- a/tests/ui/imports/ambiguous-4-extern.stderr +++ b/tests/ui/imports/ambiguous-4-extern.stderr @@ -1,67 +1,33 @@ -warning: ambiguous glob re-exports - --> $DIR/ambiguous-4-extern.rs:13:9 - | -LL | pub use evp::*; - | ^^^^^^ the name `id` in the value namespace is first re-exported here -LL | pub use handwritten::*; - | -------------- but the name `id` in the value namespace is also re-exported here - | - = note: `#[warn(ambiguous_glob_reexports)]` on by default - -warning: `id` is ambiguous - --> $DIR/ambiguous-4-extern.rs:26:5 +error[E0659]: `id` is ambiguous + --> $DIR/ambiguous-4-extern.rs:23:5 | LL | id(); | ^^ ambiguous name | = note: ambiguous because of multiple glob imports of a name in the same module note: `id` could refer to the function imported here - --> $DIR/ambiguous-4-extern.rs:13:9 + --> $DIR/ambiguous-4-extern.rs:10:9 | LL | pub use evp::*; | ^^^^^^ = help: consider adding an explicit import of `id` to disambiguate note: `id` could also refer to the function imported here - --> $DIR/ambiguous-4-extern.rs:14:9 + --> $DIR/ambiguous-4-extern.rs:11:9 | LL | pub use handwritten::*; | ^^^^^^^^^^^^^^ = help: consider adding an explicit import of `id` to disambiguate - = 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 #114095 -note: the lint level is defined here - --> $DIR/ambiguous-4-extern.rs:5:9 - | -LL | #![warn(ambiguous_glob_imports)] - | ^^^^^^^^^^^^^^^^^^^^^^ - -warning: 2 warnings emitted -Future incompatibility report: Future breakage diagnostic: -warning: `id` is ambiguous - --> $DIR/ambiguous-4-extern.rs:26:5 - | -LL | id(); - | ^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `id` could refer to the function imported here - --> $DIR/ambiguous-4-extern.rs:13:9 +warning: ambiguous glob re-exports + --> $DIR/ambiguous-4-extern.rs:10:9 | LL | pub use evp::*; - | ^^^^^^ - = help: consider adding an explicit import of `id` to disambiguate -note: `id` could also refer to the function imported here - --> $DIR/ambiguous-4-extern.rs:14:9 - | + | ^^^^^^ the name `id` in the value namespace is first re-exported here LL | pub use handwritten::*; - | ^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `id` to disambiguate - = 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 #114095 -note: the lint level is defined here - --> $DIR/ambiguous-4-extern.rs:5:9 + | -------------- but the name `id` in the value namespace is also re-exported here | -LL | #![warn(ambiguous_glob_imports)] - | ^^^^^^^^^^^^^^^^^^^^^^ + = note: `#[warn(ambiguous_glob_reexports)]` on by default + +error: aborting due to 1 previous error; 1 warning emitted +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-4.rs b/tests/ui/imports/ambiguous-4.rs deleted file mode 100644 index e66d231f93cc3..0000000000000 --- a/tests/ui/imports/ambiguous-4.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ edition:2015 -//@ aux-build: ../ambiguous-4-extern.rs - -extern crate ambiguous_4_extern; - -fn main() { - ambiguous_4_extern::id(); //~ ERROR `id` is ambiguous - //~| WARN this was previously accepted -} diff --git a/tests/ui/imports/ambiguous-4.stderr b/tests/ui/imports/ambiguous-4.stderr deleted file mode 100644 index 0d207665ca776..0000000000000 --- a/tests/ui/imports/ambiguous-4.stderr +++ /dev/null @@ -1,49 +0,0 @@ -error: `id` is ambiguous - --> $DIR/ambiguous-4.rs:7:25 - | -LL | ambiguous_4_extern::id(); - | ^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `id` could refer to the function defined here - --> $DIR/auxiliary/../ambiguous-4-extern.rs:13:9 - | -LL | pub use evp::*; - | ^^^ - = help: consider updating this dependency to resolve this error - = help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate -note: `id` could also refer to the function defined here - --> $DIR/auxiliary/../ambiguous-4-extern.rs:14:9 - | -LL | pub use handwritten::*; - | ^^^^^^^^^^^ - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - -error: aborting due to 1 previous error - -Future incompatibility report: Future breakage diagnostic: -error: `id` is ambiguous - --> $DIR/ambiguous-4.rs:7:25 - | -LL | ambiguous_4_extern::id(); - | ^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `id` could refer to the function defined here - --> $DIR/auxiliary/../ambiguous-4-extern.rs:13:9 - | -LL | pub use evp::*; - | ^^^ - = help: consider updating this dependency to resolve this error - = help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate -note: `id` could also refer to the function defined here - --> $DIR/auxiliary/../ambiguous-4-extern.rs:14:9 - | -LL | pub use handwritten::*; - | ^^^^^^^^^^^ - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - diff --git a/tests/ui/imports/ambiguous-5.rs b/tests/ui/imports/ambiguous-5.rs index 8f89c966d4a5d..a88dbf46ddab9 100644 --- a/tests/ui/imports/ambiguous-5.rs +++ b/tests/ui/imports/ambiguous-5.rs @@ -11,7 +11,6 @@ mod gpos { use super::*; struct MarkRecord(Class); //~^ ERROR`Class` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } mod gsubgpos { diff --git a/tests/ui/imports/ambiguous-5.stderr b/tests/ui/imports/ambiguous-5.stderr index 8cc37c65c4c4d..e2dfe4d2dea85 100644 --- a/tests/ui/imports/ambiguous-5.stderr +++ b/tests/ui/imports/ambiguous-5.stderr @@ -1,4 +1,4 @@ -error: `Class` is ambiguous +error[E0659]: `Class` is ambiguous --> $DIR/ambiguous-5.rs:12:23 | LL | struct MarkRecord(Class); @@ -17,33 +17,7 @@ note: `Class` could also refer to the struct imported here LL | use super::gsubgpos::*; | ^^^^^^^^^^^^^^^^^^ = help: consider adding an explicit import of `Class` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error -Future incompatibility report: Future breakage diagnostic: -error: `Class` is ambiguous - --> $DIR/ambiguous-5.rs:12:23 - | -LL | struct MarkRecord(Class); - | ^^^^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `Class` could refer to the struct imported here - --> $DIR/ambiguous-5.rs:11:9 - | -LL | use super::*; - | ^^^^^^^^ - = help: consider adding an explicit import of `Class` to disambiguate -note: `Class` could also refer to the struct imported here - --> $DIR/ambiguous-5.rs:10:9 - | -LL | use super::gsubgpos::*; - | ^^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `Class` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-6.rs b/tests/ui/imports/ambiguous-6.rs index 1c6e34377165a..71667a8f3bb80 100644 --- a/tests/ui/imports/ambiguous-6.rs +++ b/tests/ui/imports/ambiguous-6.rs @@ -5,7 +5,6 @@ pub fn foo() -> u32 { use sub::*; C //~^ ERROR `C` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } mod sub { diff --git a/tests/ui/imports/ambiguous-6.stderr b/tests/ui/imports/ambiguous-6.stderr index ea5b2d2f19b80..f1a4fb694c9a0 100644 --- a/tests/ui/imports/ambiguous-6.stderr +++ b/tests/ui/imports/ambiguous-6.stderr @@ -1,4 +1,4 @@ -error: `C` is ambiguous +error[E0659]: `C` is ambiguous --> $DIR/ambiguous-6.rs:6:5 | LL | C @@ -6,44 +6,18 @@ LL | C | = note: ambiguous because of multiple glob imports of a name in the same module note: `C` could refer to the constant imported here - --> $DIR/ambiguous-6.rs:15:13 + --> $DIR/ambiguous-6.rs:14:13 | LL | pub use mod1::*; | ^^^^^^^ = help: consider adding an explicit import of `C` to disambiguate note: `C` could also refer to the constant imported here - --> $DIR/ambiguous-6.rs:16:13 + --> $DIR/ambiguous-6.rs:15:13 | LL | pub use mod2::*; | ^^^^^^^ = help: consider adding an explicit import of `C` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error -Future incompatibility report: Future breakage diagnostic: -error: `C` is ambiguous - --> $DIR/ambiguous-6.rs:6:5 - | -LL | C - | ^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `C` could refer to the constant imported here - --> $DIR/ambiguous-6.rs:15:13 - | -LL | pub use mod1::*; - | ^^^^^^^ - = help: consider adding an explicit import of `C` to disambiguate -note: `C` could also refer to the constant imported here - --> $DIR/ambiguous-6.rs:16:13 - | -LL | pub use mod2::*; - | ^^^^^^^ - = help: consider adding an explicit import of `C` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-9.rs b/tests/ui/imports/ambiguous-9.rs index c10b1268060ce..58796031bf18f 100644 --- a/tests/ui/imports/ambiguous-9.rs +++ b/tests/ui/imports/ambiguous-9.rs @@ -22,7 +22,5 @@ use prelude::*; fn main() { date_range(); //~^ ERROR `date_range` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! //~| ERROR `date_range` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } diff --git a/tests/ui/imports/ambiguous-9.stderr b/tests/ui/imports/ambiguous-9.stderr index bbbce638a44dc..b6e4c30a8d410 100644 --- a/tests/ui/imports/ambiguous-9.stderr +++ b/tests/ui/imports/ambiguous-9.stderr @@ -1,45 +1,4 @@ -warning: ambiguous glob re-exports - --> $DIR/ambiguous-9.rs:7:13 - | -LL | pub use self::range::*; - | ^^^^^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here -LL | use super::prelude::*; - | ----------------- but the name `date_range` in the value namespace is also re-exported here - | - = note: `#[warn(ambiguous_glob_reexports)]` on by default - -error: `date_range` is ambiguous - --> $DIR/ambiguous-9.rs:23:5 - | -LL | date_range(); - | ^^^^^^^^^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `date_range` could refer to the function imported here - --> $DIR/ambiguous-9.rs:7:13 - | -LL | pub use self::range::*; - | ^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `date_range` to disambiguate -note: `date_range` could also refer to the function imported here - --> $DIR/ambiguous-9.rs:8:9 - | -LL | use super::prelude::*; - | ^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `date_range` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - -warning: ambiguous glob re-exports - --> $DIR/ambiguous-9.rs:15:13 - | -LL | pub use self::t::*; - | ^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here -LL | pub use super::dsl::*; - | ------------- but the name `date_range` in the value namespace is also re-exported here - -error: `date_range` is ambiguous +error[E0659]: `date_range` is ambiguous --> $DIR/ambiguous-9.rs:23:5 | LL | date_range(); @@ -58,13 +17,8 @@ note: `date_range` could also refer to the function imported here LL | use prelude::*; | ^^^^^^^^^^ = help: consider adding an explicit import of `date_range` to disambiguate - = 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 #114095 -error: aborting due to 2 previous errors; 2 warnings emitted - -Future incompatibility report: Future breakage diagnostic: -error: `date_range` is ambiguous +error[E0659]: `date_range` is ambiguous --> $DIR/ambiguous-9.rs:23:5 | LL | date_range(); @@ -83,31 +37,25 @@ note: `date_range` could also refer to the function imported here LL | use super::prelude::*; | ^^^^^^^^^^^^^^^^^ = help: consider adding an explicit import of `date_range` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default -Future breakage diagnostic: -error: `date_range` is ambiguous - --> $DIR/ambiguous-9.rs:23:5 - | -LL | date_range(); - | ^^^^^^^^^^ ambiguous name +warning: ambiguous glob re-exports + --> $DIR/ambiguous-9.rs:7:13 | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `date_range` could refer to the function imported here - --> $DIR/ambiguous-9.rs:19:5 +LL | pub use self::range::*; + | ^^^^^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here +LL | use super::prelude::*; + | ----------------- but the name `date_range` in the value namespace is also re-exported here | -LL | use dsl::*; - | ^^^^^^ - = help: consider adding an explicit import of `date_range` to disambiguate -note: `date_range` could also refer to the function imported here - --> $DIR/ambiguous-9.rs:20:5 + = note: `#[warn(ambiguous_glob_reexports)]` on by default + +warning: ambiguous glob re-exports + --> $DIR/ambiguous-9.rs:15:13 | -LL | use prelude::*; - | ^^^^^^^^^^ - = help: consider adding an explicit import of `date_range` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default +LL | pub use self::t::*; + | ^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here +LL | pub use super::dsl::*; + | ------------- but the name `date_range` in the value namespace is also re-exported here + +error: aborting due to 2 previous errors; 2 warnings emitted +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-panic-globvsglob.rs b/tests/ui/imports/ambiguous-panic-globvsglob.rs index 4ff3cc8225355..4b35d6014b06b 100644 --- a/tests/ui/imports/ambiguous-panic-globvsglob.rs +++ b/tests/ui/imports/ambiguous-panic-globvsglob.rs @@ -18,6 +18,5 @@ fn foo() { panic!(); //~^ WARN: `panic` is ambiguous [ambiguous_panic_imports] //~| WARN: this was previously accepted by the compiler - //~| ERROR: `panic` is ambiguous [ambiguous_glob_imports] - //~| WARN: this was previously accepted by the compiler + //~| ERROR: `panic` is ambiguous } diff --git a/tests/ui/imports/ambiguous-panic-globvsglob.stderr b/tests/ui/imports/ambiguous-panic-globvsglob.stderr index 981c9b05b9eb4..8fd785277533c 100644 --- a/tests/ui/imports/ambiguous-panic-globvsglob.stderr +++ b/tests/ui/imports/ambiguous-panic-globvsglob.stderr @@ -1,4 +1,4 @@ -error: `panic` is ambiguous +error[E0659]: `panic` is ambiguous --> $DIR/ambiguous-panic-globvsglob.rs:18:5 | LL | panic!(); @@ -17,9 +17,6 @@ note: `panic` could also refer to the macro imported here LL | use m2::*; | ^^^^^ = help: consider adding an explicit import of `panic` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default warning: `panic` is ambiguous --> $DIR/ambiguous-panic-globvsglob.rs:18:5 @@ -42,27 +39,4 @@ note: `panic` could also refer to a macro from prelude error: aborting due to 1 previous error; 1 warning emitted -Future incompatibility report: Future breakage diagnostic: -error: `panic` is ambiguous - --> $DIR/ambiguous-panic-globvsglob.rs:18:5 - | -LL | panic!(); - | ^^^^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `panic` could refer to the macro imported here - --> $DIR/ambiguous-panic-globvsglob.rs:12:9 - | -LL | use m1::*; - | ^^^^^ - = help: consider adding an explicit import of `panic` to disambiguate -note: `panic` could also refer to the macro imported here - --> $DIR/ambiguous-panic-globvsglob.rs:13:9 - | -LL | use m2::*; - | ^^^^^ - = help: consider adding an explicit import of `panic` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/glob-conflict-cross-crate-3.rs b/tests/ui/imports/glob-conflict-cross-crate-3.rs index 31c234b9250fc..74415cfd9bb36 100644 --- a/tests/ui/imports/glob-conflict-cross-crate-3.rs +++ b/tests/ui/imports/glob-conflict-cross-crate-3.rs @@ -14,5 +14,4 @@ fn main() { //~^ ERROR `C` is ambiguous //~| ERROR `C` is ambiguous //~| WARN this was previously accepted - //~| WARN this was previously accepted } diff --git a/tests/ui/imports/glob-conflict-cross-crate-3.stderr b/tests/ui/imports/glob-conflict-cross-crate-3.stderr index 8a9ece94deeb1..50a9adc097e47 100644 --- a/tests/ui/imports/glob-conflict-cross-crate-3.stderr +++ b/tests/ui/imports/glob-conflict-cross-crate-3.stderr @@ -1,27 +1,4 @@ -error: `C` is ambiguous - --> $DIR/glob-conflict-cross-crate-3.rs:13:13 - | -LL | let _a: C = 1; - | ^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `C` could refer to the type alias defined here - --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:9:9 - | -LL | pub use a::*; - | ^ - = help: consider updating this dependency to resolve this error - = help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate -note: `C` could also refer to the type alias defined here - --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:10:9 - | -LL | pub use b::*; - | ^ - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - -error: `C` is ambiguous +error[E0659]: `C` is ambiguous --> $DIR/glob-conflict-cross-crate-3.rs:13:13 | LL | let _a: C = 1; @@ -40,12 +17,7 @@ note: `C` could also refer to the type alias imported here LL | use a::*; | ^^^^ = help: consider adding an explicit import of `C` to disambiguate - = 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 #114095 -error: aborting due to 2 previous errors - -Future incompatibility report: Future breakage diagnostic: error: `C` is ambiguous --> $DIR/glob-conflict-cross-crate-3.rs:13:13 | @@ -69,7 +41,10 @@ LL | pub use b::*; = note: for more information, see issue #114095 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default -Future breakage diagnostic: +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0659`. +Future incompatibility report: Future breakage diagnostic: error: `C` is ambiguous --> $DIR/glob-conflict-cross-crate-3.rs:13:13 | @@ -77,18 +52,18 @@ LL | let _a: C = 1; | ^ ambiguous name | = note: ambiguous because of multiple glob imports of a name in the same module -note: `C` could refer to the type alias imported here - --> $DIR/glob-conflict-cross-crate-3.rs:9:5 +note: `C` could refer to the type alias defined here + --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:9:9 | -LL | use glob_conflict_cross_crate_2_extern::*; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `C` to disambiguate -note: `C` could also refer to the type alias imported here - --> $DIR/glob-conflict-cross-crate-3.rs:10:5 +LL | pub use a::*; + | ^ + = help: consider updating this dependency to resolve this error + = help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate +note: `C` could also refer to the type alias defined here + --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:10:9 | -LL | use a::*; - | ^^^^ - = help: consider adding an explicit import of `C` to disambiguate +LL | pub use b::*; + | ^ = 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 #114095 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default diff --git a/tests/ui/imports/unresolved-seg-after-ambiguous.rs b/tests/ui/imports/unresolved-seg-after-ambiguous.rs index 67366deabaafb..00a3c5b0145c2 100644 --- a/tests/ui/imports/unresolved-seg-after-ambiguous.rs +++ b/tests/ui/imports/unresolved-seg-after-ambiguous.rs @@ -17,8 +17,6 @@ mod a { } use self::a::E::in_exist; -//~^ ERROR: unresolved import `self::a::E` -//~| ERROR: `E` is ambiguous -//~| WARNING: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +//~^ ERROR: `E` is ambiguous fn main() {} diff --git a/tests/ui/imports/unresolved-seg-after-ambiguous.stderr b/tests/ui/imports/unresolved-seg-after-ambiguous.stderr index c21faffadfc31..e712d80f69460 100644 --- a/tests/ui/imports/unresolved-seg-after-ambiguous.stderr +++ b/tests/ui/imports/unresolved-seg-after-ambiguous.stderr @@ -1,10 +1,4 @@ -error[E0432]: unresolved import `self::a::E` - --> $DIR/unresolved-seg-after-ambiguous.rs:19:14 - | -LL | use self::a::E::in_exist; - | ^ `E` is a struct, not a module - -error: `E` is ambiguous +error[E0659]: `E` is ambiguous --> $DIR/unresolved-seg-after-ambiguous.rs:19:14 | LL | use self::a::E::in_exist; @@ -23,34 +17,7 @@ note: `E` could also refer to the struct imported here LL | pub use self::d::*; | ^^^^^^^^^^ = help: consider adding an explicit import of `E` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - -error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0432`. -Future incompatibility report: Future breakage diagnostic: -error: `E` is ambiguous - --> $DIR/unresolved-seg-after-ambiguous.rs:19:14 - | -LL | use self::a::E::in_exist; - | ^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `E` could refer to the struct imported here - --> $DIR/unresolved-seg-after-ambiguous.rs:13:17 - | -LL | pub use self::c::*; - | ^^^^^^^^^^ - = help: consider adding an explicit import of `E` to disambiguate -note: `E` could also refer to the struct imported here - --> $DIR/unresolved-seg-after-ambiguous.rs:12:17 - | -LL | pub use self::d::*; - | ^^^^^^^^^^ - = help: consider adding an explicit import of `E` to disambiguate - = 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 #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default +error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0659`.