authorbors <bors@rust-lang.org> 2026-05-30 03:49:29 UTC
committerbors <bors@rust-lang.org> 2026-05-30 03:49:29 UTC
log6eda7419e71fdbc1185ed5be7e6bff1a474ab5cd
tree51bc79b6fb3c3694555cd2b2eb52fb60ad17b13d
parent6368fd52cb9f230dfb156097625993e7a8891800
parent82471b6b2ab22cdbc896232076b40cc6907da571

Auto merge of #157121 - JonathanBrouwer:rollup-htRw3jp, r=JonathanBrouwer

Rollup of 16 pull requests Successful merges: - rust-lang/rust#149195 (resolve: Partially convert `ambiguous_glob_imports` lint into a hard error) - rust-lang/rust#156960 (Some cleanups around passing extra lifetime params from the resolver to ast lowering) - rust-lang/rust#156963 (definitions: remove `DefPathTable`, use `LocalDefId` instead of `DefIndex`) - rust-lang/rust#157053 (Eagerly resolve delegations in late resolution) - rust-lang/rust#157068 (NVPTX: Remove the unstable ptx linker flavor) - rust-lang/rust#157076 (Various proc-macro related code cleanups) - rust-lang/rust#157106 (add ABI check logic for wasm) - rust-lang/rust#154835 (std::offload sharedmem) - rust-lang/rust#157065 (Stabilize `Path::is_empty`) - rust-lang/rust#157088 (Improve suggestions for malformed deprecated attribute) - rust-lang/rust#157098 (Add the `clflushopt` x86 target feature) - rust-lang/rust#157103 (Add reproducibly failing tests for parallel frontend) - rust-lang/rust#157111 (Update target maintainer for x86_64-unknown-linux-none) - rust-lang/rust#157116 (rustc_public: add `with_cx()` to `CompilerInterface`) - rust-lang/rust#157119 (ast_lowering: Simplify `resolve_pin_drop_sugar_impl_item`) - rust-lang/rust#157120 (Cleanups around attribute target checking) Failed merges: - rust-lang/rust#157100 (Some more per owner things)

120 files changed, 1335 insertions(+), 2034 deletions(-)

compiler/rustc_ast_lowering/src/delegation.rs+6-16
......@@ -124,7 +124,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
124124 // Delegation can be unresolved in illegal places such as function bodies in extern blocks (see #151356)
125125 let sig_id = if let Some(delegation_info) = self.resolver.delegation_info(self.owner.def_id)
126126 {
127 self.get_sig_id(delegation_info.resolution_node, span)
127 self.get_sig_id(delegation_info.resolution_id, span)
128128 } else {
129129 self.dcx().span_delayed_bug(
130130 span,
......@@ -230,22 +230,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
230230 .collect::<Vec<_>>()
231231 }
232232
233 fn get_sig_id(&self, mut node_id: NodeId, span: Span) -> Result<DefId, ErrorGuaranteed> {
234 let mut visited: FxHashSet<NodeId> = Default::default();
233 fn get_sig_id(&self, mut def_id: DefId, span: Span) -> Result<DefId, ErrorGuaranteed> {
234 let mut visited: FxHashSet<DefId> = Default::default();
235235 let mut path: SmallVec<[DefId; 1]> = Default::default();
236236
237237 loop {
238 visited.insert(node_id);
239
240 let Some(def_id) = self.get_resolution_id(node_id) else {
241 return Err(self.tcx.dcx().span_delayed_bug(
242 span,
243 format!(
244 "LoweringContext: couldn't resolve node {:?} in delegation item",
245 node_id
246 ),
247 ));
248 };
238 visited.insert(def_id);
249239
250240 path.push(def_id);
251241
......@@ -255,8 +245,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
255245 if let Some(local_id) = def_id.as_local()
256246 && let Some(delegation_info) = self.resolver.delegation_info(local_id)
257247 {
258 node_id = delegation_info.resolution_node;
259 if visited.contains(&node_id) {
248 def_id = delegation_info.resolution_id;
249 if visited.contains(&def_id) {
260250 // We encountered a cycle in the resolution, or delegation callee refers to non-existent
261251 // entity, in this case emit an error.
262252 return Err(match visited.len() {
compiler/rustc_ast_lowering/src/item.rs+33-43
......@@ -1192,50 +1192,34 @@ impl<'hir> LoweringContext<'_, 'hir> {
11921192 })
11931193 }
11941194
1195 fn resolve_pin_drop_sugar_impl_item(
1195 fn check_pin_drop_sugar_impl_item(
11961196 &self,
11971197 i: &AssocItem,
11981198 ident: Ident,
1199 span: Span,
1200 ) -> (Ident, Result<DefId, ErrorGuaranteed>) {
1201 let trait_item_def_id = self
1202 .get_partial_res(i.id)
1203 .and_then(|r| r.expect_full_res().opt_def_id())
1204 .ok_or_else(|| {
1205 self.dcx().span_delayed_bug(span, "could not resolve trait item being implemented")
1206 });
1207
1208 let is_pin_drop_sugar = match &i.kind {
1209 AssocItemKind::Fn(fn_kind) => fn_kind.is_pin_drop_sugar(),
1210 _ => false,
1211 };
1212 let def_id = match trait_item_def_id {
1213 Ok(def_id) => def_id,
1214 Err(guar) => return (ident, Err(guar)),
1215 };
1216 if !is_pin_drop_sugar {
1217 return (ident, Ok(def_id));
1218 }
1219
1220 let is_drop_pin_drop = self
1221 .tcx
1222 .lang_items()
1223 .drop_trait()
1224 .is_some_and(|drop_trait| self.tcx.parent(def_id) == drop_trait);
1225 if is_drop_pin_drop {
1226 // Associated item collection still derives the impl item's name from HIR.
1227 return (Ident::new(sym::pin_drop, ident.span), Ok(def_id));
1199 trait_item: Result<DefId, ErrorGuaranteed>,
1200 ) -> Ident {
1201 if let AssocItemKind::Fn(fn_kind) = &i.kind
1202 && fn_kind.is_pin_drop_sugar()
1203 {
1204 if let Ok(trait_item) = trait_item
1205 && self
1206 .tcx
1207 .lang_items()
1208 .drop_trait()
1209 .is_none_or(|drop_trait| self.tcx.parent(trait_item) != drop_trait)
1210 {
1211 self.dcx()
1212 .struct_span_err(
1213 i.span,
1214 "method `drop` with `&pin mut self` is only supported for the `Drop` trait",
1215 )
1216 .with_span_label(i.span, "not a `Drop::pin_drop` implementation")
1217 .emit();
1218 }
1219 return Ident::new(sym::pin_drop, ident.span);
12281220 }
12291221
1230 let guar = self
1231 .dcx()
1232 .struct_span_err(
1233 i.span,
1234 "method `drop` with `&pin mut self` is only supported for the `Drop` trait",
1235 )
1236 .with_span_label(i.span, "not a `Drop::pin_drop` implementation")
1237 .emit();
1238 (ident, Err(guar))
1222 ident
12391223 }
12401224
12411225 fn lower_impl_item(
......@@ -1356,8 +1340,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
13561340
13571341 let span = self.lower_span(i.span);
13581342 let (effective_ident, impl_kind) = if is_in_trait_impl {
1359 let (effective_ident, trait_item_def_id) =
1360 self.resolve_pin_drop_sugar_impl_item(i, ident, span);
1343 let trait_item_def_id = self
1344 .get_partial_res(i.id)
1345 .and_then(|r| r.expect_full_res().opt_def_id())
1346 .ok_or_else(|| {
1347 self.dcx()
1348 .span_delayed_bug(span, "could not resolve trait item being implemented")
1349 });
1350 let effective_ident = self.check_pin_drop_sugar_impl_item(i, ident, trait_item_def_id);
13611351 (effective_ident, ImplItemImplKind::Trait { defaultness, trait_item_def_id })
13621352 } else {
13631353 (ident, ImplItemImplKind::Inherent { vis_span: self.lower_span(i.vis.span) })
......@@ -1928,11 +1918,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
19281918
19291919 // Introduce extra lifetimes if late resolution tells us to.
19301920 let extra_lifetimes = self.resolver.extra_lifetime_params(parent_node_id);
1931 params.extend(extra_lifetimes.into_iter().filter_map(|&(ident, node_id, res)| {
1921 params.extend(extra_lifetimes.into_iter().map(|&(ident, node_id, kind)| {
19321922 self.lifetime_res_to_generic_param(
19331923 ident,
19341924 node_id,
1935 res,
1925 kind,
19361926 hir::GenericParamSource::Generics,
19371927 )
19381928 }));
compiler/rustc_ast_lowering/src/lib.rs+18-31
......@@ -55,7 +55,7 @@ use rustc_hir::definitions::PerParentDisambiguatorState;
5555use rustc_hir::lints::DelayedLint;
5656use rustc_hir::{
5757 self as hir, AngleBrackets, ConstArg, GenericArg, HirId, ItemLocalMap, LifetimeSource,
58 LifetimeSyntax, ParamName, Target, TraitCandidate, find_attr,
58 LifetimeSyntax, MissingLifetimeKind, ParamName, Target, TraitCandidate, find_attr,
5959};
6060use rustc_index::{Idx, IndexSlice, IndexVec};
6161use rustc_macros::extension;
......@@ -310,7 +310,7 @@ impl<'tcx> ResolverAstLowering<'tcx> {
310310 ///
311311 /// The extra lifetimes that appear from the parenthesized `Fn`-trait desugaring
312312 /// should appear at the enclosing `PolyTraitRef`.
313 fn extra_lifetime_params(&self, id: NodeId) -> &[(Ident, NodeId, LifetimeRes)] {
313 fn extra_lifetime_params(&self, id: NodeId) -> &[(Ident, NodeId, MissingLifetimeKind)] {
314314 self.extra_lifetime_params_map.get(&id).map_or(&[], |v| &v[..])
315315 }
316316
......@@ -542,7 +542,7 @@ pub fn lower_to_hir(tcx: TyCtxt<'_>, (): ()) -> mid_hir::Crate<'_> {
542542 let ast_index = index_crate(&resolver, &krate);
543543 let mut owners = IndexVec::from_fn_n(
544544 |_| hir::MaybeOwner::Phantom,
545 tcx.definitions_untracked().def_index_count(),
545 tcx.definitions_untracked().num_definitions(),
546546 );
547547
548548 let mut lowerer = item::ItemLowerer {
......@@ -948,43 +948,30 @@ impl<'hir> LoweringContext<'_, 'hir> {
948948 &mut self,
949949 ident: Ident,
950950 node_id: NodeId,
951 res: LifetimeRes,
951 kind: MissingLifetimeKind,
952952 source: hir::GenericParamSource,
953 ) -> Option<hir::GenericParam<'hir>> {
954 let (name, kind) = match res {
955 LifetimeRes::Param { .. } => {
956 (hir::ParamName::Plain(ident), hir::LifetimeParamKind::Explicit)
957 }
958 LifetimeRes::Fresh { param, kind, .. } => {
959 // Late resolution delegates to us the creation of the `LocalDefId`.
960 let _def_id = self.create_def(
961 param,
962 Some(kw::UnderscoreLifetime),
963 DefKind::LifetimeParam,
964 ident.span,
965 );
966 debug!(?_def_id);
953 ) -> hir::GenericParam<'hir> {
954 // Late resolution delegates to us the creation of the `LocalDefId`.
955 let _def_id = self.create_def(
956 node_id,
957 Some(kw::UnderscoreLifetime),
958 DefKind::LifetimeParam,
959 ident.span,
960 );
961 debug!(?_def_id);
967962
968 (hir::ParamName::Fresh, hir::LifetimeParamKind::Elided(kind))
969 }
970 LifetimeRes::Static { .. } | LifetimeRes::Error(..) => return None,
971 res => panic!(
972 "Unexpected lifetime resolution {:?} for {:?} at {:?}",
973 res, ident, ident.span
974 ),
975 };
976963 let hir_id = self.lower_node_id(node_id);
977964 let def_id = self.local_def_id(node_id);
978 Some(hir::GenericParam {
965 hir::GenericParam {
979966 hir_id,
980967 def_id,
981 name,
968 name: hir::ParamName::Fresh,
982969 span: self.lower_span(ident.span),
983970 pure_wrt_drop: false,
984 kind: hir::GenericParamKind::Lifetime { kind },
971 kind: hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Elided(kind) },
985972 colon_span: None,
986973 source,
987 })
974 }
988975 }
989976
990977 /// Lowers a lifetime binder that defines `generic_params`, returning the corresponding HIR
......@@ -1005,7 +992,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1005992 debug!(?extra_lifetimes);
1006993 let extra_lifetimes: Vec<_> = extra_lifetimes
1007994 .iter()
1008 .filter_map(|&(ident, node_id, res)| {
995 .map(|&(ident, node_id, res)| {
1009996 self.lifetime_res_to_generic_param(
1010997 ident,
1011998 node_id,
compiler/rustc_attr_parsing/src/attributes/deprecation.rs+50-10
......@@ -1,3 +1,4 @@
1use rustc_ast::LitKind;
12use rustc_hir::attrs::{DeprecatedSince, Deprecation};
23use rustc_hir::{RustcVersion, VERSION_PLACEHOLDER};
34
......@@ -76,6 +77,38 @@ impl SingleAttributeParser for DeprecatedParser {
7677 // ok
7778 }
7879 ArgParser::List(list) => {
80 // If the argument list contains a single string literal:
81 // check whether it may be a version and suggest since field
82 // otherwise, suggest using NameValue syntax
83 if let Some(elem) = list.as_single()
84 && let Some(lit) = elem.as_lit()
85 && let LitKind::Str(text, _) = lit.kind
86 {
87 let mut adcx = cx.adcx();
88
89 match parse_since(text, true) {
90 DeprecatedSince::Future | DeprecatedSince::RustcVersion(_) => {
91 adcx.push_suggestion(
92 String::from("try specifying a deprecated since version"),
93 elem.span(),
94 format!("since = {}", lit.kind),
95 );
96 }
97 _ => {
98 if let Some(span) = args.span() {
99 adcx.push_suggestion(
100 String::from("try using `=` instead"),
101 span,
102 format!(" = {}", lit.kind),
103 );
104 }
105 }
106 };
107
108 adcx.expected_not_literal(elem.span());
109 return None;
110 }
111
79112 for param in list.mixed() {
80113 let Some(param) = param.meta_item() else {
81114 cx.adcx().expected_not_literal(param.span());
......@@ -133,18 +166,11 @@ impl SingleAttributeParser for DeprecatedParser {
133166 }
134167
135168 let since = if let Some(since) = since {
136 if since.as_str() == "TBD" {
137 DeprecatedSince::Future
138 } else if !is_rustc {
139 DeprecatedSince::NonStandard(since)
140 } else if since.as_str() == VERSION_PLACEHOLDER {
141 DeprecatedSince::RustcVersion(RustcVersion::CURRENT)
142 } else if let Some(version) = parse_version(since) {
143 DeprecatedSince::RustcVersion(version)
144 } else {
169 let since = parse_since(since, is_rustc);
170 if matches!(since, DeprecatedSince::Err) {
145171 cx.emit_err(InvalidSince { span: cx.attr_span });
146 DeprecatedSince::Err
147172 }
173 since
148174 } else if is_rustc {
149175 cx.emit_err(MissingSince { span: cx.attr_span });
150176 DeprecatedSince::Err
......@@ -163,3 +189,17 @@ impl SingleAttributeParser for DeprecatedParser {
163189 })
164190 }
165191}
192
193fn parse_since(since: Symbol, is_rustc: bool) -> DeprecatedSince {
194 if since.as_str() == "TBD" {
195 DeprecatedSince::Future
196 } else if !is_rustc {
197 DeprecatedSince::NonStandard(since)
198 } else if since.as_str() == VERSION_PLACEHOLDER {
199 DeprecatedSince::RustcVersion(RustcVersion::CURRENT)
200 } else if let Some(version) = parse_version(since) {
201 DeprecatedSince::RustcVersion(version)
202 } else {
203 DeprecatedSince::Err
204 }
205}
compiler/rustc_attr_parsing/src/interface.rs+1-3
......@@ -412,9 +412,7 @@ impl<'sess> AttributeParser<'sess> {
412412 (accept.accept_fn)(&mut cx, &args);
413413 finalizers.push(accept.finalizer);
414414
415 if !matches!(cx.should_emit, ShouldEmit::Nothing) {
416 Self::check_target(&accept.allowed_targets, target, &mut cx);
417 }
415 Self::check_target(&accept.allowed_targets, &mut cx);
418416 } else {
419417 let attr = AttrItem {
420418 path: attr_path.clone(),
compiler/rustc_attr_parsing/src/target_checking.rs+18-11
......@@ -7,7 +7,6 @@ use rustc_hir::attrs::AttributeKind;
77use rustc_hir::{AttrItem, Attribute, MethodKind, Target};
88use rustc_span::{BytePos, FileName, RemapPathScopeComponents, Span, Symbol, sym};
99
10use crate::AttributeParser;
1110use crate::context::AcceptContext;
1211use crate::errors::{
1312 InvalidAttrAtCrateLevel, InvalidTargetLint, ItemFollowingInnerAttr,
......@@ -15,6 +14,7 @@ use crate::errors::{
1514};
1615use crate::session_diagnostics::InvalidTarget;
1716use crate::target_checking::Policy::Allow;
17use crate::{AttributeParser, ShouldEmit};
1818
1919#[derive(Debug)]
2020pub(crate) enum AllowedTargets {
......@@ -90,17 +90,20 @@ pub(crate) enum Policy {
9090impl<'sess> AttributeParser<'sess> {
9191 pub(crate) fn check_target(
9292 allowed_targets: &AllowedTargets,
93 target: Target,
9493 cx: &mut AcceptContext<'_, 'sess>,
9594 ) {
95 if matches!(cx.should_emit, ShouldEmit::Nothing) {
96 return;
97 }
98
9699 // For crate-level attributes we emit a specific set of lints to warn
97100 // people about accidentally not using them on the crate.
98101 if let &AllowedTargets::AllowList(&[Allow(Target::Crate)]) = allowed_targets {
99 Self::check_crate_level(target, cx);
102 Self::check_crate_level(cx);
100103 return;
101104 }
102105
103 if matches!(cx.attr_path.segments.as_ref(), [sym::repr]) && target == Target::Crate {
106 if matches!(cx.attr_path.segments.as_ref(), [sym::repr]) && cx.target == Target::Crate {
104107 // The allowed targets of `repr` depend on its arguments. They can't be checked using
105108 // the `AttributeParser` code.
106109 let span = cx.attr_span;
......@@ -119,11 +122,12 @@ impl<'sess> AttributeParser<'sess> {
119122 .emit();
120123 }
121124
122 match allowed_targets.is_allowed(target) {
125 match allowed_targets.is_allowed(cx.target) {
123126 AllowedResult::Allowed => {}
124127 AllowedResult::Warn => {
125128 let allowed_targets = allowed_targets.allowed_targets();
126 let (applied, only) = allowed_targets_applied(allowed_targets, target, cx.features);
129 let (applied, only) =
130 allowed_targets_applied(allowed_targets, cx.target, cx.features);
127131 let name = cx.attr_path.clone();
128132
129133 let lint = if name.segments[0] == sym::deprecated
......@@ -134,7 +138,7 @@ impl<'sess> AttributeParser<'sess> {
134138 Target::Arm,
135139 Target::MacroCall,
136140 ]
137 .contains(&target)
141 .contains(&cx.target)
138142 {
139143 rustc_session::lint::builtin::USELESS_DEPRECATED
140144 } else {
......@@ -142,6 +146,7 @@ impl<'sess> AttributeParser<'sess> {
142146 };
143147
144148 let attr_span = cx.attr_span;
149 let target = cx.target;
145150 cx.emit_lint_with_sess(
146151 lint,
147152 move |dcx, level, _| {
......@@ -161,12 +166,13 @@ impl<'sess> AttributeParser<'sess> {
161166 }
162167 AllowedResult::Error => {
163168 let allowed_targets = allowed_targets.allowed_targets();
164 let (applied, only) = allowed_targets_applied(allowed_targets, target, cx.features);
169 let (applied, only) =
170 allowed_targets_applied(allowed_targets, cx.target, cx.features);
165171 let name = cx.attr_path.clone();
166172 cx.dcx().emit_err(InvalidTarget {
167173 span: cx.attr_span.clone(),
168174 name,
169 target: target.plural_name(),
175 target: cx.target.plural_name(),
170176 only: if only { "only " } else { "" },
171177 applied: DiagArgValue::StrListSepByAnd(
172178 applied.into_iter().map(Cow::Owned).collect(),
......@@ -176,8 +182,8 @@ impl<'sess> AttributeParser<'sess> {
176182 }
177183 }
178184
179 pub(crate) fn check_crate_level(target: Target, cx: &mut AcceptContext<'_, 'sess>) {
180 if target == Target::Crate {
185 pub(crate) fn check_crate_level(cx: &mut AcceptContext<'_, 'sess>) {
186 if cx.target == Target::Crate {
181187 return;
182188 }
183189
......@@ -200,6 +206,7 @@ impl<'sess> AttributeParser<'sess> {
200206 })
201207 .unwrap_or_default();
202208
209 let target = cx.target;
203210 cx.emit_lint(
204211 rustc_session::lint::builtin::UNUSED_ATTRIBUTES,
205212 crate::errors::InvalidAttrStyle {
compiler/rustc_codegen_gcc/build_system/src/test.rs-2
......@@ -886,8 +886,6 @@ fn valid_ui_error_pattern_test(file: &str) -> bool {
886886 "type-alias-impl-trait/auxiliary/cross_crate_ice.rs",
887887 "type-alias-impl-trait/auxiliary/cross_crate_ice2.rs",
888888 "macros/rfc-2011-nicer-assert-messages/auxiliary/common.rs",
889 "imports/ambiguous-1.rs",
890 "imports/ambiguous-4-extern.rs",
891889 "entry-point/auxiliary/bad_main_functions.rs",
892890 ]
893891 .iter()
compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs+29-17
......@@ -319,25 +319,26 @@ impl KernelArgsTy {
319319 geps: [&'ll Value; 3],
320320 workgroup_dims: &'ll Value,
321321 thread_dims: &'ll Value,
322 ) -> [(Align, &'ll Value); 13] {
322 dyn_cache: &'ll Value,
323 ) -> [(Align, &'ll str, &'ll Value); 13] {
323324 let four = Align::from_bytes(4).expect("4 Byte alignment should work");
324325 let eight = Align::EIGHT;
325326
326327 [
327 (four, cx.get_const_i32(KernelArgsTy::OFFLOAD_VERSION)),
328 (four, cx.get_const_i32(num_args)),
329 (eight, geps[0]),
330 (eight, geps[1]),
331 (eight, geps[2]),
332 (eight, memtransfer_types),
328 (four, "Version", cx.get_const_i32(KernelArgsTy::OFFLOAD_VERSION)),
329 (four, "NumArgs", cx.get_const_i32(num_args)),
330 (eight, "ArgBasePtrs", geps[0]),
331 (eight, "ArgPtrs", geps[1]),
332 (eight, "ArgSizes", geps[2]),
333 (eight, "ArgTypes", memtransfer_types),
333334 // The next two are debug infos. FIXME(offload): set them
334 (eight, cx.const_null(cx.type_ptr())), // dbg
335 (eight, cx.const_null(cx.type_ptr())), // dbg
336 (eight, cx.get_const_i64(KernelArgsTy::TRIPCOUNT)),
337 (eight, cx.get_const_i64(KernelArgsTy::FLAGS)),
338 (four, workgroup_dims),
339 (four, thread_dims),
340 (four, cx.get_const_i32(0)),
335 (eight, "ArgNames", cx.const_null(cx.type_ptr())), // dbg
336 (eight, "ArgMappers", cx.const_null(cx.type_ptr())), // dbg
337 (eight, "Tripcount", cx.get_const_i64(KernelArgsTy::TRIPCOUNT)),
338 (eight, "Flags", cx.get_const_i64(KernelArgsTy::FLAGS)),
339 (four, "NumTeams", workgroup_dims),
340 (four, "ThreadLimit", thread_dims),
341 (four, "DynCGroupMem", dyn_cache),
341342 ]
342343 }
343344}
......@@ -589,6 +590,7 @@ pub(crate) fn gen_call_handling<'ll, 'tcx>(
589590 metadata: &[OffloadMetadata],
590591 offload_globals: &OffloadGlobals<'ll>,
591592 offload_dims: &OffloadKernelDims<'ll>,
593 dyn_cache: &'ll Value,
592594) {
593595 let cx = builder.cx;
594596 let OffloadKernelGlobals {
......@@ -753,14 +755,24 @@ pub(crate) fn gen_call_handling<'ll, 'tcx>(
753755 num_args,
754756 s_ident_t,
755757 );
756 let values =
757 KernelArgsTy::new(&cx, num_args, memtransfer_kernel, geps, workgroup_dims, thread_dims);
758 let values = KernelArgsTy::new(
759 &cx,
760 num_args,
761 memtransfer_kernel,
762 geps,
763 workgroup_dims,
764 thread_dims,
765 dyn_cache,
766 );
758767
759768 // Step 3)
760769 // Here we fill the KernelArgsTy, see the documentation above
761770 for (i, value) in values.iter().enumerate() {
762771 let ptr = builder.inbounds_gep(tgt_kernel_decl, a5, &[i32_0, cx.get_const_i32(i as u64)]);
763 builder.store(value.1, ptr, value.0);
772 let name = std::ffi::CString::new(value.1).unwrap();
773 llvm::set_value_name(ptr, &name.as_bytes());
774
775 builder.store(value.2, ptr, value.0);
764776 }
765777
766778 let args = vec![
compiler/rustc_codegen_llvm/src/intrinsic.rs+15-2
......@@ -1926,7 +1926,11 @@ fn codegen_offload<'ll, 'tcx>(
19261926 };
19271927
19281928 let offload_dims = OffloadKernelDims::from_operands(bx, &args[1], &args[2]);
1929 let args = get_args_from_tuple(bx, args[3], fn_target);
1929 let dyn_cache = match args[3].val {
1930 OperandValue::Immediate(val) => val,
1931 _ => panic!("unparsable"),
1932 };
1933 let args = get_args_from_tuple(bx, args[4], fn_target);
19301934 let target_symbol = symbol_name_for_instance_in_crate(tcx, fn_target, LOCAL_CRATE);
19311935
19321936 let sig = tcx.fn_sig(fn_target.def_id()).skip_binder();
......@@ -1958,7 +1962,16 @@ fn codegen_offload<'ll, 'tcx>(
19581962 };
19591963 register_offload(cx);
19601964 let offload_data = gen_define_handling(&cx, &metadata, target_symbol, offload_globals);
1961 gen_call_handling(bx, &offload_data, &args, &types, &metadata, offload_globals, &offload_dims);
1965 gen_call_handling(
1966 bx,
1967 &offload_data,
1968 &args,
1969 &types,
1970 &metadata,
1971 offload_globals,
1972 &offload_dims,
1973 &dyn_cache,
1974 );
19621975}
19631976
19641977fn get_args_from_tuple<'ll, 'tcx>(
compiler/rustc_codegen_ssa/src/back/link.rs-4
......@@ -1530,7 +1530,6 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
15301530 }
15311531 LinkerFlavor::Bpf => "bpf-linker",
15321532 LinkerFlavor::Llbc => "llvm-bitcode-linker",
1533 LinkerFlavor::Ptx => "rust-ptx-linker",
15341533 }),
15351534 flavor,
15361535 )),
......@@ -1571,7 +1570,6 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
15711570 let linker_flavor = match sess.opts.cg.linker_flavor {
15721571 // The linker flavors that are non-target specific can be directly translated to LinkerFlavor
15731572 Some(LinkerFlavorCli::Llbc) => Some(LinkerFlavor::Llbc),
1574 Some(LinkerFlavorCli::Ptx) => Some(LinkerFlavor::Ptx),
15751573 // The linker flavors that corresponds to targets needs logic that keeps the base LinkerFlavor
15761574 linker_flavor => {
15771575 linker_flavor.map(|flavor| sess.target.linker_flavor.with_cli_hints(flavor))
......@@ -2764,8 +2762,6 @@ fn add_order_independent_options(
27642762 if crate_info.target_features.len() > 0 {
27652763 cmd.link_arg(&format!("--target-feature={}", &crate_info.target_features.join(",")));
27662764 }
2767 } else if flavor == LinkerFlavor::Ptx {
2768 cmd.link_args(&["--fallback-arch", &crate_info.target_cpu]);
27692765 } else if flavor == LinkerFlavor::Bpf {
27702766 cmd.link_args(&["--cpu", &crate_info.target_cpu]);
27712767 if let Some(feat) = [sess.opts.cg.target_feature.as_str(), &sess.target.options.features]
compiler/rustc_codegen_ssa/src/back/linker.rs-79
......@@ -161,7 +161,6 @@ pub(crate) fn get_linker<'a>(
161161 LinkerFlavor::EmCc => Box::new(EmLinker { cmd, sess }) as Box<dyn Linker>,
162162 LinkerFlavor::Bpf => Box::new(BpfLinker { cmd, sess }) as Box<dyn Linker>,
163163 LinkerFlavor::Llbc => Box::new(LlbcLinker { cmd, sess }) as Box<dyn Linker>,
164 LinkerFlavor::Ptx => Box::new(PtxLinker { cmd, sess }) as Box<dyn Linker>,
165164 }
166165}
167166
......@@ -283,7 +282,6 @@ generate_arg_methods! {
283282 L4Bender<'_>
284283 AixLinker<'_>
285284 LlbcLinker<'_>
286 PtxLinker<'_>
287285 BpfLinker<'_>
288286 dyn Linker + '_
289287}
......@@ -1920,83 +1918,6 @@ pub(crate) fn linked_symbols(
19201918 symbols
19211919}
19221920
1923/// Much simplified and explicit CLI for the NVPTX linker. The linker operates
1924/// with bitcode and uses LLVM backend to generate a PTX assembly.
1925struct PtxLinker<'a> {
1926 cmd: Command,
1927 sess: &'a Session,
1928}
1929
1930impl<'a> Linker for PtxLinker<'a> {
1931 fn cmd(&mut self) -> &mut Command {
1932 &mut self.cmd
1933 }
1934
1935 fn set_output_kind(
1936 &mut self,
1937 _output_kind: LinkOutputKind,
1938 _crate_type: CrateType,
1939 _out_filename: &Path,
1940 ) {
1941 }
1942
1943 fn link_staticlib_by_name(&mut self, _name: &str, _verbatim: bool, _whole_archive: bool) {
1944 panic!("staticlibs not supported")
1945 }
1946
1947 fn link_staticlib_by_path(&mut self, path: &Path, _whole_archive: bool) {
1948 self.link_arg("--rlib").link_arg(path);
1949 }
1950
1951 fn debuginfo(&mut self, _strip: Strip, _: &[PathBuf]) {
1952 self.link_arg("--debug");
1953 }
1954
1955 fn add_object(&mut self, path: &Path) {
1956 self.link_arg("--bitcode").link_arg(path);
1957 }
1958
1959 fn optimize(&mut self) {
1960 match self.sess.lto() {
1961 Lto::Thin | Lto::Fat | Lto::ThinLocal => {
1962 self.link_arg("-Olto");
1963 }
1964
1965 Lto::No => {}
1966 }
1967 }
1968
1969 fn full_relro(&mut self) {}
1970
1971 fn partial_relro(&mut self) {}
1972
1973 fn no_relro(&mut self) {}
1974
1975 fn gc_sections(&mut self, _keep_metadata: bool) {}
1976
1977 fn pgo_gen(&mut self) {}
1978
1979 fn no_crt_objects(&mut self) {}
1980
1981 fn no_default_libraries(&mut self) {}
1982
1983 fn control_flow_guard(&mut self) {}
1984
1985 fn ehcont_guard(&mut self) {}
1986
1987 fn export_symbols(
1988 &mut self,
1989 _tmpdir: &Path,
1990 _crate_type: CrateType,
1991 _symbols: &[(String, SymbolExportKind)],
1992 ) {
1993 }
1994
1995 fn windows_subsystem(&mut self, _subsystem: WindowsSubsystemKind) {}
1996
1997 fn linker_plugin_lto(&mut self) {}
1998}
1999
20001921/// The `self-contained` LLVM bitcode linker
20011922struct LlbcLinker<'a> {
20021923 cmd: Command,
compiler/rustc_feature/src/unstable.rs+2
......@@ -454,6 +454,8 @@ declare_features! (
454454 (unstable, cfg_version, "1.45.0", Some(64796)),
455455 /// Allows to use the `#[cfi_encoding = ""]` attribute.
456456 (unstable, cfi_encoding, "1.71.0", Some(89653)),
457 /// The `clflushopt` target feature on x86.
458 (unstable, clflushopt_target_feature, "CURRENT_RUSTC_VERSION", Some(157096)),
457459 /// Allows `for<...>` on closures and coroutines.
458460 (unstable, closure_lifetime_binder, "1.64.0", Some(97362)),
459461 /// Allows `#[track_caller]` on closures and coroutines.
compiler/rustc_hir/src/def.rs-2
......@@ -991,8 +991,6 @@ pub enum LifetimeRes {
991991 ///
992992 /// Creating the associated `LocalDefId` is the responsibility of lowering.
993993 param: NodeId,
994 /// Id of the introducing place. See `Param`.
995 binder: NodeId,
996994 /// Kind of elided lifetime
997995 kind: hir::MissingLifetimeKind,
998996 },
compiler/rustc_hir/src/definitions.rs+70-105
......@@ -20,84 +20,6 @@ pub use crate::def_id::DefPathHash;
2020use crate::def_id::{CRATE_DEF_INDEX, CrateNum, DefIndex, LOCAL_CRATE, LocalDefId, StableCrateId};
2121use crate::def_path_hash_map::DefPathHashMap;
2222
23/// The `DefPathTable` maps `DefIndex`es to `DefKey`s and vice versa.
24/// Internally the `DefPathTable` holds a tree of `DefKey`s, where each `DefKey`
25/// stores the `DefIndex` of its parent.
26/// There is one `DefPathTable` for each crate.
27#[derive(Debug)]
28pub struct DefPathTable {
29 stable_crate_id: StableCrateId,
30 index_to_key: IndexVec<DefIndex, DefKey>,
31 // We do only store the local hash, as all the definitions are from the current crate.
32 def_path_hashes: IndexVec<DefIndex, Hash64>,
33 def_path_hash_to_index: DefPathHashMap,
34}
35
36impl DefPathTable {
37 fn new(stable_crate_id: StableCrateId) -> DefPathTable {
38 DefPathTable {
39 stable_crate_id,
40 index_to_key: Default::default(),
41 def_path_hashes: Default::default(),
42 def_path_hash_to_index: Default::default(),
43 }
44 }
45
46 fn allocate(&mut self, key: DefKey, def_path_hash: DefPathHash) -> DefIndex {
47 // Assert that all DefPathHashes correctly contain the local crate's StableCrateId.
48 debug_assert_eq!(self.stable_crate_id, def_path_hash.stable_crate_id());
49 let local_hash = def_path_hash.local_hash();
50
51 let index = self.index_to_key.push(key);
52 debug!("DefPathTable::insert() - {key:?} <-> {index:?}");
53
54 self.def_path_hashes.push(local_hash);
55 debug_assert!(self.def_path_hashes.len() == self.index_to_key.len());
56
57 // Check for hash collisions of DefPathHashes. These should be
58 // exceedingly rare.
59 if let Some(existing) = self.def_path_hash_to_index.insert(&local_hash, &index) {
60 let def_path1 = DefPath::make(LOCAL_CRATE, existing, |idx| self.def_key(idx));
61 let def_path2 = DefPath::make(LOCAL_CRATE, index, |idx| self.def_key(idx));
62
63 // Continuing with colliding DefPathHashes can lead to correctness
64 // issues. We must abort compilation.
65 //
66 // The likelihood of such a collision is very small, so actually
67 // running into one could be indicative of a poor hash function
68 // being used.
69 //
70 // See the documentation for DefPathHash for more information.
71 panic!(
72 "found DefPathHash collision between {def_path1:#?} and {def_path2:#?}. \
73 Compilation cannot continue."
74 );
75 }
76
77 index
78 }
79
80 #[inline(always)]
81 pub fn def_key(&self, index: DefIndex) -> DefKey {
82 self.index_to_key[index]
83 }
84
85 #[instrument(level = "trace", skip(self), ret)]
86 #[inline(always)]
87 pub fn def_path_hash(&self, index: DefIndex) -> DefPathHash {
88 let hash = self.def_path_hashes[index];
89 DefPathHash::new(self.stable_crate_id, hash)
90 }
91
92 pub fn enumerated_keys_and_path_hashes(
93 &self,
94 ) -> impl Iterator<Item = (DefIndex, &DefKey, DefPathHash)> + ExactSizeIterator {
95 self.index_to_key
96 .iter_enumerated()
97 .map(move |(index, key)| (index, key, self.def_path_hash(index)))
98 }
99}
100
10123#[derive(Debug, Default, Clone)]
10224pub struct PerParentDisambiguatorState {
10325 #[cfg(debug_assertions)]
......@@ -123,12 +45,13 @@ impl LocalDefIdMap<PerParentDisambiguatorState> {
12345 }
12446}
12547
126/// The definition table containing node definitions.
127/// It holds the `DefPathTable` for `LocalDefId`s/`DefPath`s.
128/// It also stores mappings to convert `LocalDefId`s to/from `HirId`s.
12948#[derive(Debug)]
13049pub struct Definitions {
131 table: DefPathTable,
50 stable_crate_id: StableCrateId,
51 def_id_to_key: IndexVec<LocalDefId, DefKey>,
52 // We do only store the local hash, as all the definitions are from the current crate.
53 def_path_hashes: IndexVec<LocalDefId, Hash64>,
54 def_path_hash_to_index: DefPathHashMap,
13255}
13356
13457/// A unique identifier that we can use to lookup a definition
......@@ -167,7 +90,7 @@ impl DefKey {
16790 // Construct the new DefPathHash, making sure that the `crate_id`
16891 // portion of the hash is properly copied from the parent. This way the
16992 // `crate_id` part will be recursively propagated from the root to all
170 // DefPathHashes in this DefPathTable.
93 // DefPathHashes in this Definitions.
17194 DefPathHash::new(parent.stable_crate_id(), local_hash)
17295 }
17396
......@@ -324,23 +247,15 @@ pub enum DefPathData {
324247}
325248
326249impl Definitions {
327 pub fn def_path_table(&self) -> &DefPathTable {
328 &self.table
329 }
330
331 /// Gets the number of definitions.
332 pub fn def_index_count(&self) -> usize {
333 self.table.index_to_key.len()
334 }
335
336 #[inline]
250 #[inline(always)]
337251 pub fn def_key(&self, id: LocalDefId) -> DefKey {
338 self.table.def_key(id.local_def_index)
252 self.def_id_to_key[id]
339253 }
340254
255 #[instrument(level = "trace", skip(self), ret)]
341256 #[inline(always)]
342257 pub fn def_path_hash(&self, id: LocalDefId) -> DefPathHash {
343 self.table.def_path_hash(id.local_def_index)
258 DefPathHash::new(self.stable_crate_id, self.def_path_hashes[id])
344259 }
345260
346261 /// Returns the path from the crate root to `index`. The root
......@@ -348,6 +263,7 @@ impl Definitions {
348263 /// empty vector for the crate root). For an inlined item, this
349264 /// will be the path of the item in the external crate (but the
350265 /// path will begin with the path to the external crate).
266 #[inline]
351267 pub fn def_path(&self, id: LocalDefId) -> DefPath {
352268 DefPath::make(LOCAL_CRATE, id.local_def_index, |index| {
353269 self.def_key(LocalDefId { local_def_index: index })
......@@ -375,12 +291,62 @@ impl Definitions {
375291 let def_path_hash =
376292 DefPathHash::new(stable_crate_id, Hash64::new(stable_crate_id.as_u64()));
377293
294 let mut defs = Definitions {
295 stable_crate_id,
296 def_path_hashes: Default::default(),
297 def_id_to_key: Default::default(),
298 def_path_hash_to_index: Default::default(),
299 };
300
378301 // Create the root definition.
379 let mut table = DefPathTable::new(stable_crate_id);
380 let root = LocalDefId { local_def_index: table.allocate(key, def_path_hash) };
302 let root = defs.allocate(key, def_path_hash);
381303 assert_eq!(root.local_def_index, CRATE_DEF_INDEX);
382304
383 Definitions { table }
305 defs
306 }
307
308 fn allocate(&mut self, key: DefKey, def_path_hash: DefPathHash) -> LocalDefId {
309 // Assert that all DefPathHashes correctly contain the local crate's StableCrateId.
310 debug_assert_eq!(self.stable_crate_id, def_path_hash.stable_crate_id());
311 let local_hash = def_path_hash.local_hash();
312
313 let def_id = self.def_id_to_key.push(key);
314 debug!("def_id_to_key.push() - {key:?} <-> {:?}", def_id.local_def_index);
315
316 self.def_path_hashes.push(local_hash);
317 debug_assert!(self.def_path_hashes.len() == self.def_id_to_key.len());
318
319 // Check for hash collisions of DefPathHashes. These should be
320 // exceedingly rare.
321 if let Some(existing) =
322 self.def_path_hash_to_index.insert(&local_hash, &def_id.local_def_index)
323 {
324 let def_path1 = self.def_path(LocalDefId { local_def_index: existing });
325 let def_path2 = self.def_path(def_id);
326
327 // Continuing with colliding DefPathHashes can lead to correctness
328 // issues. We must abort compilation.
329 //
330 // The likelihood of such a collision is very small, so actually
331 // running into one could be indicative of a poor hash function
332 // being used.
333 //
334 // See the documentation for DefPathHash for more information.
335 panic!(
336 "found DefPathHash collision between {def_path1:#?} and {def_path2:#?}. \
337 Compilation cannot continue."
338 );
339 }
340
341 def_id
342 }
343
344 pub fn enumerated_keys_and_path_hashes(
345 &self,
346 ) -> impl Iterator<Item = (DefIndex, &DefKey, DefPathHash)> + ExactSizeIterator {
347 self.def_id_to_key
348 .iter_enumerated()
349 .map(move |(def_id, key)| (def_id.local_def_index, key, self.def_path_hash(def_id)))
384350 }
385351
386352 /// Creates a definition with a parent definition.
......@@ -423,13 +389,13 @@ impl Definitions {
423389 disambiguated_data: DisambiguatedDefPathData { data, disambiguator },
424390 };
425391
426 let parent_hash = self.table.def_path_hash(parent.local_def_index);
392 let parent_hash = self.def_path_hash(parent);
427393 let def_path_hash = key.compute_stable_hash(parent_hash);
428394
429395 debug!("create_def: after disambiguation, key = {:?}", key);
430396
431397 // Create the definition.
432 LocalDefId { local_def_index: self.table.allocate(key, def_path_hash) }
398 self.allocate(key, def_path_hash)
433399 }
434400
435401 #[inline(always)]
......@@ -439,19 +405,18 @@ impl Definitions {
439405 /// if the `DefPathHash` is from a previous compilation session and
440406 /// the def-path does not exist anymore.
441407 pub fn local_def_path_hash_to_def_id(&self, hash: DefPathHash) -> Option<LocalDefId> {
442 debug_assert!(hash.stable_crate_id() == self.table.stable_crate_id);
443 self.table
444 .def_path_hash_to_index
408 debug_assert!(hash.stable_crate_id() == self.stable_crate_id);
409 self.def_path_hash_to_index
445410 .get(&hash.local_hash())
446411 .map(|local_def_index| LocalDefId { local_def_index })
447412 }
448413
449414 pub fn def_path_hash_to_def_index_map(&self) -> &DefPathHashMap {
450 &self.table.def_path_hash_to_index
415 &self.def_path_hash_to_index
451416 }
452417
453418 pub fn num_definitions(&self) -> usize {
454 self.table.def_path_hashes.len()
419 self.def_path_hashes.len()
455420 }
456421}
457422
compiler/rustc_hir_analysis/src/check/intrinsic.rs+1
......@@ -356,6 +356,7 @@ pub(crate) fn check_intrinsic_type(
356356 param(0),
357357 Ty::new_array_with_const_len(tcx, tcx.types.u32, Const::from_target_usize(tcx, 3)),
358358 Ty::new_array_with_const_len(tcx, tcx.types.u32, Const::from_target_usize(tcx, 3)),
359 tcx.types.u32,
359360 param(1),
360361 ],
361362 param(2),
compiler/rustc_lint_defs/src/builtin.rs+10-17
......@@ -4529,28 +4529,21 @@ declare_lint! {
45294529 ///
45304530 /// ### Example
45314531 ///
4532 /// ```rust,compile_fail
4533 /// #![deny(ambiguous_glob_imports)]
4534 /// pub fn foo() -> u32 {
4535 /// use sub::*;
4536 /// C
4537 /// }
4538 ///
4539 /// mod sub {
4540 /// mod mod1 { pub const C: u32 = 1; }
4541 /// mod mod2 { pub const C: u32 = 2; }
4532 /// ```rust,ignore (needs extern crate)
4533 /// // library crate `my_library`
4534 /// mod mod1 { pub const C: u32 = 1; }
4535 /// mod mod2 { pub const C: u32 = 2; }
4536 /// pub use mod1::*;
4537 /// pub use mod2::*;
45424538 ///
4543 /// pub use mod1::*;
4544 /// pub use mod2::*;
4545 /// }
4539 /// // another crate using `my_library`
4540 /// let c = my_library::C; // `C` is ambiguous
45464541 /// ```
45474542 ///
4548 /// {{produces}}
4549 ///
45504543 /// ### Explanation
45514544 ///
4552 /// Previous versions of Rust compile it successfully because it
4553 /// had lost the ambiguity error when resolve `use sub::mod2::*`.
4545 /// Previous versions of Rust compile it successfully because
4546 /// ambiguous glob imports weren't preserved correctly over crate boundaries.
45544547 ///
45554548 /// This is a [future-incompatible] lint to transition this to a
45564549 /// hard error in the future.
compiler/rustc_metadata/src/rmeta/encoder.rs+11-10
......@@ -12,7 +12,7 @@ use rustc_data_structures::temp_dir::MaybeTempDir;
1212use rustc_data_structures::thousands::usize_with_underscores;
1313use rustc_hir as hir;
1414use rustc_hir::attrs::{AttributeKind, EncodeCrossCrate};
15use rustc_hir::def_id::{CRATE_DEF_ID, CRATE_DEF_INDEX, LOCAL_CRATE, LocalDefId, LocalDefIdSet};
15use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId, LocalDefIdSet};
1616use rustc_hir::definitions::DefPathData;
1717use rustc_hir::find_attr;
1818use rustc_hir_pretty::id_to_string;
......@@ -510,18 +510,20 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
510510 }
511511
512512 fn encode_def_path_table(&mut self) {
513 let table = self.tcx.def_path_table();
513 let defs = self.tcx.definitions();
514514 if self.is_proc_macro {
515 for def_index in std::iter::once(CRATE_DEF_INDEX)
516 .chain(self.tcx.resolutions(()).proc_macros.iter().map(|p| p.local_def_index))
515 for def_id in std::iter::once(CRATE_DEF_ID)
516 .chain(self.tcx.resolutions(()).proc_macros.iter().copied())
517517 {
518 let def_key = self.lazy(table.def_key(def_index));
519 let def_path_hash = table.def_path_hash(def_index);
520 self.tables.def_keys.set_some(def_index, def_key);
521 self.tables.def_path_hashes.set(def_index, def_path_hash.local_hash().as_u64());
518 let def_key = self.lazy(defs.def_key(def_id));
519 let def_path_hash = defs.def_path_hash(def_id);
520 self.tables.def_keys.set_some(def_id.local_def_index, def_key);
521 self.tables
522 .def_path_hashes
523 .set(def_id.local_def_index, def_path_hash.local_hash().as_u64());
522524 }
523525 } else {
524 for (def_index, def_key, def_path_hash) in table.enumerated_keys_and_path_hashes() {
526 for (def_index, def_key, def_path_hash) in defs.enumerated_keys_and_path_hashes() {
525527 let def_key = self.lazy(def_key);
526528 self.tables.def_keys.set_some(def_index, def_key);
527529 self.tables.def_path_hashes.set(def_index, def_path_hash.local_hash().as_u64());
......@@ -2034,7 +2036,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
20342036
20352037 let def_id = id.to_def_id();
20362038 self.tables.def_kind.set_some(def_id.index, DefKind::Macro(macro_kind.into()));
2037 self.tables.proc_macro.set_some(def_id.index, macro_kind);
20382039 self.encode_attrs(id);
20392040 record!(self.tables.def_keys[def_id] <- def_key);
20402041 record!(self.tables.def_ident_span[def_id] <- span);
compiler/rustc_metadata/src/rmeta/mod.rs-1
......@@ -464,7 +464,6 @@ define_tables! {
464464 variant_data: Table<DefIndex, LazyValue<VariantData>>,
465465 assoc_container: Table<DefIndex, LazyValue<ty::AssocContainer>>,
466466 macro_definition: Table<DefIndex, LazyValue<ast::DelimArgs>>,
467 proc_macro: Table<DefIndex, MacroKind>,
468467 deduced_param_attrs: Table<DefIndex, LazyArray<DeducedParamAttrs>>,
469468 collect_return_position_impl_trait_in_trait_tys: Table<DefIndex, LazyValue<DefIdMap<ty::EarlyBinder<'static, Ty<'static>>>>>,
470469 doc_link_resolutions: Table<DefIndex, LazyValue<DocLinkResMap>>,
compiler/rustc_middle/src/ty/context.rs+2-2
......@@ -1349,13 +1349,13 @@ impl<'tcx> TyCtxt<'tcx> {
13491349 }
13501350 }
13511351
1352 pub fn def_path_table(self) -> &'tcx rustc_hir::definitions::DefPathTable {
1352 pub fn definitions(self) -> &'tcx rustc_hir::definitions::Definitions {
13531353 // Depend on the `analysis` query to ensure compilation if finished.
13541354 self.ensure_ok().analysis(());
13551355
13561356 // Freeze definitions once we start iterating on them, to prevent adding new ones
13571357 // while iterating. If some query needs to add definitions, it should be `ensure`d above.
1358 self.untracked.definitions.freeze().def_path_table()
1358 self.untracked.definitions.freeze()
13591359 }
13601360
13611361 pub fn def_path_hash_to_def_index_map(
compiler/rustc_middle/src/ty/mod.rs+7-5
......@@ -37,12 +37,11 @@ use rustc_data_structures::stable_hash::{StableHash, StableHashCtxt, StableHashe
3737use rustc_data_structures::steal::Steal;
3838use rustc_data_structures::unord::{UnordMap, UnordSet};
3939use rustc_errors::{Diag, ErrorGuaranteed, LintBuffer};
40use rustc_hir as hir;
4140use rustc_hir::attrs::StrippedCfgItem;
4241use rustc_hir::def::{CtorKind, CtorOf, DefKind, DocLinkResMap, LifetimeRes, Res};
4342use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap};
4443use rustc_hir::definitions::PerParentDisambiguatorState;
45use rustc_hir::{LangItem, attrs as attr, find_attr};
44use rustc_hir::{self as hir, LangItem, MissingLifetimeKind, attrs as attr, find_attr};
4645use rustc_index::IndexVec;
4746use rustc_index::bit_set::BitMatrix;
4847use rustc_macros::{
......@@ -232,7 +231,7 @@ pub struct ResolverAstLowering<'tcx> {
232231 /// Resolutions for lifetimes.
233232 pub lifetimes_res_map: NodeMap<LifetimeRes>,
234233 /// Lifetime parameters that lowering will have to introduce.
235 pub extra_lifetime_params_map: NodeMap<Vec<(Ident, ast::NodeId, LifetimeRes)>>,
234 pub extra_lifetime_params_map: NodeMap<Vec<(Ident, ast::NodeId, MissingLifetimeKind)>>,
236235
237236 pub next_node_id: ast::NodeId,
238237
......@@ -253,9 +252,12 @@ pub struct ResolverAstLowering<'tcx> {
253252
254253#[derive(Debug)]
255254pub struct DelegationInfo {
256 // NodeId (either delegation.id or item_id in case of a trait impl) for signature resolution,
255 // `DefId` (either the resolution at delegation.id or item_id in case of a trait impl) for signature resolution,
257256 // for details see https://github.com/rust-lang/rust/issues/118212#issuecomment-2160686914
258 pub resolution_node: ast::NodeId,
257 /// Refers to the next element in a delegation resolution chain.
258 /// Usually points to the final resolution, as most "chains" are just
259 /// one step to a trait or an impl.
260 pub resolution_id: DefId,
259261}
260262
261263#[derive(Clone, Copy, Debug, StableHash)]
compiler/rustc_public/src/compiler_interface.rs+373-407
......@@ -79,183 +79,191 @@ pub(crate) struct CompilerInterface<'tcx> {
7979}
8080
8181impl<'tcx> CompilerInterface<'tcx> {
82 pub(crate) fn entry_fn(&self) -> Option<CrateItem> {
82 fn with_cx<R>(
83 &self,
84 f: impl FnOnce(&mut Tables<'tcx, BridgeTys>, &CompilerCtxt<'tcx, BridgeTys>) -> R,
85 ) -> R {
8386 let mut tables = self.tables.borrow_mut();
84 let cx = &*self.cx.borrow();
85 let did = cx.entry_fn();
86 Some(tables.crate_item(did?))
87 let cx = self.cx.borrow();
88 f(&mut *tables, &*cx)
89 }
90
91 pub(crate) fn entry_fn(&self) -> Option<CrateItem> {
92 self.with_cx(|tables, cx| {
93 let did = cx.entry_fn();
94 Some(tables.crate_item(did?))
95 })
8796 }
8897
8998 /// Retrieve all items of the local crate that have a MIR associated with them.
9099 pub(crate) fn all_local_items(&self) -> CrateItems {
91 let mut tables = self.tables.borrow_mut();
92 let cx = &*self.cx.borrow();
93 cx.all_local_items().iter().map(|did| tables.crate_item(*did)).collect()
100 self.with_cx(|tables, cx| {
101 cx.all_local_items().iter().map(|did| tables.crate_item(*did)).collect()
102 })
94103 }
95104
96105 /// Retrieve the body of a function.
97106 /// This function will panic if the body is not available.
98107 pub(crate) fn mir_body(&self, item: DefId) -> mir::Body {
99 let mut tables = self.tables.borrow_mut();
100 let cx = &*self.cx.borrow();
101 let did = tables[item];
102 cx.mir_body(did).stable(&mut *tables, cx)
108 self.with_cx(|tables, cx| {
109 let did = tables[item];
110 cx.mir_body(did).stable(tables, cx)
111 })
103112 }
104113
105114 /// Check whether the body of a function is available.
106115 pub(crate) fn has_body(&self, item: DefId) -> bool {
107 let mut tables = self.tables.borrow_mut();
108 let cx = &*self.cx.borrow();
109 let def = item.internal(&mut *tables, cx.tcx);
110 cx.has_body(def)
116 self.with_cx(|tables, cx| {
117 let def = item.internal(tables, cx.tcx);
118 cx.has_body(def)
119 })
111120 }
112121
113122 pub(crate) fn foreign_modules(&self, crate_num: CrateNum) -> Vec<ForeignModuleDef> {
114 let mut tables = self.tables.borrow_mut();
115 let cx = &*self.cx.borrow();
116 cx.foreign_modules(crate_num.internal(&mut *tables, cx.tcx))
117 .iter()
118 .map(|did| tables.foreign_module_def(*did))
119 .collect()
123 self.with_cx(|tables, cx| {
124 cx.foreign_modules(crate_num.internal(tables, cx.tcx))
125 .iter()
126 .map(|did| tables.foreign_module_def(*did))
127 .collect()
128 })
120129 }
121130
122131 /// Retrieve all functions defined in this crate.
123132 pub(crate) fn crate_functions(&self, crate_num: CrateNum) -> Vec<FnDef> {
124 let mut tables = self.tables.borrow_mut();
125 let cx = &*self.cx.borrow();
126 let krate = crate_num.internal(&mut *tables, cx.tcx);
127 cx.crate_functions(krate).iter().map(|did| tables.fn_def(*did)).collect()
133 self.with_cx(|tables, cx| {
134 let krate = crate_num.internal(tables, cx.tcx);
135 cx.crate_functions(krate).iter().map(|did| tables.fn_def(*did)).collect()
136 })
128137 }
129138
130139 /// Retrieve all static items defined in this crate.
131140 pub(crate) fn crate_statics(&self, crate_num: CrateNum) -> Vec<StaticDef> {
132 let mut tables = self.tables.borrow_mut();
133 let cx = &*self.cx.borrow();
134 let krate = crate_num.internal(&mut *tables, cx.tcx);
135 cx.crate_statics(krate).iter().map(|did| tables.static_def(*did)).collect()
141 self.with_cx(|tables, cx| {
142 let krate = crate_num.internal(tables, cx.tcx);
143 cx.crate_statics(krate).iter().map(|did| tables.static_def(*did)).collect()
144 })
136145 }
137146
138147 pub(crate) fn foreign_module(&self, mod_def: ForeignModuleDef) -> ForeignModule {
139 let mut tables = self.tables.borrow_mut();
140 let cx = &*self.cx.borrow();
141 let did = tables[mod_def.def_id()];
142 cx.foreign_module(did).stable(&mut *tables, cx)
148 self.with_cx(|tables, cx| {
149 let did = tables[mod_def.def_id()];
150 cx.foreign_module(did).stable(tables, cx)
151 })
143152 }
144153
145154 pub(crate) fn foreign_items(&self, mod_def: ForeignModuleDef) -> Vec<ForeignDef> {
146 let mut tables = self.tables.borrow_mut();
147 let cx = &*self.cx.borrow();
148 let did = tables[mod_def.def_id()];
149 cx.foreign_items(did).iter().map(|did| tables.foreign_def(*did)).collect()
155 self.with_cx(|tables, cx| {
156 let did = tables[mod_def.def_id()];
157 cx.foreign_items(did).iter().map(|did| tables.foreign_def(*did)).collect()
158 })
150159 }
151160
152161 pub(crate) fn all_trait_decls(&self) -> TraitDecls {
153 let mut tables = self.tables.borrow_mut();
154 let cx = &*self.cx.borrow();
155 cx.all_trait_decls().map(|did| tables.trait_def(did)).collect()
162 self.with_cx(|tables, cx| cx.all_trait_decls().map(|did| tables.trait_def(did)).collect())
156163 }
157164
158165 pub(crate) fn trait_decls(&self, crate_num: CrateNum) -> TraitDecls {
159 let mut tables = self.tables.borrow_mut();
160 let cx = &*self.cx.borrow();
161 let krate = crate_num.internal(&mut *tables, cx.tcx);
162 cx.trait_decls(krate).iter().map(|did| tables.trait_def(*did)).collect()
166 self.with_cx(|tables, cx| {
167 let krate = crate_num.internal(tables, cx.tcx);
168 cx.trait_decls(krate).iter().map(|did| tables.trait_def(*did)).collect()
169 })
163170 }
164171
165172 pub(crate) fn trait_decl(&self, trait_def: &TraitDef) -> TraitDecl {
166 let mut tables = self.tables.borrow_mut();
167 let cx = &*self.cx.borrow();
168 let did = tables[trait_def.0];
169 cx.trait_decl(did).stable(&mut *tables, cx)
173 self.with_cx(|tables, cx| {
174 let did = tables[trait_def.0];
175 cx.trait_decl(did).stable(tables, cx)
176 })
170177 }
171178
172179 pub(crate) fn all_trait_impls(&self) -> ImplTraitDecls {
173 let mut tables = self.tables.borrow_mut();
174 let cx = &*self.cx.borrow();
175 cx.all_trait_impls().iter().map(|did| tables.impl_def(*did)).collect()
180 self.with_cx(|tables, cx| {
181 cx.all_trait_impls().iter().map(|did| tables.impl_def(*did)).collect()
182 })
176183 }
177184
178185 pub(crate) fn trait_impls(&self, crate_num: CrateNum) -> ImplTraitDecls {
179 let mut tables = self.tables.borrow_mut();
180 let cx = &*self.cx.borrow();
181 let krate = crate_num.internal(&mut *tables, cx.tcx);
182 cx.trait_impls(krate).iter().map(|did| tables.impl_def(*did)).collect()
186 self.with_cx(|tables, cx| {
187 let krate = crate_num.internal(tables, cx.tcx);
188 cx.trait_impls(krate).iter().map(|did| tables.impl_def(*did)).collect()
189 })
183190 }
184191
185192 pub(crate) fn trait_impl(&self, trait_impl: &ImplDef) -> ImplTrait {
186 let mut tables = self.tables.borrow_mut();
187 let cx = &*self.cx.borrow();
188 let did = tables[trait_impl.0];
189 cx.trait_impl(did).stable(&mut *tables, cx)
193 self.with_cx(|tables, cx| {
194 let did = tables[trait_impl.0];
195 cx.trait_impl(did).stable(tables, cx)
196 })
190197 }
191198
192199 pub(crate) fn generics_of(&self, def_id: DefId) -> Generics {
193 let mut tables = self.tables.borrow_mut();
194 let cx = &*self.cx.borrow();
195 let did = tables[def_id];
196 cx.generics_of(did).stable(&mut *tables, cx)
200 self.with_cx(|tables, cx| {
201 let did = tables[def_id];
202 cx.generics_of(did).stable(tables, cx)
203 })
197204 }
198205
199206 pub(crate) fn predicates_of(&self, def_id: DefId) -> GenericPredicates {
200 let mut tables = self.tables.borrow_mut();
201 let cx = &*self.cx.borrow();
202 let did = tables[def_id];
203 let (parent, kinds) = cx.predicates_of(did);
204 crate::ty::GenericPredicates {
205 parent: parent.map(|did| tables.trait_def(did)),
206 predicates: kinds
207 .iter()
208 .map(|(kind, span)| (kind.stable(&mut *tables, cx), span.stable(&mut *tables, cx)))
209 .collect(),
210 }
207 self.with_cx(|tables, cx| {
208 let did = tables[def_id];
209 let (parent, kinds) = cx.predicates_of(did);
210 crate::ty::GenericPredicates {
211 parent: parent.map(|did| tables.trait_def(did)),
212 predicates: kinds
213 .iter()
214 .map(|(kind, span)| (kind.stable(tables, cx), span.stable(tables, cx)))
215 .collect(),
216 }
217 })
211218 }
212219
213220 pub(crate) fn explicit_predicates_of(&self, def_id: DefId) -> GenericPredicates {
214 let mut tables = self.tables.borrow_mut();
215 let cx = &*self.cx.borrow();
216 let did = tables[def_id];
217 let (parent, kinds) = cx.explicit_predicates_of(did);
218 crate::ty::GenericPredicates {
219 parent: parent.map(|did| tables.trait_def(did)),
220 predicates: kinds
221 .iter()
222 .map(|(kind, span)| (kind.stable(&mut *tables, cx), span.stable(&mut *tables, cx)))
223 .collect(),
224 }
221 self.with_cx(|tables, cx| {
222 let did = tables[def_id];
223 let (parent, kinds) = cx.explicit_predicates_of(did);
224 crate::ty::GenericPredicates {
225 parent: parent.map(|did| tables.trait_def(did)),
226 predicates: kinds
227 .iter()
228 .map(|(kind, span)| (kind.stable(tables, cx), span.stable(tables, cx)))
229 .collect(),
230 }
231 })
225232 }
226233
227234 /// Get information about the local crate.
228235 pub(crate) fn local_crate(&self) -> Crate {
229 let cx = &*self.cx.borrow();
230 smir_crate(cx, cx.local_crate_num())
236 self.with_cx(|_, cx| smir_crate(cx, cx.local_crate_num()))
231237 }
232238
233239 /// Retrieve a list of all external crates.
234240 pub(crate) fn external_crates(&self) -> Vec<Crate> {
235 let cx = &*self.cx.borrow();
236 cx.external_crates().iter().map(|crate_num| smir_crate(cx, *crate_num)).collect()
241 self.with_cx(|_, cx| {
242 cx.external_crates().iter().map(|crate_num| smir_crate(cx, *crate_num)).collect()
243 })
237244 }
238245
239246 /// Find a crate with the given name.
240247 pub(crate) fn find_crates(&self, name: &str) -> Vec<Crate> {
241 let cx = &*self.cx.borrow();
242 cx.find_crates(name).iter().map(|crate_num| smir_crate(cx, *crate_num)).collect()
248 self.with_cx(|_, cx| {
249 cx.find_crates(name).iter().map(|crate_num| smir_crate(cx, *crate_num)).collect()
250 })
243251 }
244252
245253 /// Returns the name of given `DefId`.
246254 pub(crate) fn def_name(&self, def_id: DefId, trimmed: bool) -> Symbol {
247 let tables = self.tables.borrow();
248 let cx = &*self.cx.borrow();
249 let did = tables[def_id];
250 cx.def_name(did, trimmed)
255 self.with_cx(|tables, cx| {
256 let did = tables[def_id];
257 cx.def_name(did, trimmed)
258 })
251259 }
252260
253261 /// Returns the parent of the given `DefId`.
254262 pub(crate) fn def_parent(&self, def_id: DefId) -> Option<DefId> {
255 let mut tables = self.tables.borrow_mut();
256 let cx = &*self.cx.borrow();
257 let did = tables[def_id];
258 cx.def_parent(did).map(|did| tables.create_def_id(did))
263 self.with_cx(|tables, cx| {
264 let did = tables[def_id];
265 cx.def_parent(did).map(|did| tables.create_def_id(did))
266 })
259267 }
260268
261269 /// Return registered tool attributes with the given attribute name.
......@@ -266,184 +274,169 @@ impl<'tcx> CompilerInterface<'tcx> {
266274 /// Single segmented name like `#[clippy]` is specified as `&["clippy".to_string()]`.
267275 /// Multi-segmented name like `#[rustfmt::skip]` is specified as `&["rustfmt".to_string(), "skip".to_string()]`.
268276 pub(crate) fn tool_attrs(&self, def_id: DefId, attr: &[Symbol]) -> Vec<Attribute> {
269 let mut tables = self.tables.borrow_mut();
270 let cx = &*self.cx.borrow();
271 let did = tables[def_id];
272 cx.tool_attrs(did, attr)
273 .into_iter()
274 .map(|(attr_str, span)| Attribute::new(attr_str, span.stable(&mut *tables, cx)))
275 .collect()
277 self.with_cx(|tables, cx| {
278 let did = tables[def_id];
279 cx.tool_attrs(did, attr)
280 .into_iter()
281 .map(|(attr_str, span)| Attribute::new(attr_str, span.stable(tables, cx)))
282 .collect()
283 })
276284 }
277285
278286 /// Get all tool attributes of a definition.
279287 pub(crate) fn all_tool_attrs(&self, def_id: DefId) -> Vec<Attribute> {
280 let mut tables = self.tables.borrow_mut();
281 let cx = &*self.cx.borrow();
282 let did = tables[def_id];
283 cx.all_tool_attrs(did)
284 .into_iter()
285 .map(|(attr_str, span)| Attribute::new(attr_str, span.stable(&mut *tables, cx)))
286 .collect()
288 self.with_cx(|tables, cx| {
289 let did = tables[def_id];
290 cx.all_tool_attrs(did)
291 .into_iter()
292 .map(|(attr_str, span)| Attribute::new(attr_str, span.stable(tables, cx)))
293 .collect()
294 })
287295 }
288296
289297 /// Returns printable, human readable form of `Span`.
290298 pub(crate) fn span_to_string(&self, span: Span) -> String {
291 let tables = self.tables.borrow_mut();
292 let cx = &*self.cx.borrow();
293 let sp = tables.spans[span];
294 cx.span_to_string(sp)
299 self.with_cx(|tables, cx| {
300 let sp = tables.spans[span];
301 cx.span_to_string(sp)
302 })
295303 }
296304
297305 /// Return filename from given `Span`, for diagnostic purposes.
298306 pub(crate) fn get_filename(&self, span: &Span) -> Filename {
299 let tables = self.tables.borrow_mut();
300 let cx = &*self.cx.borrow();
301 let sp = tables.spans[*span];
302 cx.get_filename(sp)
307 self.with_cx(|tables, cx| {
308 let sp = tables.spans[*span];
309 cx.get_filename(sp)
310 })
303311 }
304312
305313 /// Return lines corresponding to this `Span`.
306314 pub(crate) fn get_lines(&self, span: &Span) -> LineInfo {
307 let tables = self.tables.borrow_mut();
308 let cx = &*self.cx.borrow();
309 let sp = tables.spans[*span];
310 let lines = cx.get_lines(sp);
311 LineInfo::from(lines)
315 self.with_cx(|tables, cx| {
316 let sp = tables.spans[*span];
317 let lines = cx.get_lines(sp);
318 LineInfo::from(lines)
319 })
312320 }
313321
314322 /// Returns the `kind` of given `DefId`.
315323 pub(crate) fn item_kind(&self, item: CrateItem) -> ItemKind {
316 let tables = self.tables.borrow();
317 let cx = &*self.cx.borrow();
318 let did = tables[item.0];
319 new_item_kind(cx.def_kind(did))
324 self.with_cx(|tables, cx| {
325 let did = tables[item.0];
326 new_item_kind(cx.def_kind(did))
327 })
320328 }
321329
322330 /// Returns whether this is a foreign item.
323331 pub(crate) fn is_foreign_item(&self, item: DefId) -> bool {
324 let tables = self.tables.borrow();
325 let cx = &*self.cx.borrow();
326 let did = tables[item];
327 cx.is_foreign_item(did)
332 self.with_cx(|tables, cx| {
333 let did = tables[item];
334 cx.is_foreign_item(did)
335 })
328336 }
329337
330338 /// Returns the kind of a given foreign item.
331339 pub(crate) fn foreign_item_kind(&self, def: ForeignDef) -> ForeignItemKind {
332 let mut tables = self.tables.borrow_mut();
333 let cx = &*self.cx.borrow();
334 let def_id = tables[def.def_id()];
335 let def_kind = cx.foreign_item_kind(def_id);
336 match def_kind {
337 DefKind::Fn => ForeignItemKind::Fn(tables.fn_def(def_id)),
338 DefKind::Static { .. } => ForeignItemKind::Static(tables.static_def(def_id)),
339 DefKind::ForeignTy => {
340 use rustc_public_bridge::context::TyHelpers;
341 ForeignItemKind::Type(tables.intern_ty(cx.new_foreign(def_id)))
340 self.with_cx(|tables, cx| {
341 let def_id = tables[def.def_id()];
342 let def_kind = cx.foreign_item_kind(def_id);
343 match def_kind {
344 DefKind::Fn => ForeignItemKind::Fn(tables.fn_def(def_id)),
345 DefKind::Static { .. } => ForeignItemKind::Static(tables.static_def(def_id)),
346 DefKind::ForeignTy => {
347 use rustc_public_bridge::context::TyHelpers;
348 ForeignItemKind::Type(tables.intern_ty(cx.new_foreign(def_id)))
349 }
350 def_kind => unreachable!("Unexpected kind for a foreign item: {:?}", def_kind),
342351 }
343 def_kind => unreachable!("Unexpected kind for a foreign item: {:?}", def_kind),
344 }
352 })
345353 }
346354
347355 /// Returns the kind of a given algebraic data type.
348356 pub(crate) fn adt_kind(&self, def: AdtDef) -> AdtKind {
349 let mut tables = self.tables.borrow_mut();
350 let cx = &*self.cx.borrow();
351 cx.adt_kind(def.internal(&mut *tables, cx.tcx)).stable(&mut *tables, cx)
357 self.with_cx(|tables, cx| cx.adt_kind(def.internal(tables, cx.tcx)).stable(tables, cx))
352358 }
353359
354360 /// Returns if the ADT is a box.
355361 pub(crate) fn adt_is_box(&self, def: AdtDef) -> bool {
356 let mut tables = self.tables.borrow_mut();
357 let cx = &*self.cx.borrow();
358 cx.adt_is_box(def.internal(&mut *tables, cx.tcx))
362 self.with_cx(|tables, cx| cx.adt_is_box(def.internal(tables, cx.tcx)))
359363 }
360364
361365 /// Returns whether this ADT is simd.
362366 pub(crate) fn adt_is_simd(&self, def: AdtDef) -> bool {
363 let mut tables = self.tables.borrow_mut();
364 let cx = &*self.cx.borrow();
365 cx.adt_is_simd(def.internal(&mut *tables, cx.tcx))
367 self.with_cx(|tables, cx| cx.adt_is_simd(def.internal(tables, cx.tcx)))
366368 }
367369
368370 /// Returns whether this definition is a C string.
369371 pub(crate) fn adt_is_cstr(&self, def: AdtDef) -> bool {
370 let mut tables = self.tables.borrow_mut();
371 let cx = &*self.cx.borrow();
372 cx.adt_is_cstr(def.0.internal(&mut *tables, cx.tcx))
372 self.with_cx(|tables, cx| cx.adt_is_cstr(def.0.internal(tables, cx.tcx)))
373373 }
374374
375375 /// Returns the representation options for this ADT
376376 pub(crate) fn adt_repr(&self, def: AdtDef) -> ReprOptions {
377 let mut tables = self.tables.borrow_mut();
378 let cx = &*self.cx.borrow();
379 cx.adt_repr(def.internal(&mut *tables, cx.tcx)).stable(&mut *tables, cx)
377 self.with_cx(|tables, cx| cx.adt_repr(def.internal(tables, cx.tcx)).stable(tables, cx))
380378 }
381379
382380 /// Retrieve the function signature for the given generic arguments.
383381 pub(crate) fn fn_sig(&self, def: FnDef, args: &GenericArgs) -> PolyFnSig {
384 let mut tables = self.tables.borrow_mut();
385 let cx = &*self.cx.borrow();
386 let def_id = def.0.internal(&mut *tables, cx.tcx);
387 let args_ref = args.internal(&mut *tables, cx.tcx);
388 cx.fn_sig(def_id, args_ref).stable(&mut *tables, cx)
382 self.with_cx(|tables, cx| {
383 let def_id = def.0.internal(tables, cx.tcx);
384 let args_ref = args.internal(tables, cx.tcx);
385 cx.fn_sig(def_id, args_ref).stable(tables, cx)
386 })
389387 }
390388
391389 /// Retrieve the constness for the given function definition.
392390 pub(crate) fn constness(&self, def: FnDef) -> Constness {
393 let mut tables = self.tables.borrow_mut();
394 let cx = &*self.cx.borrow();
395 let def_id = def.0.internal(&mut *tables, cx.tcx);
396 cx.constness(def_id).stable(&mut *tables, cx)
391 self.with_cx(|tables, cx| {
392 let def_id = def.0.internal(tables, cx.tcx);
393 cx.constness(def_id).stable(tables, cx)
394 })
397395 }
398396
399397 /// Retrieve the asyncness for the given function definition.
400398 pub(crate) fn asyncness(&self, def: FnDef) -> Asyncness {
401 let mut tables = self.tables.borrow_mut();
402 let cx = &*self.cx.borrow();
403 let def_id = def.0.internal(&mut *tables, cx.tcx);
404 cx.asyncness(def_id).stable(&mut *tables, cx)
399 self.with_cx(|tables, cx| {
400 let def_id = def.0.internal(tables, cx.tcx);
401 cx.asyncness(def_id).stable(tables, cx)
402 })
405403 }
406404
407405 /// Retrieve the intrinsic definition if the item corresponds one.
408406 pub(crate) fn intrinsic(&self, item: DefId) -> Option<IntrinsicDef> {
409 let mut tables = self.tables.borrow_mut();
410 let cx = &*self.cx.borrow();
411 let def_id = item.internal(&mut *tables, cx.tcx);
412 cx.intrinsic(def_id).map(|_| IntrinsicDef(item))
407 self.with_cx(|tables, cx| {
408 let def_id = item.internal(tables, cx.tcx);
409 cx.intrinsic(def_id).map(|_| IntrinsicDef(item))
410 })
413411 }
414412
415413 /// Retrieve the plain function name of an intrinsic.
416414 pub(crate) fn intrinsic_name(&self, def: IntrinsicDef) -> Symbol {
417 let mut tables = self.tables.borrow_mut();
418 let cx = &*self.cx.borrow();
419 let def_id = def.0.internal(&mut *tables, cx.tcx);
420 cx.intrinsic_name(def_id)
415 self.with_cx(|tables, cx| {
416 let def_id = def.0.internal(tables, cx.tcx);
417 cx.intrinsic_name(def_id)
418 })
421419 }
422420
423421 /// Retrieve the closure signature for the given generic arguments.
424422 pub(crate) fn closure_sig(&self, args: &GenericArgs) -> PolyFnSig {
425 let mut tables = self.tables.borrow_mut();
426 let cx = &*self.cx.borrow();
427 let args_ref = args.internal(&mut *tables, cx.tcx);
428 cx.closure_sig(args_ref).stable(&mut *tables, cx)
423 self.with_cx(|tables, cx| {
424 let args_ref = args.internal(tables, cx.tcx);
425 cx.closure_sig(args_ref).stable(tables, cx)
426 })
429427 }
430428
431429 /// The number of variants in this ADT.
432430 pub(crate) fn adt_variants_len(&self, def: AdtDef) -> usize {
433 let mut tables = self.tables.borrow_mut();
434 let cx = &*self.cx.borrow();
435 cx.adt_variants_len(def.internal(&mut *tables, cx.tcx))
431 self.with_cx(|tables, cx| cx.adt_variants_len(def.internal(tables, cx.tcx)))
436432 }
437433
438434 /// Discriminant for a given variant index of AdtDef.
439435 pub(crate) fn adt_discr_for_variant(&self, adt: AdtDef, variant: VariantIdx) -> Discr {
440 let mut tables = self.tables.borrow_mut();
441 let cx = &*self.cx.borrow();
442 cx.adt_discr_for_variant(
443 adt.internal(&mut *tables, cx.tcx),
444 variant.internal(&mut *tables, cx.tcx),
445 )
446 .stable(&mut *tables, cx)
436 self.with_cx(|tables, cx| {
437 cx.adt_discr_for_variant(adt.internal(tables, cx.tcx), variant.internal(tables, cx.tcx))
438 .stable(tables, cx)
439 })
447440 }
448441
449442 /// Discriminant for a given variand index and args of a coroutine.
......@@ -453,67 +446,57 @@ impl<'tcx> CompilerInterface<'tcx> {
453446 args: &GenericArgs,
454447 variant: VariantIdx,
455448 ) -> Discr {
456 let mut tables = self.tables.borrow_mut();
457 let cx = &*self.cx.borrow();
458 let tcx = cx.tcx;
459 let def = coroutine.def_id().internal(&mut *tables, tcx);
460 let args_ref = args.internal(&mut *tables, tcx);
461 cx.coroutine_discr_for_variant(def, args_ref, variant.internal(&mut *tables, tcx))
462 .stable(&mut *tables, cx)
449 self.with_cx(|tables, cx| {
450 let tcx = cx.tcx;
451 let def = coroutine.def_id().internal(tables, tcx);
452 let args_ref = args.internal(tables, tcx);
453 cx.coroutine_discr_for_variant(def, args_ref, variant.internal(tables, tcx))
454 .stable(tables, cx)
455 })
463456 }
464457
465458 /// The name of a variant.
466459 pub(crate) fn variant_name(&self, def: VariantDef) -> Symbol {
467 let mut tables = self.tables.borrow_mut();
468 let cx = &*self.cx.borrow();
469 cx.variant_name(def.internal(&mut *tables, cx.tcx))
460 self.with_cx(|tables, cx| cx.variant_name(def.internal(tables, cx.tcx)))
470461 }
471462
472463 pub(crate) fn variant_fields(&self, def: VariantDef) -> Vec<FieldDef> {
473 let mut tables = self.tables.borrow_mut();
474 let cx = &*self.cx.borrow();
475 def.internal(&mut *tables, cx.tcx)
476 .fields
477 .iter()
478 .map(|f| f.stable(&mut *tables, cx))
479 .collect()
464 self.with_cx(|tables, cx| {
465 def.internal(tables, cx.tcx).fields.iter().map(|f| f.stable(tables, cx)).collect()
466 })
480467 }
481468
482469 /// Evaluate constant as a target usize.
483470 pub(crate) fn eval_target_usize(&self, mir_const: &MirConst) -> Result<u64, Error> {
484 let mut tables = self.tables.borrow_mut();
485 let cx = &*self.cx.borrow();
486 let cnst = mir_const.internal(&mut *tables, cx.tcx);
487 cx.eval_target_usize(cnst)
471 self.with_cx(|tables, cx| {
472 let cnst = mir_const.internal(tables, cx.tcx);
473 cx.eval_target_usize(cnst)
474 })
488475 }
489476
490477 pub(crate) fn eval_target_usize_ty(&self, ty_const: &TyConst) -> Result<u64, Error> {
491 let mut tables = self.tables.borrow_mut();
492 let cx = &*self.cx.borrow();
493 let cnst = ty_const.internal(&mut *tables, cx.tcx);
494 cx.eval_target_usize_ty(cnst)
478 self.with_cx(|tables, cx| {
479 let cnst = ty_const.internal(tables, cx.tcx);
480 cx.eval_target_usize_ty(cnst)
481 })
495482 }
496483
497484 /// Create a new zero-sized constant.
498485 pub(crate) fn try_new_const_zst(&self, ty: Ty) -> Result<MirConst, Error> {
499 let mut tables = self.tables.borrow_mut();
500 let cx = &*self.cx.borrow();
501 let ty_internal = ty.internal(&mut *tables, cx.tcx);
502 cx.try_new_const_zst(ty_internal).map(|cnst| cnst.stable(&mut *tables, cx))
486 self.with_cx(|tables, cx| {
487 let ty_internal = ty.internal(tables, cx.tcx);
488 cx.try_new_const_zst(ty_internal).map(|cnst| cnst.stable(tables, cx))
489 })
503490 }
504491
505492 /// Create a new constant that represents the given string value.
506493 pub(crate) fn new_const_str(&self, value: &str) -> MirConst {
507 let mut tables = self.tables.borrow_mut();
508 let cx = &*self.cx.borrow();
509 cx.new_const_str(value).stable(&mut *tables, cx)
494 self.with_cx(|tables, cx| cx.new_const_str(value).stable(tables, cx))
510495 }
511496
512497 /// Create a new constant that represents the given boolean value.
513498 pub(crate) fn new_const_bool(&self, value: bool) -> MirConst {
514 let mut tables = self.tables.borrow_mut();
515 let cx = &*self.cx.borrow();
516 cx.new_const_bool(value).stable(&mut *tables, cx)
499 self.with_cx(|tables, cx| cx.new_const_bool(value).stable(tables, cx))
517500 }
518501
519502 /// Create a new constant that represents the given value.
......@@ -522,10 +505,10 @@ impl<'tcx> CompilerInterface<'tcx> {
522505 value: u128,
523506 uint_ty: UintTy,
524507 ) -> Result<MirConst, Error> {
525 let mut tables = self.tables.borrow_mut();
526 let cx = &*self.cx.borrow();
527 let ty = cx.ty_new_uint(uint_ty.internal(&mut *tables, cx.tcx));
528 cx.try_new_const_uint(value, ty).map(|cnst| cnst.stable(&mut *tables, cx))
508 self.with_cx(|tables, cx| {
509 let ty = cx.ty_new_uint(uint_ty.internal(tables, cx.tcx));
510 cx.try_new_const_uint(value, ty).map(|cnst| cnst.stable(tables, cx))
511 })
529512 }
530513
531514 pub(crate) fn try_new_ty_const_uint(
......@@ -533,178 +516,170 @@ impl<'tcx> CompilerInterface<'tcx> {
533516 value: u128,
534517 uint_ty: UintTy,
535518 ) -> Result<TyConst, Error> {
536 let mut tables = self.tables.borrow_mut();
537 let cx = &*self.cx.borrow();
538 let ty = cx.ty_new_uint(uint_ty.internal(&mut *tables, cx.tcx));
539 cx.try_new_ty_const_uint(value, ty).map(|cnst| cnst.stable(&mut *tables, cx))
519 self.with_cx(|tables, cx| {
520 let ty = cx.ty_new_uint(uint_ty.internal(tables, cx.tcx));
521 cx.try_new_ty_const_uint(value, ty).map(|cnst| cnst.stable(tables, cx))
522 })
540523 }
541524
542525 /// Create a new type from the given kind.
543526 pub(crate) fn new_rigid_ty(&self, kind: RigidTy) -> Ty {
544 let mut tables = self.tables.borrow_mut();
545 let cx = &*self.cx.borrow();
546 let internal_kind = kind.internal(&mut *tables, cx.tcx);
547 cx.new_rigid_ty(internal_kind).stable(&mut *tables, cx)
527 self.with_cx(|tables, cx| {
528 let internal_kind = kind.internal(tables, cx.tcx);
529 cx.new_rigid_ty(internal_kind).stable(tables, cx)
530 })
548531 }
549532
550533 /// Create a new box type, `Box<T>`, for the given inner type `T`.
551534 pub(crate) fn new_box_ty(&self, ty: Ty) -> Ty {
552 let mut tables = self.tables.borrow_mut();
553 let cx = &*self.cx.borrow();
554 let inner = ty.internal(&mut *tables, cx.tcx);
555 cx.new_box_ty(inner).stable(&mut *tables, cx)
535 self.with_cx(|tables, cx| {
536 let inner = ty.internal(tables, cx.tcx);
537 cx.new_box_ty(inner).stable(tables, cx)
538 })
556539 }
557540
558541 /// Returns the type of given crate item.
559542 pub(crate) fn def_ty(&self, item: DefId) -> Ty {
560 let mut tables = self.tables.borrow_mut();
561 let cx = &*self.cx.borrow();
562 let inner = item.internal(&mut *tables, cx.tcx);
563 cx.def_ty(inner).stable(&mut *tables, cx)
543 self.with_cx(|tables, cx| {
544 let inner = item.internal(tables, cx.tcx);
545 cx.def_ty(inner).stable(tables, cx)
546 })
564547 }
565548
566549 /// Returns the type of given definition instantiated with the given arguments.
567550 pub(crate) fn def_ty_with_args(&self, item: DefId, args: &GenericArgs) -> Ty {
568 let mut tables = self.tables.borrow_mut();
569 let cx = &*self.cx.borrow();
570 let inner = item.internal(&mut *tables, cx.tcx);
571 let args_ref = args.internal(&mut *tables, cx.tcx);
572 cx.def_ty_with_args(inner, args_ref).stable(&mut *tables, cx)
551 self.with_cx(|tables, cx| {
552 let inner = item.internal(tables, cx.tcx);
553 let args_ref = args.internal(tables, cx.tcx);
554 cx.def_ty_with_args(inner, args_ref).stable(tables, cx)
555 })
573556 }
574557
575558 /// Returns literal value of a const as a string.
576559 pub(crate) fn mir_const_pretty(&self, cnst: &MirConst) -> String {
577 let mut tables = self.tables.borrow_mut();
578 let cx = &*self.cx.borrow();
579 cnst.internal(&mut *tables, cx.tcx).to_string()
560 self.with_cx(|tables, cx| cnst.internal(tables, cx.tcx).to_string())
580561 }
581562
582563 /// `Span` of a `DefId`.
583564 pub(crate) fn span_of_a_def(&self, def_id: DefId) -> Span {
584 let mut tables = self.tables.borrow_mut();
585 let cx = &*self.cx.borrow();
586 let did = tables[def_id];
587 cx.span_of_a_def(did).stable(&mut *tables, cx)
565 self.with_cx(|tables, cx| {
566 let did = tables[def_id];
567 cx.span_of_a_def(did).stable(tables, cx)
568 })
588569 }
589570
590571 pub(crate) fn ty_const_pretty(&self, ct: TyConstId) -> String {
591 let tables = self.tables.borrow_mut();
592 let cx = &*self.cx.borrow();
593 cx.ty_const_pretty(tables.ty_consts[ct])
572 self.with_cx(|tables, cx| cx.ty_const_pretty(tables.ty_consts[ct]))
594573 }
595574
596575 /// Obtain the representation of a type.
597576 pub(crate) fn ty_pretty(&self, ty: Ty) -> String {
598 let tables = self.tables.borrow_mut();
599 let cx = &*self.cx.borrow();
600 cx.ty_pretty(tables.types[ty])
577 self.with_cx(|tables, cx| cx.ty_pretty(tables.types[ty]))
601578 }
602579
603580 /// Obtain the kind of a type.
604581 pub(crate) fn ty_kind(&self, ty: Ty) -> TyKind {
605 let mut tables = self.tables.borrow_mut();
606 let cx = &*self.cx.borrow();
607 cx.ty_kind(tables.types[ty]).stable(&mut *tables, cx)
582 self.with_cx(|tables, cx| cx.ty_kind(tables.types[ty]).stable(tables, cx))
608583 }
609584
610585 /// Get the discriminant Ty for this Ty if there's one.
611586 pub(crate) fn rigid_ty_discriminant_ty(&self, ty: &RigidTy) -> Ty {
612 let mut tables = self.tables.borrow_mut();
613 let cx = &*self.cx.borrow();
614 let internal_kind = ty.internal(&mut *tables, cx.tcx);
615 cx.rigid_ty_discriminant_ty(internal_kind).stable(&mut *tables, cx)
587 self.with_cx(|tables, cx| {
588 let internal_kind = ty.internal(tables, cx.tcx);
589 cx.rigid_ty_discriminant_ty(internal_kind).stable(tables, cx)
590 })
616591 }
617592
618593 /// Get the body of an Instance which is already monomorphized.
619594 pub(crate) fn instance_body(&self, instance: InstanceDef) -> Option<Body> {
620 let mut tables = self.tables.borrow_mut();
621 let cx = &*self.cx.borrow();
622 let instance = tables.instances[instance];
623 cx.instance_body(instance).map(|body| body.stable(&mut *tables, cx))
595 self.with_cx(|tables, cx| {
596 let instance = tables.instances[instance];
597 cx.instance_body(instance).map(|body| body.stable(tables, cx))
598 })
624599 }
625600
626601 /// Get the instance type with generic instantiations applied and lifetimes erased.
627602 pub(crate) fn instance_ty(&self, instance: InstanceDef) -> Ty {
628 let mut tables = self.tables.borrow_mut();
629 let cx = &*self.cx.borrow();
630 let instance = tables.instances[instance];
631 cx.instance_ty(instance).stable(&mut *tables, cx)
603 self.with_cx(|tables, cx| {
604 let instance = tables.instances[instance];
605 cx.instance_ty(instance).stable(tables, cx)
606 })
632607 }
633608
634609 /// Get the instantiation types.
635610 pub(crate) fn instance_args(&self, def: InstanceDef) -> GenericArgs {
636 let mut tables = self.tables.borrow_mut();
637 let cx = &*self.cx.borrow();
638 let instance = tables.instances[def];
639 cx.instance_args(instance).stable(&mut *tables, cx)
611 self.with_cx(|tables, cx| {
612 let instance = tables.instances[def];
613 cx.instance_args(instance).stable(tables, cx)
614 })
640615 }
641616
642617 /// Get the instance.
643618 pub(crate) fn instance_def_id(&self, instance: InstanceDef) -> DefId {
644 let mut tables = self.tables.borrow_mut();
645 let cx = &*self.cx.borrow();
646 let instance = tables.instances[instance];
647 cx.instance_def_id(instance, &mut *tables)
619 self.with_cx(|tables, cx| {
620 let instance = tables.instances[instance];
621 cx.instance_def_id(instance, tables)
622 })
648623 }
649624
650625 /// Get the instance mangled name.
651626 pub(crate) fn instance_mangled_name(&self, instance: InstanceDef) -> Symbol {
652 let tables = self.tables.borrow_mut();
653 let cx = &*self.cx.borrow();
654 let instance = tables.instances[instance];
655 cx.instance_mangled_name(instance)
627 self.with_cx(|tables, cx| {
628 let instance = tables.instances[instance];
629 cx.instance_mangled_name(instance)
630 })
656631 }
657632
658633 /// Check if this is an empty DropGlue shim.
659634 pub(crate) fn is_empty_drop_shim(&self, def: InstanceDef) -> bool {
660 let tables = self.tables.borrow_mut();
661 let cx = &*self.cx.borrow();
662 let instance = tables.instances[def];
663 cx.is_empty_drop_shim(instance)
635 self.with_cx(|tables, cx| {
636 let instance = tables.instances[def];
637 cx.is_empty_drop_shim(instance)
638 })
664639 }
665640
666641 /// Convert a non-generic crate item into an instance.
667642 /// This function will panic if the item is generic.
668643 pub(crate) fn mono_instance(&self, def_id: DefId) -> Instance {
669 let mut tables = self.tables.borrow_mut();
670 let cx = &*self.cx.borrow();
671 let did = tables[def_id];
672 cx.mono_instance(did).stable(&mut *tables, cx)
644 self.with_cx(|tables, cx| {
645 let did = tables[def_id];
646 cx.mono_instance(did).stable(tables, cx)
647 })
673648 }
674649
675650 /// Item requires monomorphization.
676651 pub(crate) fn requires_monomorphization(&self, def_id: DefId) -> bool {
677 let tables = self.tables.borrow();
678 let cx = &*self.cx.borrow();
679 let did = tables[def_id];
680 cx.requires_monomorphization(did)
652 self.with_cx(|tables, cx| {
653 let did = tables[def_id];
654 cx.requires_monomorphization(did)
655 })
681656 }
682657
683658 /// Resolve an instance from the given function definition and generic arguments.
684659 pub(crate) fn resolve_instance(&self, def: FnDef, args: &GenericArgs) -> Option<Instance> {
685 let mut tables = self.tables.borrow_mut();
686 let cx = &*self.cx.borrow();
687 let def_id = def.0.internal(&mut *tables, cx.tcx);
688 let args_ref = args.internal(&mut *tables, cx.tcx);
689 cx.resolve_instance(def_id, args_ref).map(|inst| inst.stable(&mut *tables, cx))
660 self.with_cx(|tables, cx| {
661 let def_id = def.0.internal(tables, cx.tcx);
662 let args_ref = args.internal(tables, cx.tcx);
663 cx.resolve_instance(def_id, args_ref).map(|inst| inst.stable(tables, cx))
664 })
690665 }
691666
692667 /// Resolve an instance for drop_in_place for the given type.
693668 pub(crate) fn resolve_drop_in_place(&self, ty: Ty) -> Instance {
694 let mut tables = self.tables.borrow_mut();
695 let cx = &*self.cx.borrow();
696 let internal_ty = ty.internal(&mut *tables, cx.tcx);
669 self.with_cx(|tables, cx| {
670 let internal_ty = ty.internal(tables, cx.tcx);
697671
698 cx.resolve_drop_in_place(internal_ty).stable(&mut *tables, cx)
672 cx.resolve_drop_in_place(internal_ty).stable(tables, cx)
673 })
699674 }
700675
701676 /// Resolve instance for a function pointer.
702677 pub(crate) fn resolve_for_fn_ptr(&self, def: FnDef, args: &GenericArgs) -> Option<Instance> {
703 let mut tables = self.tables.borrow_mut();
704 let cx = &*self.cx.borrow();
705 let def_id = def.0.internal(&mut *tables, cx.tcx);
706 let args_ref = args.internal(&mut *tables, cx.tcx);
707 cx.resolve_for_fn_ptr(def_id, args_ref).stable(&mut *tables, cx)
678 self.with_cx(|tables, cx| {
679 let def_id = def.0.internal(tables, cx.tcx);
680 let args_ref = args.internal(tables, cx.tcx);
681 cx.resolve_for_fn_ptr(def_id, args_ref).stable(tables, cx)
682 })
708683 }
709684
710685 /// Resolve instance for a closure with the requested type.
......@@ -714,21 +689,21 @@ impl<'tcx> CompilerInterface<'tcx> {
714689 args: &GenericArgs,
715690 kind: ClosureKind,
716691 ) -> Option<Instance> {
717 let mut tables = self.tables.borrow_mut();
718 let cx = &*self.cx.borrow();
719 let def_id = def.0.internal(&mut *tables, cx.tcx);
720 let args_ref = args.internal(&mut *tables, cx.tcx);
721 let closure_kind = kind.internal(&mut *tables, cx.tcx);
722 cx.resolve_closure(def_id, args_ref, closure_kind).map(|inst| inst.stable(&mut *tables, cx))
692 self.with_cx(|tables, cx| {
693 let def_id = def.0.internal(tables, cx.tcx);
694 let args_ref = args.internal(tables, cx.tcx);
695 let closure_kind = kind.internal(tables, cx.tcx);
696 cx.resolve_closure(def_id, args_ref, closure_kind).map(|inst| inst.stable(tables, cx))
697 })
723698 }
724699
725700 /// Evaluate a static's initializer.
726701 pub(crate) fn eval_static_initializer(&self, def: StaticDef) -> Result<Allocation, Error> {
727 let mut tables = self.tables.borrow_mut();
728 let cx = &*self.cx.borrow();
729 let def_id = def.0.internal(&mut *tables, cx.tcx);
702 self.with_cx(|tables, cx| {
703 let def_id = def.0.internal(tables, cx.tcx);
730704
731 cx.eval_static_initializer(def_id).stable(&mut *tables, cx)
705 cx.eval_static_initializer(def_id).stable(tables, cx)
706 })
732707 }
733708
734709 /// Try to evaluate an instance into a constant.
......@@ -737,142 +712,133 @@ impl<'tcx> CompilerInterface<'tcx> {
737712 def: InstanceDef,
738713 const_ty: Ty,
739714 ) -> Result<Allocation, Error> {
740 let mut tables = self.tables.borrow_mut();
741 let instance = tables.instances[def];
742 let cx = &*self.cx.borrow();
743 let const_ty = const_ty.internal(&mut *tables, cx.tcx);
744 cx.eval_instance(instance)
745 .map(|const_val| alloc::try_new_allocation(const_ty, const_val, &mut *tables, cx))
746 .map_err(|e| e.stable(&mut *tables, cx))?
715 self.with_cx(|tables, cx| {
716 let instance = tables.instances[def];
717 let const_ty = const_ty.internal(tables, cx.tcx);
718 cx.eval_instance(instance)
719 .map(|const_val| alloc::try_new_allocation(const_ty, const_val, tables, cx))
720 .map_err(|e| e.stable(tables, cx))?
721 })
747722 }
748723
749724 /// Retrieve global allocation for the given allocation ID.
750725 pub(crate) fn global_alloc(&self, id: AllocId) -> GlobalAlloc {
751 let mut tables = self.tables.borrow_mut();
752 let cx = &*self.cx.borrow();
753 let alloc_id = id.internal(&mut *tables, cx.tcx);
754 cx.global_alloc(alloc_id).stable(&mut *tables, cx)
726 self.with_cx(|tables, cx| {
727 let alloc_id = id.internal(tables, cx.tcx);
728 cx.global_alloc(alloc_id).stable(tables, cx)
729 })
755730 }
756731
757732 /// Retrieve the id for the virtual table.
758733 pub(crate) fn vtable_allocation(&self, global_alloc: &GlobalAlloc) -> Option<AllocId> {
759 let mut tables = self.tables.borrow_mut();
760 let GlobalAlloc::VTable(ty, trait_ref) = global_alloc else {
761 return None;
762 };
763 let cx = &*self.cx.borrow();
764 let ty = ty.internal(&mut *tables, cx.tcx);
765 let trait_ref = trait_ref.internal(&mut *tables, cx.tcx);
766 let alloc_id = cx.vtable_allocation(ty, trait_ref);
767 Some(alloc_id.stable(&mut *tables, cx))
734 self.with_cx(|tables, cx| {
735 let GlobalAlloc::VTable(ty, trait_ref) = global_alloc else {
736 return None;
737 };
738 let ty = ty.internal(tables, cx.tcx);
739 let trait_ref = trait_ref.internal(tables, cx.tcx);
740 let alloc_id = cx.vtable_allocation(ty, trait_ref);
741 Some(alloc_id.stable(tables, cx))
742 })
768743 }
769744
770745 pub(crate) fn krate(&self, def_id: DefId) -> Crate {
771 let tables = self.tables.borrow();
772 let cx = &*self.cx.borrow();
773 smir_crate(cx, tables[def_id].krate)
746 self.with_cx(|tables, cx| smir_crate(cx, tables[def_id].krate))
774747 }
775748
776749 pub(crate) fn instance_name(&self, def: InstanceDef, trimmed: bool) -> Symbol {
777 let tables = self.tables.borrow_mut();
778 let cx = &*self.cx.borrow();
779 let instance = tables.instances[def];
780 cx.instance_name(instance, trimmed)
750 self.with_cx(|tables, cx| {
751 let instance = tables.instances[def];
752 cx.instance_name(instance, trimmed)
753 })
781754 }
782755
783756 /// Return information about the target machine.
784757 pub(crate) fn target_info(&self) -> MachineInfo {
785 let mut tables = self.tables.borrow_mut();
786 let cx = &*self.cx.borrow();
787 MachineInfo {
788 endian: cx.target_endian().stable(&mut *tables, cx),
758 self.with_cx(|tables, cx| MachineInfo {
759 endian: cx.target_endian().stable(tables, cx),
789760 pointer_width: MachineSize::from_bits(cx.target_pointer_size()),
790 }
761 })
791762 }
792763
793764 /// Get an instance ABI.
794765 pub(crate) fn instance_abi(&self, def: InstanceDef) -> Result<FnAbi, Error> {
795 let mut tables = self.tables.borrow_mut();
796 let cx = &*self.cx.borrow();
797 let instance = tables.instances[def];
798 cx.instance_abi(instance).map(|fn_abi| fn_abi.stable(&mut *tables, cx))
766 self.with_cx(|tables, cx| {
767 let instance = tables.instances[def];
768 cx.instance_abi(instance).map(|fn_abi| fn_abi.stable(tables, cx))
769 })
799770 }
800771
801772 /// Get the ABI of a function pointer.
802773 pub(crate) fn fn_ptr_abi(&self, fn_ptr: PolyFnSig) -> Result<FnAbi, Error> {
803 let mut tables = self.tables.borrow_mut();
804 let cx = &*self.cx.borrow();
805 let sig = fn_ptr.internal(&mut *tables, cx.tcx);
806 cx.fn_ptr_abi(sig).map(|fn_abi| fn_abi.stable(&mut *tables, cx))
774 self.with_cx(|tables, cx| {
775 let sig = fn_ptr.internal(tables, cx.tcx);
776 cx.fn_ptr_abi(sig).map(|fn_abi| fn_abi.stable(tables, cx))
777 })
807778 }
808779
809780 /// Get the layout of a type.
810781 pub(crate) fn ty_layout(&self, ty: Ty) -> Result<Layout, Error> {
811 let mut tables = self.tables.borrow_mut();
812 let cx = &*self.cx.borrow();
813 let internal_ty = ty.internal(&mut *tables, cx.tcx);
814 cx.ty_layout(internal_ty).map(|layout| layout.stable(&mut *tables, cx))
782 self.with_cx(|tables, cx| {
783 let internal_ty = ty.internal(tables, cx.tcx);
784 cx.ty_layout(internal_ty).map(|layout| layout.stable(tables, cx))
785 })
815786 }
816787
817788 /// Get the layout shape.
818789 pub(crate) fn layout_shape(&self, id: Layout) -> LayoutShape {
819 let mut tables = self.tables.borrow_mut();
820 let cx = &*self.cx.borrow();
821 id.internal(&mut *tables, cx.tcx).0.stable(&mut *tables, cx)
790 self.with_cx(|tables, cx| id.internal(tables, cx.tcx).0.stable(tables, cx))
822791 }
823792
824793 /// Get a debug string representation of a place.
825794 pub(crate) fn place_pretty(&self, place: &Place) -> String {
826 let mut tables = self.tables.borrow_mut();
827 let cx = &*self.cx.borrow();
828
829 format!("{:?}", place.internal(&mut *tables, cx.tcx))
795 self.with_cx(|tables, cx| format!("{:?}", place.internal(tables, cx.tcx)))
830796 }
831797
832798 /// Get the resulting type of binary operation.
833799 pub(crate) fn binop_ty(&self, bin_op: BinOp, rhs: Ty, lhs: Ty) -> Ty {
834 let mut tables = self.tables.borrow_mut();
835 let cx = &*self.cx.borrow();
836 let rhs_internal = rhs.internal(&mut *tables, cx.tcx);
837 let lhs_internal = lhs.internal(&mut *tables, cx.tcx);
838 let bin_op_internal = bin_op.internal(&mut *tables, cx.tcx);
839 cx.binop_ty(bin_op_internal, rhs_internal, lhs_internal).stable(&mut *tables, cx)
800 self.with_cx(|tables, cx| {
801 let rhs_internal = rhs.internal(tables, cx.tcx);
802 let lhs_internal = lhs.internal(tables, cx.tcx);
803 let bin_op_internal = bin_op.internal(tables, cx.tcx);
804 cx.binop_ty(bin_op_internal, rhs_internal, lhs_internal).stable(tables, cx)
805 })
840806 }
841807
842808 /// Get the resulting type of unary operation.
843809 pub(crate) fn unop_ty(&self, un_op: UnOp, arg: Ty) -> Ty {
844 let mut tables = self.tables.borrow_mut();
845 let cx = &*self.cx.borrow();
846 let un_op = un_op.internal(&mut *tables, cx.tcx);
847 let arg = arg.internal(&mut *tables, cx.tcx);
848 cx.unop_ty(un_op, arg).stable(&mut *tables, cx)
810 self.with_cx(|tables, cx| {
811 let un_op = un_op.internal(tables, cx.tcx);
812 let arg = arg.internal(tables, cx.tcx);
813 cx.unop_ty(un_op, arg).stable(tables, cx)
814 })
849815 }
850816
851817 /// Get all associated items of a definition.
852818 pub(crate) fn associated_items(&self, def_id: DefId) -> AssocItems {
853 let mut tables = self.tables.borrow_mut();
854 let cx = &*self.cx.borrow();
855 let did = tables[def_id];
856 cx.associated_items(did).iter().map(|assoc| assoc.stable(&mut *tables, cx)).collect()
819 self.with_cx(|tables, cx| {
820 let did = tables[def_id];
821 cx.associated_items(did).iter().map(|assoc| assoc.stable(tables, cx)).collect()
822 })
857823 }
858824
859825 /// Get all vtable entries of a trait.
860826 pub(crate) fn vtable_entries(&self, trait_ref: &TraitRef) -> Vec<VtblEntry> {
861 let mut tables = self.tables.borrow_mut();
862 let cx = &*self.cx.borrow();
863 cx.vtable_entries(trait_ref.internal(&mut *tables, cx.tcx))
864 .iter()
865 .map(|v| v.stable(&mut *tables, cx))
866 .collect()
827 self.with_cx(|tables, cx| {
828 cx.vtable_entries(trait_ref.internal(tables, cx.tcx))
829 .iter()
830 .map(|v| v.stable(tables, cx))
831 .collect()
832 })
867833 }
868834
869835 /// Returns the vtable entry at the given index.
870836 ///
871837 /// Returns `None` if the index is out of bounds.
872838 pub(crate) fn vtable_entry(&self, trait_ref: &TraitRef, idx: usize) -> Option<VtblEntry> {
873 let mut tables = self.tables.borrow_mut();
874 let cx = &*self.cx.borrow();
875 cx.vtable_entry(trait_ref.internal(&mut *tables, cx.tcx), idx).stable(&mut *tables, cx)
839 self.with_cx(|tables, cx| {
840 cx.vtable_entry(trait_ref.internal(tables, cx.tcx), idx).stable(tables, cx)
841 })
876842 }
877843}
878844
compiler/rustc_resolve/src/build_reduced_graph.rs+4-5
......@@ -52,7 +52,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
5252 decl: Decl<'ra>,
5353 ) {
5454 if let Err(old_decl) =
55 self.try_plant_decl_into_local_module(ident, orig_ident_span, ns, decl, false)
55 self.try_plant_decl_into_local_module(ident, orig_ident_span, ns, decl)
5656 {
5757 self.report_conflict(ident, ns, old_decl, decl);
5858 }
......@@ -87,13 +87,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
8787 vis: Visibility<DefId>,
8888 span: Span,
8989 expansion: LocalExpnId,
90 ambiguity: Option<Decl<'ra>>,
90 ambiguity: Option<(Decl<'ra>, bool)>,
9191 ) {
9292 let decl = self.arenas.alloc_decl(DeclData {
9393 kind: DeclKind::Def(res),
9494 ambiguity: CmCell::new(ambiguity),
95 // External ambiguities always report the `AMBIGUOUS_GLOB_IMPORTS` lint at the moment.
96 warn_ambiguity: CmCell::new(true),
9795 initial_vis: vis,
9896 ambiguity_vis_max: CmCell::new(None),
9997 ambiguity_vis_min: CmCell::new(None),
......@@ -392,7 +390,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
392390 let ModChild { ident: _, res, vis, ref reexport_chain } = *ambig_child;
393391 let span = child_span(self, reexport_chain, res);
394392 let res = res.expect_non_local();
395 self.arenas.new_def_decl(res, vis, span, expansion, Some(parent.to_module()))
393 // External ambiguities always report the `AMBIGUOUS_GLOB_IMPORTS` lint at the moment.
394 (self.arenas.new_def_decl(res, vis, span, expansion, Some(parent.to_module())), true)
396395 });
397396
398397 // Record primary definitions.
compiler/rustc_resolve/src/diagnostics.rs+1-1
......@@ -1188,7 +1188,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11881188 .emit()
11891189 }
11901190
1191 fn def_path_str(&self, mut def_id: DefId) -> String {
1191 pub(crate) fn def_path_str(&self, mut def_id: DefId) -> String {
11921192 // We can't use `def_path_str` in resolve.
11931193 let mut path = vec![def_id];
11941194 while let Some(parent) = self.tcx.opt_parent(def_id) {
compiler/rustc_resolve/src/imports.rs+108-84
......@@ -382,11 +382,9 @@ fn remove_same_import<'ra>(d1: Decl<'ra>, d2: Decl<'ra>) -> (Decl<'ra>, Decl<'ra
382382 assert_eq!(d1.span, d2.span);
383383 if d1.ambiguity.get() != d2.ambiguity.get() {
384384 assert!(d1.ambiguity.get().is_some());
385 assert!(d2.ambiguity.get().is_none());
386385 }
387386 // Visibility of the new import declaration may be different,
388387 // because it already incorporates the visibility of the source binding.
389 // `warn_ambiguity` of a re-fetched glob can also change in both directions.
390388 remove_same_import(d1_next, d2_next)
391389 } else {
392390 (d1, d2)
......@@ -450,7 +448,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
450448 self.arenas.alloc_decl(DeclData {
451449 kind: DeclKind::Import { source_decl: decl, import },
452450 ambiguity: CmCell::new(None),
453 warn_ambiguity: CmCell::new(false),
454451 span: import.span,
455452 initial_vis: vis.to_def_id(),
456453 ambiguity_vis_max: CmCell::new(None),
......@@ -460,14 +457,85 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
460457 })
461458 }
462459
460 fn is_noise_0_7_0(&self, old_glob_decl: Decl<'ra>, glob_decl: Decl<'ra>) -> bool {
461 let DeclKind::Import { import: i1, .. } = glob_decl.kind else { unreachable!() };
462 let DeclKind::Import { import: i2, .. } = old_glob_decl.kind else { unreachable!() };
463 let [seg1, seg2] = &i1.module_path[..] else { return false };
464 if seg1.ident.name != kw::SelfLower || seg2.ident.name.as_str() != "perlin_surflet" {
465 return false;
466 }
467 let [seg1, seg2] = &i2.module_path[..] else { return false };
468 if seg1.ident.name != kw::SelfLower || seg2.ident.name.as_str() != "perlin" {
469 return false;
470 }
471 let Some(def_id1) = glob_decl.res().opt_def_id() else { return false };
472 let Some(def_id2) = old_glob_decl.res().opt_def_id() else { return false };
473 self.def_path_str(def_id1).ends_with("noise_fns::generators::perlin_surflet::Perlin")
474 && self.def_path_str(def_id2).ends_with("noise_fns::generators::perlin::Perlin")
475 }
476
477 fn is_rustybuzz_0_4_0(&self, old_glob_decl: Decl<'ra>, glob_decl: Decl<'ra>) -> bool {
478 let DeclKind::Import { import: i1, .. } = glob_decl.kind else { unreachable!() };
479 let DeclKind::Import { import: i2, .. } = old_glob_decl.kind else { unreachable!() };
480 let [seg1, seg2] = &i1.module_path[..] else { return false };
481 if seg1.ident.name != kw::Super || seg2.ident.name.as_str() != "gsubgpos" {
482 return false;
483 }
484 let [seg1] = &i2.module_path[..] else { return false };
485 if seg1.ident.name != kw::Super {
486 return false;
487 }
488 let Some(def_id1) = glob_decl.res().opt_def_id() else { return false };
489 let Some(def_id2) = old_glob_decl.res().opt_def_id() else { return false };
490 self.def_path_str(def_id1).ends_with("tables::gsubgpos::Class")
491 && self.def_path_str(def_id2).ends_with("ggg::Class")
492 }
493
494 fn is_pdf_0_9_0(&self, old_glob_decl: Decl<'ra>, glob_decl: Decl<'ra>) -> bool {
495 let DeclKind::Import { import: i1, .. } = glob_decl.kind else { unreachable!() };
496 let DeclKind::Import { import: i2, .. } = old_glob_decl.kind else { unreachable!() };
497 let [seg1, seg2] = &i1.module_path[..] else { return false };
498 if seg1.ident.name != kw::Crate || seg2.ident.name.as_str() != "content" {
499 return false;
500 }
501 let [seg1, seg2] = &i2.module_path[..] else { return false };
502 if seg1.ident.name != kw::Crate || seg2.ident.name.as_str() != "object" {
503 return false;
504 }
505 let Some(def_id1) = glob_decl.res().opt_def_id() else { return false };
506 let Some(def_id2) = old_glob_decl.res().opt_def_id() else { return false };
507 self.def_path_str(def_id1).ends_with("crate::content::Rect")
508 && self.def_path_str(def_id2).ends_with("crate::object::types::Rect")
509 }
510
511 fn is_net2_0_2_39(&self, old_glob_decl: Decl<'ra>, glob_decl: Decl<'ra>) -> bool {
512 let DeclKind::Import { import: i1, .. } = glob_decl.kind else { unreachable!() };
513 let DeclKind::Import { import: i2, .. } = old_glob_decl.kind else { unreachable!() };
514 let [seg1, seg2, seg3, seg4] = &i1.module_path[..] else { return false };
515 if seg1.ident.name != kw::PathRoot
516 || seg2.ident.name.as_str() != "winapi"
517 || seg3.ident.name.as_str() != "shared"
518 || seg4.ident.name.as_str() != "ws2def"
519 {
520 return false;
521 }
522 let [seg1, seg2, seg3, seg4] = &i2.module_path[..] else { return false };
523 if seg1.ident.name != kw::PathRoot
524 || seg2.ident.name.as_str() != "winapi"
525 || seg3.ident.name.as_str() != "um"
526 || seg4.ident.name.as_str() != "winsock2"
527 {
528 return false;
529 }
530 let Some(def_id1) = glob_decl.res().opt_def_id() else { return false };
531 let Some(def_id2) = old_glob_decl.res().opt_def_id() else { return false };
532 self.def_path_str(def_id1).starts_with("winapi::shared::ws2def::")
533 && self.def_path_str(def_id2).starts_with("winapi::um::winsock2::")
534 }
535
463536 /// If `glob_decl` attempts to overwrite `old_glob_decl` in a module,
464537 /// decide which one to keep.
465 fn select_glob_decl(
466 &self,
467 old_glob_decl: Decl<'ra>,
468 glob_decl: Decl<'ra>,
469 warn_ambiguity: bool,
470 ) -> Decl<'ra> {
538 fn select_glob_decl(&self, old_glob_decl: Decl<'ra>, glob_decl: Decl<'ra>) -> Decl<'ra> {
471539 assert!(glob_decl.is_glob_import());
472540 assert!(old_glob_decl.is_glob_import());
473541 assert_ne!(glob_decl, old_glob_decl);
......@@ -476,9 +544,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
476544 // all these overwrites will be re-fetched by glob imports importing
477545 // from that module without generating new ambiguities.
478546 // - A glob decl is overwritten by a non-glob decl arriving later.
479 // - A glob decl is overwritten by its clone after setting ambiguity in it.
480 // FIXME: avoid this by removing `warn_ambiguity`, or by triggering glob re-fetch
481 // with the same decl in some way.
482547 // - A glob decl is overwritten by a glob decl re-fetching an
483548 // overwritten decl from other module (the recursive case).
484549 // Here we are detecting all such re-fetches and overwrite old decls
......@@ -489,29 +554,21 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
489554 if deep_decl != glob_decl {
490555 // Some import layers have been removed, need to overwrite.
491556 assert_ne!(old_deep_decl, old_glob_decl);
492 // FIXME: reenable the asserts when `warn_ambiguity` is removed (#149195).
493 // assert_ne!(old_deep_decl, deep_decl);
494 // assert!(old_deep_decl.is_glob_import());
495557 assert!(!deep_decl.is_glob_import());
496 if old_glob_decl.ambiguity.get().is_some() && glob_decl.ambiguity.get().is_none() {
558 if let Some((old_ambig, _)) = old_glob_decl.ambiguity.get()
559 && glob_decl.ambiguity.get().is_none()
560 {
497561 // Do not lose glob ambiguities when re-fetching the glob.
498 glob_decl.ambiguity.set_unchecked(old_glob_decl.ambiguity.get());
499 }
500 if glob_decl.is_ambiguity_recursive() {
501 glob_decl.warn_ambiguity.set_unchecked(true);
562 glob_decl.ambiguity.set_unchecked(Some((old_ambig, true)));
502563 }
503564 glob_decl
504565 } else if glob_decl.res() != old_glob_decl.res() {
505 old_glob_decl.ambiguity.set_unchecked(Some(glob_decl));
506 old_glob_decl.warn_ambiguity.set_unchecked(warn_ambiguity);
507 if warn_ambiguity {
508 old_glob_decl
509 } else {
510 // Need a fresh decl so other glob imports importing it could re-fetch it
511 // and set their own `warn_ambiguity` to true.
512 // FIXME: remove this when `warn_ambiguity` is removed (#149195).
513 self.arenas.alloc_decl((*old_glob_decl).clone())
514 }
566 let warning = self.is_noise_0_7_0(old_glob_decl, glob_decl)
567 || self.is_rustybuzz_0_4_0(old_glob_decl, glob_decl)
568 || self.is_pdf_0_9_0(old_glob_decl, glob_decl)
569 || self.is_net2_0_2_39(old_glob_decl, glob_decl);
570 old_glob_decl.ambiguity.set_unchecked(Some((glob_decl, warning)));
571 old_glob_decl
515572 } else if let old_vis = old_glob_decl.vis()
516573 && let vis = glob_decl.vis()
517574 && old_vis != vis
......@@ -529,8 +586,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
529586 old_glob_decl
530587 } else if glob_decl.is_ambiguity_recursive() && !old_glob_decl.is_ambiguity_recursive() {
531588 // Overwriting a non-ambiguous glob import with an ambiguous glob import.
532 old_glob_decl.ambiguity.set_unchecked(Some(glob_decl));
533 old_glob_decl.warn_ambiguity.set_unchecked(true);
589 old_glob_decl.ambiguity.set_unchecked(Some((glob_decl, true)));
534590 old_glob_decl
535591 } else {
536592 old_glob_decl
......@@ -545,9 +601,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
545601 orig_ident_span: Span,
546602 ns: Namespace,
547603 decl: Decl<'ra>,
548 warn_ambiguity: bool,
549604 ) -> Result<(), Decl<'ra>> {
550 assert!(!decl.warn_ambiguity.get());
551605 assert!(decl.ambiguity.get().is_none());
552606 assert!(decl.ambiguity_vis_max.get().is_none());
553607 assert!(decl.ambiguity_vis_min.get().is_none());
......@@ -562,31 +616,21 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
562616 module.underscore_disambiguator.update_unchecked(|d| d + 1);
563617 module.underscore_disambiguator.get()
564618 });
565 self.update_local_resolution(
566 module,
567 key,
568 orig_ident_span,
569 warn_ambiguity,
570 |this, resolution| {
571 if decl.is_glob_import() {
572 resolution.glob_decl = Some(match resolution.glob_decl {
573 Some(old_decl) => this.select_glob_decl(
574 old_decl,
575 decl,
576 warn_ambiguity && resolution.non_glob_decl.is_none(),
577 ),
578 None => decl,
579 })
580 } else {
581 resolution.non_glob_decl = Some(match resolution.non_glob_decl {
582 Some(old_decl) => return Err(old_decl),
583 None => decl,
584 })
585 }
619 self.update_local_resolution(module, key, orig_ident_span, |this, resolution| {
620 if decl.is_glob_import() {
621 resolution.glob_decl = Some(match resolution.glob_decl {
622 Some(old_decl) => this.select_glob_decl(old_decl, decl),
623 None => decl,
624 });
625 } else {
626 resolution.non_glob_decl = Some(match resolution.non_glob_decl {
627 Some(old_decl) => return Err(old_decl),
628 None => decl,
629 })
630 }
586631
587 Ok(())
588 },
589 )
632 Ok(())
633 })
590634 }
591635
592636 // Use `f` to mutate the resolution of the name in the module.
......@@ -596,7 +640,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
596640 module: LocalModule<'ra>,
597641 key: BindingKey,
598642 orig_ident_span: Span,
599 warn_ambiguity: bool,
600643 f: F,
601644 ) -> T
602645 where
......@@ -604,7 +647,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
604647 {
605648 // Ensure that `resolution` isn't borrowed when defining in the module's glob importers,
606649 // during which the resolution might end up getting re-defined via a glob cycle.
607 let (binding, t, warn_ambiguity) = {
650 let (binding, t) = {
608651 let resolution = &mut *self
609652 .resolution_or_default(module.to_module(), key, orig_ident_span)
610653 .borrow_mut_unchecked();
......@@ -616,7 +659,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
616659 if let Some(binding) = resolution.determined_decl()
617660 && (old_decl != Some(binding) || old_vis != Some(binding.vis()))
618661 {
619 (binding, t, warn_ambiguity || old_decl.is_some())
662 (binding, t)
620663 } else {
621664 return t;
622665 }
......@@ -639,14 +682,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
639682 };
640683 if self.is_accessible_from(binding.vis(), scope) {
641684 let import_decl = self.new_import_decl(binding, *import);
642 self.try_plant_decl_into_local_module(
643 ident,
644 orig_ident_span,
645 key.ns,
646 import_decl,
647 warn_ambiguity,
648 )
649 .expect("planting a glob cannot fail");
685 self.try_plant_decl_into_local_module(ident, orig_ident_span, key.ns, import_decl)
686 .expect("planting a glob cannot fail");
650687 }
651688 }
652689
......@@ -665,13 +702,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
665702 self.per_ns(|this, ns| {
666703 let ident = IdentKey::new(target);
667704 // This can fail, dummies are inserted only in non-occupied slots.
668 let _ = this.try_plant_decl_into_local_module(
669 ident,
670 target.span,
671 ns,
672 dummy_decl,
673 false,
674 );
705 let _ = this.try_plant_decl_into_local_module(ident, target.span, ns, dummy_decl);
675706 // Don't remove underscores from `single_imports`, they were never added.
676707 if target.name != kw::Underscore {
677708 let key = BindingKey::new(ident, ns);
......@@ -679,7 +710,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
679710 import.parent_scope.module.expect_local(),
680711 key,
681712 target.span,
682 false,
683713 |_, resolution| {
684714 resolution.single_imports.swap_remove(&import);
685715 },
......@@ -846,7 +876,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
846876 }
847877
848878 if let DeclKind::Import { import, .. } = binding.kind
849 && let Some(amb_binding) = binding.ambiguity.get()
879 && let Some((amb_binding, _)) = binding.ambiguity.get()
850880 && binding.res() != Res::Err
851881 && exported_ambiguities.contains(&binding)
852882 {
......@@ -1134,7 +1164,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11341164 parent.expect_local(),
11351165 key,
11361166 target.span,
1137 false,
11381167 |_, resolution| {
11391168 resolution.single_imports.swap_remove(&import);
11401169 },
......@@ -1820,16 +1849,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
18201849 };
18211850 if self.is_accessible_from(binding.vis(), scope) {
18221851 let import_decl = self.new_import_decl(binding, import);
1823 let warn_ambiguity = self
1824 .resolution(import.parent_scope.module, key)
1825 .and_then(|r| r.determined_decl())
1826 .is_some_and(|binding| binding.warn_ambiguity_recursive());
18271852 self.try_plant_decl_into_local_module(
18281853 key.ident,
18291854 orig_ident_span,
18301855 key.ns,
18311856 import_decl,
1832 warn_ambiguity,
18331857 )
18341858 .expect("planting a glob cannot fail");
18351859 }
compiler/rustc_resolve/src/late.rs+79-95
......@@ -27,7 +27,7 @@ use rustc_errors::{
2727use rustc_hir::def::Namespace::{self, *};
2828use rustc_hir::def::{CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS};
2929use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LOCAL_CRATE, LocalDefId};
30use rustc_hir::{MissingLifetimeKind, PrimTy, TraitCandidate};
30use rustc_hir::{MissingLifetimeKind, PrimTy};
3131use rustc_middle::middle::resolve_bound_vars::Set1;
3232use rustc_middle::ty::{AssocTag, DelegationInfo, Visibility};
3333use rustc_middle::{bug, span_bug};
......@@ -781,8 +781,7 @@ pub(crate) struct DiagMetadata<'ast> {
781781
782782 /// Accumulate the errors due to missed lifetime elision,
783783 /// and report them all at once for each function.
784 current_elision_failures:
785 Vec<(MissingLifetime, LifetimeElisionCandidate, Either<NodeId, Range<NodeId>>)>,
784 current_elision_failures: Vec<(MissingLifetime, Either<NodeId, Range<NodeId>>)>,
786785}
787786
788787struct LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
......@@ -1749,10 +1748,10 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
17491748 let ident = lifetime.ident;
17501749
17511750 if ident.name == kw::StaticLifetime {
1752 self.record_lifetime_res(
1751 self.record_lifetime_use(
17531752 lifetime.id,
17541753 LifetimeRes::Static,
1755 LifetimeElisionCandidate::Named,
1754 LifetimeElisionCandidate::Ignore,
17561755 );
17571756 return;
17581757 }
......@@ -1765,7 +1764,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
17651764 while let Some(rib) = lifetime_rib_iter.next() {
17661765 let normalized_ident = ident.normalize_to_macros_2_0();
17671766 if let Some(&(_, res)) = rib.bindings.get(&normalized_ident) {
1768 self.record_lifetime_res(lifetime.id, res, LifetimeElisionCandidate::Named);
1767 self.record_lifetime_use(lifetime.id, res, LifetimeElisionCandidate::Ignore);
17691768
17701769 if let LifetimeRes::Param { param, binder } = res {
17711770 match self.lifetime_uses.entry(param) {
......@@ -1831,20 +1830,12 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
18311830 LifetimeRibKind::Item => break,
18321831 LifetimeRibKind::ConstParamTy => {
18331832 let guar = self.emit_non_static_lt_in_const_param_ty_error(lifetime);
1834 self.record_lifetime_res(
1835 lifetime.id,
1836 LifetimeRes::Error(guar),
1837 LifetimeElisionCandidate::Ignore,
1838 );
1833 self.record_lifetime_err(lifetime.id, guar);
18391834 return;
18401835 }
18411836 LifetimeRibKind::ConcreteAnonConst(cause) => {
18421837 let guar = self.emit_forbidden_non_static_lifetime_error(cause, lifetime);
1843 self.record_lifetime_res(
1844 lifetime.id,
1845 LifetimeRes::Error(guar),
1846 LifetimeElisionCandidate::Ignore,
1847 );
1838 self.record_lifetime_err(lifetime.id, guar);
18481839 return;
18491840 }
18501841 LifetimeRibKind::AnonymousCreateParameter { .. }
......@@ -1862,11 +1853,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
18621853 .find_map(|rib| rib.bindings.get_key_value(&normalized_ident).map(|(&outer, _)| outer));
18631854
18641855 let guar = self.emit_undeclared_lifetime_error(lifetime, outer_res);
1865 self.record_lifetime_res(
1866 lifetime.id,
1867 LifetimeRes::Error(guar),
1868 LifetimeElisionCandidate::Named,
1869 );
1856 self.record_lifetime_err(lifetime.id, guar);
18701857 }
18711858
18721859 #[instrument(level = "debug", skip(self))]
......@@ -1893,7 +1880,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
18931880 match rib.kind {
18941881 LifetimeRibKind::AnonymousCreateParameter { binder, .. } => {
18951882 let res = self.create_fresh_lifetime(lifetime.ident, binder, kind);
1896 self.record_lifetime_res(lifetime.id, res, elision_candidate);
1883 self.record_lifetime_use(lifetime.id, res, elision_candidate);
18971884 return;
18981885 }
18991886 LifetimeRibKind::StaticIfNoLifetimeInScope { lint_id: node_id, emit_lint } => {
......@@ -1911,7 +1898,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
19111898 }
19121899 }
19131900 if lifetimes_in_scope.is_empty() {
1914 self.record_lifetime_res(
1901 self.record_lifetime_use(
19151902 lifetime.id,
19161903 LifetimeRes::Static,
19171904 elision_candidate,
......@@ -2015,23 +2002,17 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
20152002 span: lifetime.ident.span,
20162003 })
20172004 };
2018 self.record_lifetime_res(
2019 lifetime.id,
2020 LifetimeRes::Error(guar),
2021 elision_candidate,
2022 );
2005 self.record_lifetime_err(lifetime.id, guar);
20232006 return;
20242007 }
20252008 LifetimeRibKind::Elided(res) => {
2026 self.record_lifetime_res(lifetime.id, res, elision_candidate);
2009 self.record_lifetime_use(lifetime.id, res, elision_candidate);
20272010 return;
20282011 }
20292012 LifetimeRibKind::ElisionFailure => {
2030 self.diag_metadata.current_elision_failures.push((
2031 missing_lifetime,
2032 elision_candidate,
2033 Either::Left(lifetime.id),
2034 ));
2013 self.diag_metadata
2014 .current_elision_failures
2015 .push((missing_lifetime, Either::Left(lifetime.id)));
20352016 return;
20362017 }
20372018 LifetimeRibKind::Item => break,
......@@ -2045,7 +2026,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
20452026 }
20462027 }
20472028 let guar = self.report_missing_lifetime_specifiers([&missing_lifetime], None);
2048 self.record_lifetime_res(lifetime.id, LifetimeRes::Error(guar), elision_candidate);
2029 self.record_lifetime_err(lifetime.id, guar);
20492030 }
20502031
20512032 fn point_at_impl_lifetimes(&mut self, err: &mut Diag<'_>, i: usize, lifetime: Span) {
......@@ -2142,7 +2123,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
21422123 let id = self.r.next_node_id();
21432124 let lt = Lifetime { id, ident: Ident::new(kw::UnderscoreLifetime, span) };
21442125
2145 self.record_lifetime_res(
2126 self.record_lifetime_use(
21462127 anchor_id,
21472128 LifetimeRes::ElidedAnchor { start: id, end: id + 1 },
21482129 LifetimeElisionCandidate::Ignore,
......@@ -2162,15 +2143,15 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
21622143
21632144 // Leave the responsibility to create the `LocalDefId` to lowering.
21642145 let param = self.r.next_node_id();
2165 let res = LifetimeRes::Fresh { param, binder, kind };
2166 self.record_lifetime_param(param, res);
2146 let res = LifetimeRes::Fresh { param, kind };
2147 self.record_lifetime_def(param, res);
21672148
21682149 // Record the created lifetime parameter so lowering can pick it up and add it to HIR.
21692150 self.r
21702151 .extra_lifetime_params_map
21712152 .entry(binder)
21722153 .or_insert_with(Vec::new)
2173 .push((ident, param, res));
2154 .push((ident, param, kind));
21742155 res
21752156 }
21762157
......@@ -2226,7 +2207,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
22262207 }
22272208
22282209 let node_ids = self.r.next_node_ids(expected_lifetimes);
2229 self.record_lifetime_res(
2210 self.record_lifetime_use(
22302211 segment_id,
22312212 LifetimeRes::ElidedAnchor { start: node_ids.start, end: node_ids.end },
22322213 LifetimeElisionCandidate::Ignore,
......@@ -2252,10 +2233,10 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
22522233 // Do not create a parameter for patterns and expressions: type checking can infer
22532234 // the appropriate lifetime for us.
22542235 for id in node_ids {
2255 self.record_lifetime_res(
2236 self.record_lifetime_use(
22562237 id,
22572238 LifetimeRes::Infer,
2258 LifetimeElisionCandidate::Named,
2239 LifetimeElisionCandidate::Ignore,
22592240 );
22602241 }
22612242 continue;
......@@ -2311,11 +2292,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
23112292 should_lint = false;
23122293
23132294 for id in node_ids {
2314 self.record_lifetime_res(
2315 id,
2316 LifetimeRes::Error(guar),
2317 LifetimeElisionCandidate::Named,
2318 );
2295 self.record_lifetime_err(id, guar);
23192296 }
23202297 break;
23212298 }
......@@ -2325,10 +2302,10 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
23252302 let mut candidate = LifetimeElisionCandidate::Missing(missing_lifetime);
23262303 for id in node_ids {
23272304 let res = self.create_fresh_lifetime(ident, binder, kind);
2328 self.record_lifetime_res(
2305 self.record_lifetime_use(
23292306 id,
23302307 res,
2331 replace(&mut candidate, LifetimeElisionCandidate::Named),
2308 replace(&mut candidate, LifetimeElisionCandidate::Ignore),
23322309 );
23332310 }
23342311 break;
......@@ -2336,7 +2313,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
23362313 LifetimeRibKind::Elided(res) => {
23372314 let mut candidate = LifetimeElisionCandidate::Missing(missing_lifetime);
23382315 for id in node_ids {
2339 self.record_lifetime_res(
2316 self.record_lifetime_use(
23402317 id,
23412318 res,
23422319 replace(&mut candidate, LifetimeElisionCandidate::Ignore),
......@@ -2345,11 +2322,9 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
23452322 break;
23462323 }
23472324 LifetimeRibKind::ElisionFailure => {
2348 self.diag_metadata.current_elision_failures.push((
2349 missing_lifetime,
2350 LifetimeElisionCandidate::Ignore,
2351 Either::Right(node_ids),
2352 ));
2325 self.diag_metadata
2326 .current_elision_failures
2327 .push((missing_lifetime, Either::Right(node_ids)));
23532328 break;
23542329 }
23552330 // `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> {
23602335 let guar =
23612336 self.report_missing_lifetime_specifiers([&missing_lifetime], None);
23622337 for id in node_ids {
2363 self.record_lifetime_res(
2364 id,
2365 LifetimeRes::Error(guar),
2366 LifetimeElisionCandidate::Ignore,
2367 );
2338 self.record_lifetime_err(id, guar);
23682339 }
23692340 break;
23702341 }
......@@ -2405,16 +2376,15 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
24052376 }
24062377 }
24072378
2379 /// Register a use of an already defined lifetime.
24082380 #[instrument(level = "debug", skip(self))]
2409 fn record_lifetime_res(
2381 fn record_lifetime_use(
24102382 &mut self,
24112383 id: NodeId,
24122384 res: LifetimeRes,
24132385 candidate: LifetimeElisionCandidate,
24142386 ) {
2415 if let Some(prev_res) = self.r.lifetimes_res_map.insert(id, res) {
2416 panic!("lifetime {id:?} resolved multiple times ({prev_res:?} before, {res:?} now)")
2417 }
2387 self.record_lifetime_def(id, res);
24182388
24192389 match res {
24202390 LifetimeRes::Param { .. } | LifetimeRes::Fresh { .. } | LifetimeRes::Static { .. } => {
......@@ -2426,8 +2396,16 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
24262396 }
24272397 }
24282398
2399 /// Can be used for both definitions and uses of lifetimes, as an error
2400 /// has already been reported.
24292401 #[instrument(level = "debug", skip(self))]
2430 fn record_lifetime_param(&mut self, id: NodeId, res: LifetimeRes) {
2402 fn record_lifetime_err(&mut self, id: NodeId, guar: ErrorGuaranteed) {
2403 self.record_lifetime_def(id, LifetimeRes::Error(guar));
2404 }
2405
2406 /// Define a new lifetime (e.g. in generics)
2407 #[instrument(level = "debug", skip(self))]
2408 fn record_lifetime_def(&mut self, id: NodeId, res: LifetimeRes) {
24312409 if let Some(prev_res) = self.r.lifetimes_res_map.insert(id, res) {
24322410 panic!(
24332411 "lifetime parameter {id:?} resolved multiple times ({prev_res:?} before, {res:?} now)"
......@@ -2470,15 +2448,13 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
24702448 elision_failures.iter().map(|(missing_lifetime, ..)| missing_lifetime),
24712449 Some(failure_info),
24722450 );
2473 let mut record_res = |lifetime, candidate| {
2474 this.record_lifetime_res(lifetime, LifetimeRes::Error(guar), candidate)
2475 };
2476 for (_, candidate, nodes) in elision_failures {
2451 let mut record_res = |lifetime| this.record_lifetime_err(lifetime, guar);
2452 for (_, nodes) in elision_failures {
24772453 match nodes {
2478 Either::Left(node_id) => record_res(node_id, candidate),
2454 Either::Left(node_id) => record_res(node_id),
24792455 Either::Right(node_ids) => {
24802456 for lifetime in node_ids {
2481 record_res(lifetime, candidate)
2457 record_res(lifetime)
24822458 }
24832459 }
24842460 }
......@@ -2553,9 +2529,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
25532529 });
25542530 all_candidates.extend(candidates.into_iter().filter_map(|(_, candidate)| {
25552531 match candidate {
2556 LifetimeElisionCandidate::Ignore | LifetimeElisionCandidate::Named => {
2557 None
2558 }
2532 LifetimeElisionCandidate::Ignore => None,
25592533 LifetimeElisionCandidate::Missing(missing) => Some(missing),
25602534 }
25612535 }));
......@@ -3146,7 +3120,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
31463120 param.ident,
31473121 );
31483122 // Record lifetime res, so lowering knows there is something fishy.
3149 self.record_lifetime_param(param.id, LifetimeRes::Error(guar));
3123 self.record_lifetime_err(param.id, guar);
31503124 continue;
31513125 }
31523126
......@@ -3158,7 +3132,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
31583132 let rib = match param.kind {
31593133 GenericParamKind::Lifetime => {
31603134 // Record lifetime res, so lowering knows there is something fishy.
3161 self.record_lifetime_param(param.id, LifetimeRes::Error(guar));
3135 self.record_lifetime_err(param.id, guar);
31623136 continue;
31633137 }
31643138 GenericParamKind::Type { .. } => &mut function_type_rib,
......@@ -3193,7 +3167,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
31933167 .create_err(errors::UnderscoreLifetimeIsReserved { span: param.ident.span })
31943168 .emit_unless_delay(is_raw_underscore_lifetime);
31953169 // Record lifetime res, so lowering knows there is something fishy.
3196 self.record_lifetime_param(param.id, LifetimeRes::Error(guar));
3170 self.record_lifetime_err(param.id, guar);
31973171 continue;
31983172 }
31993173
......@@ -3203,7 +3177,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
32033177 lifetime: param.ident,
32043178 });
32053179 // Record lifetime res, so lowering knows there is something fishy.
3206 self.record_lifetime_param(param.id, LifetimeRes::Error(guar));
3180 self.record_lifetime_err(param.id, guar);
32073181 continue;
32083182 }
32093183
......@@ -3217,7 +3191,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
32173191 }
32183192 GenericParamKind::Lifetime => {
32193193 let res = LifetimeRes::Param { param: def_id, binder };
3220 self.record_lifetime_param(param.id, res);
3194 self.record_lifetime_def(param.id, res);
32213195 function_lifetime_rib.bindings.insert(ident, (param.id, res));
32223196 continue;
32233197 }
......@@ -3923,12 +3897,24 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
39233897 this.visit_path(&delegation.path);
39243898 });
39253899
3926 self.r.delegation_infos.insert(
3927 self.r.current_owner.def_id,
3928 DelegationInfo {
3929 resolution_node: if is_in_trait_impl { item_id } else { delegation.id },
3930 },
3931 );
3900 let resolution_id = if is_in_trait_impl { item_id } else { delegation.id };
3901 let def_id = self
3902 .r
3903 .partial_res_map
3904 .get(&resolution_id)
3905 .and_then(|r| r.expect_full_res().opt_def_id());
3906 if let Some(resolution_id) = def_id {
3907 self.r
3908 .delegation_infos
3909 .insert(self.r.current_owner.def_id, DelegationInfo { resolution_id });
3910 } else {
3911 self.r.tcx.dcx().span_delayed_bug(
3912 delegation.path.span,
3913 format!(
3914 "LoweringContext: couldn't resolve node {resolution_id:?} in delegation item",
3915 ),
3916 );
3917 };
39323918
39333919 let Some(body) = &delegation.body else { return };
39343920 self.with_rib(ValueNS, RibKind::FnOrCoroutine, |this| {
......@@ -4780,8 +4766,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
47804766 // it needs to be added to the trait map.
47814767 if ns == ValueNS {
47824768 let item_name = path.last().unwrap().ident;
4783 let traits = self.traits_in_scope(item_name, ns);
4784 self.r.trait_map.insert(node_id, traits);
4769 self.record_traits_in_scope(node_id, item_name);
47854770 }
47864771
47874772 if PrimTy::from_name(path[0].ident.name).is_some() {
......@@ -5382,13 +5367,11 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
53825367 // we need to add any trait methods we find that match the
53835368 // field name so that we can do some nice error reporting
53845369 // later on in typeck.
5385 let traits = self.traits_in_scope(ident, ValueNS);
5386 self.r.trait_map.insert(expr.id, traits);
5370 self.record_traits_in_scope(expr.id, ident);
53875371 }
53885372 ExprKind::MethodCall(ref call) => {
53895373 debug!("(recording candidate traits for expr) recording traits for {}", expr.id);
5390 let traits = self.traits_in_scope(call.seg.ident, ValueNS);
5391 self.r.trait_map.insert(expr.id, traits);
5374 self.record_traits_in_scope(expr.id, call.seg.ident);
53925375 }
53935376 _ => {
53945377 // Nothing to do.
......@@ -5396,13 +5379,14 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
53965379 }
53975380 }
53985381
5399 fn traits_in_scope(&mut self, ident: Ident, ns: Namespace) -> &'tcx [TraitCandidate<'tcx>] {
5400 self.r.traits_in_scope(
5382 fn record_traits_in_scope(&mut self, node_id: NodeId, ident: Ident) {
5383 let traits = self.r.traits_in_scope(
54015384 self.current_trait_ref.as_ref().map(|(module, _)| *module),
54025385 &self.parent_scope,
54035386 ident.span,
5404 Some((ident.name, ns)),
5405 )
5387 Some((ident.name, ValueNS)),
5388 );
5389 self.r.trait_map.insert(node_id, traits);
54065390 }
54075391
54085392 fn resolve_and_cache_rustdoc_path(&mut self, path_str: &str, ns: Namespace) -> Option<Res> {
compiler/rustc_resolve/src/late/diagnostics.rs+1-3
......@@ -149,10 +149,8 @@ pub(super) struct ElisionFnParameter {
149149/// This is used to suggest introducing an explicit lifetime.
150150#[derive(Clone, Copy, Debug)]
151151pub(super) enum LifetimeElisionCandidate {
152 /// This is not a real lifetime.
152 /// This is not a real lifetime, or it is a named lifetime, in which case we won't suggest anything.
153153 Ignore,
154 /// There is a named lifetime, we won't suggest anything.
155 Named,
156154 Missing(MissingLifetime),
157155}
158156
compiler/rustc_resolve/src/lib.rs+8-35
......@@ -58,7 +58,7 @@ use rustc_hir::def::{
5858};
5959use rustc_hir::def_id::{CRATE_DEF_ID, CrateNum, DefId, LOCAL_CRATE, LocalDefId, LocalDefIdMap};
6060use rustc_hir::definitions::{PerParentDisambiguatorState, PerParentDisambiguatorsMap};
61use rustc_hir::{PrimTy, TraitCandidate, find_attr};
61use rustc_hir::{MissingLifetimeKind, PrimTy, TraitCandidate, find_attr};
6262use rustc_index::bit_set::DenseBitSet;
6363use rustc_metadata::creader::CStore;
6464use rustc_middle::metadata::{AmbigModChild, ModChild, Reexport};
......@@ -822,7 +822,7 @@ impl<'ra> Module<'ra> {
822822 }
823823
824824 /// This modifies `self` in place. The traits will be stored in `self.traits`.
825 fn ensure_traits<'tcx>(self, resolver: &impl AsRef<Resolver<'ra, 'tcx>>) {
825 fn ensure_traits<'tcx>(self, resolver: &Resolver<'ra, 'tcx>) {
826826 let mut traits = self.traits.borrow_mut(resolver.as_ref());
827827 if traits.is_none() {
828828 let mut collected_traits = Vec::new();
......@@ -996,10 +996,7 @@ impl<'ra> fmt::Debug for LocalModule<'ra> {
996996#[derive(Clone, Debug)]
997997struct DeclData<'ra> {
998998 kind: DeclKind<'ra>,
999 ambiguity: CmCell<Option<Decl<'ra>>>,
1000 /// Produce a warning instead of an error when reporting ambiguities inside this binding.
1001 /// May apply to indirect ambiguities under imports, so `ambiguity.is_some()` is not required.
1002 warn_ambiguity: CmCell<bool>,
999 ambiguity: CmCell<Option<(Decl<'ra>, bool /*warning*/)>>,
10031000 expansion: LocalExpnId,
10041001 span: Span,
10051002 initial_vis: Visibility<DefId>,
......@@ -1160,7 +1157,7 @@ impl<'ra> DeclData<'ra> {
11601157
11611158 fn descent_to_ambiguity(self: Decl<'ra>) -> Option<(Decl<'ra>, Decl<'ra>)> {
11621159 match self.ambiguity.get() {
1163 Some(ambig_binding) => Some((self, ambig_binding)),
1160 Some((ambig_binding, _)) => Some((self, ambig_binding)),
11641161 None => match self.kind {
11651162 DeclKind::Import { source_decl, .. } => source_decl.descent_to_ambiguity(),
11661163 _ => None,
......@@ -1176,14 +1173,6 @@ impl<'ra> DeclData<'ra> {
11761173 }
11771174 }
11781175
1179 fn warn_ambiguity_recursive(&self) -> bool {
1180 self.warn_ambiguity.get()
1181 || match self.kind {
1182 DeclKind::Import { source_decl, .. } => source_decl.warn_ambiguity_recursive(),
1183 _ => false,
1184 }
1185 }
1186
11871176 fn is_possibly_imported_variant(&self) -> bool {
11881177 match self.kind {
11891178 DeclKind::Import { source_decl, .. } => source_decl.is_possibly_imported_variant(),
......@@ -1385,7 +1374,7 @@ pub struct Resolver<'ra, 'tcx> {
13851374 /// Resolutions for lifetimes.
13861375 lifetimes_res_map: NodeMap<LifetimeRes> = Default::default(),
13871376 /// Lifetime parameters that lowering will have to introduce.
1388 extra_lifetime_params_map: NodeMap<Vec<(Ident, NodeId, LifetimeRes)>> = Default::default(),
1377 extra_lifetime_params_map: NodeMap<Vec<(Ident, NodeId, MissingLifetimeKind)>> = Default::default(),
13891378
13901379 /// `CrateNum` resolutions of `extern crate` items.
13911380 extern_crate_map: UnordMap<LocalDefId, CrateNum> = Default::default(),
......@@ -1595,7 +1584,6 @@ impl<'ra> ResolverArenas<'ra> {
15951584 self.alloc_decl(DeclData {
15961585 kind: DeclKind::Def(res),
15971586 ambiguity: CmCell::new(None),
1598 warn_ambiguity: CmCell::new(false),
15991587 initial_vis: vis,
16001588 ambiguity_vis_max: CmCell::new(None),
16011589 ambiguity_vis_min: CmCell::new(None),
......@@ -2261,17 +2249,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
22612249 }
22622250
22632251 fn record_use(&mut self, ident: Ident, used_decl: Decl<'ra>, used: Used) {
2264 self.record_use_inner(ident, used_decl, used, used_decl.warn_ambiguity.get());
2265 }
2266
2267 fn record_use_inner(
2268 &mut self,
2269 ident: Ident,
2270 used_decl: Decl<'ra>,
2271 used: Used,
2272 warn_ambiguity: bool,
2273 ) {
2274 if let Some(b2) = used_decl.ambiguity.get() {
2252 if let Some((b2, warning)) = used_decl.ambiguity.get() {
22752253 let ambiguity_error = AmbiguityError {
22762254 kind: AmbiguityKind::GlobVsGlob,
22772255 ambig_vis: None,
......@@ -2280,7 +2258,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
22802258 b2,
22812259 scope1: Scope::ModuleGlobs(used_decl.parent_module.unwrap(), None),
22822260 scope2: Scope::ModuleGlobs(b2.parent_module.unwrap(), None),
2283 warning: if warn_ambiguity { Some(AmbiguityWarning::GlobImport) } else { None },
2261 warning: if warning { Some(AmbiguityWarning::GlobImport) } else { None },
22842262 };
22852263 if !self.matches_previous_ambiguity_error(&ambiguity_error) {
22862264 // avoid duplicated span information to be emit out
......@@ -2330,12 +2308,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
23302308 self.used_imports.insert(id);
23312309 }
23322310 self.add_to_glob_map(import, ident.name);
2333 self.record_use_inner(
2334 ident,
2335 source_decl,
2336 Used::Other,
2337 warn_ambiguity || source_decl.warn_ambiguity.get(),
2338 );
2311 self.record_use(ident, source_decl, Used::Other);
23392312 }
23402313 }
23412314
compiler/rustc_span/src/symbol.rs+1
......@@ -600,6 +600,7 @@ symbols! {
600600 cfi,
601601 cfi_encoding,
602602 char,
603 clflushopt_target_feature,
603604 client,
604605 clippy,
605606 clobber_abi,
compiler/rustc_target/src/spec/mod.rs+23-28
......@@ -132,8 +132,6 @@ pub enum LinkerFlavor {
132132 // Below: other linker-like tools with unique interfaces for exotic targets.
133133 /// Linker tool for BPF.
134134 Bpf,
135 /// Linker tool for Nvidia PTX.
136 Ptx,
137135 /// LLVM bitcode linker that can be used as a `self-contained` linker
138136 Llbc,
139137}
......@@ -153,7 +151,6 @@ pub enum LinkerFlavorCli {
153151 Msvc(Lld),
154152 EmCc,
155153 Bpf,
156 Ptx,
157154 Llbc,
158155
159156 // Legacy stable values
......@@ -174,8 +171,7 @@ impl LinkerFlavorCli {
174171 | LinkerFlavorCli::Msvc(Lld::Yes)
175172 | LinkerFlavorCli::EmCc
176173 | LinkerFlavorCli::Bpf
177 | LinkerFlavorCli::Llbc
178 | LinkerFlavorCli::Ptx => true,
174 | LinkerFlavorCli::Llbc => true,
179175 LinkerFlavorCli::Gcc
180176 | LinkerFlavorCli::Ld
181177 | LinkerFlavorCli::Lld(..)
......@@ -211,7 +207,6 @@ impl LinkerFlavor {
211207 LinkerFlavorCli::EmCc => LinkerFlavor::EmCc,
212208 LinkerFlavorCli::Bpf => LinkerFlavor::Bpf,
213209 LinkerFlavorCli::Llbc => LinkerFlavor::Llbc,
214 LinkerFlavorCli::Ptx => LinkerFlavor::Ptx,
215210
216211 // Below: legacy stable values
217212 LinkerFlavorCli::Gcc => match lld_flavor {
......@@ -251,7 +246,6 @@ impl LinkerFlavor {
251246 LinkerFlavor::EmCc => LinkerFlavorCli::Em,
252247 LinkerFlavor::Bpf => LinkerFlavorCli::Bpf,
253248 LinkerFlavor::Llbc => LinkerFlavorCli::Llbc,
254 LinkerFlavor::Ptx => LinkerFlavorCli::Ptx,
255249 }
256250 }
257251
......@@ -266,7 +260,6 @@ impl LinkerFlavor {
266260 LinkerFlavor::EmCc => LinkerFlavorCli::EmCc,
267261 LinkerFlavor::Bpf => LinkerFlavorCli::Bpf,
268262 LinkerFlavor::Llbc => LinkerFlavorCli::Llbc,
269 LinkerFlavor::Ptx => LinkerFlavorCli::Ptx,
270263 }
271264 }
272265
......@@ -279,7 +272,7 @@ impl LinkerFlavor {
279272 LinkerFlavorCli::Unix(cc) => (Some(cc), None),
280273 LinkerFlavorCli::Msvc(lld) => (Some(Cc::No), Some(lld)),
281274 LinkerFlavorCli::EmCc => (Some(Cc::Yes), Some(Lld::Yes)),
282 LinkerFlavorCli::Bpf | LinkerFlavorCli::Ptx => (None, None),
275 LinkerFlavorCli::Bpf => (None, None),
283276 LinkerFlavorCli::Llbc => (None, None),
284277
285278 // Below: legacy stable values
......@@ -336,7 +329,7 @@ impl LinkerFlavor {
336329 LinkerFlavor::WasmLld(cc) => LinkerFlavor::WasmLld(cc_hint.unwrap_or(cc)),
337330 LinkerFlavor::Unix(cc) => LinkerFlavor::Unix(cc_hint.unwrap_or(cc)),
338331 LinkerFlavor::Msvc(lld) => LinkerFlavor::Msvc(lld_hint.unwrap_or(lld)),
339 LinkerFlavor::EmCc | LinkerFlavor::Bpf | LinkerFlavor::Llbc | LinkerFlavor::Ptx => self,
332 LinkerFlavor::EmCc | LinkerFlavor::Bpf | LinkerFlavor::Llbc => self,
340333 }
341334 }
342335
......@@ -355,7 +348,7 @@ impl LinkerFlavor {
355348 let compatible = |cli| {
356349 // The CLI flavor should be compatible with the target if:
357350 match (self, cli) {
358 // 1. they are counterparts: they have the same principal flavor.
351 // they are counterparts: they have the same principal flavor.
359352 (LinkerFlavor::Gnu(..), LinkerFlavorCli::Gnu(..))
360353 | (LinkerFlavor::Darwin(..), LinkerFlavorCli::Darwin(..))
361354 | (LinkerFlavor::WasmLld(..), LinkerFlavorCli::WasmLld(..))
......@@ -363,10 +356,7 @@ impl LinkerFlavor {
363356 | (LinkerFlavor::Msvc(..), LinkerFlavorCli::Msvc(..))
364357 | (LinkerFlavor::EmCc, LinkerFlavorCli::EmCc)
365358 | (LinkerFlavor::Bpf, LinkerFlavorCli::Bpf)
366 | (LinkerFlavor::Llbc, LinkerFlavorCli::Llbc)
367 | (LinkerFlavor::Ptx, LinkerFlavorCli::Ptx) => return true,
368 // 2. The linker flavor is independent of target and compatible
369 (LinkerFlavor::Ptx, LinkerFlavorCli::Llbc) => return true,
359 | (LinkerFlavor::Llbc, LinkerFlavorCli::Llbc) => return true,
370360 _ => {}
371361 }
372362
......@@ -389,8 +379,7 @@ impl LinkerFlavor {
389379 | LinkerFlavor::Unix(..)
390380 | LinkerFlavor::EmCc
391381 | LinkerFlavor::Bpf
392 | LinkerFlavor::Llbc
393 | LinkerFlavor::Ptx => LldFlavor::Ld,
382 | LinkerFlavor::Llbc => LldFlavor::Ld,
394383 LinkerFlavor::Darwin(..) => LldFlavor::Ld64,
395384 LinkerFlavor::WasmLld(..) => LldFlavor::Wasm,
396385 LinkerFlavor::Msvc(..) => LldFlavor::Link,
......@@ -415,8 +404,7 @@ impl LinkerFlavor {
415404 | LinkerFlavor::Msvc(_)
416405 | LinkerFlavor::Unix(_)
417406 | LinkerFlavor::Bpf
418 | LinkerFlavor::Llbc
419 | LinkerFlavor::Ptx => false,
407 | LinkerFlavor::Llbc => false,
420408 }
421409 }
422410
......@@ -435,8 +423,7 @@ impl LinkerFlavor {
435423 | LinkerFlavor::Msvc(_)
436424 | LinkerFlavor::Unix(_)
437425 | LinkerFlavor::Bpf
438 | LinkerFlavor::Llbc
439 | LinkerFlavor::Ptx => false,
426 | LinkerFlavor::Llbc => false,
440427 }
441428 }
442429
......@@ -512,7 +499,6 @@ linker_flavor_cli_impls! {
512499 (LinkerFlavorCli::EmCc) "em-cc"
513500 (LinkerFlavorCli::Bpf) "bpf"
514501 (LinkerFlavorCli::Llbc) "llbc"
515 (LinkerFlavorCli::Ptx) "ptx"
516502
517503 // Legacy stable flavors
518504 (LinkerFlavorCli::Gcc) "gcc"
......@@ -2740,8 +2726,7 @@ fn add_link_args_iter(
27402726 | LinkerFlavor::Unix(..)
27412727 | LinkerFlavor::EmCc
27422728 | LinkerFlavor::Bpf
2743 | LinkerFlavor::Llbc
2744 | LinkerFlavor::Ptx => {}
2729 | LinkerFlavor::Llbc => {}
27452730 }
27462731}
27472732
......@@ -3127,10 +3112,7 @@ impl Target {
31273112 "mixing MSVC and non-MSVC linker flavors"
31283113 );
31293114 }
3130 LinkerFlavor::EmCc
3131 | LinkerFlavor::Bpf
3132 | LinkerFlavor::Ptx
3133 | LinkerFlavor::Llbc => {
3115 LinkerFlavor::EmCc | LinkerFlavor::Bpf | LinkerFlavor::Llbc => {
31343116 check_eq!(flavor, self.linker_flavor, "mixing different linker flavors")
31353117 }
31363118 }
......@@ -3582,6 +3564,19 @@ impl Target {
35823564 "invalid `target_abi` for CSky"
35833565 );
35843566 }
3567 Arch::Wasm32 | Arch::Wasm64 => {
3568 check!(
3569 self.llvm_abiname == LlvmAbi::Unspecified,
3570 "`llvm_abiname` is unused on wasm"
3571 );
3572 check!(self.llvm_floatabi.is_none(), "`llvm_floatabi` is unused on wasm");
3573 check!(self.rustc_abi.is_none(), "`rustc_abi` is unused on wasm");
3574 check_matches!(
3575 self.cfg_abi,
3576 CfgAbi::Unspecified | CfgAbi::Other(_),
3577 "invalid `target_abi` for wasm"
3578 );
3579 }
35853580 ref arch => {
35863581 check!(self.rustc_abi.is_none(), "`rustc_abi` is unused on {arch}");
35873582 // Ensure consistency among built-in targets, but give JSON targets the opportunity
compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs-1
......@@ -21,7 +21,6 @@ pub(crate) fn target() -> Target {
2121 vendor: "nvidia".into(),
2222 linker_flavor: LinkerFlavor::Llbc,
2323
24 // With `ptx-linker` approach, it can be later overridden via link flags.
2524 cpu: "sm_70".into(),
2625
2726 // No longer supported architectures
compiler/rustc_target/src/target_features.rs+7
......@@ -464,6 +464,7 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
464464 ("avxvnniint16", Stable, &["avx2"]),
465465 ("bmi1", Stable, &[]),
466466 ("bmi2", Stable, &[]),
467 ("clflushopt", Unstable(sym::clflushopt_target_feature), &[]),
467468 ("cmpxchg16b", Stable, &[]),
468469 ("ermsb", Unstable(sym::ermsb_target_feature), &[]),
469470 ("f16c", Stable, &["avx"]),
......@@ -1312,11 +1313,17 @@ impl Target {
13121313 }
13131314 }
13141315 Arch::Avr => {
1316 // We only support one ABI on AVR at the moment.
13151317 // SRAM is minimum requirement for C/C++ in both avr-gcc and Clang,
13161318 // and backends of them only support assembly for devices have no SRAM.
13171319 // See the discussion in https://github.com/rust-lang/rust/pull/146900 for more.
13181320 FeatureConstraints { required: &["sram"], incompatible: &[] }
13191321 }
1322 Arch::Wasm32 | Arch::Wasm64 => {
1323 // We only support one ABI on wasm at the moment.
1324 // No ABI-relevant target features have been identified thus far.
1325 NOTHING
1326 }
13201327 _ => NOTHING,
13211328 }
13221329 }
library/core/src/intrinsics/mod.rs+1
......@@ -3569,6 +3569,7 @@ pub const fn offload<F, T: crate::marker::Tuple, R>(
35693569 f: F,
35703570 workgroup_dim: [u32; 3],
35713571 thread_dim: [u32; 3],
3572 dyn_cache: u32,
35723573 args: T,
35733574) -> R;
35743575
library/proc_macro/src/bridge/client.rs+23-39
......@@ -2,19 +2,9 @@
22
33use std::cell::RefCell;
44use std::marker::PhantomData;
5use std::sync::atomic::AtomicU32;
65
76use super::*;
87
9#[repr(C)]
10pub(super) struct HandleCounters {
11 pub(super) token_stream: AtomicU32,
12 pub(super) span: AtomicU32,
13}
14
15static COUNTERS: HandleCounters =
16 HandleCounters { token_stream: AtomicU32::new(1), span: AtomicU32::new(1) };
17
188pub(crate) struct TokenStream {
199 handle: handle::Handle,
2010}
......@@ -47,6 +37,18 @@ impl<S> Decode<'_, '_, S> for TokenStream {
4737 }
4838}
4939
40impl Encode<()> for crate::TokenStream {
41 fn encode(self, w: &mut Buffer, s: &mut ()) {
42 self.0.encode(w, s)
43 }
44}
45
46impl Decode<'_, '_, ()> for crate::TokenStream {
47 fn decode(r: &mut &[u8], s: &mut ()) -> Self {
48 crate::TokenStream(Some(Decode::decode(r, s)))
49 }
50}
51
5052#[derive(Copy, Clone, PartialEq, Eq, Hash)]
5153pub(crate) struct Span {
5254 handle: handle::Handle,
......@@ -209,8 +211,6 @@ pub(crate) fn is_available() -> bool {
209211/// and forcing the use of APIs that take/return `S::TokenStream`, server-side.
210212#[repr(C)]
211213pub struct Client<I, O> {
212 pub(super) handle_counters: &'static HandleCounters,
213
214214 pub(super) run: extern "C" fn(BridgeConfig<'_>) -> Buffer,
215215
216216 pub(super) _marker: PhantomData<fn(I) -> O>,
......@@ -243,14 +243,13 @@ fn maybe_install_panic_hook(force_show_panics: bool) {
243243
244244/// Client-side helper for handling client panics, entering the bridge,
245245/// deserializing input and serializing output.
246// FIXME(eddyb) maybe replace `Bridge::enter` with this?
247fn run_client<A: for<'a, 's> Decode<'a, 's, ()>, R: Encode<()>>(
246fn run_client<A: for<'a, 's> Decode<'a, 's, ()>>(
248247 config: BridgeConfig<'_>,
249 f: impl FnOnce(A) -> R,
248 f: impl FnOnce(A) -> crate::TokenStream,
250249) -> Buffer {
251250 let BridgeConfig { input: mut buf, dispatch, force_show_panics, .. } = config;
252251
253 panic::catch_unwind(panic::AssertUnwindSafe(|| {
252 let res = panic::catch_unwind(panic::AssertUnwindSafe(|| {
254253 maybe_install_panic_hook(force_show_panics);
255254
256255 // Make sure the symbol store is empty before decoding inputs.
......@@ -267,23 +266,12 @@ fn run_client<A: for<'a, 's> Decode<'a, 's, ()>, R: Encode<()>>(
267266 // Take the `cached_buffer` back out, for the output value.
268267 buf = RefCell::into_inner(state).cached_buffer;
269268
270 // HACK(eddyb) Separate encoding a success value (`Ok(output)`)
271 // from encoding a panic (`Err(e: PanicMessage)`) to avoid
272 // having handles outside the `bridge.enter(|| ...)` scope, and
273 // to catch panics that could happen while encoding the success.
274 //
275 // Note that panics should be impossible beyond this point, but
276 // this is defensively trying to avoid any accidental panicking
277 // reaching the `extern "C"` (which should `abort` but might not
278 // at the moment, so this is also potentially preventing UB).
279 buf.clear();
280 Ok::<_, ()>(output).encode(&mut buf, &mut ());
281 }))
282 .map_err(PanicMessage::from)
283 .unwrap_or_else(|e| {
284 buf.clear();
285 Err::<(), _>(e).encode(&mut buf, &mut ());
286 });
269 output
270 }));
271
272 // Serialize response of type `Result<R, PanicMessage>`.
273 buf.clear();
274 res.map_err(PanicMessage::from).encode(&mut buf, &mut ());
287275
288276 // Now that a response has been serialized, invalidate all symbols
289277 // registered with the interner.
......@@ -294,9 +282,8 @@ fn run_client<A: for<'a, 's> Decode<'a, 's, ()>, R: Encode<()>>(
294282impl Client<crate::TokenStream, crate::TokenStream> {
295283 pub const fn expand1(f: impl Fn(crate::TokenStream) -> crate::TokenStream + Copy) -> Self {
296284 Client {
297 handle_counters: &COUNTERS,
298285 run: super::selfless_reify::reify_to_extern_c_fn_hrt_bridge(move |bridge| {
299 run_client(bridge, |input| f(crate::TokenStream(Some(input))).0)
286 run_client(bridge, |input| f(input))
300287 }),
301288 _marker: PhantomData,
302289 }
......@@ -308,11 +295,8 @@ impl Client<(crate::TokenStream, crate::TokenStream), crate::TokenStream> {
308295 f: impl Fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream + Copy,
309296 ) -> Self {
310297 Client {
311 handle_counters: &COUNTERS,
312298 run: super::selfless_reify::reify_to_extern_c_fn_hrt_bridge(move |bridge| {
313 run_client(bridge, |(input, input2)| {
314 f(crate::TokenStream(Some(input)), crate::TokenStream(Some(input2))).0
315 })
299 run_client(bridge, |(input, input2)| f(input, input2))
316300 }),
317301 _marker: PhantomData,
318302 }
library/proc_macro/src/bridge/rpc.rs+15-5
......@@ -15,20 +15,30 @@ pub(super) trait Decode<'a, 's, S>: Sized {
1515}
1616
1717macro_rules! rpc_encode_decode {
18 (le $ty:ty) => {
18 (le $ty:ident $size:literal) => {
1919 impl<S> Encode<S> for $ty {
2020 fn encode(self, w: &mut Buffer, _: &mut S) {
21 w.extend_from_array(&self.to_le_bytes());
21 const N: usize = size_of::<$ty>();
22
23 // We can pad with zeros without changing the value because of
24 // little endian encoding.
25 let mut bytes = [0; $size];
26 bytes[..N].copy_from_slice(&self.to_le_bytes());
27
28 w.extend_from_array(&bytes);
2229 }
2330 }
2431
2532 impl<S> Decode<'_, '_, S> for $ty {
2633 fn decode(r: &mut &[u8], _: &mut S) -> Self {
2734 const N: usize = size_of::<$ty>();
35 const {
36 assert!(N <= $size);
37 }
2838
2939 let mut bytes = [0; N];
3040 bytes.copy_from_slice(&r[..N]);
31 *r = &r[N..];
41 *r = &r[$size..];
3242
3343 Self::from_le_bytes(bytes)
3444 }
......@@ -108,8 +118,8 @@ impl<S> Decode<'_, '_, S> for u8 {
108118 }
109119}
110120
111rpc_encode_decode!(le u32);
112rpc_encode_decode!(le usize);
121rpc_encode_decode!(le u32 4);
122rpc_encode_decode!(le usize 8);
113123
114124impl<S> Encode<S> for bool {
115125 fn encode(self, w: &mut Buffer, s: &mut S) {
library/proc_macro/src/bridge/server.rs+12-17
......@@ -1,6 +1,7 @@
11//! Server-side traits.
22
33use std::cell::Cell;
4use std::sync::atomic::AtomicU32;
45use std::sync::mpsc;
56
67use super::*;
......@@ -11,10 +12,13 @@ pub(super) struct HandleStore<S: Server> {
1112}
1213
1314impl<S: Server> HandleStore<S> {
14 fn new(handle_counters: &'static client::HandleCounters) -> Self {
15 fn new() -> Self {
16 static TOKEN_STREAM: AtomicU32 = AtomicU32::new(1);
17 static SPAN: AtomicU32 = AtomicU32::new(1);
18
1519 HandleStore {
16 token_stream: handle::OwnedStore::new(&handle_counters.token_stream),
17 span: handle::InternedStore::new(&handle_counters.span),
20 token_stream: handle::OwnedStore::new(&TOKEN_STREAM),
21 span: handle::InternedStore::new(&SPAN),
1822 }
1923 }
2024}
......@@ -246,13 +250,12 @@ fn run_server<
246250 O: for<'a, 's> Decode<'a, 's, HandleStore<S>>,
247251>(
248252 strategy: &impl ExecutionStrategy,
249 handle_counters: &'static client::HandleCounters,
250253 server: S,
251254 input: I,
252255 run_client: extern "C" fn(BridgeConfig<'_>) -> Buffer,
253256 force_show_panics: bool,
254257) -> Result<O, PanicMessage> {
255 let mut dispatcher = Dispatcher { handle_store: HandleStore::new(handle_counters), server };
258 let mut dispatcher = Dispatcher { handle_store: HandleStore::new(), server };
256259
257260 let globals = dispatcher.server.globals();
258261
......@@ -276,16 +279,9 @@ impl client::Client<crate::TokenStream, crate::TokenStream> {
276279 where
277280 S: Server,
278281 {
279 let client::Client { handle_counters, run, _marker } = *self;
280 run_server(
281 strategy,
282 handle_counters,
283 server,
284 <MarkedTokenStream<S>>::mark(input),
285 run,
286 force_show_panics,
287 )
288 .map(|s| <Option<MarkedTokenStream<S>>>::unmark(s).unwrap_or_default())
282 let client::Client { run, _marker } = *self;
283 run_server(strategy, server, <MarkedTokenStream<S>>::mark(input), run, force_show_panics)
284 .map(|s| <Option<MarkedTokenStream<S>>>::unmark(s).unwrap_or_default())
289285 }
290286}
291287
......@@ -301,10 +297,9 @@ impl client::Client<(crate::TokenStream, crate::TokenStream), crate::TokenStream
301297 where
302298 S: Server,
303299 {
304 let client::Client { handle_counters, run, _marker } = *self;
300 let client::Client { run, _marker } = *self;
305301 run_server(
306302 strategy,
307 handle_counters,
308303 server,
309304 (<MarkedTokenStream<S>>::mark(input), <MarkedTokenStream<S>>::mark(input2)),
310305 run,
library/std/src/path.rs+1-2
......@@ -2854,7 +2854,6 @@ impl Path {
28542854 /// # Examples
28552855 ///
28562856 /// ```
2857 /// #![feature(path_is_empty)]
28582857 /// use std::path::Path;
28592858 ///
28602859 /// let path = Path::new("");
......@@ -2866,7 +2865,7 @@ impl Path {
28662865 /// let path = Path::new(".");
28672866 /// assert!(!path.is_empty());
28682867 /// ```
2869 #[unstable(feature = "path_is_empty", issue = "148494")]
2868 #[stable(feature = "path_is_empty", since = "CURRENT_RUSTC_VERSION")]
28702869 pub fn is_empty(&self) -> bool {
28712870 self.as_os_str().is_empty()
28722871 }
library/std_detect/src/detect/arch/x86.rs+3
......@@ -106,6 +106,7 @@ features! {
106106 /// * `"xsaves"`
107107 /// * `"xsavec"`
108108 /// * `"cmpxchg16b"`
109 /// * `"clflushopt"`
109110 /// * `"kl"`
110111 /// * `"widekl"`
111112 /// * `"adx"`
......@@ -261,6 +262,8 @@ features! {
261262 /// XSAVEC (Save Processor Extended States Compacted)
262263 @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] cmpxchg16b: "cmpxchg16b";
263264 /// CMPXCH16B (16-byte compare-and-swap instruction)
265 @FEATURE: #[unstable(feature = "clflushopt_target_feature", issue = "157096")] clflushopt: "clflushopt";
266 /// CLFLUSHOPT (Cache Line Flush Optimized)
264267 @FEATURE: #[stable(feature = "keylocker_x86", since = "1.89.0")] kl: "kl";
265268 /// Intel Key Locker
266269 @FEATURE: #[stable(feature = "keylocker_x86", since = "1.89.0")] widekl: "widekl";
library/std_detect/src/detect/os/x86.rs+2
......@@ -127,6 +127,8 @@ pub(crate) fn detect_features() -> cache::Initializer {
127127
128128 enable(extended_features_ebx, 9, Feature::ermsb);
129129
130 enable(extended_features_ebx, 23, Feature::clflushopt);
131
130132 enable(extended_features_eax_leaf_1, 31, Feature::movrs);
131133
132134 // Detect if CPUID.19h available
library/std_detect/tests/x86-specific.rs+8-1
......@@ -1,6 +1,12 @@
11#![cfg(any(target_arch = "x86", target_arch = "x86_64"))]
22#![allow(internal_features)]
3#![feature(stdarch_internal, x86_amx_intrinsics, xop_target_feature, movrs_target_feature)]
3#![feature(
4 stdarch_internal,
5 x86_amx_intrinsics,
6 xop_target_feature,
7 movrs_target_feature,
8 clflushopt_target_feature
9)]
410
511#[macro_use]
612extern crate std_detect;
......@@ -58,6 +64,7 @@ fn dump() {
5864 println!("xsaves: {:?}", is_x86_feature_detected!("xsaves"));
5965 println!("xsavec: {:?}", is_x86_feature_detected!("xsavec"));
6066 println!("cmpxchg16b: {:?}", is_x86_feature_detected!("cmpxchg16b"));
67 println!("clflushopt: {:?}", is_x86_feature_detected!("clflushopt"));
6168 println!("adx: {:?}", is_x86_feature_detected!("adx"));
6269 println!("rtm: {:?}", is_x86_feature_detected!("rtm"));
6370 println!("movbe: {:?}", is_x86_feature_detected!("movbe"));
src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md+1-1
......@@ -6,7 +6,7 @@ Freestanding x86-64 linux binary with no dependency on libc.
66
77## Target maintainers
88
9[@morr0ne](https://github.com/morr0ne)
9[@rosymati](https://github.com/rosymati)
1010
1111## Requirements
1212
src/doc/unstable-book/src/compiler-flags/codegen-options.md-2
......@@ -7,8 +7,6 @@ unstable-options` to be accepted.
77## linker-flavor
88
99In addition to the stable set of linker flavors, the following unstable values also exist:
10- `ptx`: use [`rust-ptx-linker`](https://github.com/denzp/rust-ptx-linker)
11 for Nvidia NVPTX GPGPU support.
1210- `bpf`: use [`bpf-linker`](https://github.com/alessandrod/bpf-linker) for eBPF support.
1311- `llbc`: for linking in llvm bitcode. Install the preview rustup components`llvm-bitcode-linker`
1412 and `llvm-tools` to use as a self-contained linker by passing
src/tools/compiletest/src/runtest/assembly.rs+1-2
......@@ -23,7 +23,7 @@ impl TestCx<'_> {
2323
2424 fn compile_test_and_save_assembly(&self) -> (ProcRes, Utf8PathBuf) {
2525 // This works with both `--emit asm` (as default output name for the assembly)
26 // and `ptx-linker` because the latter can write output at requested location.
26 // and `llvm-bitcode-linker` because the latter can write output at requested location.
2727 let output_path = self.output_base_name().with_extension("s");
2828 let input_file = &self.testpaths.file;
2929
......@@ -31,7 +31,6 @@ impl TestCx<'_> {
3131 let emit = match self.props.assembly_output.as_deref() {
3232 Some("emit-asm") => Emit::Asm,
3333 Some("bpf-linker") => Emit::LinkArgsAsm,
34 Some("ptx-linker") => Emit::None, // No extra flags needed.
3534 Some(other) => self.fatal(&format!("unknown 'assembly-output' directive: {other}")),
3635 None => self.fatal("missing 'assembly-output' directive"),
3736 };
tests/assembly-llvm/nvptx-arch-default.rs+2-2
......@@ -1,4 +1,4 @@
1//@ assembly-output: ptx-linker
1//@ assembly-output: emit-asm
22//@ compile-flags: --crate-type cdylib
33//@ only-nvptx64
44
......@@ -7,7 +7,7 @@
77//@ aux-build: breakpoint-panic-handler.rs
88extern crate breakpoint_panic_handler;
99
10// Verify default target arch with ptx-linker.
10// Verify default arch with llvm-bitcode-linker.
1111// CHECK: .version 7.0
1212// CHECK: .target sm_70
1313// CHECK: .address_size 64
tests/assembly-llvm/nvptx-arch-emit-asm.rs+1-1
......@@ -4,7 +4,7 @@
44
55#![no_std]
66
7// Verify default arch without ptx-linker involved.
7// Verify default arch without llvm-bitcode-linker involved.
88// CHECK: .version 7.0
99// CHECK: .target sm_70
1010// CHECK: .address_size 64
tests/assembly-llvm/nvptx-arch-link-arg.rs deleted-13
......@@ -1,13 +0,0 @@
1//@ assembly-output: ptx-linker
2//@ compile-flags: --crate-type cdylib -C link-arg=--arch=sm_60
3//@ only-nvptx64
4//@ ignore-nvptx64
5
6#![no_std]
7
8//@ aux-build: breakpoint-panic-handler.rs
9extern crate breakpoint_panic_handler;
10
11// Verify target arch override via `link-arg`.
12// CHECK: .target sm_60
13// CHECK: .address_size 64
tests/assembly-llvm/nvptx-arch-target-cpu.rs+1-1
......@@ -1,4 +1,4 @@
1//@ assembly-output: ptx-linker
1//@ assembly-output: emit-asm
22//@ compile-flags: --crate-type cdylib -C target-cpu=sm_87
33//@ only-nvptx64
44
tests/assembly-llvm/nvptx-atomics.rs+1-1
......@@ -1,4 +1,4 @@
1//@ assembly-output: ptx-linker
1//@ assembly-output: emit-asm
22//@ compile-flags: --crate-type cdylib
33//@ only-nvptx64
44//@ ignore-nvptx64
tests/assembly-llvm/nvptx-c-abi-arg-v7.rs+1-1
......@@ -1,4 +1,4 @@
1//@ assembly-output: ptx-linker
1//@ assembly-output: emit-asm
22//@ compile-flags: --crate-type cdylib -C target-cpu=sm_86
33//@ only-nvptx64
44
tests/assembly-llvm/nvptx-c-abi-ret-v7.rs+1-1
......@@ -1,4 +1,4 @@
1//@ assembly-output: ptx-linker
1//@ assembly-output: emit-asm
22//@ compile-flags: --crate-type cdylib -C target-cpu=sm_86
33//@ only-nvptx64
44
tests/assembly-llvm/nvptx-internalizing.rs+1-2
......@@ -1,7 +1,6 @@
1//@ assembly-output: ptx-linker
1//@ assembly-output: emit-asm
22//@ compile-flags: --crate-type cdylib
33//@ only-nvptx64
4//@ ignore-nvptx64
54
65#![feature(abi_ptx)]
76#![no_std]
tests/assembly-llvm/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs+1-1
......@@ -1,4 +1,4 @@
1//@ assembly-output: ptx-linker
1//@ assembly-output: emit-asm
22//@ compile-flags: --crate-type cdylib -C target-cpu=sm_86
33//@ only-nvptx64
44
tests/assembly-llvm/nvptx-linking-binary.rs+1-1
......@@ -1,4 +1,4 @@
1//@ assembly-output: ptx-linker
1//@ assembly-output: emit-asm
22//@ compile-flags: --crate-type bin
33//@ only-nvptx64
44//@ ignore-nvptx64
tests/assembly-llvm/nvptx-linking-cdylib.rs+1-1
......@@ -1,4 +1,4 @@
1//@ assembly-output: ptx-linker
1//@ assembly-output: emit-asm
22//@ compile-flags: --crate-type cdylib
33//@ only-nvptx64
44//@ ignore-nvptx64
tests/assembly-llvm/nvptx-safe-naming.rs+1-1
......@@ -1,4 +1,4 @@
1//@ assembly-output: ptx-linker
1//@ assembly-output: emit-asm
22//@ compile-flags: --crate-type cdylib
33//@ only-nvptx64
44
tests/codegen-llvm/gpu_offload/control_flow.rs+2-1
......@@ -19,7 +19,7 @@
1919// CHECK-NOT define
2020// CHECK: bb3
2121// 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)
22// 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)
22// 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)
2323// 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)
2424#[unsafe(no_mangle)]
2525unsafe fn main() {
......@@ -30,6 +30,7 @@ unsafe fn main() {
3030 foo,
3131 [256, 1, 1],
3232 [32, 1, 1],
33 0,
3334 (A.as_ptr() as *const [f32; 6],),
3435 );
3536 }
tests/codegen-llvm/gpu_offload/gpu_host.rs+5-5
......@@ -21,7 +21,7 @@ fn main() {
2121}
2222
2323pub fn kernel_1(x: &mut [f32; 256], y: &[f32; 256]) {
24 core::intrinsics::offload(_kernel_1, [256, 1, 1], [32, 1, 1], (x, y))
24 core::intrinsics::offload(_kernel_1, [256, 1, 1], [32, 1, 1], 0, (x, y))
2525}
2626
2727#[inline(never)]
......@@ -52,8 +52,8 @@ pub fn _kernel_1(x: &mut [f32; 256], y: &[f32; 256]) {
5252
5353// CHECK-LABEL: define{{( dso_local)?}} void @main()
5454// CHECK-NEXT: start:
55// CHECK-NEXT: %0 = alloca [8 x i8], align 8
56// CHECK-NEXT: %1 = alloca [8 x i8], align 8
55// CHECK-NEXT: {{%[^ ]+}} = alloca [8 x i8], align 8
56// CHECK-NEXT: {{%[^ ]+}} = alloca [8 x i8], align 8
5757// CHECK-NEXT: %y = alloca [1024 x i8], align 16
5858// CHECK-NEXT: %x = alloca [1024 x i8], align 16
5959// 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]) {
6161// CHECK-NEXT: %kernel_args = alloca %struct.__tgt_kernel_arguments, align 8
6262// CHECK: store ptr %x, ptr %.offload_baseptrs, align 8
6363// CHECK-NEXT: store ptr %x, ptr %.offload_ptrs, align 8
64// CHECK-NEXT: [[BPTRS_1:%.*]] = getelementptr inbounds nuw i8, ptr %.offload_baseptrs, i64 8
64// CHECK-NEXT: [[BPTRS_1:%[^ ]+]] = getelementptr inbounds nuw i8, ptr %.offload_baseptrs, i64 8
6565// CHECK-NEXT: store ptr %y, ptr [[BPTRS_1]], align 8
66// CHECK-NEXT: [[PTRS_1:%.*]] = getelementptr inbounds nuw i8, ptr %.offload_ptrs, i64 8
66// CHECK-NEXT: [[PTRS_1:%[^ ]+]] = getelementptr inbounds nuw i8, ptr %.offload_ptrs, i64 8
6767// CHECK-NEXT: store ptr %y, ptr [[PTRS_1]], align 8
6868// 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)
6969// CHECK-NEXT: store i32 3, ptr %kernel_args, align 8
tests/codegen-llvm/gpu_offload/scalar_host.rs+5-5
......@@ -13,11 +13,11 @@
1313// CHECK: define{{( dso_local)?}} void @main()
1414// CHECK-NOT: define
1515// CHECK: %addr = alloca i64, align 8
16// CHECK: store double 4.200000e+01, ptr %0, align 8
17// CHECK: %_0.i = load double, ptr %0, align 8
18// CHECK: store double %_0.i, ptr %addr, align 8
16// CHECK: store double 4.200000e+01, ptr [[TMP:%[^,]+]], align 8
17// CHECK: [[VAL:%[0-9]+]] = load double, ptr [[TMP]], align 8
18// CHECK: store double [[VAL]], ptr %addr, align 8
1919// CHECK: %1 = getelementptr inbounds nuw i8, ptr %.offload_baseptrs, i64 8
20// CHECK-NEXT: store double %_0.i, ptr %1, align 8
20// CHECK-NEXT: store double [[VAL]], ptr %1, align 8
2121// CHECK-NEXT: %2 = getelementptr inbounds nuw i8, ptr %.offload_ptrs, i64 8
2222// CHECK-NEXT: store ptr %addr, ptr %2, align 8
2323// CHECK-NEXT: call void @__tgt_target_data_begin_mapper
......@@ -27,7 +27,7 @@ fn main() {
2727 let mut x = 0.0;
2828 let k = core::hint::black_box(42.0);
2929
30 core::intrinsics::offload::<_, _, ()>(foo, [1, 1, 1], [1, 1, 1], (&mut x, k));
30 core::intrinsics::offload::<_, _, ()>(foo, [1, 1, 1], [1, 1, 1], 0, (&mut x, k));
3131}
3232
3333unsafe extern "C" {
tests/codegen-llvm/gpu_offload/slice_host.rs+2-2
......@@ -21,13 +21,13 @@
2121// CHECK: call void @llvm.memcpy.p0.p0.i64(ptr {{.*}} %.offload_sizes, ptr {{.*}} @.offload_sizes.foo, i64 16, i1 false)
2222// CHECK: store i64 16, ptr %.offload_sizes, align 8
2323// 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)
24// 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)
24// 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)
2525// 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)
2626
2727#[unsafe(no_mangle)]
2828fn main() {
2929 let mut x = [0.0, 0.0, 0.0, 0.0];
30 core::intrinsics::offload::<_, _, ()>(foo, [1, 1, 1], [1, 1, 1], ((&mut x) as &mut [f64],));
30 core::intrinsics::offload::<_, _, ()>(foo, [1, 1, 1], [1, 1, 1], 0, ((&mut x) as &mut [f64],));
3131}
3232
3333unsafe extern "C" {
tests/ui/check-cfg/target_feature.stderr+1
......@@ -65,6 +65,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
6565`bulk-memory`
6666`c`
6767`cache`
68`clflushopt`
6869`cmpxchg16b`
6970`concurrent-functions`
7071`crc`
tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs+1-1
......@@ -1,6 +1,6 @@
11//@ edition:2021
2
32//@ check-pass
3//@ ignore-parallel-frontend unstable liveness diagnostics
44#![allow(unreachable_code)]
55#![warn(unused)]
66#![allow(dead_code)]
tests/ui/deprecation/deprecation-sanity.rs+3
......@@ -23,6 +23,9 @@ mod bogus_attribute_types_1 {
2323
2424 #[deprecated("test")] //~ ERROR malformed `deprecated` attribute input [E0565]
2525 fn f8() { }
26
27 #[deprecated("1.2.3")] //~ ERROR malformed `deprecated` attribute input [E0565]
28 fn f9() { }
2629}
2730
2831#[deprecated(since = "a", note = "b")]
tests/ui/deprecation/deprecation-sanity.stderr+24-5
......@@ -55,21 +55,40 @@ LL | #[deprecated("test")]
5555 | ^^^^^^^^^^^^^------^^
5656 | |
5757 | didn't expect a literal here
58 |
59help: try using `=` instead
60 |
61LL - #[deprecated("test")]
62LL + #[deprecated = "test"]
63 |
64
65error[E0565]: malformed `deprecated` attribute input
66 --> $DIR/deprecation-sanity.rs:27:5
67 |
68LL | #[deprecated("1.2.3")]
69 | ^^^^^^^^^^^^^-------^^
70 | |
71 | didn't expect a literal here
72 |
73help: try specifying a deprecated since version
74 |
75LL | #[deprecated(since = "1.2.3")]
76 | +++++++
5877
5978error: multiple `deprecated` attributes
60 --> $DIR/deprecation-sanity.rs:29:1
79 --> $DIR/deprecation-sanity.rs:32:1
6180 |
6281LL | #[deprecated(since = "a", note = "b")]
6382 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
6483 |
6584note: attribute also specified here
66 --> $DIR/deprecation-sanity.rs:28:1
85 --> $DIR/deprecation-sanity.rs:31:1
6786 |
6887LL | #[deprecated(since = "a", note = "b")]
6988 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7089
7190error[E0538]: malformed `deprecated` attribute input
72 --> $DIR/deprecation-sanity.rs:32:1
91 --> $DIR/deprecation-sanity.rs:35:1
7392 |
7493LL | #[deprecated(since = "a", since = "b", note = "c")]
7594 | ^^^^^^^^^^^^^^^^^^^^^^^^^^-----------^^^^^^^^^^^^^^
......@@ -77,7 +96,7 @@ LL | #[deprecated(since = "a", since = "b", note = "c")]
7796 | found `since` used as a key more than once
7897
7998error: `#[deprecated]` attribute cannot be used on trait impl blocks
80 --> $DIR/deprecation-sanity.rs:37:1
99 --> $DIR/deprecation-sanity.rs:40:1
81100 |
82101LL | #[deprecated = "hello"]
83102 | ^^^^^^^^^^^^^^^^^^^^^^^
......@@ -86,7 +105,7 @@ LL | #[deprecated = "hello"]
86105 = 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
87106 = note: `#[deny(useless_deprecated)]` on by default
88107
89error: aborting due to 10 previous errors
108error: aborting due to 11 previous errors
90109
91110Some errors have detailed explanations: E0538, E0539, E0565.
92111For more information about an error, try `rustc --explain E0538`.
tests/ui/error-codes/E0565-1.stderr+6
......@@ -5,6 +5,12 @@ LL | #[deprecated("since")]
55 | ^^^^^^^^^^^^^-------^^
66 | |
77 | didn't expect a literal here
8 |
9help: try using `=` instead
10 |
11LL - #[deprecated("since")]
12LL + #[deprecated = "since"]
13 |
814
915error: aborting due to 1 previous error
1016
tests/ui/feature-gates/feature-gate-clflushopt_target_feature.rs created+6
......@@ -0,0 +1,6 @@
1//@ only-x86_64
2#[target_feature(enable = "clflushopt")]
3//~^ ERROR: currently unstable
4unsafe fn foo() {}
5
6fn main() {}
tests/ui/feature-gates/feature-gate-clflushopt_target_feature.stderr created+13
......@@ -0,0 +1,13 @@
1error[E0658]: the target feature `clflushopt` is currently unstable
2 --> $DIR/feature-gate-clflushopt_target_feature.rs:2:18
3 |
4LL | #[target_feature(enable = "clflushopt")]
5 | ^^^^^^^^^^^^^^^^^^^^^
6 |
7 = note: see issue #157096 <https://github.com/rust-lang/rust/issues/157096> for more information
8 = help: add `#![feature(clflushopt_target_feature)]` to the crate attributes to enable
9 = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10
11error: aborting due to 1 previous error
12
13For more information about this error, try `rustc --explain E0658`.
tests/ui/imports/ambiguous-1.rs+1-5
......@@ -1,8 +1,5 @@
1//@ check-pass
21// https://github.com/rust-lang/rust/pull/112743#issuecomment-1601986883
32
4#![warn(ambiguous_glob_imports)]
5
63macro_rules! m {
74 () => {
85 pub fn id() {}
......@@ -27,6 +24,5 @@ pub use openssl::*;
2724
2825fn main() {
2926 id();
30 //~^ WARNING `id` is ambiguous
31 //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
27 //~^ ERROR `id` is ambiguous
3228}
tests/ui/imports/ambiguous-1.stderr+13-47
......@@ -1,68 +1,34 @@
1warning: ambiguous glob re-exports
2 --> $DIR/ambiguous-1.rs:13:13
3 |
4LL | pub use self::evp::*;
5 | ^^^^^^^^^^^^ the name `id` in the value namespace is first re-exported here
6LL |
7LL | pub use self::handwritten::*;
8 | -------------------- but the name `id` in the value namespace is also re-exported here
9 |
10 = note: `#[warn(ambiguous_glob_reexports)]` on by default
11
12warning: `id` is ambiguous
13 --> $DIR/ambiguous-1.rs:29:5
1error[E0659]: `id` is ambiguous
2 --> $DIR/ambiguous-1.rs:26:5
143 |
154LL | id();
165 | ^^ ambiguous name
176 |
187 = note: ambiguous because of multiple glob imports of a name in the same module
198note: `id` could refer to the function imported here
20 --> $DIR/ambiguous-1.rs:13:13
9 --> $DIR/ambiguous-1.rs:10:13
2110 |
2211LL | pub use self::evp::*;
2312 | ^^^^^^^^^^^^
2413 = help: consider adding an explicit import of `id` to disambiguate
2514note: `id` could also refer to the function imported here
26 --> $DIR/ambiguous-1.rs:15:13
15 --> $DIR/ambiguous-1.rs:12:13
2716 |
2817LL | pub use self::handwritten::*;
2918 | ^^^^^^^^^^^^^^^^^^^^
3019 = help: consider adding an explicit import of `id` to disambiguate
31 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
32 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
33note: the lint level is defined here
34 --> $DIR/ambiguous-1.rs:4:9
35 |
36LL | #![warn(ambiguous_glob_imports)]
37 | ^^^^^^^^^^^^^^^^^^^^^^
38
39warning: 2 warnings emitted
4020
41Future incompatibility report: Future breakage diagnostic:
42warning: `id` is ambiguous
43 --> $DIR/ambiguous-1.rs:29:5
44 |
45LL | id();
46 | ^^ ambiguous name
47 |
48 = note: ambiguous because of multiple glob imports of a name in the same module
49note: `id` could refer to the function imported here
50 --> $DIR/ambiguous-1.rs:13:13
21warning: ambiguous glob re-exports
22 --> $DIR/ambiguous-1.rs:10:13
5123 |
5224LL | pub use self::evp::*;
53 | ^^^^^^^^^^^^
54 = help: consider adding an explicit import of `id` to disambiguate
55note: `id` could also refer to the function imported here
56 --> $DIR/ambiguous-1.rs:15:13
57 |
25 | ^^^^^^^^^^^^ the name `id` in the value namespace is first re-exported here
26LL |
5827LL | pub use self::handwritten::*;
59 | ^^^^^^^^^^^^^^^^^^^^
60 = help: consider adding an explicit import of `id` to disambiguate
61 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
62 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
63note: the lint level is defined here
64 --> $DIR/ambiguous-1.rs:4:9
28 | -------------------- but the name `id` in the value namespace is also re-exported here
6529 |
66LL | #![warn(ambiguous_glob_imports)]
67 | ^^^^^^^^^^^^^^^^^^^^^^
30 = note: `#[warn(ambiguous_glob_reexports)]` on by default
31
32error: aborting due to 1 previous error; 1 warning emitted
6833
34For more information about this error, try `rustc --explain E0659`.
tests/ui/imports/ambiguous-10.rs-1
......@@ -14,5 +14,4 @@ use crate::a::*;
1414use crate::b::*;
1515fn c(_: Token) {}
1616//~^ ERROR `Token` is ambiguous
17//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1817fn main() { }
tests/ui/imports/ambiguous-10.stderr+2-28
......@@ -1,4 +1,4 @@
1error: `Token` is ambiguous
1error[E0659]: `Token` is ambiguous
22 --> $DIR/ambiguous-10.rs:15:9
33 |
44LL | fn c(_: Token) {}
......@@ -17,33 +17,7 @@ note: `Token` could also refer to the enum imported here
1717LL | use crate::b::*;
1818 | ^^^^^^^^^^^
1919 = help: consider adding an explicit import of `Token` to disambiguate
20 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
21 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
22 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
2320
2421error: aborting due to 1 previous error
2522
26Future incompatibility report: Future breakage diagnostic:
27error: `Token` is ambiguous
28 --> $DIR/ambiguous-10.rs:15:9
29 |
30LL | fn c(_: Token) {}
31 | ^^^^^ ambiguous name
32 |
33 = note: ambiguous because of multiple glob imports of a name in the same module
34note: `Token` could refer to the enum imported here
35 --> $DIR/ambiguous-10.rs:13:5
36 |
37LL | use crate::a::*;
38 | ^^^^^^^^^^^
39 = help: consider adding an explicit import of `Token` to disambiguate
40note: `Token` could also refer to the enum imported here
41 --> $DIR/ambiguous-10.rs:14:5
42 |
43LL | use crate::b::*;
44 | ^^^^^^^^^^^
45 = help: consider adding an explicit import of `Token` to disambiguate
46 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
47 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
48 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
49
23For more information about this error, try `rustc --explain E0659`.
tests/ui/imports/ambiguous-12.rs-1
......@@ -20,5 +20,4 @@ use crate::public::*;
2020fn main() {
2121 b();
2222 //~^ ERROR `b` is ambiguous
23 //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2423}
tests/ui/imports/ambiguous-12.stderr+2-28
......@@ -1,4 +1,4 @@
1error: `b` is ambiguous
1error[E0659]: `b` is ambiguous
22 --> $DIR/ambiguous-12.rs:21:5
33 |
44LL | b();
......@@ -17,33 +17,7 @@ note: `b` could also refer to the function imported here
1717LL | use crate::public::*;
1818 | ^^^^^^^^^^^^^^^^
1919 = help: consider adding an explicit import of `b` to disambiguate
20 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
21 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
22 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
2320
2421error: aborting due to 1 previous error
2522
26Future incompatibility report: Future breakage diagnostic:
27error: `b` is ambiguous
28 --> $DIR/ambiguous-12.rs:21:5
29 |
30LL | b();
31 | ^ ambiguous name
32 |
33 = note: ambiguous because of multiple glob imports of a name in the same module
34note: `b` could refer to the function imported here
35 --> $DIR/ambiguous-12.rs:17:5
36 |
37LL | use crate::ciphertext::*;
38 | ^^^^^^^^^^^^^^^^^^^^
39 = help: consider adding an explicit import of `b` to disambiguate
40note: `b` could also refer to the function imported here
41 --> $DIR/ambiguous-12.rs:18:5
42 |
43LL | use crate::public::*;
44 | ^^^^^^^^^^^^^^^^
45 = help: consider adding an explicit import of `b` to disambiguate
46 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
47 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
48 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
49
23For more information about this error, try `rustc --explain E0659`.
tests/ui/imports/ambiguous-13.rs-1
......@@ -17,5 +17,4 @@ use crate::content::*;
1717
1818fn a(_: Rect) {}
1919//~^ ERROR `Rect` is ambiguous
20//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2120fn main() { }
tests/ui/imports/ambiguous-13.stderr+2-28
......@@ -1,4 +1,4 @@
1error: `Rect` is ambiguous
1error[E0659]: `Rect` is ambiguous
22 --> $DIR/ambiguous-13.rs:18:9
33 |
44LL | fn a(_: Rect) {}
......@@ -17,33 +17,7 @@ note: `Rect` could also refer to the struct imported here
1717LL | use crate::content::*;
1818 | ^^^^^^^^^^^^^^^^^
1919 = help: consider adding an explicit import of `Rect` to disambiguate
20 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
21 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
22 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
2320
2421error: aborting due to 1 previous error
2522
26Future incompatibility report: Future breakage diagnostic:
27error: `Rect` is ambiguous
28 --> $DIR/ambiguous-13.rs:18:9
29 |
30LL | fn a(_: Rect) {}
31 | ^^^^ ambiguous name
32 |
33 = note: ambiguous because of multiple glob imports of a name in the same module
34note: `Rect` could refer to the struct imported here
35 --> $DIR/ambiguous-13.rs:15:5
36 |
37LL | use crate::object::*;
38 | ^^^^^^^^^^^^^^^^
39 = help: consider adding an explicit import of `Rect` to disambiguate
40note: `Rect` could also refer to the struct imported here
41 --> $DIR/ambiguous-13.rs:16:5
42 |
43LL | use crate::content::*;
44 | ^^^^^^^^^^^^^^^^^
45 = help: consider adding an explicit import of `Rect` to disambiguate
46 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
47 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
48 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
49
23For more information about this error, try `rustc --explain E0659`.
tests/ui/imports/ambiguous-15.rs-1
......@@ -21,6 +21,5 @@ mod t3 {
2121use self::t3::*;
2222fn a<E: Error>(_: E) {}
2323//~^ ERROR `Error` is ambiguous
24//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2524
2625fn main() {}
tests/ui/imports/ambiguous-15.stderr+2-28
......@@ -1,4 +1,4 @@
1error: `Error` is ambiguous
1error[E0659]: `Error` is ambiguous
22 --> $DIR/ambiguous-15.rs:22:9
33 |
44LL | fn a<E: Error>(_: E) {}
......@@ -17,33 +17,7 @@ note: `Error` could also refer to the enum imported here
1717LL | pub use t2::*;
1818 | ^^^^^
1919 = help: consider adding an explicit import of `Error` to disambiguate
20 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
21 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
22 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
2320
2421error: aborting due to 1 previous error
2522
26Future incompatibility report: Future breakage diagnostic:
27error: `Error` is ambiguous
28 --> $DIR/ambiguous-15.rs:22:9
29 |
30LL | fn a<E: Error>(_: E) {}
31 | ^^^^^ ambiguous name
32 |
33 = note: ambiguous because of multiple glob imports of a name in the same module
34note: `Error` could refer to the trait imported here
35 --> $DIR/ambiguous-15.rs:21:5
36 |
37LL | use self::t3::*;
38 | ^^^^^^^^^^^
39 = help: consider adding an explicit import of `Error` to disambiguate
40note: `Error` could also refer to the enum imported here
41 --> $DIR/ambiguous-15.rs:15:9
42 |
43LL | pub use t2::*;
44 | ^^^^^
45 = help: consider adding an explicit import of `Error` to disambiguate
46 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
47 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
48 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
49
23For more information about this error, try `rustc --explain E0659`.
tests/ui/imports/ambiguous-16.rs-1
......@@ -21,6 +21,5 @@ mod framing {
2121
2222use crate::framing::ConfirmedTranscriptHashInput;
2323//~^ ERROR `ConfirmedTranscriptHashInput` is ambiguous
24//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2524
2625fn main() { }
tests/ui/imports/ambiguous-16.stderr+2-28
......@@ -1,4 +1,4 @@
1error: `ConfirmedTranscriptHashInput` is ambiguous
1error[E0659]: `ConfirmedTranscriptHashInput` is ambiguous
22 --> $DIR/ambiguous-16.rs:22:21
33 |
44LL | use crate::framing::ConfirmedTranscriptHashInput;
......@@ -17,33 +17,7 @@ note: `ConfirmedTranscriptHashInput` could also refer to the struct imported her
1717LL | pub use self::public_message_in::*;
1818 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
1919 = help: consider adding an explicit import of `ConfirmedTranscriptHashInput` to disambiguate
20 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
21 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
22 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
2320
2421error: aborting due to 1 previous error
2522
26Future incompatibility report: Future breakage diagnostic:
27error: `ConfirmedTranscriptHashInput` is ambiguous
28 --> $DIR/ambiguous-16.rs:22:21
29 |
30LL | use crate::framing::ConfirmedTranscriptHashInput;
31 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ambiguous name
32 |
33 = note: ambiguous because of multiple glob imports of a name in the same module
34note: `ConfirmedTranscriptHashInput` could refer to the struct imported here
35 --> $DIR/ambiguous-16.rs:18:13
36 |
37LL | pub use self::public_message::*;
38 | ^^^^^^^^^^^^^^^^^^^^^^^
39 = help: consider adding an explicit import of `ConfirmedTranscriptHashInput` to disambiguate
40note: `ConfirmedTranscriptHashInput` could also refer to the struct imported here
41 --> $DIR/ambiguous-16.rs:19:13
42 |
43LL | pub use self::public_message_in::*;
44 | ^^^^^^^^^^^^^^^^^^^^^^^^^^
45 = help: consider adding an explicit import of `ConfirmedTranscriptHashInput` to disambiguate
46 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
47 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
48 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
49
23For more information about this error, try `rustc --explain E0659`.
tests/ui/imports/ambiguous-17.rs-1
......@@ -25,5 +25,4 @@ mod handwritten {
2525fn main() {
2626 id();
2727 //~^ ERROR `id` is ambiguous
28 //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2928}
tests/ui/imports/ambiguous-17.stderr+9-35
......@@ -1,14 +1,4 @@
1warning: ambiguous glob re-exports
2 --> $DIR/ambiguous-17.rs:4:9
3 |
4LL | pub use evp::*;
5 | ^^^^^^ the name `id` in the value namespace is first re-exported here
6LL | pub use handwritten::*;
7 | -------------- but the name `id` in the value namespace is also re-exported here
8 |
9 = note: `#[warn(ambiguous_glob_reexports)]` on by default
10
11error: `id` is ambiguous
1error[E0659]: `id` is ambiguous
122 --> $DIR/ambiguous-17.rs:26:5
133 |
144LL | id();
......@@ -27,33 +17,17 @@ note: `id` could also refer to the function imported here
2717LL | pub use handwritten::*;
2818 | ^^^^^^^^^^^^^^
2919 = help: consider adding an explicit import of `id` to disambiguate
30 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
31 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
32 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
33
34error: aborting due to 1 previous error; 1 warning emitted
3520
36Future incompatibility report: Future breakage diagnostic:
37error: `id` is ambiguous
38 --> $DIR/ambiguous-17.rs:26:5
39 |
40LL | id();
41 | ^^ ambiguous name
42 |
43 = note: ambiguous because of multiple glob imports of a name in the same module
44note: `id` could refer to the function imported here
21warning: ambiguous glob re-exports
4522 --> $DIR/ambiguous-17.rs:4:9
4623 |
4724LL | pub use evp::*;
48 | ^^^^^^
49 = help: consider adding an explicit import of `id` to disambiguate
50note: `id` could also refer to the function imported here
51 --> $DIR/ambiguous-17.rs:5:9
52 |
25 | ^^^^^^ the name `id` in the value namespace is first re-exported here
5326LL | pub use handwritten::*;
54 | ^^^^^^^^^^^^^^
55 = help: consider adding an explicit import of `id` to disambiguate
56 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
57 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
58 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
27 | -------------- but the name `id` in the value namespace is also re-exported here
28 |
29 = note: `#[warn(ambiguous_glob_reexports)]` on by default
30
31error: aborting due to 1 previous error; 1 warning emitted
5932
33For more information about this error, try `rustc --explain E0659`.
tests/ui/imports/ambiguous-2.rs deleted-9
......@@ -1,9 +0,0 @@
1//@ aux-build: ../ambiguous-1.rs
2// https://github.com/rust-lang/rust/pull/113099#issuecomment-1633574396
3
4extern crate ambiguous_1;
5
6fn main() {
7 ambiguous_1::id(); //~ ERROR `id` is ambiguous
8 //~| WARN this was previously accepted
9}
tests/ui/imports/ambiguous-2.stderr deleted-49
......@@ -1,49 +0,0 @@
1error: `id` is ambiguous
2 --> $DIR/ambiguous-2.rs:7:18
3 |
4LL | ambiguous_1::id();
5 | ^^ ambiguous name
6 |
7 = note: ambiguous because of multiple glob imports of a name in the same module
8note: `id` could refer to the function defined here
9 --> $DIR/auxiliary/../ambiguous-1.rs:13:13
10 |
11LL | pub use self::evp::*;
12 | ^^^^^^^^^
13 = help: consider updating this dependency to resolve this error
14 = help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate
15note: `id` could also refer to the function defined here
16 --> $DIR/auxiliary/../ambiguous-1.rs:15:13
17 |
18LL | pub use self::handwritten::*;
19 | ^^^^^^^^^^^^^^^^^
20 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
21 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
22 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
23
24error: aborting due to 1 previous error
25
26Future incompatibility report: Future breakage diagnostic:
27error: `id` is ambiguous
28 --> $DIR/ambiguous-2.rs:7:18
29 |
30LL | ambiguous_1::id();
31 | ^^ ambiguous name
32 |
33 = note: ambiguous because of multiple glob imports of a name in the same module
34note: `id` could refer to the function defined here
35 --> $DIR/auxiliary/../ambiguous-1.rs:13:13
36 |
37LL | pub use self::evp::*;
38 | ^^^^^^^^^
39 = help: consider updating this dependency to resolve this error
40 = help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate
41note: `id` could also refer to the function defined here
42 --> $DIR/auxiliary/../ambiguous-1.rs:15:13
43 |
44LL | pub use self::handwritten::*;
45 | ^^^^^^^^^^^^^^^^^
46 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
47 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
48 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
49
tests/ui/imports/ambiguous-3.rs-1
......@@ -4,7 +4,6 @@ fn main() {
44 use a::*;
55 x();
66 //~^ ERROR `x` is ambiguous
7 //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
87}
98
109mod a {
tests/ui/imports/ambiguous-3.stderr+4-30
......@@ -1,4 +1,4 @@
1error: `x` is ambiguous
1error[E0659]: `x` is ambiguous
22 --> $DIR/ambiguous-3.rs:5:5
33 |
44LL | x();
......@@ -6,44 +6,18 @@ LL | x();
66 |
77 = note: ambiguous because of multiple glob imports of a name in the same module
88note: `x` could refer to the function imported here
9 --> $DIR/ambiguous-3.rs:18:13
9 --> $DIR/ambiguous-3.rs:17:13
1010 |
1111LL | pub use self::b::*;
1212 | ^^^^^^^^^^
1313 = help: consider adding an explicit import of `x` to disambiguate
1414note: `x` could also refer to the function imported here
15 --> $DIR/ambiguous-3.rs:19:13
15 --> $DIR/ambiguous-3.rs:18:13
1616 |
1717LL | pub use self::c::*;
1818 | ^^^^^^^^^^
1919 = help: consider adding an explicit import of `x` to disambiguate
20 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
21 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
22 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
2320
2421error: aborting due to 1 previous error
2522
26Future incompatibility report: Future breakage diagnostic:
27error: `x` is ambiguous
28 --> $DIR/ambiguous-3.rs:5:5
29 |
30LL | x();
31 | ^ ambiguous name
32 |
33 = note: ambiguous because of multiple glob imports of a name in the same module
34note: `x` could refer to the function imported here
35 --> $DIR/ambiguous-3.rs:18:13
36 |
37LL | pub use self::b::*;
38 | ^^^^^^^^^^
39 = help: consider adding an explicit import of `x` to disambiguate
40note: `x` could also refer to the function imported here
41 --> $DIR/ambiguous-3.rs:19:13
42 |
43LL | pub use self::c::*;
44 | ^^^^^^^^^^
45 = help: consider adding an explicit import of `x` to disambiguate
46 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
47 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
48 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
49
23For more information about this error, try `rustc --explain E0659`.
tests/ui/imports/ambiguous-4-extern.rs+1-5
......@@ -1,9 +1,6 @@
11//@ edition:2015
2//@ check-pass
32// https://github.com/rust-lang/rust/pull/112743#issuecomment-1601986883
43
5#![warn(ambiguous_glob_imports)]
6
74macro_rules! m {
85 () => {
96 pub fn id() {}
......@@ -24,6 +21,5 @@ mod handwritten {
2421
2522fn main() {
2623 id();
27 //~^ WARNING `id` is ambiguous
28 //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
24 //~^ ERROR `id` is ambiguous
2925}
tests/ui/imports/ambiguous-4-extern.stderr+12-46
......@@ -1,67 +1,33 @@
1warning: ambiguous glob re-exports
2 --> $DIR/ambiguous-4-extern.rs:13:9
3 |
4LL | pub use evp::*;
5 | ^^^^^^ the name `id` in the value namespace is first re-exported here
6LL | pub use handwritten::*;
7 | -------------- but the name `id` in the value namespace is also re-exported here
8 |
9 = note: `#[warn(ambiguous_glob_reexports)]` on by default
10
11warning: `id` is ambiguous
12 --> $DIR/ambiguous-4-extern.rs:26:5
1error[E0659]: `id` is ambiguous
2 --> $DIR/ambiguous-4-extern.rs:23:5
133 |
144LL | id();
155 | ^^ ambiguous name
166 |
177 = note: ambiguous because of multiple glob imports of a name in the same module
188note: `id` could refer to the function imported here
19 --> $DIR/ambiguous-4-extern.rs:13:9
9 --> $DIR/ambiguous-4-extern.rs:10:9
2010 |
2111LL | pub use evp::*;
2212 | ^^^^^^
2313 = help: consider adding an explicit import of `id` to disambiguate
2414note: `id` could also refer to the function imported here
25 --> $DIR/ambiguous-4-extern.rs:14:9
15 --> $DIR/ambiguous-4-extern.rs:11:9
2616 |
2717LL | pub use handwritten::*;
2818 | ^^^^^^^^^^^^^^
2919 = help: consider adding an explicit import of `id` to disambiguate
30 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
31 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
32note: the lint level is defined here
33 --> $DIR/ambiguous-4-extern.rs:5:9
34 |
35LL | #![warn(ambiguous_glob_imports)]
36 | ^^^^^^^^^^^^^^^^^^^^^^
37
38warning: 2 warnings emitted
3920
40Future incompatibility report: Future breakage diagnostic:
41warning: `id` is ambiguous
42 --> $DIR/ambiguous-4-extern.rs:26:5
43 |
44LL | id();
45 | ^^ ambiguous name
46 |
47 = note: ambiguous because of multiple glob imports of a name in the same module
48note: `id` could refer to the function imported here
49 --> $DIR/ambiguous-4-extern.rs:13:9
21warning: ambiguous glob re-exports
22 --> $DIR/ambiguous-4-extern.rs:10:9
5023 |
5124LL | pub use evp::*;
52 | ^^^^^^
53 = help: consider adding an explicit import of `id` to disambiguate
54note: `id` could also refer to the function imported here
55 --> $DIR/ambiguous-4-extern.rs:14:9
56 |
25 | ^^^^^^ the name `id` in the value namespace is first re-exported here
5726LL | pub use handwritten::*;
58 | ^^^^^^^^^^^^^^
59 = help: consider adding an explicit import of `id` to disambiguate
60 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
61 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
62note: the lint level is defined here
63 --> $DIR/ambiguous-4-extern.rs:5:9
27 | -------------- but the name `id` in the value namespace is also re-exported here
6428 |
65LL | #![warn(ambiguous_glob_imports)]
66 | ^^^^^^^^^^^^^^^^^^^^^^
29 = note: `#[warn(ambiguous_glob_reexports)]` on by default
30
31error: aborting due to 1 previous error; 1 warning emitted
6732
33For more information about this error, try `rustc --explain E0659`.
tests/ui/imports/ambiguous-4.rs deleted-9
......@@ -1,9 +0,0 @@
1//@ edition:2015
2//@ aux-build: ../ambiguous-4-extern.rs
3
4extern crate ambiguous_4_extern;
5
6fn main() {
7 ambiguous_4_extern::id(); //~ ERROR `id` is ambiguous
8 //~| WARN this was previously accepted
9}
tests/ui/imports/ambiguous-4.stderr deleted-49
......@@ -1,49 +0,0 @@
1error: `id` is ambiguous
2 --> $DIR/ambiguous-4.rs:7:25
3 |
4LL | ambiguous_4_extern::id();
5 | ^^ ambiguous name
6 |
7 = note: ambiguous because of multiple glob imports of a name in the same module
8note: `id` could refer to the function defined here
9 --> $DIR/auxiliary/../ambiguous-4-extern.rs:13:9
10 |
11LL | pub use evp::*;
12 | ^^^
13 = help: consider updating this dependency to resolve this error
14 = help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate
15note: `id` could also refer to the function defined here
16 --> $DIR/auxiliary/../ambiguous-4-extern.rs:14:9
17 |
18LL | pub use handwritten::*;
19 | ^^^^^^^^^^^
20 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
21 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
22 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
23
24error: aborting due to 1 previous error
25
26Future incompatibility report: Future breakage diagnostic:
27error: `id` is ambiguous
28 --> $DIR/ambiguous-4.rs:7:25
29 |
30LL | ambiguous_4_extern::id();
31 | ^^ ambiguous name
32 |
33 = note: ambiguous because of multiple glob imports of a name in the same module
34note: `id` could refer to the function defined here
35 --> $DIR/auxiliary/../ambiguous-4-extern.rs:13:9
36 |
37LL | pub use evp::*;
38 | ^^^
39 = help: consider updating this dependency to resolve this error
40 = help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate
41note: `id` could also refer to the function defined here
42 --> $DIR/auxiliary/../ambiguous-4-extern.rs:14:9
43 |
44LL | pub use handwritten::*;
45 | ^^^^^^^^^^^
46 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
47 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
48 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
49
tests/ui/imports/ambiguous-5.rs-1
......@@ -11,7 +11,6 @@ mod gpos {
1111 use super::*;
1212 struct MarkRecord(Class);
1313 //~^ ERROR`Class` is ambiguous
14 //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1514}
1615
1716mod gsubgpos {
tests/ui/imports/ambiguous-5.stderr+2-28
......@@ -1,4 +1,4 @@
1error: `Class` is ambiguous
1error[E0659]: `Class` is ambiguous
22 --> $DIR/ambiguous-5.rs:12:23
33 |
44LL | struct MarkRecord(Class);
......@@ -17,33 +17,7 @@ note: `Class` could also refer to the struct imported here
1717LL | use super::gsubgpos::*;
1818 | ^^^^^^^^^^^^^^^^^^
1919 = help: consider adding an explicit import of `Class` to disambiguate
20 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
21 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
22 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
2320
2421error: aborting due to 1 previous error
2522
26Future incompatibility report: Future breakage diagnostic:
27error: `Class` is ambiguous
28 --> $DIR/ambiguous-5.rs:12:23
29 |
30LL | struct MarkRecord(Class);
31 | ^^^^^ ambiguous name
32 |
33 = note: ambiguous because of multiple glob imports of a name in the same module
34note: `Class` could refer to the struct imported here
35 --> $DIR/ambiguous-5.rs:11:9
36 |
37LL | use super::*;
38 | ^^^^^^^^
39 = help: consider adding an explicit import of `Class` to disambiguate
40note: `Class` could also refer to the struct imported here
41 --> $DIR/ambiguous-5.rs:10:9
42 |
43LL | use super::gsubgpos::*;
44 | ^^^^^^^^^^^^^^^^^^
45 = help: consider adding an explicit import of `Class` to disambiguate
46 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
47 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
48 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
49
23For more information about this error, try `rustc --explain E0659`.
tests/ui/imports/ambiguous-6.rs-1
......@@ -5,7 +5,6 @@ pub fn foo() -> u32 {
55 use sub::*;
66 C
77 //~^ ERROR `C` is ambiguous
8 //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
98}
109
1110mod sub {
tests/ui/imports/ambiguous-6.stderr+4-30
......@@ -1,4 +1,4 @@
1error: `C` is ambiguous
1error[E0659]: `C` is ambiguous
22 --> $DIR/ambiguous-6.rs:6:5
33 |
44LL | C
......@@ -6,44 +6,18 @@ LL | C
66 |
77 = note: ambiguous because of multiple glob imports of a name in the same module
88note: `C` could refer to the constant imported here
9 --> $DIR/ambiguous-6.rs:15:13
9 --> $DIR/ambiguous-6.rs:14:13
1010 |
1111LL | pub use mod1::*;
1212 | ^^^^^^^
1313 = help: consider adding an explicit import of `C` to disambiguate
1414note: `C` could also refer to the constant imported here
15 --> $DIR/ambiguous-6.rs:16:13
15 --> $DIR/ambiguous-6.rs:15:13
1616 |
1717LL | pub use mod2::*;
1818 | ^^^^^^^
1919 = help: consider adding an explicit import of `C` to disambiguate
20 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
21 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
22 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
2320
2421error: aborting due to 1 previous error
2522
26Future incompatibility report: Future breakage diagnostic:
27error: `C` is ambiguous
28 --> $DIR/ambiguous-6.rs:6:5
29 |
30LL | C
31 | ^ ambiguous name
32 |
33 = note: ambiguous because of multiple glob imports of a name in the same module
34note: `C` could refer to the constant imported here
35 --> $DIR/ambiguous-6.rs:15:13
36 |
37LL | pub use mod1::*;
38 | ^^^^^^^
39 = help: consider adding an explicit import of `C` to disambiguate
40note: `C` could also refer to the constant imported here
41 --> $DIR/ambiguous-6.rs:16:13
42 |
43LL | pub use mod2::*;
44 | ^^^^^^^
45 = help: consider adding an explicit import of `C` to disambiguate
46 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
47 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
48 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
49
23For more information about this error, try `rustc --explain E0659`.
tests/ui/imports/ambiguous-9.rs-2
......@@ -22,7 +22,5 @@ use prelude::*;
2222fn main() {
2323 date_range();
2424 //~^ ERROR `date_range` is ambiguous
25 //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2625 //~| ERROR `date_range` is ambiguous
27 //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2826}
tests/ui/imports/ambiguous-9.stderr+19-71
......@@ -1,45 +1,4 @@
1warning: ambiguous glob re-exports
2 --> $DIR/ambiguous-9.rs:7:13
3 |
4LL | pub use self::range::*;
5 | ^^^^^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here
6LL | use super::prelude::*;
7 | ----------------- but the name `date_range` in the value namespace is also re-exported here
8 |
9 = note: `#[warn(ambiguous_glob_reexports)]` on by default
10
11error: `date_range` is ambiguous
12 --> $DIR/ambiguous-9.rs:23:5
13 |
14LL | date_range();
15 | ^^^^^^^^^^ ambiguous name
16 |
17 = note: ambiguous because of multiple glob imports of a name in the same module
18note: `date_range` could refer to the function imported here
19 --> $DIR/ambiguous-9.rs:7:13
20 |
21LL | pub use self::range::*;
22 | ^^^^^^^^^^^^^^
23 = help: consider adding an explicit import of `date_range` to disambiguate
24note: `date_range` could also refer to the function imported here
25 --> $DIR/ambiguous-9.rs:8:9
26 |
27LL | use super::prelude::*;
28 | ^^^^^^^^^^^^^^^^^
29 = help: consider adding an explicit import of `date_range` to disambiguate
30 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
31 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
32 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
33
34warning: ambiguous glob re-exports
35 --> $DIR/ambiguous-9.rs:15:13
36 |
37LL | pub use self::t::*;
38 | ^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here
39LL | pub use super::dsl::*;
40 | ------------- but the name `date_range` in the value namespace is also re-exported here
41
42error: `date_range` is ambiguous
1error[E0659]: `date_range` is ambiguous
432 --> $DIR/ambiguous-9.rs:23:5
443 |
454LL | date_range();
......@@ -58,13 +17,8 @@ note: `date_range` could also refer to the function imported here
5817LL | use prelude::*;
5918 | ^^^^^^^^^^
6019 = help: consider adding an explicit import of `date_range` to disambiguate
61 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
62 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
6320
64error: aborting due to 2 previous errors; 2 warnings emitted
65
66Future incompatibility report: Future breakage diagnostic:
67error: `date_range` is ambiguous
21error[E0659]: `date_range` is ambiguous
6822 --> $DIR/ambiguous-9.rs:23:5
6923 |
7024LL | date_range();
......@@ -83,31 +37,25 @@ note: `date_range` could also refer to the function imported here
8337LL | use super::prelude::*;
8438 | ^^^^^^^^^^^^^^^^^
8539 = help: consider adding an explicit import of `date_range` to disambiguate
86 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
87 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
88 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
8940
90Future breakage diagnostic:
91error: `date_range` is ambiguous
92 --> $DIR/ambiguous-9.rs:23:5
93 |
94LL | date_range();
95 | ^^^^^^^^^^ ambiguous name
41warning: ambiguous glob re-exports
42 --> $DIR/ambiguous-9.rs:7:13
9643 |
97 = note: ambiguous because of multiple glob imports of a name in the same module
98note: `date_range` could refer to the function imported here
99 --> $DIR/ambiguous-9.rs:19:5
44LL | pub use self::range::*;
45 | ^^^^^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here
46LL | use super::prelude::*;
47 | ----------------- but the name `date_range` in the value namespace is also re-exported here
10048 |
101LL | use dsl::*;
102 | ^^^^^^
103 = help: consider adding an explicit import of `date_range` to disambiguate
104note: `date_range` could also refer to the function imported here
105 --> $DIR/ambiguous-9.rs:20:5
49 = note: `#[warn(ambiguous_glob_reexports)]` on by default
50
51warning: ambiguous glob re-exports
52 --> $DIR/ambiguous-9.rs:15:13
10653 |
107LL | use prelude::*;
108 | ^^^^^^^^^^
109 = help: consider adding an explicit import of `date_range` to disambiguate
110 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
111 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
112 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
54LL | pub use self::t::*;
55 | ^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here
56LL | pub use super::dsl::*;
57 | ------------- but the name `date_range` in the value namespace is also re-exported here
58
59error: aborting due to 2 previous errors; 2 warnings emitted
11360
61For more information about this error, try `rustc --explain E0659`.
tests/ui/imports/ambiguous-panic-globvsglob.rs+1-2
......@@ -18,6 +18,5 @@ fn foo() {
1818 panic!();
1919 //~^ WARN: `panic` is ambiguous [ambiguous_panic_imports]
2020 //~| WARN: this was previously accepted by the compiler
21 //~| ERROR: `panic` is ambiguous [ambiguous_glob_imports]
22 //~| WARN: this was previously accepted by the compiler
21 //~| ERROR: `panic` is ambiguous
2322}
tests/ui/imports/ambiguous-panic-globvsglob.stderr+2-28
......@@ -1,4 +1,4 @@
1error: `panic` is ambiguous
1error[E0659]: `panic` is ambiguous
22 --> $DIR/ambiguous-panic-globvsglob.rs:18:5
33 |
44LL | panic!();
......@@ -17,9 +17,6 @@ note: `panic` could also refer to the macro imported here
1717LL | use m2::*;
1818 | ^^^^^
1919 = help: consider adding an explicit import of `panic` to disambiguate
20 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
21 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
22 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
2320
2421warning: `panic` is ambiguous
2522 --> $DIR/ambiguous-panic-globvsglob.rs:18:5
......@@ -42,27 +39,4 @@ note: `panic` could also refer to a macro from prelude
4239
4340error: aborting due to 1 previous error; 1 warning emitted
4441
45Future incompatibility report: Future breakage diagnostic:
46error: `panic` is ambiguous
47 --> $DIR/ambiguous-panic-globvsglob.rs:18:5
48 |
49LL | panic!();
50 | ^^^^^ ambiguous name
51 |
52 = note: ambiguous because of multiple glob imports of a name in the same module
53note: `panic` could refer to the macro imported here
54 --> $DIR/ambiguous-panic-globvsglob.rs:12:9
55 |
56LL | use m1::*;
57 | ^^^^^
58 = help: consider adding an explicit import of `panic` to disambiguate
59note: `panic` could also refer to the macro imported here
60 --> $DIR/ambiguous-panic-globvsglob.rs:13:9
61 |
62LL | use m2::*;
63 | ^^^^^
64 = help: consider adding an explicit import of `panic` to disambiguate
65 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
66 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
67 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
68
42For more information about this error, try `rustc --explain E0659`.
tests/ui/imports/glob-conflict-cross-crate-3.rs-1
......@@ -14,5 +14,4 @@ fn main() {
1414 //~^ ERROR `C` is ambiguous
1515 //~| ERROR `C` is ambiguous
1616 //~| WARN this was previously accepted
17 //~| WARN this was previously accepted
1817}
tests/ui/imports/glob-conflict-cross-crate-3.stderr+15-40
......@@ -1,27 +1,4 @@
1error: `C` is ambiguous
2 --> $DIR/glob-conflict-cross-crate-3.rs:13:13
3 |
4LL | let _a: C = 1;
5 | ^ ambiguous name
6 |
7 = note: ambiguous because of multiple glob imports of a name in the same module
8note: `C` could refer to the type alias defined here
9 --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:9:9
10 |
11LL | pub use a::*;
12 | ^
13 = help: consider updating this dependency to resolve this error
14 = help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate
15note: `C` could also refer to the type alias defined here
16 --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:10:9
17 |
18LL | pub use b::*;
19 | ^
20 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
21 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
22 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
23
24error: `C` is ambiguous
1error[E0659]: `C` is ambiguous
252 --> $DIR/glob-conflict-cross-crate-3.rs:13:13
263 |
274LL | let _a: C = 1;
......@@ -40,12 +17,7 @@ note: `C` could also refer to the type alias imported here
4017LL | use a::*;
4118 | ^^^^
4219 = help: consider adding an explicit import of `C` to disambiguate
43 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
44 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
4520
46error: aborting due to 2 previous errors
47
48Future incompatibility report: Future breakage diagnostic:
4921error: `C` is ambiguous
5022 --> $DIR/glob-conflict-cross-crate-3.rs:13:13
5123 |
......@@ -69,7 +41,10 @@ LL | pub use b::*;
6941 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
7042 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
7143
72Future breakage diagnostic:
44error: aborting due to 2 previous errors
45
46For more information about this error, try `rustc --explain E0659`.
47Future incompatibility report: Future breakage diagnostic:
7348error: `C` is ambiguous
7449 --> $DIR/glob-conflict-cross-crate-3.rs:13:13
7550 |
......@@ -77,18 +52,18 @@ LL | let _a: C = 1;
7752 | ^ ambiguous name
7853 |
7954 = note: ambiguous because of multiple glob imports of a name in the same module
80note: `C` could refer to the type alias imported here
81 --> $DIR/glob-conflict-cross-crate-3.rs:9:5
55note: `C` could refer to the type alias defined here
56 --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:9:9
8257 |
83LL | use glob_conflict_cross_crate_2_extern::*;
84 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
85 = help: consider adding an explicit import of `C` to disambiguate
86note: `C` could also refer to the type alias imported here
87 --> $DIR/glob-conflict-cross-crate-3.rs:10:5
58LL | pub use a::*;
59 | ^
60 = help: consider updating this dependency to resolve this error
61 = help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate
62note: `C` could also refer to the type alias defined here
63 --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:10:9
8864 |
89LL | use a::*;
90 | ^^^^
91 = help: consider adding an explicit import of `C` to disambiguate
65LL | pub use b::*;
66 | ^
9267 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
9368 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
9469 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
tests/ui/imports/unresolved-seg-after-ambiguous.rs+1-3
......@@ -17,8 +17,6 @@ mod a {
1717}
1818
1919use self::a::E::in_exist;
20//~^ ERROR: unresolved import `self::a::E`
21//~| ERROR: `E` is ambiguous
22//~| WARNING: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
20//~^ ERROR: `E` is ambiguous
2321
2422fn main() {}
tests/ui/imports/unresolved-seg-after-ambiguous.stderr+3-36
......@@ -1,10 +1,4 @@
1error[E0432]: unresolved import `self::a::E`
2 --> $DIR/unresolved-seg-after-ambiguous.rs:19:14
3 |
4LL | use self::a::E::in_exist;
5 | ^ `E` is a struct, not a module
6
7error: `E` is ambiguous
1error[E0659]: `E` is ambiguous
82 --> $DIR/unresolved-seg-after-ambiguous.rs:19:14
93 |
104LL | use self::a::E::in_exist;
......@@ -23,34 +17,7 @@ note: `E` could also refer to the struct imported here
2317LL | pub use self::d::*;
2418 | ^^^^^^^^^^
2519 = help: consider adding an explicit import of `E` to disambiguate
26 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
27 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
28 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
29
30error: aborting due to 2 previous errors
3120
32For more information about this error, try `rustc --explain E0432`.
33Future incompatibility report: Future breakage diagnostic:
34error: `E` is ambiguous
35 --> $DIR/unresolved-seg-after-ambiguous.rs:19:14
36 |
37LL | use self::a::E::in_exist;
38 | ^ ambiguous name
39 |
40 = note: ambiguous because of multiple glob imports of a name in the same module
41note: `E` could refer to the struct imported here
42 --> $DIR/unresolved-seg-after-ambiguous.rs:13:17
43 |
44LL | pub use self::c::*;
45 | ^^^^^^^^^^
46 = help: consider adding an explicit import of `E` to disambiguate
47note: `E` could also refer to the struct imported here
48 --> $DIR/unresolved-seg-after-ambiguous.rs:12:17
49 |
50LL | pub use self::d::*;
51 | ^^^^^^^^^^
52 = help: consider adding an explicit import of `E` to disambiguate
53 = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
54 = note: for more information, see issue #114095 <https://github.com/rust-lang/rust/issues/114095>
55 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default
21error: aborting due to 1 previous error
5622
23For more information about this error, try `rustc --explain E0659`.
tests/ui/linkage-attr/unstable-flavor.llbc.stderr created+2
......@@ -0,0 +1,2 @@
1error: the linker flavor `llbc` is unstable, the `-Z unstable-options` flag must also be passed to use the unstable values
2
tests/ui/linkage-attr/unstable-flavor.ptx.stderr deleted-2
......@@ -1,2 +0,0 @@
1error: the linker flavor `ptx` is unstable, the `-Z unstable-options` flag must also be passed to use the unstable values
2
tests/ui/linkage-attr/unstable-flavor.rs+4-4
......@@ -2,14 +2,14 @@
22// unique codepath checking all unstable options (see `LinkerFlavorCli::is_unstable` and its
33// caller). If it passes, all the other unstable options are rejected as well.
44//
5//@ revisions: bpf ptx
5//@ revisions: bpf llbc
66//@ [bpf] compile-flags: --target=bpfel-unknown-none -C linker-flavor=bpf --crate-type=rlib
77//@ [bpf] needs-llvm-components: bpf
8//@ [ptx] compile-flags: --target=nvptx64-nvidia-cuda -C linker-flavor=ptx --crate-type=rlib
9//@ [ptx] needs-llvm-components: nvptx
8//@ [llbc] compile-flags: --target=nvptx64-nvidia-cuda -C linker-flavor=llbc --crate-type=rlib
9//@ [llbc] needs-llvm-components: nvptx
1010
1111#![feature(no_core)]
1212#![no_core]
1313
1414//[bpf]~? ERROR the linker flavor `bpf` is unstable
15//[ptx]~? ERROR the linker flavor `ptx` is unstable
15//[llbc]~? ERROR the linker flavor `llbc` is unstable
tests/ui/lint/unused/unused-assign-148960.rs+1
......@@ -1,4 +1,5 @@
11//@ check-fail
2//@ ignore-parallel-frontend unstable liveness diagnostics
23#![deny(unused)]
34#![allow(dead_code)]
45
tests/ui/lint/unused/unused-assign-148960.stderr+7-7
......@@ -1,5 +1,5 @@
11error: value assigned to `value` is never read
2 --> $DIR/unused-assign-148960.rs:6:21
2 --> $DIR/unused-assign-148960.rs:7:21
33 |
44LL | let mut value = b"0".to_vec();
55 | ^^^^^^^^^^^^^ this value is reassigned later and never used
......@@ -7,14 +7,14 @@ LL | value = b"1".to_vec();
77 | ----- `value` is overwritten here before the previous value is read
88 |
99note: the lint level is defined here
10 --> $DIR/unused-assign-148960.rs:2:9
10 --> $DIR/unused-assign-148960.rs:3:9
1111 |
1212LL | #![deny(unused)]
1313 | ^^^^^^
1414 = note: `#[deny(unused_assignments)]` implied by `#[deny(unused)]`
1515
1616error: value assigned to `x` is never read
17 --> $DIR/unused-assign-148960.rs:12:17
17 --> $DIR/unused-assign-148960.rs:13:17
1818 |
1919LL | let mut x = 1;
2020 | ^ this value is reassigned later and never used
......@@ -22,7 +22,7 @@ LL | x = 2;
2222 | ----- `x` is overwritten here before the previous value is read
2323
2424error: value assigned to `x` is never read
25 --> $DIR/unused-assign-148960.rs:13:5
25 --> $DIR/unused-assign-148960.rs:14:5
2626 |
2727LL | x = 2;
2828 | ^^^^^ this value is reassigned later and never used
......@@ -30,7 +30,7 @@ LL | x = 3;
3030 | ----- `x` is overwritten here before the previous value is read
3131
3232error: value assigned to `p` is never read
33 --> $DIR/unused-assign-148960.rs:24:17
33 --> $DIR/unused-assign-148960.rs:25:17
3434 |
3535LL | let mut p = Point { x: 1, y: 1 };
3636 | ^^^^^^^^^^^^^^^^^^^^ this value is reassigned later and never used
......@@ -38,7 +38,7 @@ LL | p = Point { x: 2, y: 2 };
3838 | ------------------------ `p` is overwritten here before the previous value is read
3939
4040error: variable `foo` is assigned to, but never used
41 --> $DIR/unused-assign-148960.rs:38:9
41 --> $DIR/unused-assign-148960.rs:39:9
4242 |
4343LL | let mut foo = Foo;
4444 | ^^^^^^^
......@@ -52,7 +52,7 @@ LL + let Foo = Foo;
5252 |
5353
5454error: value assigned to `foo` is never read
55 --> $DIR/unused-assign-148960.rs:39:5
55 --> $DIR/unused-assign-148960.rs:40:5
5656 |
5757LL | foo = Foo;
5858 | ^^^
tests/ui/liveness/liveness-consts.rs+1
......@@ -1,4 +1,5 @@
11//@ check-pass
2//@ ignore-parallel-frontend unstable liveness diagnostics
23#![warn(unused)]
34#![allow(unreachable_code)]
45
tests/ui/liveness/liveness-consts.stderr+11-11
......@@ -1,30 +1,30 @@
11warning: unused variable: `e`
2 --> $DIR/liveness-consts.rs:26:13
2 --> $DIR/liveness-consts.rs:27:13
33 |
44LL | let e = 1;
55 | ^ help: if this is intentional, prefix it with an underscore: `_e`
66 |
77note: the lint level is defined here
8 --> $DIR/liveness-consts.rs:2:9
8 --> $DIR/liveness-consts.rs:3:9
99 |
1010LL | #![warn(unused)]
1111 | ^^^^^^
1212 = note: `#[warn(unused_variables)]` implied by `#[warn(unused)]`
1313
1414warning: unused variable: `s`
15 --> $DIR/liveness-consts.rs:35:24
15 --> $DIR/liveness-consts.rs:36:24
1616 |
1717LL | pub fn f(x: [u8; { let s = 17; 100 }]) -> [u8; { let z = 18; 100 }] {
1818 | ^ help: if this is intentional, prefix it with an underscore: `_s`
1919
2020warning: unused variable: `z`
21 --> $DIR/liveness-consts.rs:35:55
21 --> $DIR/liveness-consts.rs:36:55
2222 |
2323LL | pub fn f(x: [u8; { let s = 17; 100 }]) -> [u8; { let z = 18; 100 }] {
2424 | ^ help: if this is intentional, prefix it with an underscore: `_z`
2525
2626warning: variable `a` is assigned to, but never used
27 --> $DIR/liveness-consts.rs:7:9
27 --> $DIR/liveness-consts.rs:8:9
2828 |
2929LL | let mut a = 0;
3030 | ^^^^^
......@@ -32,7 +32,7 @@ LL | let mut a = 0;
3232 = note: consider using `_a` instead
3333
3434warning: value assigned to `a` is never read
35 --> $DIR/liveness-consts.rs:11:9
35 --> $DIR/liveness-consts.rs:12:9
3636 |
3737LL | a += 1;
3838 | ^^^^^^
......@@ -41,7 +41,7 @@ LL | a += 1;
4141 = note: `#[warn(unused_assignments)]` implied by `#[warn(unused)]`
4242
4343warning: value assigned to `b` is never read
44 --> $DIR/liveness-consts.rs:18:17
44 --> $DIR/liveness-consts.rs:19:17
4545 |
4646LL | let mut b = 1;
4747 | ^ this value is reassigned later and never used
......@@ -49,7 +49,7 @@ LL | b += 1;
4949 | ------ `b` is overwritten here before the previous value is read
5050
5151warning: value assigned to `b` is never read
52 --> $DIR/liveness-consts.rs:19:5
52 --> $DIR/liveness-consts.rs:20:5
5353 |
5454LL | b += 1;
5555 | ^^^^^^ this value is reassigned later and never used
......@@ -57,13 +57,13 @@ LL | b = 42;
5757 | ------ `b` is overwritten here before the previous value is read
5858
5959warning: unused variable: `z`
60 --> $DIR/liveness-consts.rs:62:13
60 --> $DIR/liveness-consts.rs:63:13
6161 |
6262LL | let z = 42;
6363 | ^ help: if this is intentional, prefix it with an underscore: `_z`
6464
6565warning: value assigned to `t` is never read
66 --> $DIR/liveness-consts.rs:44:9
66 --> $DIR/liveness-consts.rs:45:9
6767 |
6868LL | t = t + t;
6969 | ^^^^^^^^^
......@@ -71,7 +71,7 @@ LL | t = t + t;
7171 = help: maybe it is overwritten before being read?
7272
7373warning: unused variable: `w`
74 --> $DIR/liveness-consts.rs:51:13
74 --> $DIR/liveness-consts.rs:52:13
7575 |
7676LL | let w = 10;
7777 | ^ help: if this is intentional, prefix it with an underscore: `_w`
tests/ui/liveness/liveness-dead.rs+1
......@@ -1,3 +1,4 @@
1//@ ignore-parallel-frontend unstable liveness diagnostics
12#![allow(dead_code)]
23#![deny(unused_assignments)]
34
tests/ui/liveness/liveness-dead.stderr+5-5
......@@ -1,5 +1,5 @@
11error: value assigned to `x` is never read
2 --> $DIR/liveness-dead.rs:9:24
2 --> $DIR/liveness-dead.rs:10:24
33 |
44LL | let mut x: isize = 3;
55 | ^ this value is reassigned later and never used
......@@ -7,13 +7,13 @@ LL | x = 4;
77 | ----- `x` is overwritten here before the previous value is read
88 |
99note: the lint level is defined here
10 --> $DIR/liveness-dead.rs:2:9
10 --> $DIR/liveness-dead.rs:3:9
1111 |
1212LL | #![deny(unused_assignments)]
1313 | ^^^^^^^^^^^^^^^^^^
1414
1515error: value assigned to `x` is never read
16 --> $DIR/liveness-dead.rs:17:5
16 --> $DIR/liveness-dead.rs:18:5
1717 |
1818LL | x = 4;
1919 | ^^^^^
......@@ -21,7 +21,7 @@ LL | x = 4;
2121 = help: maybe it is overwritten before being read?
2222
2323error: value passed to `x` is never read
24 --> $DIR/liveness-dead.rs:20:7
24 --> $DIR/liveness-dead.rs:21:7
2525 |
2626LL | fn f4(mut x: i32) {
2727 | ^^^^^
......@@ -29,7 +29,7 @@ LL | fn f4(mut x: i32) {
2929 = help: maybe it is overwritten before being read?
3030
3131error: value assigned to `x` is never read
32 --> $DIR/liveness-dead.rs:27:5
32 --> $DIR/liveness-dead.rs:28:5
3333 |
3434LL | x = 4;
3535 | ^^^^^
tests/ui/liveness/liveness-upvars.rs+1
......@@ -1,5 +1,6 @@
11//@ edition:2018
22//@ check-pass
3//@ ignore-parallel-frontend unstable liveness diagnostics
34#![feature(coroutines, stmt_expr_attributes)]
45#![warn(unused)]
56#![allow(unreachable_code)]
tests/ui/liveness/liveness-upvars.stderr+25-25
......@@ -1,19 +1,19 @@
11warning: value captured by `last` is never read
2 --> $DIR/liveness-upvars.rs:10:9
2 --> $DIR/liveness-upvars.rs:11:9
33 |
44LL | last = Some(s);
55 | ^^^^
66 |
77 = help: did you mean to capture by reference instead?
88note: the lint level is defined here
9 --> $DIR/liveness-upvars.rs:4:9
9 --> $DIR/liveness-upvars.rs:5:9
1010 |
1111LL | #![warn(unused)]
1212 | ^^^^^^
1313 = note: `#[warn(unused_assignments)]` implied by `#[warn(unused)]`
1414
1515warning: value assigned to `last` is never read
16 --> $DIR/liveness-upvars.rs:10:9
16 --> $DIR/liveness-upvars.rs:11:9
1717 |
1818LL | last = Some(s);
1919 | ^^^^^^^^^^^^^^
......@@ -21,7 +21,7 @@ LL | last = Some(s);
2121 = help: maybe it is overwritten before being read?
2222
2323warning: value captured by `sum` is never read
24 --> $DIR/liveness-upvars.rs:22:9
24 --> $DIR/liveness-upvars.rs:23:9
2525 |
2626LL | sum += x;
2727 | ^^^
......@@ -29,7 +29,7 @@ LL | sum += x;
2929 = help: did you mean to capture by reference instead?
3030
3131warning: value assigned to `sum` is never read
32 --> $DIR/liveness-upvars.rs:22:9
32 --> $DIR/liveness-upvars.rs:23:9
3333 |
3434LL | sum += x;
3535 | ^^^^^^^^
......@@ -37,7 +37,7 @@ LL | sum += x;
3737 = help: maybe it is overwritten before being read?
3838
3939warning: value assigned to `c` is never read
40 --> $DIR/liveness-upvars.rs:69:9
40 --> $DIR/liveness-upvars.rs:70:9
4141 |
4242LL | c += 1;
4343 | ^^^^^^
......@@ -45,7 +45,7 @@ LL | c += 1;
4545 = help: maybe it is overwritten before being read?
4646
4747warning: value assigned to `c` is never read
48 --> $DIR/liveness-upvars.rs:63:9
48 --> $DIR/liveness-upvars.rs:64:9
4949 |
5050LL | c += 1;
5151 | ^^^^^^
......@@ -53,7 +53,7 @@ LL | c += 1;
5353 = help: maybe it is overwritten before being read?
5454
5555warning: value captured by `c` is never read
56 --> $DIR/liveness-upvars.rs:49:9
56 --> $DIR/liveness-upvars.rs:50:9
5757 |
5858LL | c += 1;
5959 | ^
......@@ -61,7 +61,7 @@ LL | c += 1;
6161 = help: did you mean to capture by reference instead?
6262
6363warning: value assigned to `c` is never read
64 --> $DIR/liveness-upvars.rs:49:9
64 --> $DIR/liveness-upvars.rs:50:9
6565 |
6666LL | c += 1;
6767 | ^^^^^^
......@@ -69,7 +69,7 @@ LL | c += 1;
6969 = help: maybe it is overwritten before being read?
7070
7171warning: value captured by `c` is never read
72 --> $DIR/liveness-upvars.rs:44:9
72 --> $DIR/liveness-upvars.rs:45:9
7373 |
7474LL | c += 1;
7575 | ^
......@@ -77,7 +77,7 @@ LL | c += 1;
7777 = help: did you mean to capture by reference instead?
7878
7979warning: value assigned to `c` is never read
80 --> $DIR/liveness-upvars.rs:44:9
80 --> $DIR/liveness-upvars.rs:45:9
8181 |
8282LL | c += 1;
8383 | ^^^^^^
......@@ -85,7 +85,7 @@ LL | c += 1;
8585 = help: maybe it is overwritten before being read?
8686
8787warning: value captured by `c` is never read
88 --> $DIR/liveness-upvars.rs:38:9
88 --> $DIR/liveness-upvars.rs:39:9
8989 |
9090LL | c = 1;
9191 | ^
......@@ -93,7 +93,7 @@ LL | c = 1;
9393 = help: did you mean to capture by reference instead?
9494
9595warning: value captured by `c` is never read
96 --> $DIR/liveness-upvars.rs:34:9
96 --> $DIR/liveness-upvars.rs:35:9
9797 |
9898LL | c = 1;
9999 | ^
......@@ -101,7 +101,7 @@ LL | c = 1;
101101 = help: did you mean to capture by reference instead?
102102
103103warning: value captured by `e` is never read
104 --> $DIR/liveness-upvars.rs:82:13
104 --> $DIR/liveness-upvars.rs:83:13
105105 |
106106LL | e = Some("e1");
107107 | ^
......@@ -109,7 +109,7 @@ LL | e = Some("e1");
109109 = help: did you mean to capture by reference instead?
110110
111111warning: value assigned to `e` is never read
112 --> $DIR/liveness-upvars.rs:82:13
112 --> $DIR/liveness-upvars.rs:83:13
113113 |
114114LL | e = Some("e1");
115115 | ^^^^^^^^^^^^^^ this value is reassigned later and never used
......@@ -118,7 +118,7 @@ LL | e = Some("e2");
118118 | -------------- `e` is overwritten here before the previous value is read
119119
120120warning: value assigned to `e` is never read
121 --> $DIR/liveness-upvars.rs:84:13
121 --> $DIR/liveness-upvars.rs:85:13
122122 |
123123LL | e = Some("e2");
124124 | ^^^^^^^^^^^^^^
......@@ -126,7 +126,7 @@ LL | e = Some("e2");
126126 = help: maybe it is overwritten before being read?
127127
128128warning: value assigned to `d` is never read
129 --> $DIR/liveness-upvars.rs:78:13
129 --> $DIR/liveness-upvars.rs:79:13
130130 |
131131LL | d = Some("d1");
132132 | ^^^^^^^^^^^^^^ this value is reassigned later and never used
......@@ -134,7 +134,7 @@ LL | d = Some("d2");
134134 | -------------- `d` is overwritten here before the previous value is read
135135
136136warning: value assigned to `v` is never read
137 --> $DIR/liveness-upvars.rs:92:13
137 --> $DIR/liveness-upvars.rs:93:13
138138 |
139139LL | v = T::default();
140140 | ^
......@@ -142,7 +142,7 @@ LL | v = T::default();
142142 = help: maybe it is overwritten before being read?
143143
144144warning: value captured by `z` is never read
145 --> $DIR/liveness-upvars.rs:105:17
145 --> $DIR/liveness-upvars.rs:106:17
146146 |
147147LL | z = T::default();
148148 | ^
......@@ -150,7 +150,7 @@ LL | z = T::default();
150150 = help: did you mean to capture by reference instead?
151151
152152warning: value assigned to `z` is never read
153 --> $DIR/liveness-upvars.rs:105:17
153 --> $DIR/liveness-upvars.rs:106:17
154154 |
155155LL | z = T::default();
156156 | ^^^^^^^^^^^^^^^^
......@@ -158,7 +158,7 @@ LL | z = T::default();
158158 = help: maybe it is overwritten before being read?
159159
160160warning: value captured by `state` is never read
161 --> $DIR/liveness-upvars.rs:131:9
161 --> $DIR/liveness-upvars.rs:132:9
162162 |
163163LL | state = 4;
164164 | ^^^^^
......@@ -166,7 +166,7 @@ LL | state = 4;
166166 = help: did you mean to capture by reference instead?
167167
168168warning: value assigned to `state` is never read
169 --> $DIR/liveness-upvars.rs:131:9
169 --> $DIR/liveness-upvars.rs:132:9
170170 |
171171LL | state = 4;
172172 | ^^^^^^^^^ this value is reassigned later and never used
......@@ -175,7 +175,7 @@ LL | state = 5;
175175 | --------- `state` is overwritten here before the previous value is read
176176
177177warning: value assigned to `state` is never read
178 --> $DIR/liveness-upvars.rs:134:9
178 --> $DIR/liveness-upvars.rs:135:9
179179 |
180180LL | state = 5;
181181 | ^^^^^^^^^
......@@ -183,7 +183,7 @@ LL | state = 5;
183183 = help: maybe it is overwritten before being read?
184184
185185warning: value assigned to `s` is never read
186 --> $DIR/liveness-upvars.rs:143:9
186 --> $DIR/liveness-upvars.rs:144:9
187187 |
188188LL | s = 1;
189189 | ^^^^^ this value is reassigned later and never used
......@@ -191,7 +191,7 @@ LL | yield (s = 2);
191191 | ------- `s` is overwritten here before the previous value is read
192192
193193warning: value assigned to `s` is never read
194 --> $DIR/liveness-upvars.rs:145:9
194 --> $DIR/liveness-upvars.rs:146:9
195195 |
196196LL | s = yield ();
197197 | ^^^^^^^^^^^^ this value is reassigned later and never used
tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.rs+1
......@@ -1,4 +1,5 @@
11//@ run-pass
2//@ ignore-parallel-frontend unstable liveness diagnostics
23#![allow(dead_code)]
34#![warn(unused_assignments)]
45
tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.stderr+5-5
......@@ -1,18 +1,18 @@
11warning: value assigned to `x` is never read
2 --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:10:9
2 --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:11:9
33 |
44LL | x = 35;
55 | ^^^^^^
66 |
77 = help: maybe it is overwritten before being read?
88note: the lint level is defined here
9 --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:3:9
9 --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:4:9
1010 |
1111LL | #![warn(unused_assignments)]
1212 | ^^^^^^^^^^^^^^^^^^
1313
1414warning: value assigned to `x` is never read
15 --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:21:13
15 --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:22:13
1616 |
1717LL | x = 35;
1818 | ^^^^^^
......@@ -20,7 +20,7 @@ LL | x = 35;
2020 = help: maybe it is overwritten before being read?
2121
2222warning: value assigned to `x` is never read
23 --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:36:9
23 --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:37:9
2424 |
2525LL | x = 42;
2626 | ^^^^^^ this value is reassigned later and never used
......@@ -29,7 +29,7 @@ LL | x = 99;
2929 | ------ `x` is overwritten here before the previous value is read
3030
3131warning: value assigned to `x` is never read
32 --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:33:9
32 --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:34:9
3333 |
3434LL | x = 35;
3535 | ^^^^^^ this value is reassigned later and never used
tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr+50-50
......@@ -1,5 +1,5 @@
11error: unreachable pattern
2 --> $DIR/empty-types.rs:47:9
2 --> $DIR/empty-types.rs:48:9
33 |
44LL | _ => {}
55 | ^------
......@@ -9,13 +9,13 @@ LL | _ => {}
99 |
1010 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
1111note: the lint level is defined here
12 --> $DIR/empty-types.rs:13:9
12 --> $DIR/empty-types.rs:14:9
1313 |
1414LL | #![deny(unreachable_patterns)]
1515 | ^^^^^^^^^^^^^^^^^^^^
1616
1717error: unreachable pattern
18 --> $DIR/empty-types.rs:50:9
18 --> $DIR/empty-types.rs:51:9
1919 |
2020LL | _x => {}
2121 | ^^------
......@@ -26,7 +26,7 @@ LL | _x => {}
2626 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
2727
2828error[E0004]: non-exhaustive patterns: type `&!` is non-empty
29 --> $DIR/empty-types.rs:54:11
29 --> $DIR/empty-types.rs:55:11
3030 |
3131LL | match ref_never {}
3232 | ^^^^^^^^^
......@@ -41,7 +41,7 @@ LL ~ }
4141 |
4242
4343error: unreachable pattern
44 --> $DIR/empty-types.rs:68:9
44 --> $DIR/empty-types.rs:69:9
4545 |
4646LL | (_, _) => {}
4747 | ^^^^^^------
......@@ -52,7 +52,7 @@ LL | (_, _) => {}
5252 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
5353
5454error: unreachable pattern
55 --> $DIR/empty-types.rs:74:9
55 --> $DIR/empty-types.rs:75:9
5656 |
5757LL | _ => {}
5858 | ^------
......@@ -63,7 +63,7 @@ LL | _ => {}
6363 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
6464
6565error: unreachable pattern
66 --> $DIR/empty-types.rs:77:9
66 --> $DIR/empty-types.rs:78:9
6767 |
6868LL | (_, _) => {}
6969 | ^^^^^^------
......@@ -74,7 +74,7 @@ LL | (_, _) => {}
7474 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
7575
7676error: unreachable pattern
77 --> $DIR/empty-types.rs:81:9
77 --> $DIR/empty-types.rs:82:9
7878 |
7979LL | _ => {}
8080 | ^------
......@@ -85,7 +85,7 @@ LL | _ => {}
8585 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
8686
8787error[E0004]: non-exhaustive patterns: `Ok(_)` not covered
88 --> $DIR/empty-types.rs:85:11
88 --> $DIR/empty-types.rs:86:11
8989 |
9090LL | match res_u32_never {}
9191 | ^^^^^^^^^^^^^ pattern `Ok(_)` not covered
......@@ -104,7 +104,7 @@ LL ~ }
104104 |
105105
106106error: unreachable pattern
107 --> $DIR/empty-types.rs:92:9
107 --> $DIR/empty-types.rs:93:9
108108 |
109109LL | Err(_) => {}
110110 | ^^^^^^------
......@@ -115,7 +115,7 @@ LL | Err(_) => {}
115115 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
116116
117117error: unreachable pattern
118 --> $DIR/empty-types.rs:97:9
118 --> $DIR/empty-types.rs:98:9
119119 |
120120LL | Err(_) => {}
121121 | ^^^^^^------
......@@ -126,7 +126,7 @@ LL | Err(_) => {}
126126 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
127127
128128error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered
129 --> $DIR/empty-types.rs:94:11
129 --> $DIR/empty-types.rs:95:11
130130 |
131131LL | match res_u32_never {
132132 | ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered
......@@ -144,7 +144,7 @@ LL ~ Ok(1_u32..=u32::MAX) => todo!()
144144 |
145145
146146error[E0005]: refutable pattern in local binding
147 --> $DIR/empty-types.rs:100:9
147 --> $DIR/empty-types.rs:101:9
148148 |
149149LL | let Ok(_x) = res_u32_never.as_ref();
150150 | ^^^^^^ pattern `Err(_)` not covered
......@@ -158,7 +158,7 @@ LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() };
158158 | ++++++++++++++++
159159
160160error: unreachable pattern
161 --> $DIR/empty-types.rs:110:9
161 --> $DIR/empty-types.rs:111:9
162162 |
163163LL | _ => {}
164164 | ^------
......@@ -169,7 +169,7 @@ LL | _ => {}
169169 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
170170
171171error: unreachable pattern
172 --> $DIR/empty-types.rs:113:9
172 --> $DIR/empty-types.rs:114:9
173173 |
174174LL | Ok(_) => {}
175175 | ^^^^^------
......@@ -180,7 +180,7 @@ LL | Ok(_) => {}
180180 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
181181
182182error: unreachable pattern
183 --> $DIR/empty-types.rs:116:9
183 --> $DIR/empty-types.rs:117:9
184184 |
185185LL | Ok(_) => {}
186186 | ^^^^^------
......@@ -191,7 +191,7 @@ LL | Ok(_) => {}
191191 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
192192
193193error: unreachable pattern
194 --> $DIR/empty-types.rs:117:9
194 --> $DIR/empty-types.rs:118:9
195195 |
196196LL | _ => {}
197197 | ^------
......@@ -202,7 +202,7 @@ LL | _ => {}
202202 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
203203
204204error: unreachable pattern
205 --> $DIR/empty-types.rs:120:9
205 --> $DIR/empty-types.rs:121:9
206206 |
207207LL | Ok(_) => {}
208208 | ^^^^^------
......@@ -213,7 +213,7 @@ LL | Ok(_) => {}
213213 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
214214
215215error: unreachable pattern
216 --> $DIR/empty-types.rs:121:9
216 --> $DIR/empty-types.rs:122:9
217217 |
218218LL | Err(_) => {}
219219 | ^^^^^^------
......@@ -224,7 +224,7 @@ LL | Err(_) => {}
224224 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
225225
226226error: unreachable pattern
227 --> $DIR/empty-types.rs:130:13
227 --> $DIR/empty-types.rs:131:13
228228 |
229229LL | _ => {}
230230 | ^------
......@@ -235,7 +235,7 @@ LL | _ => {}
235235 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
236236
237237error: unreachable pattern
238 --> $DIR/empty-types.rs:133:13
238 --> $DIR/empty-types.rs:134:13
239239 |
240240LL | _ if false => {}
241241 | ^---------------
......@@ -246,7 +246,7 @@ LL | _ if false => {}
246246 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
247247
248248error: unreachable pattern
249 --> $DIR/empty-types.rs:141:13
249 --> $DIR/empty-types.rs:142:13
250250 |
251251LL | Some(_) => {}
252252 | ^^^^^^^------
......@@ -257,7 +257,7 @@ LL | Some(_) => {}
257257 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
258258
259259error: unreachable pattern
260 --> $DIR/empty-types.rs:145:13
260 --> $DIR/empty-types.rs:146:13
261261 |
262262LL | None => {}
263263 | ---- matches all the relevant values
......@@ -265,7 +265,7 @@ LL | _ => {}
265265 | ^ no value can reach this
266266
267267error: unreachable pattern
268 --> $DIR/empty-types.rs:197:13
268 --> $DIR/empty-types.rs:198:13
269269 |
270270LL | _ => {}
271271 | ^------
......@@ -276,7 +276,7 @@ LL | _ => {}
276276 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
277277
278278error: unreachable pattern
279 --> $DIR/empty-types.rs:202:13
279 --> $DIR/empty-types.rs:203:13
280280 |
281281LL | _ => {}
282282 | ^------
......@@ -287,7 +287,7 @@ LL | _ => {}
287287 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
288288
289289error: unreachable pattern
290 --> $DIR/empty-types.rs:207:13
290 --> $DIR/empty-types.rs:208:13
291291 |
292292LL | _ => {}
293293 | ^------
......@@ -298,7 +298,7 @@ LL | _ => {}
298298 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
299299
300300error: unreachable pattern
301 --> $DIR/empty-types.rs:212:13
301 --> $DIR/empty-types.rs:213:13
302302 |
303303LL | _ => {}
304304 | ^------
......@@ -309,7 +309,7 @@ LL | _ => {}
309309 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
310310
311311error: unreachable pattern
312 --> $DIR/empty-types.rs:218:13
312 --> $DIR/empty-types.rs:219:13
313313 |
314314LL | _ => {}
315315 | ^------
......@@ -320,7 +320,7 @@ LL | _ => {}
320320 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
321321
322322error: unreachable pattern
323 --> $DIR/empty-types.rs:279:9
323 --> $DIR/empty-types.rs:280:9
324324 |
325325LL | _ => {}
326326 | ^------
......@@ -331,7 +331,7 @@ LL | _ => {}
331331 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
332332
333333error: unreachable pattern
334 --> $DIR/empty-types.rs:282:9
334 --> $DIR/empty-types.rs:283:9
335335 |
336336LL | (_, _) => {}
337337 | ^^^^^^------
......@@ -342,7 +342,7 @@ LL | (_, _) => {}
342342 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
343343
344344error: unreachable pattern
345 --> $DIR/empty-types.rs:285:9
345 --> $DIR/empty-types.rs:286:9
346346 |
347347LL | Ok(_) => {}
348348 | ^^^^^------
......@@ -353,7 +353,7 @@ LL | Ok(_) => {}
353353 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
354354
355355error: unreachable pattern
356 --> $DIR/empty-types.rs:286:9
356 --> $DIR/empty-types.rs:287:9
357357 |
358358LL | Err(_) => {}
359359 | ^^^^^^------
......@@ -364,7 +364,7 @@ LL | Err(_) => {}
364364 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
365365
366366error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty
367 --> $DIR/empty-types.rs:325:11
367 --> $DIR/empty-types.rs:326:11
368368 |
369369LL | match slice_never {}
370370 | ^^^^^^^^^^^
......@@ -378,7 +378,7 @@ LL ~ }
378378 |
379379
380380error[E0004]: non-exhaustive patterns: `&[]` not covered
381 --> $DIR/empty-types.rs:336:11
381 --> $DIR/empty-types.rs:337:11
382382 |
383383LL | match slice_never {
384384 | ^^^^^^^^^^^ pattern `&[]` not covered
......@@ -391,7 +391,7 @@ LL + &[] => todo!()
391391 |
392392
393393error[E0004]: non-exhaustive patterns: `&[]` not covered
394 --> $DIR/empty-types.rs:350:11
394 --> $DIR/empty-types.rs:351:11
395395 |
396396LL | match slice_never {
397397 | ^^^^^^^^^^^ pattern `&[]` not covered
......@@ -405,7 +405,7 @@ LL + &[] => todo!()
405405 |
406406
407407error[E0004]: non-exhaustive patterns: type `[!]` is non-empty
408 --> $DIR/empty-types.rs:357:11
408 --> $DIR/empty-types.rs:358:11
409409 |
410410LL | match *slice_never {}
411411 | ^^^^^^^^^^^^
......@@ -419,7 +419,7 @@ LL ~ }
419419 |
420420
421421error: unreachable pattern
422 --> $DIR/empty-types.rs:366:9
422 --> $DIR/empty-types.rs:367:9
423423 |
424424LL | _ => {}
425425 | ^------
......@@ -430,7 +430,7 @@ LL | _ => {}
430430 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
431431
432432error: unreachable pattern
433 --> $DIR/empty-types.rs:369:9
433 --> $DIR/empty-types.rs:370:9
434434 |
435435LL | [_, _, _] => {}
436436 | ^^^^^^^^^------
......@@ -441,7 +441,7 @@ LL | [_, _, _] => {}
441441 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
442442
443443error: unreachable pattern
444 --> $DIR/empty-types.rs:372:9
444 --> $DIR/empty-types.rs:373:9
445445 |
446446LL | [_, ..] => {}
447447 | ^^^^^^^------
......@@ -452,7 +452,7 @@ LL | [_, ..] => {}
452452 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
453453
454454error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty
455 --> $DIR/empty-types.rs:386:11
455 --> $DIR/empty-types.rs:387:11
456456 |
457457LL | match array_0_never {}
458458 | ^^^^^^^^^^^^^
......@@ -466,7 +466,7 @@ LL ~ }
466466 |
467467
468468error: unreachable pattern
469 --> $DIR/empty-types.rs:393:9
469 --> $DIR/empty-types.rs:394:9
470470 |
471471LL | [] => {}
472472 | -- matches all the relevant values
......@@ -474,7 +474,7 @@ LL | _ => {}
474474 | ^ no value can reach this
475475
476476error[E0004]: non-exhaustive patterns: `[]` not covered
477 --> $DIR/empty-types.rs:395:11
477 --> $DIR/empty-types.rs:396:11
478478 |
479479LL | match array_0_never {
480480 | ^^^^^^^^^^^^^ pattern `[]` not covered
......@@ -488,7 +488,7 @@ LL + [] => todo!()
488488 |
489489
490490error: unreachable pattern
491 --> $DIR/empty-types.rs:414:9
491 --> $DIR/empty-types.rs:415:9
492492 |
493493LL | Some(_) => {}
494494 | ^^^^^^^------
......@@ -499,7 +499,7 @@ LL | Some(_) => {}
499499 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
500500
501501error: unreachable pattern
502 --> $DIR/empty-types.rs:419:9
502 --> $DIR/empty-types.rs:420:9
503503 |
504504LL | Some(_a) => {}
505505 | ^^^^^^^^------
......@@ -510,7 +510,7 @@ LL | Some(_a) => {}
510510 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
511511
512512error: unreachable pattern
513 --> $DIR/empty-types.rs:424:9
513 --> $DIR/empty-types.rs:425:9
514514 |
515515LL | None => {}
516516 | ---- matches all the relevant values
......@@ -519,7 +519,7 @@ LL | _ => {}
519519 | ^ no value can reach this
520520
521521error: unreachable pattern
522 --> $DIR/empty-types.rs:429:9
522 --> $DIR/empty-types.rs:430:9
523523 |
524524LL | None => {}
525525 | ---- matches all the relevant values
......@@ -528,7 +528,7 @@ LL | _a => {}
528528 | ^^ no value can reach this
529529
530530error: unreachable pattern
531 --> $DIR/empty-types.rs:601:9
531 --> $DIR/empty-types.rs:602:9
532532 |
533533LL | _ => {}
534534 | ^------
......@@ -539,7 +539,7 @@ LL | _ => {}
539539 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
540540
541541error: unreachable pattern
542 --> $DIR/empty-types.rs:604:9
542 --> $DIR/empty-types.rs:605:9
543543 |
544544LL | _x => {}
545545 | ^^------
......@@ -550,7 +550,7 @@ LL | _x => {}
550550 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
551551
552552error: unreachable pattern
553 --> $DIR/empty-types.rs:607:9
553 --> $DIR/empty-types.rs:608:9
554554 |
555555LL | _ if false => {}
556556 | ^---------------
......@@ -561,7 +561,7 @@ LL | _ if false => {}
561561 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
562562
563563error: unreachable pattern
564 --> $DIR/empty-types.rs:610:9
564 --> $DIR/empty-types.rs:611:9
565565 |
566566LL | _x if false => {}
567567 | ^^---------------
tests/ui/pattern/usefulness/empty-types.never_pats.stderr+43-43
......@@ -1,5 +1,5 @@
11error: unreachable pattern
2 --> $DIR/empty-types.rs:47:9
2 --> $DIR/empty-types.rs:48:9
33 |
44LL | _ => {}
55 | ^------
......@@ -9,13 +9,13 @@ LL | _ => {}
99 |
1010 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
1111note: the lint level is defined here
12 --> $DIR/empty-types.rs:13:9
12 --> $DIR/empty-types.rs:14:9
1313 |
1414LL | #![deny(unreachable_patterns)]
1515 | ^^^^^^^^^^^^^^^^^^^^
1616
1717error: unreachable pattern
18 --> $DIR/empty-types.rs:50:9
18 --> $DIR/empty-types.rs:51:9
1919 |
2020LL | _x => {}
2121 | ^^------
......@@ -26,7 +26,7 @@ LL | _x => {}
2626 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
2727
2828error[E0004]: non-exhaustive patterns: type `&!` is non-empty
29 --> $DIR/empty-types.rs:54:11
29 --> $DIR/empty-types.rs:55:11
3030 |
3131LL | match ref_never {}
3232 | ^^^^^^^^^
......@@ -41,7 +41,7 @@ LL ~ }
4141 |
4242
4343error: unreachable pattern
44 --> $DIR/empty-types.rs:81:9
44 --> $DIR/empty-types.rs:82:9
4545 |
4646LL | _ => {}
4747 | ^------
......@@ -52,7 +52,7 @@ LL | _ => {}
5252 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
5353
5454error[E0004]: non-exhaustive patterns: `Ok(_)` not covered
55 --> $DIR/empty-types.rs:85:11
55 --> $DIR/empty-types.rs:86:11
5656 |
5757LL | match res_u32_never {}
5858 | ^^^^^^^^^^^^^ pattern `Ok(_)` not covered
......@@ -71,7 +71,7 @@ LL ~ }
7171 |
7272
7373error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered
74 --> $DIR/empty-types.rs:94:11
74 --> $DIR/empty-types.rs:95:11
7575 |
7676LL | match res_u32_never {
7777 | ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered
......@@ -89,7 +89,7 @@ LL ~ Ok(1_u32..=u32::MAX) => todo!()
8989 |
9090
9191error[E0005]: refutable pattern in local binding
92 --> $DIR/empty-types.rs:100:9
92 --> $DIR/empty-types.rs:101:9
9393 |
9494LL | let Ok(_x) = res_u32_never.as_ref();
9595 | ^^^^^^ pattern `Err(_)` not covered
......@@ -103,7 +103,7 @@ LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() };
103103 | ++++++++++++++++
104104
105105error[E0005]: refutable pattern in local binding
106 --> $DIR/empty-types.rs:104:9
106 --> $DIR/empty-types.rs:105:9
107107 |
108108LL | let Ok(_x) = &res_u32_never;
109109 | ^^^^^^ pattern `&Err(!)` not covered
......@@ -117,7 +117,7 @@ LL | let Ok(_x) = &res_u32_never else { todo!() };
117117 | ++++++++++++++++
118118
119119error: unreachable pattern
120 --> $DIR/empty-types.rs:130:13
120 --> $DIR/empty-types.rs:131:13
121121 |
122122LL | _ => {}
123123 | ^------
......@@ -128,7 +128,7 @@ LL | _ => {}
128128 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
129129
130130error: unreachable pattern
131 --> $DIR/empty-types.rs:133:13
131 --> $DIR/empty-types.rs:134:13
132132 |
133133LL | _ if false => {}
134134 | ^---------------
......@@ -139,7 +139,7 @@ LL | _ if false => {}
139139 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
140140
141141error[E0004]: non-exhaustive patterns: `Some(!)` not covered
142 --> $DIR/empty-types.rs:154:15
142 --> $DIR/empty-types.rs:155:15
143143 |
144144LL | match *ref_opt_void {
145145 | ^^^^^^^^^^^^^ pattern `Some(!)` not covered
......@@ -158,7 +158,7 @@ LL + Some(!)
158158 |
159159
160160error: unreachable pattern
161 --> $DIR/empty-types.rs:197:13
161 --> $DIR/empty-types.rs:198:13
162162 |
163163LL | _ => {}
164164 | ^------
......@@ -169,7 +169,7 @@ LL | _ => {}
169169 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
170170
171171error: unreachable pattern
172 --> $DIR/empty-types.rs:202:13
172 --> $DIR/empty-types.rs:203:13
173173 |
174174LL | _ => {}
175175 | ^------
......@@ -180,7 +180,7 @@ LL | _ => {}
180180 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
181181
182182error: unreachable pattern
183 --> $DIR/empty-types.rs:207:13
183 --> $DIR/empty-types.rs:208:13
184184 |
185185LL | _ => {}
186186 | ^------
......@@ -191,7 +191,7 @@ LL | _ => {}
191191 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
192192
193193error: unreachable pattern
194 --> $DIR/empty-types.rs:212:13
194 --> $DIR/empty-types.rs:213:13
195195 |
196196LL | _ => {}
197197 | ^------
......@@ -202,7 +202,7 @@ LL | _ => {}
202202 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
203203
204204error: unreachable pattern
205 --> $DIR/empty-types.rs:218:13
205 --> $DIR/empty-types.rs:219:13
206206 |
207207LL | _ => {}
208208 | ^------
......@@ -213,7 +213,7 @@ LL | _ => {}
213213 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
214214
215215error: unreachable pattern
216 --> $DIR/empty-types.rs:279:9
216 --> $DIR/empty-types.rs:280:9
217217 |
218218LL | _ => {}
219219 | ^------
......@@ -224,7 +224,7 @@ LL | _ => {}
224224 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
225225
226226error[E0005]: refutable pattern in local binding
227 --> $DIR/empty-types.rs:295:13
227 --> $DIR/empty-types.rs:296:13
228228 |
229229LL | let Ok(_) = *ptr_result_never_err;
230230 | ^^^^^ pattern `Err(!)` not covered
......@@ -238,7 +238,7 @@ LL | if let Ok(_) = *ptr_result_never_err { todo!() };
238238 | ++ +++++++++++
239239
240240error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty
241 --> $DIR/empty-types.rs:314:11
241 --> $DIR/empty-types.rs:315:11
242242 |
243243LL | match *x {}
244244 | ^^
......@@ -252,7 +252,7 @@ LL ~ }
252252 |
253253
254254error[E0004]: non-exhaustive patterns: type `(!, !)` is non-empty
255 --> $DIR/empty-types.rs:316:11
255 --> $DIR/empty-types.rs:317:11
256256 |
257257LL | match *x {}
258258 | ^^
......@@ -266,7 +266,7 @@ LL ~ }
266266 |
267267
268268error[E0004]: non-exhaustive patterns: `Ok(!)` and `Err(!)` not covered
269 --> $DIR/empty-types.rs:318:11
269 --> $DIR/empty-types.rs:319:11
270270 |
271271LL | match *x {}
272272 | ^^ patterns `Ok(!)` and `Err(!)` not covered
......@@ -288,7 +288,7 @@ LL ~ }
288288 |
289289
290290error[E0004]: non-exhaustive patterns: type `[!; 3]` is non-empty
291 --> $DIR/empty-types.rs:320:11
291 --> $DIR/empty-types.rs:321:11
292292 |
293293LL | match *x {}
294294 | ^^
......@@ -302,7 +302,7 @@ LL ~ }
302302 |
303303
304304error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty
305 --> $DIR/empty-types.rs:325:11
305 --> $DIR/empty-types.rs:326:11
306306 |
307307LL | match slice_never {}
308308 | ^^^^^^^^^^^
......@@ -316,7 +316,7 @@ LL ~ }
316316 |
317317
318318error[E0004]: non-exhaustive patterns: `&[!, ..]` not covered
319 --> $DIR/empty-types.rs:327:11
319 --> $DIR/empty-types.rs:328:11
320320 |
321321LL | match slice_never {
322322 | ^^^^^^^^^^^ pattern `&[!, ..]` not covered
......@@ -330,7 +330,7 @@ LL + &[!, ..]
330330 |
331331
332332error[E0004]: non-exhaustive patterns: `&[]`, `&[!]` and `&[!, !]` not covered
333 --> $DIR/empty-types.rs:336:11
333 --> $DIR/empty-types.rs:337:11
334334 |
335335LL | match slice_never {
336336 | ^^^^^^^^^^^ patterns `&[]`, `&[!]` and `&[!, !]` not covered
......@@ -343,7 +343,7 @@ LL + &[] | &[!] | &[!, !] => todo!()
343343 |
344344
345345error[E0004]: non-exhaustive patterns: `&[]` and `&[!, ..]` not covered
346 --> $DIR/empty-types.rs:350:11
346 --> $DIR/empty-types.rs:351:11
347347 |
348348LL | match slice_never {
349349 | ^^^^^^^^^^^ patterns `&[]` and `&[!, ..]` not covered
......@@ -357,7 +357,7 @@ LL + &[] | &[!, ..] => todo!()
357357 |
358358
359359error[E0004]: non-exhaustive patterns: type `[!]` is non-empty
360 --> $DIR/empty-types.rs:357:11
360 --> $DIR/empty-types.rs:358:11
361361 |
362362LL | match *slice_never {}
363363 | ^^^^^^^^^^^^
......@@ -371,7 +371,7 @@ LL ~ }
371371 |
372372
373373error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty
374 --> $DIR/empty-types.rs:386:11
374 --> $DIR/empty-types.rs:387:11
375375 |
376376LL | match array_0_never {}
377377 | ^^^^^^^^^^^^^
......@@ -385,7 +385,7 @@ LL ~ }
385385 |
386386
387387error: unreachable pattern
388 --> $DIR/empty-types.rs:393:9
388 --> $DIR/empty-types.rs:394:9
389389 |
390390LL | [] => {}
391391 | -- matches all the relevant values
......@@ -393,7 +393,7 @@ LL | _ => {}
393393 | ^ no value can reach this
394394
395395error[E0004]: non-exhaustive patterns: `[]` not covered
396 --> $DIR/empty-types.rs:395:11
396 --> $DIR/empty-types.rs:396:11
397397 |
398398LL | match array_0_never {
399399 | ^^^^^^^^^^^^^ pattern `[]` not covered
......@@ -407,7 +407,7 @@ LL + [] => todo!()
407407 |
408408
409409error[E0004]: non-exhaustive patterns: `&Some(!)` not covered
410 --> $DIR/empty-types.rs:449:11
410 --> $DIR/empty-types.rs:450:11
411411 |
412412LL | match ref_opt_never {
413413 | ^^^^^^^^^^^^^ pattern `&Some(!)` not covered
......@@ -426,7 +426,7 @@ LL + &Some(!)
426426 |
427427
428428error[E0004]: non-exhaustive patterns: `Some(!)` not covered
429 --> $DIR/empty-types.rs:490:11
429 --> $DIR/empty-types.rs:491:11
430430 |
431431LL | match *ref_opt_never {
432432 | ^^^^^^^^^^^^^^ pattern `Some(!)` not covered
......@@ -445,7 +445,7 @@ LL + Some(!)
445445 |
446446
447447error[E0004]: non-exhaustive patterns: `Err(!)` not covered
448 --> $DIR/empty-types.rs:538:11
448 --> $DIR/empty-types.rs:539:11
449449 |
450450LL | match *ref_res_never {
451451 | ^^^^^^^^^^^^^^ pattern `Err(!)` not covered
......@@ -464,7 +464,7 @@ LL + Err(!)
464464 |
465465
466466error[E0004]: non-exhaustive patterns: `Err(!)` not covered
467 --> $DIR/empty-types.rs:549:11
467 --> $DIR/empty-types.rs:550:11
468468 |
469469LL | match *ref_res_never {
470470 | ^^^^^^^^^^^^^^ pattern `Err(!)` not covered
......@@ -483,7 +483,7 @@ LL + Err(!)
483483 |
484484
485485error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty
486 --> $DIR/empty-types.rs:568:11
486 --> $DIR/empty-types.rs:569:11
487487 |
488488LL | match *ref_tuple_half_never {}
489489 | ^^^^^^^^^^^^^^^^^^^^^
......@@ -497,7 +497,7 @@ LL ~ }
497497 |
498498
499499error: unreachable pattern
500 --> $DIR/empty-types.rs:601:9
500 --> $DIR/empty-types.rs:602:9
501501 |
502502LL | _ => {}
503503 | ^------
......@@ -508,7 +508,7 @@ LL | _ => {}
508508 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
509509
510510error: unreachable pattern
511 --> $DIR/empty-types.rs:604:9
511 --> $DIR/empty-types.rs:605:9
512512 |
513513LL | _x => {}
514514 | ^^------
......@@ -519,7 +519,7 @@ LL | _x => {}
519519 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
520520
521521error: unreachable pattern
522 --> $DIR/empty-types.rs:607:9
522 --> $DIR/empty-types.rs:608:9
523523 |
524524LL | _ if false => {}
525525 | ^---------------
......@@ -530,7 +530,7 @@ LL | _ if false => {}
530530 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
531531
532532error: unreachable pattern
533 --> $DIR/empty-types.rs:610:9
533 --> $DIR/empty-types.rs:611:9
534534 |
535535LL | _x if false => {}
536536 | ^^---------------
......@@ -541,7 +541,7 @@ LL | _x if false => {}
541541 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
542542
543543error[E0004]: non-exhaustive patterns: `&!` not covered
544 --> $DIR/empty-types.rs:635:11
544 --> $DIR/empty-types.rs:636:11
545545 |
546546LL | match ref_never {
547547 | ^^^^^^^^^ pattern `&!` not covered
......@@ -557,7 +557,7 @@ LL + &!
557557 |
558558
559559error[E0004]: non-exhaustive patterns: `Ok(!)` not covered
560 --> $DIR/empty-types.rs:651:11
560 --> $DIR/empty-types.rs:652:11
561561 |
562562LL | match *ref_result_never {
563563 | ^^^^^^^^^^^^^^^^^ pattern `Ok(!)` not covered
......@@ -577,7 +577,7 @@ LL + Ok(!)
577577 |
578578
579579error[E0004]: non-exhaustive patterns: `Some(!)` not covered
580 --> $DIR/empty-types.rs:671:11
580 --> $DIR/empty-types.rs:672:11
581581 |
582582LL | match *x {
583583 | ^^ pattern `Some(!)` not covered
tests/ui/pattern/usefulness/empty-types.normal.stderr+43-43
......@@ -1,5 +1,5 @@
11error: unreachable pattern
2 --> $DIR/empty-types.rs:47:9
2 --> $DIR/empty-types.rs:48:9
33 |
44LL | _ => {}
55 | ^------
......@@ -9,13 +9,13 @@ LL | _ => {}
99 |
1010 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
1111note: the lint level is defined here
12 --> $DIR/empty-types.rs:13:9
12 --> $DIR/empty-types.rs:14:9
1313 |
1414LL | #![deny(unreachable_patterns)]
1515 | ^^^^^^^^^^^^^^^^^^^^
1616
1717error: unreachable pattern
18 --> $DIR/empty-types.rs:50:9
18 --> $DIR/empty-types.rs:51:9
1919 |
2020LL | _x => {}
2121 | ^^------
......@@ -26,7 +26,7 @@ LL | _x => {}
2626 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
2727
2828error[E0004]: non-exhaustive patterns: type `&!` is non-empty
29 --> $DIR/empty-types.rs:54:11
29 --> $DIR/empty-types.rs:55:11
3030 |
3131LL | match ref_never {}
3232 | ^^^^^^^^^
......@@ -41,7 +41,7 @@ LL ~ }
4141 |
4242
4343error: unreachable pattern
44 --> $DIR/empty-types.rs:81:9
44 --> $DIR/empty-types.rs:82:9
4545 |
4646LL | _ => {}
4747 | ^------
......@@ -52,7 +52,7 @@ LL | _ => {}
5252 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
5353
5454error[E0004]: non-exhaustive patterns: `Ok(_)` not covered
55 --> $DIR/empty-types.rs:85:11
55 --> $DIR/empty-types.rs:86:11
5656 |
5757LL | match res_u32_never {}
5858 | ^^^^^^^^^^^^^ pattern `Ok(_)` not covered
......@@ -71,7 +71,7 @@ LL ~ }
7171 |
7272
7373error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered
74 --> $DIR/empty-types.rs:94:11
74 --> $DIR/empty-types.rs:95:11
7575 |
7676LL | match res_u32_never {
7777 | ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered
......@@ -89,7 +89,7 @@ LL ~ Ok(1_u32..=u32::MAX) => todo!()
8989 |
9090
9191error[E0005]: refutable pattern in local binding
92 --> $DIR/empty-types.rs:100:9
92 --> $DIR/empty-types.rs:101:9
9393 |
9494LL | let Ok(_x) = res_u32_never.as_ref();
9595 | ^^^^^^ pattern `Err(_)` not covered
......@@ -103,7 +103,7 @@ LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() };
103103 | ++++++++++++++++
104104
105105error[E0005]: refutable pattern in local binding
106 --> $DIR/empty-types.rs:104:9
106 --> $DIR/empty-types.rs:105:9
107107 |
108108LL | let Ok(_x) = &res_u32_never;
109109 | ^^^^^^ pattern `&Err(_)` not covered
......@@ -117,7 +117,7 @@ LL | let Ok(_x) = &res_u32_never else { todo!() };
117117 | ++++++++++++++++
118118
119119error: unreachable pattern
120 --> $DIR/empty-types.rs:130:13
120 --> $DIR/empty-types.rs:131:13
121121 |
122122LL | _ => {}
123123 | ^------
......@@ -128,7 +128,7 @@ LL | _ => {}
128128 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
129129
130130error: unreachable pattern
131 --> $DIR/empty-types.rs:133:13
131 --> $DIR/empty-types.rs:134:13
132132 |
133133LL | _ if false => {}
134134 | ^---------------
......@@ -139,7 +139,7 @@ LL | _ if false => {}
139139 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
140140
141141error[E0004]: non-exhaustive patterns: `Some(_)` not covered
142 --> $DIR/empty-types.rs:154:15
142 --> $DIR/empty-types.rs:155:15
143143 |
144144LL | match *ref_opt_void {
145145 | ^^^^^^^^^^^^^ pattern `Some(_)` not covered
......@@ -158,7 +158,7 @@ LL + Some(_) => todo!()
158158 |
159159
160160error: unreachable pattern
161 --> $DIR/empty-types.rs:197:13
161 --> $DIR/empty-types.rs:198:13
162162 |
163163LL | _ => {}
164164 | ^------
......@@ -169,7 +169,7 @@ LL | _ => {}
169169 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
170170
171171error: unreachable pattern
172 --> $DIR/empty-types.rs:202:13
172 --> $DIR/empty-types.rs:203:13
173173 |
174174LL | _ => {}
175175 | ^------
......@@ -180,7 +180,7 @@ LL | _ => {}
180180 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
181181
182182error: unreachable pattern
183 --> $DIR/empty-types.rs:207:13
183 --> $DIR/empty-types.rs:208:13
184184 |
185185LL | _ => {}
186186 | ^------
......@@ -191,7 +191,7 @@ LL | _ => {}
191191 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
192192
193193error: unreachable pattern
194 --> $DIR/empty-types.rs:212:13
194 --> $DIR/empty-types.rs:213:13
195195 |
196196LL | _ => {}
197197 | ^------
......@@ -202,7 +202,7 @@ LL | _ => {}
202202 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
203203
204204error: unreachable pattern
205 --> $DIR/empty-types.rs:218:13
205 --> $DIR/empty-types.rs:219:13
206206 |
207207LL | _ => {}
208208 | ^------
......@@ -213,7 +213,7 @@ LL | _ => {}
213213 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
214214
215215error: unreachable pattern
216 --> $DIR/empty-types.rs:279:9
216 --> $DIR/empty-types.rs:280:9
217217 |
218218LL | _ => {}
219219 | ^------
......@@ -224,7 +224,7 @@ LL | _ => {}
224224 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
225225
226226error[E0005]: refutable pattern in local binding
227 --> $DIR/empty-types.rs:295:13
227 --> $DIR/empty-types.rs:296:13
228228 |
229229LL | let Ok(_) = *ptr_result_never_err;
230230 | ^^^^^ pattern `Err(_)` not covered
......@@ -238,7 +238,7 @@ LL | if let Ok(_) = *ptr_result_never_err { todo!() };
238238 | ++ +++++++++++
239239
240240error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty
241 --> $DIR/empty-types.rs:314:11
241 --> $DIR/empty-types.rs:315:11
242242 |
243243LL | match *x {}
244244 | ^^
......@@ -252,7 +252,7 @@ LL ~ }
252252 |
253253
254254error[E0004]: non-exhaustive patterns: type `(!, !)` is non-empty
255 --> $DIR/empty-types.rs:316:11
255 --> $DIR/empty-types.rs:317:11
256256 |
257257LL | match *x {}
258258 | ^^
......@@ -266,7 +266,7 @@ LL ~ }
266266 |
267267
268268error[E0004]: non-exhaustive patterns: `Ok(_)` and `Err(_)` not covered
269 --> $DIR/empty-types.rs:318:11
269 --> $DIR/empty-types.rs:319:11
270270 |
271271LL | match *x {}
272272 | ^^ patterns `Ok(_)` and `Err(_)` not covered
......@@ -288,7 +288,7 @@ LL ~ }
288288 |
289289
290290error[E0004]: non-exhaustive patterns: type `[!; 3]` is non-empty
291 --> $DIR/empty-types.rs:320:11
291 --> $DIR/empty-types.rs:321:11
292292 |
293293LL | match *x {}
294294 | ^^
......@@ -302,7 +302,7 @@ LL ~ }
302302 |
303303
304304error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty
305 --> $DIR/empty-types.rs:325:11
305 --> $DIR/empty-types.rs:326:11
306306 |
307307LL | match slice_never {}
308308 | ^^^^^^^^^^^
......@@ -316,7 +316,7 @@ LL ~ }
316316 |
317317
318318error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered
319 --> $DIR/empty-types.rs:327:11
319 --> $DIR/empty-types.rs:328:11
320320 |
321321LL | match slice_never {
322322 | ^^^^^^^^^^^ pattern `&[_, ..]` not covered
......@@ -330,7 +330,7 @@ LL + &[_, ..] => todo!()
330330 |
331331
332332error[E0004]: non-exhaustive patterns: `&[]`, `&[_]` and `&[_, _]` not covered
333 --> $DIR/empty-types.rs:336:11
333 --> $DIR/empty-types.rs:337:11
334334 |
335335LL | match slice_never {
336336 | ^^^^^^^^^^^ patterns `&[]`, `&[_]` and `&[_, _]` not covered
......@@ -343,7 +343,7 @@ LL + &[] | &[_] | &[_, _] => todo!()
343343 |
344344
345345error[E0004]: non-exhaustive patterns: `&[]` and `&[_, ..]` not covered
346 --> $DIR/empty-types.rs:350:11
346 --> $DIR/empty-types.rs:351:11
347347 |
348348LL | match slice_never {
349349 | ^^^^^^^^^^^ patterns `&[]` and `&[_, ..]` not covered
......@@ -357,7 +357,7 @@ LL + &[] | &[_, ..] => todo!()
357357 |
358358
359359error[E0004]: non-exhaustive patterns: type `[!]` is non-empty
360 --> $DIR/empty-types.rs:357:11
360 --> $DIR/empty-types.rs:358:11
361361 |
362362LL | match *slice_never {}
363363 | ^^^^^^^^^^^^
......@@ -371,7 +371,7 @@ LL ~ }
371371 |
372372
373373error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty
374 --> $DIR/empty-types.rs:386:11
374 --> $DIR/empty-types.rs:387:11
375375 |
376376LL | match array_0_never {}
377377 | ^^^^^^^^^^^^^
......@@ -385,7 +385,7 @@ LL ~ }
385385 |
386386
387387error: unreachable pattern
388 --> $DIR/empty-types.rs:393:9
388 --> $DIR/empty-types.rs:394:9
389389 |
390390LL | [] => {}
391391 | -- matches all the relevant values
......@@ -393,7 +393,7 @@ LL | _ => {}
393393 | ^ no value can reach this
394394
395395error[E0004]: non-exhaustive patterns: `[]` not covered
396 --> $DIR/empty-types.rs:395:11
396 --> $DIR/empty-types.rs:396:11
397397 |
398398LL | match array_0_never {
399399 | ^^^^^^^^^^^^^ pattern `[]` not covered
......@@ -407,7 +407,7 @@ LL + [] => todo!()
407407 |
408408
409409error[E0004]: non-exhaustive patterns: `&Some(_)` not covered
410 --> $DIR/empty-types.rs:449:11
410 --> $DIR/empty-types.rs:450:11
411411 |
412412LL | match ref_opt_never {
413413 | ^^^^^^^^^^^^^ pattern `&Some(_)` not covered
......@@ -426,7 +426,7 @@ LL + &Some(_) => todo!()
426426 |
427427
428428error[E0004]: non-exhaustive patterns: `Some(_)` not covered
429 --> $DIR/empty-types.rs:490:11
429 --> $DIR/empty-types.rs:491:11
430430 |
431431LL | match *ref_opt_never {
432432 | ^^^^^^^^^^^^^^ pattern `Some(_)` not covered
......@@ -445,7 +445,7 @@ LL + Some(_) => todo!()
445445 |
446446
447447error[E0004]: non-exhaustive patterns: `Err(_)` not covered
448 --> $DIR/empty-types.rs:538:11
448 --> $DIR/empty-types.rs:539:11
449449 |
450450LL | match *ref_res_never {
451451 | ^^^^^^^^^^^^^^ pattern `Err(_)` not covered
......@@ -464,7 +464,7 @@ LL + Err(_) => todo!()
464464 |
465465
466466error[E0004]: non-exhaustive patterns: `Err(_)` not covered
467 --> $DIR/empty-types.rs:549:11
467 --> $DIR/empty-types.rs:550:11
468468 |
469469LL | match *ref_res_never {
470470 | ^^^^^^^^^^^^^^ pattern `Err(_)` not covered
......@@ -483,7 +483,7 @@ LL + Err(_) => todo!()
483483 |
484484
485485error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty
486 --> $DIR/empty-types.rs:568:11
486 --> $DIR/empty-types.rs:569:11
487487 |
488488LL | match *ref_tuple_half_never {}
489489 | ^^^^^^^^^^^^^^^^^^^^^
......@@ -497,7 +497,7 @@ LL ~ }
497497 |
498498
499499error: unreachable pattern
500 --> $DIR/empty-types.rs:601:9
500 --> $DIR/empty-types.rs:602:9
501501 |
502502LL | _ => {}
503503 | ^------
......@@ -508,7 +508,7 @@ LL | _ => {}
508508 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
509509
510510error: unreachable pattern
511 --> $DIR/empty-types.rs:604:9
511 --> $DIR/empty-types.rs:605:9
512512 |
513513LL | _x => {}
514514 | ^^------
......@@ -519,7 +519,7 @@ LL | _x => {}
519519 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
520520
521521error: unreachable pattern
522 --> $DIR/empty-types.rs:607:9
522 --> $DIR/empty-types.rs:608:9
523523 |
524524LL | _ if false => {}
525525 | ^---------------
......@@ -530,7 +530,7 @@ LL | _ if false => {}
530530 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
531531
532532error: unreachable pattern
533 --> $DIR/empty-types.rs:610:9
533 --> $DIR/empty-types.rs:611:9
534534 |
535535LL | _x if false => {}
536536 | ^^---------------
......@@ -541,7 +541,7 @@ LL | _x if false => {}
541541 = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
542542
543543error[E0004]: non-exhaustive patterns: `&_` not covered
544 --> $DIR/empty-types.rs:635:11
544 --> $DIR/empty-types.rs:636:11
545545 |
546546LL | match ref_never {
547547 | ^^^^^^^^^ pattern `&_` not covered
......@@ -557,7 +557,7 @@ LL + &_ => todo!()
557557 |
558558
559559error[E0004]: non-exhaustive patterns: `Ok(_)` not covered
560 --> $DIR/empty-types.rs:651:11
560 --> $DIR/empty-types.rs:652:11
561561 |
562562LL | match *ref_result_never {
563563 | ^^^^^^^^^^^^^^^^^ pattern `Ok(_)` not covered
......@@ -577,7 +577,7 @@ LL + Ok(_) => todo!()
577577 |
578578
579579error[E0004]: non-exhaustive patterns: `Some(_)` not covered
580 --> $DIR/empty-types.rs:671:11
580 --> $DIR/empty-types.rs:672:11
581581 |
582582LL | match *x {
583583 | ^^ pattern `Some(_)` not covered
tests/ui/pattern/usefulness/empty-types.rs+1
......@@ -1,5 +1,6 @@
11//@ revisions: normal exhaustive_patterns never_pats
22//@ edition: 2024
3//@ ignore-parallel-frontend pattern matching error message mismatch
34//
45// This tests correct handling of empty types in exhaustiveness checking.
56//
tests/ui/pin-ergonomics/pinned-drop-sugar-not-other-traits.rs-2
......@@ -12,7 +12,6 @@ trait NeedsPinDrop {
1212}
1313
1414impl NeedsPinDrop for S {
15 //~^ ERROR not all trait items implemented, missing: `pin_drop` [E0046]
1615 fn drop(&pin mut self) {}
1716 //~^ ERROR method `drop` with `&pin mut self` is only supported for the `Drop` trait
1817}
......@@ -53,7 +52,6 @@ mod local_drop_trait {
5352 }
5453
5554 impl Drop for S {
56 //~^ ERROR not all trait items implemented, missing: `pin_drop` [E0046]
5755 fn drop(&pin mut self) {}
5856 //~^ ERROR method `drop` with `&pin mut self` is only supported for the `Drop` trait
5957 }
tests/ui/pin-ergonomics/pinned-drop-sugar-not-other-traits.stderr+7-25
......@@ -1,5 +1,5 @@
11error[E0407]: method `drop` is not a member of trait `HasDrop`
2 --> $DIR/pinned-drop-sugar-not-other-traits.rs:26:5
2 --> $DIR/pinned-drop-sugar-not-other-traits.rs:25:5
33 |
44LL | fn drop(&pin mut self) {}
55 | ^^^----^^^^^^^^^^^^^^^^^^
......@@ -8,7 +8,7 @@ LL | fn drop(&pin mut self) {}
88 | not a member of trait `HasDrop`
99
1010error[E0407]: method `drop` is not a member of trait `HasPinnedDropReceiver`
11 --> $DIR/pinned-drop-sugar-not-other-traits.rs:36:5
11 --> $DIR/pinned-drop-sugar-not-other-traits.rs:35:5
1212 |
1313LL | fn drop(&pin mut self) {}
1414 | ^^^----^^^^^^^^^^^^^^^^^^
......@@ -17,28 +17,19 @@ LL | fn drop(&pin mut self) {}
1717 | not a member of trait `HasPinnedDropReceiver`
1818
1919error: method `drop` with `&pin mut self` is only supported for the `Drop` trait
20 --> $DIR/pinned-drop-sugar-not-other-traits.rs:16:5
20 --> $DIR/pinned-drop-sugar-not-other-traits.rs:15:5
2121 |
2222LL | fn drop(&pin mut self) {}
2323 | ^^^^^^^^^^^^^^^^^^^^^^^^^ not a `Drop::pin_drop` implementation
2424
2525error: method `drop` with `&pin mut self` is only supported for the `Drop` trait
26 --> $DIR/pinned-drop-sugar-not-other-traits.rs:57:9
26 --> $DIR/pinned-drop-sugar-not-other-traits.rs:55:9
2727 |
2828LL | fn drop(&pin mut self) {}
2929 | ^^^^^^^^^^^^^^^^^^^^^^^^^ not a `Drop::pin_drop` implementation
3030
31error[E0046]: not all trait items implemented, missing: `pin_drop`
32 --> $DIR/pinned-drop-sugar-not-other-traits.rs:14:1
33 |
34LL | fn pin_drop(self: Pin<&mut Self>);
35 | ---------------------------------- `pin_drop` from trait
36...
37LL | impl NeedsPinDrop for S {
38 | ^^^^^^^^^^^^^^^^^^^^^^^ missing `pin_drop` in implementation
39
4031error[E0046]: not all trait items implemented, missing: `drop`
41 --> $DIR/pinned-drop-sugar-not-other-traits.rs:24:1
32 --> $DIR/pinned-drop-sugar-not-other-traits.rs:23:1
4233 |
4334LL | fn drop(self: Pin<&mut Self>);
4435 | ------------------------------ `drop` from trait
......@@ -47,7 +38,7 @@ LL | impl HasDrop for S {
4738 | ^^^^^^^^^^^^^^^^^^ missing `drop` in implementation
4839
4940error[E0046]: not all trait items implemented, missing: `drop`
50 --> $DIR/pinned-drop-sugar-not-other-traits.rs:34:1
41 --> $DIR/pinned-drop-sugar-not-other-traits.rs:33:1
5142 |
5243LL | fn drop(self: &pin mut Self);
5344 | ----------------------------- `drop` from trait
......@@ -55,16 +46,7 @@ LL | fn drop(self: &pin mut Self);
5546LL | impl HasPinnedDropReceiver for S {
5647 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation
5748
58error[E0046]: not all trait items implemented, missing: `pin_drop`
59 --> $DIR/pinned-drop-sugar-not-other-traits.rs:55:5
60 |
61LL | fn pin_drop(self: Pin<&mut Self>);
62 | ---------------------------------- `pin_drop` from trait
63...
64LL | impl Drop for S {
65 | ^^^^^^^^^^^^^^^ missing `pin_drop` in implementation
66
67error: aborting due to 8 previous errors
49error: aborting due to 6 previous errors
6850
6951Some errors have detailed explanations: E0046, E0407.
7052For more information about an error, try `rustc --explain E0046`.
tests/ui/target-feature/implied-features-nvptx.rs+2-2
......@@ -1,5 +1,5 @@
1//@ assembly-output: ptx-linker
2//@ compile-flags: --crate-type cdylib -C target-cpu=sm_80 -Z unstable-options -Clinker-flavor=llbc
1//@ assembly-output: emit-asm
2//@ compile-flags: --crate-type cdylib -C target-cpu=sm_80
33//@ only-nvptx64
44//@ build-pass
55#![no_std]
tests/ui/target-feature/invalid-attribute.stderr+3-3
......@@ -174,7 +174,7 @@ error: the feature named `foo` is not valid for this target
174174LL | #[target_feature(enable = "foo")]
175175 | ^^^^^^^^^^^^^^ `foo` is not valid for this target
176176 |
177 = help: valid names are: `fma`, `xop`, `adx`, `aes`, and `avx` and 75 more
177 = help: valid names are: `fma`, `xop`, `adx`, `aes`, and `avx` and 76 more
178178
179179error[E0046]: not all trait items implemented, missing: `foo`
180180 --> $DIR/invalid-attribute.rs:80:1
......@@ -226,7 +226,7 @@ error: the feature named `sse5` is not valid for this target
226226LL | #[target_feature(enable = "sse5")]
227227 | ^^^^^^^^^^^^^^^ `sse5` is not valid for this target
228228 |
229 = help: valid names are: `sse`, `sse2`, `sse3`, `sse4a`, and `ssse3` and 75 more
229 = help: valid names are: `sse`, `sse2`, `sse3`, `sse4a`, and `ssse3` and 76 more
230230
231231error: the feature named `avx512` is not valid for this target
232232 --> $DIR/invalid-attribute.rs:126:18
......@@ -234,7 +234,7 @@ error: the feature named `avx512` is not valid for this target
234234LL | #[target_feature(enable = "avx512")]
235235 | ^^^^^^^^^^^^^^^^^ `avx512` is not valid for this target
236236 |
237 = help: valid names are: `avx512f`, `avx2`, `avx512bw`, `avx512cd`, and `avx512dq` and 75 more
237 = help: valid names are: `avx512f`, `avx2`, `avx512bw`, `avx512cd`, and `avx512dq` and 76 more
238238
239239error: aborting due to 26 previous errors
240240