rust-lang/rust · #162925
even more cleanups for `rustc_builtin_macros`
compiler/rustc_builtin_macros/src/deriving/generic/mod.rs72 + / 135 −
@@ -571,7 +571,7 @@ impl<'a> TraitDef<'a> { methods: impl Iterator<Item = Box<ast::AssocItem>>, is_packed: bool, ) -> Box<ast::Item> {- let trait_path = self.path.to_path(cx, self.span, type_ident, generics);+ let trait_path = self.path.to_path(cx, self.span); // Transform associated types from `deriving::ty::Ty` into `ast::AssocItem` let associated_types = self.associated_types.iter().map(|&(ident, ref type_def)| {@@ -589,7 +589,7 @@ impl<'a> TraitDef<'a> { generics: Generics::default(), after_where_clause: ast::WhereClause::default(), bounds: ThinVec::new(),- ty: Some(type_def.to_ty(cx, self.span, type_ident, generics)),+ ty: Some(type_def.to_ty(cx, self.span)), })), tokens: None, })@@ -613,9 +613,7 @@ impl<'a> TraitDef<'a> { let bounds: ThinVec<_> = self .additional_bounds .iter()- .map(|p| {- cx.trait_bound(p.to_path(cx, span, type_ident, generics), self.is_const)- })+ .map(|p| cx.trait_bound(p.to_path(cx, span), self.is_const)) .chain( // Add a bound for the current trait. self.skip_path_as_bound.not().then(|| {@@ -628,10 +626,7 @@ impl<'a> TraitDef<'a> { // Add a `Copy` bound if required. if is_packed && self.needs_copy_as_bound_if_packed { let p = deriving::path_std!(marker::Copy);- Some(cx.trait_bound(- p.to_path(cx, span, type_ident, generics),- self.is_const,- ))+ Some(cx.trait_bound(p.to_path(cx, span), self.is_const)) } else { None }@@ -697,12 +692,7 @@ impl<'a> TraitDef<'a> { let mut bounds: ThinVec<_> = self .additional_bounds .iter()- .map(|p| {- cx.trait_bound(- p.to_path(cx, self.span, type_ident, generics),- self.is_const,- )- })+ .map(|p| cx.trait_bound(p.to_path(cx, self.span), self.is_const)) .collect(); // Require the current trait.@@ -713,10 +703,7 @@ impl<'a> TraitDef<'a> { // Add a `Copy` bound if required. if is_packed && self.needs_copy_as_bound_if_packed { let p = deriving::path_std!(marker::Copy);- bounds.push(cx.trait_bound(- p.to_path(cx, self.span, type_ident, generics),- self.is_const,- ));+ bounds.push(cx.trait_bound(p.to_path(cx, self.span), self.is_const)); } if !bounds.is_empty() {@@ -774,6 +761,7 @@ 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() {+ // #[rustc_const_unstable(feature = "derive_const", issue = "118304")] attrs.push( cx.attr_nested( rustc_ast::AttrItem {@@ -837,9 +825,9 @@ impl<'a> TraitDef<'a> { ) -> Box<ast::Item> { let field_tys = struct_def.fields().iter().map(|field| &*field.ty); - let methods = self.methods.iter().map(|method_def| {- let ArgDetails { explicit_self, selflike_args, nonselflike_args, nonself_arg_tys } =- method_def.extract_arg_details(cx, self, type_ident, generics);+ let methods = self.methods.iter().filter_map(|method_def| {+ let ArgDetails { selflike_args, nonselflike_args } =+ method_def.extract_arg_details(cx, self); let body = if from_scratch || method_def.is_static() { method_def.call_substructure_method(@@ -861,15 +849,7 @@ impl<'a> TraitDef<'a> { ) }; - method_def.create_method(- cx,- self,- type_ident,- generics,- explicit_self,- nonself_arg_tys,- body,- )+ method_def.create_method(cx, self, body) }); self.create_derived_impl(cx, type_ident, generics, field_tys, methods, is_packed)@@ -890,8 +870,8 @@ impl<'a> TraitDef<'a> { .map(|field| &*field.ty); let methods = self.methods.iter().filter_map(|method_def| {- let ArgDetails { explicit_self, selflike_args, nonselflike_args, nonself_arg_tys } =- method_def.extract_arg_details(cx, self, type_ident, generics);+ let ArgDetails { selflike_args, nonselflike_args } =+ method_def.extract_arg_details(cx, self); let body = if from_scratch || method_def.is_static() { method_def.call_substructure_method(@@ -912,21 +892,7 @@ impl<'a> TraitDef<'a> { ) }; - // `assert_fields_are_eq` has an empty default implementation- if body.0.is_empty() && body.1.is_none() && method_def.name == sym::assert_fields_are_eq- {- return None;- }-- Some(method_def.create_method(- cx,- self,- type_ident,- generics,- explicit_self,- nonself_arg_tys,- body,- ))+ method_def.create_method(cx, self, body) }); let is_packed = false; // enums are never packed@@ -935,15 +901,11 @@ impl<'a> TraitDef<'a> { } struct ArgDetails {- /// The `&self` arg, if present.- explicit_self: Option<ast::ExplicitSelf>, /// Expressions for `&self` (if present) and also any other /// args with the same type (e.g. the `other` arg in `PartialEq::eq`). selflike_args: ThinVec<Box<Expr>>, /// Expressions for all the remaining args. nonselflike_args: Vec<Box<Expr>>,- /// Additional information about all the args other than `&self`.- nonself_arg_tys: Vec<(Ident, Box<ast::Ty>)>, } impl<'a> MethodDef<'a> {@@ -965,70 +927,66 @@ impl<'a> MethodDef<'a> { !self.explicit_self } - fn extract_arg_details(- &self,- cx: &ExtCtxt<'_>,- trait_: &TraitDef<'_>,- type_ident: Ident,- generics: &Generics,- ) -> ArgDetails {+ fn extract_arg_details(&self, cx: &ExtCtxt<'_>, trait_: &TraitDef<'_>) -> ArgDetails { let mut selflike_args = ThinVec::new(); let mut nonselflike_args = Vec::new();- let mut nonself_arg_tys = Vec::new(); let span = trait_.span; - let explicit_self = self.explicit_self.then(|| {+ if self.explicit_self { // This constructs a fresh `self` path. selflike_args.push(cx.expr_self(span));- respan(span, SelfKind::Region(None, ast::Mutability::Not))- });+ } for (ty, name) in self.nonself_args.iter() {- let ast_ty = ty.to_ty(cx, span, type_ident, generics); let ident = Ident::new(*name, span);- nonself_arg_tys.push((ident, ast_ty));- let arg_expr = cx.expr_ident(span, ident); match ty { // Selflike (`&Self`) arguments only occur in non-static methods.- Ref(Self_, _) if !self.is_static() => selflike_args.push(arg_expr),+ Ref(Self_, _) if self.explicit_self => selflike_args.push(arg_expr), Self_ => cx.dcx().span_bug(span, "`Self` in non-return position"), _ => nonselflike_args.push(arg_expr), } } - ArgDetails { explicit_self, selflike_args, nonselflike_args, nonself_arg_tys }+ ArgDetails { selflike_args, nonselflike_args } } fn create_method( &self, cx: &ExtCtxt<'_>, trait_: &TraitDef<'_>,- type_ident: Ident,- generics: &Generics,- explicit_self: Option<ast::ExplicitSelf>,- nonself_arg_tys: Vec<(Ident, Box<ast::Ty>)>, body: BlockOrExpr,- ) -> Box<ast::AssocItem> {+ ) -> Option<Box<ast::AssocItem>> {+ // `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(); - let args = {- let self_arg = explicit_self.map(|explicit_self| {- let ident = Ident::new(kw::SelfLower, span);- ast::Param::from_self(ast::AttrVec::default(), explicit_self, ident)- });- let nonself_args =- nonself_arg_tys.into_iter().map(|(name, ty)| cx.param(span, name, ty));- self_arg.into_iter().chain(nonself_args).collect()- };+ let self_arg = self.explicit_self.then(|| {+ let ident = Ident::new(kw::SelfLower, span);+ ast::Param::from_self(+ ast::AttrVec::default(),+ respan(span, SelfKind::Region(None, ast::Mutability::Not)),+ ident,+ )+ });+ let args = self_arg+ .into_iter()+ .chain(self.nonself_args.iter().map(|(ty, name)| {+ let ast_ty = ty.to_ty(cx, span);+ let ident = Ident::new(*name, span);+ cx.param(span, ident, ast_ty)+ }))+ .collect(); let ret_type = if let Ty::Unit = &self.ret_ty { ast::FnRetTy::Default(span) } else {- ast::FnRetTy::Ty(self.ret_ty.to_ty(cx, span, type_ident, generics))+ ast::FnRetTy::Ty(self.ret_ty.to_ty(cx, span)) }; let method_ident = Ident::new(self.name, span);@@ -1041,7 +999,7 @@ impl<'a> MethodDef<'a> { let defaultness = ast::Defaultness::Implicit; // Create the method.- Box::new(ast::AssocItem {+ Some(Box::new(ast::AssocItem { id: ast::DUMMY_NODE_ID, attrs: self.attributes.clone(), span,@@ -1057,7 +1015,7 @@ impl<'a> MethodDef<'a> { eii_impl: None, })), tokens: None,- })+ })) } /// The normal case uses field access.@@ -1197,24 +1155,21 @@ impl<'a> MethodDef<'a> { // let __self_discr = ::core::intrinsics::discriminant_value(self); // let __arg1_discr = ::core::intrinsics::discriminant_value(other); // ```- let get_discr_pieces = |cx: &ExtCtxt<'_>| {- let discr_idents: Vec<_> = prefixes+ let get_discr_pieces = || {+ let discr_idents = prefixes .iter()- .map(|name| Ident::from_str_and_span(&format!("{name}_discr"), span))- .collect();+ .map(|name| Ident::from_str_and_span(&format!("{name}_discr"), span)); - let mut discr_exprs: Vec<_> = discr_idents- .iter()- .map(|&ident| cx.expr_addr_of(span, cx.expr_ident(span, ident)))- .collect();+ let mut discr_exprs =+ discr_idents.clone().map(|ident| cx.expr_addr_of(span, cx.expr_ident(span, ident))); - let self_expr = discr_exprs.remove(0);- let other_selflike_exprs = discr_exprs;+ let self_expr = discr_exprs.next().unwrap();+ let other_selflike_exprs = discr_exprs.collect(); let discr_field = FieldInfo { span, name: None, self_expr, other_selflike_exprs, maybe_scalar: true }; - let discr_let_stmts: ThinVec<_> = iter::zip(&discr_idents, &selflike_args)- .map(|(&ident, selflike_arg)| {+ let discr_let_stmts: ThinVec<_> = iter::zip(discr_idents, &selflike_args)+ .map(|(ident, selflike_arg)| { let variant_value = deriving::call_intrinsic( cx, span,@@ -1238,7 +1193,7 @@ 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(cx);+ let (discr_field, mut discr_let_stmts) = get_discr_pieces(); let mut discr_check = self.call_substructure_method( cx, trait_,@@ -1373,7 +1328,7 @@ 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(cx);+ 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(@@ -1523,62 +1478,44 @@ impl<'a> TraitDef<'a> { } } -/// The function passed to `cs_fold` is called repeatedly with a value of this-/// type. It describes one part of the code generation. The result is always an-/// expression.-pub(crate) enum CsFold {- /// 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(FieldInfo),-- /// The combination of two field expressions. E.g. for `PartialEq::eq` this- /// is something like `<field1 equality> && <field2 equality>`.- Combine(Span, Box<Expr>, Box<Expr>),-- // The fallback case for a struct or enum variant with no fields.- Fieldless,-}- /// Folds over fields, combining the expressions for each field in a sequence. /// Statics may not be folded over.-pub(crate) fn cs_fold<F>(- use_foldl: bool,+pub(crate) fn cs_foldr( cx: &ExtCtxt<'_>, trait_span: Span, substructure: Substructure<'_>,- mut f: F,-) -> Box<Expr>-where- F: FnMut(&ExtCtxt<'_>, CsFold) -> Box<Expr>,-{+ // 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<Expr>,+ // The combination of two field expressions. E.g. for `PartialEq::eq` this+ // is something like `<field1 equality> && <field2 equality>`.+ combine: impl Fn(Span, Box<Expr>, Box<Expr>) -> Box<Expr>,+ // The fallback case for a struct or enum variant with no fields.+ fieldless: impl Fn() -> Box<Expr>,+) -> Box<Expr> { match substructure.fields { EnumMatching(.., all_fields) | Struct(_, all_fields) => { let mut fields = all_fields.into_iter();-- let base_field = if use_foldl { fields.next() } else { fields.next_back() };+ let base_field = fields.next_back(); let Some(base_field) = base_field else {- return f(cx, CsFold::Fieldless);+ return fieldless(); }; - let base_expr = f(cx, CsFold::Single(base_field));+ let base_expr = single(base_field); let op = |old, field: FieldInfo| { let span = field.span;- let new = f(cx, CsFold::Single(field));- f(cx, CsFold::Combine(span, old, new))+ let new = single(field);+ combine(span, old, new) }; - if use_foldl { fields.fold(base_expr, op) } else { fields.rfold(base_expr, op) }+ fields.rfold(base_expr, op) } EnumDiscr(discr_field, match_expr) => {- let discr_check_expr = f(cx, CsFold::Single(discr_field));+ let discr_check_expr = single(discr_field); if let Some(match_expr) = match_expr {- if use_foldl {- f(cx, CsFold::Combine(trait_span, discr_check_expr, match_expr))- } else {- f(cx, CsFold::Combine(trait_span, match_expr, discr_check_expr))- }+ combine(trait_span, match_expr, discr_check_expr) } else { discr_check_expr }compiler/rustc_builtin_macros/src/deriving/generic/ty.rs18 + / 50 −
@@ -1,8 +1,10 @@ //! 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, GenericParamKind, Generics, TyKind};+use rustc_ast::{self as ast, GenericArg, TyKind}; use rustc_expand::base::ExtCtxt; use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw}; use thin_vec::ThinVec;@@ -33,21 +35,17 @@ impl Path { Path { path, params, kind } } - pub(crate) fn to_path(- &self,- cx: &ExtCtxt<'_>,- span: Span,- self_ty: Ident,- self_generics: &Generics,- ) -> ast::Path {- let mut idents = self.path.iter().map(|s| Ident::new(*s, span)).collect::<Vec<_>>();- let tys = self.params.iter().map(|t| t.to_ty(cx, span, self_ty, self_generics));+ pub(crate) fn to_path(&self, cx: &ExtCtxt<'_>, span: Span) -> ast::Path {+ let idents = self.path.iter().map(|s| Ident::new(*s, span));+ let tys = self.params.iter().map(|t| t.to_ty(cx, span)); let params = tys.map(GenericArg::Type).collect(); - if let PathKind::Std = self.kind {+ let idents = if let PathKind::Std = self.kind { let def_site = cx.with_def_site_ctxt(DUMMY_SP);- idents.insert(0, Ident::new(kw::DollarCrate, def_site));- }+ once(Ident::new(kw::DollarCrate, def_site)).chain(idents).collect()+ } else {+ idents.collect()+ }; cx.path_all(span, false, idents, params) } }@@ -72,20 +70,14 @@ pub(crate) fn self_ref() -> Ty { } impl Ty {- pub(crate) fn to_ty(- &self,- cx: &ExtCtxt<'_>,- span: Span,- self_ty: Ident,- self_generics: &Generics,- ) -> Box<ast::Ty> {+ pub(crate) fn to_ty(&self, cx: &ExtCtxt<'_>, span: Span) -> Box<ast::Ty> { match self { Ref(ty, mutbl) => {- let raw_ty = ty.to_ty(cx, span, self_ty, self_generics);+ let raw_ty = ty.to_ty(cx, span); cx.ty_ref(span, raw_ty, None, *mutbl) }- Path(p) => cx.ty_path(p.to_path(cx, span, self_ty, self_generics)),- Self_ => cx.ty_path(self.to_path(cx, span, self_ty, self_generics)),+ Path(p) => cx.ty_path(p.to_path(cx, span)),+ Self_ => cx.ty_path(self.to_path(cx, span)), Unit => { let ty = ast::TyKind::Tup(ThinVec::new()); cx.ty(span, ty)@@ -94,34 +86,10 @@ impl Ty { } } - pub(crate) fn to_path(- &self,- cx: &ExtCtxt<'_>,- span: Span,- self_ty: Ident,- generics: &Generics,- ) -> ast::Path {+ pub(crate) fn to_path(&self, cx: &ExtCtxt<'_>, span: Span) -> ast::Path { match self {- Self_ => {- let params: Vec<_> = generics- .params- .iter()- .map(|param| match param.kind {- GenericParamKind::Lifetime => {- GenericArg::Lifetime(ast::Lifetime { id: param.id, ident: param.ident })- }- GenericParamKind::Type { .. } => {- GenericArg::Type(cx.ty_ident(span, param.ident))- }- GenericParamKind::Const { .. } => {- GenericArg::Const(cx.const_ident(span, param.ident))- }- })- .collect();-- cx.path_all(span, false, vec![self_ty], params)- }- Path(p) => p.to_path(cx, span, self_ty, generics),+ Self_ => cx.path_ident(span, Ident::new(kw::SelfUpper, span)),+ Path(p) => p.to_path(cx, span), AstTy(ty) => match &ty.kind { TyKind::Path(_, path) => path.clone(), _ => cx.dcx().span_bug(span, "non-path in a path in generic `derive`"),compiler/rustc_builtin_macros/src/deriving/ord.rs13 + / 19 −
@@ -52,29 +52,23 @@ pub(crate) fn cs_cmp(cx: &ExtCtxt<'_>, span: Span, substr: Substructure<'_>) -> // ::core::cmp::Ord::cmp(&self.y, &other.y), // cmp => cmp, // }- let expr = cs_fold(- // foldr nests the if-elses correctly, leaving the first field- // as the outermost one, and the last as the innermost.- false,+ let expr = cs_foldr( cx, span, substr,- |cx, fold| match fold {- CsFold::Single(field) => {- let [other_expr] = &field.other_selflike_exprs[..] else {- cx.dcx().span_bug(field.span, "not exactly 2 arguments in `derive(Ord)`");- };- let args = thin_vec![field.self_expr.clone(), other_expr.clone()];- cx.expr_call_global(field.span, cmp_path.clone(), args)- }- CsFold::Combine(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])- }- CsFold::Fieldless => cx.expr_path(equal_path.clone()),+ |field| {+ let [other_expr] = &field.other_selflike_exprs[..] else {+ cx.dcx().span_bug(field.span, "not exactly 2 arguments in `derive(Ord)`");+ };+ let args = thin_vec![field.self_expr.clone(), other_expr.clone()];+ 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()), ); BlockOrExpr::new_expr(expr) }compiler/rustc_builtin_macros/src/deriving/partial_ord.rs52 + / 61 −
@@ -124,73 +124,64 @@ fn cs_partial_cmp( // ::core::cmp::PartialOrd::partial_cmp(&self.y, &other.y), // cmp => cmp, // }- let expr = cs_fold(- // foldr nests the if-elses correctly, leaving the first field- // as the outermost one, and the last as the innermost.- false,+ let expr = cs_foldr( cx, span, substr,- |cx, fold| match fold {- CsFold::Single(field) => {- let [other_expr] = &field.other_selflike_exprs[..] else {- cx.dcx()- .span_bug(field.span, "not exactly 2 arguments in `derive(PartialOrd)`");- };- let args = thin_vec![field.self_expr.clone(), other_expr.clone()];- cx.expr_call_global(field.span, partial_cmp_path.clone(), args)- }- CsFold::Combine(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+ |field| {+ let [other_expr] = &field.other_selflike_exprs[..] else {+ cx.dcx().span_bug(field.span, "not exactly 2 arguments in `derive(PartialOrd)`");+ };+ let args = thin_vec![field.self_expr.clone(), other_expr.clone()];+ 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 - 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- } 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])- }+ 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+ } 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]) }- CsFold::Fieldless => cx.expr_some(span, cx.expr_path(equal_path.clone())), },+ || cx.expr_some(span, cx.expr_path(equal_path.clone())), ); BlockOrExpr::new_expr(expr) }tests/ui/const-generics/mgca/const-ctor-overflow-eval.rs1 + / 2 −
@@ -7,13 +7,12 @@ struct U; #[derive(ConstParamTy, PartialEq, Eq)] //~^ ERROR overflow evaluating whether `S<U>` is well-formed-//~| ERROR overflow evaluating whether `S<U>` is well-formed- struct S<const N: U>() where S<{ U }>:; //~^ ERROR overflow evaluating whether `S<U>` is well-formed //~| ERROR overflow evaluating whether `S<U>` is well-formed //~| ERROR overflow evaluating whether `S<U>` is well-formed+//~| ERROR overflow evaluating whether `S<U>` is well-formed fn main() {}tests/ui/const-generics/mgca/const-ctor-overflow-eval.stderr12 + / 11 −
@@ -1,11 +1,11 @@ error[E0275]: overflow evaluating whether `S<U>` is well-formed- --> $DIR/const-ctor-overflow-eval.rs:14:5+ --> $DIR/const-ctor-overflow-eval.rs:12:5 | LL | S<{ U }>:; | ^^^^^^^^ | note: required by a bound in `S`- --> $DIR/const-ctor-overflow-eval.rs:14:5+ --> $DIR/const-ctor-overflow-eval.rs:12:5 | LL | struct S<const N: U>() | - required by a bound in this struct@@ -14,13 +14,13 @@ LL | S<{ U }>:; | ^^^^^^^^ required by this bound in `S` error[E0275]: overflow evaluating whether `S<U>` is well-formed- --> $DIR/const-ctor-overflow-eval.rs:14:5+ --> $DIR/const-ctor-overflow-eval.rs:12:5 | LL | S<{ U }>:; | ^^^^^^^^ | note: required by a bound in `S`- --> $DIR/const-ctor-overflow-eval.rs:14:5+ --> $DIR/const-ctor-overflow-eval.rs:12:5 | LL | struct S<const N: U>() | - required by a bound in this struct@@ -30,13 +30,13 @@ LL | S<{ U }>:; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0275]: overflow evaluating whether `S<U>` is well-formed- --> $DIR/const-ctor-overflow-eval.rs:14:5+ --> $DIR/const-ctor-overflow-eval.rs:12:5 | LL | S<{ U }>:; | ^^^^^^^^ | note: required by a bound in `S`- --> $DIR/const-ctor-overflow-eval.rs:14:5+ --> $DIR/const-ctor-overflow-eval.rs:12:5 | LL | struct S<const N: U>() | - required by a bound in this struct@@ -52,7 +52,7 @@ LL | #[derive(ConstParamTy, PartialEq, Eq)] | ^^^^^^^^^ | note: required by a bound in `S`- --> $DIR/const-ctor-overflow-eval.rs:14:5+ --> $DIR/const-ctor-overflow-eval.rs:12:5 | LL | struct S<const N: U>() | - required by a bound in this struct@@ -61,19 +61,20 @@ LL | S<{ U }>:; | ^^^^^^^^ required by this bound in `S` error[E0275]: overflow evaluating whether `S<U>` is well-formed- --> $DIR/const-ctor-overflow-eval.rs:8:35+ --> $DIR/const-ctor-overflow-eval.rs:12:5 |-LL | #[derive(ConstParamTy, PartialEq, Eq)]- | ^^+LL | S<{ U }>:;+ | ^^^^^^^^ | note: required by a bound in `S`- --> $DIR/const-ctor-overflow-eval.rs:14:5+ --> $DIR/const-ctor-overflow-eval.rs:12:5 | LL | struct S<const N: U>() | - required by a bound in this struct LL | where LL | S<{ U }>:; | ^^^^^^^^ required by this bound in `S`+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 5 previous errors tests/ui/derives/deriving-all-codegen.stdout102 + / 109 −
@@ -32,7 +32,7 @@ unsafe impl ::core::clone::TrivialClone for Empty { } #[automatically_derived] impl ::core::clone::Clone for Empty { #[inline]- fn clone(&self) -> Empty { *self }+ fn clone(&self) -> Self { *self } } #[automatically_derived] impl ::core::marker::Copy for Empty { }@@ -46,7 +46,7 @@ impl ::core::fmt::Debug for Empty { #[automatically_derived] impl ::core::default::Default for Empty { #[inline]- fn default() -> Empty { Empty }+ fn default() -> Self { Empty } } #[automatically_derived] impl ::core::hash::Hash for Empty {@@ -58,27 +58,22 @@ impl ::core::marker::StructuralPartialEq for Empty { } #[automatically_derived] impl ::core::cmp::PartialEq for Empty { #[inline]- fn eq(&self, other: &Empty) -> bool { true }+ fn eq(&self, other: &Self) -> bool { true } } #[automatically_derived]-impl ::core::cmp::Eq for Empty {- #[inline]- #[doc(hidden)]- #[coverage(off)]- fn assert_fields_are_eq(&self) {}-}+impl ::core::cmp::Eq for Empty { } #[automatically_derived] impl ::core::cmp::PartialOrd for Empty { #[inline]- fn partial_cmp(&self, other: &Empty)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { ::core::option::Option::Some(::core::cmp::Ordering::Equal) } } #[automatically_derived] impl ::core::cmp::Ord for Empty { #[inline]- fn cmp(&self, other: &Empty) -> ::core::cmp::Ordering {+ fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { ::core::cmp::Ordering::Equal } }@@ -95,7 +90,7 @@ unsafe impl ::core::clone::TrivialClone for Point { } #[automatically_derived] impl ::core::clone::Clone for Point { #[inline]- fn clone(&self) -> Point {+ fn clone(&self) -> Self { let _: ::core::clone::AssertParamIsClone<u32>; *self }@@ -113,7 +108,7 @@ impl ::core::fmt::Debug for Point { #[automatically_derived] impl ::core::default::Default for Point { #[inline]- fn default() -> Point {+ fn default() -> Self { Point { x: ::core::default::Default::default(), y: ::core::default::Default::default(),@@ -133,7 +128,7 @@ impl ::core::marker::StructuralPartialEq for Point { } #[automatically_derived] impl ::core::cmp::PartialEq for Point { #[inline]- fn eq(&self, other: &Point) -> bool {+ fn eq(&self, other: &Self) -> bool { self.x == other.x && self.y == other.y } }@@ -149,15 +144,15 @@ impl ::core::cmp::Eq for Point { #[automatically_derived] impl ::core::cmp::PartialOrd for Point { #[inline]- fn partial_cmp(&self, other: &Point)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other)) } } #[automatically_derived] impl ::core::cmp::Ord for Point { #[inline]- fn cmp(&self, other: &Point) -> ::core::cmp::Ordering {+ fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { match ::core::cmp::Ord::cmp(&self.x, &other.x) { ::core::cmp::Ordering::Equal => ::core::cmp::Ord::cmp(&self.y, &other.y),@@ -179,7 +174,7 @@ unsafe impl ::core::clone::TrivialClone for PackedPoint { } #[automatically_derived] impl ::core::clone::Clone for PackedPoint { #[inline]- fn clone(&self) -> PackedPoint {+ fn clone(&self) -> Self { let _: ::core::clone::AssertParamIsClone<u32>; *self }@@ -197,7 +192,7 @@ impl ::core::fmt::Debug for PackedPoint { #[automatically_derived] impl ::core::default::Default for PackedPoint { #[inline]- fn default() -> PackedPoint {+ fn default() -> Self { PackedPoint { x: ::core::default::Default::default(), y: ::core::default::Default::default(),@@ -217,7 +212,7 @@ impl ::core::marker::StructuralPartialEq for PackedPoint { } #[automatically_derived] impl ::core::cmp::PartialEq for PackedPoint { #[inline]- fn eq(&self, other: &PackedPoint) -> bool {+ fn eq(&self, other: &Self) -> bool { ({ self.x }) == ({ other.x }) && ({ self.y }) == ({ other.y }) } }@@ -233,15 +228,15 @@ impl ::core::cmp::Eq for PackedPoint { #[automatically_derived] impl ::core::cmp::PartialOrd for PackedPoint { #[inline]- fn partial_cmp(&self, other: &PackedPoint)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other)) } } #[automatically_derived] impl ::core::cmp::Ord for PackedPoint { #[inline]- fn cmp(&self, other: &PackedPoint) -> ::core::cmp::Ordering {+ fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { match ::core::cmp::Ord::cmp(&{ self.x }, &{ other.x }) { ::core::cmp::Ordering::Equal => ::core::cmp::Ord::cmp(&{ self.y }, &{ other.y }),@@ -257,7 +252,7 @@ unsafe impl ::core::clone::TrivialClone for TupleSingleField { } #[automatically_derived] impl ::core::clone::Clone for TupleSingleField { #[inline]- fn clone(&self) -> TupleSingleField {+ fn clone(&self) -> Self { let _: ::core::clone::AssertParamIsClone<u32>; *self }@@ -275,14 +270,14 @@ impl ::core::fmt::Debug for TupleSingleField { #[automatically_derived] impl ::core::default::Default for TupleSingleField { #[inline]- fn default() -> TupleSingleField {+ fn default() -> Self { TupleSingleField(::core::default::Default::default()) } } #[automatically_derived] impl ::core::convert::From<u32> for TupleSingleField { #[inline]- fn from(value: u32) -> TupleSingleField { Self(value) }+ fn from(value: u32) -> Self { Self(value) } } #[automatically_derived] impl ::core::hash::Hash for TupleSingleField {@@ -296,7 +291,7 @@ impl ::core::marker::StructuralPartialEq for TupleSingleField { } #[automatically_derived] impl ::core::cmp::PartialEq for TupleSingleField { #[inline]- fn eq(&self, other: &TupleSingleField) -> bool { self.0 == other.0 }+ fn eq(&self, other: &Self) -> bool { self.0 == other.0 } } #[automatically_derived] impl ::core::cmp::Eq for TupleSingleField {@@ -310,15 +305,15 @@ impl ::core::cmp::Eq for TupleSingleField { #[automatically_derived] impl ::core::cmp::PartialOrd for TupleSingleField { #[inline]- fn partial_cmp(&self, other: &TupleSingleField)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other)) } } #[automatically_derived] impl ::core::cmp::Ord for TupleSingleField { #[inline]- fn cmp(&self, other: &TupleSingleField) -> ::core::cmp::Ordering {+ fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { ::core::cmp::Ord::cmp(&self.0, &other.0) } }@@ -332,7 +327,7 @@ unsafe impl ::core::clone::TrivialClone for SingleField { } #[automatically_derived] impl ::core::clone::Clone for SingleField { #[inline]- fn clone(&self) -> SingleField {+ fn clone(&self) -> Self { let _: ::core::clone::AssertParamIsClone<bool>; *self }@@ -350,14 +345,14 @@ impl ::core::fmt::Debug for SingleField { #[automatically_derived] impl ::core::default::Default for SingleField { #[inline]- fn default() -> SingleField {+ fn default() -> Self { SingleField { foo: ::core::default::Default::default() } } } #[automatically_derived] impl ::core::convert::From<bool> for SingleField { #[inline]- fn from(value: bool) -> SingleField { Self { foo: value } }+ fn from(value: bool) -> Self { Self { foo: value } } } #[automatically_derived] impl ::core::hash::Hash for SingleField {@@ -371,7 +366,7 @@ impl ::core::marker::StructuralPartialEq for SingleField { } #[automatically_derived] impl ::core::cmp::PartialEq for SingleField { #[inline]- fn eq(&self, other: &SingleField) -> bool { self.foo == other.foo }+ fn eq(&self, other: &Self) -> bool { self.foo == other.foo } } #[automatically_derived] impl ::core::cmp::Eq for SingleField {@@ -385,15 +380,15 @@ impl ::core::cmp::Eq for SingleField { #[automatically_derived] impl ::core::cmp::PartialOrd for SingleField { #[inline]- fn partial_cmp(&self, other: &SingleField)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other)) } } #[automatically_derived] impl ::core::cmp::Ord for SingleField { #[inline]- fn cmp(&self, other: &SingleField) -> ::core::cmp::Ordering {+ fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { ::core::cmp::Ord::cmp(&self.foo, &other.foo) } }@@ -416,7 +411,7 @@ unsafe impl ::core::clone::TrivialClone for Big { } #[automatically_derived] impl ::core::clone::Clone for Big { #[inline]- fn clone(&self) -> Big {+ fn clone(&self) -> Self { let _: ::core::clone::AssertParamIsClone<u32>; *self }@@ -439,7 +434,7 @@ impl ::core::fmt::Debug for Big { #[automatically_derived] impl ::core::default::Default for Big { #[inline]- fn default() -> Big {+ fn default() -> Self { Big { b1: ::core::default::Default::default(), b2: ::core::default::Default::default(),@@ -471,7 +466,7 @@ impl ::core::marker::StructuralPartialEq for Big { } #[automatically_derived] impl ::core::cmp::PartialEq for Big { #[inline]- fn eq(&self, other: &Big) -> bool {+ fn eq(&self, other: &Self) -> bool { self.b1 == other.b1 && self.b2 == other.b2 && self.b3 == other.b3 && self.b4 == other.b4 && self.b5 == other.b5 && self.b6 == other.b6 && self.b7 == other.b7 &&@@ -490,15 +485,15 @@ impl ::core::cmp::Eq for Big { #[automatically_derived] impl ::core::cmp::PartialOrd for Big { #[inline]- fn partial_cmp(&self, other: &Big)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other)) } } #[automatically_derived] impl ::core::cmp::Ord for Big { #[inline]- fn cmp(&self, other: &Big) -> ::core::cmp::Ordering {+ fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { match ::core::cmp::Ord::cmp(&self.b1, &other.b1) { ::core::cmp::Ordering::Equal => match ::core::cmp::Ord::cmp(&self.b2, &other.b2) {@@ -550,7 +545,7 @@ impl ::core::marker::StructuralPartialEq for Reorder { } #[automatically_derived] impl ::core::cmp::PartialEq for Reorder { #[inline]- fn eq(&self, other: &Reorder) -> bool {+ fn eq(&self, other: &Self) -> bool { self.b2 == other.b2 && self.b4 == other.b4 && self.b5 == other.b5 && self.b6 == other.b6 && self.b7 == other.b7 && self.b8 == other.b8 && self.b10 == other.b10 &&@@ -561,7 +556,7 @@ impl ::core::cmp::PartialEq for Reorder { #[automatically_derived] impl ::core::cmp::PartialOrd for Reorder { #[inline]- fn partial_cmp(&self, other: &Reorder)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { match ::core::cmp::PartialOrd::partial_cmp(&self.b1, &other.b1) { ::core::option::Option::Some(::core::cmp::Ordering::Equal) =>@@ -631,9 +626,7 @@ struct NonCopy(u32); #[automatically_derived] impl ::core::clone::Clone for NonCopy { #[inline]- fn clone(&self) -> NonCopy {- NonCopy(::core::clone::Clone::clone(&self.0))- }+ fn clone(&self) -> Self { NonCopy(::core::clone::Clone::clone(&self.0)) } } // A packed struct that doesn't impl `Copy`, which means it gets the non-trivial@@ -643,7 +636,7 @@ struct PackedNonCopy(u32); #[automatically_derived] impl ::core::clone::Clone for PackedNonCopy { #[inline]- fn clone(&self) -> PackedNonCopy {+ fn clone(&self) -> Self { PackedNonCopy(::core::clone::Clone::clone(&{ self.0 })) } }@@ -654,7 +647,7 @@ struct ManualCopy(u32); #[automatically_derived] impl ::core::clone::Clone for ManualCopy { #[inline]- fn clone(&self) -> ManualCopy {+ fn clone(&self) -> Self { ManualCopy(::core::clone::Clone::clone(&self.0)) } }@@ -667,7 +660,7 @@ struct PackedManualCopy(u32); #[automatically_derived] impl ::core::clone::Clone for PackedManualCopy { #[inline]- fn clone(&self) -> PackedManualCopy {+ fn clone(&self) -> Self { PackedManualCopy(::core::clone::Clone::clone(&{ self.0 })) } }@@ -686,7 +679,7 @@ impl ::core::fmt::Debug for Unsized { #[automatically_derived] impl ::core::convert::From<[u32]> for Unsized { #[inline]- fn from(value: [u32]) -> Unsized { Self(value) }+ fn from(value: [u32]) -> Self { Self(value) } } #[automatically_derived] impl ::core::hash::Hash for Unsized {@@ -700,7 +693,7 @@ impl ::core::marker::StructuralPartialEq for Unsized { } #[automatically_derived] impl ::core::cmp::PartialEq for Unsized { #[inline]- fn eq(&self, other: &Unsized) -> bool { self.0 == other.0 }+ fn eq(&self, other: &Self) -> bool { self.0 == other.0 } } #[automatically_derived] impl ::core::cmp::Eq for Unsized {@@ -714,15 +707,15 @@ impl ::core::cmp::Eq for Unsized { #[automatically_derived] impl ::core::cmp::PartialOrd for Unsized { #[inline]- fn partial_cmp(&self, other: &Unsized)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other)) } } #[automatically_derived] impl ::core::cmp::Ord for Unsized { #[inline]- fn cmp(&self, other: &Unsized) -> ::core::cmp::Ordering {+ fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { ::core::cmp::Ord::cmp(&self.0, &other.0) } }@@ -741,7 +734,7 @@ struct Generic<T: Trait, U> { impl<T: ::core::clone::Clone + Trait, U: ::core::clone::Clone> ::core::clone::Clone for Generic<T, U> where T::A: ::core::clone::Clone { #[inline]- fn clone(&self) -> Generic<T, U> {+ fn clone(&self) -> Self { Generic { t: ::core::clone::Clone::clone(&self.t), ta: ::core::clone::Clone::clone(&self.ta),@@ -767,7 +760,7 @@ impl<T: ::core::default::Default + Trait, U: ::core::default::Default> ::core::default::Default for Generic<T, U> where T::A: ::core::default::Default { #[inline]- fn default() -> Generic<T, U> {+ fn default() -> Self { Generic { t: ::core::default::Default::default(), ta: ::core::default::Default::default(),@@ -795,7 +788,7 @@ impl<T: ::core::cmp::PartialEq + Trait, U: ::core::cmp::PartialEq> ::core::cmp::PartialEq for Generic<T, U> where T::A: ::core::cmp::PartialEq { #[inline]- fn eq(&self, other: &Generic<T, U>) -> bool {+ fn eq(&self, other: &Self) -> bool { self.t == other.t && self.ta == other.ta && self.u == other.u } }@@ -816,7 +809,7 @@ impl<T: ::core::cmp::PartialOrd + Trait, U: ::core::cmp::PartialOrd> ::core::cmp::PartialOrd for Generic<T, U> where T::A: ::core::cmp::PartialOrd { #[inline]- fn partial_cmp(&self, other: &Generic<T, U>)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { match ::core::cmp::PartialOrd::partial_cmp(&self.t, &other.t) { ::core::option::Option::Some(::core::cmp::Ordering::Equal) =>@@ -834,7 +827,7 @@ impl<T: ::core::cmp::PartialOrd + Trait, U: ::core::cmp::PartialOrd> impl<T: ::core::cmp::Ord + Trait, U: ::core::cmp::Ord> ::core::cmp::Ord for Generic<T, U> where T::A: ::core::cmp::Ord { #[inline]- fn cmp(&self, other: &Generic<T, U>) -> ::core::cmp::Ordering {+ fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { match ::core::cmp::Ord::cmp(&self.t, &other.t) { ::core::cmp::Ordering::Equal => match ::core::cmp::Ord::cmp(&self.ta, &other.ta) {@@ -860,7 +853,7 @@ impl<T: ::core::clone::Clone + ::core::marker::Copy + Trait, PackedGeneric<T, U> where T::A: ::core::clone::Clone + ::core::marker::Copy { #[inline]- fn clone(&self) -> PackedGeneric<T, U> {+ fn clone(&self) -> Self { PackedGeneric(::core::clone::Clone::clone(&{ self.0 }), ::core::clone::Clone::clone(&{ self.1 }), ::core::clone::Clone::clone(&{ self.2 }))@@ -887,7 +880,7 @@ impl<T: ::core::default::Default + Trait, U: ::core::default::Default> ::core::default::Default for PackedGeneric<T, U> where T::A: ::core::default::Default { #[inline]- fn default() -> PackedGeneric<T, U> {+ fn default() -> Self { PackedGeneric(::core::default::Default::default(), ::core::default::Default::default(), ::core::default::Default::default())@@ -916,7 +909,7 @@ impl<T: ::core::cmp::PartialEq + ::core::marker::Copy + Trait, for PackedGeneric<T, U> where T::A: ::core::cmp::PartialEq + ::core::marker::Copy { #[inline]- fn eq(&self, other: &PackedGeneric<T, U>) -> bool {+ fn eq(&self, other: &Self) -> bool { ({ self.0 }) == ({ other.0 }) && ({ self.1 }) == ({ other.1 }) && ({ self.2 }) == ({ other.2 }) }@@ -940,7 +933,7 @@ impl<T: ::core::cmp::PartialOrd + ::core::marker::Copy + Trait, for PackedGeneric<T, U> where T::A: ::core::cmp::PartialOrd + ::core::marker::Copy { #[inline]- fn partial_cmp(&self, other: &PackedGeneric<T, U>)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { match ::core::cmp::PartialOrd::partial_cmp(&{ self.0 }, &{ other.0 }) {@@ -962,7 +955,7 @@ impl<T: ::core::cmp::Ord + ::core::marker::Copy + Trait, U: ::core::cmp::Ord + ::core::marker::Copy> ::core::cmp::Ord for PackedGeneric<T, U> where T::A: ::core::cmp::Ord + ::core::marker::Copy { #[inline]- fn cmp(&self, other: &PackedGeneric<T, U>) -> ::core::cmp::Ordering {+ fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { match ::core::cmp::Ord::cmp(&{ self.0 }, &{ other.0 }) { ::core::cmp::Ordering::Equal => match ::core::cmp::Ord::cmp(&{ self.1 }, &{ other.1 }) {@@ -983,7 +976,7 @@ unsafe impl ::core::clone::TrivialClone for Enum0 { } #[automatically_derived] impl ::core::clone::Clone for Enum0 { #[inline]- fn clone(&self) -> Enum0 { *self }+ fn clone(&self) -> Self { *self } } #[automatically_derived] impl ::core::marker::Copy for Enum0 { }@@ -1006,22 +999,22 @@ impl ::core::marker::StructuralPartialEq for Enum0 { } #[automatically_derived] impl ::core::cmp::PartialEq for Enum0 { #[inline]- fn eq(&self, other: &Enum0) -> bool { match *self {} }+ fn eq(&self, other: &Self) -> bool { match *self {} } } #[automatically_derived] impl ::core::cmp::Eq for Enum0 { } #[automatically_derived] impl ::core::cmp::PartialOrd for Enum0 { #[inline]- fn partial_cmp(&self, other: &Enum0)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { match *self {} } } #[automatically_derived] impl ::core::cmp::Ord for Enum0 { #[inline]- fn cmp(&self, other: &Enum0) -> ::core::cmp::Ordering { match *self {} }+ fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { match *self {} } } // A single-variant enum.@@ -1033,7 +1026,7 @@ enum Enum1 { #[automatically_derived] impl ::core::clone::Clone for Enum1 { #[inline]- fn clone(&self) -> Enum1 {+ fn clone(&self) -> Self { match self { Enum1::Single { x: __self_0 } => Enum1::Single { x: ::core::clone::Clone::clone(__self_0) },@@ -1066,7 +1059,7 @@ impl ::core::marker::StructuralPartialEq for Enum1 { } #[automatically_derived] impl ::core::cmp::PartialEq for Enum1 { #[inline]- fn eq(&self, other: &Enum1) -> bool {+ fn eq(&self, other: &Self) -> bool { match (self, other) { (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg1_0 }) => __self_0 == __arg1_0,@@ -1085,15 +1078,15 @@ impl ::core::cmp::Eq for Enum1 { #[automatically_derived] impl ::core::cmp::PartialOrd for Enum1 { #[inline]- fn partial_cmp(&self, other: &Enum1)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other)) } } #[automatically_derived] impl ::core::cmp::Ord for Enum1 { #[inline]- fn cmp(&self, other: &Enum1) -> ::core::cmp::Ordering {+ fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { match (self, other) { (Enum1::Single { x: __self_0 }, Enum1::Single { x: __arg1_0 }) => ::core::cmp::Ord::cmp(__self_0, __arg1_0),@@ -1110,7 +1103,7 @@ enum Fieldless1 { #[automatically_derived] impl ::core::clone::Clone for Fieldless1 { #[inline]- fn clone(&self) -> Fieldless1 { Fieldless1::A }+ fn clone(&self) -> Self { Fieldless1::A } } #[automatically_derived] impl ::core::fmt::Debug for Fieldless1 {@@ -1122,7 +1115,7 @@ impl ::core::fmt::Debug for Fieldless1 { #[automatically_derived] impl ::core::default::Default for Fieldless1 { #[inline]- fn default() -> Fieldless1 { Self::A }+ fn default() -> Self { Self::A } } #[automatically_derived] impl ::core::hash::Hash for Fieldless1 {@@ -1134,22 +1127,22 @@ impl ::core::marker::StructuralPartialEq for Fieldless1 { } #[automatically_derived] impl ::core::cmp::PartialEq for Fieldless1 { #[inline]- fn eq(&self, other: &Fieldless1) -> bool { true }+ fn eq(&self, other: &Self) -> bool { true } } #[automatically_derived] impl ::core::cmp::Eq for Fieldless1 { } #[automatically_derived] impl ::core::cmp::PartialOrd for Fieldless1 { #[inline]- fn partial_cmp(&self, other: &Fieldless1)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { ::core::option::Option::Some(::core::cmp::Ordering::Equal) } } #[automatically_derived] impl ::core::cmp::Ord for Fieldless1 { #[inline]- fn cmp(&self, other: &Fieldless1) -> ::core::cmp::Ordering {+ fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { ::core::cmp::Ordering::Equal } }@@ -1168,7 +1161,7 @@ unsafe impl ::core::clone::TrivialClone for Fieldless { } #[automatically_derived] impl ::core::clone::Clone for Fieldless { #[inline]- fn clone(&self) -> Fieldless { *self }+ fn clone(&self) -> Self { *self } } #[automatically_derived] impl ::core::marker::Copy for Fieldless { }@@ -1187,7 +1180,7 @@ impl ::core::fmt::Debug for Fieldless { #[automatically_derived] impl ::core::default::Default for Fieldless { #[inline]- fn default() -> Fieldless { Self::A }+ fn default() -> Self { Self::A } } #[automatically_derived] impl ::core::hash::Hash for Fieldless {@@ -1202,7 +1195,7 @@ impl ::core::marker::StructuralPartialEq for Fieldless { } #[automatically_derived] impl ::core::cmp::PartialEq for Fieldless { #[inline]- fn eq(&self, other: &Fieldless) -> bool {+ 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@@ -1213,15 +1206,15 @@ impl ::core::cmp::Eq for Fieldless { } #[automatically_derived] impl ::core::cmp::PartialOrd for Fieldless { #[inline]- fn partial_cmp(&self, other: &Fieldless)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other)) } } #[automatically_derived] impl ::core::cmp::Ord for Fieldless { #[inline]- fn cmp(&self, other: &Fieldless) -> ::core::cmp::Ordering {+ 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)@@ -1246,7 +1239,7 @@ unsafe impl ::core::clone::TrivialClone for Mixed { } #[automatically_derived] impl ::core::clone::Clone for Mixed { #[inline]- fn clone(&self) -> Mixed {+ fn clone(&self) -> Self { let _: ::core::clone::AssertParamIsClone<u32>; let _: ::core::clone::AssertParamIsClone<Option<u32>>; let _: ::core::clone::AssertParamIsClone<Option<i32>>;@@ -1274,7 +1267,7 @@ impl ::core::fmt::Debug for Mixed { #[automatically_derived] impl ::core::default::Default for Mixed { #[inline]- fn default() -> Mixed { Self::P }+ fn default() -> Self { Self::P } } #[automatically_derived] impl ::core::hash::Hash for Mixed {@@ -1297,7 +1290,7 @@ impl ::core::marker::StructuralPartialEq for Mixed { } #[automatically_derived] impl ::core::cmp::PartialEq for Mixed { #[inline]- fn eq(&self, other: &Mixed) -> bool {+ 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 &&@@ -1325,15 +1318,15 @@ impl ::core::cmp::Eq for Mixed { #[automatically_derived] impl ::core::cmp::PartialOrd for Mixed { #[inline]- fn partial_cmp(&self, other: &Mixed)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other)) } } #[automatically_derived] impl ::core::cmp::Ord for Mixed { #[inline]- fn cmp(&self, other: &Mixed) -> ::core::cmp::Ordering {+ 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) {@@ -1372,7 +1365,7 @@ impl ::core::marker::StructuralPartialEq for ReorderEnum { } #[automatically_derived] impl ::core::cmp::PartialEq for ReorderEnum { #[inline]- fn eq(&self, other: &ReorderEnum) -> bool {+ 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 &&@@ -1392,7 +1385,7 @@ impl ::core::cmp::PartialEq for ReorderEnum { #[automatically_derived] impl ::core::cmp::PartialOrd for ReorderEnum { #[inline]- fn partial_cmp(&self, other: &ReorderEnum)+ 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);@@ -1432,7 +1425,7 @@ enum Fielded { X(u32), Y(bool), Z(Option<i32>), } #[automatically_derived] impl ::core::clone::Clone for Fielded { #[inline]- fn clone(&self) -> Fielded {+ fn clone(&self) -> Self { match self { Fielded::X(__self_0) => Fielded::X(::core::clone::Clone::clone(__self_0)),@@ -1478,7 +1471,7 @@ impl ::core::marker::StructuralPartialEq for Fielded { } #[automatically_derived] impl ::core::cmp::PartialEq for Fielded { #[inline]- fn eq(&self, other: &Fielded) -> bool {+ 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 &&@@ -1507,15 +1500,15 @@ impl ::core::cmp::Eq for Fielded { #[automatically_derived] impl ::core::cmp::PartialOrd for Fielded { #[inline]- fn partial_cmp(&self, other: &Fielded)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other)) } } #[automatically_derived] impl ::core::cmp::Ord for Fielded { #[inline]- fn cmp(&self, other: &Fielded) -> ::core::cmp::Ordering {+ 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) {@@ -1540,7 +1533,7 @@ enum EnumGeneric<T, U> { One(T), Two(U), } impl<T: ::core::clone::Clone, U: ::core::clone::Clone> ::core::clone::Clone for EnumGeneric<T, U> { #[inline]- fn clone(&self) -> EnumGeneric<T, U> {+ fn clone(&self) -> Self { match self { EnumGeneric::One(__self_0) => EnumGeneric::One(::core::clone::Clone::clone(__self_0)),@@ -1591,7 +1584,7 @@ impl<T: ::core::cmp::PartialEq, U: ::core::cmp::PartialEq> impl<T: ::core::cmp::PartialEq, U: ::core::cmp::PartialEq> ::core::cmp::PartialEq for EnumGeneric<T, U> { #[inline]- fn eq(&self, other: &EnumGeneric<T, U>) -> bool {+ 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 &&@@ -1619,7 +1612,7 @@ impl<T: ::core::cmp::Eq, U: ::core::cmp::Eq> ::core::cmp::Eq for impl<T: ::core::cmp::PartialOrd, U: ::core::cmp::PartialOrd> ::core::cmp::PartialOrd for EnumGeneric<T, U> { #[inline]- fn partial_cmp(&self, other: &EnumGeneric<T, U>)+ 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);@@ -1638,7 +1631,7 @@ impl<T: ::core::cmp::PartialOrd, U: ::core::cmp::PartialOrd> impl<T: ::core::cmp::Ord, U: ::core::cmp::Ord> ::core::cmp::Ord for EnumGeneric<T, U> { #[inline]- fn cmp(&self, other: &EnumGeneric<T, U>) -> ::core::cmp::Ordering {+ 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) {@@ -1667,7 +1660,7 @@ impl ::core::marker::StructuralPartialEq for NonCopyEnum { } #[automatically_derived] impl ::core::cmp::PartialEq for NonCopyEnum { #[inline]- fn eq(&self, other: &NonCopyEnum) -> bool {+ fn eq(&self, other: &Self) -> bool { match (self, other) { (NonCopyEnum::NonCopyField(__self_0), NonCopyEnum::NonCopyField(__arg1_0)) => __self_0 == __arg1_0,@@ -1691,7 +1684,7 @@ unsafe impl ::core::clone::TrivialClone for Union { } #[automatically_derived] impl ::core::clone::Clone for Union { #[inline]- fn clone(&self) -> Union {+ fn clone(&self) -> Self { let _: ::core::clone::AssertParamIsCopy<Self>; *self }@@ -1708,7 +1701,7 @@ unsafe impl ::core::clone::TrivialClone for FooCopyClone { } #[automatically_derived] impl ::core::clone::Clone for FooCopyClone { #[inline]- fn clone(&self) -> FooCopyClone {+ fn clone(&self) -> Self { let _: ::core::clone::AssertParamIsClone<i32>; *self }@@ -1721,7 +1714,7 @@ unsafe impl ::core::clone::TrivialClone for FooCloneCopy { } #[automatically_derived] impl ::core::clone::Clone for FooCloneCopy { #[inline]- fn clone(&self) -> FooCloneCopy {+ fn clone(&self) -> Self { let _: ::core::clone::AssertParamIsClone<i32>; *self }@@ -1736,7 +1729,7 @@ unsafe impl ::core::clone::TrivialClone for FooCopyAndClone { } #[automatically_derived] impl ::core::clone::Clone for FooCopyAndClone { #[inline]- fn clone(&self) -> FooCopyAndClone {+ fn clone(&self) -> Self { let _: ::core::clone::AssertParamIsClone<i32>; *self }@@ -1753,7 +1746,7 @@ impl ::core::marker::Copy for FooCloneAndCopy { } #[automatically_derived] impl ::core::clone::Clone for FooCloneAndCopy { #[inline]- fn clone(&self) -> FooCloneAndCopy {+ fn clone(&self) -> Self { FooCloneAndCopy(::core::clone::Clone::clone(&self.0)) } }@@ -1762,15 +1755,15 @@ struct FooPartialOrdOrd(i32); #[automatically_derived] impl ::core::cmp::PartialOrd for FooPartialOrdOrd { #[inline]- fn partial_cmp(&self, other: &FooPartialOrdOrd)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other)) } } #[automatically_derived] impl ::core::cmp::Ord for FooPartialOrdOrd { #[inline]- fn cmp(&self, other: &FooPartialOrdOrd) -> ::core::cmp::Ordering {+ fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { ::core::cmp::Ord::cmp(&self.0, &other.0) } }@@ -1779,14 +1772,14 @@ struct FooOrdPartialOrd(i32); #[automatically_derived] impl ::core::cmp::Ord for FooOrdPartialOrd { #[inline]- fn cmp(&self, other: &FooOrdPartialOrd) -> ::core::cmp::Ordering {+ fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { ::core::cmp::Ord::cmp(&self.0, &other.0) } } #[automatically_derived] impl ::core::cmp::PartialOrd for FooOrdPartialOrd { #[inline]- fn partial_cmp(&self, other: &FooOrdPartialOrd)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other)) }@@ -1796,15 +1789,15 @@ struct FooOrdBeforePartialOrd(i32); #[automatically_derived] impl ::core::cmp::PartialOrd for FooOrdBeforePartialOrd { #[inline]- fn partial_cmp(&self, other: &FooOrdBeforePartialOrd)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other)) } } #[automatically_derived] impl ::core::cmp::Ord for FooOrdBeforePartialOrd { #[inline]- fn cmp(&self, other: &FooOrdBeforePartialOrd) -> ::core::cmp::Ordering {+ fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { ::core::cmp::Ord::cmp(&self.0, &other.0) } }@@ -1814,14 +1807,14 @@ struct FooPartialOrdBeforeOrd(i32); #[automatically_derived] impl ::core::cmp::Ord for FooPartialOrdBeforeOrd { #[inline]- fn cmp(&self, other: &FooPartialOrdBeforeOrd) -> ::core::cmp::Ordering {+ fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { ::core::cmp::Ord::cmp(&self.0, &other.0) } } #[automatically_derived] impl ::core::cmp::PartialOrd for FooPartialOrdBeforeOrd { #[inline]- fn partial_cmp(&self, other: &FooPartialOrdBeforeOrd)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { ::core::cmp::PartialOrd::partial_cmp(&self.0, &other.0) }@@ -1831,15 +1824,15 @@ struct UnitStruct; #[automatically_derived] impl ::core::cmp::PartialOrd for UnitStruct { #[inline]- fn partial_cmp(&self, other: &UnitStruct)+ fn partial_cmp(&self, other: &Self) -> ::core::option::Option<::core::cmp::Ordering> { ::core::option::Option::Some(::core::cmp::Ordering::Equal) } } #[automatically_derived] impl ::core::cmp::Ord for UnitStruct { #[inline]- fn cmp(&self, other: &UnitStruct) -> ::core::cmp::Ordering {+ fn cmp(&self, other: &Self) -> ::core::cmp::Ordering { ::core::cmp::Ordering::Equal } }tests/ui/duplicate/multiple-types-with-same-name-and-derive-default-133965.rs0 + / 2 −
@@ -3,8 +3,6 @@ struct NonGeneric {} #[derive(Default)]-//~^ ERROR: struct takes 0 lifetime arguments but 1 lifetime argument was supplied-//~| ERROR: struct takes 0 generic arguments but 1 generic argument was supplied struct NonGeneric<'a, const N: usize> {} //~^ ERROR: struct takes 0 lifetime arguments but 1 lifetime argument was supplied //~| ERROR: struct takes 0 generic arguments but 1 generic argument was suppliedtests/ui/duplicate/multiple-types-with-same-name-and-derive-default-133965.stderr12 + / 39 −
@@ -1,5 +1,5 @@ error[E0428]: the name `NonGeneric` is defined multiple times- --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:8:1+ --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:6:1 | LL | struct NonGeneric {} | ----------------- previous definition of the type `NonGeneric` here@@ -10,42 +10,7 @@ LL | struct NonGeneric<'a, const N: usize> {} = note: `NonGeneric` must be defined only once in the type namespace of this module error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supplied- --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:5:10- |-LL | #[derive(Default)]- | ^^^^^^^ expected 0 lifetime arguments-...-LL | struct NonGeneric<'a, const N: usize> {}- | -- help: remove the lifetime argument- |-note: struct defined here, with 0 lifetime parameters- --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:3:8- |-LL | struct NonGeneric {}- | ^^^^^^^^^^--error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied- --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:5:10- |-LL | #[derive(Default)]- | ^^^^^^^ expected 0 generic arguments- |-note: struct defined here, with 0 generic parameters- --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:3:8- |-LL | struct NonGeneric {}- | ^^^^^^^^^^--error[E0392]: lifetime parameter `'a` is never used- --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:8:19- |-LL | struct NonGeneric<'a, const N: usize> {}- | ^^ unused lifetime parameter- |- = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`--error[E0107]: struct takes 0 lifetime arguments but 1 lifetime argument was supplied- --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:8:8+ --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:6:8 | LL | struct NonGeneric<'a, const N: usize> {} | ^^^^^^^^^^ -- help: remove the lifetime argument@@ -59,7 +24,7 @@ LL | struct NonGeneric {} | ^^^^^^^^^^ error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied- --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:8:8+ --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:6:8 | LL | struct NonGeneric<'a, const N: usize> {} | ^^^^^^^^^^ - help: remove the unnecessary generic argument@@ -72,7 +37,15 @@ note: struct defined here, with 0 generic parameters LL | struct NonGeneric {} | ^^^^^^^^^^ -error: aborting due to 6 previous errors+error[E0392]: lifetime parameter `'a` is never used+ --> $DIR/multiple-types-with-same-name-and-derive-default-133965.rs:6:19+ |+LL | struct NonGeneric<'a, const N: usize> {}+ | ^^ unused lifetime parameter+ |+ = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`++error: aborting due to 4 previous errors Some errors have detailed explanations: E0107, E0392, E0428. For more information about an error, try `rustc --explain E0107`.tests/ui/duplicate/multiple-types-with-same-name-and-derive.rs0 + / 2 −
@@ -8,12 +8,10 @@ struct NotSM; #[derive(PartialEq, Eq)]-//~^ ERROR: struct takes 0 generic arguments struct NotSM<T>(T); //~^ ERROR: struct takes 0 generic arguments //~| ERROR: struct takes 0 generic arguments //~| ERROR: struct takes 0 generic arguments //~| ERROR: the name `NotSM` is defined multiple times-//~| ERROR: no field `0` fn main() {}tests/ui/duplicate/multiple-types-with-same-name-and-derive.stderr6 + / 24 −
@@ -1,5 +1,5 @@ error[E0428]: the name `NotSM` is defined multiple times- --> $DIR/multiple-types-with-same-name-and-derive.rs:12:1+ --> $DIR/multiple-types-with-same-name-and-derive.rs:11:1 | LL | struct NotSM; | ------------- previous definition of the type `NotSM` here@@ -10,7 +10,7 @@ LL | struct NotSM<T>(T); = note: `NotSM` must be defined only once in the type namespace of this module error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied- --> $DIR/multiple-types-with-same-name-and-derive.rs:12:8+ --> $DIR/multiple-types-with-same-name-and-derive.rs:11:8 | LL | struct NotSM<T>(T); | ^^^^^ expected 0 generic arguments@@ -22,19 +22,7 @@ LL | struct NotSM; | ^^^^^ error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied- --> $DIR/multiple-types-with-same-name-and-derive.rs:10:10- |-LL | #[derive(PartialEq, Eq)]- | ^^^^^^^^^ expected 0 generic arguments- |-note: struct defined here, with 0 generic parameters- --> $DIR/multiple-types-with-same-name-and-derive.rs:8:8- |-LL | struct NotSM;- | ^^^^^--error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied- --> $DIR/multiple-types-with-same-name-and-derive.rs:12:8+ --> $DIR/multiple-types-with-same-name-and-derive.rs:11:8 | LL | struct NotSM<T>(T); | ^^^^^ expected 0 generic arguments@@ -47,7 +35,7 @@ LL | struct NotSM; = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied- --> $DIR/multiple-types-with-same-name-and-derive.rs:12:8+ --> $DIR/multiple-types-with-same-name-and-derive.rs:11:8 | LL | struct NotSM<T>(T); | ^^^^^ expected 0 generic arguments@@ -59,13 +47,7 @@ LL | struct NotSM; | ^^^^^ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0609]: no field `0` on type `&NotSM`- --> $DIR/multiple-types-with-same-name-and-derive.rs:12:17- |-LL | struct NotSM<T>(T);- | ^ unknown field--error: aborting due to 6 previous errors+error: aborting due to 4 previous errors -Some errors have detailed explanations: E0107, E0428, E0609.+Some errors have detailed explanations: E0107, E0428. For more information about an error, try `rustc --explain E0107`.tests/ui/stats/macro-stats.stderr5 + / 5 −
@@ -2,15 +2,15 @@ macro-stats ==================================================================== 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_879 234.9+macro-stats #[derive(Clone)] 8 67 8.4 1_895 236.9 macro-stats #[derive(Hash)] 2 17 8.5 565 282.5 macro-stats q! 1 26 26.0 519 519.0-macro-stats #[derive(Ord)] 1 15 15.0 503 503.0-macro-stats #[derive(Default)] 2 16 8.0 403 201.5+macro-stats #[derive(Ord)] 1 15 15.0 505 505.0+macro-stats #[derive(Default)] 2 16 8.0 407 203.5 macro-stats #[derive(Eq)] 1 11 11.0 312 312.0 macro-stats #[derive(Debug)] 1 8 8.0 277 277.0-macro-stats #[derive(PartialEq)] 1 9 9.0 267 267.0-macro-stats #[derive(PartialOrd)] 1 8 8.0 254 254.0+macro-stats #[derive(PartialEq)] 1 9 9.0 269 269.0+macro-stats #[derive(PartialOrd)] 1 8 8.0 256 256.0 macro-stats #[derive(Copy)] 1 2 2.0 61 61.0 macro-stats p! 1 3 3.0 32 32.0 macro-stats trait_impl_tys! 1 2 2.0 28 28.0tests/ui/traits/issue-106072.rs1 + / 1 −
@@ -1,4 +1,4 @@-#[derive(Clone)] //~ ERROR: expected a type, found a trait+#[derive(Clone)] struct Foo; //~ ERROR: expected a type, found a trait trait Foo {} //~ ERROR: the name `Foo` is defined multiple times fn main() {}tests/ui/traits/issue-106072.stderr1 + / 7 −
@@ -16,13 +16,7 @@ LL | #[derive(Clone)] LL | struct Foo; | ^^^ -error[E0782]: expected a type, found a trait- --> $DIR/issue-106072.rs:1:10- |-LL | #[derive(Clone)]- | ^^^^^--error: aborting due to 3 previous errors+error: aborting due to 2 previous errors Some errors have detailed explanations: E0428, E0782. For more information about an error, try `rustc --explain E0428`.