diff --git a/Cargo.lock b/Cargo.lock index 9c791babc399b..bf28939ac87b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4360,7 +4360,6 @@ dependencies = [ "rustc_infer", "rustc_macros", "rustc_middle", - "rustc_mir_build", "rustc_mir_dataflow", "rustc_session", "rustc_span", diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index fb2ccefe12a18..a4a80475ba737 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -2109,16 +2109,18 @@ pub struct MacroDef { /// `true` if macro was defined with `macro_rules`. pub macro_rules: bool, - /// If this is a macro used for externally implementable items, - /// it refers to an extern item which is its "target". This requires - /// name resolution so can't just be an attribute, so we store it in this field. - pub eii_extern_target: Option, + /// Corresponds to `#[eii_declaration(...)]`. + /// `#[eii_declaration(...)]` is a built-in attribute macro, not a built-in attribute, + /// because we require some name resolution to occur in the parameters of this attribute. + /// Name resolution isn't possible in attributes otherwise, so we encode it in the AST. + /// During ast lowering, we turn it back into an attribute again + pub eii_declaration: Option, } #[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic, Walkable)] -pub struct EiiExternTarget { +pub struct EiiDecl { /// path to the extern item we're targeting - pub extern_item_path: Path, + pub foreign_item: Path, pub impl_unsafe: bool, } @@ -3824,7 +3826,7 @@ pub struct EiiImpl { /// /// This field is that shortcut: we prefill the extern target to skip a name resolution step, /// making sure it never fails. It'd be awful UX if we fail name resolution in code invisible to the user. - pub known_eii_macro_resolution: Option, + pub known_eii_macro_resolution: Option, pub impl_safety: Safety, pub span: Span, pub inner_span: Span, diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index 83b751fbde902..f7b8b9da32417 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -489,7 +489,7 @@ macro_rules! common_visitor_and_walkers { WhereEqPredicate, WhereRegionPredicate, YieldKind, - EiiExternTarget, + EiiDecl, EiiImpl, ); diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 3a7308ef7c97a..c8ebfb96b5583 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -2,7 +2,7 @@ use rustc_abi::ExternAbi; use rustc_ast::visit::AssocCtxt; use rustc_ast::*; use rustc_errors::{E0570, ErrorGuaranteed, struct_span_code_err}; -use rustc_hir::attrs::{AttributeKind, EiiDecl, EiiImplResolution}; +use rustc_hir::attrs::{AttributeKind, EiiImplResolution}; use rustc_hir::def::{DefKind, PerNS, Res}; use rustc_hir::def_id::{CRATE_DEF_ID, LocalDefId}; use rustc_hir::{ @@ -134,16 +134,16 @@ impl<'hir> LoweringContext<'_, 'hir> { } } - fn lower_eii_extern_target( + fn lower_eii_decl( &mut self, id: NodeId, - eii_name: Ident, - EiiExternTarget { extern_item_path, impl_unsafe }: &EiiExternTarget, - ) -> Option { - self.lower_path_simple_eii(id, extern_item_path).map(|did| EiiDecl { - eii_extern_target: did, + name: Ident, + EiiDecl { foreign_item, impl_unsafe }: &EiiDecl, + ) -> Option { + self.lower_path_simple_eii(id, foreign_item).map(|did| hir::attrs::EiiDecl { + foreign_item: did, impl_unsafe: *impl_unsafe, - name: eii_name, + name, }) } @@ -160,7 +160,7 @@ impl<'hir> LoweringContext<'_, 'hir> { }: &EiiImpl, ) -> hir::attrs::EiiImpl { let resolution = if let Some(target) = known_eii_macro_resolution - && let Some(decl) = self.lower_eii_extern_target( + && let Some(decl) = self.lower_eii_decl( *node_id, // the expect is ok here since we always generate this path in the eii macro. eii_macro_path.segments.last().expect("at least one segment").ident, @@ -196,9 +196,9 @@ impl<'hir> LoweringContext<'_, 'hir> { eii_impls.iter().map(|i| self.lower_eii_impl(i)).collect(), ))] } - ItemKind::MacroDef(name, MacroDef { eii_extern_target: Some(target), .. }) => self - .lower_eii_extern_target(id, *name, target) - .map(|decl| vec![hir::Attribute::Parsed(AttributeKind::EiiExternTarget(decl))]) + ItemKind::MacroDef(name, MacroDef { eii_declaration: Some(target), .. }) => self + .lower_eii_decl(id, *name, target) + .map(|decl| vec![hir::Attribute::Parsed(AttributeKind::EiiDeclaration(decl))]) .unwrap_or_default(), ItemKind::ExternCrate(..) @@ -242,10 +242,7 @@ impl<'hir> LoweringContext<'_, 'hir> { vis_span, span: self.lower_span(i.span), has_delayed_lints: !self.delayed_lints.is_empty(), - eii: find_attr!( - attrs, - AttributeKind::EiiImpls(..) | AttributeKind::EiiExternTarget(..) - ), + eii: find_attr!(attrs, AttributeKind::EiiImpls(..) | AttributeKind::EiiDeclaration(..)), }; self.arena.alloc(item) } @@ -539,7 +536,7 @@ impl<'hir> LoweringContext<'_, 'hir> { ); hir::ItemKind::TraitAlias(constness, ident, generics, bounds) } - ItemKind::MacroDef(ident, MacroDef { body, macro_rules, eii_extern_target: _ }) => { + ItemKind::MacroDef(ident, MacroDef { body, macro_rules, eii_declaration: _ }) => { let ident = self.lower_ident(*ident); let body = Box::new(self.lower_delim_args(body)); let def_id = self.local_def_id(id); @@ -553,7 +550,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let macro_def = self.arena.alloc(ast::MacroDef { body, macro_rules: *macro_rules, - eii_extern_target: None, + eii_declaration: None, }); hir::ItemKind::Macro(ident, macro_def, macro_kinds) } @@ -693,7 +690,7 @@ impl<'hir> LoweringContext<'_, 'hir> { has_delayed_lints: !this.delayed_lints.is_empty(), eii: find_attr!( attrs, - AttributeKind::EiiImpls(..) | AttributeKind::EiiExternTarget(..) + AttributeKind::EiiImpls(..) | AttributeKind::EiiDeclaration(..) ), }; hir::OwnerNode::Item(this.arena.alloc(item)) diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 0cf0eae821e90..e50e31c226fdb 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -865,10 +865,10 @@ pub trait PrintState<'a>: std::ops::Deref + std::ops::Dere sp: Span, print_visibility: impl FnOnce(&mut Self), ) { - if let Some(eii_extern_target) = ¯o_def.eii_extern_target { - self.word("#[eii_extern_target("); - self.print_path(&eii_extern_target.extern_item_path, false, 0); - if eii_extern_target.impl_unsafe { + if let Some(eii_decl) = ¯o_def.eii_declaration { + self.word("#[eii_declaration("); + self.print_path(&eii_decl.foreign_item, false, 0); + if eii_decl.impl_unsafe { self.word(","); self.space(); self.word("unsafe"); diff --git a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs index c68c66b271857..5bbaeda18df3f 100644 --- a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs @@ -709,11 +709,11 @@ impl NoArgsAttributeParser for RustcPassIndirectlyInNonRusticAbisPa const CREATE: fn(Span) -> AttributeKind = AttributeKind::RustcPassIndirectlyInNonRusticAbis; } -pub(crate) struct EiiExternItemParser; +pub(crate) struct EiiForeignItemParser; -impl NoArgsAttributeParser for EiiExternItemParser { - const PATH: &[Symbol] = &[sym::rustc_eii_extern_item]; +impl NoArgsAttributeParser for EiiForeignItemParser { + const PATH: &[Symbol] = &[sym::rustc_eii_foreign_item]; const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error; const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::ForeignFn)]); - const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::EiiExternItem; + const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::EiiForeignItem; } diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 835bf8ae5c9c4..00921cf54cd87 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -21,7 +21,7 @@ use crate::attributes::allow_unstable::{ use crate::attributes::body::CoroutineParser; use crate::attributes::cfi_encoding::CfiEncodingParser; use crate::attributes::codegen_attrs::{ - ColdParser, CoverageParser, EiiExternItemParser, ExportNameParser, ForceTargetFeatureParser, + ColdParser, CoverageParser, EiiForeignItemParser, ExportNameParser, ForceTargetFeatureParser, NakedParser, NoMangleParser, ObjcClassParser, ObjcSelectorParser, OptimizeParser, RustcPassIndirectlyInNonRusticAbisParser, SanitizeParser, TargetFeatureParser, ThreadLocalParser, TrackCallerParser, UsedParser, @@ -243,7 +243,7 @@ attribute_parsers!( Single>, Single>, Single>, - Single>, + Single>, Single>, Single>, Single>, diff --git a/compiler/rustc_builtin_macros/messages.ftl b/compiler/rustc_builtin_macros/messages.ftl index e4fded0cb01e1..1501bd6c73e29 100644 --- a/compiler/rustc_builtin_macros/messages.ftl +++ b/compiler/rustc_builtin_macros/messages.ftl @@ -151,9 +151,9 @@ builtin_macros_derive_path_args_value = traits in `#[derive(...)]` don't accept builtin_macros_duplicate_macro_attribute = duplicated attribute -builtin_macros_eii_extern_target_expected_list = `#[eii_extern_target(...)]` expects a list of one or two elements -builtin_macros_eii_extern_target_expected_macro = `#[eii_extern_target(...)]` is only valid on macros -builtin_macros_eii_extern_target_expected_unsafe = expected this argument to be "unsafe" +builtin_macros_eii_declaration_expected_list = `#[eii_declaration(...)]` expects a list of one or two elements +builtin_macros_eii_declaration_expected_macro = `#[eii_declaration(...)]` is only valid on macros +builtin_macros_eii_declaration_expected_unsafe = expected this argument to be "unsafe" .note = the second argument is optional builtin_macros_eii_only_once = `#[{$name}]` can only be specified once diff --git a/compiler/rustc_builtin_macros/src/eii.rs b/compiler/rustc_builtin_macros/src/eii.rs index a5009b3bfa52f..cec7599d68e9c 100644 --- a/compiler/rustc_builtin_macros/src/eii.rs +++ b/compiler/rustc_builtin_macros/src/eii.rs @@ -1,7 +1,7 @@ use rustc_ast::token::{Delimiter, TokenKind}; use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree}; use rustc_ast::{ - Attribute, DUMMY_NODE_ID, EiiExternTarget, EiiImpl, ItemKind, MetaItem, Path, Stmt, StmtKind, + Attribute, DUMMY_NODE_ID, EiiDecl, EiiImpl, ItemKind, MetaItem, Path, Stmt, StmtKind, Visibility, ast, }; use rustc_ast_pretty::pprust::path_to_string; @@ -30,7 +30,7 @@ use crate::errors::{ /// } /// /// #[rustc_builtin_macro(eii_shared_macro)] -/// #[eii_extern_target(panic_handler)] +/// #[eii_declaration(panic_handler)] /// macro panic_handler() {} /// ``` pub(crate) fn eii( @@ -210,8 +210,8 @@ fn generate_default_impl( }, span: eii_attr_span, is_default: true, - known_eii_macro_resolution: Some(ast::EiiExternTarget { - extern_item_path: ecx.path( + known_eii_macro_resolution: Some(ast::EiiDecl { + foreign_item: ecx.path( foreign_item_name.span, // prefix super to escape the `dflt` module generated below vec![Ident::from_str_and_span("super", foreign_item_name.span), foreign_item_name], @@ -295,9 +295,9 @@ fn generate_foreign_item( let mut foreign_item_attrs = ThinVec::new(); foreign_item_attrs.extend_from_slice(attrs_from_decl); - // Add the rustc_eii_extern_item on the foreign item. Usually, foreign items are mangled. + // Add the rustc_eii_foreign_item on the foreign item. Usually, foreign items are mangled. // This attribute makes sure that we later know that this foreign item's symbol should not be. - foreign_item_attrs.push(ecx.attr_word(sym::rustc_eii_extern_item, eii_attr_span)); + foreign_item_attrs.push(ecx.attr_word(sym::rustc_eii_foreign_item, eii_attr_span)); let abi = match func.sig.header.ext { // extern "X" fn => extern "X" {} @@ -349,7 +349,7 @@ fn generate_foreign_item( /// // This attribute tells the compiler that /// #[builtin_macro(eii_shared_macro)] /// // the metadata to link this macro to the generated foreign item. -/// #[eii_extern_target()] +/// #[eii_declaration()] /// macro macro_name { () => {} } /// ``` fn generate_attribute_macro_to_implement( @@ -401,9 +401,9 @@ fn generate_attribute_macro_to_implement( ]), }), macro_rules: false, - // #[eii_extern_target(foreign_item_ident)] - eii_extern_target: Some(ast::EiiExternTarget { - extern_item_path: ast::Path::from_ident(foreign_item_name), + // #[eii_declaration(foreign_item_ident)] + eii_declaration: Some(ast::EiiDecl { + foreign_item: ast::Path::from_ident(foreign_item_name), impl_unsafe, }), }, @@ -412,7 +412,7 @@ fn generate_attribute_macro_to_implement( }) } -pub(crate) fn eii_extern_target( +pub(crate) fn eii_declaration( ecx: &mut ExtCtxt<'_>, span: Span, meta_item: &ast::MetaItem, @@ -461,7 +461,7 @@ pub(crate) fn eii_extern_target( false }; - d.eii_extern_target = Some(EiiExternTarget { extern_item_path, impl_unsafe }); + d.eii_declaration = Some(EiiDecl { foreign_item: extern_item_path, impl_unsafe }); // Return the original item and the new methods. vec![item] diff --git a/compiler/rustc_builtin_macros/src/errors.rs b/compiler/rustc_builtin_macros/src/errors.rs index e673ad3f8a647..5d4c4e340fa1f 100644 --- a/compiler/rustc_builtin_macros/src/errors.rs +++ b/compiler/rustc_builtin_macros/src/errors.rs @@ -1010,21 +1010,21 @@ pub(crate) struct CfgSelectUnreachable { } #[derive(Diagnostic)] -#[diag(builtin_macros_eii_extern_target_expected_macro)] +#[diag(builtin_macros_eii_declaration_expected_macro)] pub(crate) struct EiiExternTargetExpectedMacro { #[primary_span] pub span: Span, } #[derive(Diagnostic)] -#[diag(builtin_macros_eii_extern_target_expected_list)] +#[diag(builtin_macros_eii_declaration_expected_list)] pub(crate) struct EiiExternTargetExpectedList { #[primary_span] pub span: Span, } #[derive(Diagnostic)] -#[diag(builtin_macros_eii_extern_target_expected_unsafe)] +#[diag(builtin_macros_eii_declaration_expected_unsafe)] pub(crate) struct EiiExternTargetExpectedUnsafe { #[primary_span] #[note] diff --git a/compiler/rustc_builtin_macros/src/lib.rs b/compiler/rustc_builtin_macros/src/lib.rs index 89ac8db760638..e1c5a4f85c1ba 100644 --- a/compiler/rustc_builtin_macros/src/lib.rs +++ b/compiler/rustc_builtin_macros/src/lib.rs @@ -119,7 +119,7 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) { derive: derive::Expander { is_const: false }, derive_const: derive::Expander { is_const: true }, eii: eii::eii, - eii_extern_target: eii::eii_extern_target, + eii_declaration: eii::eii_declaration, eii_shared_macro: eii::eii_shared_macro, global_allocator: global_allocator::expand, test: test::expand_test, diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index dc941cb41c562..e11ed796887a5 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -1520,7 +1520,6 @@ pub(crate) fn apply_vcall_visibility_metadata<'ll, 'tcx>( // Unwrap potential addrspacecast let vtable = find_vtable_behind_cast(vtable); let trait_ref_self = trait_ref.with_self_ty(cx.tcx, ty); - let trait_ref_self = cx.tcx.erase_and_anonymize_regions(trait_ref_self); let trait_def_id = trait_ref_self.def_id; let trait_vis = cx.tcx.visibility(trait_def_id); diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs index 7dda824e2b18a..fa02c5c51f7c1 100644 --- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs +++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs @@ -282,16 +282,16 @@ fn process_builtin_attrs( AttributeKind::ObjcSelector { methname, .. } => { codegen_fn_attrs.objc_selector = Some(*methname); } - AttributeKind::EiiExternItem => { + AttributeKind::EiiForeignItem => { codegen_fn_attrs.flags |= CodegenFnAttrFlags::EXTERNALLY_IMPLEMENTABLE_ITEM; } AttributeKind::EiiImpls(impls) => { for i in impls { - let extern_item = match i.resolution { + let foreign_item = match i.resolution { EiiImplResolution::Macro(def_id) => { let Some(extern_item) = find_attr!( tcx.get_all_attrs(def_id), - AttributeKind::EiiExternTarget(target) => target.eii_extern_target + AttributeKind::EiiDeclaration(target) => target.foreign_item ) else { tcx.dcx().span_delayed_bug( i.span, @@ -301,7 +301,7 @@ fn process_builtin_attrs( }; extern_item } - EiiImplResolution::Known(decl) => decl.eii_extern_target, + EiiImplResolution::Known(decl) => decl.foreign_item, EiiImplResolution::Error(_eg) => continue, }; @@ -316,13 +316,13 @@ fn process_builtin_attrs( // iterate over all implementations *in the current crate* // (this is ok since we generate codegen fn attrs in the local crate) // if any of them is *not default* then don't emit the alias. - && tcx.externally_implementable_items(LOCAL_CRATE).get(&extern_item).expect("at least one").1.iter().any(|(_, imp)| !imp.is_default) + && tcx.externally_implementable_items(LOCAL_CRATE).get(&foreign_item).expect("at least one").1.iter().any(|(_, imp)| !imp.is_default) { continue; } codegen_fn_attrs.foreign_item_symbol_aliases.push(( - extern_item, + foreign_item, if i.is_default { Linkage::LinkOnceAny } else { Linkage::External }, Visibility::Default, )); diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index 94832c0c25776..fe1dd1b6eb352 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -13,7 +13,7 @@ use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::mir::interpret::{CTFE_ALLOC_SALT, read_target_uint, write_target_uint}; use rustc_middle::mir::{self, BinOp, ConstValue, NonDivergingIntrinsic}; use rustc_middle::ty::layout::TyAndLayout; -use rustc_middle::ty::{FloatTy, PolyExistentialPredicate, Ty, TyCtxt, TypeFoldable}; +use rustc_middle::ty::{FloatTy, PolyExistentialPredicate, Ty, TyCtxt}; use rustc_middle::{bug, span_bug, ty}; use rustc_span::{Symbol, sym}; use rustc_trait_selection::traits::{Obligation, ObligationCause, ObligationCtxt}; @@ -243,13 +243,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { ocx.register_obligations(preds.iter().map(|pred: PolyExistentialPredicate<'_>| { let pred = pred.with_self_ty(tcx, tp_ty); // Lifetimes can only be 'static because of the bound on T - let pred = pred.fold_with(&mut ty::BottomUpFolder { - tcx, - ty_op: |ty| ty, - lt_op: |lt| { - if lt == tcx.lifetimes.re_erased { tcx.lifetimes.re_static } else { lt } - }, - ct_op: |ct| ct, + let pred = ty::fold_regions(tcx, pred, |r, _| { + if r == tcx.lifetimes.re_erased { tcx.lifetimes.re_static } else { r } }); Obligation::new(tcx, ObligationCause::dummy(), param_env, pred) })); diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index a7e8515e415f0..22753adb4c995 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -962,7 +962,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ EncodeCrossCrate::No, "allow_internal_unsafe side-steps the unsafe_code lint", ), gated!( - rustc_eii_extern_item, Normal, template!(Word), + rustc_eii_foreign_item, Normal, template!(Word), ErrorFollowing, EncodeCrossCrate::Yes, eii_internals, "used internally to mark types with a `transparent` representation when it is guaranteed by the documentation", ), diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index a5ecfa45fb408..15a668bd91994 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -43,7 +43,7 @@ pub struct EiiImpl { #[derive(Copy, Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] pub struct EiiDecl { - pub eii_extern_target: DefId, + pub foreign_item: DefId, /// whether or not it is unsafe to implement this EII pub impl_unsafe: bool, pub name: Ident, @@ -744,10 +744,10 @@ pub enum AttributeKind { Dummy, /// Implementation detail of `#[eii]` - EiiExternItem, + EiiDeclaration(EiiDecl), /// Implementation detail of `#[eii]` - EiiExternTarget(EiiDecl), + EiiForeignItem, /// Implementation detail of `#[eii]` EiiImpls(ThinVec), diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index efdb4f2f22b2e..233aee54adbb6 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -47,8 +47,8 @@ impl AttributeKind { Doc(_) => Yes, DocComment { .. } => Yes, Dummy => No, - EiiExternItem => No, - EiiExternTarget(_) => Yes, + EiiDeclaration(_) => Yes, + EiiForeignItem => No, EiiImpls(..) => No, ExportName { .. } => Yes, ExportStable => No, diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index ad66003a6bf91..4664bfcce853a 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -508,23 +508,18 @@ fn sanity_check_found_hidden_type<'tcx>( return Ok(()); } } - let strip_vars = |ty: Ty<'tcx>| { - ty.fold_with(&mut BottomUpFolder { - tcx, - ty_op: |t| t, - ct_op: |c| c, - lt_op: |l| match l.kind() { - RegionKind::ReVar(_) => tcx.lifetimes.re_erased, - _ => l, - }, + let erase_re_vars = |ty: Ty<'tcx>| { + fold_regions(tcx, ty, |r, _| match r.kind() { + RegionKind::ReVar(_) => tcx.lifetimes.re_erased, + _ => r, }) }; // Closures frequently end up containing erased lifetimes in their final representation. // These correspond to lifetime variables that never got resolved, so we patch this up here. - ty.ty = strip_vars(ty.ty); + ty.ty = erase_re_vars(ty.ty); // Get the hidden type. let hidden_ty = tcx.type_of(key.def_id).instantiate(tcx, key.args); - let hidden_ty = strip_vars(hidden_ty); + let hidden_ty = erase_re_vars(hidden_ty); // If the hidden types differ, emit a type mismatch diagnostic. if hidden_ty == ty.ty { diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 7ec4110f80b90..cfc7e57cc14e7 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -1205,7 +1205,7 @@ fn check_eiis(tcx: TyCtxt<'_>, def_id: LocalDefId) { EiiImplResolution::Macro(def_id) => { // we expect this macro to have the `EiiMacroFor` attribute, that points to a function // signature that we'd like to compare the function we're currently checking with - if let Some(foreign_item) = find_attr!(tcx.get_all_attrs(*def_id), AttributeKind::EiiExternTarget(EiiDecl {eii_extern_target: t, ..}) => *t) + if let Some(foreign_item) = find_attr!(tcx.get_all_attrs(*def_id), AttributeKind::EiiDeclaration(EiiDecl {foreign_item: t, ..}) => *t) { (foreign_item, tcx.item_name(*def_id)) } else { @@ -1213,7 +1213,7 @@ fn check_eiis(tcx: TyCtxt<'_>, def_id: LocalDefId) { continue; } } - EiiImplResolution::Known(decl) => (decl.eii_extern_target, decl.name.name), + EiiImplResolution::Known(decl) => (decl.foreign_item, decl.name.name), EiiImplResolution::Error(_eg) => continue, }; diff --git a/compiler/rustc_hir_analysis/src/delegation.rs b/compiler/rustc_hir_analysis/src/delegation.rs index 4ab13140bf9c9..cf0533c39e73f 100644 --- a/compiler/rustc_hir_analysis/src/delegation.rs +++ b/compiler/rustc_hir_analysis/src/delegation.rs @@ -135,9 +135,6 @@ fn build_generics<'tcx>( // } own_params.sort_by_key(|key| key.kind.is_ty_or_const()); - let param_def_id_to_index = - own_params.iter().map(|param| (param.def_id, param.index)).collect(); - let (parent_count, has_self) = if let Some(def_id) = parent { let parent_generics = tcx.generics_of(def_id); let parent_kind = tcx.def_kind(def_id); @@ -162,6 +159,9 @@ fn build_generics<'tcx>( } } + let param_def_id_to_index = + own_params.iter().map(|param| (param.def_id, param.index)).collect(); + ty::Generics { parent, parent_count, diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index 1dd9bff425759..4f610d2512a43 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -2502,11 +2502,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { let tcx = self.tcx(); let FeedConstTy::WithTy(ty) = feed else { - return Const::new_error_with_message(tcx, span, "unsupported const tuple"); + return Const::new_error_with_message(tcx, span, "const tuple lack type information"); }; let ty::Tuple(tys) = ty.kind() else { - return Const::new_error_with_message(tcx, span, "const tuple must have a tuple type"); + let e = tcx.dcx().span_err(span, format!("expected `{}`, found const tuple", ty)); + return Const::new_error(tcx, e); }; let exprs = exprs diff --git a/compiler/rustc_metadata/src/eii.rs b/compiler/rustc_metadata/src/eii.rs index b06ac84813975..42497a82ef8c0 100644 --- a/compiler/rustc_metadata/src/eii.rs +++ b/compiler/rustc_metadata/src/eii.rs @@ -31,9 +31,9 @@ pub(crate) fn collect<'tcx>(tcx: TyCtxt<'tcx>, LocalCrate: LocalCrate) -> EiiMap let decl = match i.resolution { EiiImplResolution::Macro(macro_defid) => { // find the decl for this one if it wasn't in yet (maybe it's from the local crate? not very useful but not illegal) - let Some(decl) = find_attr!(tcx.get_all_attrs(macro_defid), AttributeKind::EiiExternTarget(d) => *d) + let Some(decl) = find_attr!(tcx.get_all_attrs(macro_defid), AttributeKind::EiiDeclaration(d) => *d) else { - // skip if it doesn't have eii_extern_target (if we resolved to another macro that's not an EII) + // skip if it doesn't have eii_declaration (if we resolved to another macro that's not an EII) tcx.dcx() .span_delayed_bug(i.span, "resolved to something that's not an EII"); continue; @@ -45,7 +45,7 @@ pub(crate) fn collect<'tcx>(tcx: TyCtxt<'tcx>, LocalCrate: LocalCrate) -> EiiMap }; // FIXME(eii) remove extern target from encoded decl - eiis.entry(decl.eii_extern_target) + eiis.entry(decl.foreign_item) .or_insert_with(|| (decl, Default::default())) .1 .insert(id.into(), *i); @@ -53,9 +53,9 @@ pub(crate) fn collect<'tcx>(tcx: TyCtxt<'tcx>, LocalCrate: LocalCrate) -> EiiMap // if we find a new declaration, add it to the list without a known implementation if let Some(decl) = - find_attr!(tcx.get_all_attrs(id), AttributeKind::EiiExternTarget(d) => *d) + find_attr!(tcx.get_all_attrs(id), AttributeKind::EiiDeclaration(d) => *d) { - eiis.entry(decl.eii_extern_target).or_insert((decl, Default::default())); + eiis.entry(decl.foreign_item).or_insert((decl, Default::default())); } } diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index f8610f0c5b034..c7423386a771d 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1536,7 +1536,7 @@ impl<'a> CrateMetadataRef<'a> { .get((self, tcx), id) .unwrap() .decode((self, tcx)); - ast::MacroDef { macro_rules, body: Box::new(body), eii_extern_target: None } + ast::MacroDef { macro_rules, body: Box::new(body), eii_declaration: None } } _ => bug!(), } diff --git a/compiler/rustc_middle/src/hooks/mod.rs b/compiler/rustc_middle/src/hooks/mod.rs index dc6a3334a4c8b..c926604a41952 100644 --- a/compiler/rustc_middle/src/hooks/mod.rs +++ b/compiler/rustc_middle/src/hooks/mod.rs @@ -102,6 +102,11 @@ declare_hooks! { /// Ensure the given scalar is valid for the given type. /// This checks non-recursive runtime validity. hook validate_scalar_in_layout(scalar: crate::ty::ScalarInt, ty: Ty<'tcx>) -> bool; + + /// **Do not call this directly; call the `mir_built` query instead.** + /// + /// Creates the MIR for a given `DefId`, including unreachable code. + hook build_mir_inner_impl(def: LocalDefId) -> mir::Body<'tcx>; } #[cold] diff --git a/compiler/rustc_mir_build/src/builder/mod.rs b/compiler/rustc_mir_build/src/builder/mod.rs index 40f1fe0d5d11e..75c6df842b50b 100644 --- a/compiler/rustc_mir_build/src/builder/mod.rs +++ b/compiler/rustc_mir_build/src/builder/mod.rs @@ -64,9 +64,11 @@ pub(crate) fn closure_saved_names_of_captured_variables<'tcx>( .collect() } -/// Create the MIR for a given `DefId`, including unreachable code. Do not call -/// this directly; instead use the cached version via `mir_built`. -pub fn build_mir<'tcx>(tcx: TyCtxt<'tcx>, def: LocalDefId) -> Body<'tcx> { +/// Create the MIR for a given `DefId`, including unreachable code. +/// +/// This is the implementation of hook `build_mir_inner_impl`, which should only +/// be called by the query `mir_built`. +pub(crate) fn build_mir_inner_impl<'tcx>(tcx: TyCtxt<'tcx>, def: LocalDefId) -> Body<'tcx> { tcx.ensure_done().thir_abstract_const(def); if let Err(e) = tcx.ensure_ok().check_match(def) { return construct_error(tcx, def, e); diff --git a/compiler/rustc_mir_build/src/lib.rs b/compiler/rustc_mir_build/src/lib.rs index 8c7003b778761..410ea791ac5ca 100644 --- a/compiler/rustc_mir_build/src/lib.rs +++ b/compiler/rustc_mir_build/src/lib.rs @@ -12,7 +12,7 @@ // The `builder` module used to be named `build`, but that was causing GitHub's // "Go to file" feature to silently ignore all files in the module, probably // because it assumes that "build" is a build-output directory. See #134365. -pub mod builder; +mod builder; mod check_tail_calls; mod check_unsafety; mod errors; @@ -30,4 +30,5 @@ pub fn provide(providers: &mut Providers) { providers.check_unsafety = check_unsafety::check_unsafety; providers.check_tail_calls = check_tail_calls::check_tail_calls; providers.thir_body = thir::cx::thir_body; + providers.hooks.build_mir_inner_impl = builder::build_mir_inner_impl; } diff --git a/compiler/rustc_mir_transform/Cargo.toml b/compiler/rustc_mir_transform/Cargo.toml index 511c1960e40b4..6df7a869ca28d 100644 --- a/compiler/rustc_mir_transform/Cargo.toml +++ b/compiler/rustc_mir_transform/Cargo.toml @@ -20,7 +20,6 @@ rustc_index = { path = "../rustc_index" } rustc_infer = { path = "../rustc_infer" } rustc_macros = { path = "../rustc_macros" } rustc_middle = { path = "../rustc_middle" } -rustc_mir_build = { path = "../rustc_mir_build" } rustc_mir_dataflow = { path = "../rustc_mir_dataflow" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 701d7ff854a75..c78b0adaf6f18 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -30,7 +30,6 @@ use rustc_middle::mir::{ use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt}; use rustc_middle::util::Providers; use rustc_middle::{bug, query, span_bug}; -use rustc_mir_build::builder::build_mir; use rustc_span::source_map::Spanned; use rustc_span::{DUMMY_SP, sym}; use tracing::debug; @@ -378,8 +377,11 @@ fn mir_const_qualif(tcx: TyCtxt<'_>, def: LocalDefId) -> ConstQualifs { validator.qualifs_in_return_place() } +/// Implementation of the `mir_built` query. fn mir_built(tcx: TyCtxt<'_>, def: LocalDefId) -> &Steal> { - let mut body = build_mir(tcx, def); + // Delegate to the main MIR building code in the `rustc_mir_build` crate. + // This is the one place that is allowed to call `build_mir_inner_impl`. + let mut body = tcx.build_mir_inner_impl(def); // Identifying trivial consts based on their mir_built is easy, but a little wasteful. // Trying to push this logic earlier in the compiler and never even produce the Body would diff --git a/compiler/rustc_next_trait_solver/src/delegate.rs b/compiler/rustc_next_trait_solver/src/delegate.rs index 41c2e5f60ec39..9d5aa8bc124b6 100644 --- a/compiler/rustc_next_trait_solver/src/delegate.rs +++ b/compiler/rustc_next_trait_solver/src/delegate.rs @@ -86,8 +86,8 @@ pub trait SolverDelegate: Deref + Sized { fn is_transmutable( &self, - dst: ::Ty, src: ::Ty, + dst: ::Ty, assume: ::Const, ) -> Result; } diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs index 2fd79f593a5f5..6841fe1c5124e 100644 --- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs @@ -1170,8 +1170,8 @@ where pub(super) fn is_transmutable( &mut self, - dst: I::Ty, src: I::Ty, + dst: I::Ty, assume: I::Const, ) -> Result { self.delegate.is_transmutable(dst, src, assume) diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 26f60c96aed6b..cdcdaa342a5d0 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -2283,7 +2283,7 @@ impl<'a> Parser<'a> { self.psess.gated_spans.gate(sym::decl_macro, lo.to(self.prev_token.span)); Ok(ItemKind::MacroDef( ident, - ast::MacroDef { body, macro_rules: false, eii_extern_target: None }, + ast::MacroDef { body, macro_rules: false, eii_declaration: None }, )) } @@ -2333,7 +2333,7 @@ impl<'a> Parser<'a> { Ok(ItemKind::MacroDef( ident, - ast::MacroDef { body, macro_rules: true, eii_extern_target: None }, + ast::MacroDef { body, macro_rules: true, eii_declaration: None }, )) } diff --git a/compiler/rustc_parse_format/src/lib.rs b/compiler/rustc_parse_format/src/lib.rs index 143fd0c4436cb..490af1257760d 100644 --- a/compiler/rustc_parse_format/src/lib.rs +++ b/compiler/rustc_parse_format/src/lib.rs @@ -461,6 +461,7 @@ impl<'input> Parser<'input> { ('?', '}') => self.missing_colon_before_debug_formatter(), ('?', _) => self.suggest_format_debug(), ('<' | '^' | '>', _) => self.suggest_format_align(c), + (',', _) => self.suggest_unsupported_python_numeric_grouping(), _ => self.suggest_positional_arg_instead_of_captured_arg(arg), } } @@ -934,6 +935,27 @@ impl<'input> Parser<'input> { } } } + + fn suggest_unsupported_python_numeric_grouping(&mut self) { + if let Some((range, _)) = self.consume_pos(',') { + self.errors.insert( + 0, + ParseError { + description: + "python's numeric grouping `,` is not supported in rust format strings" + .to_owned(), + note: Some(format!("to print `{{`, you can escape it using `{{{{`",)), + label: "expected `}`".to_owned(), + span: range, + secondary_label: self + .last_open_brace + .clone() + .map(|sp| ("because of this opening brace".to_owned(), sp)), + suggestion: Suggestion::None, + }, + ); + } + } } // Assert a reasonable size for `Piece` diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 717a0e54d0c6e..1d48785169d74 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -224,8 +224,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> { self.check_rustc_must_implement_one_of(*attr_span, fn_names, hir_id,target) }, Attribute::Parsed( - AttributeKind::EiiExternTarget { .. } - | AttributeKind::EiiExternItem + AttributeKind::EiiDeclaration { .. } + | AttributeKind::EiiForeignItem | AttributeKind::BodyStability { .. } | AttributeKind::ConstStabilityIndirect | AttributeKind::MacroTransparency(_) @@ -553,7 +553,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } if let EiiImplResolution::Macro(eii_macro) = resolution - && find_attr!(self.tcx.get_all_attrs(*eii_macro), AttributeKind::EiiExternTarget(EiiDecl { impl_unsafe, .. }) if *impl_unsafe) + && find_attr!(self.tcx.get_all_attrs(*eii_macro), AttributeKind::EiiDeclaration(EiiDecl { impl_unsafe, .. }) if *impl_unsafe) && !impl_marked_unsafe { self.dcx().emit_err(errors::EiiImplRequiresUnsafe { diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 4d2ba73c9cab3..6d00976317729 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -1079,7 +1079,7 @@ impl<'ast, 'ra, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'ra, 'tc self.smart_resolve_path( *node_id, &None, - &target.extern_item_path, + &target.foreign_item, PathSource::Expr(None), ); } else { @@ -2931,8 +2931,8 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { self.parent_scope.macro_rules = self.r.macro_rules_scopes[&def_id]; } - if let Some(EiiExternTarget { extern_item_path, impl_unsafe: _ }) = - ¯o_def.eii_extern_target + if let Some(EiiDecl { foreign_item: extern_item_path, impl_unsafe: _ }) = + ¯o_def.eii_declaration { self.smart_resolve_path( item.id, diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index b473d36a45fcb..f56c3421ce0f5 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -935,7 +935,7 @@ symbols! { eh_catch_typeinfo, eh_personality, eii, - eii_extern_target, + eii_declaration, eii_impl, eii_internals, eii_shared_macro, @@ -1951,7 +1951,7 @@ symbols! { rustc_dump_user_args, rustc_dump_vtable, rustc_effective_visibility, - rustc_eii_extern_item, + rustc_eii_foreign_item, rustc_evaluate_where_clauses, rustc_expected_cgu_reuse, rustc_force_inline, diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 0f021946e06a0..8762607edf5dc 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -2781,11 +2781,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { self.tcx.instantiate_bound_regions_with_erased(trait_pred), ); - let src_and_dst = rustc_transmute::Types { - dst: trait_pred.trait_ref.args.type_at(0), - src: trait_pred.trait_ref.args.type_at(1), - }; - let ocx = ObligationCtxt::new(self); let Ok(assume) = ocx.structurally_normalize_const( &obligation.cause, @@ -2812,7 +2807,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let err_msg = format!("`{src}` cannot be safely transmuted into `{dst}`"); match rustc_transmute::TransmuteTypeEnv::new(self.infcx.tcx) - .is_transmutable(src_and_dst, assume) + .is_transmutable(src, dst, assume) { Answer::No(reason) => { let safe_transmute_explanation = match reason { diff --git a/compiler/rustc_trait_selection/src/solve/delegate.rs b/compiler/rustc_trait_selection/src/solve/delegate.rs index b6bdf1067a35e..62572694de326 100644 --- a/compiler/rustc_trait_selection/src/solve/delegate.rs +++ b/compiler/rustc_trait_selection/src/solve/delegate.rs @@ -294,8 +294,8 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate< // register candidates. We probably need to register >1 since we may have an OR of ANDs. fn is_transmutable( &self, - dst: Ty<'tcx>, src: Ty<'tcx>, + dst: Ty<'tcx>, assume: ty::Const<'tcx>, ) -> Result { // Erase regions because we compute layouts in `rustc_transmute`, @@ -307,9 +307,7 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate< }; // FIXME(transmutability): This really should be returning nested goals for `Answer::If*` - match rustc_transmute::TransmuteTypeEnv::new(self.0.tcx) - .is_transmutable(rustc_transmute::Types { src, dst }, assume) - { + match rustc_transmute::TransmuteTypeEnv::new(self.0.tcx).is_transmutable(src, dst, assume) { rustc_transmute::Answer::Yes => Ok(Certainty::Yes), rustc_transmute::Answer::No(_) | rustc_transmute::Answer::If(_) => Err(NoSolution), } diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 20a8842f2e8e5..4f65b30775ed0 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -365,8 +365,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { debug!(?src, ?dst); let mut transmute_env = rustc_transmute::TransmuteTypeEnv::new(self.infcx.tcx); - let maybe_transmutable = - transmute_env.is_transmutable(rustc_transmute::Types { dst, src }, assume); + let maybe_transmutable = transmute_env.is_transmutable(src, dst, assume); let fully_flattened = match maybe_transmutable { Answer::No(_) => Err(SelectionError::Unimplemented)?, diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs index 08ae561c972c9..732881f12d2cb 100644 --- a/compiler/rustc_transmute/src/lib.rs +++ b/compiler/rustc_transmute/src/lib.rs @@ -93,15 +93,6 @@ mod rustc { use super::*; - /// The source and destination types of a transmutation. - #[derive(Debug, Clone, Copy)] - pub struct Types<'tcx> { - /// The source type. - pub src: Ty<'tcx>, - /// The destination type. - pub dst: Ty<'tcx>, - } - pub struct TransmuteTypeEnv<'tcx> { tcx: TyCtxt<'tcx>, } @@ -113,13 +104,12 @@ mod rustc { pub fn is_transmutable( &mut self, - types: Types<'tcx>, + src: Ty<'tcx>, + dst: Ty<'tcx>, assume: crate::Assume, ) -> crate::Answer, Ty<'tcx>> { - crate::maybe_transmutable::MaybeTransmutableQuery::new( - types.src, types.dst, assume, self.tcx, - ) - .answer() + crate::maybe_transmutable::MaybeTransmutableQuery::new(src, dst, assume, self.tcx) + .answer() } } diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index 23bbd9ca6d639..cbe15eb54787f 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -222,8 +222,6 @@ fn resolve_associated_item<'tcx>( return Err(guar); } - let args = tcx.erase_and_anonymize_regions(args); - // We check that the impl item is compatible with the trait item // because otherwise we may ICE in const eval due to type mismatches, // signature incompatibilities, etc. diff --git a/compiler/rustc_type_ir/src/flags.rs b/compiler/rustc_type_ir/src/flags.rs index 2c1fc7decc3e7..8b057e5866cd9 100644 --- a/compiler/rustc_type_ir/src/flags.rs +++ b/compiler/rustc_type_ir/src/flags.rs @@ -74,7 +74,7 @@ bitflags::bitflags! { /// Does this have `Projection`? const HAS_TY_PROJECTION = 1 << 10; /// Does this have `Free` aliases? - const HAS_TY_FREE_ALIAS = 1 << 11; + const HAS_TY_FREE_ALIAS = 1 << 11; /// Does this have `Opaque`? const HAS_TY_OPAQUE = 1 << 12; /// Does this have `Inherent`? @@ -135,7 +135,7 @@ bitflags::bitflags! { const HAS_TY_CORO = 1 << 24; /// Does this have have a `Bound(BoundVarIndexKind::Canonical, _)`? - const HAS_CANONICAL_BOUND = 1 << 25; + const HAS_CANONICAL_BOUND = 1 << 25; } } diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index 338c5688bf100..a437a4795481c 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -1912,7 +1912,7 @@ pub(crate) mod builtin { /// Impl detail of EII #[unstable(feature = "eii_internals", issue = "none")] #[rustc_builtin_macro] - pub macro eii_extern_target($item:item) { + pub macro eii_declaration($item:item) { /* compiler built-in */ } } diff --git a/library/core/src/prelude/v1.rs b/library/core/src/prelude/v1.rs index a5d9a5352dfcf..7e0a84df5118d 100644 --- a/library/core/src/prelude/v1.rs +++ b/library/core/src/prelude/v1.rs @@ -122,4 +122,4 @@ pub use crate::macros::builtin::define_opaque; pub use crate::macros::builtin::{eii, unsafe_eii}; #[unstable(feature = "eii_internals", issue = "none")] -pub use crate::macros::builtin::eii_extern_target; +pub use crate::macros::builtin::eii_declaration; diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs index 63f75ea8a8819..0f0841379b297 100644 --- a/library/std/src/prelude/v1.rs +++ b/library/std/src/prelude/v1.rs @@ -114,7 +114,7 @@ pub use core::prelude::v1::define_opaque; pub use core::prelude::v1::{eii, unsafe_eii}; #[unstable(feature = "eii_internals", issue = "none")] -pub use core::prelude::v1::eii_extern_target; +pub use core::prelude::v1::eii_declaration; // The file so far is equivalent to core/src/prelude/v1.rs. It is duplicated // rather than glob imported because we want docs to show these re-exports as diff --git a/library/std/src/sys/net/connection/uefi/tcp4.rs b/library/std/src/sys/net/connection/uefi/tcp4.rs index 00c93384e5f67..ac38dd901e4d3 100644 --- a/library/std/src/sys/net/connection/uefi/tcp4.rs +++ b/library/std/src/sys/net/connection/uefi/tcp4.rs @@ -248,7 +248,7 @@ impl Tcp4 { fragment_table: [fragment], }; - self.read_inner((&raw mut rx_data).cast(), timeout).map(|_| data_len as usize) + self.read_inner((&raw mut rx_data).cast(), timeout) } pub(crate) fn read_vectored( @@ -288,14 +288,14 @@ impl Tcp4 { ); }; - self.read_inner(rx_data.as_mut_ptr(), timeout).map(|_| data_length as usize) + self.read_inner(rx_data.as_mut_ptr(), timeout) } pub(crate) fn read_inner( &self, rx_data: *mut tcp4::ReceiveData, timeout: Option, - ) -> io::Result<()> { + ) -> io::Result { let evt = unsafe { self.create_evt() }?; let completion_token = tcp4::CompletionToken { event: evt.as_ptr(), status: Status::SUCCESS }; @@ -313,7 +313,8 @@ impl Tcp4 { if completion_token.status.is_error() { Err(io::Error::from_raw_os_error(completion_token.status.as_usize())) } else { - Ok(()) + let data_length = unsafe { (*rx_data).data_length }; + Ok(data_length as usize) } } diff --git a/rust-bors.toml b/rust-bors.toml index 0d59918e3f774..ad1100fd24219 100644 --- a/rust-bors.toml +++ b/rust-bors.toml @@ -55,7 +55,8 @@ try_failed = [ "-S-waiting-on-crater" ] auto_build_succeeded = [ - "+merged-by-bors" + "+merged-by-bors", + "-S-waiting-on-bors" ] auto_build_failed = [ "+S-waiting-on-review", diff --git a/src/tools/clippy/clippy_lints/src/matches/significant_drop_in_scrutinee.rs b/src/tools/clippy/clippy_lints/src/matches/significant_drop_in_scrutinee.rs index bac35e7f8c700..14d265bfdad87 100644 --- a/src/tools/clippy/clippy_lints/src/matches/significant_drop_in_scrutinee.rs +++ b/src/tools/clippy/clippy_lints/src/matches/significant_drop_in_scrutinee.rs @@ -12,7 +12,7 @@ use rustc_errors::{Applicability, Diag}; use rustc_hir::intravisit::{Visitor, walk_expr}; use rustc_hir::{Arm, Expr, ExprKind, MatchSource}; use rustc_lint::{LateContext, LintContext}; -use rustc_middle::ty::{GenericArgKind, Region, RegionKind, Ty, TyCtxt, TypeVisitable, TypeVisitor}; +use rustc_middle::ty::{GenericArgKind, RegionKind, Ty, TypeVisitableExt}; use rustc_span::Span; use super::SIGNIFICANT_DROP_IN_SCRUTINEE; @@ -303,13 +303,13 @@ impl<'a, 'tcx> SigDropHelper<'a, 'tcx> { if self.sig_drop_holder != SigDropHolder::None { let parent_ty = self.cx.typeck_results().expr_ty(parent_expr); - if !ty_has_erased_regions(parent_ty) && !parent_expr.is_syntactic_place_expr() { + if !parent_ty.has_erased_regions() && !parent_expr.is_syntactic_place_expr() { self.replace_current_sig_drop(parent_expr.span, parent_ty.is_unit(), 0); self.sig_drop_holder = SigDropHolder::Moved; } let (peel_ref_ty, peel_ref_times) = ty_peel_refs(parent_ty); - if !ty_has_erased_regions(peel_ref_ty) && is_copy(self.cx, peel_ref_ty) { + if !peel_ref_ty.has_erased_regions() && is_copy(self.cx, peel_ref_ty) { self.replace_current_sig_drop(parent_expr.span, peel_ref_ty.is_unit(), peel_ref_times); self.sig_drop_holder = SigDropHolder::Moved; } @@ -399,24 +399,6 @@ fn ty_peel_refs(mut ty: Ty<'_>) -> (Ty<'_>, usize) { (ty, n) } -fn ty_has_erased_regions(ty: Ty<'_>) -> bool { - struct V; - - impl<'tcx> TypeVisitor> for V { - type Result = ControlFlow<()>; - - fn visit_region(&mut self, region: Region<'tcx>) -> Self::Result { - if region.is_erased() { - ControlFlow::Break(()) - } else { - ControlFlow::Continue(()) - } - } - } - - ty.visit_with(&mut V).is_break() -} - impl<'tcx> Visitor<'tcx> for SigDropHelper<'_, 'tcx> { fn visit_expr(&mut self, ex: &'tcx Expr<'_>) { // We've emitted a lint on some neighborhood expression. That lint will suggest to move out the diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/solver.rs b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/solver.rs index 21fbd64dd066e..15d6e2e4516eb 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/solver.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/next_solver/solver.rs @@ -232,8 +232,8 @@ impl<'db> SolverDelegate for SolverContext<'db> { fn is_transmutable( &self, - _dst: Ty<'db>, _src: Ty<'db>, + _dst: Ty<'db>, _assume: ::Const, ) -> Result { // It's better to return some value while not fully implement diff --git a/tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_complex.rs b/tests/ui/const-generics/mgca/tuple_expr_arg_complex.rs similarity index 100% rename from tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_complex.rs rename to tests/ui/const-generics/mgca/tuple_expr_arg_complex.rs diff --git a/tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_complex.stderr b/tests/ui/const-generics/mgca/tuple_expr_arg_complex.stderr similarity index 77% rename from tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_complex.stderr rename to tests/ui/const-generics/mgca/tuple_expr_arg_complex.stderr index dbc64a1bf59d3..b294e1032ce8f 100644 --- a/tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_complex.stderr +++ b/tests/ui/const-generics/mgca/tuple_expr_arg_complex.stderr @@ -1,23 +1,23 @@ error: complex const arguments must be placed inside of a `const` block - --> $DIR/adt_expr_arg_tuple_expr_complex.rs:13:25 + --> $DIR/tuple_expr_arg_complex.rs:13:25 | LL | takes_tuple::<{ (N, N + 1) }>(); | ^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/adt_expr_arg_tuple_expr_complex.rs:14:25 + --> $DIR/tuple_expr_arg_complex.rs:14:25 | LL | takes_tuple::<{ (N, T::ASSOC + 1) }>(); | ^^^^^^^^^^^^ error: complex const arguments must be placed inside of a `const` block - --> $DIR/adt_expr_arg_tuple_expr_complex.rs:16:36 + --> $DIR/tuple_expr_arg_complex.rs:16:36 | LL | takes_nested_tuple::<{ (N, (N, N + 1)) }>(); | ^^^^^ error: generic parameters may not be used in const operations - --> $DIR/adt_expr_arg_tuple_expr_complex.rs:17:44 + --> $DIR/tuple_expr_arg_complex.rs:17:44 | LL | takes_nested_tuple::<{ (N, (N, const { N + 1 })) }>(); | ^ diff --git a/tests/ui/const-generics/mgca/tuple_expr_arg_mismatch_type.rs b/tests/ui/const-generics/mgca/tuple_expr_arg_mismatch_type.rs new file mode 100644 index 0000000000000..95acd66074f6f --- /dev/null +++ b/tests/ui/const-generics/mgca/tuple_expr_arg_mismatch_type.rs @@ -0,0 +1,8 @@ +#![feature(min_generic_const_args)] +#![expect(incomplete_features)] + +pub fn takes_nested_tuple() { + takes_nested_tuple::<{ () }> //~ ERROR expected `u32`, found const tuple +} + +fn main() {} diff --git a/tests/ui/const-generics/mgca/tuple_expr_arg_mismatch_type.stderr b/tests/ui/const-generics/mgca/tuple_expr_arg_mismatch_type.stderr new file mode 100644 index 0000000000000..dfbd294951fdc --- /dev/null +++ b/tests/ui/const-generics/mgca/tuple_expr_arg_mismatch_type.stderr @@ -0,0 +1,8 @@ +error: expected `u32`, found const tuple + --> $DIR/tuple_expr_arg_mismatch_type.rs:5:28 + | +LL | takes_nested_tuple::<{ () }> + | ^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_simple.rs b/tests/ui/const-generics/mgca/tuple_expr_arg_simple.rs similarity index 100% rename from tests/ui/const-generics/mgca/adt_expr_arg_tuple_expr_simple.rs rename to tests/ui/const-generics/mgca/tuple_expr_arg_simple.rs diff --git a/tests/ui/delegation/ice-issue-150673.rs b/tests/ui/delegation/ice-issue-150673.rs new file mode 100644 index 0000000000000..7f041d3ce2570 --- /dev/null +++ b/tests/ui/delegation/ice-issue-150673.rs @@ -0,0 +1,21 @@ +#![feature(fn_delegation)] +#![allow(incomplete_features)] + +mod to_reuse { + pub fn foo() -> T { + unimplemented!() + } +} + +struct S(T); + +trait Trait { + reuse to_reuse::foo; +} + +impl Trait for S { +//~^ ERROR: missing generics for struct `S` + reuse Trait::foo; +} + +fn main() {} diff --git a/tests/ui/delegation/ice-issue-150673.stderr b/tests/ui/delegation/ice-issue-150673.stderr new file mode 100644 index 0000000000000..fc817b07770e8 --- /dev/null +++ b/tests/ui/delegation/ice-issue-150673.stderr @@ -0,0 +1,19 @@ +error[E0107]: missing generics for struct `S` + --> $DIR/ice-issue-150673.rs:16:16 + | +LL | impl Trait for S { + | ^ expected 1 generic argument + | +note: struct defined here, with 1 generic parameter: `T` + --> $DIR/ice-issue-150673.rs:10:8 + | +LL | struct S(T); + | ^ - +help: add missing generic argument + | +LL | impl Trait for S { + | +++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/eii/errors.rs b/tests/ui/eii/errors.rs index d59850a7d5f5f..5fcf33336b402 100644 --- a/tests/ui/eii/errors.rs +++ b/tests/ui/eii/errors.rs @@ -5,19 +5,19 @@ #![feature(rustc_attrs)] #![feature(eii_internals)] -#[eii_extern_target(bar)] //~ ERROR `#[eii_extern_target(...)]` is only valid on macros +#[eii_declaration(bar)] //~ ERROR `#[eii_declaration(...)]` is only valid on macros fn hello() { - #[eii_extern_target(bar)] //~ ERROR `#[eii_extern_target(...)]` is only valid on macros + #[eii_declaration(bar)] //~ ERROR `#[eii_declaration(...)]` is only valid on macros let x = 3 + 3; } -#[eii_extern_target] //~ ERROR `#[eii_extern_target(...)]` expects a list of one or two elements -#[eii_extern_target()] //~ ERROR `#[eii_extern_target(...)]` expects a list of one or two elements -#[eii_extern_target(bar, hello)] //~ ERROR expected this argument to be "unsafe" -#[eii_extern_target(bar, "unsafe", hello)] //~ ERROR `#[eii_extern_target(...)]` expects a list of one or two elements -#[eii_extern_target(bar, hello, "unsafe")] //~ ERROR `#[eii_extern_target(...)]` expects a list of one or two elements -#[eii_extern_target = "unsafe"] //~ ERROR `#[eii_extern_target(...)]` expects a list of one or two elements -#[eii_extern_target(bar)] +#[eii_declaration] //~ ERROR `#[eii_declaration(...)]` expects a list of one or two elements +#[eii_declaration()] //~ ERROR `#[eii_declaration(...)]` expects a list of one or two elements +#[eii_declaration(bar, hello)] //~ ERROR expected this argument to be "unsafe" +#[eii_declaration(bar, "unsafe", hello)] //~ ERROR `#[eii_declaration(...)]` expects a list of one or two elements +#[eii_declaration(bar, hello, "unsafe")] //~ ERROR `#[eii_declaration(...)]` expects a list of one or two elements +#[eii_declaration = "unsafe"] //~ ERROR `#[eii_declaration(...)]` expects a list of one or two elements +#[eii_declaration(bar)] #[rustc_builtin_macro(eii_shared_macro)] macro foo() {} diff --git a/tests/ui/eii/errors.stderr b/tests/ui/eii/errors.stderr index c3b51421f2957..c7eb96a9c2190 100644 --- a/tests/ui/eii/errors.stderr +++ b/tests/ui/eii/errors.stderr @@ -1,56 +1,56 @@ -error: `#[eii_extern_target(...)]` is only valid on macros +error: `#[eii_declaration(...)]` is only valid on macros --> $DIR/errors.rs:8:1 | -LL | #[eii_extern_target(bar)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[eii_declaration(bar)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: `#[eii_extern_target(...)]` is only valid on macros +error: `#[eii_declaration(...)]` is only valid on macros --> $DIR/errors.rs:10:5 | -LL | #[eii_extern_target(bar)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[eii_declaration(bar)] + | ^^^^^^^^^^^^^^^^^^^^^^^ -error: `#[eii_extern_target(...)]` expects a list of one or two elements +error: `#[eii_declaration(...)]` expects a list of one or two elements --> $DIR/errors.rs:14:1 | -LL | #[eii_extern_target] - | ^^^^^^^^^^^^^^^^^^^^ +LL | #[eii_declaration] + | ^^^^^^^^^^^^^^^^^^ -error: `#[eii_extern_target(...)]` expects a list of one or two elements +error: `#[eii_declaration(...)]` expects a list of one or two elements --> $DIR/errors.rs:15:1 | -LL | #[eii_extern_target()] - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | #[eii_declaration()] + | ^^^^^^^^^^^^^^^^^^^^ error: expected this argument to be "unsafe" - --> $DIR/errors.rs:16:26 + --> $DIR/errors.rs:16:24 | -LL | #[eii_extern_target(bar, hello)] - | ^^^^^ +LL | #[eii_declaration(bar, hello)] + | ^^^^^ | note: the second argument is optional - --> $DIR/errors.rs:16:26 + --> $DIR/errors.rs:16:24 | -LL | #[eii_extern_target(bar, hello)] - | ^^^^^ +LL | #[eii_declaration(bar, hello)] + | ^^^^^ -error: `#[eii_extern_target(...)]` expects a list of one or two elements +error: `#[eii_declaration(...)]` expects a list of one or two elements --> $DIR/errors.rs:17:1 | -LL | #[eii_extern_target(bar, "unsafe", hello)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[eii_declaration(bar, "unsafe", hello)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `#[eii_extern_target(...)]` expects a list of one or two elements +error: `#[eii_declaration(...)]` expects a list of one or two elements --> $DIR/errors.rs:18:1 | -LL | #[eii_extern_target(bar, hello, "unsafe")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[eii_declaration(bar, hello, "unsafe")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `#[eii_extern_target(...)]` expects a list of one or two elements +error: `#[eii_declaration(...)]` expects a list of one or two elements --> $DIR/errors.rs:19:1 | -LL | #[eii_extern_target = "unsafe"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[eii_declaration = "unsafe"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[foo]` is only valid on functions --> $DIR/errors.rs:28:1 diff --git a/tests/ui/eii/type_checking/auxiliary/cross_crate_eii_declaration.rs b/tests/ui/eii/type_checking/auxiliary/cross_crate_eii_declaration.rs index 40d0222082d52..95ae5d923b604 100644 --- a/tests/ui/eii/type_checking/auxiliary/cross_crate_eii_declaration.rs +++ b/tests/ui/eii/type_checking/auxiliary/cross_crate_eii_declaration.rs @@ -5,7 +5,7 @@ #![feature(rustc_attrs)] #![feature(eii_internals)] -#[eii_extern_target(bar)] +#[eii_declaration(bar)] #[rustc_builtin_macro(eii_shared_macro)] pub macro foo() {} diff --git a/tests/ui/eii/type_checking/subtype_1.rs b/tests/ui/eii/type_checking/subtype_1.rs index dfb998aa6f669..d853bc4e7e3d8 100644 --- a/tests/ui/eii/type_checking/subtype_1.rs +++ b/tests/ui/eii/type_checking/subtype_1.rs @@ -6,7 +6,7 @@ #![feature(rustc_attrs)] #![feature(eii_internals)] -#[eii_extern_target(bar)] +#[eii_declaration(bar)] #[rustc_builtin_macro(eii_shared_macro)] macro foo() {} diff --git a/tests/ui/eii/type_checking/subtype_2.rs b/tests/ui/eii/type_checking/subtype_2.rs index 5f0c5553fcccb..d2b2eb073de2c 100644 --- a/tests/ui/eii/type_checking/subtype_2.rs +++ b/tests/ui/eii/type_checking/subtype_2.rs @@ -6,7 +6,7 @@ #![feature(rustc_attrs)] #![feature(eii_internals)] -#[eii_extern_target(bar)] +#[eii_declaration(bar)] #[rustc_builtin_macro(eii_shared_macro)] macro foo() {} diff --git a/tests/ui/eii/type_checking/subtype_3.rs b/tests/ui/eii/type_checking/subtype_3.rs index 269bc84df744a..458bacf4a7729 100644 --- a/tests/ui/eii/type_checking/subtype_3.rs +++ b/tests/ui/eii/type_checking/subtype_3.rs @@ -7,7 +7,7 @@ #![feature(rustc_attrs)] #![feature(eii_internals)] -#[eii_extern_target(bar)] +#[eii_declaration(bar)] #[rustc_builtin_macro(eii_shared_macro)] macro foo() {} diff --git a/tests/ui/eii/type_checking/subtype_4.rs b/tests/ui/eii/type_checking/subtype_4.rs index e9194df7584c7..6f1e4253dd735 100644 --- a/tests/ui/eii/type_checking/subtype_4.rs +++ b/tests/ui/eii/type_checking/subtype_4.rs @@ -7,7 +7,7 @@ #![feature(rustc_attrs)] #![feature(eii_internals)] -#[eii_extern_target(bar)] +#[eii_declaration(bar)] #[rustc_builtin_macro(eii_shared_macro)] macro foo() {} diff --git a/tests/ui/eii/type_checking/wrong_ret_ty.rs b/tests/ui/eii/type_checking/wrong_ret_ty.rs index 5fe7d2f8bb620..8ee81a4f24657 100644 --- a/tests/ui/eii/type_checking/wrong_ret_ty.rs +++ b/tests/ui/eii/type_checking/wrong_ret_ty.rs @@ -5,7 +5,7 @@ #![feature(rustc_attrs)] #![feature(eii_internals)] -#[eii_extern_target(bar)] +#[eii_declaration(bar)] #[rustc_builtin_macro(eii_shared_macro)] macro foo() {} diff --git a/tests/ui/eii/type_checking/wrong_ty.rs b/tests/ui/eii/type_checking/wrong_ty.rs index ebb756f6a3148..625af6e11dbf7 100644 --- a/tests/ui/eii/type_checking/wrong_ty.rs +++ b/tests/ui/eii/type_checking/wrong_ty.rs @@ -5,7 +5,7 @@ #![feature(rustc_attrs)] #![feature(eii_internals)] -#[eii_extern_target(bar)] +#[eii_declaration(bar)] #[rustc_builtin_macro(eii_shared_macro)] macro foo() {} diff --git a/tests/ui/eii/type_checking/wrong_ty_2.rs b/tests/ui/eii/type_checking/wrong_ty_2.rs index d55f405bf1575..2e477b5b6fcce 100644 --- a/tests/ui/eii/type_checking/wrong_ty_2.rs +++ b/tests/ui/eii/type_checking/wrong_ty_2.rs @@ -5,7 +5,7 @@ #![feature(rustc_attrs)] #![feature(eii_internals)] -#[eii_extern_target(bar)] +#[eii_declaration(bar)] #[rustc_builtin_macro(eii_shared_macro)] macro foo() {} diff --git a/tests/ui/eii/unsafe_impl_err.rs b/tests/ui/eii/unsafe_impl_err.rs index 6af7e9724e15b..a6d24c47ae213 100644 --- a/tests/ui/eii/unsafe_impl_err.rs +++ b/tests/ui/eii/unsafe_impl_err.rs @@ -5,7 +5,7 @@ #![feature(rustc_attrs)] #![feature(eii_internals)] -#[eii_extern_target(bar, "unsafe")] +#[eii_declaration(bar, "unsafe")] #[rustc_builtin_macro(eii_shared_macro)] macro foo() {} diff --git a/tests/ui/eii/unsafe_impl_ok.rs b/tests/ui/eii/unsafe_impl_ok.rs index 268c5bc16fd84..1af6d63eb7cff 100644 --- a/tests/ui/eii/unsafe_impl_ok.rs +++ b/tests/ui/eii/unsafe_impl_ok.rs @@ -7,7 +7,7 @@ #![feature(rustc_attrs)] #![feature(eii_internals)] -#[eii_extern_target(bar, "unsafe")] +#[eii_declaration(bar, "unsafe")] #[rustc_builtin_macro(eii_shared_macro)] macro foo() {} diff --git a/tests/ui/feature-gates/feature-gate-eii-internals.rs b/tests/ui/feature-gates/feature-gate-eii-internals.rs index b70e007ed798b..96699f2905b65 100644 --- a/tests/ui/feature-gates/feature-gate-eii-internals.rs +++ b/tests/ui/feature-gates/feature-gate-eii-internals.rs @@ -2,7 +2,7 @@ #![feature(decl_macro)] #![feature(rustc_attrs)] -#[eii_extern_target(bar)] //~ ERROR use of unstable library feature `eii_internals` +#[eii_declaration(bar)] //~ ERROR use of unstable library feature `eii_internals` #[rustc_builtin_macro(eii_macro)] macro foo() {} //~ ERROR: cannot find a built-in macro with name `foo` diff --git a/tests/ui/feature-gates/feature-gate-eii-internals.stderr b/tests/ui/feature-gates/feature-gate-eii-internals.stderr index f08f0a5e65b3b..78aa49ebab1cf 100644 --- a/tests/ui/feature-gates/feature-gate-eii-internals.stderr +++ b/tests/ui/feature-gates/feature-gate-eii-internals.stderr @@ -1,8 +1,8 @@ error[E0658]: use of unstable library feature `eii_internals` --> $DIR/feature-gate-eii-internals.rs:5:3 | -LL | #[eii_extern_target(bar)] - | ^^^^^^^^^^^^^^^^^ +LL | #[eii_declaration(bar)] + | ^^^^^^^^^^^^^^^ | = help: add `#![feature(eii_internals)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date diff --git a/tests/ui/fmt/format-string-error-2.rs b/tests/ui/fmt/format-string-error-2.rs index e14a4064aa833..63d65023eb78b 100644 --- a/tests/ui/fmt/format-string-error-2.rs +++ b/tests/ui/fmt/format-string-error-2.rs @@ -86,4 +86,6 @@ raw { \n println!("{x?}, world!",); //~^ ERROR invalid format string: expected `}`, found `?` + println!("{x,}, world!",); + //~^ ERROR invalid format string: python's numeric grouping `,` is not supported in rust format strings } diff --git a/tests/ui/fmt/format-string-error-2.stderr b/tests/ui/fmt/format-string-error-2.stderr index b117fb57cf07e..e7fbc2e81fc6b 100644 --- a/tests/ui/fmt/format-string-error-2.stderr +++ b/tests/ui/fmt/format-string-error-2.stderr @@ -188,5 +188,15 @@ LL | println!("{x?}, world!",); | = note: to print `{`, you can escape it using `{{` -error: aborting due to 19 previous errors +error: invalid format string: python's numeric grouping `,` is not supported in rust format strings + --> $DIR/format-string-error-2.rs:89:17 + | +LL | println!("{x,}, world!",); + | - ^ expected `}` in format string + | | + | because of this opening brace + | + = note: to print `{`, you can escape it using `{{` + +error: aborting due to 20 previous errors