diff --git a/compiler/rustc_builtin_macros/src/deriving/clone.rs b/compiler/rustc_builtin_macros/src/deriving/clone.rs index 7cce8a2a46269..370c0ceeda909 100644 --- a/compiler/rustc_builtin_macros/src/deriving/clone.rs +++ b/compiler/rustc_builtin_macros/src/deriving/clone.rs @@ -4,7 +4,6 @@ use rustc_expand::base::ExtCtxt; use rustc_span::{DUMMY_SP, Ident, Span, kw, sym}; use thin_vec::{ThinVec, thin_vec}; -use crate::deriving::generic::ty::*; use crate::deriving::generic::*; use crate::deriving::path_std; @@ -68,7 +67,6 @@ pub(crate) fn expand_deriving_clone( additional_bounds: bounds.clone(), supports_unions: true, methods: SmallVec::new(), - associated_types: SmallVec::new(), is_const, safety: Safety::Unsafe(DUMMY_SP), // `TrivialClone` is not part of an API guarantee, so it shouldn't @@ -91,12 +89,12 @@ pub(crate) fn expand_deriving_clone( generics: cx.empty_generics(span), explicit_self: true, nonself_args: SmallVec::new(), - ret_ty: Self_, + has_other_selflike_arg: false, + ret_ty: cx.ty_self(span), attributes: thin_vec![cx.attr_word(sym::inline, span)], fieldless_variants_strategy: FieldlessVariantsStrategy::Default, combine_substructure: substructure, }], - associated_types: SmallVec::new(), is_const, safety: Safety::Default, document: true, diff --git a/compiler/rustc_builtin_macros/src/deriving/const_param_ty.rs b/compiler/rustc_builtin_macros/src/deriving/const_param_ty.rs index 69041a60027d3..c693cbb66fee9 100644 --- a/compiler/rustc_builtin_macros/src/deriving/const_param_ty.rs +++ b/compiler/rustc_builtin_macros/src/deriving/const_param_ty.rs @@ -20,7 +20,6 @@ pub(crate) fn expand_deriving_const_param_ty( additional_bounds: smallvec![path_std!(cx, span, cmp::Eq)], supports_unions: false, methods: SmallVec::new(), - associated_types: SmallVec::new(), is_const, safety: Safety::Default, document: true, diff --git a/compiler/rustc_builtin_macros/src/deriving/copy.rs b/compiler/rustc_builtin_macros/src/deriving/copy.rs index 5badeb7e1877e..4ce8598e96711 100644 --- a/compiler/rustc_builtin_macros/src/deriving/copy.rs +++ b/compiler/rustc_builtin_macros/src/deriving/copy.rs @@ -20,7 +20,6 @@ pub(crate) fn expand_deriving_copy( additional_bounds: SmallVec::new(), supports_unions: true, methods: SmallVec::new(), - associated_types: SmallVec::new(), is_const, safety: Safety::Default, document: true, diff --git a/compiler/rustc_builtin_macros/src/deriving/debug.rs b/compiler/rustc_builtin_macros/src/deriving/debug.rs index 66e9b3ed82bcc..2f3d2058773d8 100644 --- a/compiler/rustc_builtin_macros/src/deriving/debug.rs +++ b/compiler/rustc_builtin_macros/src/deriving/debug.rs @@ -4,7 +4,6 @@ use rustc_session::config::FmtDebug; use rustc_span::{Ident, Span, Symbol, sym}; use thin_vec::{ThinVec, thin_vec}; -use crate::deriving::generic::ty::*; use crate::deriving::generic::*; use crate::deriving::path_std; @@ -16,7 +15,12 @@ pub(crate) fn expand_deriving_debug( is_const: bool, ) { // &mut ::std::fmt::Formatter - let fmtr = Ref(Box::new(Path(path_std!(cx, span, fmt::Formatter))), ast::Mutability::Mut); + let fmtr = cx.ty_ref( + span, + cx.ty_path(path_std!(cx, span, fmt::Formatter)), + None, + ast::Mutability::Mut, + ); let trait_def = TraitDef { span, @@ -30,7 +34,8 @@ pub(crate) fn expand_deriving_debug( generics: cx.empty_generics(span), explicit_self: true, nonself_args: smallvec![(fmtr, sym::character('f'))], - ret_ty: Path(path_std!(cx, span, fmt::Result)), + has_other_selflike_arg: false, + ret_ty: cx.ty_path(path_std!(cx, span, fmt::Result)), attributes: thin_vec![cx.attr_word(sym::inline, span)], fieldless_variants_strategy: FieldlessVariantsStrategy::SpecializeIfAllVariantsFieldless, @@ -41,7 +46,6 @@ pub(crate) fn expand_deriving_debug( item.kind.ident().unwrap() )), }], - associated_types: SmallVec::new(), is_const, safety: Safety::Default, document: true, @@ -50,7 +54,7 @@ pub(crate) fn expand_deriving_debug( } fn formatter_ident(cx: &ExtCtxt<'_>, span: Span) -> Box { - cx.expr_ident(span, Ident::new(sym::character('f'), span)) + cx.expr_ident_sym(span, sym::character('f')) } fn show_substructure( @@ -195,9 +199,9 @@ fn show_substructure( args.push(fmt); args.push(name); if is_struct { - args.push(cx.expr_ident(span, Ident::new(sym::names, span))); + args.push(cx.expr_ident_sym(span, sym::names)); } - args.push(cx.expr_ident(span, Ident::new(sym::values, span))); + args.push(cx.expr_ident_sym(span, sym::values)); let expr = cx.expr_call_global(span, fn_path_debug_internal, args); let mut stmts = ThinVec::with_capacity(2); diff --git a/compiler/rustc_builtin_macros/src/deriving/default.rs b/compiler/rustc_builtin_macros/src/deriving/default.rs index 866ffc74da436..28526bdef6b9d 100644 --- a/compiler/rustc_builtin_macros/src/deriving/default.rs +++ b/compiler/rustc_builtin_macros/src/deriving/default.rs @@ -7,8 +7,8 @@ use rustc_span::{ErrorGuaranteed, Ident, Span, kw, sym}; use smallvec::SmallVec; use thin_vec::{ThinVec, thin_vec}; -use crate::deriving::generic::ty::*; use crate::deriving::generic::*; +use crate::deriving::new_path; use crate::diagnostics; pub(crate) fn expand_deriving_default( @@ -22,7 +22,7 @@ pub(crate) fn expand_deriving_default( let trait_def = TraitDef { span, - path: new_path(cx, span, &[kw::Default, sym::Default], &[]), + path: new_path(cx, span, &[kw::Default, sym::Default], vec![]), skip_path_as_bound: has_a_default_variant(item), needs_copy_as_bound_if_packed: false, additional_bounds: SmallVec::new(), @@ -32,7 +32,8 @@ pub(crate) fn expand_deriving_default( generics: cx.empty_generics(span), explicit_self: false, nonself_args: SmallVec::new(), - ret_ty: Self_, + has_other_selflike_arg: false, + ret_ty: cx.ty_self(span), attributes: thin_vec![cx.attr_word(sym::inline, span)], fieldless_variants_strategy: FieldlessVariantsStrategy::Default, combine_substructure: combine_substructure(|cx, trait_span, substr| { @@ -49,7 +50,6 @@ pub(crate) fn expand_deriving_default( } }), }], - associated_types: SmallVec::new(), is_const, safety: Safety::Default, document: true, diff --git a/compiler/rustc_builtin_macros/src/deriving/eq.rs b/compiler/rustc_builtin_macros/src/deriving/eq.rs index 1083b37cbf248..da38045994c7f 100644 --- a/compiler/rustc_builtin_macros/src/deriving/eq.rs +++ b/compiler/rustc_builtin_macros/src/deriving/eq.rs @@ -4,7 +4,6 @@ use rustc_expand::base::ExtCtxt; use rustc_span::{Span, sym}; use thin_vec::{ThinVec, thin_vec}; -use crate::deriving::generic::ty::*; use crate::deriving::generic::*; use crate::deriving::path_std; @@ -29,7 +28,8 @@ pub(crate) fn expand_deriving_eq( generics: cx.empty_generics(span), explicit_self: true, nonself_args: smallvec![], - ret_ty: Unit, + has_other_selflike_arg: false, + ret_ty: cx.ty_unit(span), attributes: thin_vec![ // This method will never be called, so doing codegen etc. for it is unnecessary. // We prevent this by adding `#[inline]`, which improves compile-time. @@ -40,7 +40,6 @@ pub(crate) fn expand_deriving_eq( fieldless_variants_strategy: FieldlessVariantsStrategy::Unify, combine_substructure: combine_substructure(cs_total_eq_assert), }], - associated_types: SmallVec::new(), is_const, safety: Safety::Default, document: true, diff --git a/compiler/rustc_builtin_macros/src/deriving/from.rs b/compiler/rustc_builtin_macros/src/deriving/from.rs index 64cc917302935..df95ccd99f3e6 100644 --- a/compiler/rustc_builtin_macros/src/deriving/from.rs +++ b/compiler/rustc_builtin_macros/src/deriving/from.rs @@ -5,9 +5,8 @@ use rustc_expand::base::{DummyResult, ExtCtxt}; use rustc_span::{Ident, Span, kw, sym}; use thin_vec::thin_vec; -use crate::deriving::generic::ty::*; use crate::deriving::generic::*; -use crate::deriving::pathvec; +use crate::deriving::{new_path, pathvec}; use crate::diagnostics; /// Generate an implementation of the `From` trait, provided that `item` @@ -47,12 +46,12 @@ pub(crate) fn expand_deriving_from( _ => cx.dcx().bug("Invalid derive(From) ADT input"), }; - let from_type = Ty::AstTy(match field { + let from_type = match field { Ok(ref field) => field.ty.clone(), Err(guar) => cx.ty(span, ast::TyKind::Err(guar)), - }); + }; - let path = new_path(cx, span, pathvec!(convert::From), &[from_type.clone()]); + let path = new_path(cx, span, pathvec!(convert::From), vec![from_type.clone()]); // Generate code like this: // @@ -76,7 +75,8 @@ pub(crate) fn expand_deriving_from( generics: cx.empty_generics(span), explicit_self: false, nonself_args: smallvec![(from_type, sym::value)], - ret_ty: Ty::Self_, + has_other_selflike_arg: false, + ret_ty: cx.ty_self(span), attributes: thin_vec![cx.attr_word(sym::inline, span)], fieldless_variants_strategy: FieldlessVariantsStrategy::Default, combine_substructure: combine_substructure(|cx, span, substructure| { @@ -97,14 +97,14 @@ pub(crate) fn expand_deriving_from( thin_vec![cx.field_imm( span, field.ident.unwrap(), - cx.expr_ident(span, Ident::new(sym::value, span)) + cx.expr_ident_sym(span, sym::value) )], ), // Self(value) VariantData::Tuple(_, _) => cx.expr_call_ident( span, self_kw, - thin_vec![cx.expr_ident(span, Ident::new(sym::value, span))], + thin_vec![cx.expr_ident_sym(span, sym::value)], ), variant => { cx.dcx().bug(format!("Invalid derive(From) ADT variant: {variant:?}")); @@ -115,7 +115,6 @@ pub(crate) fn expand_deriving_from( BlockOrExpr::new_expr(expr) }), }], - associated_types: SmallVec::new(), is_const, safety: Safety::Default, document: true, diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index b6bd482945546..71329da76c481 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -174,9 +174,8 @@ //! ) //! ``` -use std::iter::once; use std::ops::Not; -use std::{iter, vec}; +use std::vec; pub(crate) use Substructure::*; pub(crate) use rustc_ast as ast; @@ -192,12 +191,9 @@ use rustc_expand::base::ExtCtxt; use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, respan, sym}; pub(crate) use smallvec::{SmallVec, smallvec}; use thin_vec::{ThinVec, thin_vec}; -use ty::{Ref, Self_, Ty}; use crate::{deriving, diagnostics}; -pub(crate) mod ty; - pub(crate) struct TraitDef<'a> { /// The span for the current #[derive(Foo)] header. pub span: Span, @@ -220,8 +216,6 @@ pub(crate) struct TraitDef<'a> { pub methods: SmallVec<[MethodDef<'a>; 1]>, - pub associated_types: SmallVec<[(Ident, Ty); 1]>, - pub is_const: bool, /// The safety of the `impl`. @@ -241,10 +235,13 @@ pub(crate) struct MethodDef<'a> { pub explicit_self: bool, /// Arguments other than the self argument. - pub nonself_args: SmallVec<[(Ty, Symbol); 1]>, + pub nonself_args: SmallVec<[(Box, Symbol); 1]>, + + /// Whether this method has another arg of type `&self`. + pub has_other_selflike_arg: bool, /// Returns type - pub ret_ty: Ty, + pub ret_ty: Box, pub attributes: ast::AttrVec, @@ -294,15 +291,14 @@ pub(crate) enum Substructure<'a> { /// variants has any fields). AllFieldlessEnum(&'a ast::EnumDef), - /// Matching variants of the enum: variant index, ast::Variant, + /// Matching variants of the enum: ast::Variant, /// fields: the field name is only non-`None` in the case of a struct /// variant. EnumMatching(&'a ast::Variant, Vec), - /// The discriminant of an enum. The first field is a `FieldInfo` for the discriminants, as - /// if they were fields. The second field is the expression to combine the + /// The discriminant of an enum. The field is the expression to combine the /// discriminant expression with; it will be `None` if no match is necessary. - EnumDiscr(FieldInfo, Option>), + EnumDiscr(Option>), /// A static method where `Self` is a struct. StaticStruct(&'a ast::VariantData), @@ -462,14 +458,30 @@ impl<'a> TraitDef<'a> { push: &mut dyn FnMut(Box), from_scratch: bool, ) { + let span = self.span; let is_packed = matches!( AttributeParser::parse_limited_sym(cx.sess, &item.attrs, &[sym::repr]), Some(Attribute::Parsed(AttributeKind::Repr { reprs, .. })) if reprs.iter().any(|(x, _)| matches!(x, ReprPacked(..))) ); let mut newitem = match &item.kind { - ast::ItemKind::Struct(ident, generics, struct_def) => { - self.expand_struct_def(cx, struct_def, *ident, generics, from_scratch, is_packed) + ast::ItemKind::Union(..) if !self.supports_unions => { + cx.dcx().emit_err(diagnostics::DeriveUnion { span }); + return; + } + ast::ItemKind::Struct(ident, generics, struct_def) + | ast::ItemKind::Union(ident, generics, struct_def) => { + let fields = struct_def.fields().iter(); + let methods = self.methods.iter().filter_map(|method_def| { + let body = if from_scratch || method_def.is_static() { + method_def.call_substructure_method(cx, span, StaticStruct(struct_def)) + } else { + method_def.expand_struct_method_body(cx, span, struct_def, is_packed) + }; + + method_def.create_method(cx, span, body) + }); + self.create_derived_impl(cx, *ident, generics, fields, methods, is_packed) } ast::ItemKind::Enum(ident, generics, enum_def) => { // We can skip generating the impl here, because `repr(packed)` @@ -479,22 +491,17 @@ impl<'a> TraitDef<'a> { if is_packed { return; } - self.expand_enum_def(cx, enum_def, *ident, generics, from_scratch) - } - ast::ItemKind::Union(ident, generics, struct_def) => { - if self.supports_unions { - self.expand_struct_def( - cx, - struct_def, - *ident, - generics, - from_scratch, - is_packed, - ) - } else { - cx.dcx().emit_err(diagnostics::DeriveUnion { span: self.span }); - return; - } + let fields = enum_def.variants.iter().flat_map(|variant| variant.data.fields()); + let methods = self.methods.iter().filter_map(|method_def| { + let body = if from_scratch || method_def.is_static() { + method_def.call_substructure_method(cx, span, StaticEnum(enum_def)) + } else { + method_def.expand_enum_method_body(cx, span, enum_def) + }; + + method_def.create_method(cx, span, body) + }); + self.create_derived_impl(cx, *ident, generics, fields, methods, is_packed) } _ => unreachable!(), }; @@ -558,36 +565,13 @@ impl<'a> TraitDef<'a> { cx: &ExtCtxt<'_>, type_ident: Ident, generics: &Generics, - field_tys: impl Iterator, + fields: impl Iterator, methods: impl Iterator>, is_packed: bool, ) -> Box { - // Transform associated types from `deriving::ty::Ty` into `ast::AssocItem` - let associated_types = self.associated_types.iter().map(|&(ident, ref type_def)| { - Box::new(ast::AssocItem { - id: ast::DUMMY_NODE_ID, - span: self.span, - vis: ast::Visibility { - span: self.span.shrink_to_lo(), - kind: ast::VisibilityKind::Inherited, - }, - attrs: ast::AttrVec::new(), - kind: ast::AssocItemKind::Type(Box::new(ast::TyAlias { - defaultness: ast::Defaultness::Implicit, - ident, - generics: Generics::default(), - after_where_clause: ast::WhereClause::default(), - bounds: ThinVec::new(), - ty: Some(type_def.to_ty(cx, self.span)), - })), - tokens: None, - }) - }); - let mut where_clause = ast::WhereClause::default(); where_clause.span = generics.where_clause.span; let ctxt = self.span.ctxt(); - let span = generics.span.with_ctxt(ctxt); // Create the generic parameters let params: ThinVec<_> = generics @@ -667,8 +651,8 @@ impl<'a> TraitDef<'a> { .collect(); if !ty_param_names.is_empty() { - for field_ty in field_tys { - let field_ty_params = find_type_parameters(field_ty, &ty_param_names, cx); + for field in fields { + let field_ty_params = find_type_parameters(&field.ty, &ty_param_names, cx); for field_ty_param in field_ty_params { // if we have already handled this type, skip it @@ -716,7 +700,7 @@ impl<'a> TraitDef<'a> { } } - let trait_generics = Generics { params, where_clause, span }; + let trait_generics = Generics { params, where_clause, span: generics.span.with_ctxt(ctxt) }; // Create the reference to the trait. let trait_ref = cx.trait_ref(self.path.clone()); @@ -741,8 +725,6 @@ impl<'a> TraitDef<'a> { let path = cx.path_all(type_ident.span.with_ctxt(ctxt), false, vec![type_ident], self_params); let self_type = cx.ty_path(path); - let rustc_const_unstable = - cx.path_ident(self.span, Ident::new(sym::rustc_const_unstable, self.span)); let mut attrs = thin_vec![cx.attr_word(sym::automatically_derived, self.span),]; @@ -750,6 +732,9 @@ impl<'a> TraitDef<'a> { // Other crates don't need stability attributes, so adding them is not useful, but libcore needs them // on all const trait impls. if self.is_const && cx.ecfg.features.staged_api() { + let rustc_const_unstable = + cx.path_ident(self.span, Ident::new(sym::rustc_const_unstable, self.span)); + // #[rustc_const_unstable(feature = "derive_const", issue = "118304")] attrs.push( cx.attr_nested( @@ -798,72 +783,20 @@ impl<'a> TraitDef<'a> { })), constness: if self.is_const { ast::Const::Yes(DUMMY_SP) } else { ast::Const::No }, self_ty: self_type, - items: methods.chain(associated_types).collect(), + items: methods.collect(), }), ) } - - fn expand_struct_def( - &self, - cx: &ExtCtxt<'_>, - struct_def: &'a VariantData, - type_ident: Ident, - generics: &Generics, - from_scratch: bool, - is_packed: bool, - ) -> Box { - let field_tys = struct_def.fields().iter().map(|field| &*field.ty); - - let methods = self.methods.iter().filter_map(|method_def| { - let body = if from_scratch || method_def.is_static() { - method_def.call_substructure_method(cx, self, StaticStruct(struct_def)) - } else { - method_def.expand_struct_method_body(cx, self, struct_def, is_packed) - }; - - method_def.create_method(cx, self, body) - }); - - self.create_derived_impl(cx, type_ident, generics, field_tys, methods, is_packed) - } - - fn expand_enum_def( - &self, - cx: &ExtCtxt<'_>, - enum_def: &'a EnumDef, - type_ident: Ident, - generics: &Generics, - from_scratch: bool, - ) -> Box { - let field_tys = enum_def - .variants - .iter() - .flat_map(|variant| variant.data.fields()) - .map(|field| &*field.ty); - - let methods = self.methods.iter().filter_map(|method_def| { - let body = if from_scratch || method_def.is_static() { - method_def.call_substructure_method(cx, self, StaticEnum(enum_def)) - } else { - method_def.expand_enum_method_body(cx, self, enum_def, type_ident) - }; - - method_def.create_method(cx, self, body) - }); - - let is_packed = false; // enums are never packed - self.create_derived_impl(cx, type_ident, generics, field_tys, methods, is_packed) - } } impl<'a> MethodDef<'a> { fn call_substructure_method( &self, cx: &ExtCtxt<'_>, - trait_: &TraitDef<'_>, + span: Span, substructure: Substructure<'_>, ) -> BlockOrExpr { - (self.combine_substructure)(cx, trait_.span, substructure) + (self.combine_substructure)(cx, span, substructure) } fn is_static(&self) -> bool { @@ -872,30 +805,27 @@ impl<'a> MethodDef<'a> { /// Expressions for `&self` and also any other /// args with the same type (e.g. the `other` arg in `PartialEq::eq`). - fn get_selflike_args(&self, cx: &ExtCtxt<'_>, trait_: &TraitDef<'_>) -> ThinVec> { + fn get_selflike_args(&self, cx: &ExtCtxt<'_>, span: Span) -> ThinVec> { assert!(self.explicit_self); - let span = trait_.span; - - once(cx.expr_self(span)) - .chain(self.nonself_args.iter().filter_map(|(ty, name)| match ty { - Ref(Self_, _) => Some(cx.expr_ident(span, Ident::new(*name, span))), - _ => None, - })) - .collect() + let self_expr = cx.expr_self(span); + if self.has_other_selflike_arg { + thin_vec![self_expr, cx.expr_ident_sym(span, self.nonself_args[0].1)] + } else { + thin_vec![self_expr] + } } fn create_method( &self, cx: &ExtCtxt<'_>, - trait_: &TraitDef<'_>, + span: Span, body: BlockOrExpr, ) -> Option> { // `assert_fields_are_eq` has an empty default implementation if body.0.is_empty() && body.1.is_none() && self.name == sym::assert_fields_are_eq { return None; } - let span = trait_.span; // Create the generics that aren't for `Self`. let fn_generics = self.generics.clone(); @@ -910,16 +840,16 @@ impl<'a> MethodDef<'a> { let args = self_arg .into_iter() .chain(self.nonself_args.iter().map(|(ty, name)| { - let ast_ty = ty.to_ty(cx, span); + let ast_ty = ty.clone(); let ident = Ident::new(*name, span); cx.param(span, ident, ast_ty) })) .collect(); - let ret_type = if let Ty::Unit = &self.ret_ty { + let ret_type = if self.ret_ty.kind.is_unit() { ast::FnRetTy::Default(span) } else { - ast::FnRetTy::Ty(self.ret_ty.to_ty(cx, span)) + ast::FnRetTy::Ty(self.ret_ty.clone()) }; let method_ident = Ident::new(self.name, span); @@ -989,15 +919,15 @@ impl<'a> MethodDef<'a> { fn expand_struct_method_body<'b>( &self, cx: &ExtCtxt<'_>, - trait_: &TraitDef<'b>, + span: Span, struct_def: &'b VariantData, is_packed: bool, ) -> BlockOrExpr { - let selflike_args = self.get_selflike_args(cx, trait_); + let selflike_args = self.get_selflike_args(cx, span); let selflike_fields = - trait_.create_struct_field_access_fields(cx, &selflike_args, struct_def, is_packed); - self.call_substructure_method(cx, trait_, Struct(struct_def, selflike_fields)) + create_struct_field_access_fields(span, cx, &selflike_args, struct_def, is_packed); + self.call_substructure_method(cx, span, Struct(struct_def, selflike_fields)) } /// ``` @@ -1038,11 +968,9 @@ impl<'a> MethodDef<'a> { fn expand_enum_method_body<'b>( &self, cx: &ExtCtxt<'_>, - trait_: &TraitDef<'b>, + span: Span, enum_def: &'b EnumDef, - type_ident: Ident, ) -> BlockOrExpr { - let span = trait_.span; let variants = &enum_def.variants; // Traits that unify fieldless variants always use the discriminant(s). @@ -1059,48 +987,12 @@ impl<'a> MethodDef<'a> { return BlockOrExpr(ThinVec::new(), Some(expr)); } - let selflike_args = self.get_selflike_args(cx, trait_); - - let prefixes = iter::once("__self".to_string()) - .chain((1..selflike_args.len()).map(|arg_count| format!("__arg{arg_count}"))) - .collect::>(); - - // Build a series of let statements mapping each selflike_arg - // to its discriminant value. - // - // e.g. for `PartialEq::eq` builds two statements: - // ``` - // let __self_discr = ::core::intrinsics::discriminant_value(self); - // let __arg1_discr = ::core::intrinsics::discriminant_value(other); - // ``` - let get_discr_pieces = || { - let discr_idents = prefixes - .iter() - .map(|name| Ident::from_str_and_span(&format!("{name}_discr"), span)); - - let mut discr_exprs = - discr_idents.clone().map(|ident| cx.expr_addr_of(span, cx.expr_ident(span, ident))); + let selflike_args = self.get_selflike_args(cx, span); - let self_expr = discr_exprs.next().unwrap(); - let other_selflike_expr = discr_exprs.next(); - debug_assert!(discr_exprs.next().is_none()); - - let discr_field = - FieldInfo { span, name: None, self_expr, other_selflike_expr, maybe_scalar: true }; - - let discr_let_stmts: ThinVec<_> = iter::zip(discr_idents, &selflike_args) - .map(|(ident, selflike_arg)| { - let variant_value = deriving::call_intrinsic( - cx, - span, - sym::discriminant_value, - thin_vec![selflike_arg.clone()], - ); - cx.stmt_let(span, false, ident, variant_value) - }) - .collect(); - - (discr_field, discr_let_stmts) + let prefixes: &[&str] = match selflike_args.len() { + 1 => &["__self"], + 2 => &["__self", "__arg1"], + _ => unreachable!(), }; // There are some special cases involving fieldless enums where no @@ -1113,29 +1005,17 @@ impl<'a> MethodDef<'a> { // If the type is fieldless and the trait uses the discriminant and // there are multiple variants, we need just an operation on // the discriminant(s). - let (discr_field, mut discr_let_stmts) = get_discr_pieces(); - let mut discr_check = - self.call_substructure_method(cx, trait_, EnumDiscr(discr_field, None)); - discr_let_stmts.append(&mut discr_check.0); - return BlockOrExpr(discr_let_stmts, discr_check.1); + return self.call_substructure_method(cx, span, EnumDiscr(None)); } FieldlessVariantsStrategy::SpecializeIfAllVariantsFieldless => { - return self.call_substructure_method( - cx, - trait_, - AllFieldlessEnum(enum_def), - ); + return self.call_substructure_method(cx, span, AllFieldlessEnum(enum_def)); } FieldlessVariantsStrategy::Default => (), } } else if let [variant] = variants.as_slice() { // If there is a single variant, we don't need an operation on // the discriminant(s). Just use the most degenerate result. - return self.call_substructure_method( - cx, - trait_, - EnumMatching(variant, Vec::new()), - ); + return self.call_substructure_method(cx, span, EnumMatching(variant, Vec::new())); } } @@ -1151,12 +1031,13 @@ impl<'a> MethodDef<'a> { // A single arm has form (&VariantK, &VariantK, ...) => BodyK // (see "Final wrinkle" note below for why.) - let fields = trait_.create_struct_pattern_fields(cx, &variant.data, &prefixes); + let fields = create_struct_pattern_fields(span, cx, &variant.data, &prefixes); - let sp = variant.span.with_ctxt(trait_.span.ctxt()); - let variant_path = cx.path(sp, vec![type_ident, variant.ident]); + let sp = variant.span.with_ctxt(span.ctxt()); + let variant_path = + cx.path(sp, vec![Ident::new(kw::SelfUpper, span), variant.ident]); let mut subpats = - trait_.create_struct_patterns(cx, variant_path, &variant.data, &prefixes); + create_struct_patterns(span, cx, variant_path, &variant.data, &prefixes); // `(VariantK, VariantK, ...)` or just `VariantK`. let single_pat = if subpats.len() == 1 { @@ -1175,7 +1056,7 @@ impl<'a> MethodDef<'a> { // Build up code associated with such a case. let substructure = EnumMatching(variant, fields); let arm_expr = - self.call_substructure_method(cx, trait_, substructure).into_expr(cx, span); + self.call_substructure_method(cx, span, substructure).into_expr(cx, span); cx.arm(span, single_pat, arm_expr) }) @@ -1185,17 +1066,15 @@ impl<'a> MethodDef<'a> { let first_fieldless = variants.iter().find(|v| v.data.fields().is_empty()); let default = match first_fieldless { Some(v) if unify_fieldless_variants => { - // We need a default case that handles all the fieldless - // variants. The index and actual variant aren't meaningful in - // this case, so just use dummy values. + // We need a default case that handles all the fieldless variants. Some( - self.call_substructure_method(cx, trait_, EnumMatching(v, Vec::new())) + self.call_substructure_method(cx, span, EnumMatching(v, Vec::new())) .into_expr(cx, span), ) } _ if variants.len() > 1 && selflike_args.len() > 1 => { // Because we know that all the arguments will match if we reach - // the match expression we add the unreachable intrinsics as the + // the match expression we add the unreachable intrinsic as the // result of the default which should help llvm in optimizing it. Some(deriving::call_unreachable(cx, span)) } @@ -1217,7 +1096,7 @@ impl<'a> MethodDef<'a> { let match_arg = if selflike_args.len() == 1 { selflike_args.pop().unwrap() } else { - cx.expr(span, ast::ExprKind::Tup(selflike_args)) + cx.expr_tuple(span, selflike_args) }; cx.expr_match(span, match_arg, match_arms) }; @@ -1226,16 +1105,8 @@ impl<'a> MethodDef<'a> { // to add a discriminant check operation before the match. Otherwise, the match // is enough. if unify_fieldless_variants && variants.len() > 1 { - let (discr_field, mut discr_let_stmts) = get_discr_pieces(); - // Combine a discriminant check with the match. - let mut discr_check_plus_match = self.call_substructure_method( - cx, - trait_, - EnumDiscr(discr_field, Some(get_match_expr(selflike_args))), - ); - discr_let_stmts.append(&mut discr_check_plus_match.0); - BlockOrExpr(discr_let_stmts, discr_check_plus_match.1) + self.call_substructure_method(cx, span, EnumDiscr(Some(get_match_expr(selflike_args)))) } else { BlockOrExpr(ThinVec::new(), Some(get_match_expr(selflike_args))) } @@ -1243,179 +1114,128 @@ impl<'a> MethodDef<'a> { } // general helper methods. -impl<'a> TraitDef<'a> { - fn create_struct_patterns( - &self, - cx: &ExtCtxt<'_>, - struct_path: ast::Path, - struct_def: &'a VariantData, - prefixes: &[String], - ) -> ThinVec { +fn create_struct_patterns( + span: Span, + cx: &ExtCtxt<'_>, + struct_path: ast::Path, + struct_def: &VariantData, + prefixes: &[&str], +) -> ThinVec { + prefixes + .iter() + .map(|prefix| { + let pieces_iter = struct_def.fields().iter().enumerate().map(|(i, struct_field)| { + let ident = mk_pattern_ident(span, prefix, i); + let path = ident.with_span_pos(struct_field.span); + (struct_field.ident, cx.pat_ident(path.span, path)) + }); + + let struct_path = struct_path.clone(); + match *struct_def { + VariantData::Struct { .. } => { + let field_pats = pieces_iter + .map(|(ident, pat)| ast::PatField { + ident: ident.expect("a braced struct with unnamed fields in `derive`"), + is_shorthand: false, + attrs: ast::AttrVec::new(), + id: ast::DUMMY_NODE_ID, + span: pat.span.with_ctxt(span.ctxt()), + pat: Box::new(pat), + is_placeholder: false, + }) + .collect(); + cx.pat_struct(span, struct_path, field_pats) + } + VariantData::Tuple(..) => { + let subpats = pieces_iter.map(|(_, subpat)| subpat).collect(); + cx.pat_tuple_struct(span, struct_path, subpats) + } + VariantData::Unit(..) => cx.pat_path(span, struct_path), + } + }) + .collect() +} + +fn create_fields(span: Span, struct_def: &VariantData, mk_exprs: F) -> Vec +where + F: Fn(usize, &ast::FieldDef, Span) -> Vec>, +{ + struct_def + .fields() + .iter() + .enumerate() + .map(|(i, struct_field)| { + // For this field, get an expr for each selflike_arg. E.g. for + // `PartialEq::eq`, one for each of `&self` and `other`. + let span = struct_field.span.with_ctxt(span.ctxt()); + let mut exprs: Vec<_> = mk_exprs(i, struct_field, span); + let self_expr = exprs.remove(0); + debug_assert!(exprs.len() <= 1); + FieldInfo { + span, + name: struct_field.ident, + self_expr, + other_selflike_expr: exprs.pop(), + maybe_scalar: struct_field.ty.peel_refs().kind.maybe_scalar(), + } + }) + .collect() +} + +fn mk_pattern_ident(span: Span, prefix: &str, i: usize) -> Ident { + Ident::from_str_and_span(&format!("{prefix}_{i}"), span) +} + +fn create_struct_pattern_fields( + span: Span, + cx: &ExtCtxt<'_>, + struct_def: &VariantData, + prefixes: &[&str], +) -> Vec { + create_fields(span, struct_def, |i, _struct_field, sp| { prefixes .iter() .map(|prefix| { - let pieces_iter = - struct_def.fields().iter().enumerate().map(|(i, struct_field)| { - let sp = struct_field.span.with_ctxt(self.span.ctxt()); - let ident = self.mk_pattern_ident(prefix, i); - let path = ident.with_span_pos(sp); - (struct_field.ident, cx.pat_ident(path.span, path)) - }); - - let struct_path = struct_path.clone(); - match *struct_def { - VariantData::Struct { .. } => { - let field_pats = pieces_iter - .map(|(ident, pat)| ast::PatField { - ident: ident - .expect("a braced struct with unnamed fields in `derive`"), - is_shorthand: false, - attrs: ast::AttrVec::new(), - id: ast::DUMMY_NODE_ID, - span: pat.span.with_ctxt(self.span.ctxt()), - pat: Box::new(pat), - is_placeholder: false, - }) - .collect(); - cx.pat_struct(self.span, struct_path, field_pats) - } - VariantData::Tuple(..) => { - let subpats = pieces_iter.map(|(_, subpat)| subpat).collect(); - cx.pat_tuple_struct(self.span, struct_path, subpats) - } - VariantData::Unit(..) => cx.pat_path(self.span, struct_path), - } + let ident = mk_pattern_ident(span, prefix, i); + cx.expr_path(cx.path_ident(sp, ident)) }) .collect() - } + }) +} - fn create_fields(&self, struct_def: &'a VariantData, mk_exprs: F) -> Vec - where - F: Fn(usize, &ast::FieldDef, Span) -> Vec>, - { - struct_def - .fields() +fn create_struct_field_access_fields( + span: Span, + cx: &ExtCtxt<'_>, + selflike_args: &[Box], + struct_def: &VariantData, + is_packed: bool, +) -> Vec { + create_fields(span, struct_def, |i, struct_field, sp| { + selflike_args .iter() - .enumerate() - .map(|(i, struct_field)| { - // For this field, get an expr for each selflike_arg. E.g. for - // `PartialEq::eq`, one for each of `&self` and `other`. - let span = struct_field.span.with_ctxt(self.span.ctxt()); - let mut exprs: Vec<_> = mk_exprs(i, struct_field, span); - let self_expr = exprs.remove(0); - debug_assert!(exprs.len() <= 1); - FieldInfo { - span, - name: struct_field.ident, - self_expr, - other_selflike_expr: exprs.pop(), - maybe_scalar: struct_field.ty.peel_refs().kind.maybe_scalar(), + .map(|selflike_arg| { + // Note: we must use `struct_field.span` rather than `sp` in the + // `unwrap_or_else` case otherwise the hygiene is wrong and we get + // "field `0` of struct `Point` is private" errors on tuple + // structs. + let mut field_expr = cx.expr( + sp, + ast::ExprKind::Field( + selflike_arg.clone(), + struct_field.ident.unwrap_or_else(|| { + Ident::from_str_and_span(&i.to_string(), struct_field.span) + }), + ), + ); + if is_packed { + // Fields in packed structs are wrapped in a block, e.g. `&{self.0}`, + // causing a copy instead of a (potentially misaligned) reference. + field_expr = cx.expr_block( + cx.block(struct_field.span, thin_vec![cx.stmt_expr(field_expr)]), + ); } + cx.expr_addr_of(sp, field_expr) }) .collect() - } - - fn mk_pattern_ident(&self, prefix: &str, i: usize) -> Ident { - Ident::from_str_and_span(&format!("{prefix}_{i}"), self.span) - } - - fn create_struct_pattern_fields( - &self, - cx: &ExtCtxt<'_>, - struct_def: &'a VariantData, - prefixes: &[String], - ) -> Vec { - self.create_fields(struct_def, |i, _struct_field, sp| { - prefixes - .iter() - .map(|prefix| { - let ident = self.mk_pattern_ident(prefix, i); - cx.expr_path(cx.path_ident(sp, ident)) - }) - .collect() - }) - } - - fn create_struct_field_access_fields( - &self, - cx: &ExtCtxt<'_>, - selflike_args: &[Box], - struct_def: &'a VariantData, - is_packed: bool, - ) -> Vec { - self.create_fields(struct_def, |i, struct_field, sp| { - selflike_args - .iter() - .map(|selflike_arg| { - // Note: we must use `struct_field.span` rather than `sp` in the - // `unwrap_or_else` case otherwise the hygiene is wrong and we get - // "field `0` of struct `Point` is private" errors on tuple - // structs. - let mut field_expr = cx.expr( - sp, - ast::ExprKind::Field( - selflike_arg.clone(), - struct_field.ident.unwrap_or_else(|| { - Ident::from_str_and_span(&i.to_string(), struct_field.span) - }), - ), - ); - if is_packed { - // Fields in packed structs are wrapped in a block, e.g. `&{self.0}`, - // causing a copy instead of a (potentially misaligned) reference. - field_expr = cx.expr_block( - cx.block(struct_field.span, thin_vec![cx.stmt_expr(field_expr)]), - ); - } - cx.expr_addr_of(sp, field_expr) - }) - .collect() - }) - } -} - -/// Folds over fields, combining the expressions for each field in a sequence. -/// Statics may not be folded over. -pub(crate) fn cs_foldr( - cx: &ExtCtxt<'_>, - trait_span: Span, - substructure: Substructure<'_>, - // The basic case: a field expression for one or more selflike args. E.g. - // for `PartialEq::eq` this is something like `self.x == other.x`. - single: impl Fn(FieldInfo) -> Box, - // The combination of two field expressions. E.g. for `PartialEq::eq` this - // is something like ` && `. - combine: impl Fn(Span, Box, Box) -> Box, - // The fallback case for a struct or enum variant with no fields. - fieldless: impl Fn() -> Box, -) -> Box { - match substructure { - EnumMatching(.., all_fields) | Struct(_, all_fields) => { - let mut fields = all_fields.into_iter(); - let base_field = fields.next_back(); - - let Some(base_field) = base_field else { - return fieldless(); - }; - - let base_expr = single(base_field); - - let op = |old, field: FieldInfo| { - let span = field.span; - let new = single(field); - combine(span, old, new) - }; - - fields.rfold(base_expr, op) - } - EnumDiscr(discr_field, match_expr) => { - let discr_check_expr = single(discr_field); - if let Some(match_expr) = match_expr { - combine(trait_span, match_expr, discr_check_expr) - } else { - discr_check_expr - } - } - _ => cx.dcx().span_bug(trait_span, "unexpected substructure in `derive`"), - } + }) } diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/ty.rs b/compiler/rustc_builtin_macros/src/deriving/generic/ty.rs deleted file mode 100644 index 8f2de7a46fa18..0000000000000 --- a/compiler/rustc_builtin_macros/src/deriving/generic/ty.rs +++ /dev/null @@ -1,53 +0,0 @@ -//! A mini version of ast::Ty, which is easier to use, and features an explicit `Self` type to use -//! when specifying impls to be derived. - -use std::iter::once; - -pub(crate) use Ty::*; -use rustc_ast::{self as ast, GenericArg}; -use rustc_expand::base::ExtCtxt; -use rustc_span::{Ident, Span, Symbol, kw}; -use thin_vec::ThinVec; - -pub(crate) fn new_path(cx: &ExtCtxt<'_>, span: Span, path: &[Symbol], params: &[Ty]) -> ast::Path { - let idents = path.iter().map(|s| Ident::new(*s, span)); - let tys = params.iter().map(|t| t.to_ty(cx, span)); - let params = tys.map(GenericArg::Type).collect(); - - let idents = once(Ident::new(kw::DollarCrate, span)).chain(idents).collect(); - cx.path_all(span, false, idents, params) -} - -/// A type. Supports pointers, Self, literals, unit or an arbitrary AST path. -#[derive(Clone)] -pub(crate) enum Ty { - Self_, - /// A reference. - Ref(Box, ast::Mutability), - /// `mod::mod::Type<[lifetime], [Params...]>`, including a plain type - /// parameter, and things like `i32` - Path(ast::Path), - /// For () return types. - Unit, - /// An arbitrary type. - AstTy(Box), -} - -pub(crate) fn self_ref() -> Ty { - Ref(Box::new(Self_), ast::Mutability::Not) -} - -impl Ty { - pub(crate) fn to_ty(&self, cx: &ExtCtxt<'_>, span: Span) -> Box { - match self { - Ref(ty, mutbl) => { - let raw_ty = ty.to_ty(cx, span); - cx.ty_ref(span, raw_ty, None, *mutbl) - } - Path(p) => cx.ty_path(p.clone()), - Self_ => cx.ty_path(cx.path_ident(span, Ident::new(kw::SelfUpper, span))), - Unit => cx.ty(span, ast::TyKind::Tup(ThinVec::new())), - AstTy(ty) => ty.clone(), - } - } -} diff --git a/compiler/rustc_builtin_macros/src/deriving/hash.rs b/compiler/rustc_builtin_macros/src/deriving/hash.rs index 55c1d338c5d2d..3d3023b39955d 100644 --- a/compiler/rustc_builtin_macros/src/deriving/hash.rs +++ b/compiler/rustc_builtin_macros/src/deriving/hash.rs @@ -1,11 +1,10 @@ use rustc_ast::{Mutability, Safety}; use rustc_expand::base::ExtCtxt; -use rustc_span::{Ident, Span, sym}; +use rustc_span::{Ident, Span, kw, sym}; use thin_vec::{ThinVec, thin_vec}; -use crate::deriving::generic::ty::*; use crate::deriving::generic::*; -use crate::deriving::path_std; +use crate::deriving::{call_discriminant_value, path_std}; pub(crate) fn expand_deriving_hash( cx: &ExtCtxt<'_>, @@ -18,7 +17,7 @@ pub(crate) fn expand_deriving_hash( let typaram = Ident::new(sym::__H, span); - let arg = cx.path_ident(span, typaram); + let arg = cx.ty_path(cx.path_ident(span, typaram)); let param = { let path = path_std!(cx, span, hash::Hasher); @@ -42,13 +41,13 @@ pub(crate) fn expand_deriving_hash( name: sym::hash, generics, explicit_self: true, - nonself_args: smallvec![(Ref(Box::new(Path(arg)), Mutability::Mut), sym::state)], - ret_ty: Unit, + nonself_args: smallvec![(cx.ty_ref(span, arg, None, Mutability::Mut), sym::state)], + has_other_selflike_arg: false, + ret_ty: cx.ty_unit(span), attributes: thin_vec![cx.attr_word(sym::inline, span)], fieldless_variants_strategy: FieldlessVariantsStrategy::Unify, combine_substructure: combine_substructure(hash_substructure), }], - associated_types: SmallVec::new(), is_const, safety: Safety::Default, document: true, @@ -57,15 +56,12 @@ pub(crate) fn expand_deriving_hash( hash_trait_def.expand(cx, item, push); } -fn hash_substructure(cx: &ExtCtxt<'_>, trait_span: Span, substr: Substructure<'_>) -> BlockOrExpr { +fn hash_substructure(cx: &ExtCtxt<'_>, span: Span, substr: Substructure<'_>) -> BlockOrExpr { let call_hash = |span, expr| { let strs = cx.std_path(&[sym::hash, sym::Hash, sym::hash]); let hash_path = cx.expr_path(cx.path_global(span, strs)); - let expr = cx.expr_call( - span, - hash_path, - thin_vec![expr, cx.expr_ident(span, Ident::new(sym::state, span))], - ); + let expr = + cx.expr_call(span, hash_path, thin_vec![expr, cx.expr_ident_sym(span, sym::state)]); cx.stmt_expr(expr) }; @@ -75,12 +71,14 @@ fn hash_substructure(cx: &ExtCtxt<'_>, trait_span: Span, substr: Substructure<'_ fields.into_iter().map(|field| call_hash(field.span, field.self_expr)).collect(); (stmts, None) } - EnumDiscr(discr_field, match_expr) => { - assert!(discr_field.other_selflike_expr.is_none()); - let stmts = thin_vec![call_hash(discr_field.span, discr_field.self_expr)]; + EnumDiscr(match_expr) => { + let stmts = thin_vec![call_hash( + span, + cx.expr_addr_of(span, call_discriminant_value(cx, span, kw::SelfLower)) + )]; (stmts, match_expr) } - _ => cx.dcx().span_bug(trait_span, "unexpected substructure in `derive(Hash)`"), + _ => cx.dcx().span_bug(span, "unexpected substructure in `derive(Hash)`"), }; BlockOrExpr::new_mixed(stmts, match_expr) diff --git a/compiler/rustc_builtin_macros/src/deriving/mod.rs b/compiler/rustc_builtin_macros/src/deriving/mod.rs index 66d4a61b97fdc..c4af6ac16bdc6 100644 --- a/compiler/rustc_builtin_macros/src/deriving/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/mod.rs @@ -1,9 +1,11 @@ //! The compiler code necessary to implement the `#[derive]` extensions. +use std::iter::once; + use rustc_ast as ast; use rustc_ast::{GenericArg, MetaItem}; use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, MultiItemModifier}; -use rustc_span::{Span, Symbol, sym}; +use rustc_span::{Ident, Span, Symbol, kw, sym}; use thin_vec::{ThinVec, thin_vec}; macro pathvec($($rest:ident)::+) {{ @@ -11,7 +13,7 @@ macro pathvec($($rest:ident)::+) {{ }} macro path_std($cx: expr, $span: expr, $($x:tt)*) { - generic::ty::new_path($cx, $span, pathvec!( $($x)* ), &[] ) + new_path($cx, $span, pathvec!( $($x)* ), vec![] ) } pub(crate) mod clone; @@ -87,6 +89,11 @@ fn call_intrinsic( cx.expr_call_global(span, path, args) } +/// Constructs an expression that calls the `discriminant_value` intrinsic. +fn call_discriminant_value(cx: &ExtCtxt<'_>, span: Span, arg: Symbol) -> Box { + call_intrinsic(cx, span, sym::discriminant_value, thin_vec![cx.expr_ident_sym(span, arg)]) +} + /// Constructs an expression that calls the `unreachable` intrinsic. fn call_unreachable(cx: &ExtCtxt<'_>, span: Span) -> Box { let call = call_intrinsic(cx, span, sym::unreachable, ThinVec::new()); @@ -110,3 +117,11 @@ fn assert_ty_bounds( let assert_path = cx.path_all(span, true, cx.std_path(assert_path), vec![GenericArg::Type(ty)]); stmts.push(cx.stmt_let_type_only(span, cx.ty_path(assert_path))); } + +fn new_path(cx: &ExtCtxt<'_>, span: Span, path: &[Symbol], params: Vec>) -> ast::Path { + let idents = path.iter().map(|s| Ident::new(*s, span)); + let params = params.into_iter().map(GenericArg::Type).collect(); + + let idents = once(Ident::new(kw::DollarCrate, span)).chain(idents).collect(); + cx.path_all(span, false, idents, params) +} diff --git a/compiler/rustc_builtin_macros/src/deriving/ord.rs b/compiler/rustc_builtin_macros/src/deriving/ord.rs index 426fa41a3b6d4..c20bfc81bd409 100644 --- a/compiler/rustc_builtin_macros/src/deriving/ord.rs +++ b/compiler/rustc_builtin_macros/src/deriving/ord.rs @@ -1,10 +1,10 @@ use rustc_ast::Safety; use rustc_expand::base::ExtCtxt; -use rustc_span::{Ident, Span, sym}; +use rustc_span::{Span, sym}; use thin_vec::thin_vec; -use crate::deriving::generic::ty::*; use crate::deriving::generic::*; +use crate::deriving::partial_ord::{OrdlikeDerive, cmp_body, discr_data_order}; use crate::deriving::path_std; pub(crate) fn expand_deriving_ord( @@ -14,6 +14,8 @@ pub(crate) fn expand_deriving_ord( push: &mut dyn FnMut(Box), is_const: bool, ) { + let discr_then_data = discr_data_order(item); + let trait_def = TraitDef { span, path: path_std!(cx, span, cmp::Ord), @@ -25,13 +27,18 @@ pub(crate) fn expand_deriving_ord( name: sym::cmp, generics: cx.empty_generics(span), explicit_self: true, - nonself_args: smallvec![(self_ref(), sym::other)], - ret_ty: Path(path_std!(cx, span, cmp::Ordering)), + nonself_args: smallvec![(cx.ty_self_ref(span), sym::other)], + has_other_selflike_arg: true, + ret_ty: cx.ty_path(path_std!(cx, span, cmp::Ordering)), attributes: thin_vec![cx.attr_word(sym::inline, span)], fieldless_variants_strategy: FieldlessVariantsStrategy::Unify, - combine_substructure: combine_substructure(cs_cmp), + combine_substructure: combine_substructure(|cx, span, substr| cs_cmp( + cx, + span, + substr, + discr_then_data + )), }], - associated_types: SmallVec::new(), is_const, safety: Safety::Default, document: true, @@ -40,11 +47,12 @@ pub(crate) fn expand_deriving_ord( trait_def.expand(cx, item, push) } -pub(crate) fn cs_cmp(cx: &ExtCtxt<'_>, span: Span, substr: Substructure<'_>) -> BlockOrExpr { - let test_id = Ident::new(sym::cmp, span); - let equal_path = cx.path_global(span, cx.std_path(&[sym::cmp, sym::Ordering, sym::Equal])); - let cmp_path = cx.std_path(&[sym::cmp, sym::Ord, sym::cmp]); - +pub(crate) fn cs_cmp( + cx: &ExtCtxt<'_>, + span: Span, + substr: Substructure<'_>, + discr_then_data: bool, +) -> BlockOrExpr { // Builds: // // match ::core::cmp::Ord::cmp(&self.x, &other.x) { @@ -52,22 +60,6 @@ pub(crate) fn cs_cmp(cx: &ExtCtxt<'_>, span: Span, substr: Substructure<'_>) -> // ::core::cmp::Ord::cmp(&self.y, &other.y), // cmp => cmp, // } - let expr = cs_foldr( - cx, - span, - substr, - |field| { - let other_expr = - field.other_selflike_expr.expect("not exactly 2 arguments in `derive(Ord)`"); - let args = thin_vec![field.self_expr, other_expr]; - cx.expr_call_global(field.span, cmp_path.clone(), args) - }, - |span, expr1, expr2| { - let eq_arm = cx.arm(span, cx.pat_path(span, equal_path.clone()), expr1); - let neq_arm = cx.arm(span, cx.pat_ident(span, test_id), cx.expr_ident(span, test_id)); - cx.expr_match(span, expr2, thin_vec![eq_arm, neq_arm]) - }, - || cx.expr_path(equal_path.clone()), - ); + let expr = cmp_body(cx, span, substr, discr_then_data, OrdlikeDerive::Ord); BlockOrExpr::new_expr(expr) } diff --git a/compiler/rustc_builtin_macros/src/deriving/partial_eq.rs b/compiler/rustc_builtin_macros/src/deriving/partial_eq.rs index 5c8a6225fa91b..377a32dcca4f0 100644 --- a/compiler/rustc_builtin_macros/src/deriving/partial_eq.rs +++ b/compiler/rustc_builtin_macros/src/deriving/partial_eq.rs @@ -1,11 +1,10 @@ use rustc_ast::{BinOpKind, BorrowKind, Expr, ExprKind, Mutability, Safety}; use rustc_expand::base::ExtCtxt; -use rustc_span::{Ident, Span, sym}; +use rustc_span::{Ident, Span, kw, sym}; use thin_vec::thin_vec; -use crate::deriving::generic::ty::*; use crate::deriving::generic::*; -use crate::deriving::path_std; +use crate::deriving::{call_discriminant_value, path_std}; /// Expands a `#[derive(PartialEq)]` attribute into an implementation for the /// target item. @@ -29,7 +28,6 @@ pub(crate) fn expand_deriving_partial_eq( // a second check here would lead to redundant error messages. supports_unions: true, methods: SmallVec::new(), - associated_types: SmallVec::new(), is_const: false, safety: Safety::Default, document: true, @@ -42,8 +40,9 @@ pub(crate) fn expand_deriving_partial_eq( name: sym::eq, generics: cx.empty_generics(span), explicit_self: true, - nonself_args: smallvec![(self_ref(), sym::other)], - ret_ty: Path(cx.path_ident(span, Ident::new(sym::bool, span))), + nonself_args: smallvec![(cx.ty_self_ref(span), sym::other)], + has_other_selflike_arg: true, + ret_ty: cx.ty_path(cx.path_ident(span, Ident::new(sym::bool, span))), attributes: thin_vec![cx.attr_word(sym::inline, span)], fieldless_variants_strategy: FieldlessVariantsStrategy::Unify, combine_substructure: combine_substructure(get_substructure_equality_expr), @@ -57,7 +56,6 @@ pub(crate) fn expand_deriving_partial_eq( additional_bounds: SmallVec::new(), supports_unions: false, methods, - associated_types: SmallVec::new(), is_const, safety: Safety::Default, document: true, @@ -123,8 +121,18 @@ fn get_substructure_equality_expr( ) -> BlockOrExpr { BlockOrExpr::new_expr(match substructure { EnumMatching(.., fields) | Struct(.., fields) => { - let combine = move |acc, field| { - let rhs = get_field_equality_expr(cx, field); + let combine = move |acc, field: &FieldInfo| { + let rhs = field + .other_selflike_expr + .as_ref() + .expect("not exactly 2 arguments in `derive(PartialEq)`"); + + let rhs = cx.expr_binary( + field.span, + BinOpKind::Eq, + wrap_block_expr(cx, peel_refs(&field.self_expr)), + wrap_block_expr(cx, peel_refs(rhs)), + ); match acc { // Combine the previous comparison with the current field // using logical AND. @@ -144,43 +152,21 @@ fn get_substructure_equality_expr( // If there are no fields, treat as always equal. .unwrap_or_else(|| cx.expr_bool(span, true)) } - EnumDiscr(disc, match_expr) => { - let lhs = get_field_equality_expr(cx, &disc); + EnumDiscr(match_expr) => { + let self_expr = call_discriminant_value(cx, span, kw::SelfLower); + let other_selflike_expr = call_discriminant_value(cx, span, sym::other); + let lhs = cx.expr_binary(span, BinOpKind::Eq, self_expr, other_selflike_expr); let Some(match_expr) = match_expr else { return BlockOrExpr::new_expr(lhs); }; // Compare the discriminant first (cheaper), then the rest of the // fields. - cx.expr_binary(disc.span, BinOpKind::And, lhs, match_expr.clone()) + cx.expr_binary(span, BinOpKind::And, lhs, match_expr) } _ => cx.dcx().span_bug(span, "unexpected substructure in `derive(PartialEq)`"), }) } -/// Generates an equality comparison expression for a single struct or enum -/// field. -/// -/// This function produces an AST expression that compares the `self` and -/// `other` values for a field using `==`. It removes any leading references -/// from both sides for readability. If the field is a block expression, it is -/// wrapped in parentheses to ensure valid syntax. -/// -/// # Panics -/// -/// Panics if there are not exactly two arguments to compare (should be `self` -/// and `other`). -fn get_field_equality_expr(cx: &ExtCtxt<'_>, field: &FieldInfo) -> Box { - let rhs = - field.other_selflike_expr.as_ref().expect("not exactly 2 arguments in `derive(PartialEq)`"); - - cx.expr_binary( - field.span, - BinOpKind::Eq, - wrap_block_expr(cx, peel_refs(&field.self_expr)), - wrap_block_expr(cx, peel_refs(rhs)), - ) -} - /// Removes all leading immutable references from an expression. /// /// This is used to strip away any number of leading `&` from an expression diff --git a/compiler/rustc_builtin_macros/src/deriving/partial_ord.rs b/compiler/rustc_builtin_macros/src/deriving/partial_ord.rs index e176152c507c9..8c3e2ee58f8e2 100644 --- a/compiler/rustc_builtin_macros/src/deriving/partial_ord.rs +++ b/compiler/rustc_builtin_macros/src/deriving/partial_ord.rs @@ -1,11 +1,10 @@ -use rustc_ast::{ExprKind, ItemKind, PatKind, Safety, ast}; +use rustc_ast::{Expr, ItemKind, Safety, ast}; use rustc_expand::base::ExtCtxt; -use rustc_span::{Ident, Span, sym}; +use rustc_span::{Ident, Span, kw, sym}; use thin_vec::thin_vec; -use crate::deriving::generic::ty::*; use crate::deriving::generic::*; -use crate::deriving::{path_std, pathvec}; +use crate::deriving::{call_discriminant_value, new_path, path_std, pathvec}; pub(crate) fn expand_deriving_partial_ord( cx: &ExtCtxt<'_>, @@ -14,36 +13,18 @@ pub(crate) fn expand_deriving_partial_ord( push: &mut dyn FnMut(Box), is_const: bool, ) { - let ordering_ty = Path(path_std!(cx, span, cmp::Ordering)); - let ret_ty = Path(new_path(cx, span, pathvec!(option::Option), &[ordering_ty])); + let ordering_ty = cx.ty_path(path_std!(cx, span, cmp::Ordering)); + let ret_ty = cx.ty_path(new_path(cx, span, pathvec!(option::Option), vec![ordering_ty])); // Order in which to perform matching - let discr_then_data = if let ItemKind::Enum(_, _, def) = &item.kind { - let dataful: Vec = def.variants.iter().map(|v| !v.data.fields().is_empty()).collect(); - match dataful.iter().filter(|&&b| b).count() { - // No data, placing the discriminant check first makes codegen simpler - 0 => true, - 1..=2 => false, - _ => (0..dataful.len() - 1).any(|i| { - if dataful[i] - && let Some(idx) = dataful[i + 1..].iter().position(|v| *v) - { - idx >= 2 - } else { - false - } - }), - } - } else { - true - }; + let discr_then_data = discr_data_order(item); let container_id = cx.current_expansion.id.expn_data().parent.expect_local(); let has_derive_ord = cx.resolver.has_derive_ord(container_id); let default_substructure = combine_substructure(|cx, span, substr| cs_partial_cmp(cx, span, substr, discr_then_data)); let simple_substructure = combine_substructure(|cx, span, _| { - cs_partial_cmp_simple(cx, span, cx.expr_ident(span, Ident::new(sym::other, span))) + cs_partial_cmp_simple(cx, span, cx.expr_ident_sym(span, sym::other)) }); let is_simple = match &item.kind { // For unit structs/zero-variant enums, the default generated code is better. @@ -72,7 +53,8 @@ pub(crate) fn expand_deriving_partial_ord( name: sym::partial_cmp, generics: cx.empty_generics(span), explicit_self: true, - nonself_args: smallvec![(self_ref(), sym::other)], + nonself_args: smallvec![(cx.ty_self_ref(span), sym::other)], + has_other_selflike_arg: true, ret_ty, attributes: thin_vec![cx.attr_word(sym::inline, span)], fieldless_variants_strategy: FieldlessVariantsStrategy::Unify, @@ -87,7 +69,6 @@ pub(crate) fn expand_deriving_partial_ord( additional_bounds: smallvec![], supports_unions: false, methods: smallvec![partial_cmp_def], - associated_types: SmallVec::new(), is_const, safety: Safety::Default, document: true, @@ -95,6 +76,28 @@ pub(crate) fn expand_deriving_partial_ord( trait_def.expand_ext(cx, item, push, is_simple) } +pub(crate) fn discr_data_order(item: &ast::Item) -> bool { + if let ItemKind::Enum(_, _, def) = &item.kind { + let dataful: Vec = def.variants.iter().map(|v| !v.data.fields().is_empty()).collect(); + match dataful.iter().filter(|&&b| b).count() { + // No data, placing the discriminant check first makes codegen simpler + 0 => true, + 1..=2 => false, + _ => (0..dataful.len() - 1).any(|i| { + if dataful[i] + && let Some(idx) = dataful[i + 1..].iter().position(|v| *v) + { + idx >= 2 + } else { + false + } + }), + } + } else { + true + } +} + // Special case for the type deriving both `PartialOrd` and `Ord`. Builds: // ``` // Some(::core::cmp::Ord::cmp(self, other)) @@ -112,10 +115,6 @@ fn cs_partial_cmp( substr: Substructure<'_>, discr_then_data: bool, ) -> BlockOrExpr { - let test_id = Ident::new(sym::cmp, span); - let equal_path = cx.path_global(span, cx.std_path(&[sym::cmp, sym::Ordering, sym::Equal])); - let partial_cmp_path = cx.std_path(&[sym::cmp, sym::PartialOrd, sym::partial_cmp]); - // Builds: // // match ::core::cmp::PartialOrd::partial_cmp(&self.x, &other.x) { @@ -123,63 +122,121 @@ fn cs_partial_cmp( // ::core::cmp::PartialOrd::partial_cmp(&self.y, &other.y), // cmp => cmp, // } - let expr = cs_foldr( - cx, - span, - substr, - |field| { - let other_expr = - field.other_selflike_expr.expect("not exactly 2 arguments in `derive(PartialOrd)`"); - let args = thin_vec![field.self_expr, other_expr]; - cx.expr_call_global(field.span, partial_cmp_path.clone(), args) - }, - |span, mut expr1, expr2| { - // When the item is an enum, this expands to - // ``` - // match (expr2) { - // Some(Ordering::Equal) => expr1, - // cmp => cmp - // } - // ``` - // where `expr2` is `partial_cmp(self_discr, other_discr)`, and `expr1` is a `match` - // against the enum variants. This means that we begin by comparing the enum discriminants, - // before either inspecting their contents (if they match), or returning - // the `cmp::Ordering` of comparing the enum discriminants. - // ``` - // match partial_cmp(self_discr, other_discr) { - // Some(Ordering::Equal) => match (self, other) { - // (Self::A(self_0), Self::A(other_0)) => partial_cmp(self_0, other_0), - // (Self::B(self_0), Self::B(other_0)) => partial_cmp(self_0, other_0), - // _ => Some(Ordering::Equal) - // } - // cmp => cmp - // } - // ``` - // If we have any certain enum layouts, flipping this results in better codegen - // ``` - // match (self, other) { - // (Self::A(self_0), Self::A(other_0)) => partial_cmp(self_0, other_0), - // _ => partial_cmp(self_discr, other_discr) - // } - // ``` - // Reference: https://github.com/rust-lang/rust/pull/103659#issuecomment-1328126354 + let expr = cmp_body(cx, span, substr, discr_then_data, OrdlikeDerive::PartialOrd); + BlockOrExpr::new_expr(expr) +} + +#[derive(PartialEq)] +pub(crate) enum OrdlikeDerive { + PartialOrd, + Ord, +} + +pub(crate) fn cmp_body( + cx: &ExtCtxt<'_>, + span: Span, + substructure: Substructure<'_>, + discr_then_data: bool, + derive: OrdlikeDerive, +) -> Box { + let is_partial_ord = derive == OrdlikeDerive::PartialOrd; + let method_path = if is_partial_ord { + cx.std_path(&[sym::cmp, sym::PartialOrd, sym::partial_cmp]) + } else { + cx.std_path(&[sym::cmp, sym::Ord, sym::cmp]) + }; + let equal_path = cx.path_global(span, cx.std_path(&[sym::cmp, sym::Ordering, sym::Equal])); + + // The combination of two field expressions. E.g. for `Ord::cmp` this + // is something like ` && `. + let combine = |span, mut expr1: Box, expr2| { + // For `PartialOrd` (`Ord` works the same but without the `Some` wrapping), + // when the item is an enum, this expands to + // ``` + // match (expr2) { + // Some(Ordering::Equal) => expr1, + // cmp => cmp + // } + // ``` + // where `expr2` is `partial_cmp(self_discr, other_discr)`, and `expr1` is a `match` + // against the enum variants. This means that we begin by comparing the enum discriminants, + // before either inspecting their contents (if they match), or returning + // the `cmp::Ordering` of comparing the enum discriminants. + // ``` + // match partial_cmp(self_discr, other_discr) { + // Some(Ordering::Equal) => match (self, other) { + // (Self::A(self_0), Self::A(other_0)) => partial_cmp(self_0, other_0), + // (Self::B(self_0), Self::B(other_0)) => partial_cmp(self_0, other_0), + // _ => Some(Ordering::Equal) + // } + // cmp => cmp + // } + // ``` + // If we have any certain enum layouts, flipping this results in better codegen + // ``` + // match (self, other) { + // (Self::A(self_0), Self::A(other_0)) => partial_cmp(self_0, other_0), + // _ => partial_cmp(self_discr, other_discr) + // } + // ``` + // Reference: https://github.com/rust-lang/rust/pull/103659#issuecomment-1328126354 - if !discr_then_data - && let ExprKind::Match(_, arms, _) = &mut expr1.kind - && let Some(last) = arms.last_mut() - && let PatKind::Wild = last.pat.kind - { - last.body = Some(expr2); - expr1 + if !discr_then_data + && let ast::ExprKind::Match(_, arms, _) = &mut expr1.kind + && let Some(last) = arms.last_mut() + && let ast::PatKind::Wild = last.pat.kind + { + last.body = Some(expr2); + expr1 + } else { + let eq_pat = cx.pat_path(span, equal_path.clone()); + let eq_arm = cx.arm( + span, + if is_partial_ord { cx.pat_some(span, eq_pat) } else { eq_pat }, + expr1, + ); + let cmp_ident = Ident::new(sym::cmp, span); + let neq_arm = + cx.arm(span, cx.pat_ident(span, cmp_ident), cx.expr_ident(span, cmp_ident)); + cx.expr_match(span, expr2, thin_vec![eq_arm, neq_arm]) + } + }; + + match substructure { + EnumMatching(.., all_fields) | Struct(_, all_fields) => { + let op = |old, field: FieldInfo| { + // The basic case: a field expression for one or more selflike args. E.g. + // for `Ord::cmp` this is something like `Ord::cmp(&self.x, &other.x)`. + let other_expr = + field.other_selflike_expr.expect("not exactly 2 arguments in `derive`"); + let args = thin_vec![field.self_expr, other_expr]; + let new = cx.expr_call_global(field.span, method_path.clone(), args); + match old { + Some(old) => Some(combine(field.span, old, new)), + None => Some(new), + } + }; + + all_fields.into_iter().rfold(None, op).unwrap_or_else(|| { + // The fallback case for a struct or enum variant with no fields. + let mut expr = cx.expr_path(equal_path); + if is_partial_ord { + expr = cx.expr_some(span, expr) + }; + expr + }) + } + EnumDiscr(match_expr) => { + let self_expr = cx.expr_addr_of(span, call_discriminant_value(cx, span, kw::SelfLower)); + let other_expr = cx.expr_addr_of(span, call_discriminant_value(cx, span, sym::other)); + let args = thin_vec![self_expr, other_expr]; + let discr_check_expr = cx.expr_call_global(span, method_path, args); + if let Some(match_expr) = match_expr { + combine(span, match_expr, discr_check_expr) } else { - let eq_arm = - cx.arm(span, cx.pat_some(span, cx.pat_path(span, equal_path.clone())), expr1); - let neq_arm = - cx.arm(span, cx.pat_ident(span, test_id), cx.expr_ident(span, test_id)); - cx.expr_match(span, expr2, thin_vec![eq_arm, neq_arm]) + discr_check_expr } - }, - || cx.expr_some(span, cx.expr_path(equal_path.clone())), - ); - BlockOrExpr::new_expr(expr) + } + _ => cx.dcx().span_bug(span, "unexpected substructure in `derive`"), + } } diff --git a/compiler/rustc_codegen_llvm/src/asm.rs b/compiler/rustc_codegen_llvm/src/asm.rs index b20a89859388e..21888720524a5 100644 --- a/compiler/rustc_codegen_llvm/src/asm.rs +++ b/compiler/rustc_codegen_llvm/src/asm.rs @@ -791,12 +791,10 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'_>>) -> } else if let Some(idx) = hexagon_vreg_pair_index(reg) { // LLVM uses `wN` for Hexagon HVX vector pair registers. format!("{{w{}}}", idx) - } else if reg == InlineAsmReg::Arm(ArmInlineAsmReg::r14) - && llvm_util::get_version() < (23, 0, 0) - { + } else if reg == InlineAsmReg::Arm(ArmInlineAsmReg::r14) { // FIXME(llvm): LLVM <23 does not recognize `r14` as a register name // in inline assembly. - // This workaround can be removed when support for LLVM 22 is dropped. + // We can make this branch fallthrough again for LLVM 23+ when https://github.com/llvm/llvm-project/pull/225746 gets released. "{lr}".to_string() } else if let InlineAsmReg::Sparc(reg) = reg && let Some(num) = reg.dreg_number() diff --git a/compiler/rustc_codegen_llvm/src/back/owned_mc_subtarget_info.rs b/compiler/rustc_codegen_llvm/src/back/owned_mc_subtarget_info.rs index f57368e755add..1a85f1458d258 100644 --- a/compiler/rustc_codegen_llvm/src/back/owned_mc_subtarget_info.rs +++ b/compiler/rustc_codegen_llvm/src/back/owned_mc_subtarget_info.rs @@ -4,7 +4,7 @@ use std::ptr::NonNull; use rustc_data_structures::small_c_str::SmallCStr; use crate::diagnostics::LlvmError; -use crate::llvm; +use crate::{llvm, llvm_util}; /// Responsible for safely creating and disposing llvm::MCSubtargetInfo via ffi functions. /// Not cloneable as there is no clone function for llvm::MCSubtargetInfo. @@ -28,11 +28,20 @@ impl OwnedMCSubtargetInfo { .ok_or_else(|| LlvmError::CreateMCSubtargetInfo { triple: SmallCStr::from(triple) }) } - pub(crate) fn has_feature(&self, feature: &CStr) -> bool { - // SAFETY: `new` ensures we have a valid pointer created by + pub(crate) fn has_features(&self, features: llvm_util::LLVMFeature<'_>) -> bool { + // Convert to a feature string expected by LLVM's `SubtargetFeatures`. + // All of the required LLVM features must be enabled. + // (The trailing comma is OK, as `SubtargetFeatures::Split` discards empty substrings.) + let features = features.into_iter().flat_map(|feat| ["+", feat, ","]).collect::(); + + // SAFETY: `info_unique` is a valid pointer created by // `llvm::LLVMRustCreateMCSubtargetInfo`. unsafe { - llvm::LLVMRustMCSubtargetInfoHasFeature(self.info_unique.as_ref(), feature.as_ptr()) + llvm::LLVMRustMCSubtargetInfoCheckFeatures( + self.info_unique.as_ref(), + features.as_ptr(), + features.len(), + ) } } } diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 07381745afe84..655a79e341bd1 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -2422,9 +2422,10 @@ unsafe extern "C" { Features: *const c_char, ) -> *mut MCSubtargetInfo; - pub(crate) fn LLVMRustMCSubtargetInfoHasFeature( + pub(crate) fn LLVMRustMCSubtargetInfoCheckFeatures( MCInfo: &MCSubtargetInfo, - Feature: *const c_char, + Features: *const c_uchar, // See "PTR_LEN_STR". + FeaturesLen: usize, ) -> bool; pub(crate) fn LLVMRustDisposeMCSubtargetInfo(MCInfo: ptr::NonNull); diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 5c0ad95fc4e43..9e37205f230ac 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -361,17 +361,9 @@ pub(crate) fn target_config(sess: &EarlySession) -> TargetConfig { // do *not* consider the `-Ctarget-feature`s here (that's why we passed `for_cfg: true` // to `global_llvm_features` above) because that will be handled later in // `internal_target_features`. - if let Some(feat) = to_llvm_features(&sess.target, feature) { - // All the LLVM features this expands to must be enabled. - for llvm_feature in feat { - let cstr = SmallCStr::new(llvm_feature); - // `has_feature` is moderately expensive. On targets with many - // features (e.g. x86) these calls take a non-trivial fraction of runtime - // when compiling very small programs. - if !mc_subtarget_info.has_feature(&cstr) { - return false; - } - } + if let Some(feat) = to_llvm_features(&sess.target, feature) + && mc_subtarget_info.has_features(feat) + { true } else { false diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs b/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs index 490c634a1845a..fa6fc1368e133 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs @@ -503,7 +503,10 @@ fn coff_collect_impl<'data, Coff: CoffHeader>( if strip_underscore { name = name.strip_prefix('_').unwrap_or(&name).to_string(); } - if !exported.contains(&name) { + let is_exported = exported.contains(&name) + || (header.machine() == pe::IMAGE_FILE_MACHINE_ARM64EC + && name.strip_prefix('#').is_some_and(|name| exported.contains(name))); + if !is_exported { out.insert(name); } } diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 25a82b22707cc..97b8557b95ef6 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -384,7 +384,6 @@ pub enum StashKey { /// FRU syntax MaybeFruTypo, CallAssocMethod, - AssociatedTypeSuggestion, UndeterminedMacroResolution, /// Used by `Parser::maybe_recover_trailing_expr` ExprInPat, diff --git a/compiler/rustc_expand/src/build.rs b/compiler/rustc_expand/src/build.rs index 0e9d9ec5e8b7e..9a93d82a4fe4c 100644 --- a/compiler/rustc_expand/src/build.rs +++ b/compiler/rustc_expand/src/build.rs @@ -125,6 +125,17 @@ impl<'a> ExtCtxt<'a> { self.ty(span, ast::TyKind::Ptr(self.ty_mt(ty, mutbl))) } + pub fn ty_unit(&self, span: Span) -> Box { + self.ty(span, ast::TyKind::Tup(ThinVec::new())) + } + + pub fn ty_self(&self, span: Span) -> Box { + self.ty_path(self.path_ident(span, Ident::new(kw::SelfUpper, span))) + } + pub fn ty_self_ref(&self, span: Span) -> Box { + self.ty_ref(span, self.ty_self(span), None, ast::Mutability::Not) + } + pub fn typaram( &self, span: Span, @@ -310,6 +321,9 @@ impl<'a> ExtCtxt<'a> { pub fn expr_self(&self, span: Span) -> Box { self.expr_ident(span, Ident::new(kw::SelfLower, span)) } + pub fn expr_ident_sym(&self, span: Span, sym: Symbol) -> Box { + self.expr_ident(span, Ident::new(sym, span)) + } pub fn expr_macro_call(&self, span: Span, call: Box) -> Box { self.expr(span, ast::ExprKind::MacCall(call)) diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs index a3cba8ce15fda..9123afd5986f5 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs @@ -2,10 +2,7 @@ use rustc_ast::TraitObjectSyntax; use rustc_attr_ir::lang_items::LangItem; use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; use rustc_errors::codes::*; -use rustc_errors::{ - Applicability, Diag, DiagCtxtHandle, Diagnostic, Level, StashKey, Suggestions, - struct_span_code_err, -}; +use rustc_errors::{Applicability, Diag, DiagCtxtHandle, Diagnostic, Level, struct_span_code_err}; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_hir::{self as hir, HirId}; @@ -17,6 +14,7 @@ use rustc_middle::ty::{ }; use rustc_span::edit_distance::find_best_match_for_name; use rustc_span::{ErrorGuaranteed, Span}; +use rustc_trait_selection::diagnostics::AssocTypeWithSameName; use rustc_trait_selection::error_reporting::traits::report_dyn_incompatibility; use rustc_trait_selection::error_reporting::traits::suggestions::NextTypeParamName; use rustc_trait_selection::traits; @@ -655,15 +653,14 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { poly_trait_ref.trait_ref.trait_def_id(), &mut diag, ); - // In case there is an associated type with the same name - // Add the suggestion to this error - if let Some(mut sugg) = - self.dcx().steal_non_err(span, StashKey::AssociatedTypeSuggestion) - && let Suggestions::Enabled(ref mut s1) = diag.suggestions - && let Suggestions::Enabled(ref mut s2) = sugg.suggestions + // If there is an associated type with the same name, add the suggestion to this error. + if self + .tcx() + .resolutions(()) + .paths_matching_assoc_types + .contains(&span.with_parent(None)) { - s1.append(s2); - sugg.cancel(); + diag.subdiagnostic(AssocTypeWithSameName { span: span.shrink_to_lo() }); } Some(diag.emit_err()) } else { diff --git a/compiler/rustc_lint/src/diagnostics.rs b/compiler/rustc_lint/src/diagnostics.rs index 0f914893bf673..98a11f8e1df08 100644 --- a/compiler/rustc_lint/src/diagnostics.rs +++ b/compiler/rustc_lint/src/diagnostics.rs @@ -1040,9 +1040,10 @@ pub(crate) struct ForgetCopyDiag<'a> { #[derive(Diagnostic)] #[diag( - "calls to `std::mem::drop` with `std::mem::ManuallyDrop` instead of the inner value does nothing" + "calls to `{$krate}::mem::drop` with `{$krate}::mem::ManuallyDrop` instead of the inner value does nothing" )] pub(crate) struct UndroppedManuallyDropsDiag<'a> { + pub krate: &'static str, pub arg_ty: Ty<'a>, #[label("argument has type `{$arg_ty}`")] pub label: Span, @@ -1052,11 +1053,12 @@ pub(crate) struct UndroppedManuallyDropsDiag<'a> { #[derive(Subdiagnostic)] #[multipart_suggestion( - "use `std::mem::ManuallyDrop::into_inner` to get the inner value", + "use `{$krate}::mem::ManuallyDrop::into_inner` to get the inner value", applicability = "machine-applicable" )] pub(crate) struct UndroppedManuallyDropsSuggestion { - #[suggestion_part(code = "std::mem::ManuallyDrop::into_inner(")] + pub krate: &'static str, + #[suggestion_part(code = "{krate}::mem::ManuallyDrop::into_inner(")] pub start_span: Span, #[suggestion_part(code = ")")] pub end_span: Span, @@ -1064,9 +1066,10 @@ pub(crate) struct UndroppedManuallyDropsSuggestion { #[derive(Diagnostic)] #[diag( - "calls to `drop_in_place` with a pointer to a `std::mem::ManuallyDrop` instead of the inner value does nothing" + "calls to `drop_in_place` with a pointer to a `{$krate}::mem::ManuallyDrop` instead of the inner value does nothing" )] pub(crate) struct UndroppedManuallyDropsInPlaceDiag<'a> { + pub krate: &'static str, pub arg_ty: Ty<'a>, #[label("argument has type `{$arg_ty}`")] pub label: Span, @@ -1076,11 +1079,12 @@ pub(crate) struct UndroppedManuallyDropsInPlaceDiag<'a> { #[derive(Subdiagnostic)] #[multipart_suggestion( - "use `std::mem::ManuallyDrop::drop` to drop the inner value", + "use `{$krate}::mem::ManuallyDrop::drop` to drop the inner value", applicability = "maybe-incorrect" )] pub(crate) struct UndroppedManuallyDropsInPlaceSuggestion { - #[suggestion_part(code = "std::mem::ManuallyDrop::drop(&mut *")] + pub krate: &'static str, + #[suggestion_part(code = "{krate}::mem::ManuallyDrop::drop(&mut *")] pub start_span: Span, #[suggestion_part(code = ")")] pub end_span: Span, @@ -2074,9 +2078,6 @@ impl<'a> Diagnostic<'a> for DropGlue<'_> { #[note( "exposed provenance semantics can be used to create a pointer based on some previously exposed provenance" )] -#[help( - "if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut`" -)] #[help( "for more information about transmute, see " )] @@ -2084,34 +2085,46 @@ impl<'a> Diagnostic<'a> for DropGlue<'_> { "for more information about exposed provenance, see " )] pub(crate) struct IntegerToPtrTransmutes<'tcx> { + #[subdiagnostic] + pub without_prov: Option, #[subdiagnostic] pub suggestion: Option>, } +#[derive(Subdiagnostic)] +#[help( + "if you truly mean to create a pointer without provenance, use `{$krate}::ptr::without_provenance_mut`" +)] +pub(crate) struct IntegerToPtrWithoutProvHelp { + pub krate: &'static str, +} + #[derive(Subdiagnostic)] pub(crate) enum IntegerToPtrTransmutesSuggestion<'tcx> { #[multipart_suggestion( - "use `std::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance", + "use `{$krate}::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance", applicability = "machine-applicable", style = "verbose" )] ToPtr { + krate: &'static str, dst: Ty<'tcx>, suffix: &'static str, - #[suggestion_part(code = "std::ptr::with_exposed_provenance{suffix}::<{dst}>(")] + #[suggestion_part(code = "{krate}::ptr::with_exposed_provenance{suffix}::<{dst}>(")] start_call: Span, }, #[multipart_suggestion( - "use `std::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance", + "use `{$krate}::ptr::with_exposed_provenance{$suffix}` instead to use a previously exposed provenance", applicability = "machine-applicable", style = "verbose" )] ToRef { + krate: &'static str, dst: Ty<'tcx>, suffix: &'static str, ref_mutbl: &'static str, #[suggestion_part( - code = "&{ref_mutbl}*std::ptr::with_exposed_provenance{suffix}::<{dst}>(" + code = "&{ref_mutbl}*{krate}::ptr::with_exposed_provenance{suffix}::<{dst}>(" )] start_call: Span, }, @@ -2348,25 +2361,30 @@ pub(crate) enum AmbiguousWidePointerComparisons<'a> { #[diag( "ambiguous wide pointer comparison, the comparison includes metadata which may not be expected" )] - #[help("use explicit `std::ptr::eq` method to compare metadata and addresses")] - #[help("use `std::ptr::addr_eq` or untyped pointers to only compare their addresses")] - Spanless, + #[help("use explicit `{$krate}::ptr::eq` method to compare metadata and addresses")] + #[help("use `{$krate}::ptr::addr_eq` or untyped pointers to only compare their addresses")] + Spanless { krate: &'static str }, + #[diag( + "ambiguous wide pointer comparison, the comparison includes metadata which may not be expected" + )] + Warn, } #[derive(Subdiagnostic)] #[multipart_suggestion( - "use explicit `std::ptr::eq` method to compare metadata and addresses", + "use explicit `{$krate}::ptr::eq` method to compare metadata and addresses", style = "verbose", // FIXME(#53934): make machine-applicable again applicability = "maybe-incorrect" )] pub(crate) struct AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a> { + pub krate: &'static str, pub ne: &'a str, pub deref_left: &'a str, pub deref_right: &'a str, pub l_modifiers: &'a str, pub r_modifiers: &'a str, - #[suggestion_part(code = "{ne}std::ptr::eq({deref_left}")] + #[suggestion_part(code = "{ne}{krate}::ptr::eq({deref_left}")] pub left: Span, #[suggestion_part(code = "{l_modifiers}, {deref_right}")] pub middle: Span, @@ -2376,18 +2394,19 @@ pub(crate) struct AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a> { #[derive(Subdiagnostic)] #[multipart_suggestion( - "use `std::ptr::addr_eq` or untyped pointers to only compare their addresses", + "use `{$krate}::ptr::addr_eq` or untyped pointers to only compare their addresses", style = "verbose", // FIXME(#53934): make machine-applicable again applicability = "maybe-incorrect" )] pub(crate) struct AmbiguousWidePointerComparisonsAddrSuggestion<'a> { + pub(crate) krate: &'static str, pub(crate) ne: &'a str, pub(crate) deref_left: &'a str, pub(crate) deref_right: &'a str, pub(crate) l_modifiers: &'a str, pub(crate) r_modifiers: &'a str, - #[suggestion_part(code = "{ne}std::ptr::addr_eq({deref_left}")] + #[suggestion_part(code = "{ne}{krate}::ptr::addr_eq({deref_left}")] pub(crate) left: Span, #[suggestion_part(code = "{l_modifiers}, {deref_right}")] pub(crate) middle: Span, @@ -2470,15 +2489,16 @@ pub(crate) enum UnpredictableFunctionPointerComparisons<'a, 'tcx> { #[derive(Subdiagnostic)] pub(crate) enum UnpredictableFunctionPointerComparisonsSuggestion<'a, 'tcx> { #[multipart_suggestion( - "refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint", + "refactor your code, or use `{$krate}::ptr::fn_addr_eq` to suppress the lint", style = "verbose", applicability = "maybe-incorrect" )] FnAddrEq { + krate: &'static str, ne: &'a str, deref_left: &'a str, deref_right: &'a str, - #[suggestion_part(code = "{ne}std::ptr::fn_addr_eq({deref_left}")] + #[suggestion_part(code = "{ne}{krate}::ptr::fn_addr_eq({deref_left}")] left: Span, #[suggestion_part(code = ", {deref_right}")] middle: Span, @@ -2486,16 +2506,17 @@ pub(crate) enum UnpredictableFunctionPointerComparisonsSuggestion<'a, 'tcx> { right: Span, }, #[multipart_suggestion( - "refactor your code, or use `std::ptr::fn_addr_eq` to suppress the lint", + "refactor your code, or use `{$krate}::ptr::fn_addr_eq` to suppress the lint", style = "verbose", applicability = "maybe-incorrect" )] FnAddrEqWithCast { + krate: &'static str, ne: &'a str, deref_left: &'a str, deref_right: &'a str, fn_sig: rustc_middle::ty::PolyFnSig<'tcx>, - #[suggestion_part(code = "{ne}std::ptr::fn_addr_eq({deref_left}")] + #[suggestion_part(code = "{ne}{krate}::ptr::fn_addr_eq({deref_left}")] left: Span, #[suggestion_part(code = ", {deref_right}")] middle: Span, diff --git a/compiler/rustc_lint/src/drop_forget_useless.rs b/compiler/rustc_lint/src/drop_forget_useless.rs index b952b62ada314..9689f6a053275 100644 --- a/compiler/rustc_lint/src/drop_forget_useless.rs +++ b/compiler/rustc_lint/src/drop_forget_useless.rs @@ -9,6 +9,7 @@ use crate::diagnostics::{ UndroppedManuallyDropsInPlaceSuggestion, UndroppedManuallyDropsSuggestion, UseLetUnderscoreIgnoreSuggestion, }; +use crate::utils::std_or_core; use crate::{LateContext, LateLintPass, LintContext}; declare_lint! { @@ -252,15 +253,18 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless { } sym::mem_drop if let ty::Adt(adt, _) = arg_ty.kind() - && adt.is_manually_drop() => + && adt.is_manually_drop() + && let Some(krate) = std_or_core(cx) => { cx.emit_span_lint( UNDROPPED_MANUALLY_DROPS, expr.span, UndroppedManuallyDropsDiag { + krate, arg_ty, label: arg.span, suggestion: UndroppedManuallyDropsSuggestion { + krate, start_span: arg.span.shrink_to_lo(), end_span: arg.span.shrink_to_hi(), }, @@ -270,15 +274,18 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless { sym::ptr_drop_in_place | sym::ptr_drop_in_place_self if let &ty::RawPtr(inner_ty, _mutbl) = arg_ty.kind() && let ty::Adt(adt, _) = inner_ty.kind() - && adt.is_manually_drop() => + && adt.is_manually_drop() + && let Some(krate) = std_or_core(cx) => { cx.emit_span_lint( UNDROPPED_MANUALLY_DROPS, expr.span, UndroppedManuallyDropsInPlaceDiag { + krate, arg_ty, label: arg.span, suggestion: UndroppedManuallyDropsInPlaceSuggestion { + krate, start_span: expr.span.shrink_to_lo().until(arg.span.shrink_to_lo()), end_span: arg.span.shrink_to_hi().until(expr.span.shrink_to_hi()), }, diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 95033707cf110..deea9e1bbc13c 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -148,6 +148,7 @@ pub use rustc_lint_defs::{ Applicability, FutureIncompatibleInfo, Lint, LintId, LintPass, LintVec, declare_lint, declare_lint_pass, declare_tool_lint, impl_lint_pass, }; +pub use utils::std_or_core; pub fn provide(providers: &mut Providers) { levels::provide(providers); diff --git a/compiler/rustc_lint/src/non_fmt_panic.rs b/compiler/rustc_lint/src/non_fmt_panic.rs index fbe8eb837f852..6598110cbfa8f 100644 --- a/compiler/rustc_lint/src/non_fmt_panic.rs +++ b/compiler/rustc_lint/src/non_fmt_panic.rs @@ -143,7 +143,14 @@ impl<'a, 'b, 'tcx> Diagnostic<'a> for PanicMessageNotLiteral<'b, 'tcx> { .get_diagnostic_item(sym::Debug) .is_some_and(|t| infcx.type_implements_trait(t, [ty], param_env).may_apply()); - let suggest_panic_any = !is_str && panic == Some(sym::std_panic_macro); + let suggest_panic_any = !is_str + && panic == Some(sym::std_panic_macro) + && cx + .tcx + .all_diagnostic_items(()) + .name_to_id + .keys() + .any(|name| name.as_str() == "panic_any"); let fmt_applicability = if suggest_panic_any { // If we can use panic_any, use that as the MachineApplicable suggestion. diff --git a/compiler/rustc_lint/src/transmute.rs b/compiler/rustc_lint/src/transmute.rs index 3a4092a46a6b6..3b269a215cb6b 100644 --- a/compiler/rustc_lint/src/transmute.rs +++ b/compiler/rustc_lint/src/transmute.rs @@ -8,7 +8,10 @@ use rustc_macros::Diagnostic; use rustc_middle::ty::{self, Ty}; use rustc_span::sym; -use crate::diagnostics::{IntegerToPtrTransmutes, IntegerToPtrTransmutesSuggestion}; +use crate::diagnostics::{ + IntegerToPtrTransmutes, IntegerToPtrTransmutesSuggestion, IntegerToPtrWithoutProvHelp, +}; +use crate::utils::std_or_core; use crate::{LateContext, LateLintPass}; declare_lint! { @@ -166,30 +169,30 @@ fn check_int_to_ptr_transmute<'tcx>( } let suffix = if mutbl.is_mut() { "_mut" } else { "" }; + let krate = std_or_core(cx); cx.tcx.emit_node_span_lint( INTEGER_TO_PTR_TRANSMUTES, expr.hir_id, expr.span, IntegerToPtrTransmutes { - suggestion: if layout_inner_ty.is_sized() { - Some(if dst.is_ref() { - IntegerToPtrTransmutesSuggestion::ToRef { + without_prov: krate.map(|krate| IntegerToPtrWithoutProvHelp { krate }), + suggestion: match (krate, layout_inner_ty.is_sized()) { + (Some(krate), true) if dst.is_ref() => { + Some(IntegerToPtrTransmutesSuggestion::ToRef { + krate, dst: *inner_ty, suffix, ref_mutbl: mutbl.prefix_str(), start_call: expr.span.shrink_to_lo().until(arg.span), - } - } else { - IntegerToPtrTransmutesSuggestion::ToPtr { - dst: *inner_ty, - suffix, - start_call: expr.span.shrink_to_lo().until(arg.span), - } - }) - } else { - // We can't suggest using `with_exposed_provenance` for unsized type - // so don't suggest anything. - None + }) + } + (Some(krate), true) => Some(IntegerToPtrTransmutesSuggestion::ToPtr { + krate, + dst: *inner_ty, + suffix, + start_call: expr.span.shrink_to_lo().until(arg.span), + }), + _ => None, }, }, ); diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index eab950f4d66a8..9897e9cbb4f07 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -25,6 +25,7 @@ use crate::diagnostics::{ UnpredictableFunctionPointerComparisonsSuggestion, UnusedComparisons, VariantSizeDifferencesDiag, }; +use crate::utils::std_or_core; use crate::{LateContext, LateLintPass, LintContext}; mod literal; @@ -348,13 +349,21 @@ fn lint_wide_pointer<'tcx>( return; }; + let Some(krate) = std_or_core(cx) else { + return cx.emit_span_lint( + AMBIGUOUS_WIDE_POINTER_COMPARISONS, + e.span, + AmbiguousWidePointerComparisons::Warn, + ); + }; + let (Some(l_span), Some(r_span)) = (l.span.find_ancestor_inside(e.span), r.span.find_ancestor_inside(e.span)) else { return cx.emit_span_lint( AMBIGUOUS_WIDE_POINTER_COMPARISONS, e.span, - AmbiguousWidePointerComparisons::Spanless, + AmbiguousWidePointerComparisons::Spanless { krate }, ); }; @@ -380,6 +389,7 @@ fn lint_wide_pointer<'tcx>( AmbiguousWidePointerComparisons::SpanfulEq { addr_metadata_suggestion: (!is_dyn_comparison).then(|| { AmbiguousWidePointerComparisonsAddrMetadataSuggestion { + krate, ne, deref_left, deref_right, @@ -391,6 +401,7 @@ fn lint_wide_pointer<'tcx>( } }), addr_suggestion: AmbiguousWidePointerComparisonsAddrSuggestion { + krate, ne, deref_left, deref_right, @@ -512,6 +523,14 @@ fn lint_fn_pointer<'tcx>( let middle = l_span.shrink_to_hi().until(r_span.shrink_to_lo()); let right = r_span.shrink_to_hi().until(e.span.shrink_to_hi()); + let Some(krate) = std_or_core(cx) else { + return cx.emit_span_lint( + UNPREDICTABLE_FUNCTION_POINTER_COMPARISONS, + e.span, + UnpredictableFunctionPointerComparisons::Warn, + ); + }; + let sugg = // We only check for a right cast as `FnDef` == `FnPtr` is not possible, // only `FnPtr == FnDef` is possible. @@ -519,6 +538,7 @@ fn lint_fn_pointer<'tcx>( let fn_sig = r_ty.fn_sig(cx.tcx); UnpredictableFunctionPointerComparisonsSuggestion::FnAddrEqWithCast { + krate, ne, fn_sig, deref_left, @@ -529,6 +549,7 @@ fn lint_fn_pointer<'tcx>( } } else { UnpredictableFunctionPointerComparisonsSuggestion::FnAddrEq { + krate, ne, deref_left, deref_right, diff --git a/compiler/rustc_lint/src/utils.rs b/compiler/rustc_lint/src/utils.rs index 5854e89d801de..e3c0198775433 100644 --- a/compiler/rustc_lint/src/utils.rs +++ b/compiler/rustc_lint/src/utils.rs @@ -1,4 +1,4 @@ -use rustc_hir::{Expr, ExprKind}; +use rustc_hir::{Expr, ExprKind, find_attr}; use rustc_span::sym; use crate::LateContext; @@ -47,3 +47,14 @@ pub(crate) fn peel_casts<'tcx>( e } + +/// Crate to use for rustfix / diagnostic paths that exist in both `std` and `core`. Returns `None` for `#![no_core]`. +pub fn std_or_core(cx: &LateContext<'_>) -> Option<&'static str> { + if find_attr!(cx.tcx, crate, NoCore) { + None + } else if find_attr!(cx.tcx, crate, NoStd) { + Some("core") + } else { + Some("std") + } +} diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 35d5597795a9e..beb63ad61493c 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -107,9 +107,10 @@ LLVMRustCreateMCSubtargetInfo(const char *TripleStr, const char *CPU, #endif } -extern "C" bool LLVMRustMCSubtargetInfoHasFeature(MCSubtargetInfo *MCInfo, - const char *Feature) { - return MCInfo->checkFeatures(std::string("+") + Feature); +extern "C" bool LLVMRustMCSubtargetInfoCheckFeatures(MCSubtargetInfo *MCInfo, + const char *Features, + size_t FeaturesLen) { + return MCInfo->checkFeatures(StringRef{Features, FeaturesLen}); } extern "C" void LLVMRustDisposeMCSubtargetInfo(MCSubtargetInfo *MCInfo) { diff --git a/compiler/rustc_middle/src/middle/resolve.rs b/compiler/rustc_middle/src/middle/resolve.rs index 8267cde89ad27..491fec97db6c1 100644 --- a/compiler/rustc_middle/src/middle/resolve.rs +++ b/compiler/rustc_middle/src/middle/resolve.rs @@ -180,6 +180,9 @@ pub struct ResolverGlobalCtxt { /// A list of proc macro LocalDefIds, written out in the order in which /// they are declared in the static array generated by proc_macro_harness. pub proc_macros: Vec, + /// Path spans where the ident matches an associated type for an enclosing trait. Used to + /// improve certain error messages. + pub paths_matching_assoc_types: UnordSet, /// Mapping from ident span to path span for paths that don't exist as written, but that /// exist under `std`. For example, wrote `str::from_utf8` instead of `std::str::from_utf8`. pub confused_type_with_std_module: FxIndexMap, diff --git a/compiler/rustc_middle/src/ty/context/impl_interner.rs b/compiler/rustc_middle/src/ty/context/impl_interner.rs index fdaf5cacfbf27..a6688b668aab3 100644 --- a/compiler/rustc_middle/src/ty/context/impl_interner.rs +++ b/compiler/rustc_middle/src/ty/context/impl_interner.rs @@ -580,6 +580,10 @@ impl<'tcx> Interner for TyCtxt<'tcx> { self.trait_is_auto(trait_def_id) } + fn trait_is_marker(self, trait_def_id: DefId) -> bool { + self.trait_def(trait_def_id).is_marker + } + fn trait_is_coinductive(self, trait_def_id: DefId) -> bool { self.trait_is_coinductive(trait_def_id) } diff --git a/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs b/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs index 32e38ad88c856..ae538441499e0 100644 --- a/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs @@ -1091,8 +1091,12 @@ where // we still use modulo regions here. This is fine as specialization currently // assumes that specializing impls have to be always applicable, meaning that // the only allowed region constraints may be constraints also present on the default impl. + // + // If both impls have the same response, dropping victim doesn't change the + // result. We need to do so here as we don't merge distinct impl candidates. if matches!(allow_inference_constraints, AllowInferenceConstraints::Yes) || has_only_region_constraints(c.result) + || c.result == candidates[i].result { if self.cx().impl_specializes(other_def_id, victim_def_id) { candidates.remove(i); diff --git a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs index d7c37b6344d23..19a09e99c7d64 100644 --- a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs +++ b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs @@ -1556,19 +1556,77 @@ where } } + /// Like `try_merge_candidates`, but returns `None` if there are multiple user-written + /// impls, or a user-written impl and a builtin impl, in which case we bail with ambiguity. + /// + /// Candidates with equal responses can still come from conflicting impls, ex - two + /// overlapping impls which both apply due to impossible where-clauses. We don't want + /// to merge these. Multiple builtin impls are still merged as usual. This is not + /// done for marker traits, as their impls are allowed to overlap. + #[instrument(level = "trace", skip(self), ret)] + fn try_merge_impl_candidates( + &mut self, + trait_def_id: I::TraitId, + candidates: &[Candidate], + ) -> Option> { + let is_marker = self.cx().trait_is_marker(trait_def_id); + let all_builtin = candidates + .iter() + .all(|candidate| matches!(candidate.source, CandidateSource::BuiltinImpl(_))); + + if is_marker || all_builtin { + self.try_merge_candidates(candidates).map(|(response, _)| response) + } else if candidates.len() > 1 { + None + } else { + candidates.first().map(|candidate| candidate.result) + } + } + + fn merge_candidates_or_bail_with_ambiguity( + &mut self, + candidates: &[Candidate], + proven_via: TraitGoalProvenVia, + ) -> (CanonicalResponse, Option) { + if let Some((response, _)) = self.try_merge_candidates(candidates) { + (response, Some(proven_via)) + } else { + (self.bail_with_ambiguity(candidates), None) + } + } + + fn merge_impl_candidates_or_bail_with_ambiguity( + &mut self, + trait_def_id: I::TraitId, + candidates: &[Candidate], + ) -> (CanonicalResponse, Option) { + debug_assert!(candidates.iter().all(|c| matches!( + c.source, + CandidateSource::Impl(_) | CandidateSource::BuiltinImpl(_) + ))); + match self.try_merge_impl_candidates(trait_def_id, candidates) { + Some(response) => (response, Some(TraitGoalProvenVia::Misc)), + None => (self.bail_with_ambiguity(candidates), None), + } + } + #[instrument(level = "debug", skip(self), ret)] pub(super) fn merge_trait_candidates( &mut self, - candidate_preference_mode: CandidatePreferenceMode, + trait_def_id: I::TraitId, mut candidates: Vec>, failed_candidate_info: FailedCandidateInfo, ) -> Result<(CanonicalResponse, Option), NoSolution> { + if candidates.is_empty() { + return Err(NoSolution); + } + + let candidate_preference_mode = CandidatePreferenceMode::compute(self.cx(), trait_def_id); if self.typing_mode().is_coherence() { - return if let Some((response, _)) = self.try_merge_candidates(&candidates) { - Ok((response, Some(TraitGoalProvenVia::Misc))) - } else { - self.flounder(&candidates).map(|r| (r, None)) - }; + return Ok(match self.try_merge_impl_candidates(trait_def_id, &candidates) { + Some(response) => (response, Some(TraitGoalProvenVia::Misc)), + None => (self.bail_with_ambiguity(&candidates), None), + }); } // We prefer trivial builtin candidates, i.e. builtin impls without any @@ -1595,11 +1653,10 @@ where let alias_bounds: Vec<_> = candidates .extract_if(.., |c| matches!(c.source, CandidateSource::AliasBound(..))) .collect(); - return if let Some((response, _)) = self.try_merge_candidates(&alias_bounds) { - Ok((response, Some(TraitGoalProvenVia::AliasBound))) - } else { - Ok((self.bail_with_ambiguity(&alias_bounds), None)) - }; + return Ok(self.merge_candidates_or_bail_with_ambiguity( + &alias_bounds, + TraitGoalProvenVia::AliasBound, + )); } // If there are non-global where-bounds, prefer where-bounds @@ -1651,11 +1708,10 @@ where let alias_bounds: Vec<_> = candidates .extract_if(.., |c| matches!(c.source, CandidateSource::AliasBound(_))) .collect(); - return if let Some((response, _)) = self.try_merge_candidates(&alias_bounds) { - Ok((response, Some(TraitGoalProvenVia::AliasBound))) - } else { - Ok((self.bail_with_ambiguity(&alias_bounds), None)) - }; + return Ok(self.merge_candidates_or_bail_with_ambiguity( + &alias_bounds, + TraitGoalProvenVia::AliasBound, + )); } self.filter_specialized_impls(AllowInferenceConstraints::No, &mut candidates); @@ -1665,21 +1721,16 @@ where // is still reported as being proven-via the param-env so that rigid projections // operate correctly. Otherwise, drop all global where-bounds before merging the // remaining candidates. - let proven_via = if candidates + let only_global_where_bounds = candidates .iter() - .all(|c| matches!(c.source, CandidateSource::ParamEnv(ParamEnvSource::Global))) - { - TraitGoalProvenVia::ParamEnv + .all(|c| matches!(c.source, CandidateSource::ParamEnv(ParamEnvSource::Global))); + if only_global_where_bounds { + Ok(self + .merge_candidates_or_bail_with_ambiguity(&candidates, TraitGoalProvenVia::ParamEnv)) } else { candidates .retain(|c| !matches!(c.source, CandidateSource::ParamEnv(ParamEnvSource::Global))); - TraitGoalProvenVia::Misc - }; - - if let Some((response, _)) = self.try_merge_candidates(&candidates) { - Ok((response, Some(proven_via))) - } else { - self.flounder(&candidates).map(|r| (r, None)) + Ok(self.merge_impl_candidates_or_bail_with_ambiguity(trait_def_id, &candidates)) } } @@ -1691,9 +1742,7 @@ where { let (candidates, failed_candidate_info) = self.assemble_and_evaluate_candidates(goal, AssembleCandidatesFrom::All)?; - let candidate_preference_mode = - CandidatePreferenceMode::compute(self.cx(), goal.predicate.def_id()); - self.merge_trait_candidates(candidate_preference_mode, candidates, failed_candidate_info) + self.merge_trait_candidates(goal.predicate.def_id(), candidates, failed_candidate_info) .map_err(Into::into) } diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 8c4a9babe2213..cb6642a696504 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -22,7 +22,7 @@ use rustc_data_structures::unord::{UnordMap, UnordSet}; use rustc_errors::codes::*; use rustc_errors::{ Applicability, Diag, DiagArgValue, Diagnostic, ErrorGuaranteed, IntoDiagArg, MultiSpan, - StashKey, Suggestions, elided_lifetime_in_path_suggestion, pluralize, + Suggestions, elided_lifetime_in_path_suggestion, pluralize, }; use rustc_hir::def::Namespace::{self, *}; use rustc_hir::def::{CtorKind, DefKind, NonMacroAttrKind, PerNS}; @@ -4823,7 +4823,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { source, ) { Ok(Some(partial_res)) if let Some(res) = partial_res.full_res() => { - // if we also have an associated type that matches the ident, stash a suggestion + // If we also have an associated type that matches the ident, record that. if let Some(items) = self.diag_metadata.current_trait_assoc_items && let [Segment { ident, .. }] = path && items.iter().any(|item| { @@ -4836,14 +4836,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { } }) { - let mut diag = self.r.tcx.dcx().struct_allow(""); - diag.span_suggestion_verbose( - path_span.shrink_to_lo(), - "there is an associated type with the same name", - "Self::", - Applicability::MaybeIncorrect, - ); - diag.stash(path_span, StashKey::AssociatedTypeSuggestion); + self.r.paths_matching_assoc_types.insert(path_span.with_parent(None)); } if source.is_expected(res) || res == Res::Err { diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 7c80a892fa131..a913149733614 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -1529,6 +1529,7 @@ pub struct Resolver<'ra, 'tcx> { /// A list of proc macro LocalDefIds, written out in the order in which /// they are declared in the static array generated by proc_macro_harness. proc_macros: Vec = Vec::new(), + paths_matching_assoc_types: UnordSet, confused_type_with_std_module: FxIndexMap, /// Names of items that were stripped out via cfg with their corresponding cfg meta item. @@ -1892,6 +1893,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { invocation_parents, trait_impls: Default::default(), confused_type_with_std_module: Default::default(), + paths_matching_assoc_types: Default::default(), stripped_cfg_items: Default::default(), effective_visibilities: Default::default(), macro_reachable_adts: Default::default(), @@ -1970,6 +1972,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { let glob_map = self.glob_map; let main_def = self.main_def; let confused_type_with_std_module = self.confused_type_with_std_module; + let paths_matching_assoc_types = self.paths_matching_assoc_types; let effective_visibilities = self.effective_visibilities; let stripped_cfg_items = self @@ -2000,6 +2003,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { trait_impls: self.trait_impls, proc_macros, confused_type_with_std_module, + paths_matching_assoc_types, doc_link_resolutions: self.doc_link_resolutions, doc_link_traits_in_scope: self.doc_link_traits_in_scope, all_macro_rules: self.all_macro_rules, diff --git a/compiler/rustc_symbol_mangling/src/test.rs b/compiler/rustc_symbol_mangling/src/test.rs index 646a916fb5085..f9a17cd0c40ad 100644 --- a/compiler/rustc_symbol_mangling/src/test.rs +++ b/compiler/rustc_symbol_mangling/src/test.rs @@ -32,13 +32,16 @@ pub fn dump_symbol_names_and_def_paths(tcx: TyCtxt<'_>) { let args = tcx.erase_and_anonymize_regions(args); let instance = Instance::new_raw(def_id, args); let mangled = tcx.symbol_name(instance); + let def_span = tcx.def_span(def_id); + let span = span.to(def_span); - tcx.dcx().span_err(span, format!("symbol-name({mangled})")); + let mut err = tcx.dcx().struct_span_err(span, format!("symbol-name({mangled})")); if let Ok(demangling) = rustc_demangle::try_demangle(mangled.name) { - tcx.dcx().span_err(span, format!("demangling({demangling})")); - tcx.dcx().span_err(span, format!("demangling-alt({demangling:#})")); + err.note(format!("demangling({demangling})")); + err.note(format!("demangling-alt({demangling:#})")); } + err.emit_err(); } if let Some(&span) = find_attr!(tcx, id.def_id, RustcDumpDefPath(span) => span) { diff --git a/compiler/rustc_trait_selection/src/diagnostics.rs b/compiler/rustc_trait_selection/src/diagnostics.rs index 4b7be976cdb30..80ffbba041ccd 100644 --- a/compiler/rustc_trait_selection/src/diagnostics.rs +++ b/compiler/rustc_trait_selection/src/diagnostics.rs @@ -2083,3 +2083,15 @@ pub(crate) struct NonGenericOpaqueTypeParam<'a, 'tcx> { }")] pub param_span: Span, } + +#[derive(Subdiagnostic)] +#[suggestion( + "there is an associated type with the same name", + style = "verbose", + code = "Self::", + applicability = "maybe-incorrect" +)] +pub struct AssocTypeWithSameName { + #[primary_span] + pub span: Span, +} 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 4cb5465b5bbee..062b087413e4f 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 @@ -13,8 +13,8 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::unord::UnordSet; use rustc_errors::codes::*; use rustc_errors::{ - Applicability, Diag, ErrorGuaranteed, MultiSpan, StashKey, StringPart, Sublevel, Suggestions, - msg, pluralize, struct_span_code_err, + Applicability, Diag, ErrorGuaranteed, MultiSpan, StringPart, Sublevel, msg, pluralize, + struct_span_code_err, }; use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId}; use rustc_hir::intravisit::Visitor; @@ -42,7 +42,8 @@ use tracing::{debug, instrument}; use super::suggestions::get_explanation_based_on_obligation; use super::{ArgKind, CandidateSimilarity, GetSafeTransmuteErrorAndReason, ImplCandidate}; use crate::diagnostics::{ - ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch, CoroClosureNotFn, + AssocTypeWithSameName, ClosureFnMutLabel, ClosureFnOnceLabel, ClosureKindMismatch, + CoroClosureNotFn, }; use crate::error_reporting::TypeErrCtxt; use crate::error_reporting::infer::TyCategory; @@ -3107,13 +3108,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ); self.suggest_unsized_bound_if_applicable(err, obligation); if let Some(span) = err.span.primary_span() - && let Some(mut diag) = - self.dcx().steal_non_err(span, StashKey::AssociatedTypeSuggestion) - && let Suggestions::Enabled(ref mut s1) = err.suggestions - && let Suggestions::Enabled(ref mut s2) = diag.suggestions + && self + .tcx + .resolutions(()) + .paths_matching_assoc_types + .contains(&span.with_parent(None)) { - s1.append(s2); - diag.cancel() + err.subdiagnostic(AssocTypeWithSameName { span: span.shrink_to_lo() }); } } } diff --git a/compiler/rustc_type_ir/src/interner.rs b/compiler/rustc_type_ir/src/interner.rs index 85a69af53539a..e3bf97dfebd26 100644 --- a/compiler/rustc_type_ir/src/interner.rs +++ b/compiler/rustc_type_ir/src/interner.rs @@ -491,6 +491,8 @@ pub trait Interner: fn trait_is_auto(self, trait_def_id: Self::TraitId) -> bool; + fn trait_is_marker(self, trait_def_id: Self::TraitId) -> bool; + fn trait_is_coinductive(self, trait_def_id: Self::TraitId) -> bool; fn trait_is_alias(self, trait_def_id: Self::TraitId) -> bool; diff --git a/compiler/rustc_type_ir/src/search_graph/mod.rs b/compiler/rustc_type_ir/src/search_graph/mod.rs index c081898f26f56..228b6c34b06ed 100644 --- a/compiler/rustc_type_ir/src/search_graph/mod.rs +++ b/compiler/rustc_type_ir/src/search_graph/mod.rs @@ -628,8 +628,8 @@ pub struct SearchGraph, X: Cx = ::Cx> { /// don't need to track the nested goals used while computing a provisional /// cache entry. enum UpdateParentGoalCtxt<'a, X: Cx> { - Ordinary { nested_goals: &'a NestedGoals, min_reachable_available_depth: AvailableDepth }, - CycleOnStack(X::Input), + Ordinary { nested_goals: &'a NestedGoals }, + CycleOnStack { head: X::Input }, ProvisionalCacheHit, } @@ -653,9 +653,12 @@ impl, X: Cx> SearchGraph { heads: impl Iterator, encountered_overflow: bool, context: UpdateParentGoalCtxt<'_, X>, + min_reachable_available_depth: AvailableDepth, ) { if let Some((parent_index, parent)) = stack.last_mut_with_index() { parent.encountered_overflow |= encountered_overflow; + parent.min_reached_available_depth = + parent.min_reached_available_depth.min(min_reachable_available_depth); for (head_index, head) in heads { if let Some(candidate_usages) = &mut parent.candidate_usages { @@ -679,13 +682,11 @@ impl, X: Cx> SearchGraph { } } let parent_depends_on_cycle = match context { - UpdateParentGoalCtxt::Ordinary { nested_goals, min_reachable_available_depth } => { - parent.min_reached_available_depth = - parent.min_reached_available_depth.min(min_reachable_available_depth); + UpdateParentGoalCtxt::Ordinary { nested_goals } => { parent.nested_goals.extend_from_child(step_kind_from_parent, nested_goals); !nested_goals.is_empty() } - UpdateParentGoalCtxt::CycleOnStack(head) => { + UpdateParentGoalCtxt::CycleOnStack { head } => { // We lookup provisional cache entries before detecting cycles. // We therefore can't use a global cache entry if it contains a cycle // whose head is in the provisional cache. @@ -811,7 +812,9 @@ impl, X: Cx> SearchGraph { // - A // - BA cycle // - CB :x: - if let Some(result) = self.lookup_provisional_cache(input, step_kind_from_parent) { + if let Some(result) = + self.lookup_provisional_cache(input, step_kind_from_parent, available_depth) + { return result; } @@ -839,7 +842,9 @@ impl, X: Cx> SearchGraph { // avoid iterating over the stack in case a goal has already been computed. // This may not have an actual performance impact and we could reorder them // as it may reduce the number of `nested_goals` we need to track. - if let Some(result) = self.check_cycle_on_stack(cx, input, step_kind_from_parent) { + if let Some(result) = + self.check_cycle_on_stack(cx, input, step_kind_from_parent, available_depth) + { debug_assert!(validate_cache.is_none(), "global cache and cycle on stack: {input:?}"); return result; } @@ -874,10 +879,8 @@ impl, X: Cx> SearchGraph { step_kind_from_parent, evaluation_result.heads.iter(), evaluation_result.encountered_overflow, - UpdateParentGoalCtxt::Ordinary { - nested_goals: &evaluation_result.nested_goals, - min_reachable_available_depth: available_depth - evaluation_result.required_depth, - }, + UpdateParentGoalCtxt::Ordinary { nested_goals: &evaluation_result.nested_goals }, + available_depth - evaluation_result.required_depth, ); let result = evaluation_result.result; @@ -1119,6 +1122,7 @@ impl, X: Cx> SearchGraph { &mut self, input: X::Input, step_kind_from_parent: PathKind, + available_depth: AvailableDepth, ) -> Option { if !D::ENABLE_PROVISIONAL_CACHE { return None; @@ -1157,6 +1161,7 @@ impl, X: Cx> SearchGraph { heads.iter(), encountered_overflow, UpdateParentGoalCtxt::ProvisionalCacheHit, + available_depth, ); debug!(?head_index, ?path_from_head, "provisional cache hit"); return Some(result); @@ -1278,10 +1283,8 @@ impl, X: Cx> SearchGraph { step_kind_from_parent, heads, encountered_overflow, - UpdateParentGoalCtxt::Ordinary { - nested_goals, - min_reachable_available_depth: available_depth - required_depth, - }, + UpdateParentGoalCtxt::Ordinary { nested_goals }, + available_depth - required_depth, ); debug!(?required_depth, "global cache hit"); @@ -1294,6 +1297,7 @@ impl, X: Cx> SearchGraph { cx: X, input: X::Input, step_kind_from_parent: PathKind, + available_depth: AvailableDepth, ) -> Option { let head_index = self.stack.find(input)?; // We have a nested goal which directly relies on a goal deeper in the stack. @@ -1312,7 +1316,8 @@ impl, X: Cx> SearchGraph { step_kind_from_parent, iter::once((head_index, head)), false, - UpdateParentGoalCtxt::CycleOnStack(input), + UpdateParentGoalCtxt::CycleOnStack { head: input }, + available_depth, ); // Return the provisional result or, if we're in the first iteration, diff --git a/library/core/src/cmp.rs b/library/core/src/cmp.rs index a7c22a195e5d2..2792c7cde57be 100644 --- a/library/core/src/cmp.rs +++ b/library/core/src/cmp.rs @@ -1967,24 +1967,19 @@ macro impl_tuples($($mac:ident,)+) { } /// Implementation detail for [`smallest`] and [`largest`]. -/// Marker indicating that `Self` is a tuple where all members are of the same type. +/// Marker indicating that `Self` is a tuple where all members are of the type `T`. +/// Cannot be an associated type as we require the empty tuple to implement this trait +/// for all types `T`. #[diagnostic::on_unimplemented(message = "`{Self}` is not a homogeneous tuple")] #[unstable(feature = "cmp_splat_internals", issue = "160728")] #[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")] -const trait HomogeneousTuple: crate::marker::Tuple { - /// The type of each item in this tuple. - type Item; -} +const trait HomogeneousTuple: crate::marker::Tuple {} /// Implements [`HomogeneousTuple`] for a provided tuple. -macro impl_homogeneous_tuple($($($x:ident,)+)?) { - $( - #[unstable(feature = "cmp_splat_internals", issue = "160728")] - #[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")] - const impl HomogeneousTuple for ($(${ignore($x)}T,)+) { - type Item = T; - } - )? +macro impl_homogeneous_tuple($($x:ident,)*) { + #[unstable(feature = "cmp_splat_internals", issue = "160728")] + #[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")] + const impl HomogeneousTuple for ($(${ignore($x)}T,)*) { } } impl_tuples! { @@ -2040,36 +2035,34 @@ impl_tuples! { #[expect(private_bounds, reason = "`SmallestArgs` is an internal implementation detail")] #[cfg(not(test))] // FIXME: splat interacts poorly with the double linking of `core` in tests pub const fn smallest( - #[rustc_splat] args: impl [const] SmallestArgs, + v1: T, + #[rustc_splat] args: impl [const] SmallestArgs, ) -> T { - SmallestArgs::smallest(args) + SmallestArgs::smallest(v1, args) } /// Implementation detail for [`smallest`]. #[diagnostic::on_unimplemented(message = "`{Self}` is not a valid set of arguments for `smallest`")] #[unstable(feature = "cmp_splat_internals", issue = "160728")] #[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")] -const trait SmallestArgs: HomogeneousTuple { +const trait SmallestArgs: HomogeneousTuple { /// Reduces all elements of a homogeneous tuple to its smallest value. - fn smallest(self) -> Self::Item; + fn smallest(v1: T, args: Self) -> T; } /// Implements [`SmallestArgs`] for a provided tuple if applicable. -macro impl_smallest_args($($x:ident, $($($y:ident,)+)?)?) { - $( - #[unstable(feature = "cmp_splat_internals", issue = "160728")] - #[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")] - const impl SmallestArgs for (T, $($(${ignore($y)}T,)+)?) - $(where T: [const] Destruct + [const] Ord, $(${ignore($y)})+)? - { - #[inline] - fn smallest(self) -> Self::Item { - let ($x, $($($y,)+)?) = self; - $($(let $x = $x.min($y);)+)? - $x - } +macro impl_smallest_args($($x:ident,)*) { + #[unstable(feature = "cmp_splat_internals", issue = "160728")] + #[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")] + const impl SmallestArgs for ($(${ignore($x)}T,)*) + where + T: [const] Destruct + [const] Ord, + { + #[inline(always)] // improves unoptimised codegen + fn smallest(v1: T, ($($x,)*): Self) -> T { + v1$(.min($x))* } - )? + } } impl_tuples! { @@ -2125,36 +2118,34 @@ impl_tuples! { #[expect(private_bounds, reason = "`LargestArgs` is an internal implementation detail")] #[cfg(not(test))] // FIXME: splat interacts poorly with the double linking of `core` in tests pub const fn largest( - #[rustc_splat] args: impl [const] LargestArgs, + v1: T, + #[rustc_splat] args: impl [const] LargestArgs, ) -> T { - LargestArgs::largest(args) + LargestArgs::largest(v1, args) } /// Implementation detail for [`largest`]. #[diagnostic::on_unimplemented(message = "`{Self}` is not a valid set of arguments for `largest`")] #[unstable(feature = "cmp_splat_internals", issue = "160728")] #[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")] -const trait LargestArgs: HomogeneousTuple { +const trait LargestArgs: HomogeneousTuple { /// Reduces all elements of a homogeneous tuple to its largest value. - fn largest(self) -> Self::Item; + fn largest(v1: T, args: Self) -> T; } /// Implements [`LargestArgs`] for a provided tuple if applicable. -macro impl_largest_args($($x:ident, $($($y:ident,)+)?)?) { - $( - #[unstable(feature = "cmp_splat_internals", issue = "160728")] - #[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")] - const impl LargestArgs for (T, $($(${ignore($y)}T,)+)?) - $(where T: [const] Destruct + [const] Ord, $(${ignore($y)})+)? - { - #[inline] - fn largest(self) -> Self::Item { - let ($x, $($($y,)+)?) = self; - $($(let $x = $x.max($y);)+)? - $x - } +macro impl_largest_args($($x:ident,)*) { + #[unstable(feature = "cmp_splat_internals", issue = "160728")] + #[rustc_const_unstable(feature = "cmp_splat_internals", issue = "160728")] + const impl LargestArgs for ($(${ignore($x)}T,)*) + where + T: [const] Destruct + [const] Ord, + { + #[inline(always)] // improves unoptimised codegen + fn largest(v1: T, ($($x,)*): Self) -> T { + v1$(.max($x))* } - )? + } } impl_tuples! { diff --git a/library/std/src/os/wasip2/mod.rs b/library/std/src/os/wasip2/mod.rs index 809a288f20d04..6932bb577cff2 100644 --- a/library/std/src/os/wasip2/mod.rs +++ b/library/std/src/os/wasip2/mod.rs @@ -3,4 +3,5 @@ //! This module is currently empty, but will be filled over time as wasi-libc support for WASI Preview 2 is stabilized. #![forbid(unsafe_op_in_unsafe_fn)] -#![stable(feature = "raw_ext", since = "1.1.0")] +#![unstable(feature = "wasip2", issue = "none")] +#![doc(cfg(all(target_os = "wasi", target_env = "p2")))] diff --git a/src/librustdoc/html/render/sidebar.rs b/src/librustdoc/html/render/sidebar.rs index 6fa033f927c85..011079f9e4f2b 100644 --- a/src/librustdoc/html/render/sidebar.rs +++ b/src/librustdoc/html/render/sidebar.rs @@ -3,7 +3,7 @@ use std::cmp::Ordering; use std::fmt; use askama::Template; -use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::def::CtorKind; use rustc_hir::def_id::{DefIdMap, DefIdSet}; use rustc_middle::ty::TyCtxt; @@ -442,7 +442,7 @@ fn sidebar_assoc_items<'a>( let mut assoc_fns = Vec::new(); let mut methods = Vec::new(); if let Some(v) = cache.impls.get(&did) { - let mut used_links = FxHashSet::default(); + let mut used_links = UsedLinks::default(); let mut id_map = IdMap::new(); { @@ -524,7 +524,7 @@ fn sidebar_deref_methods<'a>( impl_: &Impl, v: &[Impl], derefs: &mut DefIdSet, - used_links: &mut FxHashSet, + used_links: &mut UsedLinks, deref_id_map: &'a DefIdMap, ) { let c = cx.cache(); @@ -745,15 +745,14 @@ fn sidebar_render_assoc_items( ]); } -fn get_next_url(used_links: &mut FxHashSet, url: String) -> String { - if used_links.insert(url.clone()) { - return url; - } - let mut add = 1; - while !used_links.insert(format!("{url}-{add}")) { - add += 1; - } - format!("{url}-{add}") +/// Tracks sidebar link anchors so duplicates get unique names. +type UsedLinks = FxHashMap; + +fn get_next_url(used_links: &mut UsedLinks, url: String) -> String { + let count = used_links.entry(url.clone()).or_insert(0); + let res = if *count == 0 { url } else { format!("{url}-{count}") }; + *count += 1; + res } enum GetMethodsMode<'r, 'l> { @@ -764,7 +763,7 @@ enum GetMethodsMode<'r, 'l> { fn get_methods<'a>( i: &'a clean::Impl, mut mode: GetMethodsMode<'_, 'a>, - used_links: &mut FxHashSet, + used_links: &mut UsedLinks, tcx: TyCtxt<'_>, ) -> impl Iterator> { i.items.iter().filter_map(move |item| { @@ -802,7 +801,7 @@ fn get_methods<'a>( fn get_associated_constants<'a>( i: &'a clean::Impl, - used_links: &mut FxHashSet, + used_links: &mut UsedLinks, ) -> impl Iterator> { i.items.iter().filter_map(|item| { if let Some(ref name) = item.name @@ -820,7 +819,7 @@ fn get_associated_constants<'a>( fn get_associated_types<'a>( i: &'a clean::Impl, - used_links: &mut FxHashSet, + used_links: &mut UsedLinks, ) -> impl Iterator> { i.items.iter().filter_map(|item| { if let Some(ref name) = item.name diff --git a/src/tools/miri/.gitignore b/src/tools/miri/.gitignore index 23f2513addb74..6851dc9190fce 100644 --- a/src/tools/miri/.gitignore +++ b/src/tools/miri/.gitignore @@ -13,5 +13,6 @@ flamegraph*.svg rustc-ice*.txt tests/native-lib/libtestlib.so .auto-* +miri.toml /genmc/ diff --git a/src/tools/miri/CONTRIBUTING.md b/src/tools/miri/CONTRIBUTING.md index 0a330cdd45537..4bc02217c6f7b 100644 --- a/src/tools/miri/CONTRIBUTING.md +++ b/src/tools/miri/CONTRIBUTING.md @@ -111,13 +111,36 @@ install that exact version of rustc as a toolchain: This will set up a rustup toolchain called `miri` and set it as an override for the current directory. -You can also create a `.auto-everything` file (contents don't matter, can be empty), which -will cause any `./miri` command to automatically call `./miri toolchain`, `clippy` and `rustfmt` -for you. If you don't want all of these to happen, you can add individual `.auto-toolchain`, -`.auto-clippy` and `.auto-fmt` files respectively. - [`rustup-toolchain-install-master`]: https://github.com/kennytm/rustup-toolchain-install-master +### Configuring `./miri` + +The `./miri` script supports optional configuration via a `miri.toml` file. +The following configuration keys are currently supported, with the given default values: + +```toml +[toolchain] +# Overwrite the default toolchain name used by `./miri toolchain`. +# Note that all other commands will just use the currently active rustup toolchain! +# (Though note that if you have `auto.toolchain` enabled, most commands will run `./miri toolchain` +# first, which will activate the toolchain given here.) +name = "miri" +# Additional components to install with the toolchain. Note that if you remove `clippy` or `rustfmt` +# from this list then obviously `./miri clippy`/`./miri fmt` will not work. +# Only takes effect when a new toolchain is installed. Run `rustup toolchain remove ` followed +# by `./miri toolchain` to force this to have effect. +components = ["clippy", "rustfmt"] + +[auto] +# Automatically run `./miri toolchain` before most commands. +# Uses the toolchain name configured above, if any. +toolchain = false +# Automatically run `./miri clippy` before most commands. +clippy = false +# Automatically run `./miri fmt` before most commands. +fmt = false +``` + ## Building and testing Miri Invoking Miri requires getting a bunch of flags right and setting up a custom diff --git a/src/tools/miri/cargo-miri/src/util.rs b/src/tools/miri/cargo-miri/src/util.rs index 162ddcb18bd5f..fb93f177aac9e 100644 --- a/src/tools/miri/cargo-miri/src/util.rs +++ b/src/tools/miri/cargo-miri/src/util.rs @@ -42,9 +42,17 @@ impl CrateRunInfo { let env = env::vars_os() .filter(|(var, _val)| { // We only need to bother with env vars cargo actually sets. - // We try to avoid storing anything that may contain secrets. var.to_str().is_some_and(|var| { - var == "OUT_DIR" || (var.starts_with("CARGO_") && !var.ends_with("_TOKEN")) + ( // Env vars cargo sets for crates. + // + var == "OUT_DIR" + || var.starts_with("CARGO_") + // Env vars rustdoc sets for its rustc invocation. + || var.starts_with("UNSTABLE_RUSTDOC_") + || var.starts_with("RUSTDOC_") + ) + // We try to avoid storing anything that may contain secrets. + && !var.ends_with("_TOKEN") }) }) .collect(); diff --git a/src/tools/miri/etc/rust_analyzer_vscode.json b/src/tools/miri/etc/rust_analyzer_vscode.json index e82c648f59ab4..42b9d830facf5 100644 --- a/src/tools/miri/etc/rust_analyzer_vscode.json +++ b/src/tools/miri/etc/rust_analyzer_vscode.json @@ -25,4 +25,6 @@ "--compile-time-deps", "--message-format=json", ], + // RA reports false errors due to + "rust-analyzer.diagnostics.enable": false, } diff --git a/src/tools/miri/miri-script/Cargo.lock b/src/tools/miri/miri-script/Cargo.lock index d946d77987cf3..3a5afb25a74e5 100644 --- a/src/tools/miri/miri-script/Cargo.lock +++ b/src/tools/miri/miri-script/Cargo.lock @@ -274,6 +274,7 @@ dependencies = [ "serde_json", "shell-words", "tempfile", + "toml", "walkdir", "xshell", ] @@ -409,6 +410,15 @@ dependencies = [ "zmij", ] +[[package]] +name = "serde_spanned" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26" +dependencies = [ + "serde_core", +] + [[package]] name = "shell-words" version = "1.1.1" @@ -445,6 +455,37 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "toml" +version = "1.1.4+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3aace63f4bbcdfc2c965b059de67119c89c4017a70d633be6c104910f67056f5" +dependencies = [ + "serde_core", + "serde_spanned", + "toml_datetime", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_datetime" +version = "1.1.1+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_parser" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56" +dependencies = [ + "winnow", +] + [[package]] name = "unicode-ident" version = "1.0.24" @@ -549,6 +590,12 @@ dependencies = [ "windows-link", ] +[[package]] +name = "winnow" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" + [[package]] name = "wit-bindgen" version = "0.46.0" diff --git a/src/tools/miri/miri-script/Cargo.toml b/src/tools/miri/miri-script/Cargo.toml index fd9a563e1fafd..1b0a34de3e3db 100644 --- a/src/tools/miri/miri-script/Cargo.toml +++ b/src/tools/miri/miri-script/Cargo.toml @@ -22,7 +22,8 @@ xshell = "0.2.6" rustc_version = "0.4" dunce = "1.0.4" serde = "1" +serde_derive = "1" # direct dependency better parallelizes builds serde_json = "1" -serde_derive = "1" tempfile = "3.13.0" clap = { version = "4.5.21", features = ["derive"] } +toml = {version = "1", default-features = false, features = ["serde", "parse"] } diff --git a/src/tools/miri/miri-script/src/commands.rs b/src/tools/miri/miri-script/src/commands.rs index e9b9273611510..90fdef1da949a 100644 --- a/src/tools/miri/miri-script/src/commands.rs +++ b/src/tools/miri/miri-script/src/commands.rs @@ -14,6 +14,7 @@ use walkdir::WalkDir; use xshell::{Shell, cmd}; use crate::Command; +use crate::config::{Config, Toolchain}; use crate::util::*; impl MiriEnv { @@ -67,25 +68,19 @@ impl MiriEnv { } impl Command { - fn auto_actions() -> Result<()> { + fn auto_actions(config: &Config) -> Result<()> { if env::var_os("MIRI_AUTO_OPS").is_some_and(|x| x == "no") { return Ok(()); } - let miri_dir = miri_dir()?; - let auto_everything = path!(miri_dir / ".auto-everything").exists(); - let auto_toolchain = auto_everything || path!(miri_dir / ".auto-toolchain").exists(); - let auto_fmt = auto_everything || path!(miri_dir / ".auto-fmt").exists(); - let auto_clippy = auto_everything || path!(miri_dir / ".auto-clippy").exists(); - // `toolchain` goes first as it could affect the others - if auto_toolchain { - Self::toolchain(None, vec![])?; + if config.auto.toolchain { + Self::toolchain(None, None, vec![], config)?; } - if auto_fmt { + if config.auto.fmt { Self::fmt(vec![])?; } - if auto_clippy { + if config.auto.clippy { // no features for auto actions, see // https://github.com/rust-lang/miri/pull/4396#discussion_r2149654845 Self::clippy(vec![], vec![])?; @@ -94,7 +89,7 @@ impl Command { Ok(()) } - pub fn exec(self) -> Result<()> { + pub fn exec(self, config: &Config) -> Result<()> { // First, and crucially only once, run the auto-actions -- but not for all commands. match &self { Command::Install { .. } @@ -104,7 +99,7 @@ impl Command { | Command::Run { .. } | Command::Fmt { .. } | Command::Doc { .. } - | Command::Clippy { .. } => Self::auto_actions()?, + | Command::Clippy { .. } => Self::auto_actions(config)?, | Command::Toolchain { .. } | Command::Bench { .. } | Command::Squash => {} } // Then run the actual command. @@ -121,12 +116,21 @@ impl Command { Command::Clippy { features, flags } => Self::clippy(features, flags), Command::Bench { target, no_install, save_baseline, load_baseline, benches } => Self::bench(target, no_install, save_baseline, load_baseline, benches), - Command::Toolchain { commit, flags } => Self::toolchain(commit, flags), + Command::Toolchain { name, commit, flags } => + Self::toolchain(name, commit, flags, config), Command::Squash => Self::squash(), } } - fn toolchain(new_commit: Option, flags: Vec) -> Result<()> { + fn toolchain( + name: Option, + new_commit: Option, + flags: Vec, + config: &Config, + ) -> Result<()> { + let name = + name.as_deref().or(config.toolchain.name.as_deref()).unwrap_or(Toolchain::DEFAULT_NAME); + let sh = Shell::new()?; sh.change_dir(miri_dir()?); let new_commit = match new_commit { @@ -134,7 +138,7 @@ impl Command { None => sh.read_file("rust-version")?.trim().to_owned(), }; let current_commit = { - let rustc_info = cmd!(sh, "rustc +miri --version -v").read(); + let rustc_info = cmd!(sh, "rustc +{name} --version -v").read(); if let Ok(rustc_info) = rustc_info { let metadata = rustc_version::version_meta_for(&rustc_info)?; Some( @@ -148,18 +152,25 @@ impl Command { }; // Check if we already are at that commit. if current_commit.as_ref() == Some(&new_commit) { - if active_toolchain()? != "miri" { - cmd!(sh, "rustup override set miri").run()?; + // The toolchain is already at the right version. Make sure it is active in `miri_dir`. + // Ignore errors from `active_toolchain`, the active toolchain might be uninstalled. + if active_toolchain().ok().is_none_or(|toolchain| toolchain != name) { + cmd!(sh, "rustup override set {name}").run()?; } return Ok(()); } - // Install and setup new toolchain. - cmd!(sh, "rustup toolchain uninstall miri").run()?; - cmd!(sh, "rustup-toolchain-install-master -n miri -c cargo -c rust-src -c rustc-dev -c llvm-tools -c rustfmt -c clippy {flags...} -- {new_commit}") + // Compute rustup-toolchain-install-master flags for additional components. + let components = + config.toolchain.components.as_deref().unwrap_or(Toolchain::DEFAULT_COMPONENTS); + let component_flags = components.iter().flat_map(|component| ["-c", component]); + + // Install and setup new toolchain. + cmd!(sh, "rustup toolchain uninstall {name}").run()?; + cmd!(sh, "rustup-toolchain-install-master -n {name} -c cargo -c rust-src -c rustc-dev -c llvm-tools {component_flags...} {flags...} -- {new_commit}") .run() .context("Failed to run rustup-toolchain-install-master. If it is not installed, run 'cargo install --locked rustup-toolchain-install-master'.")?; - cmd!(sh, "rustup override set miri").run()?; + cmd!(sh, "rustup override set {name}").run()?; // Cleanup. cmd!(sh, "cargo clean").run()?; // Call `cargo metadata` on the sources in case that changes the lockfile diff --git a/src/tools/miri/miri-script/src/config.rs b/src/tools/miri/miri-script/src/config.rs new file mode 100644 index 0000000000000..b5f4e729c9d35 --- /dev/null +++ b/src/tools/miri/miri-script/src/config.rs @@ -0,0 +1,59 @@ +use std::borrow::Cow; +use std::{fs, io}; + +use anyhow::{Context, Result, bail}; +use path_macro::path; +use serde_derive::Deserialize; + +use crate::util::miri_dir; + +#[derive(Deserialize, Default)] +pub struct Config { + #[serde(default)] + pub toolchain: Toolchain, + #[serde(default)] + pub auto: Auto, +} + +#[derive(Deserialize, Default)] +pub struct Toolchain { + pub name: Option, + pub components: Option>>, +} + +impl Toolchain { + pub const DEFAULT_NAME: &str = "miri"; + pub const DEFAULT_COMPONENTS: &[Cow<'static, str>] = + &[Cow::Borrowed("clippy"), Cow::Borrowed("rustfmt")]; +} + +#[derive(Deserialize, Default)] +pub struct Auto { + #[serde(default)] + pub toolchain: bool, + #[serde(default)] + pub fmt: bool, + #[serde(default)] + pub clippy: bool, +} + +impl Config { + pub fn load() -> Result { + let miri_dir = miri_dir()?; + + Ok(match fs::read(path!(miri_dir / "miri.toml")) { + Ok(config) => toml::from_slice(&config).context("failed to parse `miri.toml`")?, + Err(err) if err.kind() == io::ErrorKind::NotFound => { + // Just ignore error if the file does not exist. Fall back to parsing the `.auto-*` + // files. + let mut config = Config::default(); + let everything = path!(miri_dir / ".auto-everything").exists(); + config.auto.toolchain = everything || path!(miri_dir / ".auto-toolchain").exists(); + config.auto.fmt = everything || path!(miri_dir / ".auto-fmt").exists(); + config.auto.clippy = everything || path!(miri_dir / ".auto-clippy").exists(); + config + } + Err(err) => bail!("unable to open `miri.toml`: {err}"), + }) + } +} diff --git a/src/tools/miri/miri-script/src/main.rs b/src/tools/miri/miri-script/src/main.rs index b575842fc6c78..bcad8f148d23f 100644 --- a/src/tools/miri/miri-script/src/main.rs +++ b/src/tools/miri/miri-script/src/main.rs @@ -1,6 +1,7 @@ #![allow(clippy::needless_question_mark, rustc::internal)] mod commands; +mod config; mod coverage; mod util; @@ -137,11 +138,15 @@ pub enum Command { /// List of benchmarks to run (default: run all benchmarks). benches: Vec, }, - /// Update and activate the rustup toolchain 'miri'. + /// Update and activate the rustup toolchain 'miri' (or whatever name is configured in + /// `miri.toml`). /// /// The `rust-version` file is used to determine the commit that will be intsalled. /// `rustup-toolchain-install-master` must be installed for this to work. Toolchain { + /// Overwrite the name the toolchain will have in `rustup`. + #[arg(long)] + name: Option, /// Overwrite the commit to install. #[arg(long)] commit: Option, @@ -200,6 +205,10 @@ fn main() -> Result<()> { let args = Cli::parse_from(miri_args); let mut command = args.command; command.add_remainder(remainder)?; - command.exec()?; - Ok(()) + + // Parse config file. + let config = config::Config::load()?; + + // Run the thing. + command.exec(&config) } diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version index e861a160a977a..89c3e1334a546 100644 --- a/src/tools/miri/rust-version +++ b/src/tools/miri/rust-version @@ -1 +1 @@ -feaadeeaca7db0594da854e7c8c07495341c7439 +88638df1e741778019e42fcdf307072865d19501 diff --git a/src/tools/miri/test-cargo-miri/run-test.py b/src/tools/miri/test-cargo-miri/run-test.py index 9764700347c8f..f593a16df9869 100755 --- a/src/tools/miri/test-cargo-miri/run-test.py +++ b/src/tools/miri/test-cargo-miri/run-test.py @@ -49,6 +49,7 @@ def check_output(actual, path, name): if expected == actual: return True print(f"{name} output did not match reference in {path}!") + print("Run `./run-test.py --bless` to update reference files.") print(f"--- BEGIN diff {name} ---") for text in difflib.unified_diff(expected.split("\n"), actual.split("\n")): print(text) diff --git a/src/tools/miri/test-cargo-miri/src/doctest.rs b/src/tools/miri/test-cargo-miri/src/doctest.rs new file mode 100644 index 0000000000000..9e1dd68dc1a2b --- /dev/null +++ b/src/tools/miri/test-cargo-miri/src/doctest.rs @@ -0,0 +1,4 @@ +// Imported into a doctest via `#[path]`. +pub fn make_true() -> bool { + true +} diff --git a/src/tools/miri/test-cargo-miri/src/lib.rs b/src/tools/miri/test-cargo-miri/src/lib.rs index 3b63f8afc9023..0b268e6969d68 100644 --- a/src/tools/miri/test-cargo-miri/src/lib.rs +++ b/src/tools/miri/test-cargo-miri/src/lib.rs @@ -26,6 +26,13 @@ /// /// let _val = Fail::::C; /// ``` +/// +/// Doctest with `#[path]`: +/// +/// ```rust +/// #[path = "doctest.rs"] mod doctest; +/// assert!(doctest::make_true()); +/// ``` // This is imported in `main.rs`. #[unsafe(no_mangle)] pub fn make_true() -> bool { diff --git a/src/tools/miri/test-cargo-miri/test.default.stdout.ref b/src/tools/miri/test-cargo-miri/test.default.stdout.ref index deb7cd839f125..b800d17b83b29 100644 --- a/src/tools/miri/test-cargo-miri/test.default.stdout.ref +++ b/src/tools/miri/test-cargo-miri/test.default.stdout.ref @@ -10,8 +10,8 @@ running 6 tests test result: ok. 5 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in $TIME -running 5 tests -..... -test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +running 6 tests +...... +test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/src/tools/miri/test-cargo-miri/test.filter.stdout.ref b/src/tools/miri/test-cargo-miri/test.filter.stdout.ref index a4d912e7a8d0a..5b0c846b8a1e0 100644 --- a/src/tools/miri/test-cargo-miri/test.filter.stdout.ref +++ b/src/tools/miri/test-cargo-miri/test.filter.stdout.ref @@ -13,6 +13,6 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 5 filtered out; fini running 0 tests -test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 5 filtered out; finished in $TIME +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 6 filtered out; finished in $TIME all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/src/tools/miri/test-cargo-miri/test.multiple_targets.stdout.ref b/src/tools/miri/test-cargo-miri/test.multiple_targets.stdout.ref index b36fb3af66641..d4f9de09366b1 100644 --- a/src/tools/miri/test-cargo-miri/test.multiple_targets.stdout.ref +++ b/src/tools/miri/test-cargo-miri/test.multiple_targets.stdout.ref @@ -21,14 +21,14 @@ running 6 tests test result: ok. 5 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in $TIME -running 5 tests -..... -test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +running 6 tests +...... +test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME all doctests ran in $TIME; merged doctests compilation took $TIME -running 5 tests -..... -test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +running 6 tests +...... +test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/src/tools/miri/test-cargo-miri/test.workspace.stdout.ref b/src/tools/miri/test-cargo-miri/test.workspace.stdout.ref index c890af4bd974c..2400dff6c3197 100644 --- a/src/tools/miri/test-cargo-miri/test.workspace.stdout.ref +++ b/src/tools/miri/test-cargo-miri/test.workspace.stdout.ref @@ -21,9 +21,9 @@ running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME -running 5 tests -..... -test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME +running 6 tests +...... +test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME all doctests ran in $TIME; merged doctests compilation took $TIME diff --git a/tests/codegen-llvm/asm-arm-r14.rs b/tests/codegen-llvm/asm-arm-r14.rs index 2404e84c1701e..2af9e372a462d 100644 --- a/tests/codegen-llvm/asm-arm-r14.rs +++ b/tests/codegen-llvm/asm-arm-r14.rs @@ -1,9 +1,6 @@ //@ add-minicore //@ compile-flags: --target armv7-unknown-linux-gnueabihf //@ needs-llvm-components: arm -//@ revisions: LLVM22 LLVM23 -//@ [LLVM22] max-llvm-major-version: 22 -//@ [LLVM23] min-llvm-version: 23 #![feature(no_core)] #![no_core] @@ -15,8 +12,7 @@ use minicore::*; #[no_mangle] pub unsafe fn r14_output() -> u32 { // CHECK-LABEL: define{{.*}}@r14_output - // LLVM22: asm sideeffect{{.*}}"=&{lr},~{cc},~{memory}" - // LLVM23: asm sideeffect{{.*}}"=&{r14},~{cc},~{memory}" + // CHECK: asm sideeffect{{.*}}"=&{lr},~{cc},~{memory}" let output: u32; asm!("", out("r14") output); output diff --git a/tests/mir-opt/pre-codegen/cmp_splat.min_direct_u8.runtime-optimized.after.mir b/tests/mir-opt/pre-codegen/cmp_splat.min_direct_u8.runtime-optimized.after.mir new file mode 100644 index 0000000000000..16d011eeddf2b --- /dev/null +++ b/tests/mir-opt/pre-codegen/cmp_splat.min_direct_u8.runtime-optimized.after.mir @@ -0,0 +1,19 @@ +// MIR for `min_direct_u8` after runtime-optimized + +fn min_direct_u8(_1: u8, _2: u8) -> u8 { + debug x => _1; + debug y => _2; + let mut _0: u8; + scope 1 (inlined std::cmp::min::) { + scope 2 (inlined std::cmp::impls::::min) { + } + } + + bb0: { + _0 = integer_min::(move _1, move _2) -> [return: bb1, unwind unreachable]; + } + + bb1: { + return; + } +} diff --git a/tests/mir-opt/pre-codegen/cmp_splat.min_splatted_u8.runtime-optimized.after.mir b/tests/mir-opt/pre-codegen/cmp_splat.min_splatted_u8.runtime-optimized.after.mir new file mode 100644 index 0000000000000..270d217153870 --- /dev/null +++ b/tests/mir-opt/pre-codegen/cmp_splat.min_splatted_u8.runtime-optimized.after.mir @@ -0,0 +1,23 @@ +// MIR for `min_splatted_u8` after runtime-optimized + +fn min_splatted_u8(_1: u8, _2: u8) -> u8 { + debug x => _1; + debug y => _2; + let mut _0: u8; + scope 1 (inlined smallest::) { + scope 2 (inlined <(u8,) as std::cmp::SmallestArgs>::smallest) { + scope 3 { + scope 4 (inlined std::cmp::impls::::min) { + } + } + } + } + + bb0: { + _0 = integer_min::(move _1, move _2) -> [return: bb1, unwind unreachable]; + } + + bb1: { + return; + } +} diff --git a/tests/mir-opt/pre-codegen/cmp_splat.rs b/tests/mir-opt/pre-codegen/cmp_splat.rs new file mode 100644 index 0000000000000..ac4d1989ff3c6 --- /dev/null +++ b/tests/mir-opt/pre-codegen/cmp_splat.rs @@ -0,0 +1,33 @@ +#![feature(cmp_splat)] + +// Comparing the MIR of a splat-compatible function with it's direct counterpart. +// This test is to ensure MIR optimizations are able to remove the added layers +// of indirection. + +// EMIT_MIR cmp_splat.min_direct_u8.runtime-optimized.after.mir +pub fn min_direct_u8(x: u8, y: u8) -> u8 { + // CHECK-LABEL: fn min_direct_u8( + // CHECK: debug x => _1; + // CHECK: debug y => _2; + // CHECK: bb0: { + // CHECK-NEXT: _0 = integer_min::(move _1, move _2) -> [return: bb1, unwind unreachable]; + // CHECK-NEXT: } + // CHECK: bb1: { + // CHECK-NEXT: return; + // CHECK-NEXT: } + std::cmp::min(x, y) +} + +// EMIT_MIR cmp_splat.min_splatted_u8.runtime-optimized.after.mir +pub fn min_splatted_u8(x: u8, y: u8) -> u8 { + // CHECK-LABEL: fn min_splatted_u8( + // CHECK: debug x => _1; + // CHECK: debug y => _2; + // CHECK: bb0: { + // CHECK-NEXT: _0 = integer_min::(move _1, move _2) -> [return: bb1, unwind unreachable]; + // CHECK-NEXT: } + // CHECK: bb1: { + // CHECK-NEXT: return; + // CHECK-NEXT: } + std::cmp::smallest(x, y) +} diff --git a/tests/mir-opt/pre-codegen/const_promotion_option_ordering_eq.direct.runtime-optimized.after.mir b/tests/mir-opt/pre-codegen/const_promotion_option_ordering_eq.direct.runtime-optimized.after.mir index b1bbceae330c7..f7faefcc1bf7b 100644 --- a/tests/mir-opt/pre-codegen/const_promotion_option_ordering_eq.direct.runtime-optimized.after.mir +++ b/tests/mir-opt/pre-codegen/const_promotion_option_ordering_eq.direct.runtime-optimized.after.mir @@ -7,11 +7,7 @@ fn direct(_1: Option) -> bool { let mut _2: isize; scope 2 { scope 3 (inlined ::eq) { - let _3: i8; - scope 4 { - scope 5 { - } - } + let mut _3: i8; } } } @@ -30,7 +26,7 @@ fn direct(_1: Option) -> bool { bb2: { StorageLive(_3); _3 = discriminant(((_1 as Some).0: std::cmp::Ordering)); - _0 = Eq(copy _3, const 0_i8); + _0 = Eq(move _3, const 0_i8); StorageDead(_3); goto -> bb3; } diff --git a/tests/mir-opt/pre-codegen/const_promotion_option_ordering_eq.with_let.runtime-optimized.after.mir b/tests/mir-opt/pre-codegen/const_promotion_option_ordering_eq.with_let.runtime-optimized.after.mir index 86ef69b9a4cd5..2f0233e353c2f 100644 --- a/tests/mir-opt/pre-codegen/const_promotion_option_ordering_eq.with_let.runtime-optimized.after.mir +++ b/tests/mir-opt/pre-codegen/const_promotion_option_ordering_eq.with_let.runtime-optimized.after.mir @@ -9,11 +9,7 @@ fn with_let(_1: Option) -> bool { let mut _2: isize; scope 3 { scope 4 (inlined ::eq) { - let _3: i8; - scope 5 { - scope 6 { - } - } + let mut _3: i8; } } } @@ -33,7 +29,7 @@ fn with_let(_1: Option) -> bool { bb2: { StorageLive(_3); _3 = discriminant(((_1 as Some).0: std::cmp::Ordering)); - _0 = Eq(copy _3, const 0_i8); + _0 = Eq(move _3, const 0_i8); StorageDead(_3); goto -> bb3; } diff --git a/tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs b/tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs index 38cf724ee7d1b..0b3f445a6ec70 100644 --- a/tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs +++ b/tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs @@ -153,8 +153,6 @@ fn check_coff_symbols( ) { // ImageSymbol is 18 bytes; ImageSymbolEx (bigobj) is 20. let sym_size = std::mem::size_of::(); - // i686 decorates symbol names with a leading underscore. - let strip_underscore = header.machine() == pe::IMAGE_FILE_MACHINE_I386; let Ok(symbols) = header.symbols(data) else { return }; let strings = symbols.strings(); let symtab_base = header.pointer_to_symbol_table() as usize; @@ -179,8 +177,16 @@ fn check_coff_symbols( } let Ok(name_bytes) = symbol.name(strings) else { continue }; let Ok(mut name) = str::from_utf8(name_bytes).map(String::from) else { continue }; - if strip_underscore { - name = name.strip_prefix('_').unwrap_or(&name).to_string(); + + // Adjust for various symbol decorations. + match header.machine() { + pe::IMAGE_FILE_MACHINE_I386 => { + name = name.strip_prefix('_').unwrap_or(&name).to_string(); + } + pe::IMAGE_FILE_MACHINE_ARM64EC => { + name = name.strip_prefix('#').unwrap_or(&name).to_string(); + } + _ => {} } if EXPORTED.contains(&name.as_str()) { diff --git a/tests/rustdoc-html/deref/sidebar-links-deref-chain.rs b/tests/rustdoc-html/deref/sidebar-links-deref-chain.rs new file mode 100644 index 0000000000000..2b67228f5de30 --- /dev/null +++ b/tests/rustdoc-html/deref/sidebar-links-deref-chain.rs @@ -0,0 +1,21 @@ +// Regression test for . +#![crate_name = "foo"] + +pub struct S0; +pub struct S1; +pub struct S2; +pub struct S3; + +impl S0 { pub fn foo(&self) {} } +impl S1 { pub fn foo(&self) {} } +impl S2 { pub fn foo(&self) {} } +impl S3 { pub fn foo(&self) {} } + +impl std::ops::Deref for S0 { type Target = S1; fn deref(&self) -> &S1 { &S1 } } +impl std::ops::Deref for S1 { type Target = S2; fn deref(&self) -> &S2 { &S2 } } +impl std::ops::Deref for S2 { type Target = S3; fn deref(&self) -> &S3 { &S3 } } + +//@ has foo/struct.S0.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.foo"]' 'foo' +//@ has foo/struct.S0.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.foo-1"]' 'foo' +//@ has foo/struct.S0.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.foo-2"]' 'foo' +//@ has foo/struct.S0.html '//*[@class="sidebar-elems"]//section//li/a[@href="#method.foo-3"]' 'foo' diff --git a/tests/ui/asm/thumbv6m-clobber-abi-r14.rs b/tests/ui/asm/thumbv6m-clobber-abi-r14.rs new file mode 100644 index 0000000000000..342e65b52d9d8 --- /dev/null +++ b/tests/ui/asm/thumbv6m-clobber-abi-r14.rs @@ -0,0 +1,18 @@ +//@ add-minicore +//@ build-pass +//@ compile-flags: --target thumbv6m-none-eabi +//@ needs-llvm-components: arm +//@ ignore-backends: gcc + +#![feature(no_core)] +#![no_core] +#![crate_type = "rlib"] + +extern crate minicore; +use minicore::*; + +pub fn clobber_c_abi() { + unsafe { + asm!("nop", clobber_abi("C")); + } +} diff --git a/tests/ui/associated-types/issue-38821.rs b/tests/ui/associated-types/issue-38821.rs index 35c371235e640..227599204cc1f 100644 --- a/tests/ui/associated-types/issue-38821.rs +++ b/tests/ui/associated-types/issue-38821.rs @@ -32,8 +32,6 @@ pub trait Column: Expression {} //~| ERROR the trait bound `::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `::SqlType: NotNull` is not satisfied -//~| ERROR the trait bound `::SqlType: NotNull` is not satisfied -//~| ERROR the trait bound `::SqlType: NotNull` is not satisfied pub enum ColumnInsertValue where //~^ ERROR the trait bound `::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `::SqlType: NotNull` is not satisfied @@ -44,6 +42,8 @@ pub enum ColumnInsertValue where //~^ ERROR the trait bound `::SqlType: IntoNullable` is not satisfied { Expression(Col, Expr), + //~^ ERROR the trait bound `::SqlType: NotNull` is not satisfied + //~| ERROR the trait bound `::SqlType: NotNull` is not satisfied Default(Col), } diff --git a/tests/ui/associated-types/issue-38821.stderr b/tests/ui/associated-types/issue-38821.stderr index 050054ad704bc..ad59184366ae1 100644 --- a/tests/ui/associated-types/issue-38821.stderr +++ b/tests/ui/associated-types/issue-38821.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:37:1 + --> $DIR/issue-38821.rs:35:1 | LL | pub enum ColumnInsertValue where | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `::SqlType` @@ -17,7 +17,7 @@ LL | Expr: Expression::Nullable>, ::SqlType: IntoNullable` is not satisfied - --> $DIR/issue-38821.rs:43:22 + --> $DIR/issue-38821.rs:41:22 | LL | Expr: Expression::Nullable>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `::SqlType` @@ -82,7 +82,7 @@ LL | impl IntoNullable for T { = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:37:10 + --> $DIR/issue-38821.rs:35:10 | LL | #[derive(Debug, Copy, Clone)] | ----- in this derive macro expansion @@ -98,7 +98,7 @@ LL | impl IntoNullable for T { | | | unsatisfied trait bound introduced here note: required for `ColumnInsertValue` to implement `Debug` - --> $DIR/issue-38821.rs:37:10 + --> $DIR/issue-38821.rs:35:10 | LL | #[derive(Debug, Copy, Clone)] | ----- in this derive macro expansion @@ -132,7 +132,7 @@ LL | Expr: Expression::Nullable>, ::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:37:10 + --> $DIR/issue-38821.rs:35:10 | LL | #[derive(Debug, Copy, Clone)] | ---- in this derive macro expansion @@ -148,7 +148,7 @@ LL | impl IntoNullable for T { | | | unsatisfied trait bound introduced here note: required for `ColumnInsertValue` to implement `Copy` - --> $DIR/issue-38821.rs:37:10 + --> $DIR/issue-38821.rs:35:10 | LL | #[derive(Debug, Copy, Clone)] | ---- in this derive macro expansion @@ -211,7 +211,7 @@ LL | impl IntoNullable for T { = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:37:10 + --> $DIR/issue-38821.rs:35:10 | LL | #[derive(Debug, Copy, Clone)] | ----- in this derive macro expansion @@ -227,7 +227,7 @@ LL | impl IntoNullable for T { | | | unsatisfied trait bound introduced here note: required for `ColumnInsertValue` to implement `Clone` - --> $DIR/issue-38821.rs:37:10 + --> $DIR/issue-38821.rs:35:10 | LL | #[derive(Debug, Copy, Clone)] | ----- in this derive macro expansion @@ -303,10 +303,13 @@ LL | impl IntoNullable for T { = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:23:10 + --> $DIR/issue-38821.rs:44:5 | LL | #[derive(Debug, Copy, Clone)] - | ^^^^^ the trait `NotNull` is not implemented for `::SqlType` + | ----- in this derive macro expansion +... +LL | Expression(Col, Expr), + | ^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `::SqlType` | note: required for `::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 @@ -315,13 +318,15 @@ LL | impl IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:23:23 + --> $DIR/issue-38821.rs:44:5 | LL | #[derive(Debug, Copy, Clone)] - | ^^^^^ the trait `NotNull` is not implemented for `::SqlType` + | ----- in this derive macro expansion +... +LL | Expression(Col, Expr), + | ^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `::SqlType` | note: required for `::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 @@ -330,7 +335,6 @@ LL | impl IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 18 previous errors diff --git a/tests/ui/attributes/doc_examples/rustc_dump_symbol_name.rs b/tests/ui/attributes/doc_examples/rustc_dump_symbol_name.rs index 7c5750d1936db..ac62614bfe050 100644 --- a/tests/ui/attributes/doc_examples/rustc_dump_symbol_name.rs +++ b/tests/ui/attributes/doc_examples/rustc_dump_symbol_name.rs @@ -1,5 +1,5 @@ //@ dont-require-annotations: ERROR -//@ compile-flags: --crate-type lib -Z ui-testing=no +//@ compile-flags: --crate-type lib --crate-name crate_name -Z ui-testing=no //@ build-fail #![feature(rustc_attrs)] diff --git a/tests/ui/attributes/doc_examples/rustc_dump_symbol_name.stderr b/tests/ui/attributes/doc_examples/rustc_dump_symbol_name.stderr index a1d298909fae6..c97275b533331 100644 --- a/tests/ui/attributes/doc_examples/rustc_dump_symbol_name.stderr +++ b/tests/ui/attributes/doc_examples/rustc_dump_symbol_name.stderr @@ -1,32 +1,27 @@ -error: symbol-name(_RNvCsCRATE_HASH_22rustc_dump_symbol_name7mangled) +error: symbol-name(_RNvCsCRATE_HASH_10crate_name7mangled) --> $DIR/rustc_dump_symbol_name.rs:7:1 | -7 | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(rustc_dump_symbol_name[6981ee133444a33d]::mangled) - --> $DIR/rustc_dump_symbol_name.rs:7:1 - | -7 | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(rustc_dump_symbol_name::mangled) - --> $DIR/rustc_dump_symbol_name.rs:7:1 +7 | / #[rustc_dump_symbol_name] +8 | | fn mangled() {} + | |____________^ | -7 | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(crate_name[8cfd4c3bf0e8f389]::mangled) + = note: demangling-alt(crate_name::mangled) error: symbol-name(no_mangle) --> $DIR/rustc_dump_symbol_name.rs:10:1 | -10 | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +10 | / #[rustc_dump_symbol_name] +11 | | #[unsafe(no_mangle)] +12 | | fn no_mangle() {} + | |______________^ error: symbol-name(abort) --> $DIR/rustc_dump_symbol_name.rs:15:5 | -15 | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +15 | / #[rustc_dump_symbol_name] +16 | | fn abort(); + | |_______________^ -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr b/tests/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr index 5b6ce4e2eec89..0fcc164a25872 100644 --- a/tests/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr +++ b/tests/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr @@ -4,7 +4,12 @@ error[E0391]: cycle detected when building specialization graph of trait `Trait` LL | trait Trait { type Assoc; } | ^^^^^^^^^^^^^^ | - = note: ...which immediately requires building specialization graph of trait `Trait` again +note: ...which requires computing whether impls specialize one another... + --> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:17:1 + | +LL | impl Trait for String { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which again requires building specialization graph of trait `Trait`, completing the cycle = note: cycle used when coherence checking all impls of trait `Trait` = note: for more information, see and diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.rs b/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.rs index d467d5e0def02..2a28022b8844e 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.rs +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.rs @@ -21,8 +21,8 @@ trait Trait { #[rustc_dump_symbol_name] //~^ ERROR symbol-name(_RMCs -//~| ERROR demangling(>) +//~| NOTE demangling(>) impl dyn Trait {} fn main() {} diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.v0.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.v0.stderr index d87ed6292608e..945b005e10c50 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.v0.stderr +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-symbol-mangling.v0.stderr @@ -1,20 +1,13 @@ error: symbol-name(_RMCsCRATE_HASH_3symDNtB_5Traitp1NKj0_EL_) --> $DIR/dyn-compat-symbol-mangling.rs:22:1 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/dyn-compat-symbol-mangling.rs:22:1 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/dyn-compat-symbol-mangling.rs:22:1 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl dyn Trait {} + | |_____________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) -error: aborting due to 3 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/derives/deriving-all-codegen.stdout b/tests/ui/derives/deriving-all-codegen.stdout index ddd1158132c7d..05412aca82360 100644 --- a/tests/ui/derives/deriving-all-codegen.stdout +++ b/tests/ui/derives/deriving-all-codegen.stdout @@ -1018,7 +1018,7 @@ impl ::core::clone::Clone for Enum1 { #[inline] fn clone(&self) -> Self { match self { - Enum1::Single { x: __self_0 } => + Self::Single { x: __self_0 } => Self::Single { x: ::core::clone::Clone::clone(__self_0) }, } } @@ -1028,7 +1028,7 @@ impl ::core::fmt::Debug for Enum1 { #[inline] fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { match self { - Enum1::Single { x: __self_0 } => + Self::Single { x: __self_0 } => ::core::fmt::Formatter::debug_struct_field1_finish(f, "Single", "x", &__self_0), } @@ -1039,7 +1039,7 @@ impl ::core::hash::Hash for Enum1 { #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) { match self { - Enum1::Single { x: __self_0 } => + Self::Single { x: __self_0 } => ::core::hash::Hash::hash(__self_0, state), } } @@ -1051,7 +1051,7 @@ impl ::core::cmp::PartialEq for Enum1 { #[inline] fn eq(&self, other: &Self) -> bool { match (self, other) { - (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg1_0 }) => + (Self::Single { x: __self_0 }, Self::Single { x: __arg1_0 }) => __self_0 == __arg1_0, } } @@ -1078,7 +1078,7 @@ impl ::core::cmp::Ord for Enum1 { #[inline] fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { match (self, other) { - (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg1_0 }) => + (Self::Single { x: __self_0 }, Self::Single { x: __arg1_0 }) => ::core::cmp::Ord::cmp(__self_0, __arg1_0), } } @@ -1176,8 +1176,8 @@ impl ::core::default::Default for Fieldless { impl ::core::hash::Hash for Fieldless { #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) { - let __self_discr = ::core::intrinsics::discriminant_value(self); - ::core::hash::Hash::hash(&__self_discr, state) + ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self), + state) } } #[automatically_derived] @@ -1186,9 +1186,8 @@ impl ::core::marker::StructuralPartialEq for Fieldless { } impl ::core::cmp::PartialEq for Fieldless { #[inline] fn eq(&self, other: &Self) -> bool { - let __self_discr = ::core::intrinsics::discriminant_value(self); - let __arg1_discr = ::core::intrinsics::discriminant_value(other); - __self_discr == __arg1_discr + ::core::intrinsics::discriminant_value(self) == + ::core::intrinsics::discriminant_value(other) } } #[automatically_derived] @@ -1205,9 +1204,8 @@ impl ::core::cmp::PartialOrd for Fieldless { impl ::core::cmp::Ord for Fieldless { #[inline] fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { - let __self_discr = ::core::intrinsics::discriminant_value(self); - let __arg1_discr = ::core::intrinsics::discriminant_value(other); - ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr) + ::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self), + &::core::intrinsics::discriminant_value(other)) } } @@ -1243,12 +1241,12 @@ impl ::core::fmt::Debug for Mixed { #[inline] fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { match self { - Mixed::P => ::core::fmt::Formatter::write_str(f, "P"), - Mixed::Q => ::core::fmt::Formatter::write_str(f, "Q"), - Mixed::R(__self_0) => + Self::P => ::core::fmt::Formatter::write_str(f, "P"), + Self::Q => ::core::fmt::Formatter::write_str(f, "Q"), + Self::R(__self_0) => ::core::fmt::Formatter::debug_tuple_field1_finish(f, "R", &__self_0), - Mixed::S { d1: __self_0, d2: __self_1 } => + Self::S { d1: __self_0, d2: __self_1 } => ::core::fmt::Formatter::debug_struct_field2_finish(f, "S", "d1", __self_0, "d2", &__self_1), } @@ -1263,11 +1261,11 @@ impl ::core::default::Default for Mixed { impl ::core::hash::Hash for Mixed { #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) { - let __self_discr = ::core::intrinsics::discriminant_value(self); - ::core::hash::Hash::hash(&__self_discr, state); + ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self), + state); match self { - Mixed::R(__self_0) => ::core::hash::Hash::hash(__self_0, state), - Mixed::S { d1: __self_0, d2: __self_1 } => { + Self::R(__self_0) => ::core::hash::Hash::hash(__self_0, state), + Self::S { d1: __self_0, d2: __self_1 } => { ::core::hash::Hash::hash(__self_0, state); ::core::hash::Hash::hash(__self_1, state) } @@ -1281,13 +1279,12 @@ impl ::core::marker::StructuralPartialEq for Mixed { } impl ::core::cmp::PartialEq for Mixed { #[inline] fn eq(&self, other: &Self) -> bool { - let __self_discr = ::core::intrinsics::discriminant_value(self); - let __arg1_discr = ::core::intrinsics::discriminant_value(other); - __self_discr == __arg1_discr && + ::core::intrinsics::discriminant_value(self) == + ::core::intrinsics::discriminant_value(other) && match (self, other) { - (Mixed::R(__self_0), Mixed::R(__arg1_0)) => + (Self::R(__self_0), Self::R(__arg1_0)) => __self_0 == __arg1_0, - (Mixed::S { d1: __self_0, d2: __self_1 }, Mixed::S { + (Self::S { d1: __self_0, d2: __self_1 }, Self::S { d1: __arg1_0, d2: __arg1_1 }) => __self_0 == __arg1_0 && __self_1 == __arg1_1, _ => true, @@ -1317,23 +1314,19 @@ impl ::core::cmp::PartialOrd for Mixed { impl ::core::cmp::Ord for Mixed { #[inline] fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { - let __self_discr = ::core::intrinsics::discriminant_value(self); - let __arg1_discr = ::core::intrinsics::discriminant_value(other); - match ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr) { - ::core::cmp::Ordering::Equal => - match (self, other) { - (Mixed::R(__self_0), Mixed::R(__arg1_0)) => - ::core::cmp::Ord::cmp(__self_0, __arg1_0), - (Mixed::S { d1: __self_0, d2: __self_1 }, Mixed::S { - d1: __arg1_0, d2: __arg1_1 }) => - match ::core::cmp::Ord::cmp(__self_0, __arg1_0) { - ::core::cmp::Ordering::Equal => - ::core::cmp::Ord::cmp(__self_1, __arg1_1), - cmp => cmp, - }, - _ => ::core::cmp::Ordering::Equal, + match (self, other) { + (Self::R(__self_0), Self::R(__arg1_0)) => + ::core::cmp::Ord::cmp(__self_0, __arg1_0), + (Self::S { d1: __self_0, d2: __self_1 }, Self::S { + d1: __arg1_0, d2: __arg1_1 }) => + match ::core::cmp::Ord::cmp(__self_0, __arg1_0) { + ::core::cmp::Ordering::Equal => + ::core::cmp::Ord::cmp(__self_1, __arg1_1), + cmp => cmp, }, - cmp => cmp, + _ => + ::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self), + &::core::intrinsics::discriminant_value(other)), } } } @@ -1356,16 +1349,15 @@ impl ::core::marker::StructuralPartialEq for ReorderEnum { } impl ::core::cmp::PartialEq for ReorderEnum { #[inline] fn eq(&self, other: &Self) -> bool { - let __self_discr = ::core::intrinsics::discriminant_value(self); - let __arg1_discr = ::core::intrinsics::discriminant_value(other); - __self_discr == __arg1_discr && + ::core::intrinsics::discriminant_value(self) == + ::core::intrinsics::discriminant_value(other) && match (self, other) { - (ReorderEnum::A(__self_0), ReorderEnum::A(__arg1_0)) => + (Self::A(__self_0), Self::A(__arg1_0)) => __self_0 == __arg1_0, - (ReorderEnum::C(__self_0), ReorderEnum::C(__arg1_0)) => + (Self::C(__self_0), Self::C(__arg1_0)) => __self_0 == __arg1_0, - (ReorderEnum::G(__self_0, __self_1, __self_2), - ReorderEnum::G(__arg1_0, __arg1_1, __arg1_2)) => + (Self::G(__self_0, __self_1, __self_2), + Self::G(__arg1_0, __arg1_1, __arg1_2)) => __self_1 == __arg1_1 && __self_0 == __arg1_0 && __self_2 == __arg1_2, _ => true, @@ -1377,18 +1369,16 @@ impl ::core::cmp::PartialOrd for ReorderEnum { #[inline] fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { - let __self_discr = ::core::intrinsics::discriminant_value(self); - let __arg1_discr = ::core::intrinsics::discriminant_value(other); - match ::core::cmp::PartialOrd::partial_cmp(&__self_discr, - &__arg1_discr) { + match ::core::cmp::PartialOrd::partial_cmp(&::core::intrinsics::discriminant_value(self), + &::core::intrinsics::discriminant_value(other)) { ::core::option::Option::Some(::core::cmp::Ordering::Equal) => match (self, other) { - (ReorderEnum::A(__self_0), ReorderEnum::A(__arg1_0)) => + (Self::A(__self_0), Self::A(__arg1_0)) => ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0), - (ReorderEnum::C(__self_0), ReorderEnum::C(__arg1_0)) => + (Self::C(__self_0), Self::C(__arg1_0)) => ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0), - (ReorderEnum::G(__self_0, __self_1, __self_2), - ReorderEnum::G(__arg1_0, __arg1_1, __arg1_2)) => + (Self::G(__self_0, __self_1, __self_2), + Self::G(__arg1_0, __arg1_1, __arg1_2)) => match ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0) { ::core::option::Option::Some(::core::cmp::Ordering::Equal) @@ -1417,11 +1407,11 @@ impl ::core::clone::Clone for Fielded { #[inline] fn clone(&self) -> Self { match self { - Fielded::X(__self_0) => + Self::X(__self_0) => Self::X(::core::clone::Clone::clone(__self_0)), - Fielded::Y(__self_0) => + Self::Y(__self_0) => Self::Y(::core::clone::Clone::clone(__self_0)), - Fielded::Z(__self_0) => + Self::Z(__self_0) => Self::Z(::core::clone::Clone::clone(__self_0)), } } @@ -1431,13 +1421,13 @@ impl ::core::fmt::Debug for Fielded { #[inline] fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { match self { - Fielded::X(__self_0) => + Self::X(__self_0) => ::core::fmt::Formatter::debug_tuple_field1_finish(f, "X", &__self_0), - Fielded::Y(__self_0) => + Self::Y(__self_0) => ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Y", &__self_0), - Fielded::Z(__self_0) => + Self::Z(__self_0) => ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Z", &__self_0), } @@ -1447,12 +1437,12 @@ impl ::core::fmt::Debug for Fielded { impl ::core::hash::Hash for Fielded { #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) { - let __self_discr = ::core::intrinsics::discriminant_value(self); - ::core::hash::Hash::hash(&__self_discr, state); + ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self), + state); match self { - Fielded::X(__self_0) => ::core::hash::Hash::hash(__self_0, state), - Fielded::Y(__self_0) => ::core::hash::Hash::hash(__self_0, state), - Fielded::Z(__self_0) => ::core::hash::Hash::hash(__self_0, state), + Self::X(__self_0) => ::core::hash::Hash::hash(__self_0, state), + Self::Y(__self_0) => ::core::hash::Hash::hash(__self_0, state), + Self::Z(__self_0) => ::core::hash::Hash::hash(__self_0, state), } } } @@ -1462,15 +1452,14 @@ impl ::core::marker::StructuralPartialEq for Fielded { } impl ::core::cmp::PartialEq for Fielded { #[inline] fn eq(&self, other: &Self) -> bool { - let __self_discr = ::core::intrinsics::discriminant_value(self); - let __arg1_discr = ::core::intrinsics::discriminant_value(other); - __self_discr == __arg1_discr && + ::core::intrinsics::discriminant_value(self) == + ::core::intrinsics::discriminant_value(other) && match (self, other) { - (Fielded::X(__self_0), Fielded::X(__arg1_0)) => + (Self::X(__self_0), Self::X(__arg1_0)) => __self_0 == __arg1_0, - (Fielded::Y(__self_0), Fielded::Y(__arg1_0)) => + (Self::Y(__self_0), Self::Y(__arg1_0)) => __self_0 == __arg1_0, - (Fielded::Z(__self_0), Fielded::Z(__arg1_0)) => + (Self::Z(__self_0), Self::Z(__arg1_0)) => __self_0 == __arg1_0, _ => unsafe { ::core::intrinsics::unreachable() } } @@ -1499,20 +1488,16 @@ impl ::core::cmp::PartialOrd for Fielded { impl ::core::cmp::Ord for Fielded { #[inline] fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { - let __self_discr = ::core::intrinsics::discriminant_value(self); - let __arg1_discr = ::core::intrinsics::discriminant_value(other); - match ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr) { - ::core::cmp::Ordering::Equal => - match (self, other) { - (Fielded::X(__self_0), Fielded::X(__arg1_0)) => - ::core::cmp::Ord::cmp(__self_0, __arg1_0), - (Fielded::Y(__self_0), Fielded::Y(__arg1_0)) => - ::core::cmp::Ord::cmp(__self_0, __arg1_0), - (Fielded::Z(__self_0), Fielded::Z(__arg1_0)) => - ::core::cmp::Ord::cmp(__self_0, __arg1_0), - _ => unsafe { ::core::intrinsics::unreachable() } - }, - cmp => cmp, + match (self, other) { + (Self::X(__self_0), Self::X(__arg1_0)) => + ::core::cmp::Ord::cmp(__self_0, __arg1_0), + (Self::Y(__self_0), Self::Y(__arg1_0)) => + ::core::cmp::Ord::cmp(__self_0, __arg1_0), + (Self::Z(__self_0), Self::Z(__arg1_0)) => + ::core::cmp::Ord::cmp(__self_0, __arg1_0), + _ => + ::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self), + &::core::intrinsics::discriminant_value(other)), } } } @@ -1525,9 +1510,9 @@ impl ::core::clone::Clone #[inline] fn clone(&self) -> Self { match self { - EnumGeneric::One(__self_0) => + Self::One(__self_0) => Self::One(::core::clone::Clone::clone(__self_0)), - EnumGeneric::Two(__self_0) => + Self::Two(__self_0) => Self::Two(::core::clone::Clone::clone(__self_0)), } } @@ -1542,10 +1527,10 @@ impl ::core::fmt::Debug for #[inline] fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { match self { - EnumGeneric::One(__self_0) => + Self::One(__self_0) => ::core::fmt::Formatter::debug_tuple_field1_finish(f, "One", &__self_0), - EnumGeneric::Two(__self_0) => + Self::Two(__self_0) => ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Two", &__self_0), } @@ -1556,13 +1541,11 @@ impl ::core::hash::Hash for EnumGeneric { #[inline] fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) { - let __self_discr = ::core::intrinsics::discriminant_value(self); - ::core::hash::Hash::hash(&__self_discr, state); + ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self), + state); match self { - EnumGeneric::One(__self_0) => - ::core::hash::Hash::hash(__self_0, state), - EnumGeneric::Two(__self_0) => - ::core::hash::Hash::hash(__self_0, state), + Self::One(__self_0) => ::core::hash::Hash::hash(__self_0, state), + Self::Two(__self_0) => ::core::hash::Hash::hash(__self_0, state), } } } @@ -1575,13 +1558,12 @@ impl ::core::cmp::PartialEq for EnumGeneric { #[inline] fn eq(&self, other: &Self) -> bool { - let __self_discr = ::core::intrinsics::discriminant_value(self); - let __arg1_discr = ::core::intrinsics::discriminant_value(other); - __self_discr == __arg1_discr && + ::core::intrinsics::discriminant_value(self) == + ::core::intrinsics::discriminant_value(other) && match (self, other) { - (EnumGeneric::One(__self_0), EnumGeneric::One(__arg1_0)) => + (Self::One(__self_0), Self::One(__arg1_0)) => __self_0 == __arg1_0, - (EnumGeneric::Two(__self_0), EnumGeneric::Two(__arg1_0)) => + (Self::Two(__self_0), Self::Two(__arg1_0)) => __self_0 == __arg1_0, _ => unsafe { ::core::intrinsics::unreachable() } } @@ -1604,16 +1586,14 @@ impl #[inline] fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { - let __self_discr = ::core::intrinsics::discriminant_value(self); - let __arg1_discr = ::core::intrinsics::discriminant_value(other); match (self, other) { - (EnumGeneric::One(__self_0), EnumGeneric::One(__arg1_0)) => + (Self::One(__self_0), Self::One(__arg1_0)) => ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0), - (EnumGeneric::Two(__self_0), EnumGeneric::Two(__arg1_0)) => + (Self::Two(__self_0), Self::Two(__arg1_0)) => ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0), _ => - ::core::cmp::PartialOrd::partial_cmp(&__self_discr, - &__arg1_discr), + ::core::cmp::PartialOrd::partial_cmp(&::core::intrinsics::discriminant_value(self), + &::core::intrinsics::discriminant_value(other)), } } } @@ -1622,18 +1602,14 @@ impl ::core::cmp::Ord for EnumGeneric { #[inline] fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { - let __self_discr = ::core::intrinsics::discriminant_value(self); - let __arg1_discr = ::core::intrinsics::discriminant_value(other); - match ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr) { - ::core::cmp::Ordering::Equal => - match (self, other) { - (EnumGeneric::One(__self_0), EnumGeneric::One(__arg1_0)) => - ::core::cmp::Ord::cmp(__self_0, __arg1_0), - (EnumGeneric::Two(__self_0), EnumGeneric::Two(__arg1_0)) => - ::core::cmp::Ord::cmp(__self_0, __arg1_0), - _ => unsafe { ::core::intrinsics::unreachable() } - }, - cmp => cmp, + match (self, other) { + (Self::One(__self_0), Self::One(__arg1_0)) => + ::core::cmp::Ord::cmp(__self_0, __arg1_0), + (Self::Two(__self_0), Self::Two(__arg1_0)) => + ::core::cmp::Ord::cmp(__self_0, __arg1_0), + _ => + ::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self), + &::core::intrinsics::discriminant_value(other)), } } } @@ -1652,8 +1628,8 @@ impl ::core::cmp::PartialEq for NonCopyEnum { #[inline] fn eq(&self, other: &Self) -> bool { match (self, other) { - (NonCopyEnum::NonCopyField(__self_0), - NonCopyEnum::NonCopyField(__arg1_0)) => __self_0 == __arg1_0, + (Self::NonCopyField(__self_0), Self::NonCopyField(__arg1_0)) => + __self_0 == __arg1_0, } } } diff --git a/tests/ui/lint/fn-ptr-comparisons-no_std.fixed b/tests/ui/lint/fn-ptr-comparisons-no_std.fixed new file mode 100644 index 0000000000000..dd7477976b108 --- /dev/null +++ b/tests/ui/lint/fn-ptr-comparisons-no_std.fixed @@ -0,0 +1,13 @@ +//@ check-pass +//@ run-rustfix + +#![no_std] +#![crate_type = "lib"] +#![allow(dead_code)] + +fn a() {} + +fn cmp(f: fn()) -> bool { + core::ptr::fn_addr_eq(f, a as fn()) + //~^ WARN function pointer comparisons +} diff --git a/tests/ui/lint/fn-ptr-comparisons-no_std.rs b/tests/ui/lint/fn-ptr-comparisons-no_std.rs new file mode 100644 index 0000000000000..cdeab43b8b2b1 --- /dev/null +++ b/tests/ui/lint/fn-ptr-comparisons-no_std.rs @@ -0,0 +1,13 @@ +//@ check-pass +//@ run-rustfix + +#![no_std] +#![crate_type = "lib"] +#![allow(dead_code)] + +fn a() {} + +fn cmp(f: fn()) -> bool { + f == a + //~^ WARN function pointer comparisons +} diff --git a/tests/ui/lint/fn-ptr-comparisons-no_std.stderr b/tests/ui/lint/fn-ptr-comparisons-no_std.stderr new file mode 100644 index 0000000000000..f51f0bbb7437b --- /dev/null +++ b/tests/ui/lint/fn-ptr-comparisons-no_std.stderr @@ -0,0 +1,18 @@ +warning: function pointer comparisons do not produce meaningful results since their addresses are not guaranteed to be unique + --> $DIR/fn-ptr-comparisons-no_std.rs:11:5 + | +LL | f == a + | ^^^^^^ + | + = note: the address of the same function can vary between different codegen units + = note: furthermore, different functions could have the same address after being merged together + = note: for more information visit + = note: `#[warn(unpredictable_function_pointer_comparisons)]` on by default +help: refactor your code, or use `core::ptr::fn_addr_eq` to suppress the lint + | +LL - f == a +LL + core::ptr::fn_addr_eq(f, a as fn()) + | + +warning: 1 warning emitted + diff --git a/tests/ui/lint/int_to_ptr-no_core.rs b/tests/ui/lint/int_to_ptr-no_core.rs new file mode 100644 index 0000000000000..d62855e43ddb8 --- /dev/null +++ b/tests/ui/lint/int_to_ptr-no_core.rs @@ -0,0 +1,15 @@ +//@ check-pass +//@ add-minicore + +#![feature(no_core)] +#![no_core] +#![crate_type = "lib"] +#![allow(dead_code)] + +extern crate minicore; +use minicore::*; + +pub unsafe fn should_lint(a: usize) -> *const u8 { + unsafe { mem::transmute::(a) } + //~^ WARN transmuting an integer to a pointer +} diff --git a/tests/ui/lint/int_to_ptr-no_core.stderr b/tests/ui/lint/int_to_ptr-no_core.stderr new file mode 100644 index 0000000000000..4977bfe058cde --- /dev/null +++ b/tests/ui/lint/int_to_ptr-no_core.stderr @@ -0,0 +1,14 @@ +warning: transmuting an integer to a pointer creates a pointer without provenance + --> $DIR/int_to_ptr-no_core.rs:13:14 + | +LL | unsafe { mem::transmute::(a) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this is dangerous because dereferencing the resulting pointer is undefined behavior + = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance + = help: for more information about transmute, see + = help: for more information about exposed provenance, see + = note: `#[warn(integer_to_ptr_transmutes)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/lint/int_to_ptr-no_std.fixed b/tests/ui/lint/int_to_ptr-no_std.fixed new file mode 100644 index 0000000000000..4d476c265abb5 --- /dev/null +++ b/tests/ui/lint/int_to_ptr-no_std.fixed @@ -0,0 +1,14 @@ +//@ check-pass +//@ run-rustfix + +#![no_std] +#![crate_type = "lib"] +#![allow(unused_unsafe)] +#![allow(dead_code)] + +pub unsafe fn should_lint(a: usize) { + let _ptr: *const u8 = unsafe { core::ptr::with_exposed_provenance::(a) }; + //~^ WARN transmuting an integer to a pointer + let _ptr: *mut u8 = unsafe { core::ptr::with_exposed_provenance_mut::(a) }; + //~^ WARN transmuting an integer to a pointer +} diff --git a/tests/ui/lint/int_to_ptr-no_std.rs b/tests/ui/lint/int_to_ptr-no_std.rs new file mode 100644 index 0000000000000..f0eb95b3db7d1 --- /dev/null +++ b/tests/ui/lint/int_to_ptr-no_std.rs @@ -0,0 +1,14 @@ +//@ check-pass +//@ run-rustfix + +#![no_std] +#![crate_type = "lib"] +#![allow(unused_unsafe)] +#![allow(dead_code)] + +pub unsafe fn should_lint(a: usize) { + let _ptr: *const u8 = unsafe { core::mem::transmute::(a) }; + //~^ WARN transmuting an integer to a pointer + let _ptr: *mut u8 = unsafe { core::mem::transmute::(a) }; + //~^ WARN transmuting an integer to a pointer +} diff --git a/tests/ui/lint/int_to_ptr-no_std.stderr b/tests/ui/lint/int_to_ptr-no_std.stderr new file mode 100644 index 0000000000000..9de31a80efcc5 --- /dev/null +++ b/tests/ui/lint/int_to_ptr-no_std.stderr @@ -0,0 +1,37 @@ +warning: transmuting an integer to a pointer creates a pointer without provenance + --> $DIR/int_to_ptr-no_std.rs:10:36 + | +LL | let _ptr: *const u8 = unsafe { core::mem::transmute::(a) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this is dangerous because dereferencing the resulting pointer is undefined behavior + = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance + = help: for more information about transmute, see + = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `core::ptr::without_provenance_mut` + = note: `#[warn(integer_to_ptr_transmutes)]` on by default +help: use `core::ptr::with_exposed_provenance` instead to use a previously exposed provenance + | +LL - let _ptr: *const u8 = unsafe { core::mem::transmute::(a) }; +LL + let _ptr: *const u8 = unsafe { core::ptr::with_exposed_provenance::(a) }; + | + +warning: transmuting an integer to a pointer creates a pointer without provenance + --> $DIR/int_to_ptr-no_std.rs:12:34 + | +LL | let _ptr: *mut u8 = unsafe { core::mem::transmute::(a) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this is dangerous because dereferencing the resulting pointer is undefined behavior + = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance + = help: for more information about transmute, see + = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `core::ptr::without_provenance_mut` +help: use `core::ptr::with_exposed_provenance_mut` instead to use a previously exposed provenance + | +LL - let _ptr: *mut u8 = unsafe { core::mem::transmute::(a) }; +LL + let _ptr: *mut u8 = unsafe { core::ptr::with_exposed_provenance_mut::(a) }; + | + +warning: 2 warnings emitted + diff --git a/tests/ui/lint/int_to_ptr-unsized.stderr b/tests/ui/lint/int_to_ptr-unsized.stderr index 9799af8b12c15..559c4011c6c2e 100644 --- a/tests/ui/lint/int_to_ptr-unsized.stderr +++ b/tests/ui/lint/int_to_ptr-unsized.stderr @@ -6,9 +6,9 @@ LL | let _ref = unsafe { std::mem::transmute::( | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = note: `#[warn(integer_to_ptr_transmutes)]` on by default warning: transmuting an integer to a pointer creates a pointer without provenance @@ -19,9 +19,9 @@ LL | let _ptr = unsafe { std::mem::transmute::(0 | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` warning: 2 warnings emitted diff --git a/tests/ui/lint/int_to_ptr.stderr b/tests/ui/lint/int_to_ptr.stderr index 4035bda8fb2cf..fe4cf56373208 100644 --- a/tests/ui/lint/int_to_ptr.stderr +++ b/tests/ui/lint/int_to_ptr.stderr @@ -6,9 +6,9 @@ LL | let _ptr: *const u8 = unsafe { std::mem::transmute::( | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = note: `#[warn(integer_to_ptr_transmutes)]` on by default help: use `std::ptr::with_exposed_provenance` instead to use a previously exposed provenance | @@ -24,9 +24,9 @@ LL | let _ptr: *mut u8 = unsafe { std::mem::transmute::(a) } | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance_mut` instead to use a previously exposed provenance | LL - let _ptr: *mut u8 = unsafe { std::mem::transmute::(a) }; @@ -41,9 +41,9 @@ LL | let _ref: &'static u8 = unsafe { std::mem::transmute:: = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance` instead to use a previously exposed provenance | LL - let _ref: &'static u8 = unsafe { std::mem::transmute::(a) }; @@ -58,9 +58,9 @@ LL | let _ref: &'static mut u8 = unsafe { std::mem::transmute:: = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance_mut` instead to use a previously exposed provenance | LL - let _ref: &'static mut u8 = unsafe { std::mem::transmute::(a) }; @@ -75,9 +75,9 @@ LL | let _ptr = unsafe { std::mem::transmute::(42usize) }; | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance` instead to use a previously exposed provenance | LL - let _ptr = unsafe { std::mem::transmute::(42usize) }; @@ -92,9 +92,9 @@ LL | let _ptr = unsafe { std::mem::transmute::(a + a) }; | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance` instead to use a previously exposed provenance | LL - let _ptr = unsafe { std::mem::transmute::(a + a) }; @@ -109,9 +109,9 @@ LL | let _ptr: *const u8 = unsafe { std::mem::transmute::( | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance` instead to use a previously exposed provenance | LL - let _ptr: *const u8 = unsafe { std::mem::transmute::(a) }; @@ -126,9 +126,9 @@ LL | let _ptr: *mut u8 = unsafe { std::mem::transmute::(a) } | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance_mut` instead to use a previously exposed provenance | LL - let _ptr: *mut u8 = unsafe { std::mem::transmute::(a) }; @@ -143,9 +143,9 @@ LL | let _ref: &'static u8 = unsafe { std::mem::transmute:: = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance` instead to use a previously exposed provenance | LL - let _ref: &'static u8 = unsafe { std::mem::transmute::(a) }; @@ -160,9 +160,9 @@ LL | let _ref: &'static mut u8 = unsafe { std::mem::transmute:: = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance_mut` instead to use a previously exposed provenance | LL - let _ref: &'static mut u8 = unsafe { std::mem::transmute::(a) }; @@ -177,9 +177,9 @@ LL | let _ptr = unsafe { std::mem::transmute::(42usize) }; | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance` instead to use a previously exposed provenance | LL - let _ptr = unsafe { std::mem::transmute::(42usize) }; @@ -194,9 +194,9 @@ LL | let _ptr = unsafe { std::mem::transmute::(a + a) }; | = note: this is dangerous because dereferencing the resulting pointer is undefined behavior = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance - = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` = help: for more information about transmute, see = help: for more information about exposed provenance, see + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` help: use `std::ptr::with_exposed_provenance` instead to use a previously exposed provenance | LL - let _ptr = unsafe { std::mem::transmute::(a + a) }; diff --git a/tests/ui/lint/undropped_manually_drops-no_std.fixed b/tests/ui/lint/undropped_manually_drops-no_std.fixed new file mode 100644 index 0000000000000..f3b26a1f2903a --- /dev/null +++ b/tests/ui/lint/undropped_manually_drops-no_std.fixed @@ -0,0 +1,13 @@ +//@ check-fail +//@ run-rustfix + +#![no_std] +#![crate_type = "lib"] +#![allow(dead_code)] + +struct S; + +fn drop_md() { + core::mem::drop(core::mem::ManuallyDrop::into_inner(core::mem::ManuallyDrop::new(S))); + //~^ ERROR calls to `core::mem::drop` +} diff --git a/tests/ui/lint/undropped_manually_drops-no_std.rs b/tests/ui/lint/undropped_manually_drops-no_std.rs new file mode 100644 index 0000000000000..fb9f23282861f --- /dev/null +++ b/tests/ui/lint/undropped_manually_drops-no_std.rs @@ -0,0 +1,13 @@ +//@ check-fail +//@ run-rustfix + +#![no_std] +#![crate_type = "lib"] +#![allow(dead_code)] + +struct S; + +fn drop_md() { + core::mem::drop(core::mem::ManuallyDrop::new(S)); + //~^ ERROR calls to `core::mem::drop` +} diff --git a/tests/ui/lint/undropped_manually_drops-no_std.stderr b/tests/ui/lint/undropped_manually_drops-no_std.stderr new file mode 100644 index 0000000000000..db573e1f7388a --- /dev/null +++ b/tests/ui/lint/undropped_manually_drops-no_std.stderr @@ -0,0 +1,16 @@ +error: calls to `core::mem::drop` with `core::mem::ManuallyDrop` instead of the inner value does nothing + --> $DIR/undropped_manually_drops-no_std.rs:11:5 + | +LL | core::mem::drop(core::mem::ManuallyDrop::new(S)); + | ^^^^^^^^^^^^^^^^-------------------------------^ + | | + | argument has type `ManuallyDrop` + | + = note: `#[deny(undropped_manually_drops)]` on by default +help: use `core::mem::ManuallyDrop::into_inner` to get the inner value + | +LL | core::mem::drop(core::mem::ManuallyDrop::into_inner(core::mem::ManuallyDrop::new(S))); + | ++++++++++++++++++++++++++++++++++++ + + +error: aborting due to 1 previous error + diff --git a/tests/ui/lint/wide_pointer_comparisons-no_std.rs b/tests/ui/lint/wide_pointer_comparisons-no_std.rs new file mode 100644 index 0000000000000..745c9925f22a6 --- /dev/null +++ b/tests/ui/lint/wide_pointer_comparisons-no_std.rs @@ -0,0 +1,10 @@ +//@ check-pass + +#![no_std] +#![crate_type = "lib"] +#![allow(dead_code)] + +fn cmp(a: *mut [u8], b: *mut [u8]) -> bool { + a == b + //~^ WARN ambiguous wide pointer comparison +} diff --git a/tests/ui/lint/wide_pointer_comparisons-no_std.stderr b/tests/ui/lint/wide_pointer_comparisons-no_std.stderr new file mode 100644 index 0000000000000..a5090cb872a41 --- /dev/null +++ b/tests/ui/lint/wide_pointer_comparisons-no_std.stderr @@ -0,0 +1,20 @@ +warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected + --> $DIR/wide_pointer_comparisons-no_std.rs:8:5 + | +LL | a == b + | ^^^^^^ + | + = note: `#[warn(ambiguous_wide_pointer_comparisons)]` on by default +help: use `core::ptr::addr_eq` or untyped pointers to only compare their addresses + | +LL - a == b +LL + core::ptr::addr_eq(a, b) + | +help: use explicit `core::ptr::eq` method to compare metadata and addresses + | +LL - a == b +LL + core::ptr::eq(a, b) + | + +warning: 1 warning emitted + diff --git a/tests/ui/macros/non-fmt-panic-no_std-extern-std.fixed b/tests/ui/macros/non-fmt-panic-no_std-extern-std.fixed new file mode 100644 index 0000000000000..e39a5a5566db4 --- /dev/null +++ b/tests/ui/macros/non-fmt-panic-no_std-extern-std.fixed @@ -0,0 +1,14 @@ +//@ edition:2018 +//@ check-pass +//@ run-rustfix +//@ rustfix-only-machine-applicable + +#![no_std] +#![crate_type = "lib"] + +extern crate std; + +pub fn f() { + std::panic::panic_any(123); + //~^ WARN panic message is not a string literal +} diff --git a/tests/ui/macros/non-fmt-panic-no_std-extern-std.rs b/tests/ui/macros/non-fmt-panic-no_std-extern-std.rs new file mode 100644 index 0000000000000..0e2dd8dab6e3c --- /dev/null +++ b/tests/ui/macros/non-fmt-panic-no_std-extern-std.rs @@ -0,0 +1,14 @@ +//@ edition:2018 +//@ check-pass +//@ run-rustfix +//@ rustfix-only-machine-applicable + +#![no_std] +#![crate_type = "lib"] + +extern crate std; + +pub fn f() { + std::panic!(123); + //~^ WARN panic message is not a string literal +} diff --git a/tests/ui/macros/non-fmt-panic-no_std-extern-std.stderr b/tests/ui/macros/non-fmt-panic-no_std-extern-std.stderr new file mode 100644 index 0000000000000..9c96c1f032cc5 --- /dev/null +++ b/tests/ui/macros/non-fmt-panic-no_std-extern-std.stderr @@ -0,0 +1,22 @@ +warning: panic message is not a string literal + --> $DIR/non-fmt-panic-no_std-extern-std.rs:12:17 + | +LL | std::panic!(123); + | ^^^ + | + = note: this usage of `std::panic!()` is deprecated; it will be a hard error in Rust 2021 + = note: for more information, see + = note: for more information, see + = note: `#[warn(non_fmt_panics)]` (part of `#[warn(rust_2021_compatibility)]`) on by default +help: add a "{}" format string to `Display` the message + | +LL | std::panic!("{}", 123); + | +++++ +help: or use std::panic::panic_any instead + | +LL - std::panic!(123); +LL + std::panic::panic_any(123); + | + +warning: 1 warning emitted + diff --git a/tests/ui/macros/non-fmt-panic-no_std.fixed b/tests/ui/macros/non-fmt-panic-no_std.fixed new file mode 100644 index 0000000000000..f7904b15b2b23 --- /dev/null +++ b/tests/ui/macros/non-fmt-panic-no_std.fixed @@ -0,0 +1,14 @@ +//@ edition:2018 +//@ check-pass +//@ run-rustfix +//@ rustfix-only-machine-applicable + +#![no_std] +#![crate_type = "lib"] + +pub fn f(s: &str) { + panic!("{}", s); + //~^ WARN panic message is not a string literal + core::panic!("{}", s); + //~^ WARN panic message is not a string literal +} diff --git a/tests/ui/macros/non-fmt-panic-no_std.rs b/tests/ui/macros/non-fmt-panic-no_std.rs new file mode 100644 index 0000000000000..b1b0f609e6716 --- /dev/null +++ b/tests/ui/macros/non-fmt-panic-no_std.rs @@ -0,0 +1,14 @@ +//@ edition:2018 +//@ check-pass +//@ run-rustfix +//@ rustfix-only-machine-applicable + +#![no_std] +#![crate_type = "lib"] + +pub fn f(s: &str) { + panic!(s); + //~^ WARN panic message is not a string literal + core::panic!(s); + //~^ WARN panic message is not a string literal +} diff --git a/tests/ui/macros/non-fmt-panic-no_std.stderr b/tests/ui/macros/non-fmt-panic-no_std.stderr new file mode 100644 index 0000000000000..8fdf5bfaf7e13 --- /dev/null +++ b/tests/ui/macros/non-fmt-panic-no_std.stderr @@ -0,0 +1,31 @@ +warning: panic message is not a string literal + --> $DIR/non-fmt-panic-no_std.rs:10:12 + | +LL | panic!(s); + | ^ + | + = note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021 + = note: for more information, see + = note: for more information, see + = note: `#[warn(non_fmt_panics)]` (part of `#[warn(rust_2021_compatibility)]`) on by default +help: add a "{}" format string to `Display` the message + | +LL | panic!("{}", s); + | +++++ + +warning: panic message is not a string literal + --> $DIR/non-fmt-panic-no_std.rs:12:18 + | +LL | core::panic!(s); + | ^ + | + = note: this usage of `core::panic!()` is deprecated; it will be a hard error in Rust 2021 + = note: for more information, see + = note: for more information, see +help: add a "{}" format string to `Display` the message + | +LL | core::panic!("{}", s); + | +++++ + +warning: 2 warnings emitted + diff --git a/tests/ui/splat/splat-mangling.default.stderr b/tests/ui/splat/splat-mangling.default.stderr index ebe82cea89b62..d57d73ff019c2 100644 --- a/tests/ui/splat/splat-mangling.default.stderr +++ b/tests/ui/splat/splat-mangling.default.stderr @@ -1,146 +1,90 @@ error: symbol-name(_RMNvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFwThmEEuE) --> $DIR/splat-mangling.rs:22:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/splat-mangling.rs:22:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/splat-mangling.rs:22:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |___________________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFThmEEuE) --> $DIR/splat-mangling.rs:32:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/splat-mangling.rs:32:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/splat-mangling.rs:32:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |____________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs0_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFwTThmEEEuE) --> $DIR/splat-mangling.rs:42:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/splat-mangling.rs:42:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/splat-mangling.rs:42:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |______________________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs1_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFTThmEEEuE) --> $DIR/splat-mangling.rs:52:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/splat-mangling.rs:52:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/splat-mangling.rs:52:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |_______________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs2_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypePFwTmaEEuE) --> $DIR/splat-mangling.rs:62:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/splat-mangling.rs:62:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/splat-mangling.rs:62:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<*const fn(#[rustc_splat] (u32, i8))> {} + | |__________________________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs3_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypePFTmaEEuE) --> $DIR/splat-mangling.rs:72:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/splat-mangling.rs:72:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/splat-mangling.rs:72:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<*const fn((u32, i8))> {} + | |___________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs4_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFwTmaEdEuE) --> $DIR/splat-mangling.rs:82:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/splat-mangling.rs:82:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/splat-mangling.rs:82:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |________________________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs5_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFTmaEdEuE) --> $DIR/splat-mangling.rs:92:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/splat-mangling.rs:92:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/splat-mangling.rs:92:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |_________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) -error: aborting due to 24 previous errors +error: aborting due to 8 previous errors diff --git a/tests/ui/splat/splat-mangling.legacy.stderr b/tests/ui/splat/splat-mangling.legacy.stderr index 526fd04f0f951..17525117e687e 100644 --- a/tests/ui/splat/splat-mangling.legacy.stderr +++ b/tests/ui/splat/splat-mangling.legacy.stderr @@ -1,146 +1,90 @@ error: symbol-name(_ZN14splat_mangling4main72Type$LT$fn$LP$$C$$u20$$u23$$u5b$rustc_splat$u5d$$LP$u8$C$u32$RP$$RP$$GT$17hCRATE_HASHE) --> $DIR/splat-mangling.rs:22:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(splat_mangling::main::Type::hCRATE_HASH) - --> $DIR/splat-mangling.rs:22:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(splat_mangling::main::Type) - --> $DIR/splat-mangling.rs:22:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |___________________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(splat_mangling::main::Type::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type) error: symbol-name(_ZN14splat_mangling4main38Type$LT$fn$LP$$LP$u8$C$u32$RP$$RP$$GT$17hCRATE_HASHE) --> $DIR/splat-mangling.rs:32:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(splat_mangling::main::Type::hCRATE_HASH) - --> $DIR/splat-mangling.rs:32:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(splat_mangling::main::Type) - --> $DIR/splat-mangling.rs:32:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |____________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(splat_mangling::main::Type::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type) error: symbol-name(_ZN14splat_mangling4main83Type$LT$fn$LP$$C$$u20$$u23$$u5b$rustc_splat$u5d$$LP$$LP$u8$C$u32$RP$$C$$RP$$RP$$GT$17hCRATE_HASHE) --> $DIR/splat-mangling.rs:42:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(splat_mangling::main::Type::hCRATE_HASH) - --> $DIR/splat-mangling.rs:42:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(splat_mangling::main::Type) - --> $DIR/splat-mangling.rs:42:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |______________________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(splat_mangling::main::Type::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type) error: symbol-name(_ZN14splat_mangling4main49Type$LT$fn$LP$$LP$$LP$u8$C$u32$RP$$C$$RP$$RP$$GT$17hCRATE_HASHE) --> $DIR/splat-mangling.rs:52:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(splat_mangling::main::Type::hCRATE_HASH) - --> $DIR/splat-mangling.rs:52:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(splat_mangling::main::Type) - --> $DIR/splat-mangling.rs:52:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |_______________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(splat_mangling::main::Type::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type) error: symbol-name(_ZN14splat_mangling4main86Type$LT$$BP$const$u20$fn$LP$$C$$u20$$u23$$u5b$rustc_splat$u5d$$LP$u32$C$i8$RP$$RP$$GT$17hCRATE_HASHE) --> $DIR/splat-mangling.rs:62:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(splat_mangling::main::Type<*const fn(, #[rustc_splat](u32,i8))>::hCRATE_HASH) - --> $DIR/splat-mangling.rs:62:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(splat_mangling::main::Type<*const fn(, #[rustc_splat](u32,i8))>) - --> $DIR/splat-mangling.rs:62:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<*const fn(#[rustc_splat] (u32, i8))> {} + | |__________________________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(splat_mangling::main::Type<*const fn(, #[rustc_splat](u32,i8))>::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type<*const fn(, #[rustc_splat](u32,i8))>) error: symbol-name(_ZN14splat_mangling4main52Type$LT$$BP$const$u20$fn$LP$$LP$u32$C$i8$RP$$RP$$GT$17hCRATE_HASHE) --> $DIR/splat-mangling.rs:72:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(splat_mangling::main::Type<*const fn((u32,i8))>::hCRATE_HASH) - --> $DIR/splat-mangling.rs:72:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(splat_mangling::main::Type<*const fn((u32,i8))>) - --> $DIR/splat-mangling.rs:72:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<*const fn((u32, i8))> {} + | |___________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(splat_mangling::main::Type<*const fn((u32,i8))>::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type<*const fn((u32,i8))>) error: symbol-name(_ZN14splat_mangling4main78Type$LT$fn$LP$$C$$u20$$u23$$u5b$rustc_splat$u5d$$LP$u32$C$i8$RP$$C$f64$RP$$GT$17hCRATE_HASHE) --> $DIR/splat-mangling.rs:82:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(splat_mangling::main::Type::hCRATE_HASH) - --> $DIR/splat-mangling.rs:82:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(splat_mangling::main::Type) - --> $DIR/splat-mangling.rs:82:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |________________________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(splat_mangling::main::Type::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type) error: symbol-name(_ZN14splat_mangling4main44Type$LT$fn$LP$$LP$u32$C$i8$RP$$C$f64$RP$$GT$17hCRATE_HASHE) --> $DIR/splat-mangling.rs:92:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(splat_mangling::main::Type::hCRATE_HASH) - --> $DIR/splat-mangling.rs:92:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(splat_mangling::main::Type) - --> $DIR/splat-mangling.rs:92:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |_________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(splat_mangling::main::Type::hCRATE_HASH) + = note: demangling-alt(splat_mangling::main::Type) -error: aborting due to 24 previous errors +error: aborting due to 8 previous errors diff --git a/tests/ui/splat/splat-mangling.rs b/tests/ui/splat/splat-mangling.rs index b6e2fd3ecd47e..982d070199c7d 100644 --- a/tests/ui/splat/splat-mangling.rs +++ b/tests/ui/splat/splat-mangling.rs @@ -21,80 +21,80 @@ fn main() { // FIXME(splat, legacy mangling): the first comma is in the wrong place #[rustc_dump_symbol_name] //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main72Type$LT$fn$LP$$C$$u20$$u23$$u5b$rustc_splat$u5d$$LP$u8$C$u32$RP$$RP$$GT - //[legacy]~| ERROR demangling(splat_mangling::main::Type:: - //[legacy]~| ERROR demangling-alt(splat_mangling::main::Type) + //[legacy]~| NOTE demangling(splat_mangling::main::Type:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type) //[v0,default]~^^^^ ERROR symbol-name(_RMNvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFwThmEEuE) - //[v0,default]~| ERROR demangling(>) + //[v0,default]~| NOTE demangling(>) impl Type {} #[rustfmt::skip] #[rustc_dump_symbol_name] //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main38Type$LT$fn$LP$$LP$u8$C$u32$RP$$RP$$GT - //[legacy]~| ERROR demangling(splat_mangling::main::Type:: - //[legacy]~| ERROR demangling-alt(splat_mangling::main::Type) + //[legacy]~| NOTE demangling(splat_mangling::main::Type:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type) //[v0,default]~^^^^ ERROR symbol-name(_RMs_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFThmEEuE) - //[v0,default]~| ERROR demangling(>) + //[v0,default]~| NOTE demangling(>) impl Type {} #[rustfmt::skip] #[rustc_dump_symbol_name] //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main83Type$LT$fn$LP$$C$$u20$$u23$$u5b$rustc_splat$u5d$$LP$$LP$u8$C$u32$RP$$C$$RP$$RP$$GT - //[legacy]~| ERROR demangling(splat_mangling::main::Type:: - //[legacy]~| ERROR demangling-alt(splat_mangling::main::Type) + //[legacy]~| NOTE demangling(splat_mangling::main::Type:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type) //[v0,default]~^^^^ ERROR symbol-name(_RMs0_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFwTThmEEEuE) - //[v0,default]~| ERROR demangling(>) + //[v0,default]~| NOTE demangling(>) impl Type {} #[rustfmt::skip] #[rustc_dump_symbol_name] //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main49Type$LT$fn$LP$$LP$$LP$u8$C$u32$RP$$C$$RP$$RP$$GT - //[legacy]~| ERROR demangling(splat_mangling::main::Type:: - //[legacy]~| ERROR demangling-alt(splat_mangling::main::Type) + //[legacy]~| NOTE demangling(splat_mangling::main::Type:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type) //[v0,default]~^^^^ ERROR symbol-name(_RMs1_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFTThmEEEuE) - //[v0,default]~| ERROR demangling(>) + //[v0,default]~| NOTE demangling(>) impl Type {} #[rustfmt::skip] #[rustc_dump_symbol_name] //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main86Type$LT$$BP$const$u20$fn$LP$$C$$u20$$u23$$u5b$rustc_splat$u5d$$LP$u32$C$i8$RP$$RP$$GT - //[legacy]~| ERROR demangling(splat_mangling::main::Type<*const fn(, #[rustc_splat](u32,i8))>:: - //[legacy]~| ERROR demangling-alt(splat_mangling::main::Type<*const fn(, #[rustc_splat](u32,i8))>) + //[legacy]~| NOTE demangling(splat_mangling::main::Type<*const fn(, #[rustc_splat](u32,i8))>:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type<*const fn(, #[rustc_splat](u32,i8))>) //[v0,default]~^^^^ ERROR symbol-name(_RMs2_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypePFwTmaEEuE) - //[v0,default]~| ERROR demangling(>) + //[v0,default]~| NOTE demangling(>) impl Type<*const fn(#[rustc_splat] (u32, i8))> {} #[rustfmt::skip] #[rustc_dump_symbol_name] //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main52Type$LT$$BP$const$u20$fn$LP$$LP$u32$C$i8$RP$$RP$$GT - //[legacy]~| ERROR demangling(splat_mangling::main::Type<*const fn((u32,i8))>:: - //[legacy]~| ERROR demangling-alt(splat_mangling::main::Type<*const fn((u32,i8))>) + //[legacy]~| NOTE demangling(splat_mangling::main::Type<*const fn((u32,i8))>:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type<*const fn((u32,i8))>) //[v0,default]~^^^^ ERROR symbol-name(_RMs3_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypePFTmaEEuE) - //[v0,default]~| ERROR demangling(>) + //[v0,default]~| NOTE demangling(>) impl Type<*const fn((u32, i8))> {} #[rustfmt::skip] #[rustc_dump_symbol_name] //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main78Type$LT$fn$LP$$C$$u20$$u23$$u5b$rustc_splat$u5d$$LP$u32$C$i8$RP$$C$f64$RP$$GT - //[legacy]~| ERROR demangling(splat_mangling::main::Type:: - //[legacy]~| ERROR demangling-alt(splat_mangling::main::Type) + //[legacy]~| NOTE demangling(splat_mangling::main::Type:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type) //[v0,default]~^^^^ ERROR symbol-name(_RMs4_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFwTmaEdEuE) - //[v0,default]~| ERROR demangling(>) + //[v0,default]~| NOTE demangling(>) impl Type {} #[rustfmt::skip] #[rustc_dump_symbol_name] //[legacy]~^ ERROR symbol-name(_ZN14splat_mangling4main44Type$LT$fn$LP$$LP$u32$C$i8$RP$$C$f64$RP$$GT - //[legacy]~| ERROR demangling(splat_mangling::main::Type:: - //[legacy]~| ERROR demangling-alt(splat_mangling::main::Type) + //[legacy]~| NOTE demangling(splat_mangling::main::Type:: + //[legacy]~| NOTE demangling-alt(splat_mangling::main::Type) //[v0,default]~^^^^ ERROR symbol-name(_RMs5_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFTmaEdEuE) - //[v0,default]~| ERROR demangling(>) + //[v0,default]~| NOTE demangling(>) impl Type {} } diff --git a/tests/ui/splat/splat-mangling.v0.stderr b/tests/ui/splat/splat-mangling.v0.stderr index ebe82cea89b62..d57d73ff019c2 100644 --- a/tests/ui/splat/splat-mangling.v0.stderr +++ b/tests/ui/splat/splat-mangling.v0.stderr @@ -1,146 +1,90 @@ error: symbol-name(_RMNvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFwThmEEuE) --> $DIR/splat-mangling.rs:22:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/splat-mangling.rs:22:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/splat-mangling.rs:22:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |___________________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFThmEEuE) --> $DIR/splat-mangling.rs:32:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/splat-mangling.rs:32:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/splat-mangling.rs:32:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |____________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs0_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFwTThmEEEuE) --> $DIR/splat-mangling.rs:42:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/splat-mangling.rs:42:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/splat-mangling.rs:42:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |______________________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs1_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFTThmEEEuE) --> $DIR/splat-mangling.rs:52:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/splat-mangling.rs:52:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/splat-mangling.rs:52:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |_______________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs2_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypePFwTmaEEuE) --> $DIR/splat-mangling.rs:62:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/splat-mangling.rs:62:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/splat-mangling.rs:62:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<*const fn(#[rustc_splat] (u32, i8))> {} + | |__________________________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs3_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypePFTmaEEuE) --> $DIR/splat-mangling.rs:72:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/splat-mangling.rs:72:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/splat-mangling.rs:72:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<*const fn((u32, i8))> {} + | |___________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs4_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFwTmaEdEuE) --> $DIR/splat-mangling.rs:82:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/splat-mangling.rs:82:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/splat-mangling.rs:82:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |________________________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs5_NvCsCRATE_HASH_14splat_mangling4mainINtB_4TypeFTmaEdEuE) --> $DIR/splat-mangling.rs:92:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/splat-mangling.rs:92:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/splat-mangling.rs:92:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |_________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) -error: aborting due to 24 previous errors +error: aborting due to 8 previous errors diff --git a/tests/ui/stats/macro-stats.stderr b/tests/ui/stats/macro-stats.stderr index 95567e20db3bf..efc3785878c39 100644 --- a/tests/ui/stats/macro-stats.stderr +++ b/tests/ui/stats/macro-stats.stderr @@ -3,7 +3,7 @@ macro-stats MACRO EXPANSION STATS: macro_stats macro-stats Macro Name Uses Lines Avg Lines Bytes Avg Bytes macro-stats ----------------------------------------------------------------------------------- macro-stats #[derive(Clone)] 8 67 8.4 1_909 238.6 -macro-stats #[derive(Hash)] 2 17 8.5 565 282.5 +macro-stats #[derive(Hash)] 2 17 8.5 536 268.0 macro-stats q! 1 26 26.0 519 519.0 macro-stats #[derive(Ord)] 1 15 15.0 505 505.0 macro-stats #[derive(Default)] 2 16 8.0 409 204.5 diff --git a/tests/ui/symbol-names/basic.legacy.stderr b/tests/ui/symbol-names/basic.legacy.stderr index 9c30ebdf30b88..a50a7702a7f29 100644 --- a/tests/ui/symbol-names/basic.legacy.stderr +++ b/tests/ui/symbol-names/basic.legacy.stderr @@ -1,20 +1,13 @@ error: symbol-name(_ZN5basic4main17hd30beb15618b9d64E) --> $DIR/basic.rs:8:1 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(basic::main::hd30beb15618b9d64) - --> $DIR/basic.rs:8:1 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(basic::main) - --> $DIR/basic.rs:8:1 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn main() { + | |_________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(basic::main::hd30beb15618b9d64) + = note: demangling-alt(basic::main) error: def-path(main) --> $DIR/basic.rs:15:1 @@ -22,5 +15,5 @@ error: def-path(main) LL | #[rustc_dump_def_path] | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/symbol-names/basic.rs b/tests/ui/symbol-names/basic.rs index d4c23f988384a..bd717f3edd077 100644 --- a/tests/ui/symbol-names/basic.rs +++ b/tests/ui/symbol-names/basic.rs @@ -7,11 +7,11 @@ #[rustc_dump_symbol_name] //[legacy]~^ ERROR symbol-name(_ZN5basic4main -//[legacy]~| ERROR demangling(basic::main -//[legacy]~| ERROR demangling-alt(basic::main) +//[legacy]~| NOTE demangling(basic::main +//[legacy]~| NOTE demangling-alt(basic::main) //[v0]~^^^^ ERROR symbol-name(_RNv - //[v0]~| ERROR demangling(basic[ - //[v0]~| ERROR demangling-alt(basic::main) + //[v0]~| NOTE demangling(basic[ + //[v0]~| NOTE demangling-alt(basic::main) #[rustc_dump_def_path] //[legacy]~^ ERROR def-path(main) //[v0]~^^ ERROR def-path(main) diff --git a/tests/ui/symbol-names/basic.v0.stderr b/tests/ui/symbol-names/basic.v0.stderr index 6a9da17eebe03..d4df8d74ca5f8 100644 --- a/tests/ui/symbol-names/basic.v0.stderr +++ b/tests/ui/symbol-names/basic.v0.stderr @@ -1,20 +1,13 @@ error: symbol-name(_RNvCsCRATE_HASH_5basic4main) --> $DIR/basic.rs:8:1 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(basic[a90d658f4748b9d1]::main) - --> $DIR/basic.rs:8:1 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(basic::main) - --> $DIR/basic.rs:8:1 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn main() { + | |_________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(basic[a90d658f4748b9d1]::main) + = note: demangling-alt(basic::main) error: def-path(main) --> $DIR/basic.rs:15:1 @@ -22,5 +15,5 @@ error: def-path(main) LL | #[rustc_dump_def_path] | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/symbol-names/const-generics-demangling.legacy.stderr b/tests/ui/symbol-names/const-generics-demangling.legacy.stderr index a2331da13c414..de3fbf0443585 100644 --- a/tests/ui/symbol-names/const-generics-demangling.legacy.stderr +++ b/tests/ui/symbol-names/const-generics-demangling.legacy.stderr @@ -1,74 +1,46 @@ error: symbol-name(_ZN1c21Unsigned$LT$11_u8$GT$1f17h[HASH]E) --> $DIR/const-generics-demangling.rs:13:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(c::Unsigned<11_u8>::f::h[HASH]) - --> $DIR/const-generics-demangling.rs:13:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(c::Unsigned<11_u8>::f) - --> $DIR/const-generics-demangling.rs:13:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn f() {} + | |__________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(c::Unsigned<11_u8>::f::h[HASH]) + = note: demangling-alt(c::Unsigned<11_u8>::f) error: symbol-name(_ZN1c22Signed$LT$.152_i16$GT$1f17h[HASH]E) --> $DIR/const-generics-demangling.rs:26:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(c::Signed<.152_i16>::f::h[HASH]) - --> $DIR/const-generics-demangling.rs:26:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(c::Signed<.152_i16>::f) - --> $DIR/const-generics-demangling.rs:26:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn f() {} + | |__________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(c::Signed<.152_i16>::f::h[HASH]) + = note: demangling-alt(c::Signed<.152_i16>::f) error: symbol-name(_ZN1c13Bool$LT$_$GT$1f17h[HASH]E) --> $DIR/const-generics-demangling.rs:39:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(c::Bool<_>::f::h[HASH]) - --> $DIR/const-generics-demangling.rs:39:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(c::Bool<_>::f) - --> $DIR/const-generics-demangling.rs:39:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn f() {} + | |__________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(c::Bool<_>::f::h[HASH]) + = note: demangling-alt(c::Bool<_>::f) error: symbol-name(_ZN1c13Char$LT$_$GT$1f17h[HASH]E) --> $DIR/const-generics-demangling.rs:52:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(c::Char<_>::f::h[HASH]) - --> $DIR/const-generics-demangling.rs:52:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(c::Char<_>::f) - --> $DIR/const-generics-demangling.rs:52:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn f() {} + | |__________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(c::Char<_>::f::h[HASH]) + = note: demangling-alt(c::Char<_>::f) -error: aborting due to 12 previous errors +error: aborting due to 4 previous errors diff --git a/tests/ui/symbol-names/const-generics-demangling.rs b/tests/ui/symbol-names/const-generics-demangling.rs index e32ab180fab28..7a0c4bd8ccb37 100644 --- a/tests/ui/symbol-names/const-generics-demangling.rs +++ b/tests/ui/symbol-names/const-generics-demangling.rs @@ -12,11 +12,11 @@ pub struct Unsigned; impl Unsigned<11> { #[rustc_dump_symbol_name] //[v0]~^ ERROR symbol-name(_RNvMCs - //[v0]~| ERROR demangling(>::f) + //[v0]~| NOTE demangling(>::f) //[legacy]~^^^^ ERROR symbol-name(_ZN1c21Unsigned$LT$11_u8$GT$ - //[legacy]~| ERROR demangling(c::Unsigned<11_u8>::f:: - //[legacy]~| ERROR demangling-alt(c::Unsigned<11_u8>::f) + //[legacy]~| NOTE demangling(c::Unsigned<11_u8>::f:: + //[legacy]~| NOTE demangling-alt(c::Unsigned<11_u8>::f) fn f() {} } @@ -25,11 +25,11 @@ pub struct Signed; impl Signed<-152> { #[rustc_dump_symbol_name] //[v0]~^ ERROR symbol-name(_RNvMs_Cs - //[v0]~| ERROR demangling(>::f) + //[v0]~| NOTE demangling(>::f) //[legacy]~^^^^ ERROR symbol-name(_ZN1c22Signed$LT$.152_i16$GT$ - //[legacy]~| ERROR demangling(c::Signed<.152_i16>::f:: - //[legacy]~| ERROR demangling-alt(c::Signed<.152_i16>::f) + //[legacy]~| NOTE demangling(c::Signed<.152_i16>::f:: + //[legacy]~| NOTE demangling-alt(c::Signed<.152_i16>::f) fn f() {} } @@ -38,11 +38,11 @@ pub struct Bool; impl Bool { #[rustc_dump_symbol_name] //[v0]~^ ERROR symbol-name(_RNvMs0_Cs - //[v0]~| ERROR demangling(>::f) + //[v0]~| NOTE demangling(>::f) //[legacy]~^^^^ ERROR symbol-name(_ZN1c13Bool$LT$_$GT$ - //[legacy]~| ERROR demangling(c::Bool<_>::f:: - //[legacy]~| ERROR demangling-alt(c::Bool<_>::f) + //[legacy]~| NOTE demangling(c::Bool<_>::f:: + //[legacy]~| NOTE demangling-alt(c::Bool<_>::f) fn f() {} } @@ -51,11 +51,11 @@ pub struct Char; impl Char<'∂'> { #[rustc_dump_symbol_name] //[v0]~^ ERROR symbol-name(_RNvMs1_Cs - //[v0]~| ERROR demangling(>::f) + //[v0]~| NOTE demangling(>::f) //[legacy]~^^^^ ERROR symbol-name(_ZN1c13Char$LT$_$GT$ - //[legacy]~| ERROR demangling(c::Char<_>::f:: - //[legacy]~| ERROR demangling-alt(c::Char<_>::f) + //[legacy]~| NOTE demangling(c::Char<_>::f:: + //[legacy]~| NOTE demangling-alt(c::Char<_>::f) fn f() {} } diff --git a/tests/ui/symbol-names/const-generics-demangling.v0.stderr b/tests/ui/symbol-names/const-generics-demangling.v0.stderr index 25fe5873389e7..8e69a1a1d80ea 100644 --- a/tests/ui/symbol-names/const-generics-demangling.v0.stderr +++ b/tests/ui/symbol-names/const-generics-demangling.v0.stderr @@ -1,74 +1,46 @@ error: symbol-name(_RNvMCsCRATE_HASH_1cINtB_8UnsignedKhb_E1f) --> $DIR/const-generics-demangling.rs:13:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>::f) - --> $DIR/const-generics-demangling.rs:13:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>::f) - --> $DIR/const-generics-demangling.rs:13:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn f() {} + | |__________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>::f) + = note: demangling-alt(>::f) error: symbol-name(_RNvMs_CsCRATE_HASH_1cINtB_6SignedKsn98_E1f) --> $DIR/const-generics-demangling.rs:26:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>::f) - --> $DIR/const-generics-demangling.rs:26:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>::f) - --> $DIR/const-generics-demangling.rs:26:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn f() {} + | |__________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>::f) + = note: demangling-alt(>::f) error: symbol-name(_RNvMs0_CsCRATE_HASH_1cINtB_4BoolKb1_E1f) --> $DIR/const-generics-demangling.rs:39:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>::f) - --> $DIR/const-generics-demangling.rs:39:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>::f) - --> $DIR/const-generics-demangling.rs:39:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn f() {} + | |__________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>::f) + = note: demangling-alt(>::f) error: symbol-name(_RNvMs1_CsCRATE_HASH_1cINtB_4CharKc2202_E1f) --> $DIR/const-generics-demangling.rs:52:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>::f) - --> $DIR/const-generics-demangling.rs:52:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>::f) - --> $DIR/const-generics-demangling.rs:52:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn f() {} + | |__________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>::f) + = note: demangling-alt(>::f) -error: aborting due to 12 previous errors +error: aborting due to 4 previous errors diff --git a/tests/ui/symbol-names/const-generics-str-demangling.rs b/tests/ui/symbol-names/const-generics-str-demangling.rs index 90a79fd5bf7d9..789034283d956 100644 --- a/tests/ui/symbol-names/const-generics-str-demangling.rs +++ b/tests/ui/symbol-names/const-generics-str-demangling.rs @@ -8,38 +8,38 @@ pub struct Str; #[rustc_dump_symbol_name] //~^ ERROR symbol-name -//~| ERROR demangling -//~| ERROR demangling-alt(>) +//~| NOTE demangling +//~| NOTE demangling-alt(>) impl Str<"abc"> {} #[rustc_dump_symbol_name] //~^ ERROR symbol-name -//~| ERROR demangling -//~| ERROR demangling-alt(>) +//~| NOTE demangling +//~| NOTE demangling-alt(>) impl Str<"'"> {} #[rustc_dump_symbol_name] //~^ ERROR symbol-name -//~| ERROR demangling -//~| ERROR demangling-alt(>) +//~| NOTE demangling +//~| NOTE demangling-alt(>) impl Str<"\t\n"> {} #[rustc_dump_symbol_name] //~^ ERROR symbol-name -//~| ERROR demangling -//~| ERROR demangling-alt(>) +//~| NOTE demangling +//~| NOTE demangling-alt(>) impl Str<"∂ü"> {} #[rustc_dump_symbol_name] //~^ ERROR symbol-name -//~| ERROR demangling -//~| ERROR demangling-alt(>) +//~| NOTE demangling +//~| NOTE demangling-alt(>) impl Str<"საჭმელად_გემრიელი_სადილი"> {} #[rustc_dump_symbol_name] //~^ ERROR symbol-name -//~| ERROR demangling -//~| ERROR demangling-alt(>) +//~| NOTE demangling +//~| NOTE demangling-alt(>) impl Str<"🐊🦈🦆🐮 § 🐶👒☕🔥 § 🧡💛💚💙💜"> {} fn main() {} diff --git a/tests/ui/symbol-names/const-generics-str-demangling.stderr b/tests/ui/symbol-names/const-generics-str-demangling.stderr index 09c3f7ca743fa..7221b89a7c7a8 100644 --- a/tests/ui/symbol-names/const-generics-str-demangling.stderr +++ b/tests/ui/symbol-names/const-generics-str-demangling.stderr @@ -1,110 +1,68 @@ error: symbol-name(_RMCsCRATE_HASH_1cINtB_3StrKRe616263_E) --> $DIR/const-generics-str-demangling.rs:9:1 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/const-generics-str-demangling.rs:9:1 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/const-generics-str-demangling.rs:9:1 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Str<"abc"> {} + | |_______________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs_CsCRATE_HASH_1cINtB_3StrKRe27_E) --> $DIR/const-generics-str-demangling.rs:15:1 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/const-generics-str-demangling.rs:15:1 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Str<"'"> {} + | |_____________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/const-generics-str-demangling.rs:15:1 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs0_CsCRATE_HASH_1cINtB_3StrKRe090a_E) --> $DIR/const-generics-str-demangling.rs:21:1 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/const-generics-str-demangling.rs:21:1 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/const-generics-str-demangling.rs:21:1 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Str<"\t\n"> {} + | |________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs1_CsCRATE_HASH_1cINtB_3StrKRee28882c3bc_E) --> $DIR/const-generics-str-demangling.rs:27:1 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/const-generics-str-demangling.rs:27:1 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/const-generics-str-demangling.rs:27:1 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Str<"∂ü"> {} + | |______________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs2_CsCRATE_HASH_1cINtB_3StrKRee183a1e18390e183ade1839be18394e1839ae18390e183935fe18392e18394e1839be183a0e18398e18394e1839ae183985fe183a1e18390e18393e18398e1839ae18398_E) --> $DIR/const-generics-str-demangling.rs:33:1 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/const-generics-str-demangling.rs:33:1 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Str<"საჭმელად_გემრიელი_სადილი"> {} + | |____________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/const-generics-str-demangling.rs:33:1 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs3_CsCRATE_HASH_1cINtB_3StrKRef09f908af09fa688f09fa686f09f90ae20c2a720f09f90b6f09f9192e29895f09f94a520c2a720f09fa7a1f09f929bf09f929af09f9299f09f929c_E) --> $DIR/const-generics-str-demangling.rs:39:1 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/const-generics-str-demangling.rs:39:1 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/const-generics-str-demangling.rs:39:1 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Str<"🐊🦈🦆🐮 § 🐶👒☕🔥 § 🧡💛💚💙💜"> {} + | |____________________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) -error: aborting due to 18 previous errors +error: aborting due to 6 previous errors diff --git a/tests/ui/symbol-names/const-generics-structural-demangling.rs b/tests/ui/symbol-names/const-generics-structural-demangling.rs index a9a11d0ea8a4f..467861c4b8348 100644 --- a/tests/ui/symbol-names/const-generics-structural-demangling.rs +++ b/tests/ui/symbol-names/const-generics-structural-demangling.rs @@ -12,8 +12,8 @@ pub struct RefByte; #[rustc_dump_symbol_name] //~^ ERROR symbol-name -//~| ERROR demangling -//~| ERROR demangling-alt(>) +//~| NOTE demangling +//~| NOTE demangling-alt(>) impl RefByte<{ &123 }> {} // FIXME(eddyb) this was supposed to be `RefMutZst` with `&mut []`, @@ -22,24 +22,24 @@ pub struct RefZst; #[rustc_dump_symbol_name] //~^ ERROR symbol-name -//~| ERROR demangling -//~| ERROR demangling-alt(>) +//~| NOTE demangling +//~| NOTE demangling-alt(>) impl RefZst<{ &[] }> {} pub struct Array3Bytes; #[rustc_dump_symbol_name] //~^ ERROR symbol-name -//~| ERROR demangling -//~| ERROR demangling-alt(>) +//~| NOTE demangling +//~| NOTE demangling-alt(>) impl Array3Bytes<{ [1, 2, 3] }> {} pub struct TupleByteBool; #[rustc_dump_symbol_name] //~^ ERROR symbol-name -//~| ERROR demangling -//~| ERROR demangling-alt(>) +//~| NOTE demangling +//~| NOTE demangling-alt(>) impl TupleByteBool<{ (1, false) }> {} #[derive(PartialEq, Eq, ConstParamTy)] @@ -54,16 +54,16 @@ pub struct OptionUsize>; // the `core` disambiguator hash away there, but not here. #[rustc_dump_symbol_name] //~^ ERROR symbol-name -//~| ERROR demangling -//~| ERROR demangling-alt(::None}>>) +//~| NOTE demangling +//~| NOTE demangling-alt(::None}>>) impl OptionUsize<{ MyOption::None }> {} // HACK(eddyb) the full mangling is only in `.stderr` because we can normalize // the `core` disambiguator hash away there, but not here. #[rustc_dump_symbol_name] //~^ ERROR symbol-name -//~| ERROR demangling -//~| ERROR demangling-alt(::Some(0)}>>) +//~| NOTE demangling +//~| NOTE demangling-alt(::Some(0)}>>) impl OptionUsize<{ MyOption::Some(0) }> {} #[derive(PartialEq, Eq, ConstParamTy)] @@ -76,8 +76,8 @@ pub struct Foo_; #[rustc_dump_symbol_name] //~^ ERROR symbol-name -//~| ERROR demangling -//~| ERROR demangling-alt(>) +//~| NOTE demangling +//~| NOTE demangling-alt(>) impl Foo_<{ Foo { s: "abc", ch: 'x', slice: &[1, 2, 3] } }> {} // NOTE(eddyb) this tests specifically the use of disambiguators in field names, @@ -92,10 +92,13 @@ macro duplicate_field_name_test($x:ident) { #[rustc_dump_symbol_name] //~^ ERROR symbol-name - //~| ERROR demangling - //~| ERROR demangling-alt(>) + //~| NOTE demangling + //~| NOTE demangling-alt(>) impl Bar_<{ Bar { $x: 123, x: 4096 } }> {} } duplicate_field_name_test!(x); +//~^ NOTE in this expansion +//~| NOTE in this expansion +//~| NOTE in this expansion fn main() {} diff --git a/tests/ui/symbol-names/const-generics-structural-demangling.stderr b/tests/ui/symbol-names/const-generics-structural-demangling.stderr index 19deb1af31418..f018629879bac 100644 --- a/tests/ui/symbol-names/const-generics-structural-demangling.stderr +++ b/tests/ui/symbol-names/const-generics-structural-demangling.stderr @@ -1,161 +1,95 @@ error: symbol-name(_RMCsCRATE_HASH_1cINtB_7RefByteKRh7b_E) --> $DIR/const-generics-structural-demangling.rs:13:1 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/const-generics-structural-demangling.rs:13:1 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/const-generics-structural-demangling.rs:13:1 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl RefByte<{ &123 }> {} + | |______________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs_CsCRATE_HASH_1cINtB_6RefZstKRAEE) --> $DIR/const-generics-structural-demangling.rs:23:1 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/const-generics-structural-demangling.rs:23:1 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/const-generics-structural-demangling.rs:23:1 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl RefZst<{ &[] }> {} + | |____________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs0_CsCRATE_HASH_1cINtB_11Array3BytesKAh1_h2_h3_EE) --> $DIR/const-generics-structural-demangling.rs:31:1 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/const-generics-structural-demangling.rs:31:1 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/const-generics-structural-demangling.rs:31:1 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Array3Bytes<{ [1, 2, 3] }> {} + | |_______________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs1_CsCRATE_HASH_1cINtB_13TupleByteBoolKTh1_b0_EE) --> $DIR/const-generics-structural-demangling.rs:39:1 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/const-generics-structural-demangling.rs:39:1 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/const-generics-structural-demangling.rs:39:1 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl TupleByteBool<{ (1, false) }> {} + | |__________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs2_CsCRATE_HASH_1cINtB_11OptionUsizeKVNtINtB_8MyOptionjE4NoneUE) --> $DIR/const-generics-structural-demangling.rs:55:1 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(::None}>>) - --> $DIR/const-generics-structural-demangling.rs:55:1 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl OptionUsize<{ MyOption::None }> {} + | |____________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(::None}>>) - --> $DIR/const-generics-structural-demangling.rs:55:1 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(::None}>>) + = note: demangling-alt(::None}>>) error: symbol-name(_RMs3_CsCRATE_HASH_1cINtB_11OptionUsizeKVNtINtB_8MyOptionjE4SomeTj0_EE) --> $DIR/const-generics-structural-demangling.rs:63:1 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(::Some(0usize)}>>) - --> $DIR/const-generics-structural-demangling.rs:63:1 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(::Some(0)}>>) - --> $DIR/const-generics-structural-demangling.rs:63:1 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl OptionUsize<{ MyOption::Some(0) }> {} + | |_______________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(::Some(0usize)}>>) + = note: demangling-alt(::Some(0)}>>) error: symbol-name(_RMs4_CsCRATE_HASH_1cINtB_4Foo_KVNtB_3FooS1sRe616263_2chc78_5sliceRAh1_h2_h3_EEE) --> $DIR/const-generics-structural-demangling.rs:77:1 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/const-generics-structural-demangling.rs:77:1 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/const-generics-structural-demangling.rs:77:1 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Foo_<{ Foo { s: "abc", ch: 'x', slice: &[1, 2, 3] } }> {} + | |___________________________________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMsd_CsCRATE_HASH_1cINtB_4Bar_KVNtB_3BarS1xh7b_s_1xt1000_EE) --> $DIR/const-generics-structural-demangling.rs:93:5 | -LL | macro duplicate_field_name_test($x:ident) { -... -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | macro duplicate_field_name_test($x:ident) { ... -LL | duplicate_field_name_test!(x); - | ----------------------------- in this macro invocation - -error: demangling(>) - --> $DIR/const-generics-structural-demangling.rs:93:5 - | -LL | macro duplicate_field_name_test($x:ident) { -... -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -... -LL | duplicate_field_name_test!(x); - | ----------------------------- in this macro invocation - -error: demangling-alt(>) - --> $DIR/const-generics-structural-demangling.rs:93:5 - | -LL | macro duplicate_field_name_test($x:ident) { -... -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -... -LL | duplicate_field_name_test!(x); - | ----------------------------- in this macro invocation - -error: aborting due to 24 previous errors +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Bar_<{ Bar { $x: 123, x: 4096 } }> {} + | |___________________________________________^ +LL | } +LL | duplicate_field_name_test!(x); + | ----------------------------- in this macro invocation + | + = note: demangling(>) + = note: demangling-alt(>) + +error: aborting due to 8 previous errors diff --git a/tests/ui/symbol-names/foreign-types.rs b/tests/ui/symbol-names/foreign-types.rs index b7851a06ed067..32337f0455cae 100644 --- a/tests/ui/symbol-names/foreign-types.rs +++ b/tests/ui/symbol-names/foreign-types.rs @@ -15,8 +15,8 @@ struct Check(T); #[rustc_dump_symbol_name] //~^ ERROR symbol-name(_RMCs -//~| ERROR demangling(>) +//~| NOTE demangling(>) impl Check {} fn main() {} diff --git a/tests/ui/symbol-names/foreign-types.stderr b/tests/ui/symbol-names/foreign-types.stderr index b0af84801795f..7c1c6b2c5f540 100644 --- a/tests/ui/symbol-names/foreign-types.stderr +++ b/tests/ui/symbol-names/foreign-types.stderr @@ -1,20 +1,13 @@ error: symbol-name(_RMCsCRATE_HASH_13foreign_typesINtB_5CheckNtB_11ForeignTypeE) --> $DIR/foreign-types.rs:16:1 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/foreign-types.rs:16:1 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/foreign-types.rs:16:1 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Check {} + | |_______________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) -error: aborting due to 3 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/symbol-names/impl1.legacy.stderr b/tests/ui/symbol-names/impl1.legacy.stderr index 87a2837e01920..72b6ecb73b52f 100644 --- a/tests/ui/symbol-names/impl1.legacy.stderr +++ b/tests/ui/symbol-names/impl1.legacy.stderr @@ -1,20 +1,13 @@ error: symbol-name(_ZN5impl13foo3Foo3bar17) --> $DIR/impl1.rs:14:9 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(impl1::foo::Foo::bar::) - --> $DIR/impl1.rs:14:9 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(impl1::foo::Foo::bar) - --> $DIR/impl1.rs:14:9 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn bar() { } + | |________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(impl1::foo::Foo::bar::) + = note: demangling-alt(impl1::foo::Foo::bar) error: def-path(foo::Foo::bar) --> $DIR/impl1.rs:21:9 @@ -25,20 +18,13 @@ LL | #[rustc_dump_def_path] error: symbol-name(_ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz17) --> $DIR/impl1.rs:32:9 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(impl1::bar::::baz::) - --> $DIR/impl1.rs:32:9 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn baz() { } + | |________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(impl1::bar::::baz) - --> $DIR/impl1.rs:32:9 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(impl1::bar::::baz::) + = note: demangling-alt(impl1::bar::::baz) error: def-path(bar::::baz) --> $DIR/impl1.rs:39:9 @@ -49,20 +35,13 @@ LL | #[rustc_dump_def_path] error: symbol-name(_ZN209_$LT$$u5b$$RF$dyn$u20$impl1..Foo$u2b$Assoc$u20$$u3d$$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RF$u8$C$$u20$...$RP$$u2b$impl1..AutoTrait$u3b$$u20$3$u5d$$u20$as$u20$impl1..main..$u7b$$u7b$closure$u7d$$u7d$..Bar$GT$6method17) --> $DIR/impl1.rs:62:13 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::{{closure}}::Bar>::method::) - --> $DIR/impl1.rs:62:13 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::{{closure}}::Bar>::method) - --> $DIR/impl1.rs:62:13 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn method(&self) {} + | |____________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::{{closure}}::Bar>::method::) + = note: demangling-alt(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::{{closure}}::Bar>::method) error: def-path(<[&dyn Foo extern "C" fn(&'a u8, ...)> + AutoTrait; 3] as main::{closure#1}::Bar>::method) --> $DIR/impl1.rs:69:13 @@ -70,5 +49,5 @@ error: def-path(<[&dyn Foo extern "C" fn(&'a u8, ...)> + AutoTra LL | #[rustc_dump_def_path] | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 12 previous errors +error: aborting due to 6 previous errors diff --git a/tests/ui/symbol-names/impl1.rs b/tests/ui/symbol-names/impl1.rs index 5902df54b486f..be2ce5f82a1e4 100644 --- a/tests/ui/symbol-names/impl1.rs +++ b/tests/ui/symbol-names/impl1.rs @@ -13,11 +13,11 @@ mod foo { impl Foo { #[rustc_dump_symbol_name] //[legacy]~^ ERROR symbol-name(_ZN5impl13foo3Foo3bar - //[legacy]~| ERROR demangling(impl1::foo::Foo::bar - //[legacy]~| ERROR demangling-alt(impl1::foo::Foo::bar) + //[legacy]~| NOTE demangling(impl1::foo::Foo::bar + //[legacy]~| NOTE demangling-alt(impl1::foo::Foo::bar) //[v0]~^^^^ ERROR symbol-name(_RNvMNtCs - //[v0]~| ERROR demangling(::bar) + //[v0]~| NOTE demangling(::bar) #[rustc_dump_def_path] //[legacy]~^ ERROR def-path(foo::Foo::bar) //[v0]~^^ ERROR def-path(foo::Foo::bar) @@ -31,11 +31,11 @@ mod bar { impl Foo { #[rustc_dump_symbol_name] //[legacy]~^ ERROR symbol-name(_ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz - //[legacy]~| ERROR demangling(impl1::bar::::baz - //[legacy]~| ERROR demangling-alt(impl1::bar::::baz) + //[legacy]~| NOTE demangling(impl1::bar::::baz + //[legacy]~| NOTE demangling-alt(impl1::bar::::baz) //[v0]~^^^^ ERROR symbol-name(_RNvMNtCs - //[v0]~| ERROR demangling(::baz) + //[v0]~| NOTE demangling(::baz) #[rustc_dump_def_path] //[legacy]~^ ERROR def-path(bar::::baz) //[v0]~^^ ERROR def-path(bar::::baz) @@ -61,11 +61,11 @@ fn main() { impl Bar for [&'_ (dyn Foo + AutoTrait); 3] { #[rustc_dump_symbol_name] //[legacy]~^ ERROR symbol-name(_ZN209_$LT$$u5b$$RF$dyn$u20$impl1..Foo$u2b$Assoc$u20$$u3d$$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RF$u8$C$$u20$...$RP$$u2b$impl1..AutoTrait$u3b$$u20$3$u5d$$u20$as$u20$impl1..main..$u7b$$u7b$closure$u7d$$u7d$..Bar$GT$6method - //[legacy]~| ERROR demangling(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::{{closure}}::Bar>::method - //[legacy]~| ERROR demangling-alt(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::{{closure}}::Bar>::method) + //[legacy]~| NOTE demangling(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::{{closure}}::Bar>::method + //[legacy]~| NOTE demangling-alt(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::{{closure}}::Bar>::method) //[v0]~^^^^ ERROR symbol-name(_RNvXNCNvCs - //[v0]~| ERROR demangling(<[&dyn - //[v0]~| ERROR demangling-alt(<[&dyn impl1::Foo extern "C" fn(&'a u8, ...)> + impl1::AutoTrait; 3] as impl1::main::{closure#1}::Bar>::method) + //[v0]~| NOTE demangling(<[&dyn + //[v0]~| NOTE demangling-alt(<[&dyn impl1::Foo extern "C" fn(&'a u8, ...)> + impl1::AutoTrait; 3] as impl1::main::{closure#1}::Bar>::method) #[rustc_dump_def_path] //[legacy]~^ ERROR def-path(<[&dyn Foo extern "C" fn(&'a u8, ...)> + AutoTrait; 3] as main::{closure#1}::Bar>::method) //[v0]~^^ ERROR def-path(<[&dyn Foo extern "C" fn(&'a u8, ...)> + AutoTrait; 3] as main::{closure#1}::Bar>::method) diff --git a/tests/ui/symbol-names/impl1.v0.stderr b/tests/ui/symbol-names/impl1.v0.stderr index 77319825b1770..95c01cdeef4fd 100644 --- a/tests/ui/symbol-names/impl1.v0.stderr +++ b/tests/ui/symbol-names/impl1.v0.stderr @@ -1,20 +1,13 @@ error: symbol-name(_RNvMNtCsCRATE_HASH_5impl13fooNtB_3Foo3bar) --> $DIR/impl1.rs:14:9 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(::bar) - --> $DIR/impl1.rs:14:9 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(::bar) - --> $DIR/impl1.rs:14:9 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn bar() { } + | |________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(::bar) + = note: demangling-alt(::bar) error: def-path(foo::Foo::bar) --> $DIR/impl1.rs:21:9 @@ -25,20 +18,13 @@ LL | #[rustc_dump_def_path] error: symbol-name(_RNvMNtCsCRATE_HASH_5impl13barNtNtB_3foo3Foo3baz) --> $DIR/impl1.rs:32:9 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(::baz) - --> $DIR/impl1.rs:32:9 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn baz() { } + | |________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(::baz) - --> $DIR/impl1.rs:32:9 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(::baz) + = note: demangling-alt(::baz) error: def-path(bar::::baz) --> $DIR/impl1.rs:39:9 @@ -49,20 +35,13 @@ LL | #[rustc_dump_def_path] error: symbol-name(_RNvXNCNvCsCRATE_HASH_5impl14mains_0ARDNtB_3Foop5AssocFG_KCRL0_hvEuNtB_9AutoTraitEL_j3_NtB_3Bar6method) --> $DIR/impl1.rs:62:13 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(<[&dyn impl1[d5591eb39db23cbb]::Foo extern "C" fn(&'a u8, ...)> + impl1[d5591eb39db23cbb]::AutoTrait; 3usize] as impl1[d5591eb39db23cbb]::main::{closure#1}::Bar>::method) - --> $DIR/impl1.rs:62:13 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(<[&dyn impl1::Foo extern "C" fn(&'a u8, ...)> + impl1::AutoTrait; 3] as impl1::main::{closure#1}::Bar>::method) - --> $DIR/impl1.rs:62:13 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn method(&self) {} + | |____________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(<[&dyn impl1[d5591eb39db23cbb]::Foo extern "C" fn(&'a u8, ...)> + impl1[d5591eb39db23cbb]::AutoTrait; 3usize] as impl1[d5591eb39db23cbb]::main::{closure#1}::Bar>::method) + = note: demangling-alt(<[&dyn impl1::Foo extern "C" fn(&'a u8, ...)> + impl1::AutoTrait; 3] as impl1::main::{closure#1}::Bar>::method) error: def-path(<[&dyn Foo extern "C" fn(&'a u8, ...)> + AutoTrait; 3] as main::{closure#1}::Bar>::method) --> $DIR/impl1.rs:69:13 @@ -70,5 +49,5 @@ error: def-path(<[&dyn Foo extern "C" fn(&'a u8, ...)> + AutoTra LL | #[rustc_dump_def_path] | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 12 previous errors +error: aborting due to 6 previous errors diff --git a/tests/ui/symbol-names/issue-60925.legacy.stderr b/tests/ui/symbol-names/issue-60925.legacy.stderr index 0411d70119235..787c681bcce68 100644 --- a/tests/ui/symbol-names/issue-60925.legacy.stderr +++ b/tests/ui/symbol-names/issue-60925.legacy.stderr @@ -1,20 +1,13 @@ error: symbol-name(_ZN11issue_609253foo37Foo$LT$issue_60925..llv$u6d$..Foo$GT$3foo17heb0a993da0d0e50cE) --> $DIR/issue-60925.rs:21:9 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(issue_60925::foo::Foo::foo::heb0a993da0d0e50c) - --> $DIR/issue-60925.rs:21:9 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(issue_60925::foo::Foo::foo) - --> $DIR/issue-60925.rs:21:9 +LL | / #[rustc_dump_symbol_name] +... | +LL | | pub(crate) fn foo() { + | |___________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(issue_60925::foo::Foo::foo::heb0a993da0d0e50c) + = note: demangling-alt(issue_60925::foo::Foo::foo) -error: aborting due to 3 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/symbol-names/issue-60925.rs b/tests/ui/symbol-names/issue-60925.rs index 76552d88880e5..28206b69d4fd4 100644 --- a/tests/ui/symbol-names/issue-60925.rs +++ b/tests/ui/symbol-names/issue-60925.rs @@ -20,11 +20,11 @@ mod foo { impl Foo { #[rustc_dump_symbol_name] //[legacy]~^ ERROR symbol-name(_ZN11issue_609253foo37Foo$LT$issue_60925..llv$u6d$..Foo$GT$3foo - //[legacy]~| ERROR demangling(issue_60925::foo::Foo::foo - //[legacy]~| ERROR demangling-alt(issue_60925::foo::Foo::foo) + //[legacy]~| NOTE demangling(issue_60925::foo::Foo::foo + //[legacy]~| NOTE demangling-alt(issue_60925::foo::Foo::foo) //[v0]~^^^^ ERROR symbol-name - //[v0]~| ERROR demangling - //[v0]~| ERROR demangling-alt(>::foo) + //[v0]~| NOTE demangling + //[v0]~| NOTE demangling-alt(>::foo) pub(crate) fn foo() { for _ in 0..0 { for _ in &[crate::dummy()] { diff --git a/tests/ui/symbol-names/issue-60925.v0.stderr b/tests/ui/symbol-names/issue-60925.v0.stderr index 587ee1090ade3..f82e4a422cda6 100644 --- a/tests/ui/symbol-names/issue-60925.v0.stderr +++ b/tests/ui/symbol-names/issue-60925.v0.stderr @@ -1,20 +1,13 @@ error: symbol-name(_RNvMNtCsCRATE_HASH_11issue_609253fooINtB_3FooNtNtB_4llvm3FooE3foo) --> $DIR/issue-60925.rs:21:9 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>::foo) - --> $DIR/issue-60925.rs:21:9 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>::foo) - --> $DIR/issue-60925.rs:21:9 +LL | / #[rustc_dump_symbol_name] +... | +LL | | pub(crate) fn foo() { + | |___________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>::foo) + = note: demangling-alt(>::foo) -error: aborting due to 3 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/symbol-names/issue-75326.legacy.stderr b/tests/ui/symbol-names/issue-75326.legacy.stderr index c4b248427c7e4..a312b7cf0b69b 100644 --- a/tests/ui/symbol-names/issue-75326.legacy.stderr +++ b/tests/ui/symbol-names/issue-75326.legacy.stderr @@ -1,20 +1,13 @@ error: symbol-name(_ZN72_$LT$issue_75326..Foo$LT$I$C$E$GT$$u20$as$u20$issue_75326..Iterator2$GT$4next17SYMBOL_HASH) --> $DIR/issue-75326.rs:41:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling( as issue_75326::Iterator2>::next::SYMBOL_HASH) - --> $DIR/issue-75326.rs:41:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt( as issue_75326::Iterator2>::next) - --> $DIR/issue-75326.rs:41:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn next(&mut self) -> Option { + | |____________________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling( as issue_75326::Iterator2>::next::SYMBOL_HASH) + = note: demangling-alt( as issue_75326::Iterator2>::next) -error: aborting due to 3 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/symbol-names/issue-75326.rs b/tests/ui/symbol-names/issue-75326.rs index 7810483f5f39f..4871bac2d68cf 100644 --- a/tests/ui/symbol-names/issue-75326.rs +++ b/tests/ui/symbol-names/issue-75326.rs @@ -40,11 +40,11 @@ where #[rustc_dump_symbol_name] //[legacy]~^ ERROR symbol-name(_ZN72_$LT$issue_75326..Foo$LT$I$C$E$GT$$u20$as$u20$issue_75326..Iterator2$GT$4next - //[legacy]~| ERROR demangling( as issue_75326::Iterator2>::next - //[legacy]~| ERROR demangling-alt( as issue_75326::Iterator2>::next) + //[legacy]~| NOTE demangling( as issue_75326::Iterator2>::next + //[legacy]~| NOTE demangling-alt( as issue_75326::Iterator2>::next) //[v0]~^^^^ ERROR symbol-name - //[v0]~| ERROR demangling - //[v0]~| ERROR demangling-alt( as issue_75326::Iterator2>::next) + //[v0]~| NOTE demangling + //[v0]~| NOTE demangling-alt( as issue_75326::Iterator2>::next) fn next(&mut self) -> Option { self.find(|_| true) } diff --git a/tests/ui/symbol-names/issue-75326.v0.stderr b/tests/ui/symbol-names/issue-75326.v0.stderr index d07a85730a2b2..af95044e8ea20 100644 --- a/tests/ui/symbol-names/issue-75326.v0.stderr +++ b/tests/ui/symbol-names/issue-75326.v0.stderr @@ -1,20 +1,13 @@ error: symbol-name(_RNvXINICsCRATE_HASH_11issue_75326s_0pppEINtB_3FooppENtB_9Iterator24nextB_) --> $DIR/issue-75326.rs:41:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling( as issue_75326[189ebc60e18860d7]::Iterator2>::next) - --> $DIR/issue-75326.rs:41:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt( as issue_75326::Iterator2>::next) - --> $DIR/issue-75326.rs:41:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn next(&mut self) -> Option { + | |____________________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling( as issue_75326[189ebc60e18860d7]::Iterator2>::next) + = note: demangling-alt( as issue_75326::Iterator2>::next) -error: aborting due to 3 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/symbol-names/trait-objects.rs b/tests/ui/symbol-names/trait-objects.rs index 9f9178c6b0743..7a6f340d11a6b 100644 --- a/tests/ui/symbol-names/trait-objects.rs +++ b/tests/ui/symbol-names/trait-objects.rs @@ -14,8 +14,8 @@ trait Bar { impl Bar for &dyn FnMut(&u8) { #[rustc_dump_symbol_name] //[v0]~^ ERROR symbol-name - //[v0]~| ERROR demangling - //[v0]~| ERROR demangling-alt + //[v0]~| NOTE demangling + //[v0]~| NOTE demangling-alt fn method(&self) {} } @@ -26,8 +26,8 @@ trait Foo { impl Foo for &(dyn FnMut(&u8) + for<'b> Send) { #[rustc_dump_symbol_name] //[v0]~^ ERROR symbol-name - //[v0]~| ERROR demangling - //[v0]~| ERROR demangling-alt + //[v0]~| NOTE demangling + //[v0]~| NOTE demangling-alt fn method(&self) {} } @@ -38,8 +38,8 @@ trait Baz { impl Baz for &(dyn for<'b> Send + FnMut(&u8)) { #[rustc_dump_symbol_name] //[v0]~^ ERROR symbol-name - //[v0]~| ERROR demangling - //[v0]~| ERROR demangling-alt + //[v0]~| NOTE demangling + //[v0]~| NOTE demangling-alt fn method(&self) {} } diff --git a/tests/ui/symbol-names/trait-objects.v0.stderr b/tests/ui/symbol-names/trait-objects.v0.stderr index b0cd9c9e7e3f2..e1c4ef9313902 100644 --- a/tests/ui/symbol-names/trait-objects.v0.stderr +++ b/tests/ui/symbol-names/trait-objects.v0.stderr @@ -1,56 +1,35 @@ error: symbol-name(_RNvXCsCRATE_HASH_13trait_objectsRDG_INtNtNtCsCRATE_HASH_4core3ops8function5FnMutTRL0_hEEp6OutputuEL_NtB_3Bar6method) --> $DIR/trait-objects.rs:15:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(<&dyn for<'a> core[HASH]::ops::function::FnMut<(&'a u8,), Output = ()> as trait_objects[3c073c57f94bedc2]::Bar>::method) - --> $DIR/trait-objects.rs:15:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(<&dyn for<'a> core::ops::function::FnMut<(&'a u8,), Output = ()> as trait_objects::Bar>::method) - --> $DIR/trait-objects.rs:15:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn method(&self) {} + | |____________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(<&dyn for<'a> core[HASH]::ops::function::FnMut<(&'a u8,), Output = ()> as trait_objects[3c073c57f94bedc2]::Bar>::method) + = note: demangling-alt(<&dyn for<'a> core::ops::function::FnMut<(&'a u8,), Output = ()> as trait_objects::Bar>::method) error: symbol-name(_RNvXs_CsCRATE_HASH_13trait_objectsRDG_INtNtNtCsCRATE_HASH_4core3ops8function5FnMutTRL0_hEEp6OutputuNtNtB_6marker4SendEL_NtB_3Foo6method) --> $DIR/trait-objects.rs:27:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(<&dyn for<'a> core[HASH]::ops::function::FnMut<(&'a u8,), Output = ()> + core[HASH]::marker::Send as trait_objects[3c073c57f94bedc2]::Foo>::method) - --> $DIR/trait-objects.rs:27:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn method(&self) {} + | |____________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(<&dyn for<'a> core::ops::function::FnMut<(&'a u8,), Output = ()> + core::marker::Send as trait_objects::Foo>::method) - --> $DIR/trait-objects.rs:27:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(<&dyn for<'a> core[HASH]::ops::function::FnMut<(&'a u8,), Output = ()> + core[HASH]::marker::Send as trait_objects[3c073c57f94bedc2]::Foo>::method) + = note: demangling-alt(<&dyn for<'a> core::ops::function::FnMut<(&'a u8,), Output = ()> + core::marker::Send as trait_objects::Foo>::method) error: symbol-name(_RNvXs0_CsCRATE_HASH_13trait_objectsRDG_INtNtNtCsCRATE_HASH_4core3ops8function5FnMutTRL0_hEEp6OutputuNtNtB_6marker4SendEL_NtB_3Baz6method) --> $DIR/trait-objects.rs:39:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(<&dyn for<'a> core[HASH]::ops::function::FnMut<(&'a u8,), Output = ()> + core[HASH]::marker::Send as trait_objects[3c073c57f94bedc2]::Baz>::method) - --> $DIR/trait-objects.rs:39:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(<&dyn for<'a> core::ops::function::FnMut<(&'a u8,), Output = ()> + core::marker::Send as trait_objects::Baz>::method) - --> $DIR/trait-objects.rs:39:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | fn method(&self) {} + | |____________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(<&dyn for<'a> core[HASH]::ops::function::FnMut<(&'a u8,), Output = ()> + core[HASH]::marker::Send as trait_objects[3c073c57f94bedc2]::Baz>::method) + = note: demangling-alt(<&dyn for<'a> core::ops::function::FnMut<(&'a u8,), Output = ()> + core::marker::Send as trait_objects::Baz>::method) -error: aborting due to 9 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/symbol-names/types.legacy.stderr b/tests/ui/symbol-names/types.legacy.stderr index a9922d9a957f9..7aab974703452 100644 --- a/tests/ui/symbol-names/types.legacy.stderr +++ b/tests/ui/symbol-names/types.legacy.stderr @@ -1,524 +1,321 @@ error: symbol-name(_ZN1a1b16Type$LT$bool$GT$17h[HASH]E) --> $DIR/types.rs:17:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:17:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:17:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |___________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b16Type$LT$char$GT$17h[HASH]E) --> $DIR/types.rs:26:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:26:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:26:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |___________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b14Type$LT$i8$GT$17h[HASH]E) --> $DIR/types.rs:35:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:35:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:35:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |_________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$i16$GT$17h[HASH]E) --> $DIR/types.rs:44:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:44:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:44:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$i32$GT$17h[HASH]E) --> $DIR/types.rs:53:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:53:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:53:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$i64$GT$17h[HASH]E) --> $DIR/types.rs:62:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:62:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:62:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b14Type$LT$u8$GT$17h[HASH]E) --> $DIR/types.rs:71:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:71:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |_________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:71:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$u16$GT$17h[HASH]E) --> $DIR/types.rs:80:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:80:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:80:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$u32$GT$17h[HASH]E) --> $DIR/types.rs:89:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:89:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:89:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$u64$GT$17h[HASH]E) --> $DIR/types.rs:98:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:98:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:98:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$f16$GT$17h[HASH]E) --> $DIR/types.rs:107:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:107:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:107:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$f32$GT$17h[HASH]E) --> $DIR/types.rs:116:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:116:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:116:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$f64$GT$17h[HASH]E) --> $DIR/types.rs:125:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:125:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:125:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b16Type$LT$f128$GT$17h[HASH]E) --> $DIR/types.rs:134:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:134:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |___________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:134:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$str$GT$17h[HASH]E) --> $DIR/types.rs:143:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:143:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:143:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b17Type$LT$$u21$$GT$17h[HASH]E) --> $DIR/types.rs:152:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:152:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:152:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b20Type$LT$$LP$$RP$$GT$17h[HASH]E) --> $DIR/types.rs:161:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<()>::h[HASH]) - --> $DIR/types.rs:161:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<()>) - --> $DIR/types.rs:161:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<()> {} + | |_________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<()>::h[HASH]) + = note: demangling-alt(a::b::Type<()>) error: symbol-name(_ZN1a1b25Type$LT$$LP$u8$C$$RP$$GT$17h[HASH]E) --> $DIR/types.rs:170:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<(u8,)>::h[HASH]) - --> $DIR/types.rs:170:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<(u8,)> {} + | |____________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<(u8,)>) - --> $DIR/types.rs:170:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<(u8,)>::h[HASH]) + = note: demangling-alt(a::b::Type<(u8,)>) error: symbol-name(_ZN1a1b28Type$LT$$LP$u8$C$u16$RP$$GT$17h[HASH]E) --> $DIR/types.rs:179:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<(u8,u16)>::h[HASH]) - --> $DIR/types.rs:179:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<(u8,u16)>) - --> $DIR/types.rs:179:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<(u8, u16)> {} + | |________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<(u8,u16)>::h[HASH]) + = note: demangling-alt(a::b::Type<(u8,u16)>) error: symbol-name(_ZN1a1b34Type$LT$$LP$u8$C$u16$C$u32$RP$$GT$17h[HASH]E) --> $DIR/types.rs:188:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<(u8,u16,u32)>::h[HASH]) - --> $DIR/types.rs:188:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<(u8,u16,u32)>) - --> $DIR/types.rs:188:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<(u8, u16, u32)> {} + | |_____________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<(u8,u16,u32)>::h[HASH]) + = note: demangling-alt(a::b::Type<(u8,u16,u32)>) error: symbol-name(_ZN1a1b28Type$LT$$BP$const$u20$u8$GT$17h[HASH]E) --> $DIR/types.rs:197:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<*const u8>::h[HASH]) - --> $DIR/types.rs:197:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<*const u8>) - --> $DIR/types.rs:197:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<*const u8> {} + | |________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<*const u8>::h[HASH]) + = note: demangling-alt(a::b::Type<*const u8>) error: symbol-name(_ZN1a1b26Type$LT$$BP$mut$u20$u8$GT$17h[HASH]E) --> $DIR/types.rs:206:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<*mut u8>::h[HASH]) - --> $DIR/types.rs:206:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<*mut u8>) - --> $DIR/types.rs:206:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<*mut u8> {} + | |______________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<*mut u8>::h[HASH]) + = note: demangling-alt(a::b::Type<*mut u8>) error: symbol-name(_ZN1a1b19Type$LT$$RF$str$GT$17h[HASH]E) --> $DIR/types.rs:215:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<&str>::h[HASH]) - --> $DIR/types.rs:215:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<&str> {} + | |___________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<&str>) - --> $DIR/types.rs:215:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<&str>::h[HASH]) + = note: demangling-alt(a::b::Type<&str>) error: symbol-name(_ZN1a1b27Type$LT$$RF$mut$u20$str$GT$17h[HASH]E) --> $DIR/types.rs:224:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<&mut str>::h[HASH]) - --> $DIR/types.rs:224:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<&mut str>) - --> $DIR/types.rs:224:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<&mut str> {} + | |_______________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<&mut str>::h[HASH]) + = note: demangling-alt(a::b::Type<&mut str>) error: symbol-name(_ZN1a1b35Type$LT$$u5b$u8$u3b$$u20$0$u5d$$GT$17h[HASH]E) --> $DIR/types.rs:233:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<[u8; 0]>::h[HASH]) - --> $DIR/types.rs:233:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<[u8; 0]> {} + | |______________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<[u8; 0]>) - --> $DIR/types.rs:233:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<[u8; 0]>::h[HASH]) + = note: demangling-alt(a::b::Type<[u8; 0]>) error: symbol-name(_ZN1a1b22Type$LT$fn$LP$$RP$$GT$17h[HASH]E) --> $DIR/types.rs:242:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:242:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:242:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |___________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b60Type$LT$unsafe$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RP$$GT$17h[HASH]E) --> $DIR/types.rs:251:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:251:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |_____________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:251:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b34Type$LT$$u5b$T$u3b$$u20$N$u5d$$GT$17h[HASH]E) --> $DIR/types.rs:260:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<[T; N]>::h[HASH]) - --> $DIR/types.rs:260:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<[T; N]>) - --> $DIR/types.rs:260:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<[T; N]> {} + | |________________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<[T; N]>::h[HASH]) + = note: demangling-alt(a::b::Type<[T; N]>) error: symbol-name(_ZN1a1b35Type$LT$$u5b$u8$u3b$$u20$0$u5d$$GT$17h[HASH]E) --> $DIR/types.rs:271:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<[u8; 0]>::h[HASH]) - --> $DIR/types.rs:271:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<[u8; 0]>) - --> $DIR/types.rs:271:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<[u8; ZERO]> {} + | |_________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<[u8; 0]>::h[HASH]) + = note: demangling-alt(a::b::Type<[u8; 0]>) -error: aborting due to 87 previous errors +error: aborting due to 29 previous errors diff --git a/tests/ui/symbol-names/types.rs b/tests/ui/symbol-names/types.rs index f1789cba6abe6..c74f44bd5394a 100644 --- a/tests/ui/symbol-names/types.rs +++ b/tests/ui/symbol-names/types.rs @@ -16,265 +16,265 @@ pub fn b() { #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b16Type$LT$bool$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type) //[v0]~^^^^ ERROR symbol-name(_RMNvCsCRATE_HASH_1a1bINtB_4TypebE) - //[v0]~| ERROR ::b::Type>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type>) + //[v0]~| NOTE demangling-alt(>) impl Type {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b16Type$LT$char$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type) //[v0]~^^^^ ERROR symbol-name(_RMs_NvCsCRATE_HASH_1a1bINtB_4TypecE) - //[v0]~| ERROR ::b::Type>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type>) + //[v0]~| NOTE demangling-alt(>) impl Type {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b14Type$LT$i8$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type) //[v0]~^^^^ ERROR symbol-name(_RMs0_NvCsCRATE_HASH_1a1bINtB_4TypeaE) - //[v0]~| ERROR ::b::Type>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type>) + //[v0]~| NOTE demangling-alt(>) impl Type {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b15Type$LT$i16$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type) //[v0]~^^^^ ERROR symbol-name(_RMs1_NvCsCRATE_HASH_1a1bINtB_4TypesE) - //[v0]~| ERROR ::b::Type>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type>) + //[v0]~| NOTE demangling-alt(>) impl Type {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b15Type$LT$i32$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type) //[v0]~^^^^ ERROR symbol-name(_RMs2_NvCsCRATE_HASH_1a1bINtB_4TypelE) - //[v0]~| ERROR ::b::Type>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type>) + //[v0]~| NOTE demangling-alt(>) impl Type {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b15Type$LT$i64$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type) //[v0]~^^^^ ERROR symbol-name(_RMs3_NvCsCRATE_HASH_1a1bINtB_4TypexE) - //[v0]~| ERROR ::b::Type>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type>) + //[v0]~| NOTE demangling-alt(>) impl Type {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b14Type$LT$u8$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type) //[v0]~^^^^ ERROR symbol-name(_RMs4_NvCsCRATE_HASH_1a1bINtB_4TypehE) - //[v0]~| ERROR ::b::Type>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type>) + //[v0]~| NOTE demangling-alt(>) impl Type {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b15Type$LT$u16$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type) //[v0]~^^^^ ERROR symbol-name(_RMs5_NvCsCRATE_HASH_1a1bINtB_4TypetE) - //[v0]~| ERROR ::b::Type>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type>) + //[v0]~| NOTE demangling-alt(>) impl Type {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b15Type$LT$u32$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type) //[v0]~^^^^ ERROR symbol-name(_RMs6_NvCsCRATE_HASH_1a1bINtB_4TypemE) - //[v0]~| ERROR ::b::Type>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type>) + //[v0]~| NOTE demangling-alt(>) impl Type {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b15Type$LT$u64$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type) //[v0]~^^^^ ERROR symbol-name(_RMs7_NvCsCRATE_HASH_1a1bINtB_4TypeyE) - //[v0]~| ERROR ::b::Type>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type>) + //[v0]~| NOTE demangling-alt(>) impl Type {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b15Type$LT$f16$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type) //[v0]~^^^^ ERROR symbol-name(_RMs8_NvCsCRATE_HASH_1a1bINtB_4TypeC3f16E) - //[v0]~| ERROR ::b::Type>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type>) + //[v0]~| NOTE demangling-alt(>) impl Type {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b15Type$LT$f32$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type) //[v0]~^^^^ ERROR symbol-name(_RMs9_NvCsCRATE_HASH_1a1bINtB_4TypefE) - //[v0]~| ERROR ::b::Type>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type>) + //[v0]~| NOTE demangling-alt(>) impl Type {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b15Type$LT$f64$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type) //[v0]~^^^^ ERROR symbol-name(_RMsa_NvCsCRATE_HASH_1a1bINtB_4TypedE) - //[v0]~| ERROR ::b::Type>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type>) + //[v0]~| NOTE demangling-alt(>) impl Type {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b16Type$LT$f128$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type) //[v0]~^^^^ ERROR symbol-name(_RMsb_NvCsCRATE_HASH_1a1bINtB_4TypeC4f128E) - //[v0]~| ERROR ::b::Type>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type>) + //[v0]~| NOTE demangling-alt(>) impl Type {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b15Type$LT$str$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type) //[v0]~^^^^ ERROR symbol-name(_RMsc_NvCsCRATE_HASH_1a1bINtB_4TypeeE) - //[v0]~| ERROR ::b::Type>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type>) + //[v0]~| NOTE demangling-alt(>) impl Type {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b17Type$LT$$u21$$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type) //[v0]~^^^^ ERROR symbol-name(_RMsd_NvCsCRATE_HASH_1a1bINtB_4TypezE) - //[v0]~| ERROR ::b::Type>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type>) + //[v0]~| NOTE demangling-alt(>) impl Type {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b20Type$LT$$LP$$RP$$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type<()>:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type<()>) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type<()>:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type<()>) //[v0]~^^^^ ERROR symbol-name(_RMse_NvCsCRATE_HASH_1a1bINtB_4TypeuE) - //[v0]~| ERROR ::b::Type<()>>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type<()>>) + //[v0]~| NOTE demangling-alt(>) impl Type<()> {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b25Type$LT$$LP$u8$C$$RP$$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type<(u8,)>:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type<(u8,)>) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type<(u8,)>:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type<(u8,)>) //[v0]~^^^^ ERROR symbol-name(_RMsf_NvCsCRATE_HASH_1a1bINtB_4TypeThEE) - //[v0]~| ERROR ::b::Type<(u8,)>>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type<(u8,)>>) + //[v0]~| NOTE demangling-alt(>) impl Type<(u8,)> {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b28Type$LT$$LP$u8$C$u16$RP$$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type<(u8,u16)>:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type<(u8,u16)>) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type<(u8,u16)>:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type<(u8,u16)>) //[v0]~^^^^ ERROR symbol-name(_RMsg_NvCsCRATE_HASH_1a1bINtB_4TypeThtEE) - //[v0]~| ERROR ::b::Type<(u8, u16)>>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type<(u8, u16)>>) + //[v0]~| NOTE demangling-alt(>) impl Type<(u8, u16)> {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b34Type$LT$$LP$u8$C$u16$C$u32$RP$$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type<(u8,u16,u32)>:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type<(u8,u16,u32)>) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type<(u8,u16,u32)>:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type<(u8,u16,u32)>) //[v0]~^^^^ ERROR symbol-name(_RMsh_NvCsCRATE_HASH_1a1bINtB_4TypeThtmEE) - //[v0]~| ERROR ::b::Type<(u8, u16, u32)>>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type<(u8, u16, u32)>>) + //[v0]~| NOTE demangling-alt(>) impl Type<(u8, u16, u32)> {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b28Type$LT$$BP$const$u20$u8$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type<*const u8>:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type<*const u8>) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type<*const u8>:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type<*const u8>) //[v0]~^^^^ ERROR symbol-name(_RMsi_NvCsCRATE_HASH_1a1bINtB_4TypePhE) - //[v0]~| ERROR ::b::Type<*const u8>>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type<*const u8>>) + //[v0]~| NOTE demangling-alt(>) impl Type<*const u8> {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b26Type$LT$$BP$mut$u20$u8$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type<*mut u8>:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type<*mut u8>) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type<*mut u8>:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type<*mut u8>) //[v0]~^^^^ ERROR symbol-name(_RMsj_NvCsCRATE_HASH_1a1bINtB_4TypeOhE) - //[v0]~| ERROR ::b::Type<*mut u8>>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type<*mut u8>>) + //[v0]~| NOTE demangling-alt(>) impl Type<*mut u8> {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b19Type$LT$$RF$str$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type<&str>:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type<&str>) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type<&str>:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type<&str>) //[v0]~^^^^ ERROR symbol-name(_RMsk_NvCsCRATE_HASH_1a1bINtB_4TypeReE) - //[v0]~| ERROR ::b::Type<&str>>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type<&str>>) + //[v0]~| NOTE demangling-alt(>) impl Type<&str> {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b27Type$LT$$RF$mut$u20$str$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type<&mut str>:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type<&mut str>) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type<&mut str>:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type<&mut str>) //[v0]~^^^^ ERROR symbol-name(_RMsl_NvCsCRATE_HASH_1a1bINtB_4TypeQeE) - //[v0]~| ERROR ::b::Type<&mut str>>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type<&mut str>>) + //[v0]~| NOTE demangling-alt(>) impl Type<&mut str> {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b35Type$LT$$u5b$u8$u3b$$u20$0$u5d$$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type<[u8; 0]>:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type<[u8; 0]>) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type<[u8; 0]>:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type<[u8; 0]>) //[v0]~^^^^ ERROR symbol-name(_RMsm_NvCsCRATE_HASH_1a1bINtB_4TypeAhj0_E) - //[v0]~| ERROR ::b::Type<[u8; 0usize]>>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type<[u8; 0usize]>>) + //[v0]~| NOTE demangling-alt(>) impl Type<[u8; 0]> {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b22Type$LT$fn$LP$$RP$$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type) //[v0]~^^^^ ERROR symbol-name(_RMsn_NvCsCRATE_HASH_1a1bINtB_4TypeFEuE) - //[v0]~| ERROR ::b::Type>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type>) + //[v0]~| NOTE demangling-alt(>) impl Type {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b60Type$LT$unsafe$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RP$$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type) //[v0]~^^^^ ERROR symbol-name(_RMso_NvCsCRATE_HASH_1a1bINtB_4TypeFUKCEuE) - //[v0]~| ERROR ::b::Type>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type>) + //[v0]~| NOTE demangling-alt(>) impl Type {} #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b34Type$LT$$u5b$T$u3b$$u20$N$u5d$$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type<[T; N]>:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type<[T; N]>) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type<[T; N]>:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type<[T; N]>) //[v0]~^^^^ ERROR symbol-name(_RMsp_NvCsCRATE_HASH_1a1bINtB_4TypeAppEB_) - //[v0]~| ERROR ::b::Type<[_; _]>>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type<[_; _]>>) + //[v0]~| NOTE demangling-alt(>) impl Type<[T; N]> {} const ZERO: usize = 0; #[rustc_dump_symbol_name] //[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b35Type$LT$$u5b$u8$u3b$$u20$0$u5d$$GT$ - //[legacy,verbose-legacy]~| ERROR demangling(a::b::Type<[u8; 0]>:: - //[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type<[u8; 0]>) + //[legacy,verbose-legacy]~| NOTE demangling(a::b::Type<[u8; 0]>:: + //[legacy,verbose-legacy]~| NOTE demangling-alt(a::b::Type<[u8; 0]>) //[v0]~^^^^ ERROR symbol-name(_RMsq_NvCsCRATE_HASH_1a1bINtB_4TypeAhj0_E) - //[v0]~| ERROR ::b::Type<[u8; 0usize]>>) - //[v0]~| ERROR demangling-alt(>) + //[v0]~| NOTE ::b::Type<[u8; 0usize]>>) + //[v0]~| NOTE demangling-alt(>) impl Type<[u8; ZERO]> {} } diff --git a/tests/ui/symbol-names/types.v0.stderr b/tests/ui/symbol-names/types.v0.stderr index 4ac96ca19a53a..841f88ffb0e35 100644 --- a/tests/ui/symbol-names/types.v0.stderr +++ b/tests/ui/symbol-names/types.v0.stderr @@ -1,524 +1,321 @@ error: symbol-name(_RMNvCsCRATE_HASH_1a1bINtB_4TypebE) --> $DIR/types.rs:17:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:17:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:17:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |___________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs_NvCsCRATE_HASH_1a1bINtB_4TypecE) --> $DIR/types.rs:26:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:26:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:26:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |___________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs0_NvCsCRATE_HASH_1a1bINtB_4TypeaE) --> $DIR/types.rs:35:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:35:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:35:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |_________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs1_NvCsCRATE_HASH_1a1bINtB_4TypesE) --> $DIR/types.rs:44:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:44:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:44:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs2_NvCsCRATE_HASH_1a1bINtB_4TypelE) --> $DIR/types.rs:53:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:53:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:53:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs3_NvCsCRATE_HASH_1a1bINtB_4TypexE) --> $DIR/types.rs:62:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:62:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:62:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs4_NvCsCRATE_HASH_1a1bINtB_4TypehE) --> $DIR/types.rs:71:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:71:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |_________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:71:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs5_NvCsCRATE_HASH_1a1bINtB_4TypetE) --> $DIR/types.rs:80:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:80:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:80:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs6_NvCsCRATE_HASH_1a1bINtB_4TypemE) --> $DIR/types.rs:89:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:89:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:89:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs7_NvCsCRATE_HASH_1a1bINtB_4TypeyE) --> $DIR/types.rs:98:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:98:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:98:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs8_NvCsCRATE_HASH_1a1bINtB_4TypeC3f16E) --> $DIR/types.rs:107:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:107:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:107:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMs9_NvCsCRATE_HASH_1a1bINtB_4TypefE) --> $DIR/types.rs:116:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:116:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:116:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMsa_NvCsCRATE_HASH_1a1bINtB_4TypedE) --> $DIR/types.rs:125:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:125:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:125:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMsb_NvCsCRATE_HASH_1a1bINtB_4TypeC4f128E) --> $DIR/types.rs:134:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:134:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |___________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:134:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMsc_NvCsCRATE_HASH_1a1bINtB_4TypeeE) --> $DIR/types.rs:143:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:143:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:143:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMsd_NvCsCRATE_HASH_1a1bINtB_4TypezE) --> $DIR/types.rs:152:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:152:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:152:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMse_NvCsCRATE_HASH_1a1bINtB_4TypeuE) --> $DIR/types.rs:161:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:161:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:161:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<()> {} + | |_________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMsf_NvCsCRATE_HASH_1a1bINtB_4TypeThEE) --> $DIR/types.rs:170:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:170:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<(u8,)> {} + | |____________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:170:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMsg_NvCsCRATE_HASH_1a1bINtB_4TypeThtEE) --> $DIR/types.rs:179:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:179:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:179:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<(u8, u16)> {} + | |________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMsh_NvCsCRATE_HASH_1a1bINtB_4TypeThtmEE) --> $DIR/types.rs:188:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:188:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:188:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<(u8, u16, u32)> {} + | |_____________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMsi_NvCsCRATE_HASH_1a1bINtB_4TypePhE) --> $DIR/types.rs:197:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:197:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:197:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<*const u8> {} + | |________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMsj_NvCsCRATE_HASH_1a1bINtB_4TypeOhE) --> $DIR/types.rs:206:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:206:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:206:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<*mut u8> {} + | |______________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMsk_NvCsCRATE_HASH_1a1bINtB_4TypeReE) --> $DIR/types.rs:215:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:215:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<&str> {} + | |___________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:215:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMsl_NvCsCRATE_HASH_1a1bINtB_4TypeQeE) --> $DIR/types.rs:224:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:224:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:224:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<&mut str> {} + | |_______________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMsm_NvCsCRATE_HASH_1a1bINtB_4TypeAhj0_E) --> $DIR/types.rs:233:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:233:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<[u8; 0]> {} + | |______________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:233:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMsn_NvCsCRATE_HASH_1a1bINtB_4TypeFEuE) --> $DIR/types.rs:242:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:242:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:242:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |___________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMso_NvCsCRATE_HASH_1a1bINtB_4TypeFUKCEuE) --> $DIR/types.rs:251:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:251:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |_____________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:251:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMsp_NvCsCRATE_HASH_1a1bINtB_4TypeAppEB_) --> $DIR/types.rs:260:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:260:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:260:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<[T; N]> {} + | |________________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) error: symbol-name(_RMsq_NvCsCRATE_HASH_1a1bINtB_4TypeAhj0_E) --> $DIR/types.rs:271:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(>) - --> $DIR/types.rs:271:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(>) - --> $DIR/types.rs:271:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<[u8; ZERO]> {} + | |_________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(>) + = note: demangling-alt(>) -error: aborting due to 87 previous errors +error: aborting due to 29 previous errors diff --git a/tests/ui/symbol-names/types.verbose-legacy.stderr b/tests/ui/symbol-names/types.verbose-legacy.stderr index a9922d9a957f9..7aab974703452 100644 --- a/tests/ui/symbol-names/types.verbose-legacy.stderr +++ b/tests/ui/symbol-names/types.verbose-legacy.stderr @@ -1,524 +1,321 @@ error: symbol-name(_ZN1a1b16Type$LT$bool$GT$17h[HASH]E) --> $DIR/types.rs:17:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:17:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:17:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |___________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b16Type$LT$char$GT$17h[HASH]E) --> $DIR/types.rs:26:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:26:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:26:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |___________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b14Type$LT$i8$GT$17h[HASH]E) --> $DIR/types.rs:35:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:35:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:35:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |_________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$i16$GT$17h[HASH]E) --> $DIR/types.rs:44:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:44:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:44:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$i32$GT$17h[HASH]E) --> $DIR/types.rs:53:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:53:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:53:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$i64$GT$17h[HASH]E) --> $DIR/types.rs:62:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:62:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:62:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b14Type$LT$u8$GT$17h[HASH]E) --> $DIR/types.rs:71:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:71:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |_________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:71:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$u16$GT$17h[HASH]E) --> $DIR/types.rs:80:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:80:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:80:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$u32$GT$17h[HASH]E) --> $DIR/types.rs:89:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:89:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:89:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$u64$GT$17h[HASH]E) --> $DIR/types.rs:98:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:98:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:98:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$f16$GT$17h[HASH]E) --> $DIR/types.rs:107:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:107:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:107:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$f32$GT$17h[HASH]E) --> $DIR/types.rs:116:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:116:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:116:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$f64$GT$17h[HASH]E) --> $DIR/types.rs:125:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:125:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:125:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b16Type$LT$f128$GT$17h[HASH]E) --> $DIR/types.rs:134:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:134:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |___________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:134:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b15Type$LT$str$GT$17h[HASH]E) --> $DIR/types.rs:143:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:143:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |__________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:143:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b17Type$LT$$u21$$GT$17h[HASH]E) --> $DIR/types.rs:152:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:152:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:152:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b20Type$LT$$LP$$RP$$GT$17h[HASH]E) --> $DIR/types.rs:161:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<()>::h[HASH]) - --> $DIR/types.rs:161:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<()>) - --> $DIR/types.rs:161:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<()> {} + | |_________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<()>::h[HASH]) + = note: demangling-alt(a::b::Type<()>) error: symbol-name(_ZN1a1b25Type$LT$$LP$u8$C$$RP$$GT$17h[HASH]E) --> $DIR/types.rs:170:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<(u8,)>::h[HASH]) - --> $DIR/types.rs:170:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<(u8,)> {} + | |____________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<(u8,)>) - --> $DIR/types.rs:170:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<(u8,)>::h[HASH]) + = note: demangling-alt(a::b::Type<(u8,)>) error: symbol-name(_ZN1a1b28Type$LT$$LP$u8$C$u16$RP$$GT$17h[HASH]E) --> $DIR/types.rs:179:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<(u8,u16)>::h[HASH]) - --> $DIR/types.rs:179:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<(u8,u16)>) - --> $DIR/types.rs:179:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<(u8, u16)> {} + | |________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<(u8,u16)>::h[HASH]) + = note: demangling-alt(a::b::Type<(u8,u16)>) error: symbol-name(_ZN1a1b34Type$LT$$LP$u8$C$u16$C$u32$RP$$GT$17h[HASH]E) --> $DIR/types.rs:188:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<(u8,u16,u32)>::h[HASH]) - --> $DIR/types.rs:188:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<(u8,u16,u32)>) - --> $DIR/types.rs:188:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<(u8, u16, u32)> {} + | |_____________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<(u8,u16,u32)>::h[HASH]) + = note: demangling-alt(a::b::Type<(u8,u16,u32)>) error: symbol-name(_ZN1a1b28Type$LT$$BP$const$u20$u8$GT$17h[HASH]E) --> $DIR/types.rs:197:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<*const u8>::h[HASH]) - --> $DIR/types.rs:197:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<*const u8>) - --> $DIR/types.rs:197:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<*const u8> {} + | |________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<*const u8>::h[HASH]) + = note: demangling-alt(a::b::Type<*const u8>) error: symbol-name(_ZN1a1b26Type$LT$$BP$mut$u20$u8$GT$17h[HASH]E) --> $DIR/types.rs:206:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<*mut u8>::h[HASH]) - --> $DIR/types.rs:206:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<*mut u8>) - --> $DIR/types.rs:206:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<*mut u8> {} + | |______________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<*mut u8>::h[HASH]) + = note: demangling-alt(a::b::Type<*mut u8>) error: symbol-name(_ZN1a1b19Type$LT$$RF$str$GT$17h[HASH]E) --> $DIR/types.rs:215:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<&str>::h[HASH]) - --> $DIR/types.rs:215:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<&str> {} + | |___________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<&str>) - --> $DIR/types.rs:215:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<&str>::h[HASH]) + = note: demangling-alt(a::b::Type<&str>) error: symbol-name(_ZN1a1b27Type$LT$$RF$mut$u20$str$GT$17h[HASH]E) --> $DIR/types.rs:224:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<&mut str>::h[HASH]) - --> $DIR/types.rs:224:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<&mut str>) - --> $DIR/types.rs:224:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<&mut str> {} + | |_______________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<&mut str>::h[HASH]) + = note: demangling-alt(a::b::Type<&mut str>) error: symbol-name(_ZN1a1b35Type$LT$$u5b$u8$u3b$$u20$0$u5d$$GT$17h[HASH]E) --> $DIR/types.rs:233:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<[u8; 0]>::h[HASH]) - --> $DIR/types.rs:233:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<[u8; 0]> {} + | |______________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<[u8; 0]>) - --> $DIR/types.rs:233:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<[u8; 0]>::h[HASH]) + = note: demangling-alt(a::b::Type<[u8; 0]>) error: symbol-name(_ZN1a1b22Type$LT$fn$LP$$RP$$GT$17h[HASH]E) --> $DIR/types.rs:242:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:242:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:242:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |___________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b60Type$LT$unsafe$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RP$$GT$17h[HASH]E) --> $DIR/types.rs:251:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type::h[HASH]) - --> $DIR/types.rs:251:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type {} + | |_____________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type) - --> $DIR/types.rs:251:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type::h[HASH]) + = note: demangling-alt(a::b::Type) error: symbol-name(_ZN1a1b34Type$LT$$u5b$T$u3b$$u20$N$u5d$$GT$17h[HASH]E) --> $DIR/types.rs:260:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<[T; N]>::h[HASH]) - --> $DIR/types.rs:260:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<[T; N]>) - --> $DIR/types.rs:260:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<[T; N]> {} + | |________________________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<[T; N]>::h[HASH]) + = note: demangling-alt(a::b::Type<[T; N]>) error: symbol-name(_ZN1a1b35Type$LT$$u5b$u8$u3b$$u20$0$u5d$$GT$17h[HASH]E) --> $DIR/types.rs:271:5 | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling(a::b::Type<[u8; 0]>::h[HASH]) - --> $DIR/types.rs:271:5 - | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: demangling-alt(a::b::Type<[u8; 0]>) - --> $DIR/types.rs:271:5 +LL | / #[rustc_dump_symbol_name] +... | +LL | | impl Type<[u8; ZERO]> {} + | |_________________________^ | -LL | #[rustc_dump_symbol_name] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: demangling(a::b::Type<[u8; 0]>::h[HASH]) + = note: demangling-alt(a::b::Type<[u8; 0]>) -error: aborting due to 87 previous errors +error: aborting due to 29 previous errors diff --git a/tests/ui/traits/next-solver/ambiguous-impl-in-resolve.next.stderr b/tests/ui/traits/next-solver/ambiguous-impl-in-resolve.next.stderr new file mode 100644 index 0000000000000..20bbcdd8af423 --- /dev/null +++ b/tests/ui/traits/next-solver/ambiguous-impl-in-resolve.next.stderr @@ -0,0 +1,17 @@ +error[E0283]: type annotations needed: cannot satisfy `Option: Overlap` + --> $DIR/ambiguous-impl-in-resolve.rs:17:6 + | +LL | as Overlap>::f(); + | ^^^^^^^^^ + | +note: multiple `impl`s satisfying `Option: Overlap` found + --> $DIR/ambiguous-impl-in-resolve.rs:10:1 + | +LL | impl Overlap for Option where Self: Clone, { fn f() {} } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | impl Overlap for Option where Self: Local, { fn f() {} } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/traits/next-solver/ambiguous-impl-in-resolve.old.stderr b/tests/ui/traits/next-solver/ambiguous-impl-in-resolve.old.stderr new file mode 100644 index 0000000000000..20bbcdd8af423 --- /dev/null +++ b/tests/ui/traits/next-solver/ambiguous-impl-in-resolve.old.stderr @@ -0,0 +1,17 @@ +error[E0283]: type annotations needed: cannot satisfy `Option: Overlap` + --> $DIR/ambiguous-impl-in-resolve.rs:17:6 + | +LL | as Overlap>::f(); + | ^^^^^^^^^ + | +note: multiple `impl`s satisfying `Option: Overlap` found + --> $DIR/ambiguous-impl-in-resolve.rs:10:1 + | +LL | impl Overlap for Option where Self: Clone, { fn f() {} } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | impl Overlap for Option where Self: Local, { fn f() {} } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/traits/next-solver/ambiguous-impl-in-resolve.rs b/tests/ui/traits/next-solver/ambiguous-impl-in-resolve.rs index 78dffcbf6abc3..fd90d11575b07 100644 --- a/tests/ui/traits/next-solver/ambiguous-impl-in-resolve.rs +++ b/tests/ui/traits/next-solver/ambiguous-impl-in-resolve.rs @@ -1,5 +1,8 @@ -//@ check-pass -//@ compile-flags: -Znext-solver +//@ revisions: old next +//@[next] compile-flags: -Znext-solver + +// Impossible where-clauses can cause multiple overlapping impls to apply +// with the same constraints. trait Local {} @@ -12,6 +15,7 @@ where Option: Clone + Local, { as Overlap>::f(); + //~^ ERROR type annotations needed } fn main() {} diff --git a/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.rs b/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.rs index 326d888a55f3d..1956f4a65f7e6 100644 --- a/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.rs +++ b/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.rs @@ -19,6 +19,7 @@ impl<'a, 'b, T> Trait<'a, 'b> for A where B: Trait<'a, 'b> {} // not have a cycle with `A`. This candidate never applies because of // the `A: NotImplemented` bound. impl<'a, 'b, T> Trait<'a, 'b> for B +//~^ ERROR: type annotations needed: cannot satisfy `B: Trait<'a, 'b>` [E0283] where A: Trait<'a, 'b>, A: NotImplemented, @@ -33,6 +34,7 @@ where // regions in the `A: Trait<'a, 'b>` where-bound. As both the impl above // and the impl below now apply with some constraints, we failed with ambiguity. impl<'a, 'b, T> Trait<'a, 'b> for B +//~^ ERROR: type annotations needed: cannot satisfy `B: Trait<'a, 'b>` [E0283] where A: NotImplemented, {} diff --git a/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.stderr b/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.stderr index c88081736f3c3..6088fb52e808f 100644 --- a/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.stderr +++ b/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.stderr @@ -1,10 +1,65 @@ +error[E0283]: type annotations needed: cannot satisfy `B: Trait<'a, 'b>` + --> $DIR/fixpoint-rerun-all-cycle-heads.rs:21:35 + | +LL | impl<'a, 'b, T> Trait<'a, 'b> for B + | ^^^^ + | +note: multiple `impl`s satisfying `B: Trait<'a, 'b>` found + --> $DIR/fixpoint-rerun-all-cycle-heads.rs:21:1 + | +LL | / impl<'a, 'b, T> Trait<'a, 'b> for B +LL | | +LL | | where +LL | | A: Trait<'a, 'b>, +LL | | A: NotImplemented, + | |_________________________^ +... +LL | / impl<'a, 'b, T> Trait<'a, 'b> for B +LL | | +LL | | where +LL | | A: NotImplemented, + | |_________________________^ +... +LL | / impl<'a, T> Trait<'a, 'static> for B +LL | | where +LL | | C: Trait<'a, 'a>, + | |________________________^ + +error[E0283]: type annotations needed: cannot satisfy `B: Trait<'a, 'b>` + --> $DIR/fixpoint-rerun-all-cycle-heads.rs:36:35 + | +LL | impl<'a, 'b, T> Trait<'a, 'b> for B + | ^^^^ + | +note: multiple `impl`s satisfying `B: Trait<'a, 'b>` found + --> $DIR/fixpoint-rerun-all-cycle-heads.rs:21:1 + | +LL | / impl<'a, 'b, T> Trait<'a, 'b> for B +LL | | +LL | | where +LL | | A: Trait<'a, 'b>, +LL | | A: NotImplemented, + | |_________________________^ +... +LL | / impl<'a, 'b, T> Trait<'a, 'b> for B +LL | | +LL | | where +LL | | A: NotImplemented, + | |_________________________^ +... +LL | / impl<'a, T> Trait<'a, 'static> for B +LL | | where +LL | | C: Trait<'a, 'a>, + | |________________________^ + error: lifetime may not live long enough - --> $DIR/fixpoint-rerun-all-cycle-heads.rs:60:5 + --> $DIR/fixpoint-rerun-all-cycle-heads.rs:62:5 | LL | fn check<'a, T>() { | -- lifetime `'a` defined here LL | impls_trait::<'a, 'static, A>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` -error: aborting due to 1 previous error +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/traits/next-solver/overflow/cycle-required-depth.rs b/tests/ui/traits/next-solver/overflow/cycle-required-depth.rs new file mode 100644 index 0000000000000..105460eee8013 --- /dev/null +++ b/tests/ui/traits/next-solver/overflow/cycle-required-depth.rs @@ -0,0 +1,27 @@ +//@ compile-flags: -Znext-solver +//@ check-pass + +// We must properly decrement available_depth when encountering cycles. +// Proving `Foo: Send` results in a cycle: +// - Foo: Send +// ->PhantomData: Send +// ->Foo: Send +// and if we cache this result with too small of a required depth, the second +// `require` call will succeed with the cached result where it would fail if +// the goal were freshly evaluated. + +#![recursion_limit = "6"] + +use std::marker::PhantomData; + +pub struct Foo(PhantomData); +pub struct W(T); + +fn require() {} + +fn main() { + require::(); + require::>>>>>(); + //~^ WARN overflow evaluating the requirement `W>>>>: Send` + //~| WARN this was previously accepted by the compiler but is being phased out +} diff --git a/tests/ui/traits/next-solver/overflow/cycle-required-depth.stderr b/tests/ui/traits/next-solver/overflow/cycle-required-depth.stderr new file mode 100644 index 0000000000000..15e121053c22d --- /dev/null +++ b/tests/ui/traits/next-solver/overflow/cycle-required-depth.stderr @@ -0,0 +1,21 @@ +warning: overflow evaluating the requirement `W>>>>: Send` + --> $DIR/cycle-required-depth.rs:24:5 + | +LL | require::>>>>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: which requires `W>>>: Send` + = note: which requires `W>>: Send` + = note: which requires `W>: Send` + = note: which requires `W: Send` + = note: which requires `Foo: Send` + = note: and so on... + = help: consider adding a manual `impl` of auto traits like `Send` for intermediate types, if auto traits are involved + = help: or consider increasing the recursion limit by adding a `#![recursion_limit = "12"]` attribute to your crate (`cycle_required_depth`) + = note: this lint is attached to the whole crate and can't be disabled on a per-function basis + = 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 #159228 + = note: `#[warn(recursion_depth_exceeding_limit)]` (part of `#[warn(future_incompatible)]`) on by default + +warning: 1 warning emitted + diff --git a/tests/ui/traits/next-solver/overflow/provisional-cache-required-depth.rs b/tests/ui/traits/next-solver/overflow/provisional-cache-required-depth.rs new file mode 100644 index 0000000000000..ad070e2d276a3 --- /dev/null +++ b/tests/ui/traits/next-solver/overflow/provisional-cache-required-depth.rs @@ -0,0 +1,27 @@ +//@ compile-flags: -Znext-solver +//@ check-pass + +#![recursion_limit = "6"] +use std::marker::PhantomData; + +// We need to decrement available_depth on provisional cache hits. +// e.g., in the following example: +// A: Send, avail = 6 +// -> PhantomData: Send, avail = 5 +// -> A: Send, avail = 4 +// -> B: Send, avail = 5 +// -> C: Send, avail = 4 +// -> PhantomData: Send, provisional cache hit, avail = 4 if we don't decrement +struct A(PhantomData, B); +struct B(C); +struct C(PhantomData); +struct W(T); + +fn require() {} + +fn main() { + require::(); + require::>>>>(); + //~^ WARN overflow evaluating the requirement `W>>>: Send` + //~| WARN this was previously accepted by the compiler but is being phased out +} diff --git a/tests/ui/traits/next-solver/overflow/provisional-cache-required-depth.stderr b/tests/ui/traits/next-solver/overflow/provisional-cache-required-depth.stderr new file mode 100644 index 0000000000000..a4ee2a2d87078 --- /dev/null +++ b/tests/ui/traits/next-solver/overflow/provisional-cache-required-depth.stderr @@ -0,0 +1,21 @@ +warning: overflow evaluating the requirement `W>>>: Send` + --> $DIR/provisional-cache-required-depth.rs:24:5 + | +LL | require::>>>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: which requires `W>>: Send` + = note: which requires `W>: Send` + = note: which requires `W: Send` + = note: which requires `A: Send` + = note: which requires `B: Send` + = note: and so on... + = help: consider adding a manual `impl` of auto traits like `Send` for intermediate types, if auto traits are involved + = help: or consider increasing the recursion limit by adding a `#![recursion_limit = "12"]` attribute to your crate (`provisional_cache_required_depth`) + = note: this lint is attached to the whole crate and can't be disabled on a per-function basis + = 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 #159228 + = note: `#[warn(recursion_depth_exceeding_limit)]` (part of `#[warn(future_incompatible)]`) on by default + +warning: 1 warning emitted + diff --git a/tests/ui/traits/trait-predicate-with-escaping-bounds.rs b/tests/ui/traits/trait-predicate-with-escaping-bounds.rs new file mode 100644 index 0000000000000..0aac6bae5fe99 --- /dev/null +++ b/tests/ui/traits/trait-predicate-with-escaping-bounds.rs @@ -0,0 +1,16 @@ +//! Regression test for . +//@ check-fail + +struct StatSeries {} + +impl StatSeries { + fn new(headers: [H; N]) -> () //~ ERROR: cannot find value `N` in this scope [E0425] + where + String: for<'a> From<&'a H>, + { + } +} + +fn main() { + let series = StatSeries::new([""]); //~ ERROR: the trait bound `for<'a> String: From<&'a &str>` is not satisfied [E0277] +} diff --git a/tests/ui/traits/trait-predicate-with-escaping-bounds.stderr b/tests/ui/traits/trait-predicate-with-escaping-bounds.stderr new file mode 100644 index 0000000000000..dd1b793eedb10 --- /dev/null +++ b/tests/ui/traits/trait-predicate-with-escaping-bounds.stderr @@ -0,0 +1,34 @@ +error[E0425]: cannot find value `N` in this scope + --> $DIR/trait-predicate-with-escaping-bounds.rs:7:28 + | +LL | fn new(headers: [H; N]) -> () + | ^ not found in this scope + +error[E0277]: the trait bound `for<'a> String: From<&'a &str>` is not satisfied + --> $DIR/trait-predicate-with-escaping-bounds.rs:15:34 + | +LL | let series = StatSeries::new([""]); + | --------------- ^^^^ the trait `for<'a> From<&'a &str>` is not implemented for `String` + | | + | required by a bound introduced by this call + | + = help: `String` implements trait `From`: + From<&String> + From<&mut str> + From<&str> + From> + From> + From +note: required by a bound in `StatSeries::new` + --> $DIR/trait-predicate-with-escaping-bounds.rs:9:17 + | +LL | impl StatSeries { +LL | fn new(headers: [H; N]) -> () +LL | where +LL | String: for<'a> From<&'a H>, + | ^^^^^^^^^^^^^^^^^^^ required by this bound in `StatSeries::new` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0277, E0425. +For more information about an error, try `rustc --explain E0277`.