diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs index 8accaa8c3125c..5ea62010c3135 100644 --- a/compiler/rustc_ast_lowering/src/delegation.rs +++ b/compiler/rustc_ast_lowering/src/delegation.rs @@ -124,7 +124,7 @@ impl<'hir> LoweringContext<'_, 'hir> { // Delegation can be unresolved in illegal places such as function bodies in extern blocks (see #151356) let sig_id = if let Some(delegation_info) = self.resolver.delegation_info(self.owner.def_id) { - self.get_sig_id(delegation_info.resolution_node, span) + self.get_sig_id(delegation_info.resolution_id, span) } else { self.dcx().span_delayed_bug( span, @@ -230,22 +230,12 @@ impl<'hir> LoweringContext<'_, 'hir> { .collect::>() } - fn get_sig_id(&self, mut node_id: NodeId, span: Span) -> Result { - let mut visited: FxHashSet = Default::default(); + fn get_sig_id(&self, mut def_id: DefId, span: Span) -> Result { + let mut visited: FxHashSet = Default::default(); let mut path: SmallVec<[DefId; 1]> = Default::default(); loop { - visited.insert(node_id); - - let Some(def_id) = self.get_resolution_id(node_id) else { - return Err(self.tcx.dcx().span_delayed_bug( - span, - format!( - "LoweringContext: couldn't resolve node {:?} in delegation item", - node_id - ), - )); - }; + visited.insert(def_id); path.push(def_id); @@ -255,8 +245,8 @@ impl<'hir> LoweringContext<'_, 'hir> { if let Some(local_id) = def_id.as_local() && let Some(delegation_info) = self.resolver.delegation_info(local_id) { - node_id = delegation_info.resolution_node; - if visited.contains(&node_id) { + def_id = delegation_info.resolution_id; + if visited.contains(&def_id) { // We encountered a cycle in the resolution, or delegation callee refers to non-existent // entity, in this case emit an error. return Err(match visited.len() { diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index e38415caaa222..70f55d67c7a16 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1192,50 +1192,34 @@ impl<'hir> LoweringContext<'_, 'hir> { }) } - fn resolve_pin_drop_sugar_impl_item( + fn check_pin_drop_sugar_impl_item( &self, i: &AssocItem, ident: Ident, - span: Span, - ) -> (Ident, Result) { - let trait_item_def_id = self - .get_partial_res(i.id) - .and_then(|r| r.expect_full_res().opt_def_id()) - .ok_or_else(|| { - self.dcx().span_delayed_bug(span, "could not resolve trait item being implemented") - }); - - let is_pin_drop_sugar = match &i.kind { - AssocItemKind::Fn(fn_kind) => fn_kind.is_pin_drop_sugar(), - _ => false, - }; - let def_id = match trait_item_def_id { - Ok(def_id) => def_id, - Err(guar) => return (ident, Err(guar)), - }; - if !is_pin_drop_sugar { - return (ident, Ok(def_id)); - } - - let is_drop_pin_drop = self - .tcx - .lang_items() - .drop_trait() - .is_some_and(|drop_trait| self.tcx.parent(def_id) == drop_trait); - if is_drop_pin_drop { - // Associated item collection still derives the impl item's name from HIR. - return (Ident::new(sym::pin_drop, ident.span), Ok(def_id)); + trait_item: Result, + ) -> Ident { + if let AssocItemKind::Fn(fn_kind) = &i.kind + && fn_kind.is_pin_drop_sugar() + { + if let Ok(trait_item) = trait_item + && self + .tcx + .lang_items() + .drop_trait() + .is_none_or(|drop_trait| self.tcx.parent(trait_item) != drop_trait) + { + self.dcx() + .struct_span_err( + i.span, + "method `drop` with `&pin mut self` is only supported for the `Drop` trait", + ) + .with_span_label(i.span, "not a `Drop::pin_drop` implementation") + .emit(); + } + return Ident::new(sym::pin_drop, ident.span); } - let guar = self - .dcx() - .struct_span_err( - i.span, - "method `drop` with `&pin mut self` is only supported for the `Drop` trait", - ) - .with_span_label(i.span, "not a `Drop::pin_drop` implementation") - .emit(); - (ident, Err(guar)) + ident } fn lower_impl_item( @@ -1356,8 +1340,14 @@ impl<'hir> LoweringContext<'_, 'hir> { let span = self.lower_span(i.span); let (effective_ident, impl_kind) = if is_in_trait_impl { - let (effective_ident, trait_item_def_id) = - self.resolve_pin_drop_sugar_impl_item(i, ident, span); + let trait_item_def_id = self + .get_partial_res(i.id) + .and_then(|r| r.expect_full_res().opt_def_id()) + .ok_or_else(|| { + self.dcx() + .span_delayed_bug(span, "could not resolve trait item being implemented") + }); + let effective_ident = self.check_pin_drop_sugar_impl_item(i, ident, trait_item_def_id); (effective_ident, ImplItemImplKind::Trait { defaultness, trait_item_def_id }) } else { (ident, ImplItemImplKind::Inherent { vis_span: self.lower_span(i.vis.span) }) @@ -1928,11 +1918,11 @@ impl<'hir> LoweringContext<'_, 'hir> { // Introduce extra lifetimes if late resolution tells us to. let extra_lifetimes = self.resolver.extra_lifetime_params(parent_node_id); - params.extend(extra_lifetimes.into_iter().filter_map(|&(ident, node_id, res)| { + params.extend(extra_lifetimes.into_iter().map(|&(ident, node_id, kind)| { self.lifetime_res_to_generic_param( ident, node_id, - res, + kind, hir::GenericParamSource::Generics, ) })); diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index a916ee1f143bd..9e855f305ae84 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -55,7 +55,7 @@ use rustc_hir::definitions::PerParentDisambiguatorState; use rustc_hir::lints::DelayedLint; use rustc_hir::{ self as hir, AngleBrackets, ConstArg, GenericArg, HirId, ItemLocalMap, LifetimeSource, - LifetimeSyntax, ParamName, Target, TraitCandidate, find_attr, + LifetimeSyntax, MissingLifetimeKind, ParamName, Target, TraitCandidate, find_attr, }; use rustc_index::{Idx, IndexSlice, IndexVec}; use rustc_macros::extension; @@ -310,7 +310,7 @@ impl<'tcx> ResolverAstLowering<'tcx> { /// /// The extra lifetimes that appear from the parenthesized `Fn`-trait desugaring /// should appear at the enclosing `PolyTraitRef`. - fn extra_lifetime_params(&self, id: NodeId) -> &[(Ident, NodeId, LifetimeRes)] { + fn extra_lifetime_params(&self, id: NodeId) -> &[(Ident, NodeId, MissingLifetimeKind)] { self.extra_lifetime_params_map.get(&id).map_or(&[], |v| &v[..]) } @@ -542,7 +542,7 @@ pub fn lower_to_hir(tcx: TyCtxt<'_>, (): ()) -> mid_hir::Crate<'_> { let ast_index = index_crate(&resolver, &krate); let mut owners = IndexVec::from_fn_n( |_| hir::MaybeOwner::Phantom, - tcx.definitions_untracked().def_index_count(), + tcx.definitions_untracked().num_definitions(), ); let mut lowerer = item::ItemLowerer { @@ -948,43 +948,30 @@ impl<'hir> LoweringContext<'_, 'hir> { &mut self, ident: Ident, node_id: NodeId, - res: LifetimeRes, + kind: MissingLifetimeKind, source: hir::GenericParamSource, - ) -> Option> { - let (name, kind) = match res { - LifetimeRes::Param { .. } => { - (hir::ParamName::Plain(ident), hir::LifetimeParamKind::Explicit) - } - LifetimeRes::Fresh { param, kind, .. } => { - // Late resolution delegates to us the creation of the `LocalDefId`. - let _def_id = self.create_def( - param, - Some(kw::UnderscoreLifetime), - DefKind::LifetimeParam, - ident.span, - ); - debug!(?_def_id); + ) -> hir::GenericParam<'hir> { + // Late resolution delegates to us the creation of the `LocalDefId`. + let _def_id = self.create_def( + node_id, + Some(kw::UnderscoreLifetime), + DefKind::LifetimeParam, + ident.span, + ); + debug!(?_def_id); - (hir::ParamName::Fresh, hir::LifetimeParamKind::Elided(kind)) - } - LifetimeRes::Static { .. } | LifetimeRes::Error(..) => return None, - res => panic!( - "Unexpected lifetime resolution {:?} for {:?} at {:?}", - res, ident, ident.span - ), - }; let hir_id = self.lower_node_id(node_id); let def_id = self.local_def_id(node_id); - Some(hir::GenericParam { + hir::GenericParam { hir_id, def_id, - name, + name: hir::ParamName::Fresh, span: self.lower_span(ident.span), pure_wrt_drop: false, - kind: hir::GenericParamKind::Lifetime { kind }, + kind: hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Elided(kind) }, colon_span: None, source, - }) + } } /// Lowers a lifetime binder that defines `generic_params`, returning the corresponding HIR @@ -1005,7 +992,7 @@ impl<'hir> LoweringContext<'_, 'hir> { debug!(?extra_lifetimes); let extra_lifetimes: Vec<_> = extra_lifetimes .iter() - .filter_map(|&(ident, node_id, res)| { + .map(|&(ident, node_id, res)| { self.lifetime_res_to_generic_param( ident, node_id, diff --git a/compiler/rustc_attr_parsing/src/attributes/deprecation.rs b/compiler/rustc_attr_parsing/src/attributes/deprecation.rs index 3b6dd7a67ed17..e0adbb0900deb 100644 --- a/compiler/rustc_attr_parsing/src/attributes/deprecation.rs +++ b/compiler/rustc_attr_parsing/src/attributes/deprecation.rs @@ -1,3 +1,4 @@ +use rustc_ast::LitKind; use rustc_hir::attrs::{DeprecatedSince, Deprecation}; use rustc_hir::{RustcVersion, VERSION_PLACEHOLDER}; @@ -76,6 +77,38 @@ impl SingleAttributeParser for DeprecatedParser { // ok } ArgParser::List(list) => { + // If the argument list contains a single string literal: + // check whether it may be a version and suggest since field + // otherwise, suggest using NameValue syntax + if let Some(elem) = list.as_single() + && let Some(lit) = elem.as_lit() + && let LitKind::Str(text, _) = lit.kind + { + let mut adcx = cx.adcx(); + + match parse_since(text, true) { + DeprecatedSince::Future | DeprecatedSince::RustcVersion(_) => { + adcx.push_suggestion( + String::from("try specifying a deprecated since version"), + elem.span(), + format!("since = {}", lit.kind), + ); + } + _ => { + if let Some(span) = args.span() { + adcx.push_suggestion( + String::from("try using `=` instead"), + span, + format!(" = {}", lit.kind), + ); + } + } + }; + + adcx.expected_not_literal(elem.span()); + return None; + } + for param in list.mixed() { let Some(param) = param.meta_item() else { cx.adcx().expected_not_literal(param.span()); @@ -133,18 +166,11 @@ impl SingleAttributeParser for DeprecatedParser { } let since = if let Some(since) = since { - if since.as_str() == "TBD" { - DeprecatedSince::Future - } else if !is_rustc { - DeprecatedSince::NonStandard(since) - } else if since.as_str() == VERSION_PLACEHOLDER { - DeprecatedSince::RustcVersion(RustcVersion::CURRENT) - } else if let Some(version) = parse_version(since) { - DeprecatedSince::RustcVersion(version) - } else { + let since = parse_since(since, is_rustc); + if matches!(since, DeprecatedSince::Err) { cx.emit_err(InvalidSince { span: cx.attr_span }); - DeprecatedSince::Err } + since } else if is_rustc { cx.emit_err(MissingSince { span: cx.attr_span }); DeprecatedSince::Err @@ -163,3 +189,17 @@ impl SingleAttributeParser for DeprecatedParser { }) } } + +fn parse_since(since: Symbol, is_rustc: bool) -> DeprecatedSince { + if since.as_str() == "TBD" { + DeprecatedSince::Future + } else if !is_rustc { + DeprecatedSince::NonStandard(since) + } else if since.as_str() == VERSION_PLACEHOLDER { + DeprecatedSince::RustcVersion(RustcVersion::CURRENT) + } else if let Some(version) = parse_version(since) { + DeprecatedSince::RustcVersion(version) + } else { + DeprecatedSince::Err + } +} diff --git a/compiler/rustc_attr_parsing/src/interface.rs b/compiler/rustc_attr_parsing/src/interface.rs index 4a0ad63c0c053..eb49f108b0414 100644 --- a/compiler/rustc_attr_parsing/src/interface.rs +++ b/compiler/rustc_attr_parsing/src/interface.rs @@ -412,9 +412,7 @@ impl<'sess> AttributeParser<'sess> { (accept.accept_fn)(&mut cx, &args); finalizers.push(accept.finalizer); - if !matches!(cx.should_emit, ShouldEmit::Nothing) { - Self::check_target(&accept.allowed_targets, target, &mut cx); - } + Self::check_target(&accept.allowed_targets, &mut cx); } else { let attr = AttrItem { path: attr_path.clone(), diff --git a/compiler/rustc_attr_parsing/src/target_checking.rs b/compiler/rustc_attr_parsing/src/target_checking.rs index fe4d72b83282b..db8650461769f 100644 --- a/compiler/rustc_attr_parsing/src/target_checking.rs +++ b/compiler/rustc_attr_parsing/src/target_checking.rs @@ -7,7 +7,6 @@ use rustc_hir::attrs::AttributeKind; use rustc_hir::{AttrItem, Attribute, MethodKind, Target}; use rustc_span::{BytePos, FileName, RemapPathScopeComponents, Span, Symbol, sym}; -use crate::AttributeParser; use crate::context::AcceptContext; use crate::errors::{ InvalidAttrAtCrateLevel, InvalidTargetLint, ItemFollowingInnerAttr, @@ -15,6 +14,7 @@ use crate::errors::{ }; use crate::session_diagnostics::InvalidTarget; use crate::target_checking::Policy::Allow; +use crate::{AttributeParser, ShouldEmit}; #[derive(Debug)] pub(crate) enum AllowedTargets { @@ -90,17 +90,20 @@ pub(crate) enum Policy { impl<'sess> AttributeParser<'sess> { pub(crate) fn check_target( allowed_targets: &AllowedTargets, - target: Target, cx: &mut AcceptContext<'_, 'sess>, ) { + if matches!(cx.should_emit, ShouldEmit::Nothing) { + return; + } + // For crate-level attributes we emit a specific set of lints to warn // people about accidentally not using them on the crate. if let &AllowedTargets::AllowList(&[Allow(Target::Crate)]) = allowed_targets { - Self::check_crate_level(target, cx); + Self::check_crate_level(cx); return; } - if matches!(cx.attr_path.segments.as_ref(), [sym::repr]) && target == Target::Crate { + if matches!(cx.attr_path.segments.as_ref(), [sym::repr]) && cx.target == Target::Crate { // The allowed targets of `repr` depend on its arguments. They can't be checked using // the `AttributeParser` code. let span = cx.attr_span; @@ -119,11 +122,12 @@ impl<'sess> AttributeParser<'sess> { .emit(); } - match allowed_targets.is_allowed(target) { + match allowed_targets.is_allowed(cx.target) { AllowedResult::Allowed => {} AllowedResult::Warn => { let allowed_targets = allowed_targets.allowed_targets(); - let (applied, only) = allowed_targets_applied(allowed_targets, target, cx.features); + let (applied, only) = + allowed_targets_applied(allowed_targets, cx.target, cx.features); let name = cx.attr_path.clone(); let lint = if name.segments[0] == sym::deprecated @@ -134,7 +138,7 @@ impl<'sess> AttributeParser<'sess> { Target::Arm, Target::MacroCall, ] - .contains(&target) + .contains(&cx.target) { rustc_session::lint::builtin::USELESS_DEPRECATED } else { @@ -142,6 +146,7 @@ impl<'sess> AttributeParser<'sess> { }; let attr_span = cx.attr_span; + let target = cx.target; cx.emit_lint_with_sess( lint, move |dcx, level, _| { @@ -161,12 +166,13 @@ impl<'sess> AttributeParser<'sess> { } AllowedResult::Error => { let allowed_targets = allowed_targets.allowed_targets(); - let (applied, only) = allowed_targets_applied(allowed_targets, target, cx.features); + let (applied, only) = + allowed_targets_applied(allowed_targets, cx.target, cx.features); let name = cx.attr_path.clone(); cx.dcx().emit_err(InvalidTarget { span: cx.attr_span.clone(), name, - target: target.plural_name(), + target: cx.target.plural_name(), only: if only { "only " } else { "" }, applied: DiagArgValue::StrListSepByAnd( applied.into_iter().map(Cow::Owned).collect(), @@ -176,8 +182,8 @@ impl<'sess> AttributeParser<'sess> { } } - pub(crate) fn check_crate_level(target: Target, cx: &mut AcceptContext<'_, 'sess>) { - if target == Target::Crate { + pub(crate) fn check_crate_level(cx: &mut AcceptContext<'_, 'sess>) { + if cx.target == Target::Crate { return; } @@ -200,6 +206,7 @@ impl<'sess> AttributeParser<'sess> { }) .unwrap_or_default(); + let target = cx.target; cx.emit_lint( rustc_session::lint::builtin::UNUSED_ATTRIBUTES, crate::errors::InvalidAttrStyle { diff --git a/compiler/rustc_codegen_gcc/build_system/src/test.rs b/compiler/rustc_codegen_gcc/build_system/src/test.rs index 3f02df8399554..2475a3a6a7155 100644 --- a/compiler/rustc_codegen_gcc/build_system/src/test.rs +++ b/compiler/rustc_codegen_gcc/build_system/src/test.rs @@ -886,8 +886,6 @@ fn valid_ui_error_pattern_test(file: &str) -> bool { "type-alias-impl-trait/auxiliary/cross_crate_ice.rs", "type-alias-impl-trait/auxiliary/cross_crate_ice2.rs", "macros/rfc-2011-nicer-assert-messages/auxiliary/common.rs", - "imports/ambiguous-1.rs", - "imports/ambiguous-4-extern.rs", "entry-point/auxiliary/bad_main_functions.rs", ] .iter() diff --git a/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs b/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs index 73822eb7ec50c..0b009321802cf 100644 --- a/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs +++ b/compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs @@ -319,25 +319,26 @@ impl KernelArgsTy { geps: [&'ll Value; 3], workgroup_dims: &'ll Value, thread_dims: &'ll Value, - ) -> [(Align, &'ll Value); 13] { + dyn_cache: &'ll Value, + ) -> [(Align, &'ll str, &'ll Value); 13] { let four = Align::from_bytes(4).expect("4 Byte alignment should work"); let eight = Align::EIGHT; [ - (four, cx.get_const_i32(KernelArgsTy::OFFLOAD_VERSION)), - (four, cx.get_const_i32(num_args)), - (eight, geps[0]), - (eight, geps[1]), - (eight, geps[2]), - (eight, memtransfer_types), + (four, "Version", cx.get_const_i32(KernelArgsTy::OFFLOAD_VERSION)), + (four, "NumArgs", cx.get_const_i32(num_args)), + (eight, "ArgBasePtrs", geps[0]), + (eight, "ArgPtrs", geps[1]), + (eight, "ArgSizes", geps[2]), + (eight, "ArgTypes", memtransfer_types), // The next two are debug infos. FIXME(offload): set them - (eight, cx.const_null(cx.type_ptr())), // dbg - (eight, cx.const_null(cx.type_ptr())), // dbg - (eight, cx.get_const_i64(KernelArgsTy::TRIPCOUNT)), - (eight, cx.get_const_i64(KernelArgsTy::FLAGS)), - (four, workgroup_dims), - (four, thread_dims), - (four, cx.get_const_i32(0)), + (eight, "ArgNames", cx.const_null(cx.type_ptr())), // dbg + (eight, "ArgMappers", cx.const_null(cx.type_ptr())), // dbg + (eight, "Tripcount", cx.get_const_i64(KernelArgsTy::TRIPCOUNT)), + (eight, "Flags", cx.get_const_i64(KernelArgsTy::FLAGS)), + (four, "NumTeams", workgroup_dims), + (four, "ThreadLimit", thread_dims), + (four, "DynCGroupMem", dyn_cache), ] } } @@ -589,6 +590,7 @@ pub(crate) fn gen_call_handling<'ll, 'tcx>( metadata: &[OffloadMetadata], offload_globals: &OffloadGlobals<'ll>, offload_dims: &OffloadKernelDims<'ll>, + dyn_cache: &'ll Value, ) { let cx = builder.cx; let OffloadKernelGlobals { @@ -753,14 +755,24 @@ pub(crate) fn gen_call_handling<'ll, 'tcx>( num_args, s_ident_t, ); - let values = - KernelArgsTy::new(&cx, num_args, memtransfer_kernel, geps, workgroup_dims, thread_dims); + let values = KernelArgsTy::new( + &cx, + num_args, + memtransfer_kernel, + geps, + workgroup_dims, + thread_dims, + dyn_cache, + ); // Step 3) // Here we fill the KernelArgsTy, see the documentation above for (i, value) in values.iter().enumerate() { let ptr = builder.inbounds_gep(tgt_kernel_decl, a5, &[i32_0, cx.get_const_i32(i as u64)]); - builder.store(value.1, ptr, value.0); + let name = std::ffi::CString::new(value.1).unwrap(); + llvm::set_value_name(ptr, &name.as_bytes()); + + builder.store(value.2, ptr, value.0); } let args = vec![ diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index a400fcba613e9..1c7b415fd04c7 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -1926,7 +1926,11 @@ fn codegen_offload<'ll, 'tcx>( }; let offload_dims = OffloadKernelDims::from_operands(bx, &args[1], &args[2]); - let args = get_args_from_tuple(bx, args[3], fn_target); + let dyn_cache = match args[3].val { + OperandValue::Immediate(val) => val, + _ => panic!("unparsable"), + }; + let args = get_args_from_tuple(bx, args[4], fn_target); let target_symbol = symbol_name_for_instance_in_crate(tcx, fn_target, LOCAL_CRATE); let sig = tcx.fn_sig(fn_target.def_id()).skip_binder(); @@ -1958,7 +1962,16 @@ fn codegen_offload<'ll, 'tcx>( }; register_offload(cx); let offload_data = gen_define_handling(&cx, &metadata, target_symbol, offload_globals); - gen_call_handling(bx, &offload_data, &args, &types, &metadata, offload_globals, &offload_dims); + gen_call_handling( + bx, + &offload_data, + &args, + &types, + &metadata, + offload_globals, + &offload_dims, + &dyn_cache, + ); } fn get_args_from_tuple<'ll, 'tcx>( diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index d2c82280ad2ab..532f2d6d6af09 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1530,7 +1530,6 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { } LinkerFlavor::Bpf => "bpf-linker", LinkerFlavor::Llbc => "llvm-bitcode-linker", - LinkerFlavor::Ptx => "rust-ptx-linker", }), flavor, )), @@ -1571,7 +1570,6 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) { let linker_flavor = match sess.opts.cg.linker_flavor { // The linker flavors that are non-target specific can be directly translated to LinkerFlavor Some(LinkerFlavorCli::Llbc) => Some(LinkerFlavor::Llbc), - Some(LinkerFlavorCli::Ptx) => Some(LinkerFlavor::Ptx), // The linker flavors that corresponds to targets needs logic that keeps the base LinkerFlavor linker_flavor => { linker_flavor.map(|flavor| sess.target.linker_flavor.with_cli_hints(flavor)) @@ -2764,8 +2762,6 @@ fn add_order_independent_options( if crate_info.target_features.len() > 0 { cmd.link_arg(&format!("--target-feature={}", &crate_info.target_features.join(","))); } - } else if flavor == LinkerFlavor::Ptx { - cmd.link_args(&["--fallback-arch", &crate_info.target_cpu]); } else if flavor == LinkerFlavor::Bpf { cmd.link_args(&["--cpu", &crate_info.target_cpu]); if let Some(feat) = [sess.opts.cg.target_feature.as_str(), &sess.target.options.features] diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index 2155f94a7cfd3..d40340e4d8c09 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -161,7 +161,6 @@ pub(crate) fn get_linker<'a>( LinkerFlavor::EmCc => Box::new(EmLinker { cmd, sess }) as Box, LinkerFlavor::Bpf => Box::new(BpfLinker { cmd, sess }) as Box, LinkerFlavor::Llbc => Box::new(LlbcLinker { cmd, sess }) as Box, - LinkerFlavor::Ptx => Box::new(PtxLinker { cmd, sess }) as Box, } } @@ -283,7 +282,6 @@ generate_arg_methods! { L4Bender<'_> AixLinker<'_> LlbcLinker<'_> - PtxLinker<'_> BpfLinker<'_> dyn Linker + '_ } @@ -1920,83 +1918,6 @@ pub(crate) fn linked_symbols( symbols } -/// Much simplified and explicit CLI for the NVPTX linker. The linker operates -/// with bitcode and uses LLVM backend to generate a PTX assembly. -struct PtxLinker<'a> { - cmd: Command, - sess: &'a Session, -} - -impl<'a> Linker for PtxLinker<'a> { - fn cmd(&mut self) -> &mut Command { - &mut self.cmd - } - - fn set_output_kind( - &mut self, - _output_kind: LinkOutputKind, - _crate_type: CrateType, - _out_filename: &Path, - ) { - } - - fn link_staticlib_by_name(&mut self, _name: &str, _verbatim: bool, _whole_archive: bool) { - panic!("staticlibs not supported") - } - - fn link_staticlib_by_path(&mut self, path: &Path, _whole_archive: bool) { - self.link_arg("--rlib").link_arg(path); - } - - fn debuginfo(&mut self, _strip: Strip, _: &[PathBuf]) { - self.link_arg("--debug"); - } - - fn add_object(&mut self, path: &Path) { - self.link_arg("--bitcode").link_arg(path); - } - - fn optimize(&mut self) { - match self.sess.lto() { - Lto::Thin | Lto::Fat | Lto::ThinLocal => { - self.link_arg("-Olto"); - } - - Lto::No => {} - } - } - - fn full_relro(&mut self) {} - - fn partial_relro(&mut self) {} - - fn no_relro(&mut self) {} - - fn gc_sections(&mut self, _keep_metadata: bool) {} - - fn pgo_gen(&mut self) {} - - fn no_crt_objects(&mut self) {} - - fn no_default_libraries(&mut self) {} - - fn control_flow_guard(&mut self) {} - - fn ehcont_guard(&mut self) {} - - fn export_symbols( - &mut self, - _tmpdir: &Path, - _crate_type: CrateType, - _symbols: &[(String, SymbolExportKind)], - ) { - } - - fn windows_subsystem(&mut self, _subsystem: WindowsSubsystemKind) {} - - fn linker_plugin_lto(&mut self) {} -} - /// The `self-contained` LLVM bitcode linker struct LlbcLinker<'a> { cmd: Command, diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index da45596d0b74e..3691e952f045a 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -454,6 +454,8 @@ declare_features! ( (unstable, cfg_version, "1.45.0", Some(64796)), /// Allows to use the `#[cfi_encoding = ""]` attribute. (unstable, cfi_encoding, "1.71.0", Some(89653)), + /// The `clflushopt` target feature on x86. + (unstable, clflushopt_target_feature, "CURRENT_RUSTC_VERSION", Some(157096)), /// Allows `for<...>` on closures and coroutines. (unstable, closure_lifetime_binder, "1.64.0", Some(97362)), /// Allows `#[track_caller]` on closures and coroutines. diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index ad5d6b1509dfd..d275d5a28b88a 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -991,8 +991,6 @@ pub enum LifetimeRes { /// /// Creating the associated `LocalDefId` is the responsibility of lowering. param: NodeId, - /// Id of the introducing place. See `Param`. - binder: NodeId, /// Kind of elided lifetime kind: hir::MissingLifetimeKind, }, diff --git a/compiler/rustc_hir/src/definitions.rs b/compiler/rustc_hir/src/definitions.rs index 70720c6dbd981..97e739a7f3893 100644 --- a/compiler/rustc_hir/src/definitions.rs +++ b/compiler/rustc_hir/src/definitions.rs @@ -20,84 +20,6 @@ pub use crate::def_id::DefPathHash; use crate::def_id::{CRATE_DEF_INDEX, CrateNum, DefIndex, LOCAL_CRATE, LocalDefId, StableCrateId}; use crate::def_path_hash_map::DefPathHashMap; -/// The `DefPathTable` maps `DefIndex`es to `DefKey`s and vice versa. -/// Internally the `DefPathTable` holds a tree of `DefKey`s, where each `DefKey` -/// stores the `DefIndex` of its parent. -/// There is one `DefPathTable` for each crate. -#[derive(Debug)] -pub struct DefPathTable { - stable_crate_id: StableCrateId, - index_to_key: IndexVec, - // We do only store the local hash, as all the definitions are from the current crate. - def_path_hashes: IndexVec, - def_path_hash_to_index: DefPathHashMap, -} - -impl DefPathTable { - fn new(stable_crate_id: StableCrateId) -> DefPathTable { - DefPathTable { - stable_crate_id, - index_to_key: Default::default(), - def_path_hashes: Default::default(), - def_path_hash_to_index: Default::default(), - } - } - - fn allocate(&mut self, key: DefKey, def_path_hash: DefPathHash) -> DefIndex { - // Assert that all DefPathHashes correctly contain the local crate's StableCrateId. - debug_assert_eq!(self.stable_crate_id, def_path_hash.stable_crate_id()); - let local_hash = def_path_hash.local_hash(); - - let index = self.index_to_key.push(key); - debug!("DefPathTable::insert() - {key:?} <-> {index:?}"); - - self.def_path_hashes.push(local_hash); - debug_assert!(self.def_path_hashes.len() == self.index_to_key.len()); - - // Check for hash collisions of DefPathHashes. These should be - // exceedingly rare. - if let Some(existing) = self.def_path_hash_to_index.insert(&local_hash, &index) { - let def_path1 = DefPath::make(LOCAL_CRATE, existing, |idx| self.def_key(idx)); - let def_path2 = DefPath::make(LOCAL_CRATE, index, |idx| self.def_key(idx)); - - // Continuing with colliding DefPathHashes can lead to correctness - // issues. We must abort compilation. - // - // The likelihood of such a collision is very small, so actually - // running into one could be indicative of a poor hash function - // being used. - // - // See the documentation for DefPathHash for more information. - panic!( - "found DefPathHash collision between {def_path1:#?} and {def_path2:#?}. \ - Compilation cannot continue." - ); - } - - index - } - - #[inline(always)] - pub fn def_key(&self, index: DefIndex) -> DefKey { - self.index_to_key[index] - } - - #[instrument(level = "trace", skip(self), ret)] - #[inline(always)] - pub fn def_path_hash(&self, index: DefIndex) -> DefPathHash { - let hash = self.def_path_hashes[index]; - DefPathHash::new(self.stable_crate_id, hash) - } - - pub fn enumerated_keys_and_path_hashes( - &self, - ) -> impl Iterator + ExactSizeIterator { - self.index_to_key - .iter_enumerated() - .map(move |(index, key)| (index, key, self.def_path_hash(index))) - } -} - #[derive(Debug, Default, Clone)] pub struct PerParentDisambiguatorState { #[cfg(debug_assertions)] @@ -123,12 +45,13 @@ impl LocalDefIdMap { } } -/// The definition table containing node definitions. -/// It holds the `DefPathTable` for `LocalDefId`s/`DefPath`s. -/// It also stores mappings to convert `LocalDefId`s to/from `HirId`s. #[derive(Debug)] pub struct Definitions { - table: DefPathTable, + stable_crate_id: StableCrateId, + def_id_to_key: IndexVec, + // We do only store the local hash, as all the definitions are from the current crate. + def_path_hashes: IndexVec, + def_path_hash_to_index: DefPathHashMap, } /// A unique identifier that we can use to lookup a definition @@ -167,7 +90,7 @@ impl DefKey { // Construct the new DefPathHash, making sure that the `crate_id` // portion of the hash is properly copied from the parent. This way the // `crate_id` part will be recursively propagated from the root to all - // DefPathHashes in this DefPathTable. + // DefPathHashes in this Definitions. DefPathHash::new(parent.stable_crate_id(), local_hash) } @@ -324,23 +247,15 @@ pub enum DefPathData { } impl Definitions { - pub fn def_path_table(&self) -> &DefPathTable { - &self.table - } - - /// Gets the number of definitions. - pub fn def_index_count(&self) -> usize { - self.table.index_to_key.len() - } - - #[inline] + #[inline(always)] pub fn def_key(&self, id: LocalDefId) -> DefKey { - self.table.def_key(id.local_def_index) + self.def_id_to_key[id] } + #[instrument(level = "trace", skip(self), ret)] #[inline(always)] pub fn def_path_hash(&self, id: LocalDefId) -> DefPathHash { - self.table.def_path_hash(id.local_def_index) + DefPathHash::new(self.stable_crate_id, self.def_path_hashes[id]) } /// Returns the path from the crate root to `index`. The root @@ -348,6 +263,7 @@ impl Definitions { /// empty vector for the crate root). For an inlined item, this /// will be the path of the item in the external crate (but the /// path will begin with the path to the external crate). + #[inline] pub fn def_path(&self, id: LocalDefId) -> DefPath { DefPath::make(LOCAL_CRATE, id.local_def_index, |index| { self.def_key(LocalDefId { local_def_index: index }) @@ -375,12 +291,62 @@ impl Definitions { let def_path_hash = DefPathHash::new(stable_crate_id, Hash64::new(stable_crate_id.as_u64())); + let mut defs = Definitions { + stable_crate_id, + def_path_hashes: Default::default(), + def_id_to_key: Default::default(), + def_path_hash_to_index: Default::default(), + }; + // Create the root definition. - let mut table = DefPathTable::new(stable_crate_id); - let root = LocalDefId { local_def_index: table.allocate(key, def_path_hash) }; + let root = defs.allocate(key, def_path_hash); assert_eq!(root.local_def_index, CRATE_DEF_INDEX); - Definitions { table } + defs + } + + fn allocate(&mut self, key: DefKey, def_path_hash: DefPathHash) -> LocalDefId { + // Assert that all DefPathHashes correctly contain the local crate's StableCrateId. + debug_assert_eq!(self.stable_crate_id, def_path_hash.stable_crate_id()); + let local_hash = def_path_hash.local_hash(); + + let def_id = self.def_id_to_key.push(key); + debug!("def_id_to_key.push() - {key:?} <-> {:?}", def_id.local_def_index); + + self.def_path_hashes.push(local_hash); + debug_assert!(self.def_path_hashes.len() == self.def_id_to_key.len()); + + // Check for hash collisions of DefPathHashes. These should be + // exceedingly rare. + if let Some(existing) = + self.def_path_hash_to_index.insert(&local_hash, &def_id.local_def_index) + { + let def_path1 = self.def_path(LocalDefId { local_def_index: existing }); + let def_path2 = self.def_path(def_id); + + // Continuing with colliding DefPathHashes can lead to correctness + // issues. We must abort compilation. + // + // The likelihood of such a collision is very small, so actually + // running into one could be indicative of a poor hash function + // being used. + // + // See the documentation for DefPathHash for more information. + panic!( + "found DefPathHash collision between {def_path1:#?} and {def_path2:#?}. \ + Compilation cannot continue." + ); + } + + def_id + } + + pub fn enumerated_keys_and_path_hashes( + &self, + ) -> impl Iterator + ExactSizeIterator { + self.def_id_to_key + .iter_enumerated() + .map(move |(def_id, key)| (def_id.local_def_index, key, self.def_path_hash(def_id))) } /// Creates a definition with a parent definition. @@ -423,13 +389,13 @@ impl Definitions { disambiguated_data: DisambiguatedDefPathData { data, disambiguator }, }; - let parent_hash = self.table.def_path_hash(parent.local_def_index); + let parent_hash = self.def_path_hash(parent); let def_path_hash = key.compute_stable_hash(parent_hash); debug!("create_def: after disambiguation, key = {:?}", key); // Create the definition. - LocalDefId { local_def_index: self.table.allocate(key, def_path_hash) } + self.allocate(key, def_path_hash) } #[inline(always)] @@ -439,19 +405,18 @@ impl Definitions { /// if the `DefPathHash` is from a previous compilation session and /// the def-path does not exist anymore. pub fn local_def_path_hash_to_def_id(&self, hash: DefPathHash) -> Option { - debug_assert!(hash.stable_crate_id() == self.table.stable_crate_id); - self.table - .def_path_hash_to_index + debug_assert!(hash.stable_crate_id() == self.stable_crate_id); + self.def_path_hash_to_index .get(&hash.local_hash()) .map(|local_def_index| LocalDefId { local_def_index }) } pub fn def_path_hash_to_def_index_map(&self) -> &DefPathHashMap { - &self.table.def_path_hash_to_index + &self.def_path_hash_to_index } pub fn num_definitions(&self) -> usize { - self.table.def_path_hashes.len() + self.def_path_hashes.len() } } diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs index 644e8dd690ef4..a4d6056e47bdc 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs @@ -356,6 +356,7 @@ pub(crate) fn check_intrinsic_type( param(0), Ty::new_array_with_const_len(tcx, tcx.types.u32, Const::from_target_usize(tcx, 3)), Ty::new_array_with_const_len(tcx, tcx.types.u32, Const::from_target_usize(tcx, 3)), + tcx.types.u32, param(1), ], param(2), diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index caa41fd0f6ab3..8ddaf7a630d31 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -4529,28 +4529,21 @@ declare_lint! { /// /// ### Example /// - /// ```rust,compile_fail - /// #![deny(ambiguous_glob_imports)] - /// pub fn foo() -> u32 { - /// use sub::*; - /// C - /// } - /// - /// mod sub { - /// mod mod1 { pub const C: u32 = 1; } - /// mod mod2 { pub const C: u32 = 2; } + /// ```rust,ignore (needs extern crate) + /// // library crate `my_library` + /// mod mod1 { pub const C: u32 = 1; } + /// mod mod2 { pub const C: u32 = 2; } + /// pub use mod1::*; + /// pub use mod2::*; /// - /// pub use mod1::*; - /// pub use mod2::*; - /// } + /// // another crate using `my_library` + /// let c = my_library::C; // `C` is ambiguous /// ``` /// - /// {{produces}} - /// /// ### Explanation /// - /// Previous versions of Rust compile it successfully because it - /// had lost the ambiguity error when resolve `use sub::mod2::*`. + /// Previous versions of Rust compile it successfully because + /// ambiguous glob imports weren't preserved correctly over crate boundaries. /// /// This is a [future-incompatible] lint to transition this to a /// hard error in the future. diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index a0db004b7f4c4..1483de572c341 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -12,7 +12,7 @@ use rustc_data_structures::temp_dir::MaybeTempDir; use rustc_data_structures::thousands::usize_with_underscores; use rustc_hir as hir; use rustc_hir::attrs::{AttributeKind, EncodeCrossCrate}; -use rustc_hir::def_id::{CRATE_DEF_ID, CRATE_DEF_INDEX, LOCAL_CRATE, LocalDefId, LocalDefIdSet}; +use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId, LocalDefIdSet}; use rustc_hir::definitions::DefPathData; use rustc_hir::find_attr; use rustc_hir_pretty::id_to_string; @@ -510,18 +510,20 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { } fn encode_def_path_table(&mut self) { - let table = self.tcx.def_path_table(); + let defs = self.tcx.definitions(); if self.is_proc_macro { - for def_index in std::iter::once(CRATE_DEF_INDEX) - .chain(self.tcx.resolutions(()).proc_macros.iter().map(|p| p.local_def_index)) + for def_id in std::iter::once(CRATE_DEF_ID) + .chain(self.tcx.resolutions(()).proc_macros.iter().copied()) { - let def_key = self.lazy(table.def_key(def_index)); - let def_path_hash = table.def_path_hash(def_index); - self.tables.def_keys.set_some(def_index, def_key); - self.tables.def_path_hashes.set(def_index, def_path_hash.local_hash().as_u64()); + let def_key = self.lazy(defs.def_key(def_id)); + let def_path_hash = defs.def_path_hash(def_id); + self.tables.def_keys.set_some(def_id.local_def_index, def_key); + self.tables + .def_path_hashes + .set(def_id.local_def_index, def_path_hash.local_hash().as_u64()); } } else { - for (def_index, def_key, def_path_hash) in table.enumerated_keys_and_path_hashes() { + for (def_index, def_key, def_path_hash) in defs.enumerated_keys_and_path_hashes() { let def_key = self.lazy(def_key); self.tables.def_keys.set_some(def_index, def_key); self.tables.def_path_hashes.set(def_index, def_path_hash.local_hash().as_u64()); @@ -2034,7 +2036,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { let def_id = id.to_def_id(); self.tables.def_kind.set_some(def_id.index, DefKind::Macro(macro_kind.into())); - self.tables.proc_macro.set_some(def_id.index, macro_kind); self.encode_attrs(id); record!(self.tables.def_keys[def_id] <- def_key); record!(self.tables.def_ident_span[def_id] <- span); diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index a3645a5556bf3..6a396faf914cc 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -464,7 +464,6 @@ define_tables! { variant_data: Table>, assoc_container: Table>, macro_definition: Table>, - proc_macro: Table, deduced_param_attrs: Table>, collect_return_position_impl_trait_in_trait_tys: Table>>>>, doc_link_resolutions: Table>, diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 9610956c89573..c5fab56bfbbb2 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1349,13 +1349,13 @@ impl<'tcx> TyCtxt<'tcx> { } } - pub fn def_path_table(self) -> &'tcx rustc_hir::definitions::DefPathTable { + pub fn definitions(self) -> &'tcx rustc_hir::definitions::Definitions { // Depend on the `analysis` query to ensure compilation if finished. self.ensure_ok().analysis(()); // Freeze definitions once we start iterating on them, to prevent adding new ones // while iterating. If some query needs to add definitions, it should be `ensure`d above. - self.untracked.definitions.freeze().def_path_table() + self.untracked.definitions.freeze() } pub fn def_path_hash_to_def_index_map( diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 74f9e75fb48c0..28e18331d7127 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -37,12 +37,11 @@ use rustc_data_structures::stable_hash::{StableHash, StableHashCtxt, StableHashe use rustc_data_structures::steal::Steal; use rustc_data_structures::unord::{UnordMap, UnordSet}; use rustc_errors::{Diag, ErrorGuaranteed, LintBuffer}; -use rustc_hir as hir; use rustc_hir::attrs::StrippedCfgItem; use rustc_hir::def::{CtorKind, CtorOf, DefKind, DocLinkResMap, LifetimeRes, Res}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap}; use rustc_hir::definitions::PerParentDisambiguatorState; -use rustc_hir::{LangItem, attrs as attr, find_attr}; +use rustc_hir::{self as hir, LangItem, MissingLifetimeKind, attrs as attr, find_attr}; use rustc_index::IndexVec; use rustc_index::bit_set::BitMatrix; use rustc_macros::{ @@ -232,7 +231,7 @@ pub struct ResolverAstLowering<'tcx> { /// Resolutions for lifetimes. pub lifetimes_res_map: NodeMap, /// Lifetime parameters that lowering will have to introduce. - pub extra_lifetime_params_map: NodeMap>, + pub extra_lifetime_params_map: NodeMap>, pub next_node_id: ast::NodeId, @@ -253,9 +252,12 @@ pub struct ResolverAstLowering<'tcx> { #[derive(Debug)] pub struct DelegationInfo { - // NodeId (either delegation.id or item_id in case of a trait impl) for signature resolution, + // `DefId` (either the resolution at delegation.id or item_id in case of a trait impl) for signature resolution, // for details see https://github.com/rust-lang/rust/issues/118212#issuecomment-2160686914 - pub resolution_node: ast::NodeId, + /// Refers to the next element in a delegation resolution chain. + /// Usually points to the final resolution, as most "chains" are just + /// one step to a trait or an impl. + pub resolution_id: DefId, } #[derive(Clone, Copy, Debug, StableHash)] diff --git a/compiler/rustc_public/src/compiler_interface.rs b/compiler/rustc_public/src/compiler_interface.rs index c2f36bea81ca6..7953af37c1833 100644 --- a/compiler/rustc_public/src/compiler_interface.rs +++ b/compiler/rustc_public/src/compiler_interface.rs @@ -79,183 +79,191 @@ pub(crate) struct CompilerInterface<'tcx> { } impl<'tcx> CompilerInterface<'tcx> { - pub(crate) fn entry_fn(&self) -> Option { + fn with_cx( + &self, + f: impl FnOnce(&mut Tables<'tcx, BridgeTys>, &CompilerCtxt<'tcx, BridgeTys>) -> R, + ) -> R { let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let did = cx.entry_fn(); - Some(tables.crate_item(did?)) + let cx = self.cx.borrow(); + f(&mut *tables, &*cx) + } + + pub(crate) fn entry_fn(&self) -> Option { + self.with_cx(|tables, cx| { + let did = cx.entry_fn(); + Some(tables.crate_item(did?)) + }) } /// Retrieve all items of the local crate that have a MIR associated with them. pub(crate) fn all_local_items(&self) -> CrateItems { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cx.all_local_items().iter().map(|did| tables.crate_item(*did)).collect() + self.with_cx(|tables, cx| { + cx.all_local_items().iter().map(|did| tables.crate_item(*did)).collect() + }) } /// Retrieve the body of a function. /// This function will panic if the body is not available. pub(crate) fn mir_body(&self, item: DefId) -> mir::Body { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let did = tables[item]; - cx.mir_body(did).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let did = tables[item]; + cx.mir_body(did).stable(tables, cx) + }) } /// Check whether the body of a function is available. pub(crate) fn has_body(&self, item: DefId) -> bool { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let def = item.internal(&mut *tables, cx.tcx); - cx.has_body(def) + self.with_cx(|tables, cx| { + let def = item.internal(tables, cx.tcx); + cx.has_body(def) + }) } pub(crate) fn foreign_modules(&self, crate_num: CrateNum) -> Vec { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cx.foreign_modules(crate_num.internal(&mut *tables, cx.tcx)) - .iter() - .map(|did| tables.foreign_module_def(*did)) - .collect() + self.with_cx(|tables, cx| { + cx.foreign_modules(crate_num.internal(tables, cx.tcx)) + .iter() + .map(|did| tables.foreign_module_def(*did)) + .collect() + }) } /// Retrieve all functions defined in this crate. pub(crate) fn crate_functions(&self, crate_num: CrateNum) -> Vec { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let krate = crate_num.internal(&mut *tables, cx.tcx); - cx.crate_functions(krate).iter().map(|did| tables.fn_def(*did)).collect() + self.with_cx(|tables, cx| { + let krate = crate_num.internal(tables, cx.tcx); + cx.crate_functions(krate).iter().map(|did| tables.fn_def(*did)).collect() + }) } /// Retrieve all static items defined in this crate. pub(crate) fn crate_statics(&self, crate_num: CrateNum) -> Vec { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let krate = crate_num.internal(&mut *tables, cx.tcx); - cx.crate_statics(krate).iter().map(|did| tables.static_def(*did)).collect() + self.with_cx(|tables, cx| { + let krate = crate_num.internal(tables, cx.tcx); + cx.crate_statics(krate).iter().map(|did| tables.static_def(*did)).collect() + }) } pub(crate) fn foreign_module(&self, mod_def: ForeignModuleDef) -> ForeignModule { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let did = tables[mod_def.def_id()]; - cx.foreign_module(did).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let did = tables[mod_def.def_id()]; + cx.foreign_module(did).stable(tables, cx) + }) } pub(crate) fn foreign_items(&self, mod_def: ForeignModuleDef) -> Vec { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let did = tables[mod_def.def_id()]; - cx.foreign_items(did).iter().map(|did| tables.foreign_def(*did)).collect() + self.with_cx(|tables, cx| { + let did = tables[mod_def.def_id()]; + cx.foreign_items(did).iter().map(|did| tables.foreign_def(*did)).collect() + }) } pub(crate) fn all_trait_decls(&self) -> TraitDecls { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cx.all_trait_decls().map(|did| tables.trait_def(did)).collect() + self.with_cx(|tables, cx| cx.all_trait_decls().map(|did| tables.trait_def(did)).collect()) } pub(crate) fn trait_decls(&self, crate_num: CrateNum) -> TraitDecls { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let krate = crate_num.internal(&mut *tables, cx.tcx); - cx.trait_decls(krate).iter().map(|did| tables.trait_def(*did)).collect() + self.with_cx(|tables, cx| { + let krate = crate_num.internal(tables, cx.tcx); + cx.trait_decls(krate).iter().map(|did| tables.trait_def(*did)).collect() + }) } pub(crate) fn trait_decl(&self, trait_def: &TraitDef) -> TraitDecl { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let did = tables[trait_def.0]; - cx.trait_decl(did).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let did = tables[trait_def.0]; + cx.trait_decl(did).stable(tables, cx) + }) } pub(crate) fn all_trait_impls(&self) -> ImplTraitDecls { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cx.all_trait_impls().iter().map(|did| tables.impl_def(*did)).collect() + self.with_cx(|tables, cx| { + cx.all_trait_impls().iter().map(|did| tables.impl_def(*did)).collect() + }) } pub(crate) fn trait_impls(&self, crate_num: CrateNum) -> ImplTraitDecls { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let krate = crate_num.internal(&mut *tables, cx.tcx); - cx.trait_impls(krate).iter().map(|did| tables.impl_def(*did)).collect() + self.with_cx(|tables, cx| { + let krate = crate_num.internal(tables, cx.tcx); + cx.trait_impls(krate).iter().map(|did| tables.impl_def(*did)).collect() + }) } pub(crate) fn trait_impl(&self, trait_impl: &ImplDef) -> ImplTrait { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let did = tables[trait_impl.0]; - cx.trait_impl(did).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let did = tables[trait_impl.0]; + cx.trait_impl(did).stable(tables, cx) + }) } pub(crate) fn generics_of(&self, def_id: DefId) -> Generics { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let did = tables[def_id]; - cx.generics_of(did).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let did = tables[def_id]; + cx.generics_of(did).stable(tables, cx) + }) } pub(crate) fn predicates_of(&self, def_id: DefId) -> GenericPredicates { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let did = tables[def_id]; - let (parent, kinds) = cx.predicates_of(did); - crate::ty::GenericPredicates { - parent: parent.map(|did| tables.trait_def(did)), - predicates: kinds - .iter() - .map(|(kind, span)| (kind.stable(&mut *tables, cx), span.stable(&mut *tables, cx))) - .collect(), - } + self.with_cx(|tables, cx| { + let did = tables[def_id]; + let (parent, kinds) = cx.predicates_of(did); + crate::ty::GenericPredicates { + parent: parent.map(|did| tables.trait_def(did)), + predicates: kinds + .iter() + .map(|(kind, span)| (kind.stable(tables, cx), span.stable(tables, cx))) + .collect(), + } + }) } pub(crate) fn explicit_predicates_of(&self, def_id: DefId) -> GenericPredicates { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let did = tables[def_id]; - let (parent, kinds) = cx.explicit_predicates_of(did); - crate::ty::GenericPredicates { - parent: parent.map(|did| tables.trait_def(did)), - predicates: kinds - .iter() - .map(|(kind, span)| (kind.stable(&mut *tables, cx), span.stable(&mut *tables, cx))) - .collect(), - } + self.with_cx(|tables, cx| { + let did = tables[def_id]; + let (parent, kinds) = cx.explicit_predicates_of(did); + crate::ty::GenericPredicates { + parent: parent.map(|did| tables.trait_def(did)), + predicates: kinds + .iter() + .map(|(kind, span)| (kind.stable(tables, cx), span.stable(tables, cx))) + .collect(), + } + }) } /// Get information about the local crate. pub(crate) fn local_crate(&self) -> Crate { - let cx = &*self.cx.borrow(); - smir_crate(cx, cx.local_crate_num()) + self.with_cx(|_, cx| smir_crate(cx, cx.local_crate_num())) } /// Retrieve a list of all external crates. pub(crate) fn external_crates(&self) -> Vec { - let cx = &*self.cx.borrow(); - cx.external_crates().iter().map(|crate_num| smir_crate(cx, *crate_num)).collect() + self.with_cx(|_, cx| { + cx.external_crates().iter().map(|crate_num| smir_crate(cx, *crate_num)).collect() + }) } /// Find a crate with the given name. pub(crate) fn find_crates(&self, name: &str) -> Vec { - let cx = &*self.cx.borrow(); - cx.find_crates(name).iter().map(|crate_num| smir_crate(cx, *crate_num)).collect() + self.with_cx(|_, cx| { + cx.find_crates(name).iter().map(|crate_num| smir_crate(cx, *crate_num)).collect() + }) } /// Returns the name of given `DefId`. pub(crate) fn def_name(&self, def_id: DefId, trimmed: bool) -> Symbol { - let tables = self.tables.borrow(); - let cx = &*self.cx.borrow(); - let did = tables[def_id]; - cx.def_name(did, trimmed) + self.with_cx(|tables, cx| { + let did = tables[def_id]; + cx.def_name(did, trimmed) + }) } /// Returns the parent of the given `DefId`. pub(crate) fn def_parent(&self, def_id: DefId) -> Option { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let did = tables[def_id]; - cx.def_parent(did).map(|did| tables.create_def_id(did)) + self.with_cx(|tables, cx| { + let did = tables[def_id]; + cx.def_parent(did).map(|did| tables.create_def_id(did)) + }) } /// Return registered tool attributes with the given attribute name. @@ -266,184 +274,169 @@ impl<'tcx> CompilerInterface<'tcx> { /// Single segmented name like `#[clippy]` is specified as `&["clippy".to_string()]`. /// Multi-segmented name like `#[rustfmt::skip]` is specified as `&["rustfmt".to_string(), "skip".to_string()]`. pub(crate) fn tool_attrs(&self, def_id: DefId, attr: &[Symbol]) -> Vec { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let did = tables[def_id]; - cx.tool_attrs(did, attr) - .into_iter() - .map(|(attr_str, span)| Attribute::new(attr_str, span.stable(&mut *tables, cx))) - .collect() + self.with_cx(|tables, cx| { + let did = tables[def_id]; + cx.tool_attrs(did, attr) + .into_iter() + .map(|(attr_str, span)| Attribute::new(attr_str, span.stable(tables, cx))) + .collect() + }) } /// Get all tool attributes of a definition. pub(crate) fn all_tool_attrs(&self, def_id: DefId) -> Vec { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let did = tables[def_id]; - cx.all_tool_attrs(did) - .into_iter() - .map(|(attr_str, span)| Attribute::new(attr_str, span.stable(&mut *tables, cx))) - .collect() + self.with_cx(|tables, cx| { + let did = tables[def_id]; + cx.all_tool_attrs(did) + .into_iter() + .map(|(attr_str, span)| Attribute::new(attr_str, span.stable(tables, cx))) + .collect() + }) } /// Returns printable, human readable form of `Span`. pub(crate) fn span_to_string(&self, span: Span) -> String { - let tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let sp = tables.spans[span]; - cx.span_to_string(sp) + self.with_cx(|tables, cx| { + let sp = tables.spans[span]; + cx.span_to_string(sp) + }) } /// Return filename from given `Span`, for diagnostic purposes. pub(crate) fn get_filename(&self, span: &Span) -> Filename { - let tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let sp = tables.spans[*span]; - cx.get_filename(sp) + self.with_cx(|tables, cx| { + let sp = tables.spans[*span]; + cx.get_filename(sp) + }) } /// Return lines corresponding to this `Span`. pub(crate) fn get_lines(&self, span: &Span) -> LineInfo { - let tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let sp = tables.spans[*span]; - let lines = cx.get_lines(sp); - LineInfo::from(lines) + self.with_cx(|tables, cx| { + let sp = tables.spans[*span]; + let lines = cx.get_lines(sp); + LineInfo::from(lines) + }) } /// Returns the `kind` of given `DefId`. pub(crate) fn item_kind(&self, item: CrateItem) -> ItemKind { - let tables = self.tables.borrow(); - let cx = &*self.cx.borrow(); - let did = tables[item.0]; - new_item_kind(cx.def_kind(did)) + self.with_cx(|tables, cx| { + let did = tables[item.0]; + new_item_kind(cx.def_kind(did)) + }) } /// Returns whether this is a foreign item. pub(crate) fn is_foreign_item(&self, item: DefId) -> bool { - let tables = self.tables.borrow(); - let cx = &*self.cx.borrow(); - let did = tables[item]; - cx.is_foreign_item(did) + self.with_cx(|tables, cx| { + let did = tables[item]; + cx.is_foreign_item(did) + }) } /// Returns the kind of a given foreign item. pub(crate) fn foreign_item_kind(&self, def: ForeignDef) -> ForeignItemKind { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let def_id = tables[def.def_id()]; - let def_kind = cx.foreign_item_kind(def_id); - match def_kind { - DefKind::Fn => ForeignItemKind::Fn(tables.fn_def(def_id)), - DefKind::Static { .. } => ForeignItemKind::Static(tables.static_def(def_id)), - DefKind::ForeignTy => { - use rustc_public_bridge::context::TyHelpers; - ForeignItemKind::Type(tables.intern_ty(cx.new_foreign(def_id))) + self.with_cx(|tables, cx| { + let def_id = tables[def.def_id()]; + let def_kind = cx.foreign_item_kind(def_id); + match def_kind { + DefKind::Fn => ForeignItemKind::Fn(tables.fn_def(def_id)), + DefKind::Static { .. } => ForeignItemKind::Static(tables.static_def(def_id)), + DefKind::ForeignTy => { + use rustc_public_bridge::context::TyHelpers; + ForeignItemKind::Type(tables.intern_ty(cx.new_foreign(def_id))) + } + def_kind => unreachable!("Unexpected kind for a foreign item: {:?}", def_kind), } - def_kind => unreachable!("Unexpected kind for a foreign item: {:?}", def_kind), - } + }) } /// Returns the kind of a given algebraic data type. pub(crate) fn adt_kind(&self, def: AdtDef) -> AdtKind { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cx.adt_kind(def.internal(&mut *tables, cx.tcx)).stable(&mut *tables, cx) + self.with_cx(|tables, cx| cx.adt_kind(def.internal(tables, cx.tcx)).stable(tables, cx)) } /// Returns if the ADT is a box. pub(crate) fn adt_is_box(&self, def: AdtDef) -> bool { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cx.adt_is_box(def.internal(&mut *tables, cx.tcx)) + self.with_cx(|tables, cx| cx.adt_is_box(def.internal(tables, cx.tcx))) } /// Returns whether this ADT is simd. pub(crate) fn adt_is_simd(&self, def: AdtDef) -> bool { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cx.adt_is_simd(def.internal(&mut *tables, cx.tcx)) + self.with_cx(|tables, cx| cx.adt_is_simd(def.internal(tables, cx.tcx))) } /// Returns whether this definition is a C string. pub(crate) fn adt_is_cstr(&self, def: AdtDef) -> bool { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cx.adt_is_cstr(def.0.internal(&mut *tables, cx.tcx)) + self.with_cx(|tables, cx| cx.adt_is_cstr(def.0.internal(tables, cx.tcx))) } /// Returns the representation options for this ADT pub(crate) fn adt_repr(&self, def: AdtDef) -> ReprOptions { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cx.adt_repr(def.internal(&mut *tables, cx.tcx)).stable(&mut *tables, cx) + self.with_cx(|tables, cx| cx.adt_repr(def.internal(tables, cx.tcx)).stable(tables, cx)) } /// Retrieve the function signature for the given generic arguments. pub(crate) fn fn_sig(&self, def: FnDef, args: &GenericArgs) -> PolyFnSig { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let def_id = def.0.internal(&mut *tables, cx.tcx); - let args_ref = args.internal(&mut *tables, cx.tcx); - cx.fn_sig(def_id, args_ref).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let def_id = def.0.internal(tables, cx.tcx); + let args_ref = args.internal(tables, cx.tcx); + cx.fn_sig(def_id, args_ref).stable(tables, cx) + }) } /// Retrieve the constness for the given function definition. pub(crate) fn constness(&self, def: FnDef) -> Constness { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let def_id = def.0.internal(&mut *tables, cx.tcx); - cx.constness(def_id).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let def_id = def.0.internal(tables, cx.tcx); + cx.constness(def_id).stable(tables, cx) + }) } /// Retrieve the asyncness for the given function definition. pub(crate) fn asyncness(&self, def: FnDef) -> Asyncness { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let def_id = def.0.internal(&mut *tables, cx.tcx); - cx.asyncness(def_id).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let def_id = def.0.internal(tables, cx.tcx); + cx.asyncness(def_id).stable(tables, cx) + }) } /// Retrieve the intrinsic definition if the item corresponds one. pub(crate) fn intrinsic(&self, item: DefId) -> Option { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let def_id = item.internal(&mut *tables, cx.tcx); - cx.intrinsic(def_id).map(|_| IntrinsicDef(item)) + self.with_cx(|tables, cx| { + let def_id = item.internal(tables, cx.tcx); + cx.intrinsic(def_id).map(|_| IntrinsicDef(item)) + }) } /// Retrieve the plain function name of an intrinsic. pub(crate) fn intrinsic_name(&self, def: IntrinsicDef) -> Symbol { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let def_id = def.0.internal(&mut *tables, cx.tcx); - cx.intrinsic_name(def_id) + self.with_cx(|tables, cx| { + let def_id = def.0.internal(tables, cx.tcx); + cx.intrinsic_name(def_id) + }) } /// Retrieve the closure signature for the given generic arguments. pub(crate) fn closure_sig(&self, args: &GenericArgs) -> PolyFnSig { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let args_ref = args.internal(&mut *tables, cx.tcx); - cx.closure_sig(args_ref).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let args_ref = args.internal(tables, cx.tcx); + cx.closure_sig(args_ref).stable(tables, cx) + }) } /// The number of variants in this ADT. pub(crate) fn adt_variants_len(&self, def: AdtDef) -> usize { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cx.adt_variants_len(def.internal(&mut *tables, cx.tcx)) + self.with_cx(|tables, cx| cx.adt_variants_len(def.internal(tables, cx.tcx))) } /// Discriminant for a given variant index of AdtDef. pub(crate) fn adt_discr_for_variant(&self, adt: AdtDef, variant: VariantIdx) -> Discr { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cx.adt_discr_for_variant( - adt.internal(&mut *tables, cx.tcx), - variant.internal(&mut *tables, cx.tcx), - ) - .stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + cx.adt_discr_for_variant(adt.internal(tables, cx.tcx), variant.internal(tables, cx.tcx)) + .stable(tables, cx) + }) } /// Discriminant for a given variand index and args of a coroutine. @@ -453,67 +446,57 @@ impl<'tcx> CompilerInterface<'tcx> { args: &GenericArgs, variant: VariantIdx, ) -> Discr { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let tcx = cx.tcx; - let def = coroutine.def_id().internal(&mut *tables, tcx); - let args_ref = args.internal(&mut *tables, tcx); - cx.coroutine_discr_for_variant(def, args_ref, variant.internal(&mut *tables, tcx)) - .stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let tcx = cx.tcx; + let def = coroutine.def_id().internal(tables, tcx); + let args_ref = args.internal(tables, tcx); + cx.coroutine_discr_for_variant(def, args_ref, variant.internal(tables, tcx)) + .stable(tables, cx) + }) } /// The name of a variant. pub(crate) fn variant_name(&self, def: VariantDef) -> Symbol { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cx.variant_name(def.internal(&mut *tables, cx.tcx)) + self.with_cx(|tables, cx| cx.variant_name(def.internal(tables, cx.tcx))) } pub(crate) fn variant_fields(&self, def: VariantDef) -> Vec { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - def.internal(&mut *tables, cx.tcx) - .fields - .iter() - .map(|f| f.stable(&mut *tables, cx)) - .collect() + self.with_cx(|tables, cx| { + def.internal(tables, cx.tcx).fields.iter().map(|f| f.stable(tables, cx)).collect() + }) } /// Evaluate constant as a target usize. pub(crate) fn eval_target_usize(&self, mir_const: &MirConst) -> Result { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let cnst = mir_const.internal(&mut *tables, cx.tcx); - cx.eval_target_usize(cnst) + self.with_cx(|tables, cx| { + let cnst = mir_const.internal(tables, cx.tcx); + cx.eval_target_usize(cnst) + }) } pub(crate) fn eval_target_usize_ty(&self, ty_const: &TyConst) -> Result { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let cnst = ty_const.internal(&mut *tables, cx.tcx); - cx.eval_target_usize_ty(cnst) + self.with_cx(|tables, cx| { + let cnst = ty_const.internal(tables, cx.tcx); + cx.eval_target_usize_ty(cnst) + }) } /// Create a new zero-sized constant. pub(crate) fn try_new_const_zst(&self, ty: Ty) -> Result { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let ty_internal = ty.internal(&mut *tables, cx.tcx); - cx.try_new_const_zst(ty_internal).map(|cnst| cnst.stable(&mut *tables, cx)) + self.with_cx(|tables, cx| { + let ty_internal = ty.internal(tables, cx.tcx); + cx.try_new_const_zst(ty_internal).map(|cnst| cnst.stable(tables, cx)) + }) } /// Create a new constant that represents the given string value. pub(crate) fn new_const_str(&self, value: &str) -> MirConst { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cx.new_const_str(value).stable(&mut *tables, cx) + self.with_cx(|tables, cx| cx.new_const_str(value).stable(tables, cx)) } /// Create a new constant that represents the given boolean value. pub(crate) fn new_const_bool(&self, value: bool) -> MirConst { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cx.new_const_bool(value).stable(&mut *tables, cx) + self.with_cx(|tables, cx| cx.new_const_bool(value).stable(tables, cx)) } /// Create a new constant that represents the given value. @@ -522,10 +505,10 @@ impl<'tcx> CompilerInterface<'tcx> { value: u128, uint_ty: UintTy, ) -> Result { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let ty = cx.ty_new_uint(uint_ty.internal(&mut *tables, cx.tcx)); - cx.try_new_const_uint(value, ty).map(|cnst| cnst.stable(&mut *tables, cx)) + self.with_cx(|tables, cx| { + let ty = cx.ty_new_uint(uint_ty.internal(tables, cx.tcx)); + cx.try_new_const_uint(value, ty).map(|cnst| cnst.stable(tables, cx)) + }) } pub(crate) fn try_new_ty_const_uint( @@ -533,178 +516,170 @@ impl<'tcx> CompilerInterface<'tcx> { value: u128, uint_ty: UintTy, ) -> Result { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let ty = cx.ty_new_uint(uint_ty.internal(&mut *tables, cx.tcx)); - cx.try_new_ty_const_uint(value, ty).map(|cnst| cnst.stable(&mut *tables, cx)) + self.with_cx(|tables, cx| { + let ty = cx.ty_new_uint(uint_ty.internal(tables, cx.tcx)); + cx.try_new_ty_const_uint(value, ty).map(|cnst| cnst.stable(tables, cx)) + }) } /// Create a new type from the given kind. pub(crate) fn new_rigid_ty(&self, kind: RigidTy) -> Ty { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let internal_kind = kind.internal(&mut *tables, cx.tcx); - cx.new_rigid_ty(internal_kind).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let internal_kind = kind.internal(tables, cx.tcx); + cx.new_rigid_ty(internal_kind).stable(tables, cx) + }) } /// Create a new box type, `Box`, for the given inner type `T`. pub(crate) fn new_box_ty(&self, ty: Ty) -> Ty { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let inner = ty.internal(&mut *tables, cx.tcx); - cx.new_box_ty(inner).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let inner = ty.internal(tables, cx.tcx); + cx.new_box_ty(inner).stable(tables, cx) + }) } /// Returns the type of given crate item. pub(crate) fn def_ty(&self, item: DefId) -> Ty { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let inner = item.internal(&mut *tables, cx.tcx); - cx.def_ty(inner).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let inner = item.internal(tables, cx.tcx); + cx.def_ty(inner).stable(tables, cx) + }) } /// Returns the type of given definition instantiated with the given arguments. pub(crate) fn def_ty_with_args(&self, item: DefId, args: &GenericArgs) -> Ty { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let inner = item.internal(&mut *tables, cx.tcx); - let args_ref = args.internal(&mut *tables, cx.tcx); - cx.def_ty_with_args(inner, args_ref).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let inner = item.internal(tables, cx.tcx); + let args_ref = args.internal(tables, cx.tcx); + cx.def_ty_with_args(inner, args_ref).stable(tables, cx) + }) } /// Returns literal value of a const as a string. pub(crate) fn mir_const_pretty(&self, cnst: &MirConst) -> String { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cnst.internal(&mut *tables, cx.tcx).to_string() + self.with_cx(|tables, cx| cnst.internal(tables, cx.tcx).to_string()) } /// `Span` of a `DefId`. pub(crate) fn span_of_a_def(&self, def_id: DefId) -> Span { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let did = tables[def_id]; - cx.span_of_a_def(did).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let did = tables[def_id]; + cx.span_of_a_def(did).stable(tables, cx) + }) } pub(crate) fn ty_const_pretty(&self, ct: TyConstId) -> String { - let tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cx.ty_const_pretty(tables.ty_consts[ct]) + self.with_cx(|tables, cx| cx.ty_const_pretty(tables.ty_consts[ct])) } /// Obtain the representation of a type. pub(crate) fn ty_pretty(&self, ty: Ty) -> String { - let tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cx.ty_pretty(tables.types[ty]) + self.with_cx(|tables, cx| cx.ty_pretty(tables.types[ty])) } /// Obtain the kind of a type. pub(crate) fn ty_kind(&self, ty: Ty) -> TyKind { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cx.ty_kind(tables.types[ty]).stable(&mut *tables, cx) + self.with_cx(|tables, cx| cx.ty_kind(tables.types[ty]).stable(tables, cx)) } /// Get the discriminant Ty for this Ty if there's one. pub(crate) fn rigid_ty_discriminant_ty(&self, ty: &RigidTy) -> Ty { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let internal_kind = ty.internal(&mut *tables, cx.tcx); - cx.rigid_ty_discriminant_ty(internal_kind).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let internal_kind = ty.internal(tables, cx.tcx); + cx.rigid_ty_discriminant_ty(internal_kind).stable(tables, cx) + }) } /// Get the body of an Instance which is already monomorphized. pub(crate) fn instance_body(&self, instance: InstanceDef) -> Option { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let instance = tables.instances[instance]; - cx.instance_body(instance).map(|body| body.stable(&mut *tables, cx)) + self.with_cx(|tables, cx| { + let instance = tables.instances[instance]; + cx.instance_body(instance).map(|body| body.stable(tables, cx)) + }) } /// Get the instance type with generic instantiations applied and lifetimes erased. pub(crate) fn instance_ty(&self, instance: InstanceDef) -> Ty { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let instance = tables.instances[instance]; - cx.instance_ty(instance).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let instance = tables.instances[instance]; + cx.instance_ty(instance).stable(tables, cx) + }) } /// Get the instantiation types. pub(crate) fn instance_args(&self, def: InstanceDef) -> GenericArgs { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let instance = tables.instances[def]; - cx.instance_args(instance).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let instance = tables.instances[def]; + cx.instance_args(instance).stable(tables, cx) + }) } /// Get the instance. pub(crate) fn instance_def_id(&self, instance: InstanceDef) -> DefId { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let instance = tables.instances[instance]; - cx.instance_def_id(instance, &mut *tables) + self.with_cx(|tables, cx| { + let instance = tables.instances[instance]; + cx.instance_def_id(instance, tables) + }) } /// Get the instance mangled name. pub(crate) fn instance_mangled_name(&self, instance: InstanceDef) -> Symbol { - let tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let instance = tables.instances[instance]; - cx.instance_mangled_name(instance) + self.with_cx(|tables, cx| { + let instance = tables.instances[instance]; + cx.instance_mangled_name(instance) + }) } /// Check if this is an empty DropGlue shim. pub(crate) fn is_empty_drop_shim(&self, def: InstanceDef) -> bool { - let tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let instance = tables.instances[def]; - cx.is_empty_drop_shim(instance) + self.with_cx(|tables, cx| { + let instance = tables.instances[def]; + cx.is_empty_drop_shim(instance) + }) } /// Convert a non-generic crate item into an instance. /// This function will panic if the item is generic. pub(crate) fn mono_instance(&self, def_id: DefId) -> Instance { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let did = tables[def_id]; - cx.mono_instance(did).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let did = tables[def_id]; + cx.mono_instance(did).stable(tables, cx) + }) } /// Item requires monomorphization. pub(crate) fn requires_monomorphization(&self, def_id: DefId) -> bool { - let tables = self.tables.borrow(); - let cx = &*self.cx.borrow(); - let did = tables[def_id]; - cx.requires_monomorphization(did) + self.with_cx(|tables, cx| { + let did = tables[def_id]; + cx.requires_monomorphization(did) + }) } /// Resolve an instance from the given function definition and generic arguments. pub(crate) fn resolve_instance(&self, def: FnDef, args: &GenericArgs) -> Option { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let def_id = def.0.internal(&mut *tables, cx.tcx); - let args_ref = args.internal(&mut *tables, cx.tcx); - cx.resolve_instance(def_id, args_ref).map(|inst| inst.stable(&mut *tables, cx)) + self.with_cx(|tables, cx| { + let def_id = def.0.internal(tables, cx.tcx); + let args_ref = args.internal(tables, cx.tcx); + cx.resolve_instance(def_id, args_ref).map(|inst| inst.stable(tables, cx)) + }) } /// Resolve an instance for drop_in_place for the given type. pub(crate) fn resolve_drop_in_place(&self, ty: Ty) -> Instance { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let internal_ty = ty.internal(&mut *tables, cx.tcx); + self.with_cx(|tables, cx| { + let internal_ty = ty.internal(tables, cx.tcx); - cx.resolve_drop_in_place(internal_ty).stable(&mut *tables, cx) + cx.resolve_drop_in_place(internal_ty).stable(tables, cx) + }) } /// Resolve instance for a function pointer. pub(crate) fn resolve_for_fn_ptr(&self, def: FnDef, args: &GenericArgs) -> Option { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let def_id = def.0.internal(&mut *tables, cx.tcx); - let args_ref = args.internal(&mut *tables, cx.tcx); - cx.resolve_for_fn_ptr(def_id, args_ref).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let def_id = def.0.internal(tables, cx.tcx); + let args_ref = args.internal(tables, cx.tcx); + cx.resolve_for_fn_ptr(def_id, args_ref).stable(tables, cx) + }) } /// Resolve instance for a closure with the requested type. @@ -714,21 +689,21 @@ impl<'tcx> CompilerInterface<'tcx> { args: &GenericArgs, kind: ClosureKind, ) -> Option { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let def_id = def.0.internal(&mut *tables, cx.tcx); - let args_ref = args.internal(&mut *tables, cx.tcx); - let closure_kind = kind.internal(&mut *tables, cx.tcx); - cx.resolve_closure(def_id, args_ref, closure_kind).map(|inst| inst.stable(&mut *tables, cx)) + self.with_cx(|tables, cx| { + let def_id = def.0.internal(tables, cx.tcx); + let args_ref = args.internal(tables, cx.tcx); + let closure_kind = kind.internal(tables, cx.tcx); + cx.resolve_closure(def_id, args_ref, closure_kind).map(|inst| inst.stable(tables, cx)) + }) } /// Evaluate a static's initializer. pub(crate) fn eval_static_initializer(&self, def: StaticDef) -> Result { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let def_id = def.0.internal(&mut *tables, cx.tcx); + self.with_cx(|tables, cx| { + let def_id = def.0.internal(tables, cx.tcx); - cx.eval_static_initializer(def_id).stable(&mut *tables, cx) + cx.eval_static_initializer(def_id).stable(tables, cx) + }) } /// Try to evaluate an instance into a constant. @@ -737,142 +712,133 @@ impl<'tcx> CompilerInterface<'tcx> { def: InstanceDef, const_ty: Ty, ) -> Result { - let mut tables = self.tables.borrow_mut(); - let instance = tables.instances[def]; - let cx = &*self.cx.borrow(); - let const_ty = const_ty.internal(&mut *tables, cx.tcx); - cx.eval_instance(instance) - .map(|const_val| alloc::try_new_allocation(const_ty, const_val, &mut *tables, cx)) - .map_err(|e| e.stable(&mut *tables, cx))? + self.with_cx(|tables, cx| { + let instance = tables.instances[def]; + let const_ty = const_ty.internal(tables, cx.tcx); + cx.eval_instance(instance) + .map(|const_val| alloc::try_new_allocation(const_ty, const_val, tables, cx)) + .map_err(|e| e.stable(tables, cx))? + }) } /// Retrieve global allocation for the given allocation ID. pub(crate) fn global_alloc(&self, id: AllocId) -> GlobalAlloc { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let alloc_id = id.internal(&mut *tables, cx.tcx); - cx.global_alloc(alloc_id).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let alloc_id = id.internal(tables, cx.tcx); + cx.global_alloc(alloc_id).stable(tables, cx) + }) } /// Retrieve the id for the virtual table. pub(crate) fn vtable_allocation(&self, global_alloc: &GlobalAlloc) -> Option { - let mut tables = self.tables.borrow_mut(); - let GlobalAlloc::VTable(ty, trait_ref) = global_alloc else { - return None; - }; - let cx = &*self.cx.borrow(); - let ty = ty.internal(&mut *tables, cx.tcx); - let trait_ref = trait_ref.internal(&mut *tables, cx.tcx); - let alloc_id = cx.vtable_allocation(ty, trait_ref); - Some(alloc_id.stable(&mut *tables, cx)) + self.with_cx(|tables, cx| { + let GlobalAlloc::VTable(ty, trait_ref) = global_alloc else { + return None; + }; + let ty = ty.internal(tables, cx.tcx); + let trait_ref = trait_ref.internal(tables, cx.tcx); + let alloc_id = cx.vtable_allocation(ty, trait_ref); + Some(alloc_id.stable(tables, cx)) + }) } pub(crate) fn krate(&self, def_id: DefId) -> Crate { - let tables = self.tables.borrow(); - let cx = &*self.cx.borrow(); - smir_crate(cx, tables[def_id].krate) + self.with_cx(|tables, cx| smir_crate(cx, tables[def_id].krate)) } pub(crate) fn instance_name(&self, def: InstanceDef, trimmed: bool) -> Symbol { - let tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let instance = tables.instances[def]; - cx.instance_name(instance, trimmed) + self.with_cx(|tables, cx| { + let instance = tables.instances[def]; + cx.instance_name(instance, trimmed) + }) } /// Return information about the target machine. pub(crate) fn target_info(&self) -> MachineInfo { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - MachineInfo { - endian: cx.target_endian().stable(&mut *tables, cx), + self.with_cx(|tables, cx| MachineInfo { + endian: cx.target_endian().stable(tables, cx), pointer_width: MachineSize::from_bits(cx.target_pointer_size()), - } + }) } /// Get an instance ABI. pub(crate) fn instance_abi(&self, def: InstanceDef) -> Result { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let instance = tables.instances[def]; - cx.instance_abi(instance).map(|fn_abi| fn_abi.stable(&mut *tables, cx)) + self.with_cx(|tables, cx| { + let instance = tables.instances[def]; + cx.instance_abi(instance).map(|fn_abi| fn_abi.stable(tables, cx)) + }) } /// Get the ABI of a function pointer. pub(crate) fn fn_ptr_abi(&self, fn_ptr: PolyFnSig) -> Result { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let sig = fn_ptr.internal(&mut *tables, cx.tcx); - cx.fn_ptr_abi(sig).map(|fn_abi| fn_abi.stable(&mut *tables, cx)) + self.with_cx(|tables, cx| { + let sig = fn_ptr.internal(tables, cx.tcx); + cx.fn_ptr_abi(sig).map(|fn_abi| fn_abi.stable(tables, cx)) + }) } /// Get the layout of a type. pub(crate) fn ty_layout(&self, ty: Ty) -> Result { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let internal_ty = ty.internal(&mut *tables, cx.tcx); - cx.ty_layout(internal_ty).map(|layout| layout.stable(&mut *tables, cx)) + self.with_cx(|tables, cx| { + let internal_ty = ty.internal(tables, cx.tcx); + cx.ty_layout(internal_ty).map(|layout| layout.stable(tables, cx)) + }) } /// Get the layout shape. pub(crate) fn layout_shape(&self, id: Layout) -> LayoutShape { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - id.internal(&mut *tables, cx.tcx).0.stable(&mut *tables, cx) + self.with_cx(|tables, cx| id.internal(tables, cx.tcx).0.stable(tables, cx)) } /// Get a debug string representation of a place. pub(crate) fn place_pretty(&self, place: &Place) -> String { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - - format!("{:?}", place.internal(&mut *tables, cx.tcx)) + self.with_cx(|tables, cx| format!("{:?}", place.internal(tables, cx.tcx))) } /// Get the resulting type of binary operation. pub(crate) fn binop_ty(&self, bin_op: BinOp, rhs: Ty, lhs: Ty) -> Ty { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let rhs_internal = rhs.internal(&mut *tables, cx.tcx); - let lhs_internal = lhs.internal(&mut *tables, cx.tcx); - let bin_op_internal = bin_op.internal(&mut *tables, cx.tcx); - cx.binop_ty(bin_op_internal, rhs_internal, lhs_internal).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let rhs_internal = rhs.internal(tables, cx.tcx); + let lhs_internal = lhs.internal(tables, cx.tcx); + let bin_op_internal = bin_op.internal(tables, cx.tcx); + cx.binop_ty(bin_op_internal, rhs_internal, lhs_internal).stable(tables, cx) + }) } /// Get the resulting type of unary operation. pub(crate) fn unop_ty(&self, un_op: UnOp, arg: Ty) -> Ty { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let un_op = un_op.internal(&mut *tables, cx.tcx); - let arg = arg.internal(&mut *tables, cx.tcx); - cx.unop_ty(un_op, arg).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + let un_op = un_op.internal(tables, cx.tcx); + let arg = arg.internal(tables, cx.tcx); + cx.unop_ty(un_op, arg).stable(tables, cx) + }) } /// Get all associated items of a definition. pub(crate) fn associated_items(&self, def_id: DefId) -> AssocItems { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - let did = tables[def_id]; - cx.associated_items(did).iter().map(|assoc| assoc.stable(&mut *tables, cx)).collect() + self.with_cx(|tables, cx| { + let did = tables[def_id]; + cx.associated_items(did).iter().map(|assoc| assoc.stable(tables, cx)).collect() + }) } /// Get all vtable entries of a trait. pub(crate) fn vtable_entries(&self, trait_ref: &TraitRef) -> Vec { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cx.vtable_entries(trait_ref.internal(&mut *tables, cx.tcx)) - .iter() - .map(|v| v.stable(&mut *tables, cx)) - .collect() + self.with_cx(|tables, cx| { + cx.vtable_entries(trait_ref.internal(tables, cx.tcx)) + .iter() + .map(|v| v.stable(tables, cx)) + .collect() + }) } /// Returns the vtable entry at the given index. /// /// Returns `None` if the index is out of bounds. pub(crate) fn vtable_entry(&self, trait_ref: &TraitRef, idx: usize) -> Option { - let mut tables = self.tables.borrow_mut(); - let cx = &*self.cx.borrow(); - cx.vtable_entry(trait_ref.internal(&mut *tables, cx.tcx), idx).stable(&mut *tables, cx) + self.with_cx(|tables, cx| { + cx.vtable_entry(trait_ref.internal(tables, cx.tcx), idx).stable(tables, cx) + }) } } diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index 43443e0ac3052..4fd98944909dc 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -52,7 +52,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { decl: Decl<'ra>, ) { if let Err(old_decl) = - self.try_plant_decl_into_local_module(ident, orig_ident_span, ns, decl, false) + self.try_plant_decl_into_local_module(ident, orig_ident_span, ns, decl) { self.report_conflict(ident, ns, old_decl, decl); } @@ -87,13 +87,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { vis: Visibility, span: Span, expansion: LocalExpnId, - ambiguity: Option>, + ambiguity: Option<(Decl<'ra>, bool)>, ) { let decl = self.arenas.alloc_decl(DeclData { kind: DeclKind::Def(res), ambiguity: CmCell::new(ambiguity), - // External ambiguities always report the `AMBIGUOUS_GLOB_IMPORTS` lint at the moment. - warn_ambiguity: CmCell::new(true), initial_vis: vis, ambiguity_vis_max: CmCell::new(None), ambiguity_vis_min: CmCell::new(None), @@ -392,7 +390,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { let ModChild { ident: _, res, vis, ref reexport_chain } = *ambig_child; let span = child_span(self, reexport_chain, res); let res = res.expect_non_local(); - self.arenas.new_def_decl(res, vis, span, expansion, Some(parent.to_module())) + // External ambiguities always report the `AMBIGUOUS_GLOB_IMPORTS` lint at the moment. + (self.arenas.new_def_decl(res, vis, span, expansion, Some(parent.to_module())), true) }); // Record primary definitions. diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 85e8d6711e075..d75ae850ca33b 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1188,7 +1188,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { .emit() } - fn def_path_str(&self, mut def_id: DefId) -> String { + pub(crate) fn def_path_str(&self, mut def_id: DefId) -> String { // We can't use `def_path_str` in resolve. let mut path = vec![def_id]; while let Some(parent) = self.tcx.opt_parent(def_id) { diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index c49e0fce630d4..c95799758cd59 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -382,11 +382,9 @@ fn remove_same_import<'ra>(d1: Decl<'ra>, d2: Decl<'ra>) -> (Decl<'ra>, Decl<'ra assert_eq!(d1.span, d2.span); if d1.ambiguity.get() != d2.ambiguity.get() { assert!(d1.ambiguity.get().is_some()); - assert!(d2.ambiguity.get().is_none()); } // Visibility of the new import declaration may be different, // because it already incorporates the visibility of the source binding. - // `warn_ambiguity` of a re-fetched glob can also change in both directions. remove_same_import(d1_next, d2_next) } else { (d1, d2) @@ -450,7 +448,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { self.arenas.alloc_decl(DeclData { kind: DeclKind::Import { source_decl: decl, import }, ambiguity: CmCell::new(None), - warn_ambiguity: CmCell::new(false), span: import.span, initial_vis: vis.to_def_id(), ambiguity_vis_max: CmCell::new(None), @@ -460,14 +457,85 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { }) } + fn is_noise_0_7_0(&self, old_glob_decl: Decl<'ra>, glob_decl: Decl<'ra>) -> bool { + let DeclKind::Import { import: i1, .. } = glob_decl.kind else { unreachable!() }; + let DeclKind::Import { import: i2, .. } = old_glob_decl.kind else { unreachable!() }; + let [seg1, seg2] = &i1.module_path[..] else { return false }; + if seg1.ident.name != kw::SelfLower || seg2.ident.name.as_str() != "perlin_surflet" { + return false; + } + let [seg1, seg2] = &i2.module_path[..] else { return false }; + if seg1.ident.name != kw::SelfLower || seg2.ident.name.as_str() != "perlin" { + return false; + } + let Some(def_id1) = glob_decl.res().opt_def_id() else { return false }; + let Some(def_id2) = old_glob_decl.res().opt_def_id() else { return false }; + self.def_path_str(def_id1).ends_with("noise_fns::generators::perlin_surflet::Perlin") + && self.def_path_str(def_id2).ends_with("noise_fns::generators::perlin::Perlin") + } + + fn is_rustybuzz_0_4_0(&self, old_glob_decl: Decl<'ra>, glob_decl: Decl<'ra>) -> bool { + let DeclKind::Import { import: i1, .. } = glob_decl.kind else { unreachable!() }; + let DeclKind::Import { import: i2, .. } = old_glob_decl.kind else { unreachable!() }; + let [seg1, seg2] = &i1.module_path[..] else { return false }; + if seg1.ident.name != kw::Super || seg2.ident.name.as_str() != "gsubgpos" { + return false; + } + let [seg1] = &i2.module_path[..] else { return false }; + if seg1.ident.name != kw::Super { + return false; + } + let Some(def_id1) = glob_decl.res().opt_def_id() else { return false }; + let Some(def_id2) = old_glob_decl.res().opt_def_id() else { return false }; + self.def_path_str(def_id1).ends_with("tables::gsubgpos::Class") + && self.def_path_str(def_id2).ends_with("ggg::Class") + } + + fn is_pdf_0_9_0(&self, old_glob_decl: Decl<'ra>, glob_decl: Decl<'ra>) -> bool { + let DeclKind::Import { import: i1, .. } = glob_decl.kind else { unreachable!() }; + let DeclKind::Import { import: i2, .. } = old_glob_decl.kind else { unreachable!() }; + let [seg1, seg2] = &i1.module_path[..] else { return false }; + if seg1.ident.name != kw::Crate || seg2.ident.name.as_str() != "content" { + return false; + } + let [seg1, seg2] = &i2.module_path[..] else { return false }; + if seg1.ident.name != kw::Crate || seg2.ident.name.as_str() != "object" { + return false; + } + let Some(def_id1) = glob_decl.res().opt_def_id() else { return false }; + let Some(def_id2) = old_glob_decl.res().opt_def_id() else { return false }; + self.def_path_str(def_id1).ends_with("crate::content::Rect") + && self.def_path_str(def_id2).ends_with("crate::object::types::Rect") + } + + fn is_net2_0_2_39(&self, old_glob_decl: Decl<'ra>, glob_decl: Decl<'ra>) -> bool { + let DeclKind::Import { import: i1, .. } = glob_decl.kind else { unreachable!() }; + let DeclKind::Import { import: i2, .. } = old_glob_decl.kind else { unreachable!() }; + let [seg1, seg2, seg3, seg4] = &i1.module_path[..] else { return false }; + if seg1.ident.name != kw::PathRoot + || seg2.ident.name.as_str() != "winapi" + || seg3.ident.name.as_str() != "shared" + || seg4.ident.name.as_str() != "ws2def" + { + return false; + } + let [seg1, seg2, seg3, seg4] = &i2.module_path[..] else { return false }; + if seg1.ident.name != kw::PathRoot + || seg2.ident.name.as_str() != "winapi" + || seg3.ident.name.as_str() != "um" + || seg4.ident.name.as_str() != "winsock2" + { + return false; + } + let Some(def_id1) = glob_decl.res().opt_def_id() else { return false }; + let Some(def_id2) = old_glob_decl.res().opt_def_id() else { return false }; + self.def_path_str(def_id1).starts_with("winapi::shared::ws2def::") + && self.def_path_str(def_id2).starts_with("winapi::um::winsock2::") + } + /// If `glob_decl` attempts to overwrite `old_glob_decl` in a module, /// decide which one to keep. - fn select_glob_decl( - &self, - old_glob_decl: Decl<'ra>, - glob_decl: Decl<'ra>, - warn_ambiguity: bool, - ) -> Decl<'ra> { + fn select_glob_decl(&self, old_glob_decl: Decl<'ra>, glob_decl: Decl<'ra>) -> Decl<'ra> { assert!(glob_decl.is_glob_import()); assert!(old_glob_decl.is_glob_import()); assert_ne!(glob_decl, old_glob_decl); @@ -476,9 +544,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // all these overwrites will be re-fetched by glob imports importing // from that module without generating new ambiguities. // - A glob decl is overwritten by a non-glob decl arriving later. - // - A glob decl is overwritten by its clone after setting ambiguity in it. - // FIXME: avoid this by removing `warn_ambiguity`, or by triggering glob re-fetch - // with the same decl in some way. // - A glob decl is overwritten by a glob decl re-fetching an // overwritten decl from other module (the recursive case). // Here we are detecting all such re-fetches and overwrite old decls @@ -489,29 +554,21 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { if deep_decl != glob_decl { // Some import layers have been removed, need to overwrite. assert_ne!(old_deep_decl, old_glob_decl); - // FIXME: reenable the asserts when `warn_ambiguity` is removed (#149195). - // assert_ne!(old_deep_decl, deep_decl); - // assert!(old_deep_decl.is_glob_import()); assert!(!deep_decl.is_glob_import()); - if old_glob_decl.ambiguity.get().is_some() && glob_decl.ambiguity.get().is_none() { + if let Some((old_ambig, _)) = old_glob_decl.ambiguity.get() + && glob_decl.ambiguity.get().is_none() + { // Do not lose glob ambiguities when re-fetching the glob. - glob_decl.ambiguity.set_unchecked(old_glob_decl.ambiguity.get()); - } - if glob_decl.is_ambiguity_recursive() { - glob_decl.warn_ambiguity.set_unchecked(true); + glob_decl.ambiguity.set_unchecked(Some((old_ambig, true))); } glob_decl } else if glob_decl.res() != old_glob_decl.res() { - old_glob_decl.ambiguity.set_unchecked(Some(glob_decl)); - old_glob_decl.warn_ambiguity.set_unchecked(warn_ambiguity); - if warn_ambiguity { - old_glob_decl - } else { - // Need a fresh decl so other glob imports importing it could re-fetch it - // and set their own `warn_ambiguity` to true. - // FIXME: remove this when `warn_ambiguity` is removed (#149195). - self.arenas.alloc_decl((*old_glob_decl).clone()) - } + let warning = self.is_noise_0_7_0(old_glob_decl, glob_decl) + || self.is_rustybuzz_0_4_0(old_glob_decl, glob_decl) + || self.is_pdf_0_9_0(old_glob_decl, glob_decl) + || self.is_net2_0_2_39(old_glob_decl, glob_decl); + old_glob_decl.ambiguity.set_unchecked(Some((glob_decl, warning))); + old_glob_decl } else if let old_vis = old_glob_decl.vis() && let vis = glob_decl.vis() && old_vis != vis @@ -529,8 +586,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { old_glob_decl } else if glob_decl.is_ambiguity_recursive() && !old_glob_decl.is_ambiguity_recursive() { // Overwriting a non-ambiguous glob import with an ambiguous glob import. - old_glob_decl.ambiguity.set_unchecked(Some(glob_decl)); - old_glob_decl.warn_ambiguity.set_unchecked(true); + old_glob_decl.ambiguity.set_unchecked(Some((glob_decl, true))); old_glob_decl } else { old_glob_decl @@ -545,9 +601,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { orig_ident_span: Span, ns: Namespace, decl: Decl<'ra>, - warn_ambiguity: bool, ) -> Result<(), Decl<'ra>> { - assert!(!decl.warn_ambiguity.get()); assert!(decl.ambiguity.get().is_none()); assert!(decl.ambiguity_vis_max.get().is_none()); assert!(decl.ambiguity_vis_min.get().is_none()); @@ -562,31 +616,21 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { module.underscore_disambiguator.update_unchecked(|d| d + 1); module.underscore_disambiguator.get() }); - self.update_local_resolution( - module, - key, - orig_ident_span, - warn_ambiguity, - |this, resolution| { - if decl.is_glob_import() { - resolution.glob_decl = Some(match resolution.glob_decl { - Some(old_decl) => this.select_glob_decl( - old_decl, - decl, - warn_ambiguity && resolution.non_glob_decl.is_none(), - ), - None => decl, - }) - } else { - resolution.non_glob_decl = Some(match resolution.non_glob_decl { - Some(old_decl) => return Err(old_decl), - None => decl, - }) - } + self.update_local_resolution(module, key, orig_ident_span, |this, resolution| { + if decl.is_glob_import() { + resolution.glob_decl = Some(match resolution.glob_decl { + Some(old_decl) => this.select_glob_decl(old_decl, decl), + None => decl, + }); + } else { + resolution.non_glob_decl = Some(match resolution.non_glob_decl { + Some(old_decl) => return Err(old_decl), + None => decl, + }) + } - Ok(()) - }, - ) + Ok(()) + }) } // Use `f` to mutate the resolution of the name in the module. @@ -596,7 +640,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { module: LocalModule<'ra>, key: BindingKey, orig_ident_span: Span, - warn_ambiguity: bool, f: F, ) -> T where @@ -604,7 +647,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { { // Ensure that `resolution` isn't borrowed when defining in the module's glob importers, // during which the resolution might end up getting re-defined via a glob cycle. - let (binding, t, warn_ambiguity) = { + let (binding, t) = { let resolution = &mut *self .resolution_or_default(module.to_module(), key, orig_ident_span) .borrow_mut_unchecked(); @@ -616,7 +659,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { if let Some(binding) = resolution.determined_decl() && (old_decl != Some(binding) || old_vis != Some(binding.vis())) { - (binding, t, warn_ambiguity || old_decl.is_some()) + (binding, t) } else { return t; } @@ -639,14 +682,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { }; if self.is_accessible_from(binding.vis(), scope) { let import_decl = self.new_import_decl(binding, *import); - self.try_plant_decl_into_local_module( - ident, - orig_ident_span, - key.ns, - import_decl, - warn_ambiguity, - ) - .expect("planting a glob cannot fail"); + self.try_plant_decl_into_local_module(ident, orig_ident_span, key.ns, import_decl) + .expect("planting a glob cannot fail"); } } @@ -665,13 +702,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { self.per_ns(|this, ns| { let ident = IdentKey::new(target); // This can fail, dummies are inserted only in non-occupied slots. - let _ = this.try_plant_decl_into_local_module( - ident, - target.span, - ns, - dummy_decl, - false, - ); + let _ = this.try_plant_decl_into_local_module(ident, target.span, ns, dummy_decl); // Don't remove underscores from `single_imports`, they were never added. if target.name != kw::Underscore { let key = BindingKey::new(ident, ns); @@ -679,7 +710,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { import.parent_scope.module.expect_local(), key, target.span, - false, |_, resolution| { resolution.single_imports.swap_remove(&import); }, @@ -846,7 +876,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } if let DeclKind::Import { import, .. } = binding.kind - && let Some(amb_binding) = binding.ambiguity.get() + && let Some((amb_binding, _)) = binding.ambiguity.get() && binding.res() != Res::Err && exported_ambiguities.contains(&binding) { @@ -1134,7 +1164,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { parent.expect_local(), key, target.span, - false, |_, resolution| { resolution.single_imports.swap_remove(&import); }, @@ -1820,16 +1849,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { }; if self.is_accessible_from(binding.vis(), scope) { let import_decl = self.new_import_decl(binding, import); - let warn_ambiguity = self - .resolution(import.parent_scope.module, key) - .and_then(|r| r.determined_decl()) - .is_some_and(|binding| binding.warn_ambiguity_recursive()); self.try_plant_decl_into_local_module( key.ident, orig_ident_span, key.ns, import_decl, - warn_ambiguity, ) .expect("planting a glob cannot fail"); } diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index fb8de90d28aca..d7ff0ebb3c993 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -27,7 +27,7 @@ use rustc_errors::{ use rustc_hir::def::Namespace::{self, *}; use rustc_hir::def::{CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS}; use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LOCAL_CRATE, LocalDefId}; -use rustc_hir::{MissingLifetimeKind, PrimTy, TraitCandidate}; +use rustc_hir::{MissingLifetimeKind, PrimTy}; use rustc_middle::middle::resolve_bound_vars::Set1; use rustc_middle::ty::{AssocTag, DelegationInfo, Visibility}; use rustc_middle::{bug, span_bug}; @@ -781,8 +781,7 @@ pub(crate) struct DiagMetadata<'ast> { /// Accumulate the errors due to missed lifetime elision, /// and report them all at once for each function. - current_elision_failures: - Vec<(MissingLifetime, LifetimeElisionCandidate, Either>)>, + current_elision_failures: Vec<(MissingLifetime, Either>)>, } struct LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { @@ -1749,10 +1748,10 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { let ident = lifetime.ident; if ident.name == kw::StaticLifetime { - self.record_lifetime_res( + self.record_lifetime_use( lifetime.id, LifetimeRes::Static, - LifetimeElisionCandidate::Named, + LifetimeElisionCandidate::Ignore, ); return; } @@ -1765,7 +1764,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { while let Some(rib) = lifetime_rib_iter.next() { let normalized_ident = ident.normalize_to_macros_2_0(); if let Some(&(_, res)) = rib.bindings.get(&normalized_ident) { - self.record_lifetime_res(lifetime.id, res, LifetimeElisionCandidate::Named); + self.record_lifetime_use(lifetime.id, res, LifetimeElisionCandidate::Ignore); if let LifetimeRes::Param { param, binder } = res { match self.lifetime_uses.entry(param) { @@ -1831,20 +1830,12 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { LifetimeRibKind::Item => break, LifetimeRibKind::ConstParamTy => { let guar = self.emit_non_static_lt_in_const_param_ty_error(lifetime); - self.record_lifetime_res( - lifetime.id, - LifetimeRes::Error(guar), - LifetimeElisionCandidate::Ignore, - ); + self.record_lifetime_err(lifetime.id, guar); return; } LifetimeRibKind::ConcreteAnonConst(cause) => { let guar = self.emit_forbidden_non_static_lifetime_error(cause, lifetime); - self.record_lifetime_res( - lifetime.id, - LifetimeRes::Error(guar), - LifetimeElisionCandidate::Ignore, - ); + self.record_lifetime_err(lifetime.id, guar); return; } LifetimeRibKind::AnonymousCreateParameter { .. } @@ -1862,11 +1853,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { .find_map(|rib| rib.bindings.get_key_value(&normalized_ident).map(|(&outer, _)| outer)); let guar = self.emit_undeclared_lifetime_error(lifetime, outer_res); - self.record_lifetime_res( - lifetime.id, - LifetimeRes::Error(guar), - LifetimeElisionCandidate::Named, - ); + self.record_lifetime_err(lifetime.id, guar); } #[instrument(level = "debug", skip(self))] @@ -1893,7 +1880,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { match rib.kind { LifetimeRibKind::AnonymousCreateParameter { binder, .. } => { let res = self.create_fresh_lifetime(lifetime.ident, binder, kind); - self.record_lifetime_res(lifetime.id, res, elision_candidate); + self.record_lifetime_use(lifetime.id, res, elision_candidate); return; } LifetimeRibKind::StaticIfNoLifetimeInScope { lint_id: node_id, emit_lint } => { @@ -1911,7 +1898,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } } if lifetimes_in_scope.is_empty() { - self.record_lifetime_res( + self.record_lifetime_use( lifetime.id, LifetimeRes::Static, elision_candidate, @@ -2015,23 +2002,17 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { span: lifetime.ident.span, }) }; - self.record_lifetime_res( - lifetime.id, - LifetimeRes::Error(guar), - elision_candidate, - ); + self.record_lifetime_err(lifetime.id, guar); return; } LifetimeRibKind::Elided(res) => { - self.record_lifetime_res(lifetime.id, res, elision_candidate); + self.record_lifetime_use(lifetime.id, res, elision_candidate); return; } LifetimeRibKind::ElisionFailure => { - self.diag_metadata.current_elision_failures.push(( - missing_lifetime, - elision_candidate, - Either::Left(lifetime.id), - )); + self.diag_metadata + .current_elision_failures + .push((missing_lifetime, Either::Left(lifetime.id))); return; } LifetimeRibKind::Item => break, @@ -2045,7 +2026,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } } let guar = self.report_missing_lifetime_specifiers([&missing_lifetime], None); - self.record_lifetime_res(lifetime.id, LifetimeRes::Error(guar), elision_candidate); + self.record_lifetime_err(lifetime.id, guar); } fn point_at_impl_lifetimes(&mut self, err: &mut Diag<'_>, i: usize, lifetime: Span) { @@ -2142,7 +2123,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { let id = self.r.next_node_id(); let lt = Lifetime { id, ident: Ident::new(kw::UnderscoreLifetime, span) }; - self.record_lifetime_res( + self.record_lifetime_use( anchor_id, LifetimeRes::ElidedAnchor { start: id, end: id + 1 }, LifetimeElisionCandidate::Ignore, @@ -2162,15 +2143,15 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { // Leave the responsibility to create the `LocalDefId` to lowering. let param = self.r.next_node_id(); - let res = LifetimeRes::Fresh { param, binder, kind }; - self.record_lifetime_param(param, res); + let res = LifetimeRes::Fresh { param, kind }; + self.record_lifetime_def(param, res); // Record the created lifetime parameter so lowering can pick it up and add it to HIR. self.r .extra_lifetime_params_map .entry(binder) .or_insert_with(Vec::new) - .push((ident, param, res)); + .push((ident, param, kind)); res } @@ -2226,7 +2207,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } let node_ids = self.r.next_node_ids(expected_lifetimes); - self.record_lifetime_res( + self.record_lifetime_use( segment_id, LifetimeRes::ElidedAnchor { start: node_ids.start, end: node_ids.end }, LifetimeElisionCandidate::Ignore, @@ -2252,10 +2233,10 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { // Do not create a parameter for patterns and expressions: type checking can infer // the appropriate lifetime for us. for id in node_ids { - self.record_lifetime_res( + self.record_lifetime_use( id, LifetimeRes::Infer, - LifetimeElisionCandidate::Named, + LifetimeElisionCandidate::Ignore, ); } continue; @@ -2311,11 +2292,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { should_lint = false; for id in node_ids { - self.record_lifetime_res( - id, - LifetimeRes::Error(guar), - LifetimeElisionCandidate::Named, - ); + self.record_lifetime_err(id, guar); } break; } @@ -2325,10 +2302,10 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { let mut candidate = LifetimeElisionCandidate::Missing(missing_lifetime); for id in node_ids { let res = self.create_fresh_lifetime(ident, binder, kind); - self.record_lifetime_res( + self.record_lifetime_use( id, res, - replace(&mut candidate, LifetimeElisionCandidate::Named), + replace(&mut candidate, LifetimeElisionCandidate::Ignore), ); } break; @@ -2336,7 +2313,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { LifetimeRibKind::Elided(res) => { let mut candidate = LifetimeElisionCandidate::Missing(missing_lifetime); for id in node_ids { - self.record_lifetime_res( + self.record_lifetime_use( id, res, replace(&mut candidate, LifetimeElisionCandidate::Ignore), @@ -2345,11 +2322,9 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { break; } LifetimeRibKind::ElisionFailure => { - self.diag_metadata.current_elision_failures.push(( - missing_lifetime, - LifetimeElisionCandidate::Ignore, - Either::Right(node_ids), - )); + self.diag_metadata + .current_elision_failures + .push((missing_lifetime, Either::Right(node_ids))); break; } // `LifetimeRes::Error`, which would usually be used in the case of @@ -2360,11 +2335,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { let guar = self.report_missing_lifetime_specifiers([&missing_lifetime], None); for id in node_ids { - self.record_lifetime_res( - id, - LifetimeRes::Error(guar), - LifetimeElisionCandidate::Ignore, - ); + self.record_lifetime_err(id, guar); } break; } @@ -2405,16 +2376,15 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } } + /// Register a use of an already defined lifetime. #[instrument(level = "debug", skip(self))] - fn record_lifetime_res( + fn record_lifetime_use( &mut self, id: NodeId, res: LifetimeRes, candidate: LifetimeElisionCandidate, ) { - if let Some(prev_res) = self.r.lifetimes_res_map.insert(id, res) { - panic!("lifetime {id:?} resolved multiple times ({prev_res:?} before, {res:?} now)") - } + self.record_lifetime_def(id, res); match res { LifetimeRes::Param { .. } | LifetimeRes::Fresh { .. } | LifetimeRes::Static { .. } => { @@ -2426,8 +2396,16 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } } + /// Can be used for both definitions and uses of lifetimes, as an error + /// has already been reported. #[instrument(level = "debug", skip(self))] - fn record_lifetime_param(&mut self, id: NodeId, res: LifetimeRes) { + fn record_lifetime_err(&mut self, id: NodeId, guar: ErrorGuaranteed) { + self.record_lifetime_def(id, LifetimeRes::Error(guar)); + } + + /// Define a new lifetime (e.g. in generics) + #[instrument(level = "debug", skip(self))] + fn record_lifetime_def(&mut self, id: NodeId, res: LifetimeRes) { if let Some(prev_res) = self.r.lifetimes_res_map.insert(id, res) { panic!( "lifetime parameter {id:?} resolved multiple times ({prev_res:?} before, {res:?} now)" @@ -2470,15 +2448,13 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { elision_failures.iter().map(|(missing_lifetime, ..)| missing_lifetime), Some(failure_info), ); - let mut record_res = |lifetime, candidate| { - this.record_lifetime_res(lifetime, LifetimeRes::Error(guar), candidate) - }; - for (_, candidate, nodes) in elision_failures { + let mut record_res = |lifetime| this.record_lifetime_err(lifetime, guar); + for (_, nodes) in elision_failures { match nodes { - Either::Left(node_id) => record_res(node_id, candidate), + Either::Left(node_id) => record_res(node_id), Either::Right(node_ids) => { for lifetime in node_ids { - record_res(lifetime, candidate) + record_res(lifetime) } } } @@ -2553,9 +2529,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { }); all_candidates.extend(candidates.into_iter().filter_map(|(_, candidate)| { match candidate { - LifetimeElisionCandidate::Ignore | LifetimeElisionCandidate::Named => { - None - } + LifetimeElisionCandidate::Ignore => None, LifetimeElisionCandidate::Missing(missing) => Some(missing), } })); @@ -3146,7 +3120,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { param.ident, ); // Record lifetime res, so lowering knows there is something fishy. - self.record_lifetime_param(param.id, LifetimeRes::Error(guar)); + self.record_lifetime_err(param.id, guar); continue; } @@ -3158,7 +3132,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { let rib = match param.kind { GenericParamKind::Lifetime => { // Record lifetime res, so lowering knows there is something fishy. - self.record_lifetime_param(param.id, LifetimeRes::Error(guar)); + self.record_lifetime_err(param.id, guar); continue; } GenericParamKind::Type { .. } => &mut function_type_rib, @@ -3193,7 +3167,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { .create_err(errors::UnderscoreLifetimeIsReserved { span: param.ident.span }) .emit_unless_delay(is_raw_underscore_lifetime); // Record lifetime res, so lowering knows there is something fishy. - self.record_lifetime_param(param.id, LifetimeRes::Error(guar)); + self.record_lifetime_err(param.id, guar); continue; } @@ -3203,7 +3177,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { lifetime: param.ident, }); // Record lifetime res, so lowering knows there is something fishy. - self.record_lifetime_param(param.id, LifetimeRes::Error(guar)); + self.record_lifetime_err(param.id, guar); continue; } @@ -3217,7 +3191,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } GenericParamKind::Lifetime => { let res = LifetimeRes::Param { param: def_id, binder }; - self.record_lifetime_param(param.id, res); + self.record_lifetime_def(param.id, res); function_lifetime_rib.bindings.insert(ident, (param.id, res)); continue; } @@ -3923,12 +3897,24 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { this.visit_path(&delegation.path); }); - self.r.delegation_infos.insert( - self.r.current_owner.def_id, - DelegationInfo { - resolution_node: if is_in_trait_impl { item_id } else { delegation.id }, - }, - ); + let resolution_id = if is_in_trait_impl { item_id } else { delegation.id }; + let def_id = self + .r + .partial_res_map + .get(&resolution_id) + .and_then(|r| r.expect_full_res().opt_def_id()); + if let Some(resolution_id) = def_id { + self.r + .delegation_infos + .insert(self.r.current_owner.def_id, DelegationInfo { resolution_id }); + } else { + self.r.tcx.dcx().span_delayed_bug( + delegation.path.span, + format!( + "LoweringContext: couldn't resolve node {resolution_id:?} in delegation item", + ), + ); + }; let Some(body) = &delegation.body else { return }; self.with_rib(ValueNS, RibKind::FnOrCoroutine, |this| { @@ -4780,8 +4766,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { // it needs to be added to the trait map. if ns == ValueNS { let item_name = path.last().unwrap().ident; - let traits = self.traits_in_scope(item_name, ns); - self.r.trait_map.insert(node_id, traits); + self.record_traits_in_scope(node_id, item_name); } if PrimTy::from_name(path[0].ident.name).is_some() { @@ -5382,13 +5367,11 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { // we need to add any trait methods we find that match the // field name so that we can do some nice error reporting // later on in typeck. - let traits = self.traits_in_scope(ident, ValueNS); - self.r.trait_map.insert(expr.id, traits); + self.record_traits_in_scope(expr.id, ident); } ExprKind::MethodCall(ref call) => { debug!("(recording candidate traits for expr) recording traits for {}", expr.id); - let traits = self.traits_in_scope(call.seg.ident, ValueNS); - self.r.trait_map.insert(expr.id, traits); + self.record_traits_in_scope(expr.id, call.seg.ident); } _ => { // Nothing to do. @@ -5396,13 +5379,14 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } } - fn traits_in_scope(&mut self, ident: Ident, ns: Namespace) -> &'tcx [TraitCandidate<'tcx>] { - self.r.traits_in_scope( + fn record_traits_in_scope(&mut self, node_id: NodeId, ident: Ident) { + let traits = self.r.traits_in_scope( self.current_trait_ref.as_ref().map(|(module, _)| *module), &self.parent_scope, ident.span, - Some((ident.name, ns)), - ) + Some((ident.name, ValueNS)), + ); + self.r.trait_map.insert(node_id, traits); } fn resolve_and_cache_rustdoc_path(&mut self, path_str: &str, ns: Namespace) -> Option { diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 419a47b126980..423c13ff87d37 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -149,10 +149,8 @@ pub(super) struct ElisionFnParameter { /// This is used to suggest introducing an explicit lifetime. #[derive(Clone, Copy, Debug)] pub(super) enum LifetimeElisionCandidate { - /// This is not a real lifetime. + /// This is not a real lifetime, or it is a named lifetime, in which case we won't suggest anything. Ignore, - /// There is a named lifetime, we won't suggest anything. - Named, Missing(MissingLifetime), } diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index f5f4c9e6e2580..0889a29571292 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -58,7 +58,7 @@ use rustc_hir::def::{ }; use rustc_hir::def_id::{CRATE_DEF_ID, CrateNum, DefId, LOCAL_CRATE, LocalDefId, LocalDefIdMap}; use rustc_hir::definitions::{PerParentDisambiguatorState, PerParentDisambiguatorsMap}; -use rustc_hir::{PrimTy, TraitCandidate, find_attr}; +use rustc_hir::{MissingLifetimeKind, PrimTy, TraitCandidate, find_attr}; use rustc_index::bit_set::DenseBitSet; use rustc_metadata::creader::CStore; use rustc_middle::metadata::{AmbigModChild, ModChild, Reexport}; @@ -822,7 +822,7 @@ impl<'ra> Module<'ra> { } /// This modifies `self` in place. The traits will be stored in `self.traits`. - fn ensure_traits<'tcx>(self, resolver: &impl AsRef>) { + fn ensure_traits<'tcx>(self, resolver: &Resolver<'ra, 'tcx>) { let mut traits = self.traits.borrow_mut(resolver.as_ref()); if traits.is_none() { let mut collected_traits = Vec::new(); @@ -996,10 +996,7 @@ impl<'ra> fmt::Debug for LocalModule<'ra> { #[derive(Clone, Debug)] struct DeclData<'ra> { kind: DeclKind<'ra>, - ambiguity: CmCell>>, - /// Produce a warning instead of an error when reporting ambiguities inside this binding. - /// May apply to indirect ambiguities under imports, so `ambiguity.is_some()` is not required. - warn_ambiguity: CmCell, + ambiguity: CmCell, bool /*warning*/)>>, expansion: LocalExpnId, span: Span, initial_vis: Visibility, @@ -1160,7 +1157,7 @@ impl<'ra> DeclData<'ra> { fn descent_to_ambiguity(self: Decl<'ra>) -> Option<(Decl<'ra>, Decl<'ra>)> { match self.ambiguity.get() { - Some(ambig_binding) => Some((self, ambig_binding)), + Some((ambig_binding, _)) => Some((self, ambig_binding)), None => match self.kind { DeclKind::Import { source_decl, .. } => source_decl.descent_to_ambiguity(), _ => None, @@ -1176,14 +1173,6 @@ impl<'ra> DeclData<'ra> { } } - fn warn_ambiguity_recursive(&self) -> bool { - self.warn_ambiguity.get() - || match self.kind { - DeclKind::Import { source_decl, .. } => source_decl.warn_ambiguity_recursive(), - _ => false, - } - } - fn is_possibly_imported_variant(&self) -> bool { match self.kind { DeclKind::Import { source_decl, .. } => source_decl.is_possibly_imported_variant(), @@ -1385,7 +1374,7 @@ pub struct Resolver<'ra, 'tcx> { /// Resolutions for lifetimes. lifetimes_res_map: NodeMap = Default::default(), /// Lifetime parameters that lowering will have to introduce. - extra_lifetime_params_map: NodeMap> = Default::default(), + extra_lifetime_params_map: NodeMap> = Default::default(), /// `CrateNum` resolutions of `extern crate` items. extern_crate_map: UnordMap = Default::default(), @@ -1595,7 +1584,6 @@ impl<'ra> ResolverArenas<'ra> { self.alloc_decl(DeclData { kind: DeclKind::Def(res), ambiguity: CmCell::new(None), - warn_ambiguity: CmCell::new(false), initial_vis: vis, ambiguity_vis_max: CmCell::new(None), ambiguity_vis_min: CmCell::new(None), @@ -2261,17 +2249,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } fn record_use(&mut self, ident: Ident, used_decl: Decl<'ra>, used: Used) { - self.record_use_inner(ident, used_decl, used, used_decl.warn_ambiguity.get()); - } - - fn record_use_inner( - &mut self, - ident: Ident, - used_decl: Decl<'ra>, - used: Used, - warn_ambiguity: bool, - ) { - if let Some(b2) = used_decl.ambiguity.get() { + if let Some((b2, warning)) = used_decl.ambiguity.get() { let ambiguity_error = AmbiguityError { kind: AmbiguityKind::GlobVsGlob, ambig_vis: None, @@ -2280,7 +2258,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { b2, scope1: Scope::ModuleGlobs(used_decl.parent_module.unwrap(), None), scope2: Scope::ModuleGlobs(b2.parent_module.unwrap(), None), - warning: if warn_ambiguity { Some(AmbiguityWarning::GlobImport) } else { None }, + warning: if warning { Some(AmbiguityWarning::GlobImport) } else { None }, }; if !self.matches_previous_ambiguity_error(&ambiguity_error) { // avoid duplicated span information to be emit out @@ -2330,12 +2308,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { self.used_imports.insert(id); } self.add_to_glob_map(import, ident.name); - self.record_use_inner( - ident, - source_decl, - Used::Other, - warn_ambiguity || source_decl.warn_ambiguity.get(), - ); + self.record_use(ident, source_decl, Used::Other); } } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index ba8ab39ede8cd..68e29369e1f64 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -600,6 +600,7 @@ symbols! { cfi, cfi_encoding, char, + clflushopt_target_feature, client, clippy, clobber_abi, diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index d6a9e27c46553..ea6abe5491262 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -132,8 +132,6 @@ pub enum LinkerFlavor { // Below: other linker-like tools with unique interfaces for exotic targets. /// Linker tool for BPF. Bpf, - /// Linker tool for Nvidia PTX. - Ptx, /// LLVM bitcode linker that can be used as a `self-contained` linker Llbc, } @@ -153,7 +151,6 @@ pub enum LinkerFlavorCli { Msvc(Lld), EmCc, Bpf, - Ptx, Llbc, // Legacy stable values @@ -174,8 +171,7 @@ impl LinkerFlavorCli { | LinkerFlavorCli::Msvc(Lld::Yes) | LinkerFlavorCli::EmCc | LinkerFlavorCli::Bpf - | LinkerFlavorCli::Llbc - | LinkerFlavorCli::Ptx => true, + | LinkerFlavorCli::Llbc => true, LinkerFlavorCli::Gcc | LinkerFlavorCli::Ld | LinkerFlavorCli::Lld(..) @@ -211,7 +207,6 @@ impl LinkerFlavor { LinkerFlavorCli::EmCc => LinkerFlavor::EmCc, LinkerFlavorCli::Bpf => LinkerFlavor::Bpf, LinkerFlavorCli::Llbc => LinkerFlavor::Llbc, - LinkerFlavorCli::Ptx => LinkerFlavor::Ptx, // Below: legacy stable values LinkerFlavorCli::Gcc => match lld_flavor { @@ -251,7 +246,6 @@ impl LinkerFlavor { LinkerFlavor::EmCc => LinkerFlavorCli::Em, LinkerFlavor::Bpf => LinkerFlavorCli::Bpf, LinkerFlavor::Llbc => LinkerFlavorCli::Llbc, - LinkerFlavor::Ptx => LinkerFlavorCli::Ptx, } } @@ -266,7 +260,6 @@ impl LinkerFlavor { LinkerFlavor::EmCc => LinkerFlavorCli::EmCc, LinkerFlavor::Bpf => LinkerFlavorCli::Bpf, LinkerFlavor::Llbc => LinkerFlavorCli::Llbc, - LinkerFlavor::Ptx => LinkerFlavorCli::Ptx, } } @@ -279,7 +272,7 @@ impl LinkerFlavor { LinkerFlavorCli::Unix(cc) => (Some(cc), None), LinkerFlavorCli::Msvc(lld) => (Some(Cc::No), Some(lld)), LinkerFlavorCli::EmCc => (Some(Cc::Yes), Some(Lld::Yes)), - LinkerFlavorCli::Bpf | LinkerFlavorCli::Ptx => (None, None), + LinkerFlavorCli::Bpf => (None, None), LinkerFlavorCli::Llbc => (None, None), // Below: legacy stable values @@ -336,7 +329,7 @@ impl LinkerFlavor { LinkerFlavor::WasmLld(cc) => LinkerFlavor::WasmLld(cc_hint.unwrap_or(cc)), LinkerFlavor::Unix(cc) => LinkerFlavor::Unix(cc_hint.unwrap_or(cc)), LinkerFlavor::Msvc(lld) => LinkerFlavor::Msvc(lld_hint.unwrap_or(lld)), - LinkerFlavor::EmCc | LinkerFlavor::Bpf | LinkerFlavor::Llbc | LinkerFlavor::Ptx => self, + LinkerFlavor::EmCc | LinkerFlavor::Bpf | LinkerFlavor::Llbc => self, } } @@ -355,7 +348,7 @@ impl LinkerFlavor { let compatible = |cli| { // The CLI flavor should be compatible with the target if: match (self, cli) { - // 1. they are counterparts: they have the same principal flavor. + // they are counterparts: they have the same principal flavor. (LinkerFlavor::Gnu(..), LinkerFlavorCli::Gnu(..)) | (LinkerFlavor::Darwin(..), LinkerFlavorCli::Darwin(..)) | (LinkerFlavor::WasmLld(..), LinkerFlavorCli::WasmLld(..)) @@ -363,10 +356,7 @@ impl LinkerFlavor { | (LinkerFlavor::Msvc(..), LinkerFlavorCli::Msvc(..)) | (LinkerFlavor::EmCc, LinkerFlavorCli::EmCc) | (LinkerFlavor::Bpf, LinkerFlavorCli::Bpf) - | (LinkerFlavor::Llbc, LinkerFlavorCli::Llbc) - | (LinkerFlavor::Ptx, LinkerFlavorCli::Ptx) => return true, - // 2. The linker flavor is independent of target and compatible - (LinkerFlavor::Ptx, LinkerFlavorCli::Llbc) => return true, + | (LinkerFlavor::Llbc, LinkerFlavorCli::Llbc) => return true, _ => {} } @@ -389,8 +379,7 @@ impl LinkerFlavor { | LinkerFlavor::Unix(..) | LinkerFlavor::EmCc | LinkerFlavor::Bpf - | LinkerFlavor::Llbc - | LinkerFlavor::Ptx => LldFlavor::Ld, + | LinkerFlavor::Llbc => LldFlavor::Ld, LinkerFlavor::Darwin(..) => LldFlavor::Ld64, LinkerFlavor::WasmLld(..) => LldFlavor::Wasm, LinkerFlavor::Msvc(..) => LldFlavor::Link, @@ -415,8 +404,7 @@ impl LinkerFlavor { | LinkerFlavor::Msvc(_) | LinkerFlavor::Unix(_) | LinkerFlavor::Bpf - | LinkerFlavor::Llbc - | LinkerFlavor::Ptx => false, + | LinkerFlavor::Llbc => false, } } @@ -435,8 +423,7 @@ impl LinkerFlavor { | LinkerFlavor::Msvc(_) | LinkerFlavor::Unix(_) | LinkerFlavor::Bpf - | LinkerFlavor::Llbc - | LinkerFlavor::Ptx => false, + | LinkerFlavor::Llbc => false, } } @@ -512,7 +499,6 @@ linker_flavor_cli_impls! { (LinkerFlavorCli::EmCc) "em-cc" (LinkerFlavorCli::Bpf) "bpf" (LinkerFlavorCli::Llbc) "llbc" - (LinkerFlavorCli::Ptx) "ptx" // Legacy stable flavors (LinkerFlavorCli::Gcc) "gcc" @@ -2740,8 +2726,7 @@ fn add_link_args_iter( | LinkerFlavor::Unix(..) | LinkerFlavor::EmCc | LinkerFlavor::Bpf - | LinkerFlavor::Llbc - | LinkerFlavor::Ptx => {} + | LinkerFlavor::Llbc => {} } } @@ -3127,10 +3112,7 @@ impl Target { "mixing MSVC and non-MSVC linker flavors" ); } - LinkerFlavor::EmCc - | LinkerFlavor::Bpf - | LinkerFlavor::Ptx - | LinkerFlavor::Llbc => { + LinkerFlavor::EmCc | LinkerFlavor::Bpf | LinkerFlavor::Llbc => { check_eq!(flavor, self.linker_flavor, "mixing different linker flavors") } } @@ -3582,6 +3564,19 @@ impl Target { "invalid `target_abi` for CSky" ); } + Arch::Wasm32 | Arch::Wasm64 => { + check!( + self.llvm_abiname == LlvmAbi::Unspecified, + "`llvm_abiname` is unused on wasm" + ); + check!(self.llvm_floatabi.is_none(), "`llvm_floatabi` is unused on wasm"); + check!(self.rustc_abi.is_none(), "`rustc_abi` is unused on wasm"); + check_matches!( + self.cfg_abi, + CfgAbi::Unspecified | CfgAbi::Other(_), + "invalid `target_abi` for wasm" + ); + } ref arch => { check!(self.rustc_abi.is_none(), "`rustc_abi` is unused on {arch}"); // Ensure consistency among built-in targets, but give JSON targets the opportunity diff --git a/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs b/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs index d8a0bd50ee204..b74aca48bb9ec 100644 --- a/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs +++ b/compiler/rustc_target/src/spec/targets/nvptx64_nvidia_cuda.rs @@ -21,7 +21,6 @@ pub(crate) fn target() -> Target { vendor: "nvidia".into(), linker_flavor: LinkerFlavor::Llbc, - // With `ptx-linker` approach, it can be later overridden via link flags. cpu: "sm_70".into(), // No longer supported architectures diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index b009c42eb2302..80f29511ebb8e 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -464,6 +464,7 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ ("avxvnniint16", Stable, &["avx2"]), ("bmi1", Stable, &[]), ("bmi2", Stable, &[]), + ("clflushopt", Unstable(sym::clflushopt_target_feature), &[]), ("cmpxchg16b", Stable, &[]), ("ermsb", Unstable(sym::ermsb_target_feature), &[]), ("f16c", Stable, &["avx"]), @@ -1312,11 +1313,17 @@ impl Target { } } Arch::Avr => { + // We only support one ABI on AVR at the moment. // SRAM is minimum requirement for C/C++ in both avr-gcc and Clang, // and backends of them only support assembly for devices have no SRAM. // See the discussion in https://github.com/rust-lang/rust/pull/146900 for more. FeatureConstraints { required: &["sram"], incompatible: &[] } } + Arch::Wasm32 | Arch::Wasm64 => { + // We only support one ABI on wasm at the moment. + // No ABI-relevant target features have been identified thus far. + NOTHING + } _ => NOTHING, } } diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index 05edd8a208f29..78d7314c58110 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -3569,6 +3569,7 @@ pub const fn offload( f: F, workgroup_dim: [u32; 3], thread_dim: [u32; 3], + dyn_cache: u32, args: T, ) -> R; diff --git a/library/proc_macro/src/bridge/client.rs b/library/proc_macro/src/bridge/client.rs index 696cd4ee3d887..3d8ad719f7176 100644 --- a/library/proc_macro/src/bridge/client.rs +++ b/library/proc_macro/src/bridge/client.rs @@ -2,19 +2,9 @@ use std::cell::RefCell; use std::marker::PhantomData; -use std::sync::atomic::AtomicU32; use super::*; -#[repr(C)] -pub(super) struct HandleCounters { - pub(super) token_stream: AtomicU32, - pub(super) span: AtomicU32, -} - -static COUNTERS: HandleCounters = - HandleCounters { token_stream: AtomicU32::new(1), span: AtomicU32::new(1) }; - pub(crate) struct TokenStream { handle: handle::Handle, } @@ -47,6 +37,18 @@ impl Decode<'_, '_, S> for TokenStream { } } +impl Encode<()> for crate::TokenStream { + fn encode(self, w: &mut Buffer, s: &mut ()) { + self.0.encode(w, s) + } +} + +impl Decode<'_, '_, ()> for crate::TokenStream { + fn decode(r: &mut &[u8], s: &mut ()) -> Self { + crate::TokenStream(Some(Decode::decode(r, s))) + } +} + #[derive(Copy, Clone, PartialEq, Eq, Hash)] pub(crate) struct Span { handle: handle::Handle, @@ -209,8 +211,6 @@ pub(crate) fn is_available() -> bool { /// and forcing the use of APIs that take/return `S::TokenStream`, server-side. #[repr(C)] pub struct Client { - pub(super) handle_counters: &'static HandleCounters, - pub(super) run: extern "C" fn(BridgeConfig<'_>) -> Buffer, pub(super) _marker: PhantomData O>, @@ -243,14 +243,13 @@ fn maybe_install_panic_hook(force_show_panics: bool) { /// Client-side helper for handling client panics, entering the bridge, /// deserializing input and serializing output. -// FIXME(eddyb) maybe replace `Bridge::enter` with this? -fn run_client Decode<'a, 's, ()>, R: Encode<()>>( +fn run_client Decode<'a, 's, ()>>( config: BridgeConfig<'_>, - f: impl FnOnce(A) -> R, + f: impl FnOnce(A) -> crate::TokenStream, ) -> Buffer { let BridgeConfig { input: mut buf, dispatch, force_show_panics, .. } = config; - panic::catch_unwind(panic::AssertUnwindSafe(|| { + let res = panic::catch_unwind(panic::AssertUnwindSafe(|| { maybe_install_panic_hook(force_show_panics); // Make sure the symbol store is empty before decoding inputs. @@ -267,23 +266,12 @@ fn run_client Decode<'a, 's, ()>, R: Encode<()>>( // Take the `cached_buffer` back out, for the output value. buf = RefCell::into_inner(state).cached_buffer; - // HACK(eddyb) Separate encoding a success value (`Ok(output)`) - // from encoding a panic (`Err(e: PanicMessage)`) to avoid - // having handles outside the `bridge.enter(|| ...)` scope, and - // to catch panics that could happen while encoding the success. - // - // Note that panics should be impossible beyond this point, but - // this is defensively trying to avoid any accidental panicking - // reaching the `extern "C"` (which should `abort` but might not - // at the moment, so this is also potentially preventing UB). - buf.clear(); - Ok::<_, ()>(output).encode(&mut buf, &mut ()); - })) - .map_err(PanicMessage::from) - .unwrap_or_else(|e| { - buf.clear(); - Err::<(), _>(e).encode(&mut buf, &mut ()); - }); + output + })); + + // Serialize response of type `Result`. + buf.clear(); + res.map_err(PanicMessage::from).encode(&mut buf, &mut ()); // Now that a response has been serialized, invalidate all symbols // registered with the interner. @@ -294,9 +282,8 @@ fn run_client Decode<'a, 's, ()>, R: Encode<()>>( impl Client { pub const fn expand1(f: impl Fn(crate::TokenStream) -> crate::TokenStream + Copy) -> Self { Client { - handle_counters: &COUNTERS, run: super::selfless_reify::reify_to_extern_c_fn_hrt_bridge(move |bridge| { - run_client(bridge, |input| f(crate::TokenStream(Some(input))).0) + run_client(bridge, |input| f(input)) }), _marker: PhantomData, } @@ -308,11 +295,8 @@ impl Client<(crate::TokenStream, crate::TokenStream), crate::TokenStream> { f: impl Fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream + Copy, ) -> Self { Client { - handle_counters: &COUNTERS, run: super::selfless_reify::reify_to_extern_c_fn_hrt_bridge(move |bridge| { - run_client(bridge, |(input, input2)| { - f(crate::TokenStream(Some(input)), crate::TokenStream(Some(input2))).0 - }) + run_client(bridge, |(input, input2)| f(input, input2)) }), _marker: PhantomData, } diff --git a/library/proc_macro/src/bridge/rpc.rs b/library/proc_macro/src/bridge/rpc.rs index 2ada18205673e..8804cf8459abf 100644 --- a/library/proc_macro/src/bridge/rpc.rs +++ b/library/proc_macro/src/bridge/rpc.rs @@ -15,20 +15,30 @@ pub(super) trait Decode<'a, 's, S>: Sized { } macro_rules! rpc_encode_decode { - (le $ty:ty) => { + (le $ty:ident $size:literal) => { impl Encode for $ty { fn encode(self, w: &mut Buffer, _: &mut S) { - w.extend_from_array(&self.to_le_bytes()); + const N: usize = size_of::<$ty>(); + + // We can pad with zeros without changing the value because of + // little endian encoding. + let mut bytes = [0; $size]; + bytes[..N].copy_from_slice(&self.to_le_bytes()); + + w.extend_from_array(&bytes); } } impl Decode<'_, '_, S> for $ty { fn decode(r: &mut &[u8], _: &mut S) -> Self { const N: usize = size_of::<$ty>(); + const { + assert!(N <= $size); + } let mut bytes = [0; N]; bytes.copy_from_slice(&r[..N]); - *r = &r[N..]; + *r = &r[$size..]; Self::from_le_bytes(bytes) } @@ -108,8 +118,8 @@ impl Decode<'_, '_, S> for u8 { } } -rpc_encode_decode!(le u32); -rpc_encode_decode!(le usize); +rpc_encode_decode!(le u32 4); +rpc_encode_decode!(le usize 8); impl Encode for bool { fn encode(self, w: &mut Buffer, s: &mut S) { diff --git a/library/proc_macro/src/bridge/server.rs b/library/proc_macro/src/bridge/server.rs index 1151798fccf40..6a739da7641d1 100644 --- a/library/proc_macro/src/bridge/server.rs +++ b/library/proc_macro/src/bridge/server.rs @@ -1,6 +1,7 @@ //! Server-side traits. use std::cell::Cell; +use std::sync::atomic::AtomicU32; use std::sync::mpsc; use super::*; @@ -11,10 +12,13 @@ pub(super) struct HandleStore { } impl HandleStore { - fn new(handle_counters: &'static client::HandleCounters) -> Self { + fn new() -> Self { + static TOKEN_STREAM: AtomicU32 = AtomicU32::new(1); + static SPAN: AtomicU32 = AtomicU32::new(1); + HandleStore { - token_stream: handle::OwnedStore::new(&handle_counters.token_stream), - span: handle::InternedStore::new(&handle_counters.span), + token_stream: handle::OwnedStore::new(&TOKEN_STREAM), + span: handle::InternedStore::new(&SPAN), } } } @@ -246,13 +250,12 @@ fn run_server< O: for<'a, 's> Decode<'a, 's, HandleStore>, >( strategy: &impl ExecutionStrategy, - handle_counters: &'static client::HandleCounters, server: S, input: I, run_client: extern "C" fn(BridgeConfig<'_>) -> Buffer, force_show_panics: bool, ) -> Result { - let mut dispatcher = Dispatcher { handle_store: HandleStore::new(handle_counters), server }; + let mut dispatcher = Dispatcher { handle_store: HandleStore::new(), server }; let globals = dispatcher.server.globals(); @@ -276,16 +279,9 @@ impl client::Client { where S: Server, { - let client::Client { handle_counters, run, _marker } = *self; - run_server( - strategy, - handle_counters, - server, - >::mark(input), - run, - force_show_panics, - ) - .map(|s| >>::unmark(s).unwrap_or_default()) + let client::Client { run, _marker } = *self; + run_server(strategy, server, >::mark(input), run, force_show_panics) + .map(|s| >>::unmark(s).unwrap_or_default()) } } @@ -301,10 +297,9 @@ impl client::Client<(crate::TokenStream, crate::TokenStream), crate::TokenStream where S: Server, { - let client::Client { handle_counters, run, _marker } = *self; + let client::Client { run, _marker } = *self; run_server( strategy, - handle_counters, server, (>::mark(input), >::mark(input2)), run, diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 222bf77996c7f..3ff591b1907d3 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -2854,7 +2854,6 @@ impl Path { /// # Examples /// /// ``` - /// #![feature(path_is_empty)] /// use std::path::Path; /// /// let path = Path::new(""); @@ -2866,7 +2865,7 @@ impl Path { /// let path = Path::new("."); /// assert!(!path.is_empty()); /// ``` - #[unstable(feature = "path_is_empty", issue = "148494")] + #[stable(feature = "path_is_empty", since = "CURRENT_RUSTC_VERSION")] pub fn is_empty(&self) -> bool { self.as_os_str().is_empty() } diff --git a/library/std_detect/src/detect/arch/x86.rs b/library/std_detect/src/detect/arch/x86.rs index 4c3a71ebc5ee7..ede4a80c088ed 100644 --- a/library/std_detect/src/detect/arch/x86.rs +++ b/library/std_detect/src/detect/arch/x86.rs @@ -106,6 +106,7 @@ features! { /// * `"xsaves"` /// * `"xsavec"` /// * `"cmpxchg16b"` + /// * `"clflushopt"` /// * `"kl"` /// * `"widekl"` /// * `"adx"` @@ -261,6 +262,8 @@ features! { /// XSAVEC (Save Processor Extended States Compacted) @FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] cmpxchg16b: "cmpxchg16b"; /// CMPXCH16B (16-byte compare-and-swap instruction) + @FEATURE: #[unstable(feature = "clflushopt_target_feature", issue = "157096")] clflushopt: "clflushopt"; + /// CLFLUSHOPT (Cache Line Flush Optimized) @FEATURE: #[stable(feature = "keylocker_x86", since = "1.89.0")] kl: "kl"; /// Intel Key Locker @FEATURE: #[stable(feature = "keylocker_x86", since = "1.89.0")] widekl: "widekl"; diff --git a/library/std_detect/src/detect/os/x86.rs b/library/std_detect/src/detect/os/x86.rs index b24ef6a37ef55..2b75cd6257087 100644 --- a/library/std_detect/src/detect/os/x86.rs +++ b/library/std_detect/src/detect/os/x86.rs @@ -127,6 +127,8 @@ pub(crate) fn detect_features() -> cache::Initializer { enable(extended_features_ebx, 9, Feature::ermsb); + enable(extended_features_ebx, 23, Feature::clflushopt); + enable(extended_features_eax_leaf_1, 31, Feature::movrs); // Detect if CPUID.19h available diff --git a/library/std_detect/tests/x86-specific.rs b/library/std_detect/tests/x86-specific.rs index 90ca32208e78d..4b02f78b7944e 100644 --- a/library/std_detect/tests/x86-specific.rs +++ b/library/std_detect/tests/x86-specific.rs @@ -1,6 +1,12 @@ #![cfg(any(target_arch = "x86", target_arch = "x86_64"))] #![allow(internal_features)] -#![feature(stdarch_internal, x86_amx_intrinsics, xop_target_feature, movrs_target_feature)] +#![feature( + stdarch_internal, + x86_amx_intrinsics, + xop_target_feature, + movrs_target_feature, + clflushopt_target_feature +)] #[macro_use] extern crate std_detect; @@ -58,6 +64,7 @@ fn dump() { println!("xsaves: {:?}", is_x86_feature_detected!("xsaves")); println!("xsavec: {:?}", is_x86_feature_detected!("xsavec")); println!("cmpxchg16b: {:?}", is_x86_feature_detected!("cmpxchg16b")); + println!("clflushopt: {:?}", is_x86_feature_detected!("clflushopt")); println!("adx: {:?}", is_x86_feature_detected!("adx")); println!("rtm: {:?}", is_x86_feature_detected!("rtm")); println!("movbe: {:?}", is_x86_feature_detected!("movbe")); diff --git a/src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md b/src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md index ec16c181fe127..af9d13454afeb 100644 --- a/src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md +++ b/src/doc/rustc/src/platform-support/x86_64-unknown-linux-none.md @@ -6,7 +6,7 @@ Freestanding x86-64 linux binary with no dependency on libc. ## Target maintainers -[@morr0ne](https://github.com/morr0ne) +[@rosymati](https://github.com/rosymati) ## Requirements diff --git a/src/doc/unstable-book/src/compiler-flags/codegen-options.md b/src/doc/unstable-book/src/compiler-flags/codegen-options.md index f927e5c439c66..efde41040184a 100644 --- a/src/doc/unstable-book/src/compiler-flags/codegen-options.md +++ b/src/doc/unstable-book/src/compiler-flags/codegen-options.md @@ -7,8 +7,6 @@ unstable-options` to be accepted. ## linker-flavor In addition to the stable set of linker flavors, the following unstable values also exist: -- `ptx`: use [`rust-ptx-linker`](https://github.com/denzp/rust-ptx-linker) - for Nvidia NVPTX GPGPU support. - `bpf`: use [`bpf-linker`](https://github.com/alessandrod/bpf-linker) for eBPF support. - `llbc`: for linking in llvm bitcode. Install the preview rustup components`llvm-bitcode-linker` and `llvm-tools` to use as a self-contained linker by passing diff --git a/src/tools/compiletest/src/runtest/assembly.rs b/src/tools/compiletest/src/runtest/assembly.rs index 0d41c29075c43..be2430f006a54 100644 --- a/src/tools/compiletest/src/runtest/assembly.rs +++ b/src/tools/compiletest/src/runtest/assembly.rs @@ -23,7 +23,7 @@ impl TestCx<'_> { fn compile_test_and_save_assembly(&self) -> (ProcRes, Utf8PathBuf) { // This works with both `--emit asm` (as default output name for the assembly) - // and `ptx-linker` because the latter can write output at requested location. + // and `llvm-bitcode-linker` because the latter can write output at requested location. let output_path = self.output_base_name().with_extension("s"); let input_file = &self.testpaths.file; @@ -31,7 +31,6 @@ impl TestCx<'_> { let emit = match self.props.assembly_output.as_deref() { Some("emit-asm") => Emit::Asm, Some("bpf-linker") => Emit::LinkArgsAsm, - Some("ptx-linker") => Emit::None, // No extra flags needed. Some(other) => self.fatal(&format!("unknown 'assembly-output' directive: {other}")), None => self.fatal("missing 'assembly-output' directive"), }; diff --git a/tests/assembly-llvm/nvptx-arch-default.rs b/tests/assembly-llvm/nvptx-arch-default.rs index e71304e453303..a0c2b5387275d 100644 --- a/tests/assembly-llvm/nvptx-arch-default.rs +++ b/tests/assembly-llvm/nvptx-arch-default.rs @@ -1,4 +1,4 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type cdylib //@ only-nvptx64 @@ -7,7 +7,7 @@ //@ aux-build: breakpoint-panic-handler.rs extern crate breakpoint_panic_handler; -// Verify default target arch with ptx-linker. +// Verify default arch with llvm-bitcode-linker. // CHECK: .version 7.0 // CHECK: .target sm_70 // CHECK: .address_size 64 diff --git a/tests/assembly-llvm/nvptx-arch-emit-asm.rs b/tests/assembly-llvm/nvptx-arch-emit-asm.rs index 9266309c6202e..135149679a4d1 100644 --- a/tests/assembly-llvm/nvptx-arch-emit-asm.rs +++ b/tests/assembly-llvm/nvptx-arch-emit-asm.rs @@ -4,7 +4,7 @@ #![no_std] -// Verify default arch without ptx-linker involved. +// Verify default arch without llvm-bitcode-linker involved. // CHECK: .version 7.0 // CHECK: .target sm_70 // CHECK: .address_size 64 diff --git a/tests/assembly-llvm/nvptx-arch-link-arg.rs b/tests/assembly-llvm/nvptx-arch-link-arg.rs deleted file mode 100644 index 3432e6161bf14..0000000000000 --- a/tests/assembly-llvm/nvptx-arch-link-arg.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ assembly-output: ptx-linker -//@ compile-flags: --crate-type cdylib -C link-arg=--arch=sm_60 -//@ only-nvptx64 -//@ ignore-nvptx64 - -#![no_std] - -//@ aux-build: breakpoint-panic-handler.rs -extern crate breakpoint_panic_handler; - -// Verify target arch override via `link-arg`. -// CHECK: .target sm_60 -// CHECK: .address_size 64 diff --git a/tests/assembly-llvm/nvptx-arch-target-cpu.rs b/tests/assembly-llvm/nvptx-arch-target-cpu.rs index b5062f1ba20d7..8e1ef9b13fa40 100644 --- a/tests/assembly-llvm/nvptx-arch-target-cpu.rs +++ b/tests/assembly-llvm/nvptx-arch-target-cpu.rs @@ -1,4 +1,4 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type cdylib -C target-cpu=sm_87 //@ only-nvptx64 diff --git a/tests/assembly-llvm/nvptx-atomics.rs b/tests/assembly-llvm/nvptx-atomics.rs index 52b8c86d8a9c1..5895a731167c6 100644 --- a/tests/assembly-llvm/nvptx-atomics.rs +++ b/tests/assembly-llvm/nvptx-atomics.rs @@ -1,4 +1,4 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type cdylib //@ only-nvptx64 //@ ignore-nvptx64 diff --git a/tests/assembly-llvm/nvptx-c-abi-arg-v7.rs b/tests/assembly-llvm/nvptx-c-abi-arg-v7.rs index 6f5ef792e9b34..2f27988ba3743 100644 --- a/tests/assembly-llvm/nvptx-c-abi-arg-v7.rs +++ b/tests/assembly-llvm/nvptx-c-abi-arg-v7.rs @@ -1,4 +1,4 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type cdylib -C target-cpu=sm_86 //@ only-nvptx64 diff --git a/tests/assembly-llvm/nvptx-c-abi-ret-v7.rs b/tests/assembly-llvm/nvptx-c-abi-ret-v7.rs index 02ec9facee7a8..e7db3108952b1 100644 --- a/tests/assembly-llvm/nvptx-c-abi-ret-v7.rs +++ b/tests/assembly-llvm/nvptx-c-abi-ret-v7.rs @@ -1,4 +1,4 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type cdylib -C target-cpu=sm_86 //@ only-nvptx64 diff --git a/tests/assembly-llvm/nvptx-internalizing.rs b/tests/assembly-llvm/nvptx-internalizing.rs index 0acfd5c244319..b671c876e23a2 100644 --- a/tests/assembly-llvm/nvptx-internalizing.rs +++ b/tests/assembly-llvm/nvptx-internalizing.rs @@ -1,7 +1,6 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type cdylib //@ only-nvptx64 -//@ ignore-nvptx64 #![feature(abi_ptx)] #![no_std] diff --git a/tests/assembly-llvm/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs b/tests/assembly-llvm/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs index 00f6fe9332d94..cb88cfd33ee58 100644 --- a/tests/assembly-llvm/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs +++ b/tests/assembly-llvm/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs @@ -1,4 +1,4 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type cdylib -C target-cpu=sm_86 //@ only-nvptx64 diff --git a/tests/assembly-llvm/nvptx-linking-binary.rs b/tests/assembly-llvm/nvptx-linking-binary.rs index 3b50b472ab10e..4ec9c4a0af0bf 100644 --- a/tests/assembly-llvm/nvptx-linking-binary.rs +++ b/tests/assembly-llvm/nvptx-linking-binary.rs @@ -1,4 +1,4 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type bin //@ only-nvptx64 //@ ignore-nvptx64 diff --git a/tests/assembly-llvm/nvptx-linking-cdylib.rs b/tests/assembly-llvm/nvptx-linking-cdylib.rs index 9742e26fb31a9..82bca1f6c1699 100644 --- a/tests/assembly-llvm/nvptx-linking-cdylib.rs +++ b/tests/assembly-llvm/nvptx-linking-cdylib.rs @@ -1,4 +1,4 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type cdylib //@ only-nvptx64 //@ ignore-nvptx64 diff --git a/tests/assembly-llvm/nvptx-safe-naming.rs b/tests/assembly-llvm/nvptx-safe-naming.rs index 050c3fb9d93b6..69bf71b9a7821 100644 --- a/tests/assembly-llvm/nvptx-safe-naming.rs +++ b/tests/assembly-llvm/nvptx-safe-naming.rs @@ -1,4 +1,4 @@ -//@ assembly-output: ptx-linker +//@ assembly-output: emit-asm //@ compile-flags: --crate-type cdylib //@ only-nvptx64 diff --git a/tests/codegen-llvm/gpu_offload/control_flow.rs b/tests/codegen-llvm/gpu_offload/control_flow.rs index 503e9e4221cdc..605a6f08843c3 100644 --- a/tests/codegen-llvm/gpu_offload/control_flow.rs +++ b/tests/codegen-llvm/gpu_offload/control_flow.rs @@ -19,7 +19,7 @@ // CHECK-NOT define // CHECK: bb3 // CHECK: call void @__tgt_target_data_begin_mapper(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 1, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull @.offload_sizes.foo, ptr nonnull @.offload_maptypes.foo.begin, ptr null, ptr null) -// CHECK: %10 = call i32 @__tgt_target_kernel(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 256, i32 32, ptr nonnull @.foo.region_id, ptr nonnull %kernel_args) +// CHECK: = call i32 @__tgt_target_kernel(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 256, i32 32, ptr nonnull @.foo.region_id, ptr nonnull %kernel_args) // CHECK-NEXT: call void @__tgt_target_data_end_mapper(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 1, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull @.offload_sizes.foo, ptr nonnull @.offload_maptypes.foo.end, ptr null, ptr null) #[unsafe(no_mangle)] unsafe fn main() { @@ -30,6 +30,7 @@ unsafe fn main() { foo, [256, 1, 1], [32, 1, 1], + 0, (A.as_ptr() as *const [f32; 6],), ); } diff --git a/tests/codegen-llvm/gpu_offload/gpu_host.rs b/tests/codegen-llvm/gpu_offload/gpu_host.rs index 8179d868da95f..2bfaf89b45590 100644 --- a/tests/codegen-llvm/gpu_offload/gpu_host.rs +++ b/tests/codegen-llvm/gpu_offload/gpu_host.rs @@ -21,7 +21,7 @@ fn main() { } pub fn kernel_1(x: &mut [f32; 256], y: &[f32; 256]) { - core::intrinsics::offload(_kernel_1, [256, 1, 1], [32, 1, 1], (x, y)) + core::intrinsics::offload(_kernel_1, [256, 1, 1], [32, 1, 1], 0, (x, y)) } #[inline(never)] @@ -52,8 +52,8 @@ pub fn _kernel_1(x: &mut [f32; 256], y: &[f32; 256]) { // CHECK-LABEL: define{{( dso_local)?}} void @main() // CHECK-NEXT: start: -// CHECK-NEXT: %0 = alloca [8 x i8], align 8 -// CHECK-NEXT: %1 = alloca [8 x i8], align 8 +// CHECK-NEXT: {{%[^ ]+}} = alloca [8 x i8], align 8 +// CHECK-NEXT: {{%[^ ]+}} = alloca [8 x i8], align 8 // CHECK-NEXT: %y = alloca [1024 x i8], align 16 // CHECK-NEXT: %x = alloca [1024 x i8], align 16 // CHECK-NEXT: %.offload_baseptrs = alloca [2 x ptr], align 8 @@ -61,9 +61,9 @@ pub fn _kernel_1(x: &mut [f32; 256], y: &[f32; 256]) { // CHECK-NEXT: %kernel_args = alloca %struct.__tgt_kernel_arguments, align 8 // CHECK: store ptr %x, ptr %.offload_baseptrs, align 8 // CHECK-NEXT: store ptr %x, ptr %.offload_ptrs, align 8 -// CHECK-NEXT: [[BPTRS_1:%.*]] = getelementptr inbounds nuw i8, ptr %.offload_baseptrs, i64 8 +// CHECK-NEXT: [[BPTRS_1:%[^ ]+]] = getelementptr inbounds nuw i8, ptr %.offload_baseptrs, i64 8 // CHECK-NEXT: store ptr %y, ptr [[BPTRS_1]], align 8 -// CHECK-NEXT: [[PTRS_1:%.*]] = getelementptr inbounds nuw i8, ptr %.offload_ptrs, i64 8 +// CHECK-NEXT: [[PTRS_1:%[^ ]+]] = getelementptr inbounds nuw i8, ptr %.offload_ptrs, i64 8 // CHECK-NEXT: store ptr %y, ptr [[PTRS_1]], align 8 // CHECK-NEXT: call void @__tgt_target_data_begin_mapper(ptr nonnull @anon.{{.*}}.1, i64 -1, i32 2, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull @.offload_sizes.[[K]], ptr nonnull @.offload_maptypes.[[K]].begin, ptr null, ptr null) // CHECK-NEXT: store i32 3, ptr %kernel_args, align 8 diff --git a/tests/codegen-llvm/gpu_offload/scalar_host.rs b/tests/codegen-llvm/gpu_offload/scalar_host.rs index d5b40fb0a26db..3470761be06c8 100644 --- a/tests/codegen-llvm/gpu_offload/scalar_host.rs +++ b/tests/codegen-llvm/gpu_offload/scalar_host.rs @@ -13,11 +13,11 @@ // CHECK: define{{( dso_local)?}} void @main() // CHECK-NOT: define // CHECK: %addr = alloca i64, align 8 -// CHECK: store double 4.200000e+01, ptr %0, align 8 -// CHECK: %_0.i = load double, ptr %0, align 8 -// CHECK: store double %_0.i, ptr %addr, align 8 +// CHECK: store double 4.200000e+01, ptr [[TMP:%[^,]+]], align 8 +// CHECK: [[VAL:%[0-9]+]] = load double, ptr [[TMP]], align 8 +// CHECK: store double [[VAL]], ptr %addr, align 8 // CHECK: %1 = getelementptr inbounds nuw i8, ptr %.offload_baseptrs, i64 8 -// CHECK-NEXT: store double %_0.i, ptr %1, align 8 +// CHECK-NEXT: store double [[VAL]], ptr %1, align 8 // CHECK-NEXT: %2 = getelementptr inbounds nuw i8, ptr %.offload_ptrs, i64 8 // CHECK-NEXT: store ptr %addr, ptr %2, align 8 // CHECK-NEXT: call void @__tgt_target_data_begin_mapper @@ -27,7 +27,7 @@ fn main() { let mut x = 0.0; let k = core::hint::black_box(42.0); - core::intrinsics::offload::<_, _, ()>(foo, [1, 1, 1], [1, 1, 1], (&mut x, k)); + core::intrinsics::offload::<_, _, ()>(foo, [1, 1, 1], [1, 1, 1], 0, (&mut x, k)); } unsafe extern "C" { diff --git a/tests/codegen-llvm/gpu_offload/slice_host.rs b/tests/codegen-llvm/gpu_offload/slice_host.rs index 62f12da079d82..d4157d24e03dd 100644 --- a/tests/codegen-llvm/gpu_offload/slice_host.rs +++ b/tests/codegen-llvm/gpu_offload/slice_host.rs @@ -21,13 +21,13 @@ // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr {{.*}} %.offload_sizes, ptr {{.*}} @.offload_sizes.foo, i64 16, i1 false) // CHECK: store i64 16, ptr %.offload_sizes, align 8 // CHECK: call void @__tgt_target_data_begin_mapper(ptr nonnull @anon.[[ID]].1, i64 -1, i32 2, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull %.offload_sizes, ptr nonnull @.offload_maptypes.[[K]].begin, ptr null, ptr null) -// CHECK: %11 = call i32 @__tgt_target_kernel(ptr nonnull @anon.[[ID]].1, i64 -1, i32 1, i32 1, ptr nonnull @.foo.region_id, ptr nonnull %kernel_args) +// CHECK: call i32 @__tgt_target_kernel(ptr nonnull @anon.[[ID]].1, i64 -1, i32 1, i32 1, ptr nonnull @.foo.region_id, ptr nonnull %kernel_args) // CHECK-NEXT: call void @__tgt_target_data_end_mapper(ptr nonnull @anon.[[ID]].1, i64 -1, i32 2, ptr nonnull %.offload_baseptrs, ptr nonnull %.offload_ptrs, ptr nonnull %.offload_sizes, ptr nonnull @.offload_maptypes.[[K]].end, ptr null, ptr null) #[unsafe(no_mangle)] fn main() { let mut x = [0.0, 0.0, 0.0, 0.0]; - core::intrinsics::offload::<_, _, ()>(foo, [1, 1, 1], [1, 1, 1], ((&mut x) as &mut [f64],)); + core::intrinsics::offload::<_, _, ()>(foo, [1, 1, 1], [1, 1, 1], 0, ((&mut x) as &mut [f64],)); } unsafe extern "C" { diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr index 981c173242408..3474228c4fe16 100644 --- a/tests/ui/check-cfg/target_feature.stderr +++ b/tests/ui/check-cfg/target_feature.stderr @@ -65,6 +65,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `bulk-memory` `c` `cache` +`clflushopt` `cmpxchg16b` `concurrent-functions` `crc` diff --git a/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs b/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs index 641066b002273..e5f7ed3a8d774 100644 --- a/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs +++ b/tests/ui/closures/2229_closure_analysis/diagnostics/liveness.rs @@ -1,6 +1,6 @@ //@ edition:2021 - //@ check-pass +//@ ignore-parallel-frontend unstable liveness diagnostics #![allow(unreachable_code)] #![warn(unused)] #![allow(dead_code)] diff --git a/tests/ui/deprecation/deprecation-sanity.rs b/tests/ui/deprecation/deprecation-sanity.rs index d1061dc1e170b..0ad491186cc38 100644 --- a/tests/ui/deprecation/deprecation-sanity.rs +++ b/tests/ui/deprecation/deprecation-sanity.rs @@ -23,6 +23,9 @@ mod bogus_attribute_types_1 { #[deprecated("test")] //~ ERROR malformed `deprecated` attribute input [E0565] fn f8() { } + + #[deprecated("1.2.3")] //~ ERROR malformed `deprecated` attribute input [E0565] + fn f9() { } } #[deprecated(since = "a", note = "b")] diff --git a/tests/ui/deprecation/deprecation-sanity.stderr b/tests/ui/deprecation/deprecation-sanity.stderr index 427d14d89c19f..2e00b2efea5c5 100644 --- a/tests/ui/deprecation/deprecation-sanity.stderr +++ b/tests/ui/deprecation/deprecation-sanity.stderr @@ -55,21 +55,40 @@ LL | #[deprecated("test")] | ^^^^^^^^^^^^^------^^ | | | didn't expect a literal here + | +help: try using `=` instead + | +LL - #[deprecated("test")] +LL + #[deprecated = "test"] + | + +error[E0565]: malformed `deprecated` attribute input + --> $DIR/deprecation-sanity.rs:27:5 + | +LL | #[deprecated("1.2.3")] + | ^^^^^^^^^^^^^-------^^ + | | + | didn't expect a literal here + | +help: try specifying a deprecated since version + | +LL | #[deprecated(since = "1.2.3")] + | +++++++ error: multiple `deprecated` attributes - --> $DIR/deprecation-sanity.rs:29:1 + --> $DIR/deprecation-sanity.rs:32:1 | LL | #[deprecated(since = "a", note = "b")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute | note: attribute also specified here - --> $DIR/deprecation-sanity.rs:28:1 + --> $DIR/deprecation-sanity.rs:31:1 | LL | #[deprecated(since = "a", note = "b")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0538]: malformed `deprecated` attribute input - --> $DIR/deprecation-sanity.rs:32:1 + --> $DIR/deprecation-sanity.rs:35:1 | LL | #[deprecated(since = "a", since = "b", note = "c")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^-----------^^^^^^^^^^^^^^ @@ -77,7 +96,7 @@ LL | #[deprecated(since = "a", since = "b", note = "c")] | found `since` used as a key more than once error: `#[deprecated]` attribute cannot be used on trait impl blocks - --> $DIR/deprecation-sanity.rs:37:1 + --> $DIR/deprecation-sanity.rs:40:1 | LL | #[deprecated = "hello"] | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -86,7 +105,7 @@ LL | #[deprecated = "hello"] = help: `#[deprecated]` can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, and use statements = note: `#[deny(useless_deprecated)]` on by default -error: aborting due to 10 previous errors +error: aborting due to 11 previous errors Some errors have detailed explanations: E0538, E0539, E0565. For more information about an error, try `rustc --explain E0538`. diff --git a/tests/ui/error-codes/E0565-1.stderr b/tests/ui/error-codes/E0565-1.stderr index d1aff042e8fb6..0c500d2cbf231 100644 --- a/tests/ui/error-codes/E0565-1.stderr +++ b/tests/ui/error-codes/E0565-1.stderr @@ -5,6 +5,12 @@ LL | #[deprecated("since")] | ^^^^^^^^^^^^^-------^^ | | | didn't expect a literal here + | +help: try using `=` instead + | +LL - #[deprecated("since")] +LL + #[deprecated = "since"] + | error: aborting due to 1 previous error diff --git a/tests/ui/feature-gates/feature-gate-clflushopt_target_feature.rs b/tests/ui/feature-gates/feature-gate-clflushopt_target_feature.rs new file mode 100644 index 0000000000000..8200efadf98a6 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-clflushopt_target_feature.rs @@ -0,0 +1,6 @@ +//@ only-x86_64 +#[target_feature(enable = "clflushopt")] +//~^ ERROR: currently unstable +unsafe fn foo() {} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-clflushopt_target_feature.stderr b/tests/ui/feature-gates/feature-gate-clflushopt_target_feature.stderr new file mode 100644 index 0000000000000..722bf861b1fed --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-clflushopt_target_feature.stderr @@ -0,0 +1,13 @@ +error[E0658]: the target feature `clflushopt` is currently unstable + --> $DIR/feature-gate-clflushopt_target_feature.rs:2:18 + | +LL | #[target_feature(enable = "clflushopt")] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #157096 for more information + = help: add `#![feature(clflushopt_target_feature)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/imports/ambiguous-1.rs b/tests/ui/imports/ambiguous-1.rs index 31f39eee62b9a..6c8e7da74f967 100644 --- a/tests/ui/imports/ambiguous-1.rs +++ b/tests/ui/imports/ambiguous-1.rs @@ -1,8 +1,5 @@ -//@ check-pass // https://github.com/rust-lang/rust/pull/112743#issuecomment-1601986883 -#![warn(ambiguous_glob_imports)] - macro_rules! m { () => { pub fn id() {} @@ -27,6 +24,5 @@ pub use openssl::*; fn main() { id(); - //~^ WARNING `id` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~^ ERROR `id` is ambiguous } diff --git a/tests/ui/imports/ambiguous-1.stderr b/tests/ui/imports/ambiguous-1.stderr index 603a8938194b1..b891baafe5710 100644 --- a/tests/ui/imports/ambiguous-1.stderr +++ b/tests/ui/imports/ambiguous-1.stderr @@ -1,68 +1,34 @@ -warning: ambiguous glob re-exports - --> $DIR/ambiguous-1.rs:13:13 - | -LL | pub use self::evp::*; - | ^^^^^^^^^^^^ the name `id` in the value namespace is first re-exported here -LL | -LL | pub use self::handwritten::*; - | -------------------- but the name `id` in the value namespace is also re-exported here - | - = note: `#[warn(ambiguous_glob_reexports)]` on by default - -warning: `id` is ambiguous - --> $DIR/ambiguous-1.rs:29:5 +error[E0659]: `id` is ambiguous + --> $DIR/ambiguous-1.rs:26:5 | LL | id(); | ^^ ambiguous name | = note: ambiguous because of multiple glob imports of a name in the same module note: `id` could refer to the function imported here - --> $DIR/ambiguous-1.rs:13:13 + --> $DIR/ambiguous-1.rs:10:13 | LL | pub use self::evp::*; | ^^^^^^^^^^^^ = help: consider adding an explicit import of `id` to disambiguate note: `id` could also refer to the function imported here - --> $DIR/ambiguous-1.rs:15:13 + --> $DIR/ambiguous-1.rs:12:13 | LL | pub use self::handwritten::*; | ^^^^^^^^^^^^^^^^^^^^ = help: consider adding an explicit import of `id` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 -note: the lint level is defined here - --> $DIR/ambiguous-1.rs:4:9 - | -LL | #![warn(ambiguous_glob_imports)] - | ^^^^^^^^^^^^^^^^^^^^^^ - -warning: 2 warnings emitted -Future incompatibility report: Future breakage diagnostic: -warning: `id` is ambiguous - --> $DIR/ambiguous-1.rs:29:5 - | -LL | id(); - | ^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `id` could refer to the function imported here - --> $DIR/ambiguous-1.rs:13:13 +warning: ambiguous glob re-exports + --> $DIR/ambiguous-1.rs:10:13 | LL | pub use self::evp::*; - | ^^^^^^^^^^^^ - = help: consider adding an explicit import of `id` to disambiguate -note: `id` could also refer to the function imported here - --> $DIR/ambiguous-1.rs:15:13 - | + | ^^^^^^^^^^^^ the name `id` in the value namespace is first re-exported here +LL | LL | pub use self::handwritten::*; - | ^^^^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `id` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 -note: the lint level is defined here - --> $DIR/ambiguous-1.rs:4:9 + | -------------------- but the name `id` in the value namespace is also re-exported here | -LL | #![warn(ambiguous_glob_imports)] - | ^^^^^^^^^^^^^^^^^^^^^^ + = note: `#[warn(ambiguous_glob_reexports)]` on by default + +error: aborting due to 1 previous error; 1 warning emitted +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-10.rs b/tests/ui/imports/ambiguous-10.rs index 166b01ede12d3..362633b2cb29c 100644 --- a/tests/ui/imports/ambiguous-10.rs +++ b/tests/ui/imports/ambiguous-10.rs @@ -14,5 +14,4 @@ use crate::a::*; use crate::b::*; fn c(_: Token) {} //~^ ERROR `Token` is ambiguous -//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! fn main() { } diff --git a/tests/ui/imports/ambiguous-10.stderr b/tests/ui/imports/ambiguous-10.stderr index edd787785d9d8..e3f126d338c49 100644 --- a/tests/ui/imports/ambiguous-10.stderr +++ b/tests/ui/imports/ambiguous-10.stderr @@ -1,4 +1,4 @@ -error: `Token` is ambiguous +error[E0659]: `Token` is ambiguous --> $DIR/ambiguous-10.rs:15:9 | LL | fn c(_: Token) {} @@ -17,33 +17,7 @@ note: `Token` could also refer to the enum imported here LL | use crate::b::*; | ^^^^^^^^^^^ = help: consider adding an explicit import of `Token` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error -Future incompatibility report: Future breakage diagnostic: -error: `Token` is ambiguous - --> $DIR/ambiguous-10.rs:15:9 - | -LL | fn c(_: Token) {} - | ^^^^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `Token` could refer to the enum imported here - --> $DIR/ambiguous-10.rs:13:5 - | -LL | use crate::a::*; - | ^^^^^^^^^^^ - = help: consider adding an explicit import of `Token` to disambiguate -note: `Token` could also refer to the enum imported here - --> $DIR/ambiguous-10.rs:14:5 - | -LL | use crate::b::*; - | ^^^^^^^^^^^ - = help: consider adding an explicit import of `Token` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-12.rs b/tests/ui/imports/ambiguous-12.rs index 543396b8dfe5c..54bdf26e88cce 100644 --- a/tests/ui/imports/ambiguous-12.rs +++ b/tests/ui/imports/ambiguous-12.rs @@ -20,5 +20,4 @@ use crate::public::*; fn main() { b(); //~^ ERROR `b` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } diff --git a/tests/ui/imports/ambiguous-12.stderr b/tests/ui/imports/ambiguous-12.stderr index e20eec249965a..099abd66e8a3c 100644 --- a/tests/ui/imports/ambiguous-12.stderr +++ b/tests/ui/imports/ambiguous-12.stderr @@ -1,4 +1,4 @@ -error: `b` is ambiguous +error[E0659]: `b` is ambiguous --> $DIR/ambiguous-12.rs:21:5 | LL | b(); @@ -17,33 +17,7 @@ note: `b` could also refer to the function imported here LL | use crate::public::*; | ^^^^^^^^^^^^^^^^ = help: consider adding an explicit import of `b` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error -Future incompatibility report: Future breakage diagnostic: -error: `b` is ambiguous - --> $DIR/ambiguous-12.rs:21:5 - | -LL | b(); - | ^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `b` could refer to the function imported here - --> $DIR/ambiguous-12.rs:17:5 - | -LL | use crate::ciphertext::*; - | ^^^^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `b` to disambiguate -note: `b` could also refer to the function imported here - --> $DIR/ambiguous-12.rs:18:5 - | -LL | use crate::public::*; - | ^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `b` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-13.rs b/tests/ui/imports/ambiguous-13.rs index 3569dd5d9adc2..7dc617ce48768 100644 --- a/tests/ui/imports/ambiguous-13.rs +++ b/tests/ui/imports/ambiguous-13.rs @@ -17,5 +17,4 @@ use crate::content::*; fn a(_: Rect) {} //~^ ERROR `Rect` is ambiguous -//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! fn main() { } diff --git a/tests/ui/imports/ambiguous-13.stderr b/tests/ui/imports/ambiguous-13.stderr index c1dfac5eb4332..1d105eec0e36f 100644 --- a/tests/ui/imports/ambiguous-13.stderr +++ b/tests/ui/imports/ambiguous-13.stderr @@ -1,4 +1,4 @@ -error: `Rect` is ambiguous +error[E0659]: `Rect` is ambiguous --> $DIR/ambiguous-13.rs:18:9 | LL | fn a(_: Rect) {} @@ -17,33 +17,7 @@ note: `Rect` could also refer to the struct imported here LL | use crate::content::*; | ^^^^^^^^^^^^^^^^^ = help: consider adding an explicit import of `Rect` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error -Future incompatibility report: Future breakage diagnostic: -error: `Rect` is ambiguous - --> $DIR/ambiguous-13.rs:18:9 - | -LL | fn a(_: Rect) {} - | ^^^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `Rect` could refer to the struct imported here - --> $DIR/ambiguous-13.rs:15:5 - | -LL | use crate::object::*; - | ^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `Rect` to disambiguate -note: `Rect` could also refer to the struct imported here - --> $DIR/ambiguous-13.rs:16:5 - | -LL | use crate::content::*; - | ^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `Rect` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-15.rs b/tests/ui/imports/ambiguous-15.rs index 07d8893b2dead..72c2940573c6b 100644 --- a/tests/ui/imports/ambiguous-15.rs +++ b/tests/ui/imports/ambiguous-15.rs @@ -21,6 +21,5 @@ mod t3 { use self::t3::*; fn a(_: E) {} //~^ ERROR `Error` is ambiguous -//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! fn main() {} diff --git a/tests/ui/imports/ambiguous-15.stderr b/tests/ui/imports/ambiguous-15.stderr index cb9f6ebde1fb1..fb3551d76274c 100644 --- a/tests/ui/imports/ambiguous-15.stderr +++ b/tests/ui/imports/ambiguous-15.stderr @@ -1,4 +1,4 @@ -error: `Error` is ambiguous +error[E0659]: `Error` is ambiguous --> $DIR/ambiguous-15.rs:22:9 | LL | fn a(_: E) {} @@ -17,33 +17,7 @@ note: `Error` could also refer to the enum imported here LL | pub use t2::*; | ^^^^^ = help: consider adding an explicit import of `Error` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error -Future incompatibility report: Future breakage diagnostic: -error: `Error` is ambiguous - --> $DIR/ambiguous-15.rs:22:9 - | -LL | fn a(_: E) {} - | ^^^^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `Error` could refer to the trait imported here - --> $DIR/ambiguous-15.rs:21:5 - | -LL | use self::t3::*; - | ^^^^^^^^^^^ - = help: consider adding an explicit import of `Error` to disambiguate -note: `Error` could also refer to the enum imported here - --> $DIR/ambiguous-15.rs:15:9 - | -LL | pub use t2::*; - | ^^^^^ - = help: consider adding an explicit import of `Error` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-16.rs b/tests/ui/imports/ambiguous-16.rs index f31c78d18a380..a20c0e340d601 100644 --- a/tests/ui/imports/ambiguous-16.rs +++ b/tests/ui/imports/ambiguous-16.rs @@ -21,6 +21,5 @@ mod framing { use crate::framing::ConfirmedTranscriptHashInput; //~^ ERROR `ConfirmedTranscriptHashInput` is ambiguous -//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! fn main() { } diff --git a/tests/ui/imports/ambiguous-16.stderr b/tests/ui/imports/ambiguous-16.stderr index cad19b8f7a16b..c18242d4a3cfc 100644 --- a/tests/ui/imports/ambiguous-16.stderr +++ b/tests/ui/imports/ambiguous-16.stderr @@ -1,4 +1,4 @@ -error: `ConfirmedTranscriptHashInput` is ambiguous +error[E0659]: `ConfirmedTranscriptHashInput` is ambiguous --> $DIR/ambiguous-16.rs:22:21 | LL | use crate::framing::ConfirmedTranscriptHashInput; @@ -17,33 +17,7 @@ note: `ConfirmedTranscriptHashInput` could also refer to the struct imported her LL | pub use self::public_message_in::*; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: consider adding an explicit import of `ConfirmedTranscriptHashInput` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error -Future incompatibility report: Future breakage diagnostic: -error: `ConfirmedTranscriptHashInput` is ambiguous - --> $DIR/ambiguous-16.rs:22:21 - | -LL | use crate::framing::ConfirmedTranscriptHashInput; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `ConfirmedTranscriptHashInput` could refer to the struct imported here - --> $DIR/ambiguous-16.rs:18:13 - | -LL | pub use self::public_message::*; - | ^^^^^^^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `ConfirmedTranscriptHashInput` to disambiguate -note: `ConfirmedTranscriptHashInput` could also refer to the struct imported here - --> $DIR/ambiguous-16.rs:19:13 - | -LL | pub use self::public_message_in::*; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `ConfirmedTranscriptHashInput` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-17.rs b/tests/ui/imports/ambiguous-17.rs index 3a51c156d34ca..5ba51ce714b75 100644 --- a/tests/ui/imports/ambiguous-17.rs +++ b/tests/ui/imports/ambiguous-17.rs @@ -25,5 +25,4 @@ mod handwritten { fn main() { id(); //~^ ERROR `id` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } diff --git a/tests/ui/imports/ambiguous-17.stderr b/tests/ui/imports/ambiguous-17.stderr index 80d152fe53440..b46a9430d2a7c 100644 --- a/tests/ui/imports/ambiguous-17.stderr +++ b/tests/ui/imports/ambiguous-17.stderr @@ -1,14 +1,4 @@ -warning: ambiguous glob re-exports - --> $DIR/ambiguous-17.rs:4:9 - | -LL | pub use evp::*; - | ^^^^^^ the name `id` in the value namespace is first re-exported here -LL | pub use handwritten::*; - | -------------- but the name `id` in the value namespace is also re-exported here - | - = note: `#[warn(ambiguous_glob_reexports)]` on by default - -error: `id` is ambiguous +error[E0659]: `id` is ambiguous --> $DIR/ambiguous-17.rs:26:5 | LL | id(); @@ -27,33 +17,17 @@ note: `id` could also refer to the function imported here LL | pub use handwritten::*; | ^^^^^^^^^^^^^^ = help: consider adding an explicit import of `id` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - -error: aborting due to 1 previous error; 1 warning emitted -Future incompatibility report: Future breakage diagnostic: -error: `id` is ambiguous - --> $DIR/ambiguous-17.rs:26:5 - | -LL | id(); - | ^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `id` could refer to the function imported here +warning: ambiguous glob re-exports --> $DIR/ambiguous-17.rs:4:9 | LL | pub use evp::*; - | ^^^^^^ - = help: consider adding an explicit import of `id` to disambiguate -note: `id` could also refer to the function imported here - --> $DIR/ambiguous-17.rs:5:9 - | + | ^^^^^^ the name `id` in the value namespace is first re-exported here LL | pub use handwritten::*; - | ^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `id` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default + | -------------- but the name `id` in the value namespace is also re-exported here + | + = note: `#[warn(ambiguous_glob_reexports)]` on by default + +error: aborting due to 1 previous error; 1 warning emitted +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-2.rs b/tests/ui/imports/ambiguous-2.rs deleted file mode 100644 index 65c971c00b9ac..0000000000000 --- a/tests/ui/imports/ambiguous-2.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ aux-build: ../ambiguous-1.rs -// https://github.com/rust-lang/rust/pull/113099#issuecomment-1633574396 - -extern crate ambiguous_1; - -fn main() { - ambiguous_1::id(); //~ ERROR `id` is ambiguous - //~| WARN this was previously accepted -} diff --git a/tests/ui/imports/ambiguous-2.stderr b/tests/ui/imports/ambiguous-2.stderr deleted file mode 100644 index a07f09c41475b..0000000000000 --- a/tests/ui/imports/ambiguous-2.stderr +++ /dev/null @@ -1,49 +0,0 @@ -error: `id` is ambiguous - --> $DIR/ambiguous-2.rs:7:18 - | -LL | ambiguous_1::id(); - | ^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `id` could refer to the function defined here - --> $DIR/auxiliary/../ambiguous-1.rs:13:13 - | -LL | pub use self::evp::*; - | ^^^^^^^^^ - = help: consider updating this dependency to resolve this error - = help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate -note: `id` could also refer to the function defined here - --> $DIR/auxiliary/../ambiguous-1.rs:15:13 - | -LL | pub use self::handwritten::*; - | ^^^^^^^^^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - -error: aborting due to 1 previous error - -Future incompatibility report: Future breakage diagnostic: -error: `id` is ambiguous - --> $DIR/ambiguous-2.rs:7:18 - | -LL | ambiguous_1::id(); - | ^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `id` could refer to the function defined here - --> $DIR/auxiliary/../ambiguous-1.rs:13:13 - | -LL | pub use self::evp::*; - | ^^^^^^^^^ - = help: consider updating this dependency to resolve this error - = help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate -note: `id` could also refer to the function defined here - --> $DIR/auxiliary/../ambiguous-1.rs:15:13 - | -LL | pub use self::handwritten::*; - | ^^^^^^^^^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - diff --git a/tests/ui/imports/ambiguous-3.rs b/tests/ui/imports/ambiguous-3.rs index ff0dcc221ec05..4919d9fbac63d 100644 --- a/tests/ui/imports/ambiguous-3.rs +++ b/tests/ui/imports/ambiguous-3.rs @@ -4,7 +4,6 @@ fn main() { use a::*; x(); //~^ ERROR `x` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } mod a { diff --git a/tests/ui/imports/ambiguous-3.stderr b/tests/ui/imports/ambiguous-3.stderr index 1e4aad83d985b..6c3031a9807aa 100644 --- a/tests/ui/imports/ambiguous-3.stderr +++ b/tests/ui/imports/ambiguous-3.stderr @@ -1,4 +1,4 @@ -error: `x` is ambiguous +error[E0659]: `x` is ambiguous --> $DIR/ambiguous-3.rs:5:5 | LL | x(); @@ -6,44 +6,18 @@ LL | x(); | = note: ambiguous because of multiple glob imports of a name in the same module note: `x` could refer to the function imported here - --> $DIR/ambiguous-3.rs:18:13 + --> $DIR/ambiguous-3.rs:17:13 | LL | pub use self::b::*; | ^^^^^^^^^^ = help: consider adding an explicit import of `x` to disambiguate note: `x` could also refer to the function imported here - --> $DIR/ambiguous-3.rs:19:13 + --> $DIR/ambiguous-3.rs:18:13 | LL | pub use self::c::*; | ^^^^^^^^^^ = help: consider adding an explicit import of `x` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error -Future incompatibility report: Future breakage diagnostic: -error: `x` is ambiguous - --> $DIR/ambiguous-3.rs:5:5 - | -LL | x(); - | ^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `x` could refer to the function imported here - --> $DIR/ambiguous-3.rs:18:13 - | -LL | pub use self::b::*; - | ^^^^^^^^^^ - = help: consider adding an explicit import of `x` to disambiguate -note: `x` could also refer to the function imported here - --> $DIR/ambiguous-3.rs:19:13 - | -LL | pub use self::c::*; - | ^^^^^^^^^^ - = help: consider adding an explicit import of `x` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-4-extern.rs b/tests/ui/imports/ambiguous-4-extern.rs index 125612dea03e5..a062b38df617e 100644 --- a/tests/ui/imports/ambiguous-4-extern.rs +++ b/tests/ui/imports/ambiguous-4-extern.rs @@ -1,9 +1,6 @@ //@ edition:2015 -//@ check-pass // https://github.com/rust-lang/rust/pull/112743#issuecomment-1601986883 -#![warn(ambiguous_glob_imports)] - macro_rules! m { () => { pub fn id() {} @@ -24,6 +21,5 @@ mod handwritten { fn main() { id(); - //~^ WARNING `id` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + //~^ ERROR `id` is ambiguous } diff --git a/tests/ui/imports/ambiguous-4-extern.stderr b/tests/ui/imports/ambiguous-4-extern.stderr index 4658071363e91..dae8432118f45 100644 --- a/tests/ui/imports/ambiguous-4-extern.stderr +++ b/tests/ui/imports/ambiguous-4-extern.stderr @@ -1,67 +1,33 @@ -warning: ambiguous glob re-exports - --> $DIR/ambiguous-4-extern.rs:13:9 - | -LL | pub use evp::*; - | ^^^^^^ the name `id` in the value namespace is first re-exported here -LL | pub use handwritten::*; - | -------------- but the name `id` in the value namespace is also re-exported here - | - = note: `#[warn(ambiguous_glob_reexports)]` on by default - -warning: `id` is ambiguous - --> $DIR/ambiguous-4-extern.rs:26:5 +error[E0659]: `id` is ambiguous + --> $DIR/ambiguous-4-extern.rs:23:5 | LL | id(); | ^^ ambiguous name | = note: ambiguous because of multiple glob imports of a name in the same module note: `id` could refer to the function imported here - --> $DIR/ambiguous-4-extern.rs:13:9 + --> $DIR/ambiguous-4-extern.rs:10:9 | LL | pub use evp::*; | ^^^^^^ = help: consider adding an explicit import of `id` to disambiguate note: `id` could also refer to the function imported here - --> $DIR/ambiguous-4-extern.rs:14:9 + --> $DIR/ambiguous-4-extern.rs:11:9 | LL | pub use handwritten::*; | ^^^^^^^^^^^^^^ = help: consider adding an explicit import of `id` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 -note: the lint level is defined here - --> $DIR/ambiguous-4-extern.rs:5:9 - | -LL | #![warn(ambiguous_glob_imports)] - | ^^^^^^^^^^^^^^^^^^^^^^ - -warning: 2 warnings emitted -Future incompatibility report: Future breakage diagnostic: -warning: `id` is ambiguous - --> $DIR/ambiguous-4-extern.rs:26:5 - | -LL | id(); - | ^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `id` could refer to the function imported here - --> $DIR/ambiguous-4-extern.rs:13:9 +warning: ambiguous glob re-exports + --> $DIR/ambiguous-4-extern.rs:10:9 | LL | pub use evp::*; - | ^^^^^^ - = help: consider adding an explicit import of `id` to disambiguate -note: `id` could also refer to the function imported here - --> $DIR/ambiguous-4-extern.rs:14:9 - | + | ^^^^^^ the name `id` in the value namespace is first re-exported here LL | pub use handwritten::*; - | ^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `id` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 -note: the lint level is defined here - --> $DIR/ambiguous-4-extern.rs:5:9 + | -------------- but the name `id` in the value namespace is also re-exported here | -LL | #![warn(ambiguous_glob_imports)] - | ^^^^^^^^^^^^^^^^^^^^^^ + = note: `#[warn(ambiguous_glob_reexports)]` on by default + +error: aborting due to 1 previous error; 1 warning emitted +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-4.rs b/tests/ui/imports/ambiguous-4.rs deleted file mode 100644 index e66d231f93cc3..0000000000000 --- a/tests/ui/imports/ambiguous-4.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ edition:2015 -//@ aux-build: ../ambiguous-4-extern.rs - -extern crate ambiguous_4_extern; - -fn main() { - ambiguous_4_extern::id(); //~ ERROR `id` is ambiguous - //~| WARN this was previously accepted -} diff --git a/tests/ui/imports/ambiguous-4.stderr b/tests/ui/imports/ambiguous-4.stderr deleted file mode 100644 index 0d207665ca776..0000000000000 --- a/tests/ui/imports/ambiguous-4.stderr +++ /dev/null @@ -1,49 +0,0 @@ -error: `id` is ambiguous - --> $DIR/ambiguous-4.rs:7:25 - | -LL | ambiguous_4_extern::id(); - | ^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `id` could refer to the function defined here - --> $DIR/auxiliary/../ambiguous-4-extern.rs:13:9 - | -LL | pub use evp::*; - | ^^^ - = help: consider updating this dependency to resolve this error - = help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate -note: `id` could also refer to the function defined here - --> $DIR/auxiliary/../ambiguous-4-extern.rs:14:9 - | -LL | pub use handwritten::*; - | ^^^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - -error: aborting due to 1 previous error - -Future incompatibility report: Future breakage diagnostic: -error: `id` is ambiguous - --> $DIR/ambiguous-4.rs:7:25 - | -LL | ambiguous_4_extern::id(); - | ^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `id` could refer to the function defined here - --> $DIR/auxiliary/../ambiguous-4-extern.rs:13:9 - | -LL | pub use evp::*; - | ^^^ - = help: consider updating this dependency to resolve this error - = help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate -note: `id` could also refer to the function defined here - --> $DIR/auxiliary/../ambiguous-4-extern.rs:14:9 - | -LL | pub use handwritten::*; - | ^^^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - diff --git a/tests/ui/imports/ambiguous-5.rs b/tests/ui/imports/ambiguous-5.rs index 8f89c966d4a5d..a88dbf46ddab9 100644 --- a/tests/ui/imports/ambiguous-5.rs +++ b/tests/ui/imports/ambiguous-5.rs @@ -11,7 +11,6 @@ mod gpos { use super::*; struct MarkRecord(Class); //~^ ERROR`Class` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } mod gsubgpos { diff --git a/tests/ui/imports/ambiguous-5.stderr b/tests/ui/imports/ambiguous-5.stderr index 8cc37c65c4c4d..e2dfe4d2dea85 100644 --- a/tests/ui/imports/ambiguous-5.stderr +++ b/tests/ui/imports/ambiguous-5.stderr @@ -1,4 +1,4 @@ -error: `Class` is ambiguous +error[E0659]: `Class` is ambiguous --> $DIR/ambiguous-5.rs:12:23 | LL | struct MarkRecord(Class); @@ -17,33 +17,7 @@ note: `Class` could also refer to the struct imported here LL | use super::gsubgpos::*; | ^^^^^^^^^^^^^^^^^^ = help: consider adding an explicit import of `Class` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error -Future incompatibility report: Future breakage diagnostic: -error: `Class` is ambiguous - --> $DIR/ambiguous-5.rs:12:23 - | -LL | struct MarkRecord(Class); - | ^^^^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `Class` could refer to the struct imported here - --> $DIR/ambiguous-5.rs:11:9 - | -LL | use super::*; - | ^^^^^^^^ - = help: consider adding an explicit import of `Class` to disambiguate -note: `Class` could also refer to the struct imported here - --> $DIR/ambiguous-5.rs:10:9 - | -LL | use super::gsubgpos::*; - | ^^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `Class` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-6.rs b/tests/ui/imports/ambiguous-6.rs index 1c6e34377165a..71667a8f3bb80 100644 --- a/tests/ui/imports/ambiguous-6.rs +++ b/tests/ui/imports/ambiguous-6.rs @@ -5,7 +5,6 @@ pub fn foo() -> u32 { use sub::*; C //~^ ERROR `C` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } mod sub { diff --git a/tests/ui/imports/ambiguous-6.stderr b/tests/ui/imports/ambiguous-6.stderr index ea5b2d2f19b80..f1a4fb694c9a0 100644 --- a/tests/ui/imports/ambiguous-6.stderr +++ b/tests/ui/imports/ambiguous-6.stderr @@ -1,4 +1,4 @@ -error: `C` is ambiguous +error[E0659]: `C` is ambiguous --> $DIR/ambiguous-6.rs:6:5 | LL | C @@ -6,44 +6,18 @@ LL | C | = note: ambiguous because of multiple glob imports of a name in the same module note: `C` could refer to the constant imported here - --> $DIR/ambiguous-6.rs:15:13 + --> $DIR/ambiguous-6.rs:14:13 | LL | pub use mod1::*; | ^^^^^^^ = help: consider adding an explicit import of `C` to disambiguate note: `C` could also refer to the constant imported here - --> $DIR/ambiguous-6.rs:16:13 + --> $DIR/ambiguous-6.rs:15:13 | LL | pub use mod2::*; | ^^^^^^^ = help: consider adding an explicit import of `C` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default error: aborting due to 1 previous error -Future incompatibility report: Future breakage diagnostic: -error: `C` is ambiguous - --> $DIR/ambiguous-6.rs:6:5 - | -LL | C - | ^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `C` could refer to the constant imported here - --> $DIR/ambiguous-6.rs:15:13 - | -LL | pub use mod1::*; - | ^^^^^^^ - = help: consider adding an explicit import of `C` to disambiguate -note: `C` could also refer to the constant imported here - --> $DIR/ambiguous-6.rs:16:13 - | -LL | pub use mod2::*; - | ^^^^^^^ - = help: consider adding an explicit import of `C` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-9.rs b/tests/ui/imports/ambiguous-9.rs index c10b1268060ce..58796031bf18f 100644 --- a/tests/ui/imports/ambiguous-9.rs +++ b/tests/ui/imports/ambiguous-9.rs @@ -22,7 +22,5 @@ use prelude::*; fn main() { date_range(); //~^ ERROR `date_range` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! //~| ERROR `date_range` is ambiguous - //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } diff --git a/tests/ui/imports/ambiguous-9.stderr b/tests/ui/imports/ambiguous-9.stderr index bbbce638a44dc..b6e4c30a8d410 100644 --- a/tests/ui/imports/ambiguous-9.stderr +++ b/tests/ui/imports/ambiguous-9.stderr @@ -1,45 +1,4 @@ -warning: ambiguous glob re-exports - --> $DIR/ambiguous-9.rs:7:13 - | -LL | pub use self::range::*; - | ^^^^^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here -LL | use super::prelude::*; - | ----------------- but the name `date_range` in the value namespace is also re-exported here - | - = note: `#[warn(ambiguous_glob_reexports)]` on by default - -error: `date_range` is ambiguous - --> $DIR/ambiguous-9.rs:23:5 - | -LL | date_range(); - | ^^^^^^^^^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `date_range` could refer to the function imported here - --> $DIR/ambiguous-9.rs:7:13 - | -LL | pub use self::range::*; - | ^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `date_range` to disambiguate -note: `date_range` could also refer to the function imported here - --> $DIR/ambiguous-9.rs:8:9 - | -LL | use super::prelude::*; - | ^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `date_range` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - -warning: ambiguous glob re-exports - --> $DIR/ambiguous-9.rs:15:13 - | -LL | pub use self::t::*; - | ^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here -LL | pub use super::dsl::*; - | ------------- but the name `date_range` in the value namespace is also re-exported here - -error: `date_range` is ambiguous +error[E0659]: `date_range` is ambiguous --> $DIR/ambiguous-9.rs:23:5 | LL | date_range(); @@ -58,13 +17,8 @@ note: `date_range` could also refer to the function imported here LL | use prelude::*; | ^^^^^^^^^^ = help: consider adding an explicit import of `date_range` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 -error: aborting due to 2 previous errors; 2 warnings emitted - -Future incompatibility report: Future breakage diagnostic: -error: `date_range` is ambiguous +error[E0659]: `date_range` is ambiguous --> $DIR/ambiguous-9.rs:23:5 | LL | date_range(); @@ -83,31 +37,25 @@ note: `date_range` could also refer to the function imported here LL | use super::prelude::*; | ^^^^^^^^^^^^^^^^^ = help: consider adding an explicit import of `date_range` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default -Future breakage diagnostic: -error: `date_range` is ambiguous - --> $DIR/ambiguous-9.rs:23:5 - | -LL | date_range(); - | ^^^^^^^^^^ ambiguous name +warning: ambiguous glob re-exports + --> $DIR/ambiguous-9.rs:7:13 | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `date_range` could refer to the function imported here - --> $DIR/ambiguous-9.rs:19:5 +LL | pub use self::range::*; + | ^^^^^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here +LL | use super::prelude::*; + | ----------------- but the name `date_range` in the value namespace is also re-exported here | -LL | use dsl::*; - | ^^^^^^ - = help: consider adding an explicit import of `date_range` to disambiguate -note: `date_range` could also refer to the function imported here - --> $DIR/ambiguous-9.rs:20:5 + = note: `#[warn(ambiguous_glob_reexports)]` on by default + +warning: ambiguous glob re-exports + --> $DIR/ambiguous-9.rs:15:13 | -LL | use prelude::*; - | ^^^^^^^^^^ - = help: consider adding an explicit import of `date_range` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default +LL | pub use self::t::*; + | ^^^^^^^^^^ the name `date_range` in the value namespace is first re-exported here +LL | pub use super::dsl::*; + | ------------- but the name `date_range` in the value namespace is also re-exported here + +error: aborting due to 2 previous errors; 2 warnings emitted +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/ambiguous-panic-globvsglob.rs b/tests/ui/imports/ambiguous-panic-globvsglob.rs index 4ff3cc8225355..4b35d6014b06b 100644 --- a/tests/ui/imports/ambiguous-panic-globvsglob.rs +++ b/tests/ui/imports/ambiguous-panic-globvsglob.rs @@ -18,6 +18,5 @@ fn foo() { panic!(); //~^ WARN: `panic` is ambiguous [ambiguous_panic_imports] //~| WARN: this was previously accepted by the compiler - //~| ERROR: `panic` is ambiguous [ambiguous_glob_imports] - //~| WARN: this was previously accepted by the compiler + //~| ERROR: `panic` is ambiguous } diff --git a/tests/ui/imports/ambiguous-panic-globvsglob.stderr b/tests/ui/imports/ambiguous-panic-globvsglob.stderr index 981c9b05b9eb4..8fd785277533c 100644 --- a/tests/ui/imports/ambiguous-panic-globvsglob.stderr +++ b/tests/ui/imports/ambiguous-panic-globvsglob.stderr @@ -1,4 +1,4 @@ -error: `panic` is ambiguous +error[E0659]: `panic` is ambiguous --> $DIR/ambiguous-panic-globvsglob.rs:18:5 | LL | panic!(); @@ -17,9 +17,6 @@ note: `panic` could also refer to the macro imported here LL | use m2::*; | ^^^^^ = help: consider adding an explicit import of `panic` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default warning: `panic` is ambiguous --> $DIR/ambiguous-panic-globvsglob.rs:18:5 @@ -42,27 +39,4 @@ note: `panic` could also refer to a macro from prelude error: aborting due to 1 previous error; 1 warning emitted -Future incompatibility report: Future breakage diagnostic: -error: `panic` is ambiguous - --> $DIR/ambiguous-panic-globvsglob.rs:18:5 - | -LL | panic!(); - | ^^^^^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `panic` could refer to the macro imported here - --> $DIR/ambiguous-panic-globvsglob.rs:12:9 - | -LL | use m1::*; - | ^^^^^ - = help: consider adding an explicit import of `panic` to disambiguate -note: `panic` could also refer to the macro imported here - --> $DIR/ambiguous-panic-globvsglob.rs:13:9 - | -LL | use m2::*; - | ^^^^^ - = help: consider adding an explicit import of `panic` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/imports/glob-conflict-cross-crate-3.rs b/tests/ui/imports/glob-conflict-cross-crate-3.rs index 31c234b9250fc..74415cfd9bb36 100644 --- a/tests/ui/imports/glob-conflict-cross-crate-3.rs +++ b/tests/ui/imports/glob-conflict-cross-crate-3.rs @@ -14,5 +14,4 @@ fn main() { //~^ ERROR `C` is ambiguous //~| ERROR `C` is ambiguous //~| WARN this was previously accepted - //~| WARN this was previously accepted } diff --git a/tests/ui/imports/glob-conflict-cross-crate-3.stderr b/tests/ui/imports/glob-conflict-cross-crate-3.stderr index 8a9ece94deeb1..50a9adc097e47 100644 --- a/tests/ui/imports/glob-conflict-cross-crate-3.stderr +++ b/tests/ui/imports/glob-conflict-cross-crate-3.stderr @@ -1,27 +1,4 @@ -error: `C` is ambiguous - --> $DIR/glob-conflict-cross-crate-3.rs:13:13 - | -LL | let _a: C = 1; - | ^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `C` could refer to the type alias defined here - --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:9:9 - | -LL | pub use a::*; - | ^ - = help: consider updating this dependency to resolve this error - = help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate -note: `C` could also refer to the type alias defined here - --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:10:9 - | -LL | pub use b::*; - | ^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - -error: `C` is ambiguous +error[E0659]: `C` is ambiguous --> $DIR/glob-conflict-cross-crate-3.rs:13:13 | LL | let _a: C = 1; @@ -40,12 +17,7 @@ note: `C` could also refer to the type alias imported here LL | use a::*; | ^^^^ = help: consider adding an explicit import of `C` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 -error: aborting due to 2 previous errors - -Future incompatibility report: Future breakage diagnostic: error: `C` is ambiguous --> $DIR/glob-conflict-cross-crate-3.rs:13:13 | @@ -69,7 +41,10 @@ LL | pub use b::*; = note: for more information, see issue #114095 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default -Future breakage diagnostic: +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0659`. +Future incompatibility report: Future breakage diagnostic: error: `C` is ambiguous --> $DIR/glob-conflict-cross-crate-3.rs:13:13 | @@ -77,18 +52,18 @@ LL | let _a: C = 1; | ^ ambiguous name | = note: ambiguous because of multiple glob imports of a name in the same module -note: `C` could refer to the type alias imported here - --> $DIR/glob-conflict-cross-crate-3.rs:9:5 +note: `C` could refer to the type alias defined here + --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:9:9 | -LL | use glob_conflict_cross_crate_2_extern::*; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: consider adding an explicit import of `C` to disambiguate -note: `C` could also refer to the type alias imported here - --> $DIR/glob-conflict-cross-crate-3.rs:10:5 +LL | pub use a::*; + | ^ + = help: consider updating this dependency to resolve this error + = help: if updating the dependency does not resolve the problem report the problem to the author of the relevant crate +note: `C` could also refer to the type alias defined here + --> $DIR/auxiliary/glob-conflict-cross-crate-2-extern.rs:10:9 | -LL | use a::*; - | ^^^^ - = help: consider adding an explicit import of `C` to disambiguate +LL | pub use b::*; + | ^ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #114095 = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default diff --git a/tests/ui/imports/unresolved-seg-after-ambiguous.rs b/tests/ui/imports/unresolved-seg-after-ambiguous.rs index 67366deabaafb..00a3c5b0145c2 100644 --- a/tests/ui/imports/unresolved-seg-after-ambiguous.rs +++ b/tests/ui/imports/unresolved-seg-after-ambiguous.rs @@ -17,8 +17,6 @@ mod a { } use self::a::E::in_exist; -//~^ ERROR: unresolved import `self::a::E` -//~| ERROR: `E` is ambiguous -//~| WARNING: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +//~^ ERROR: `E` is ambiguous fn main() {} diff --git a/tests/ui/imports/unresolved-seg-after-ambiguous.stderr b/tests/ui/imports/unresolved-seg-after-ambiguous.stderr index c21faffadfc31..e712d80f69460 100644 --- a/tests/ui/imports/unresolved-seg-after-ambiguous.stderr +++ b/tests/ui/imports/unresolved-seg-after-ambiguous.stderr @@ -1,10 +1,4 @@ -error[E0432]: unresolved import `self::a::E` - --> $DIR/unresolved-seg-after-ambiguous.rs:19:14 - | -LL | use self::a::E::in_exist; - | ^ `E` is a struct, not a module - -error: `E` is ambiguous +error[E0659]: `E` is ambiguous --> $DIR/unresolved-seg-after-ambiguous.rs:19:14 | LL | use self::a::E::in_exist; @@ -23,34 +17,7 @@ note: `E` could also refer to the struct imported here LL | pub use self::d::*; | ^^^^^^^^^^ = help: consider adding an explicit import of `E` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default - -error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0432`. -Future incompatibility report: Future breakage diagnostic: -error: `E` is ambiguous - --> $DIR/unresolved-seg-after-ambiguous.rs:19:14 - | -LL | use self::a::E::in_exist; - | ^ ambiguous name - | - = note: ambiguous because of multiple glob imports of a name in the same module -note: `E` could refer to the struct imported here - --> $DIR/unresolved-seg-after-ambiguous.rs:13:17 - | -LL | pub use self::c::*; - | ^^^^^^^^^^ - = help: consider adding an explicit import of `E` to disambiguate -note: `E` could also refer to the struct imported here - --> $DIR/unresolved-seg-after-ambiguous.rs:12:17 - | -LL | pub use self::d::*; - | ^^^^^^^^^^ - = help: consider adding an explicit import of `E` to disambiguate - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #114095 - = note: `#[deny(ambiguous_glob_imports)]` (part of `#[deny(future_incompatible)]`) on by default +error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/linkage-attr/unstable-flavor.llbc.stderr b/tests/ui/linkage-attr/unstable-flavor.llbc.stderr new file mode 100644 index 0000000000000..796daa4c4e8c2 --- /dev/null +++ b/tests/ui/linkage-attr/unstable-flavor.llbc.stderr @@ -0,0 +1,2 @@ +error: the linker flavor `llbc` is unstable, the `-Z unstable-options` flag must also be passed to use the unstable values + diff --git a/tests/ui/linkage-attr/unstable-flavor.ptx.stderr b/tests/ui/linkage-attr/unstable-flavor.ptx.stderr deleted file mode 100644 index 2ebdc1a903399..0000000000000 --- a/tests/ui/linkage-attr/unstable-flavor.ptx.stderr +++ /dev/null @@ -1,2 +0,0 @@ -error: the linker flavor `ptx` is unstable, the `-Z unstable-options` flag must also be passed to use the unstable values - diff --git a/tests/ui/linkage-attr/unstable-flavor.rs b/tests/ui/linkage-attr/unstable-flavor.rs index 5412e248f341f..adb34a9a80cd8 100644 --- a/tests/ui/linkage-attr/unstable-flavor.rs +++ b/tests/ui/linkage-attr/unstable-flavor.rs @@ -2,14 +2,14 @@ // unique codepath checking all unstable options (see `LinkerFlavorCli::is_unstable` and its // caller). If it passes, all the other unstable options are rejected as well. // -//@ revisions: bpf ptx +//@ revisions: bpf llbc //@ [bpf] compile-flags: --target=bpfel-unknown-none -C linker-flavor=bpf --crate-type=rlib //@ [bpf] needs-llvm-components: bpf -//@ [ptx] compile-flags: --target=nvptx64-nvidia-cuda -C linker-flavor=ptx --crate-type=rlib -//@ [ptx] needs-llvm-components: nvptx +//@ [llbc] compile-flags: --target=nvptx64-nvidia-cuda -C linker-flavor=llbc --crate-type=rlib +//@ [llbc] needs-llvm-components: nvptx #![feature(no_core)] #![no_core] //[bpf]~? ERROR the linker flavor `bpf` is unstable -//[ptx]~? ERROR the linker flavor `ptx` is unstable +//[llbc]~? ERROR the linker flavor `llbc` is unstable diff --git a/tests/ui/lint/unused/unused-assign-148960.rs b/tests/ui/lint/unused/unused-assign-148960.rs index 2e51c01398a37..b7e129a4f2ab7 100644 --- a/tests/ui/lint/unused/unused-assign-148960.rs +++ b/tests/ui/lint/unused/unused-assign-148960.rs @@ -1,4 +1,5 @@ //@ check-fail +//@ ignore-parallel-frontend unstable liveness diagnostics #![deny(unused)] #![allow(dead_code)] diff --git a/tests/ui/lint/unused/unused-assign-148960.stderr b/tests/ui/lint/unused/unused-assign-148960.stderr index aa5326cea6476..60966beb36ab6 100644 --- a/tests/ui/lint/unused/unused-assign-148960.stderr +++ b/tests/ui/lint/unused/unused-assign-148960.stderr @@ -1,5 +1,5 @@ error: value assigned to `value` is never read - --> $DIR/unused-assign-148960.rs:6:21 + --> $DIR/unused-assign-148960.rs:7:21 | LL | let mut value = b"0".to_vec(); | ^^^^^^^^^^^^^ this value is reassigned later and never used @@ -7,14 +7,14 @@ LL | value = b"1".to_vec(); | ----- `value` is overwritten here before the previous value is read | note: the lint level is defined here - --> $DIR/unused-assign-148960.rs:2:9 + --> $DIR/unused-assign-148960.rs:3:9 | LL | #![deny(unused)] | ^^^^^^ = note: `#[deny(unused_assignments)]` implied by `#[deny(unused)]` error: value assigned to `x` is never read - --> $DIR/unused-assign-148960.rs:12:17 + --> $DIR/unused-assign-148960.rs:13:17 | LL | let mut x = 1; | ^ this value is reassigned later and never used @@ -22,7 +22,7 @@ LL | x = 2; | ----- `x` is overwritten here before the previous value is read error: value assigned to `x` is never read - --> $DIR/unused-assign-148960.rs:13:5 + --> $DIR/unused-assign-148960.rs:14:5 | LL | x = 2; | ^^^^^ this value is reassigned later and never used @@ -30,7 +30,7 @@ LL | x = 3; | ----- `x` is overwritten here before the previous value is read error: value assigned to `p` is never read - --> $DIR/unused-assign-148960.rs:24:17 + --> $DIR/unused-assign-148960.rs:25:17 | LL | let mut p = Point { x: 1, y: 1 }; | ^^^^^^^^^^^^^^^^^^^^ this value is reassigned later and never used @@ -38,7 +38,7 @@ LL | p = Point { x: 2, y: 2 }; | ------------------------ `p` is overwritten here before the previous value is read error: variable `foo` is assigned to, but never used - --> $DIR/unused-assign-148960.rs:38:9 + --> $DIR/unused-assign-148960.rs:39:9 | LL | let mut foo = Foo; | ^^^^^^^ @@ -52,7 +52,7 @@ LL + let Foo = Foo; | error: value assigned to `foo` is never read - --> $DIR/unused-assign-148960.rs:39:5 + --> $DIR/unused-assign-148960.rs:40:5 | LL | foo = Foo; | ^^^ diff --git a/tests/ui/liveness/liveness-consts.rs b/tests/ui/liveness/liveness-consts.rs index 7e56bf8c2cda4..b239e12b2e021 100644 --- a/tests/ui/liveness/liveness-consts.rs +++ b/tests/ui/liveness/liveness-consts.rs @@ -1,4 +1,5 @@ //@ check-pass +//@ ignore-parallel-frontend unstable liveness diagnostics #![warn(unused)] #![allow(unreachable_code)] diff --git a/tests/ui/liveness/liveness-consts.stderr b/tests/ui/liveness/liveness-consts.stderr index 6b4acf1c8de9a..f4a5b82725346 100644 --- a/tests/ui/liveness/liveness-consts.stderr +++ b/tests/ui/liveness/liveness-consts.stderr @@ -1,30 +1,30 @@ warning: unused variable: `e` - --> $DIR/liveness-consts.rs:26:13 + --> $DIR/liveness-consts.rs:27:13 | LL | let e = 1; | ^ help: if this is intentional, prefix it with an underscore: `_e` | note: the lint level is defined here - --> $DIR/liveness-consts.rs:2:9 + --> $DIR/liveness-consts.rs:3:9 | LL | #![warn(unused)] | ^^^^^^ = note: `#[warn(unused_variables)]` implied by `#[warn(unused)]` warning: unused variable: `s` - --> $DIR/liveness-consts.rs:35:24 + --> $DIR/liveness-consts.rs:36:24 | LL | pub fn f(x: [u8; { let s = 17; 100 }]) -> [u8; { let z = 18; 100 }] { | ^ help: if this is intentional, prefix it with an underscore: `_s` warning: unused variable: `z` - --> $DIR/liveness-consts.rs:35:55 + --> $DIR/liveness-consts.rs:36:55 | LL | pub fn f(x: [u8; { let s = 17; 100 }]) -> [u8; { let z = 18; 100 }] { | ^ help: if this is intentional, prefix it with an underscore: `_z` warning: variable `a` is assigned to, but never used - --> $DIR/liveness-consts.rs:7:9 + --> $DIR/liveness-consts.rs:8:9 | LL | let mut a = 0; | ^^^^^ @@ -32,7 +32,7 @@ LL | let mut a = 0; = note: consider using `_a` instead warning: value assigned to `a` is never read - --> $DIR/liveness-consts.rs:11:9 + --> $DIR/liveness-consts.rs:12:9 | LL | a += 1; | ^^^^^^ @@ -41,7 +41,7 @@ LL | a += 1; = note: `#[warn(unused_assignments)]` implied by `#[warn(unused)]` warning: value assigned to `b` is never read - --> $DIR/liveness-consts.rs:18:17 + --> $DIR/liveness-consts.rs:19:17 | LL | let mut b = 1; | ^ this value is reassigned later and never used @@ -49,7 +49,7 @@ LL | b += 1; | ------ `b` is overwritten here before the previous value is read warning: value assigned to `b` is never read - --> $DIR/liveness-consts.rs:19:5 + --> $DIR/liveness-consts.rs:20:5 | LL | b += 1; | ^^^^^^ this value is reassigned later and never used @@ -57,13 +57,13 @@ LL | b = 42; | ------ `b` is overwritten here before the previous value is read warning: unused variable: `z` - --> $DIR/liveness-consts.rs:62:13 + --> $DIR/liveness-consts.rs:63:13 | LL | let z = 42; | ^ help: if this is intentional, prefix it with an underscore: `_z` warning: value assigned to `t` is never read - --> $DIR/liveness-consts.rs:44:9 + --> $DIR/liveness-consts.rs:45:9 | LL | t = t + t; | ^^^^^^^^^ @@ -71,7 +71,7 @@ LL | t = t + t; = help: maybe it is overwritten before being read? warning: unused variable: `w` - --> $DIR/liveness-consts.rs:51:13 + --> $DIR/liveness-consts.rs:52:13 | LL | let w = 10; | ^ help: if this is intentional, prefix it with an underscore: `_w` diff --git a/tests/ui/liveness/liveness-dead.rs b/tests/ui/liveness/liveness-dead.rs index 004663c85ee50..c48b28ef74fec 100644 --- a/tests/ui/liveness/liveness-dead.rs +++ b/tests/ui/liveness/liveness-dead.rs @@ -1,3 +1,4 @@ +//@ ignore-parallel-frontend unstable liveness diagnostics #![allow(dead_code)] #![deny(unused_assignments)] diff --git a/tests/ui/liveness/liveness-dead.stderr b/tests/ui/liveness/liveness-dead.stderr index ade0e04d2e7a9..2288fae52091a 100644 --- a/tests/ui/liveness/liveness-dead.stderr +++ b/tests/ui/liveness/liveness-dead.stderr @@ -1,5 +1,5 @@ error: value assigned to `x` is never read - --> $DIR/liveness-dead.rs:9:24 + --> $DIR/liveness-dead.rs:10:24 | LL | let mut x: isize = 3; | ^ this value is reassigned later and never used @@ -7,13 +7,13 @@ LL | x = 4; | ----- `x` is overwritten here before the previous value is read | note: the lint level is defined here - --> $DIR/liveness-dead.rs:2:9 + --> $DIR/liveness-dead.rs:3:9 | LL | #![deny(unused_assignments)] | ^^^^^^^^^^^^^^^^^^ error: value assigned to `x` is never read - --> $DIR/liveness-dead.rs:17:5 + --> $DIR/liveness-dead.rs:18:5 | LL | x = 4; | ^^^^^ @@ -21,7 +21,7 @@ LL | x = 4; = help: maybe it is overwritten before being read? error: value passed to `x` is never read - --> $DIR/liveness-dead.rs:20:7 + --> $DIR/liveness-dead.rs:21:7 | LL | fn f4(mut x: i32) { | ^^^^^ @@ -29,7 +29,7 @@ LL | fn f4(mut x: i32) { = help: maybe it is overwritten before being read? error: value assigned to `x` is never read - --> $DIR/liveness-dead.rs:27:5 + --> $DIR/liveness-dead.rs:28:5 | LL | x = 4; | ^^^^^ diff --git a/tests/ui/liveness/liveness-upvars.rs b/tests/ui/liveness/liveness-upvars.rs index be58b48a40576..1a3d0e5be54ad 100644 --- a/tests/ui/liveness/liveness-upvars.rs +++ b/tests/ui/liveness/liveness-upvars.rs @@ -1,5 +1,6 @@ //@ edition:2018 //@ check-pass +//@ ignore-parallel-frontend unstable liveness diagnostics #![feature(coroutines, stmt_expr_attributes)] #![warn(unused)] #![allow(unreachable_code)] diff --git a/tests/ui/liveness/liveness-upvars.stderr b/tests/ui/liveness/liveness-upvars.stderr index 96a922772c919..b569acdccf8a7 100644 --- a/tests/ui/liveness/liveness-upvars.stderr +++ b/tests/ui/liveness/liveness-upvars.stderr @@ -1,19 +1,19 @@ warning: value captured by `last` is never read - --> $DIR/liveness-upvars.rs:10:9 + --> $DIR/liveness-upvars.rs:11:9 | LL | last = Some(s); | ^^^^ | = help: did you mean to capture by reference instead? note: the lint level is defined here - --> $DIR/liveness-upvars.rs:4:9 + --> $DIR/liveness-upvars.rs:5:9 | LL | #![warn(unused)] | ^^^^^^ = note: `#[warn(unused_assignments)]` implied by `#[warn(unused)]` warning: value assigned to `last` is never read - --> $DIR/liveness-upvars.rs:10:9 + --> $DIR/liveness-upvars.rs:11:9 | LL | last = Some(s); | ^^^^^^^^^^^^^^ @@ -21,7 +21,7 @@ LL | last = Some(s); = help: maybe it is overwritten before being read? warning: value captured by `sum` is never read - --> $DIR/liveness-upvars.rs:22:9 + --> $DIR/liveness-upvars.rs:23:9 | LL | sum += x; | ^^^ @@ -29,7 +29,7 @@ LL | sum += x; = help: did you mean to capture by reference instead? warning: value assigned to `sum` is never read - --> $DIR/liveness-upvars.rs:22:9 + --> $DIR/liveness-upvars.rs:23:9 | LL | sum += x; | ^^^^^^^^ @@ -37,7 +37,7 @@ LL | sum += x; = help: maybe it is overwritten before being read? warning: value assigned to `c` is never read - --> $DIR/liveness-upvars.rs:69:9 + --> $DIR/liveness-upvars.rs:70:9 | LL | c += 1; | ^^^^^^ @@ -45,7 +45,7 @@ LL | c += 1; = help: maybe it is overwritten before being read? warning: value assigned to `c` is never read - --> $DIR/liveness-upvars.rs:63:9 + --> $DIR/liveness-upvars.rs:64:9 | LL | c += 1; | ^^^^^^ @@ -53,7 +53,7 @@ LL | c += 1; = help: maybe it is overwritten before being read? warning: value captured by `c` is never read - --> $DIR/liveness-upvars.rs:49:9 + --> $DIR/liveness-upvars.rs:50:9 | LL | c += 1; | ^ @@ -61,7 +61,7 @@ LL | c += 1; = help: did you mean to capture by reference instead? warning: value assigned to `c` is never read - --> $DIR/liveness-upvars.rs:49:9 + --> $DIR/liveness-upvars.rs:50:9 | LL | c += 1; | ^^^^^^ @@ -69,7 +69,7 @@ LL | c += 1; = help: maybe it is overwritten before being read? warning: value captured by `c` is never read - --> $DIR/liveness-upvars.rs:44:9 + --> $DIR/liveness-upvars.rs:45:9 | LL | c += 1; | ^ @@ -77,7 +77,7 @@ LL | c += 1; = help: did you mean to capture by reference instead? warning: value assigned to `c` is never read - --> $DIR/liveness-upvars.rs:44:9 + --> $DIR/liveness-upvars.rs:45:9 | LL | c += 1; | ^^^^^^ @@ -85,7 +85,7 @@ LL | c += 1; = help: maybe it is overwritten before being read? warning: value captured by `c` is never read - --> $DIR/liveness-upvars.rs:38:9 + --> $DIR/liveness-upvars.rs:39:9 | LL | c = 1; | ^ @@ -93,7 +93,7 @@ LL | c = 1; = help: did you mean to capture by reference instead? warning: value captured by `c` is never read - --> $DIR/liveness-upvars.rs:34:9 + --> $DIR/liveness-upvars.rs:35:9 | LL | c = 1; | ^ @@ -101,7 +101,7 @@ LL | c = 1; = help: did you mean to capture by reference instead? warning: value captured by `e` is never read - --> $DIR/liveness-upvars.rs:82:13 + --> $DIR/liveness-upvars.rs:83:13 | LL | e = Some("e1"); | ^ @@ -109,7 +109,7 @@ LL | e = Some("e1"); = help: did you mean to capture by reference instead? warning: value assigned to `e` is never read - --> $DIR/liveness-upvars.rs:82:13 + --> $DIR/liveness-upvars.rs:83:13 | LL | e = Some("e1"); | ^^^^^^^^^^^^^^ this value is reassigned later and never used @@ -118,7 +118,7 @@ LL | e = Some("e2"); | -------------- `e` is overwritten here before the previous value is read warning: value assigned to `e` is never read - --> $DIR/liveness-upvars.rs:84:13 + --> $DIR/liveness-upvars.rs:85:13 | LL | e = Some("e2"); | ^^^^^^^^^^^^^^ @@ -126,7 +126,7 @@ LL | e = Some("e2"); = help: maybe it is overwritten before being read? warning: value assigned to `d` is never read - --> $DIR/liveness-upvars.rs:78:13 + --> $DIR/liveness-upvars.rs:79:13 | LL | d = Some("d1"); | ^^^^^^^^^^^^^^ this value is reassigned later and never used @@ -134,7 +134,7 @@ LL | d = Some("d2"); | -------------- `d` is overwritten here before the previous value is read warning: value assigned to `v` is never read - --> $DIR/liveness-upvars.rs:92:13 + --> $DIR/liveness-upvars.rs:93:13 | LL | v = T::default(); | ^ @@ -142,7 +142,7 @@ LL | v = T::default(); = help: maybe it is overwritten before being read? warning: value captured by `z` is never read - --> $DIR/liveness-upvars.rs:105:17 + --> $DIR/liveness-upvars.rs:106:17 | LL | z = T::default(); | ^ @@ -150,7 +150,7 @@ LL | z = T::default(); = help: did you mean to capture by reference instead? warning: value assigned to `z` is never read - --> $DIR/liveness-upvars.rs:105:17 + --> $DIR/liveness-upvars.rs:106:17 | LL | z = T::default(); | ^^^^^^^^^^^^^^^^ @@ -158,7 +158,7 @@ LL | z = T::default(); = help: maybe it is overwritten before being read? warning: value captured by `state` is never read - --> $DIR/liveness-upvars.rs:131:9 + --> $DIR/liveness-upvars.rs:132:9 | LL | state = 4; | ^^^^^ @@ -166,7 +166,7 @@ LL | state = 4; = help: did you mean to capture by reference instead? warning: value assigned to `state` is never read - --> $DIR/liveness-upvars.rs:131:9 + --> $DIR/liveness-upvars.rs:132:9 | LL | state = 4; | ^^^^^^^^^ this value is reassigned later and never used @@ -175,7 +175,7 @@ LL | state = 5; | --------- `state` is overwritten here before the previous value is read warning: value assigned to `state` is never read - --> $DIR/liveness-upvars.rs:134:9 + --> $DIR/liveness-upvars.rs:135:9 | LL | state = 5; | ^^^^^^^^^ @@ -183,7 +183,7 @@ LL | state = 5; = help: maybe it is overwritten before being read? warning: value assigned to `s` is never read - --> $DIR/liveness-upvars.rs:143:9 + --> $DIR/liveness-upvars.rs:144:9 | LL | s = 1; | ^^^^^ this value is reassigned later and never used @@ -191,7 +191,7 @@ LL | yield (s = 2); | ------- `s` is overwritten here before the previous value is read warning: value assigned to `s` is never read - --> $DIR/liveness-upvars.rs:145:9 + --> $DIR/liveness-upvars.rs:146:9 | LL | s = yield (); | ^^^^^^^^^^^^ this value is reassigned later and never used diff --git a/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.rs b/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.rs index 08cffa00f752f..d1fb55d874518 100644 --- a/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.rs +++ b/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.rs @@ -1,4 +1,5 @@ //@ run-pass +//@ ignore-parallel-frontend unstable liveness diagnostics #![allow(dead_code)] #![warn(unused_assignments)] diff --git a/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.stderr b/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.stderr index 5afb33626e055..4ec4a3d3839b7 100644 --- a/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.stderr +++ b/tests/ui/liveness/unused-assignments-diverging-branch-issue-156416.stderr @@ -1,18 +1,18 @@ warning: value assigned to `x` is never read - --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:10:9 + --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:11:9 | LL | x = 35; | ^^^^^^ | = help: maybe it is overwritten before being read? note: the lint level is defined here - --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:3:9 + --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:4:9 | LL | #![warn(unused_assignments)] | ^^^^^^^^^^^^^^^^^^ warning: value assigned to `x` is never read - --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:21:13 + --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:22:13 | LL | x = 35; | ^^^^^^ @@ -20,7 +20,7 @@ LL | x = 35; = help: maybe it is overwritten before being read? warning: value assigned to `x` is never read - --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:36:9 + --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:37:9 | LL | x = 42; | ^^^^^^ this value is reassigned later and never used @@ -29,7 +29,7 @@ LL | x = 99; | ------ `x` is overwritten here before the previous value is read warning: value assigned to `x` is never read - --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:33:9 + --> $DIR/unused-assignments-diverging-branch-issue-156416.rs:34:9 | LL | x = 35; | ^^^^^^ this value is reassigned later and never used diff --git a/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr index 75a633cd49a3d..d26ba93e72117 100644 --- a/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr @@ -1,5 +1,5 @@ error: unreachable pattern - --> $DIR/empty-types.rs:47:9 + --> $DIR/empty-types.rs:48:9 | LL | _ => {} | ^------ @@ -9,13 +9,13 @@ LL | _ => {} | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here - --> $DIR/empty-types.rs:13:9 + --> $DIR/empty-types.rs:14:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:50:9 + --> $DIR/empty-types.rs:51:9 | LL | _x => {} | ^^------ @@ -26,7 +26,7 @@ LL | _x => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: type `&!` is non-empty - --> $DIR/empty-types.rs:54:11 + --> $DIR/empty-types.rs:55:11 | LL | match ref_never {} | ^^^^^^^^^ @@ -41,7 +41,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:68:9 + --> $DIR/empty-types.rs:69:9 | LL | (_, _) => {} | ^^^^^^------ @@ -52,7 +52,7 @@ LL | (_, _) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:74:9 + --> $DIR/empty-types.rs:75:9 | LL | _ => {} | ^------ @@ -63,7 +63,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:77:9 + --> $DIR/empty-types.rs:78:9 | LL | (_, _) => {} | ^^^^^^------ @@ -74,7 +74,7 @@ LL | (_, _) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:81:9 + --> $DIR/empty-types.rs:82:9 | LL | _ => {} | ^------ @@ -85,7 +85,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: `Ok(_)` not covered - --> $DIR/empty-types.rs:85:11 + --> $DIR/empty-types.rs:86:11 | LL | match res_u32_never {} | ^^^^^^^^^^^^^ pattern `Ok(_)` not covered @@ -104,7 +104,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:92:9 + --> $DIR/empty-types.rs:93:9 | LL | Err(_) => {} | ^^^^^^------ @@ -115,7 +115,7 @@ LL | Err(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:97:9 + --> $DIR/empty-types.rs:98:9 | LL | Err(_) => {} | ^^^^^^------ @@ -126,7 +126,7 @@ LL | Err(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered - --> $DIR/empty-types.rs:94:11 + --> $DIR/empty-types.rs:95:11 | LL | match res_u32_never { | ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered @@ -144,7 +144,7 @@ LL ~ Ok(1_u32..=u32::MAX) => todo!() | error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:100:9 + --> $DIR/empty-types.rs:101:9 | LL | let Ok(_x) = res_u32_never.as_ref(); | ^^^^^^ pattern `Err(_)` not covered @@ -158,7 +158,7 @@ LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() }; | ++++++++++++++++ error: unreachable pattern - --> $DIR/empty-types.rs:110:9 + --> $DIR/empty-types.rs:111:9 | LL | _ => {} | ^------ @@ -169,7 +169,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:113:9 + --> $DIR/empty-types.rs:114:9 | LL | Ok(_) => {} | ^^^^^------ @@ -180,7 +180,7 @@ LL | Ok(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:116:9 + --> $DIR/empty-types.rs:117:9 | LL | Ok(_) => {} | ^^^^^------ @@ -191,7 +191,7 @@ LL | Ok(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:117:9 + --> $DIR/empty-types.rs:118:9 | LL | _ => {} | ^------ @@ -202,7 +202,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:120:9 + --> $DIR/empty-types.rs:121:9 | LL | Ok(_) => {} | ^^^^^------ @@ -213,7 +213,7 @@ LL | Ok(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:121:9 + --> $DIR/empty-types.rs:122:9 | LL | Err(_) => {} | ^^^^^^------ @@ -224,7 +224,7 @@ LL | Err(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:130:13 + --> $DIR/empty-types.rs:131:13 | LL | _ => {} | ^------ @@ -235,7 +235,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:133:13 + --> $DIR/empty-types.rs:134:13 | LL | _ if false => {} | ^--------------- @@ -246,7 +246,7 @@ LL | _ if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:141:13 + --> $DIR/empty-types.rs:142:13 | LL | Some(_) => {} | ^^^^^^^------ @@ -257,7 +257,7 @@ LL | Some(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:145:13 + --> $DIR/empty-types.rs:146:13 | LL | None => {} | ---- matches all the relevant values @@ -265,7 +265,7 @@ LL | _ => {} | ^ no value can reach this error: unreachable pattern - --> $DIR/empty-types.rs:197:13 + --> $DIR/empty-types.rs:198:13 | LL | _ => {} | ^------ @@ -276,7 +276,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:202:13 + --> $DIR/empty-types.rs:203:13 | LL | _ => {} | ^------ @@ -287,7 +287,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:207:13 + --> $DIR/empty-types.rs:208:13 | LL | _ => {} | ^------ @@ -298,7 +298,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:212:13 + --> $DIR/empty-types.rs:213:13 | LL | _ => {} | ^------ @@ -309,7 +309,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:218:13 + --> $DIR/empty-types.rs:219:13 | LL | _ => {} | ^------ @@ -320,7 +320,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:279:9 + --> $DIR/empty-types.rs:280:9 | LL | _ => {} | ^------ @@ -331,7 +331,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:282:9 + --> $DIR/empty-types.rs:283:9 | LL | (_, _) => {} | ^^^^^^------ @@ -342,7 +342,7 @@ LL | (_, _) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:285:9 + --> $DIR/empty-types.rs:286:9 | LL | Ok(_) => {} | ^^^^^------ @@ -353,7 +353,7 @@ LL | Ok(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:286:9 + --> $DIR/empty-types.rs:287:9 | LL | Err(_) => {} | ^^^^^^------ @@ -364,7 +364,7 @@ LL | Err(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty - --> $DIR/empty-types.rs:325:11 + --> $DIR/empty-types.rs:326:11 | LL | match slice_never {} | ^^^^^^^^^^^ @@ -378,7 +378,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: `&[]` not covered - --> $DIR/empty-types.rs:336:11 + --> $DIR/empty-types.rs:337:11 | LL | match slice_never { | ^^^^^^^^^^^ pattern `&[]` not covered @@ -391,7 +391,7 @@ LL + &[] => todo!() | error[E0004]: non-exhaustive patterns: `&[]` not covered - --> $DIR/empty-types.rs:350:11 + --> $DIR/empty-types.rs:351:11 | LL | match slice_never { | ^^^^^^^^^^^ pattern `&[]` not covered @@ -405,7 +405,7 @@ LL + &[] => todo!() | error[E0004]: non-exhaustive patterns: type `[!]` is non-empty - --> $DIR/empty-types.rs:357:11 + --> $DIR/empty-types.rs:358:11 | LL | match *slice_never {} | ^^^^^^^^^^^^ @@ -419,7 +419,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:366:9 + --> $DIR/empty-types.rs:367:9 | LL | _ => {} | ^------ @@ -430,7 +430,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:369:9 + --> $DIR/empty-types.rs:370:9 | LL | [_, _, _] => {} | ^^^^^^^^^------ @@ -441,7 +441,7 @@ LL | [_, _, _] => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:372:9 + --> $DIR/empty-types.rs:373:9 | LL | [_, ..] => {} | ^^^^^^^------ @@ -452,7 +452,7 @@ LL | [_, ..] => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty - --> $DIR/empty-types.rs:386:11 + --> $DIR/empty-types.rs:387:11 | LL | match array_0_never {} | ^^^^^^^^^^^^^ @@ -466,7 +466,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:393:9 + --> $DIR/empty-types.rs:394:9 | LL | [] => {} | -- matches all the relevant values @@ -474,7 +474,7 @@ LL | _ => {} | ^ no value can reach this error[E0004]: non-exhaustive patterns: `[]` not covered - --> $DIR/empty-types.rs:395:11 + --> $DIR/empty-types.rs:396:11 | LL | match array_0_never { | ^^^^^^^^^^^^^ pattern `[]` not covered @@ -488,7 +488,7 @@ LL + [] => todo!() | error: unreachable pattern - --> $DIR/empty-types.rs:414:9 + --> $DIR/empty-types.rs:415:9 | LL | Some(_) => {} | ^^^^^^^------ @@ -499,7 +499,7 @@ LL | Some(_) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:419:9 + --> $DIR/empty-types.rs:420:9 | LL | Some(_a) => {} | ^^^^^^^^------ @@ -510,7 +510,7 @@ LL | Some(_a) => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:424:9 + --> $DIR/empty-types.rs:425:9 | LL | None => {} | ---- matches all the relevant values @@ -519,7 +519,7 @@ LL | _ => {} | ^ no value can reach this error: unreachable pattern - --> $DIR/empty-types.rs:429:9 + --> $DIR/empty-types.rs:430:9 | LL | None => {} | ---- matches all the relevant values @@ -528,7 +528,7 @@ LL | _a => {} | ^^ no value can reach this error: unreachable pattern - --> $DIR/empty-types.rs:601:9 + --> $DIR/empty-types.rs:602:9 | LL | _ => {} | ^------ @@ -539,7 +539,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:604:9 + --> $DIR/empty-types.rs:605:9 | LL | _x => {} | ^^------ @@ -550,7 +550,7 @@ LL | _x => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:607:9 + --> $DIR/empty-types.rs:608:9 | LL | _ if false => {} | ^--------------- @@ -561,7 +561,7 @@ LL | _ if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:610:9 + --> $DIR/empty-types.rs:611:9 | LL | _x if false => {} | ^^--------------- diff --git a/tests/ui/pattern/usefulness/empty-types.never_pats.stderr b/tests/ui/pattern/usefulness/empty-types.never_pats.stderr index 68a1bebf6b132..4dcbe6ce677f9 100644 --- a/tests/ui/pattern/usefulness/empty-types.never_pats.stderr +++ b/tests/ui/pattern/usefulness/empty-types.never_pats.stderr @@ -1,5 +1,5 @@ error: unreachable pattern - --> $DIR/empty-types.rs:47:9 + --> $DIR/empty-types.rs:48:9 | LL | _ => {} | ^------ @@ -9,13 +9,13 @@ LL | _ => {} | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here - --> $DIR/empty-types.rs:13:9 + --> $DIR/empty-types.rs:14:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:50:9 + --> $DIR/empty-types.rs:51:9 | LL | _x => {} | ^^------ @@ -26,7 +26,7 @@ LL | _x => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: type `&!` is non-empty - --> $DIR/empty-types.rs:54:11 + --> $DIR/empty-types.rs:55:11 | LL | match ref_never {} | ^^^^^^^^^ @@ -41,7 +41,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:81:9 + --> $DIR/empty-types.rs:82:9 | LL | _ => {} | ^------ @@ -52,7 +52,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: `Ok(_)` not covered - --> $DIR/empty-types.rs:85:11 + --> $DIR/empty-types.rs:86:11 | LL | match res_u32_never {} | ^^^^^^^^^^^^^ pattern `Ok(_)` not covered @@ -71,7 +71,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered - --> $DIR/empty-types.rs:94:11 + --> $DIR/empty-types.rs:95:11 | LL | match res_u32_never { | ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered @@ -89,7 +89,7 @@ LL ~ Ok(1_u32..=u32::MAX) => todo!() | error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:100:9 + --> $DIR/empty-types.rs:101:9 | LL | let Ok(_x) = res_u32_never.as_ref(); | ^^^^^^ pattern `Err(_)` not covered @@ -103,7 +103,7 @@ LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() }; | ++++++++++++++++ error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:104:9 + --> $DIR/empty-types.rs:105:9 | LL | let Ok(_x) = &res_u32_never; | ^^^^^^ pattern `&Err(!)` not covered @@ -117,7 +117,7 @@ LL | let Ok(_x) = &res_u32_never else { todo!() }; | ++++++++++++++++ error: unreachable pattern - --> $DIR/empty-types.rs:130:13 + --> $DIR/empty-types.rs:131:13 | LL | _ => {} | ^------ @@ -128,7 +128,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:133:13 + --> $DIR/empty-types.rs:134:13 | LL | _ if false => {} | ^--------------- @@ -139,7 +139,7 @@ LL | _ if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: `Some(!)` not covered - --> $DIR/empty-types.rs:154:15 + --> $DIR/empty-types.rs:155:15 | LL | match *ref_opt_void { | ^^^^^^^^^^^^^ pattern `Some(!)` not covered @@ -158,7 +158,7 @@ LL + Some(!) | error: unreachable pattern - --> $DIR/empty-types.rs:197:13 + --> $DIR/empty-types.rs:198:13 | LL | _ => {} | ^------ @@ -169,7 +169,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:202:13 + --> $DIR/empty-types.rs:203:13 | LL | _ => {} | ^------ @@ -180,7 +180,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:207:13 + --> $DIR/empty-types.rs:208:13 | LL | _ => {} | ^------ @@ -191,7 +191,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:212:13 + --> $DIR/empty-types.rs:213:13 | LL | _ => {} | ^------ @@ -202,7 +202,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:218:13 + --> $DIR/empty-types.rs:219:13 | LL | _ => {} | ^------ @@ -213,7 +213,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:279:9 + --> $DIR/empty-types.rs:280:9 | LL | _ => {} | ^------ @@ -224,7 +224,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:295:13 + --> $DIR/empty-types.rs:296:13 | LL | let Ok(_) = *ptr_result_never_err; | ^^^^^ pattern `Err(!)` not covered @@ -238,7 +238,7 @@ LL | if let Ok(_) = *ptr_result_never_err { todo!() }; | ++ +++++++++++ error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty - --> $DIR/empty-types.rs:314:11 + --> $DIR/empty-types.rs:315:11 | LL | match *x {} | ^^ @@ -252,7 +252,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `(!, !)` is non-empty - --> $DIR/empty-types.rs:316:11 + --> $DIR/empty-types.rs:317:11 | LL | match *x {} | ^^ @@ -266,7 +266,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: `Ok(!)` and `Err(!)` not covered - --> $DIR/empty-types.rs:318:11 + --> $DIR/empty-types.rs:319:11 | LL | match *x {} | ^^ patterns `Ok(!)` and `Err(!)` not covered @@ -288,7 +288,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `[!; 3]` is non-empty - --> $DIR/empty-types.rs:320:11 + --> $DIR/empty-types.rs:321:11 | LL | match *x {} | ^^ @@ -302,7 +302,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty - --> $DIR/empty-types.rs:325:11 + --> $DIR/empty-types.rs:326:11 | LL | match slice_never {} | ^^^^^^^^^^^ @@ -316,7 +316,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: `&[!, ..]` not covered - --> $DIR/empty-types.rs:327:11 + --> $DIR/empty-types.rs:328:11 | LL | match slice_never { | ^^^^^^^^^^^ pattern `&[!, ..]` not covered @@ -330,7 +330,7 @@ LL + &[!, ..] | error[E0004]: non-exhaustive patterns: `&[]`, `&[!]` and `&[!, !]` not covered - --> $DIR/empty-types.rs:336:11 + --> $DIR/empty-types.rs:337:11 | LL | match slice_never { | ^^^^^^^^^^^ patterns `&[]`, `&[!]` and `&[!, !]` not covered @@ -343,7 +343,7 @@ LL + &[] | &[!] | &[!, !] => todo!() | error[E0004]: non-exhaustive patterns: `&[]` and `&[!, ..]` not covered - --> $DIR/empty-types.rs:350:11 + --> $DIR/empty-types.rs:351:11 | LL | match slice_never { | ^^^^^^^^^^^ patterns `&[]` and `&[!, ..]` not covered @@ -357,7 +357,7 @@ LL + &[] | &[!, ..] => todo!() | error[E0004]: non-exhaustive patterns: type `[!]` is non-empty - --> $DIR/empty-types.rs:357:11 + --> $DIR/empty-types.rs:358:11 | LL | match *slice_never {} | ^^^^^^^^^^^^ @@ -371,7 +371,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty - --> $DIR/empty-types.rs:386:11 + --> $DIR/empty-types.rs:387:11 | LL | match array_0_never {} | ^^^^^^^^^^^^^ @@ -385,7 +385,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:393:9 + --> $DIR/empty-types.rs:394:9 | LL | [] => {} | -- matches all the relevant values @@ -393,7 +393,7 @@ LL | _ => {} | ^ no value can reach this error[E0004]: non-exhaustive patterns: `[]` not covered - --> $DIR/empty-types.rs:395:11 + --> $DIR/empty-types.rs:396:11 | LL | match array_0_never { | ^^^^^^^^^^^^^ pattern `[]` not covered @@ -407,7 +407,7 @@ LL + [] => todo!() | error[E0004]: non-exhaustive patterns: `&Some(!)` not covered - --> $DIR/empty-types.rs:449:11 + --> $DIR/empty-types.rs:450:11 | LL | match ref_opt_never { | ^^^^^^^^^^^^^ pattern `&Some(!)` not covered @@ -426,7 +426,7 @@ LL + &Some(!) | error[E0004]: non-exhaustive patterns: `Some(!)` not covered - --> $DIR/empty-types.rs:490:11 + --> $DIR/empty-types.rs:491:11 | LL | match *ref_opt_never { | ^^^^^^^^^^^^^^ pattern `Some(!)` not covered @@ -445,7 +445,7 @@ LL + Some(!) | error[E0004]: non-exhaustive patterns: `Err(!)` not covered - --> $DIR/empty-types.rs:538:11 + --> $DIR/empty-types.rs:539:11 | LL | match *ref_res_never { | ^^^^^^^^^^^^^^ pattern `Err(!)` not covered @@ -464,7 +464,7 @@ LL + Err(!) | error[E0004]: non-exhaustive patterns: `Err(!)` not covered - --> $DIR/empty-types.rs:549:11 + --> $DIR/empty-types.rs:550:11 | LL | match *ref_res_never { | ^^^^^^^^^^^^^^ pattern `Err(!)` not covered @@ -483,7 +483,7 @@ LL + Err(!) | error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty - --> $DIR/empty-types.rs:568:11 + --> $DIR/empty-types.rs:569:11 | LL | match *ref_tuple_half_never {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -497,7 +497,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:601:9 + --> $DIR/empty-types.rs:602:9 | LL | _ => {} | ^------ @@ -508,7 +508,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:604:9 + --> $DIR/empty-types.rs:605:9 | LL | _x => {} | ^^------ @@ -519,7 +519,7 @@ LL | _x => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:607:9 + --> $DIR/empty-types.rs:608:9 | LL | _ if false => {} | ^--------------- @@ -530,7 +530,7 @@ LL | _ if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:610:9 + --> $DIR/empty-types.rs:611:9 | LL | _x if false => {} | ^^--------------- @@ -541,7 +541,7 @@ LL | _x if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: `&!` not covered - --> $DIR/empty-types.rs:635:11 + --> $DIR/empty-types.rs:636:11 | LL | match ref_never { | ^^^^^^^^^ pattern `&!` not covered @@ -557,7 +557,7 @@ LL + &! | error[E0004]: non-exhaustive patterns: `Ok(!)` not covered - --> $DIR/empty-types.rs:651:11 + --> $DIR/empty-types.rs:652:11 | LL | match *ref_result_never { | ^^^^^^^^^^^^^^^^^ pattern `Ok(!)` not covered @@ -577,7 +577,7 @@ LL + Ok(!) | error[E0004]: non-exhaustive patterns: `Some(!)` not covered - --> $DIR/empty-types.rs:671:11 + --> $DIR/empty-types.rs:672:11 | LL | match *x { | ^^ pattern `Some(!)` not covered diff --git a/tests/ui/pattern/usefulness/empty-types.normal.stderr b/tests/ui/pattern/usefulness/empty-types.normal.stderr index 320959534e522..a49050cedb4d0 100644 --- a/tests/ui/pattern/usefulness/empty-types.normal.stderr +++ b/tests/ui/pattern/usefulness/empty-types.normal.stderr @@ -1,5 +1,5 @@ error: unreachable pattern - --> $DIR/empty-types.rs:47:9 + --> $DIR/empty-types.rs:48:9 | LL | _ => {} | ^------ @@ -9,13 +9,13 @@ LL | _ => {} | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types note: the lint level is defined here - --> $DIR/empty-types.rs:13:9 + --> $DIR/empty-types.rs:14:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/empty-types.rs:50:9 + --> $DIR/empty-types.rs:51:9 | LL | _x => {} | ^^------ @@ -26,7 +26,7 @@ LL | _x => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: type `&!` is non-empty - --> $DIR/empty-types.rs:54:11 + --> $DIR/empty-types.rs:55:11 | LL | match ref_never {} | ^^^^^^^^^ @@ -41,7 +41,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:81:9 + --> $DIR/empty-types.rs:82:9 | LL | _ => {} | ^------ @@ -52,7 +52,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: `Ok(_)` not covered - --> $DIR/empty-types.rs:85:11 + --> $DIR/empty-types.rs:86:11 | LL | match res_u32_never {} | ^^^^^^^^^^^^^ pattern `Ok(_)` not covered @@ -71,7 +71,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered - --> $DIR/empty-types.rs:94:11 + --> $DIR/empty-types.rs:95:11 | LL | match res_u32_never { | ^^^^^^^^^^^^^ pattern `Ok(1_u32..=u32::MAX)` not covered @@ -89,7 +89,7 @@ LL ~ Ok(1_u32..=u32::MAX) => todo!() | error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:100:9 + --> $DIR/empty-types.rs:101:9 | LL | let Ok(_x) = res_u32_never.as_ref(); | ^^^^^^ pattern `Err(_)` not covered @@ -103,7 +103,7 @@ LL | let Ok(_x) = res_u32_never.as_ref() else { todo!() }; | ++++++++++++++++ error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:104:9 + --> $DIR/empty-types.rs:105:9 | LL | let Ok(_x) = &res_u32_never; | ^^^^^^ pattern `&Err(_)` not covered @@ -117,7 +117,7 @@ LL | let Ok(_x) = &res_u32_never else { todo!() }; | ++++++++++++++++ error: unreachable pattern - --> $DIR/empty-types.rs:130:13 + --> $DIR/empty-types.rs:131:13 | LL | _ => {} | ^------ @@ -128,7 +128,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:133:13 + --> $DIR/empty-types.rs:134:13 | LL | _ if false => {} | ^--------------- @@ -139,7 +139,7 @@ LL | _ if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:154:15 + --> $DIR/empty-types.rs:155:15 | LL | match *ref_opt_void { | ^^^^^^^^^^^^^ pattern `Some(_)` not covered @@ -158,7 +158,7 @@ LL + Some(_) => todo!() | error: unreachable pattern - --> $DIR/empty-types.rs:197:13 + --> $DIR/empty-types.rs:198:13 | LL | _ => {} | ^------ @@ -169,7 +169,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:202:13 + --> $DIR/empty-types.rs:203:13 | LL | _ => {} | ^------ @@ -180,7 +180,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:207:13 + --> $DIR/empty-types.rs:208:13 | LL | _ => {} | ^------ @@ -191,7 +191,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:212:13 + --> $DIR/empty-types.rs:213:13 | LL | _ => {} | ^------ @@ -202,7 +202,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:218:13 + --> $DIR/empty-types.rs:219:13 | LL | _ => {} | ^------ @@ -213,7 +213,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:279:9 + --> $DIR/empty-types.rs:280:9 | LL | _ => {} | ^------ @@ -224,7 +224,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0005]: refutable pattern in local binding - --> $DIR/empty-types.rs:295:13 + --> $DIR/empty-types.rs:296:13 | LL | let Ok(_) = *ptr_result_never_err; | ^^^^^ pattern `Err(_)` not covered @@ -238,7 +238,7 @@ LL | if let Ok(_) = *ptr_result_never_err { todo!() }; | ++ +++++++++++ error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty - --> $DIR/empty-types.rs:314:11 + --> $DIR/empty-types.rs:315:11 | LL | match *x {} | ^^ @@ -252,7 +252,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `(!, !)` is non-empty - --> $DIR/empty-types.rs:316:11 + --> $DIR/empty-types.rs:317:11 | LL | match *x {} | ^^ @@ -266,7 +266,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: `Ok(_)` and `Err(_)` not covered - --> $DIR/empty-types.rs:318:11 + --> $DIR/empty-types.rs:319:11 | LL | match *x {} | ^^ patterns `Ok(_)` and `Err(_)` not covered @@ -288,7 +288,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `[!; 3]` is non-empty - --> $DIR/empty-types.rs:320:11 + --> $DIR/empty-types.rs:321:11 | LL | match *x {} | ^^ @@ -302,7 +302,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty - --> $DIR/empty-types.rs:325:11 + --> $DIR/empty-types.rs:326:11 | LL | match slice_never {} | ^^^^^^^^^^^ @@ -316,7 +316,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered - --> $DIR/empty-types.rs:327:11 + --> $DIR/empty-types.rs:328:11 | LL | match slice_never { | ^^^^^^^^^^^ pattern `&[_, ..]` not covered @@ -330,7 +330,7 @@ LL + &[_, ..] => todo!() | error[E0004]: non-exhaustive patterns: `&[]`, `&[_]` and `&[_, _]` not covered - --> $DIR/empty-types.rs:336:11 + --> $DIR/empty-types.rs:337:11 | LL | match slice_never { | ^^^^^^^^^^^ patterns `&[]`, `&[_]` and `&[_, _]` not covered @@ -343,7 +343,7 @@ LL + &[] | &[_] | &[_, _] => todo!() | error[E0004]: non-exhaustive patterns: `&[]` and `&[_, ..]` not covered - --> $DIR/empty-types.rs:350:11 + --> $DIR/empty-types.rs:351:11 | LL | match slice_never { | ^^^^^^^^^^^ patterns `&[]` and `&[_, ..]` not covered @@ -357,7 +357,7 @@ LL + &[] | &[_, ..] => todo!() | error[E0004]: non-exhaustive patterns: type `[!]` is non-empty - --> $DIR/empty-types.rs:357:11 + --> $DIR/empty-types.rs:358:11 | LL | match *slice_never {} | ^^^^^^^^^^^^ @@ -371,7 +371,7 @@ LL ~ } | error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty - --> $DIR/empty-types.rs:386:11 + --> $DIR/empty-types.rs:387:11 | LL | match array_0_never {} | ^^^^^^^^^^^^^ @@ -385,7 +385,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:393:9 + --> $DIR/empty-types.rs:394:9 | LL | [] => {} | -- matches all the relevant values @@ -393,7 +393,7 @@ LL | _ => {} | ^ no value can reach this error[E0004]: non-exhaustive patterns: `[]` not covered - --> $DIR/empty-types.rs:395:11 + --> $DIR/empty-types.rs:396:11 | LL | match array_0_never { | ^^^^^^^^^^^^^ pattern `[]` not covered @@ -407,7 +407,7 @@ LL + [] => todo!() | error[E0004]: non-exhaustive patterns: `&Some(_)` not covered - --> $DIR/empty-types.rs:449:11 + --> $DIR/empty-types.rs:450:11 | LL | match ref_opt_never { | ^^^^^^^^^^^^^ pattern `&Some(_)` not covered @@ -426,7 +426,7 @@ LL + &Some(_) => todo!() | error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:490:11 + --> $DIR/empty-types.rs:491:11 | LL | match *ref_opt_never { | ^^^^^^^^^^^^^^ pattern `Some(_)` not covered @@ -445,7 +445,7 @@ LL + Some(_) => todo!() | error[E0004]: non-exhaustive patterns: `Err(_)` not covered - --> $DIR/empty-types.rs:538:11 + --> $DIR/empty-types.rs:539:11 | LL | match *ref_res_never { | ^^^^^^^^^^^^^^ pattern `Err(_)` not covered @@ -464,7 +464,7 @@ LL + Err(_) => todo!() | error[E0004]: non-exhaustive patterns: `Err(_)` not covered - --> $DIR/empty-types.rs:549:11 + --> $DIR/empty-types.rs:550:11 | LL | match *ref_res_never { | ^^^^^^^^^^^^^^ pattern `Err(_)` not covered @@ -483,7 +483,7 @@ LL + Err(_) => todo!() | error[E0004]: non-exhaustive patterns: type `(u32, !)` is non-empty - --> $DIR/empty-types.rs:568:11 + --> $DIR/empty-types.rs:569:11 | LL | match *ref_tuple_half_never {} | ^^^^^^^^^^^^^^^^^^^^^ @@ -497,7 +497,7 @@ LL ~ } | error: unreachable pattern - --> $DIR/empty-types.rs:601:9 + --> $DIR/empty-types.rs:602:9 | LL | _ => {} | ^------ @@ -508,7 +508,7 @@ LL | _ => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:604:9 + --> $DIR/empty-types.rs:605:9 | LL | _x => {} | ^^------ @@ -519,7 +519,7 @@ LL | _x => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:607:9 + --> $DIR/empty-types.rs:608:9 | LL | _ if false => {} | ^--------------- @@ -530,7 +530,7 @@ LL | _ if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error: unreachable pattern - --> $DIR/empty-types.rs:610:9 + --> $DIR/empty-types.rs:611:9 | LL | _x if false => {} | ^^--------------- @@ -541,7 +541,7 @@ LL | _x if false => {} = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types error[E0004]: non-exhaustive patterns: `&_` not covered - --> $DIR/empty-types.rs:635:11 + --> $DIR/empty-types.rs:636:11 | LL | match ref_never { | ^^^^^^^^^ pattern `&_` not covered @@ -557,7 +557,7 @@ LL + &_ => todo!() | error[E0004]: non-exhaustive patterns: `Ok(_)` not covered - --> $DIR/empty-types.rs:651:11 + --> $DIR/empty-types.rs:652:11 | LL | match *ref_result_never { | ^^^^^^^^^^^^^^^^^ pattern `Ok(_)` not covered @@ -577,7 +577,7 @@ LL + Ok(_) => todo!() | error[E0004]: non-exhaustive patterns: `Some(_)` not covered - --> $DIR/empty-types.rs:671:11 + --> $DIR/empty-types.rs:672:11 | LL | match *x { | ^^ pattern `Some(_)` not covered diff --git a/tests/ui/pattern/usefulness/empty-types.rs b/tests/ui/pattern/usefulness/empty-types.rs index d4fdb7c1dd46a..cb0f1813e915b 100644 --- a/tests/ui/pattern/usefulness/empty-types.rs +++ b/tests/ui/pattern/usefulness/empty-types.rs @@ -1,5 +1,6 @@ //@ revisions: normal exhaustive_patterns never_pats //@ edition: 2024 +//@ ignore-parallel-frontend pattern matching error message mismatch // // This tests correct handling of empty types in exhaustiveness checking. // diff --git a/tests/ui/pin-ergonomics/pinned-drop-sugar-not-other-traits.rs b/tests/ui/pin-ergonomics/pinned-drop-sugar-not-other-traits.rs index ace00348d1876..e6e8dd1414bb4 100644 --- a/tests/ui/pin-ergonomics/pinned-drop-sugar-not-other-traits.rs +++ b/tests/ui/pin-ergonomics/pinned-drop-sugar-not-other-traits.rs @@ -12,7 +12,6 @@ trait NeedsPinDrop { } impl NeedsPinDrop for S { - //~^ ERROR not all trait items implemented, missing: `pin_drop` [E0046] fn drop(&pin mut self) {} //~^ ERROR method `drop` with `&pin mut self` is only supported for the `Drop` trait } @@ -53,7 +52,6 @@ mod local_drop_trait { } impl Drop for S { - //~^ ERROR not all trait items implemented, missing: `pin_drop` [E0046] fn drop(&pin mut self) {} //~^ ERROR method `drop` with `&pin mut self` is only supported for the `Drop` trait } diff --git a/tests/ui/pin-ergonomics/pinned-drop-sugar-not-other-traits.stderr b/tests/ui/pin-ergonomics/pinned-drop-sugar-not-other-traits.stderr index 2238abea2484d..2fba64f965e33 100644 --- a/tests/ui/pin-ergonomics/pinned-drop-sugar-not-other-traits.stderr +++ b/tests/ui/pin-ergonomics/pinned-drop-sugar-not-other-traits.stderr @@ -1,5 +1,5 @@ error[E0407]: method `drop` is not a member of trait `HasDrop` - --> $DIR/pinned-drop-sugar-not-other-traits.rs:26:5 + --> $DIR/pinned-drop-sugar-not-other-traits.rs:25:5 | LL | fn drop(&pin mut self) {} | ^^^----^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | fn drop(&pin mut self) {} | not a member of trait `HasDrop` error[E0407]: method `drop` is not a member of trait `HasPinnedDropReceiver` - --> $DIR/pinned-drop-sugar-not-other-traits.rs:36:5 + --> $DIR/pinned-drop-sugar-not-other-traits.rs:35:5 | LL | fn drop(&pin mut self) {} | ^^^----^^^^^^^^^^^^^^^^^^ @@ -17,28 +17,19 @@ LL | fn drop(&pin mut self) {} | not a member of trait `HasPinnedDropReceiver` error: method `drop` with `&pin mut self` is only supported for the `Drop` trait - --> $DIR/pinned-drop-sugar-not-other-traits.rs:16:5 + --> $DIR/pinned-drop-sugar-not-other-traits.rs:15:5 | LL | fn drop(&pin mut self) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ not a `Drop::pin_drop` implementation error: method `drop` with `&pin mut self` is only supported for the `Drop` trait - --> $DIR/pinned-drop-sugar-not-other-traits.rs:57:9 + --> $DIR/pinned-drop-sugar-not-other-traits.rs:55:9 | LL | fn drop(&pin mut self) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ not a `Drop::pin_drop` implementation -error[E0046]: not all trait items implemented, missing: `pin_drop` - --> $DIR/pinned-drop-sugar-not-other-traits.rs:14:1 - | -LL | fn pin_drop(self: Pin<&mut Self>); - | ---------------------------------- `pin_drop` from trait -... -LL | impl NeedsPinDrop for S { - | ^^^^^^^^^^^^^^^^^^^^^^^ missing `pin_drop` in implementation - error[E0046]: not all trait items implemented, missing: `drop` - --> $DIR/pinned-drop-sugar-not-other-traits.rs:24:1 + --> $DIR/pinned-drop-sugar-not-other-traits.rs:23:1 | LL | fn drop(self: Pin<&mut Self>); | ------------------------------ `drop` from trait @@ -47,7 +38,7 @@ LL | impl HasDrop for S { | ^^^^^^^^^^^^^^^^^^ missing `drop` in implementation error[E0046]: not all trait items implemented, missing: `drop` - --> $DIR/pinned-drop-sugar-not-other-traits.rs:34:1 + --> $DIR/pinned-drop-sugar-not-other-traits.rs:33:1 | LL | fn drop(self: &pin mut Self); | ----------------------------- `drop` from trait @@ -55,16 +46,7 @@ LL | fn drop(self: &pin mut Self); LL | impl HasPinnedDropReceiver for S { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation -error[E0046]: not all trait items implemented, missing: `pin_drop` - --> $DIR/pinned-drop-sugar-not-other-traits.rs:55:5 - | -LL | fn pin_drop(self: Pin<&mut Self>); - | ---------------------------------- `pin_drop` from trait -... -LL | impl Drop for S { - | ^^^^^^^^^^^^^^^ missing `pin_drop` in implementation - -error: aborting due to 8 previous errors +error: aborting due to 6 previous errors Some errors have detailed explanations: E0046, E0407. For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/target-feature/implied-features-nvptx.rs b/tests/ui/target-feature/implied-features-nvptx.rs index 1550c99f67a8d..a51c22afaf956 100644 --- a/tests/ui/target-feature/implied-features-nvptx.rs +++ b/tests/ui/target-feature/implied-features-nvptx.rs @@ -1,5 +1,5 @@ -//@ assembly-output: ptx-linker -//@ compile-flags: --crate-type cdylib -C target-cpu=sm_80 -Z unstable-options -Clinker-flavor=llbc +//@ assembly-output: emit-asm +//@ compile-flags: --crate-type cdylib -C target-cpu=sm_80 //@ only-nvptx64 //@ build-pass #![no_std] diff --git a/tests/ui/target-feature/invalid-attribute.stderr b/tests/ui/target-feature/invalid-attribute.stderr index cb19bdc60ceb4..702ea3bb3ba5f 100644 --- a/tests/ui/target-feature/invalid-attribute.stderr +++ b/tests/ui/target-feature/invalid-attribute.stderr @@ -174,7 +174,7 @@ error: the feature named `foo` is not valid for this target LL | #[target_feature(enable = "foo")] | ^^^^^^^^^^^^^^ `foo` is not valid for this target | - = help: valid names are: `fma`, `xop`, `adx`, `aes`, and `avx` and 75 more + = help: valid names are: `fma`, `xop`, `adx`, `aes`, and `avx` and 76 more error[E0046]: not all trait items implemented, missing: `foo` --> $DIR/invalid-attribute.rs:80:1 @@ -226,7 +226,7 @@ error: the feature named `sse5` is not valid for this target LL | #[target_feature(enable = "sse5")] | ^^^^^^^^^^^^^^^ `sse5` is not valid for this target | - = help: valid names are: `sse`, `sse2`, `sse3`, `sse4a`, and `ssse3` and 75 more + = help: valid names are: `sse`, `sse2`, `sse3`, `sse4a`, and `ssse3` and 76 more error: the feature named `avx512` is not valid for this target --> $DIR/invalid-attribute.rs:126:18 @@ -234,7 +234,7 @@ error: the feature named `avx512` is not valid for this target LL | #[target_feature(enable = "avx512")] | ^^^^^^^^^^^^^^^^^ `avx512` is not valid for this target | - = help: valid names are: `avx512f`, `avx2`, `avx512bw`, `avx512cd`, and `avx512dq` and 75 more + = help: valid names are: `avx512f`, `avx2`, `avx512bw`, `avx512cd`, and `avx512dq` and 76 more error: aborting due to 26 previous errors