diff options
607 files changed, 4976 insertions, 3300 deletions
diff --git a/Cargo.lock b/Cargo.lock index c31fed86bc8..6bc88fb7a6d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2751,9 +2751,9 @@ dependencies = [ [[package]] name = "psm" -version = "0.1.24" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "200b9ff220857e53e184257720a14553b2f4aa02577d2ed9842d45d4b9654810" +checksum = "f58e5423e24c18cc840e1c98370b3993c6649cd1678b4d24318bcf0a083cbe88" dependencies = [ "cc", ] @@ -4947,9 +4947,9 @@ dependencies = [ [[package]] name = "stacker" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799c883d55abdb5e98af1a7b3f23b9b6de8ecada0ecac058672d7635eb48ca7b" +checksum = "1d08feb8f695b465baed819b03c128dc23f57a694510ab1f06c77f763975685e" dependencies = [ "cc", "cfg-if", diff --git a/compiler/rustc/Cargo.toml b/compiler/rustc/Cargo.toml index d24b630516a..f4caa3ef769 100644 --- a/compiler/rustc/Cargo.toml +++ b/compiler/rustc/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc-main" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc/src/main.rs b/compiler/rustc/src/main.rs index a55a63a7bf1..ca1bb59e59d 100644 --- a/compiler/rustc/src/main.rs +++ b/compiler/rustc/src/main.rs @@ -65,7 +65,7 @@ fn main() { // linking, so we need to explicitly depend on the function. #[cfg(target_os = "macos")] { - extern "C" { + unsafe extern "C" { fn _rjem_je_zone_register(); } diff --git a/compiler/rustc_abi/Cargo.toml b/compiler/rustc_abi/Cargo.toml index 3d6f4a6a109..86dc84e2016 100644 --- a/compiler/rustc_abi/Cargo.toml +++ b/compiler/rustc_abi/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_abi" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_abi/src/callconv.rs b/compiler/rustc_abi/src/callconv.rs index 9fb70b80c9e..4529ab8058e 100644 --- a/compiler/rustc_abi/src/callconv.rs +++ b/compiler/rustc_abi/src/callconv.rs @@ -65,8 +65,6 @@ impl<'a, Ty> TyAndLayout<'a, Ty> { Ty: TyAbiInterface<'a, C> + Copy, { match self.backend_repr { - BackendRepr::Uninhabited => Err(Heterogeneous), - // The primitive for this algorithm. BackendRepr::Scalar(scalar) => { let kind = match scalar.primitive() { diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs index 45cd0b517f6..53243266f99 100644 --- a/compiler/rustc_abi/src/layout.rs +++ b/compiler/rustc_abi/src/layout.rs @@ -130,6 +130,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> { }, backend_repr: BackendRepr::ScalarPair(a, b), largest_niche, + uninhabited: false, align, size, max_repr_align: None, @@ -221,8 +222,9 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> { LayoutData { variants: Variants::Empty, fields: FieldsShape::Primitive, - backend_repr: BackendRepr::Uninhabited, + backend_repr: BackendRepr::Memory { sized: true }, largest_niche: None, + uninhabited: true, align: dl.i8_align, size: Size::ZERO, max_repr_align: None, @@ -400,6 +402,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> { fields: FieldsShape::Union(union_field_count), backend_repr: abi, largest_niche: None, + uninhabited: false, align, size: size.align_to(align.abi), max_repr_align, @@ -447,7 +450,6 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> { Scalar::Union { .. } => {} }; match &mut st.backend_repr { - BackendRepr::Uninhabited => {} BackendRepr::Scalar(scalar) => hide_niches(scalar), BackendRepr::ScalarPair(a, b) => { hide_niches(a); @@ -639,9 +641,8 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> { let same_size = size == variant_layouts[largest_variant_index].size; let same_align = align == variant_layouts[largest_variant_index].align; - let abi = if variant_layouts.iter().all(|v| v.is_uninhabited()) { - BackendRepr::Uninhabited - } else if same_size && same_align && others_zst { + let uninhabited = variant_layouts.iter().all(|v| v.is_uninhabited()); + let abi = if same_size && same_align && others_zst { match variant_layouts[largest_variant_index].backend_repr { // When the total alignment and size match, we can use the // same ABI as the scalar variant with the reserved niche. @@ -683,6 +684,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> { }, backend_repr: abi, largest_niche, + uninhabited, size, align, max_repr_align, @@ -853,9 +855,8 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> { }; let mut abi = BackendRepr::Memory { sized: true }; - if layout_variants.iter().all(|v| v.is_uninhabited()) { - abi = BackendRepr::Uninhabited; - } else if tag.size(dl) == size { + let uninhabited = layout_variants.iter().all(|v| v.is_uninhabited()); + if tag.size(dl) == size { // Make sure we only use scalar layout when the enum is entirely its // own tag (i.e. it has no padding nor any non-ZST variant fields). abi = BackendRepr::Scalar(tag); @@ -995,6 +996,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> { memory_index: [0].into(), }, largest_niche, + uninhabited, backend_repr: abi, align, size, @@ -1355,9 +1357,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> { _ => {} } } - if fields.iter().any(|f| f.is_uninhabited()) { - abi = BackendRepr::Uninhabited; - } + let uninhabited = fields.iter().any(|f| f.is_uninhabited()); let unadjusted_abi_align = if repr.transparent() { match layout_of_single_non_zst_field { @@ -1378,6 +1378,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> { fields: FieldsShape::Arbitrary { offsets, memory_index }, backend_repr: abi, largest_niche, + uninhabited, align, size, max_repr_align, diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index dbb4bed5cdd..34228912041 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -329,19 +329,19 @@ impl TargetDataLayout { [p] if p.starts_with('P') => { dl.instruction_address_space = parse_address_space(&p[1..], "P")? } - ["a", ref a @ ..] => dl.aggregate_align = parse_align(a, "a")?, - ["f16", ref a @ ..] => dl.f16_align = parse_align(a, "f16")?, - ["f32", ref a @ ..] => dl.f32_align = parse_align(a, "f32")?, - ["f64", ref a @ ..] => dl.f64_align = parse_align(a, "f64")?, - ["f128", ref a @ ..] => dl.f128_align = parse_align(a, "f128")?, + ["a", a @ ..] => dl.aggregate_align = parse_align(a, "a")?, + ["f16", a @ ..] => dl.f16_align = parse_align(a, "f16")?, + ["f32", a @ ..] => dl.f32_align = parse_align(a, "f32")?, + ["f64", a @ ..] => dl.f64_align = parse_align(a, "f64")?, + ["f128", a @ ..] => dl.f128_align = parse_align(a, "f128")?, // FIXME(erikdesjardins): we should be parsing nonzero address spaces // this will require replacing TargetDataLayout::{pointer_size,pointer_align} // with e.g. `fn pointer_size_in(AddressSpace)` - [p @ "p", s, ref a @ ..] | [p @ "p0", s, ref a @ ..] => { + [p @ "p", s, a @ ..] | [p @ "p0", s, a @ ..] => { dl.pointer_size = parse_size(s, p)?; dl.pointer_align = parse_align(a, p)?; } - [s, ref a @ ..] if s.starts_with('i') => { + [s, a @ ..] if s.starts_with('i') => { let Ok(bits) = s[1..].parse::<u64>() else { parse_size(&s[1..], "i")?; // For the user error. continue; @@ -362,7 +362,7 @@ impl TargetDataLayout { dl.i128_align = a; } } - [s, ref a @ ..] if s.starts_with('v') => { + [s, a @ ..] if s.starts_with('v') => { let v_size = parse_size(&s[1..], "v")?; let a = parse_align(a, s)?; if let Some(v) = dl.vector_align.iter_mut().find(|v| v.0 == v_size) { @@ -1404,7 +1404,6 @@ impl AddressSpace { #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] #[cfg_attr(feature = "nightly", derive(HashStable_Generic))] pub enum BackendRepr { - Uninhabited, Scalar(Scalar), ScalarPair(Scalar, Scalar), Vector { @@ -1423,10 +1422,9 @@ impl BackendRepr { #[inline] pub fn is_unsized(&self) -> bool { match *self { - BackendRepr::Uninhabited - | BackendRepr::Scalar(_) - | BackendRepr::ScalarPair(..) - | BackendRepr::Vector { .. } => false, + BackendRepr::Scalar(_) | BackendRepr::ScalarPair(..) | BackendRepr::Vector { .. } => { + false + } BackendRepr::Memory { sized } => !sized, } } @@ -1445,12 +1443,6 @@ impl BackendRepr { } } - /// Returns `true` if this is an uninhabited type - #[inline] - pub fn is_uninhabited(&self) -> bool { - matches!(*self, BackendRepr::Uninhabited) - } - /// Returns `true` if this is a scalar type #[inline] pub fn is_scalar(&self) -> bool { @@ -1471,7 +1463,7 @@ impl BackendRepr { BackendRepr::Vector { element, count } => { cx.data_layout().vector_align(element.size(cx) * count) } - BackendRepr::Uninhabited | BackendRepr::Memory { .. } => return None, + BackendRepr::Memory { .. } => return None, }) } @@ -1492,7 +1484,7 @@ impl BackendRepr { // to make the size a multiple of align (e.g. for vectors of size 3). (element.size(cx) * count).align_to(self.inherent_align(cx)?.abi) } - BackendRepr::Uninhabited | BackendRepr::Memory { .. } => return None, + BackendRepr::Memory { .. } => return None, }) } @@ -1506,9 +1498,7 @@ impl BackendRepr { BackendRepr::Vector { element, count } => { BackendRepr::Vector { element: element.to_union(), count } } - BackendRepr::Uninhabited | BackendRepr::Memory { .. } => { - BackendRepr::Memory { sized: true } - } + BackendRepr::Memory { .. } => BackendRepr::Memory { sized: true }, } } @@ -1704,6 +1694,11 @@ pub struct LayoutData<FieldIdx: Idx, VariantIdx: Idx> { /// The leaf scalar with the largest number of invalid values /// (i.e. outside of its `valid_range`), if it exists. pub largest_niche: Option<Niche>, + /// Is this type known to be uninhabted? + /// + /// This is separate from BackendRepr because uninhabited return types can affect ABI, + /// especially in the case of by-pointer struct returns, which allocate stack even when unused. + pub uninhabited: bool, pub align: AbiAndPrefAlign, pub size: Size, @@ -1735,14 +1730,14 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> { /// Returns `true` if this is an aggregate type (including a ScalarPair!) pub fn is_aggregate(&self) -> bool { match self.backend_repr { - BackendRepr::Uninhabited | BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => false, + BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => false, BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => true, } } /// Returns `true` if this is an uninhabited type pub fn is_uninhabited(&self) -> bool { - self.backend_repr.is_uninhabited() + self.uninhabited } pub fn scalar<C: HasDataLayout>(cx: &C, scalar: Scalar) -> Self { @@ -1778,6 +1773,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> { fields: FieldsShape::Primitive, backend_repr: BackendRepr::Scalar(scalar), largest_niche, + uninhabited: false, size, align, max_repr_align: None, @@ -1802,10 +1798,11 @@ where backend_repr, fields, largest_niche, + uninhabited, variants, max_repr_align, unadjusted_abi_align, - ref randomization_seed, + randomization_seed, } = self; f.debug_struct("Layout") .field("size", size) @@ -1813,6 +1810,7 @@ where .field("abi", backend_repr) .field("fields", fields) .field("largest_niche", largest_niche) + .field("uninhabited", uninhabited) .field("variants", variants) .field("max_repr_align", max_repr_align) .field("unadjusted_abi_align", unadjusted_abi_align) @@ -1877,7 +1875,6 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> { BackendRepr::Scalar(_) | BackendRepr::ScalarPair(..) | BackendRepr::Vector { .. } => { false } - BackendRepr::Uninhabited => self.size.bytes() == 0, BackendRepr::Memory { sized } => sized && self.size.bytes() == 0, } } diff --git a/compiler/rustc_arena/Cargo.toml b/compiler/rustc_arena/Cargo.toml index 382ab2b0775..bbcd8ea6d38 100644 --- a/compiler/rustc_arena/Cargo.toml +++ b/compiler/rustc_arena/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_arena" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_ast/Cargo.toml b/compiler/rustc_ast/Cargo.toml index 34c612dac69..902287d0328 100644 --- a/compiler/rustc_ast/Cargo.toml +++ b/compiler/rustc_ast/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_ast" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_ast/src/ast_traits.rs b/compiler/rustc_ast/src/ast_traits.rs index 60f8c6e1048..346edc87c86 100644 --- a/compiler/rustc_ast/src/ast_traits.rs +++ b/compiler/rustc_ast/src/ast_traits.rs @@ -203,10 +203,8 @@ impl HasTokens for Nonterminal { Nonterminal::NtStmt(stmt) => stmt.tokens(), Nonterminal::NtExpr(expr) | Nonterminal::NtLiteral(expr) => expr.tokens(), Nonterminal::NtPat(pat) => pat.tokens(), - Nonterminal::NtTy(ty) => ty.tokens(), Nonterminal::NtMeta(attr_item) => attr_item.tokens(), Nonterminal::NtPath(path) => path.tokens(), - Nonterminal::NtVis(vis) => vis.tokens(), Nonterminal::NtBlock(block) => block.tokens(), } } @@ -216,10 +214,8 @@ impl HasTokens for Nonterminal { Nonterminal::NtStmt(stmt) => stmt.tokens_mut(), Nonterminal::NtExpr(expr) | Nonterminal::NtLiteral(expr) => expr.tokens_mut(), Nonterminal::NtPat(pat) => pat.tokens_mut(), - Nonterminal::NtTy(ty) => ty.tokens_mut(), Nonterminal::NtMeta(attr_item) => attr_item.tokens_mut(), Nonterminal::NtPath(path) => path.tokens_mut(), - Nonterminal::NtVis(vis) => vis.tokens_mut(), Nonterminal::NtBlock(block) => block.tokens_mut(), } } diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index de9f049704a..40b29fdba25 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -907,7 +907,6 @@ fn visit_nonterminal<T: MutVisitor>(vis: &mut T, nt: &mut token::Nonterminal) { }), token::NtPat(pat) => vis.visit_pat(pat), token::NtExpr(expr) => vis.visit_expr(expr), - token::NtTy(ty) => vis.visit_ty(ty), token::NtLiteral(expr) => vis.visit_expr(expr), token::NtMeta(item) => { let AttrItem { unsafety: _, path, args, tokens } = item.deref_mut(); @@ -916,7 +915,6 @@ fn visit_nonterminal<T: MutVisitor>(vis: &mut T, nt: &mut token::Nonterminal) { visit_lazy_tts(vis, tokens); } token::NtPath(path) => vis.visit_path(path), - token::NtVis(visib) => vis.visit_vis(visib), } } diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 36a7b7d8789..97d121909f8 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -84,7 +84,9 @@ pub enum MetaVarKind { // This field is needed for `Token::can_begin_string_literal`. can_begin_string_literal: bool, }, - Ty, + Ty { + is_path: bool, + }, Ident, Lifetime, Literal, @@ -104,7 +106,7 @@ impl fmt::Display for MetaVarKind { MetaVarKind::Pat(PatParam { inferred: false }) => sym::pat_param, MetaVarKind::Expr { kind: Expr2021 { inferred: true } | Expr, .. } => sym::expr, MetaVarKind::Expr { kind: Expr2021 { inferred: false }, .. } => sym::expr_2021, - MetaVarKind::Ty => sym::ty, + MetaVarKind::Ty { .. } => sym::ty, MetaVarKind::Ident => sym::ident, MetaVarKind::Lifetime => sym::lifetime, MetaVarKind::Literal => sym::literal, @@ -659,7 +661,6 @@ impl Token { | NtMeta(..) | NtPat(..) | NtPath(..) - | NtTy(..) ), OpenDelim(Delimiter::Invisible(InvisibleOrigin::MetaVar( MetaVarKind::Expr { .. } | @@ -667,7 +668,7 @@ impl Token { MetaVarKind::Meta | MetaVarKind::Pat(_) | MetaVarKind::Path | - MetaVarKind::Ty + MetaVarKind::Ty { .. } ))) => true, _ => false, } @@ -688,9 +689,9 @@ impl Token { Lifetime(..) | // lifetime bound in trait object Lt | BinOp(Shl) | // associated path PathSep => true, // global path - Interpolated(ref nt) => matches!(&**nt, NtTy(..) | NtPath(..)), + Interpolated(ref nt) => matches!(&**nt, NtPath(..)), OpenDelim(Delimiter::Invisible(InvisibleOrigin::MetaVar( - MetaVarKind::Ty | + MetaVarKind::Ty { .. } | MetaVarKind::Path ))) => true, // For anonymous structs or unions, which only appear in specific positions @@ -969,6 +970,15 @@ impl Token { } } + /// Is this an invisible open delimiter at the start of a token sequence + /// from an expanded metavar? + pub fn is_metavar_seq(&self) -> Option<MetaVarKind> { + match self.kind { + OpenDelim(Delimiter::Invisible(InvisibleOrigin::MetaVar(kind))) => Some(kind), + _ => None, + } + } + pub fn glue(&self, joint: &Token) -> Option<Token> { let kind = match self.kind { Eq => match joint.kind { @@ -1067,12 +1077,10 @@ pub enum Nonterminal { NtStmt(P<ast::Stmt>), NtPat(P<ast::Pat>), NtExpr(P<ast::Expr>), - NtTy(P<ast::Ty>), NtLiteral(P<ast::Expr>), /// Stuff inside brackets for attributes NtMeta(P<ast::AttrItem>), NtPath(P<ast::Path>), - NtVis(P<ast::Visibility>), } #[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable_Generic)] @@ -1166,10 +1174,8 @@ impl Nonterminal { NtStmt(stmt) => stmt.span, NtPat(pat) => pat.span, NtExpr(expr) | NtLiteral(expr) => expr.span, - NtTy(ty) => ty.span, NtMeta(attr_item) => attr_item.span(), NtPath(path) => path.span, - NtVis(vis) => vis.span, } } @@ -1181,10 +1187,8 @@ impl Nonterminal { NtPat(..) => "pattern", NtExpr(..) => "expression", NtLiteral(..) => "literal", - NtTy(..) => "type", NtMeta(..) => "attribute", NtPath(..) => "path", - NtVis(..) => "visibility", } } } @@ -1207,11 +1211,9 @@ impl fmt::Debug for Nonterminal { NtStmt(..) => f.pad("NtStmt(..)"), NtPat(..) => f.pad("NtPat(..)"), NtExpr(..) => f.pad("NtExpr(..)"), - NtTy(..) => f.pad("NtTy(..)"), NtLiteral(..) => f.pad("NtLiteral(..)"), NtMeta(..) => f.pad("NtMeta(..)"), NtPath(..) => f.pad("NtPath(..)"), - NtVis(..) => f.pad("NtVis(..)"), } } } diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 50f10d083a0..1123ea3a449 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -469,10 +469,8 @@ impl TokenStream { } Nonterminal::NtStmt(stmt) => TokenStream::from_ast(stmt), Nonterminal::NtPat(pat) => TokenStream::from_ast(pat), - Nonterminal::NtTy(ty) => TokenStream::from_ast(ty), Nonterminal::NtMeta(attr) => TokenStream::from_ast(attr), Nonterminal::NtPath(path) => TokenStream::from_ast(path), - Nonterminal::NtVis(vis) => TokenStream::from_ast(vis), Nonterminal::NtExpr(expr) | Nonterminal::NtLiteral(expr) => TokenStream::from_ast(expr), } } diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index 3242d414595..1cb32b56875 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -597,7 +597,7 @@ pub fn walk_use_tree<'a, V: Visitor<'a>>( visit_opt!(visitor, visit_ident, rename); } UseTreeKind::Glob => {} - UseTreeKind::Nested { ref items, span: _ } => { + UseTreeKind::Nested { items, span: _ } => { for &(ref nested_tree, nested_id) in items { try_visit!(visitor.visit_use_tree(nested_tree, nested_id, true)); } diff --git a/compiler/rustc_ast_ir/Cargo.toml b/compiler/rustc_ast_ir/Cargo.toml index 1905574073f..f54e9687d8c 100644 --- a/compiler/rustc_ast_ir/Cargo.toml +++ b/compiler/rustc_ast_ir/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_ast_ir" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_ast_lowering/Cargo.toml b/compiler/rustc_ast_lowering/Cargo.toml index ce95f4dfa1b..3215ce6b0cb 100644 --- a/compiler/rustc_ast_lowering/Cargo.toml +++ b/compiler/rustc_ast_lowering/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_ast_lowering" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] doctest = false diff --git a/compiler/rustc_ast_passes/Cargo.toml b/compiler/rustc_ast_passes/Cargo.toml index e4c22753208..c738cb2aa2f 100644 --- a/compiler/rustc_ast_passes/Cargo.toml +++ b/compiler/rustc_ast_passes/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_ast_passes" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_ast_pretty/Cargo.toml b/compiler/rustc_ast_pretty/Cargo.toml index f290fedcd8b..2634dd1fdf9 100644 --- a/compiler/rustc_ast_pretty/Cargo.toml +++ b/compiler/rustc_ast_pretty/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_ast_pretty" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_attr_data_structures/Cargo.toml b/compiler/rustc_attr_data_structures/Cargo.toml index 2ee58f24470..19d0d5a306d 100644 --- a/compiler/rustc_attr_data_structures/Cargo.toml +++ b/compiler/rustc_attr_data_structures/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_attr_data_structures" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_attr_parsing/Cargo.toml b/compiler/rustc_attr_parsing/Cargo.toml index 7ccedf40c3f..f681e9397d9 100644 --- a/compiler/rustc_attr_parsing/Cargo.toml +++ b/compiler/rustc_attr_parsing/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_attr_parsing" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_baked_icu_data/Cargo.toml b/compiler/rustc_baked_icu_data/Cargo.toml index c35556dcf5b..cb0e145386b 100644 --- a/compiler/rustc_baked_icu_data/Cargo.toml +++ b/compiler/rustc_baked_icu_data/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_baked_icu_data" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_borrowck/Cargo.toml b/compiler/rustc_borrowck/Cargo.toml index 89154bf2c23..9e7d55180a2 100644 --- a/compiler/rustc_borrowck/Cargo.toml +++ b/compiler/rustc_borrowck/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_borrowck" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index b2cc58fbe11..94662070db4 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -386,7 +386,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { } } let tcx = self.infcx.tcx; - let hir = self.infcx.tcx.hir(); if let Some(body) = tcx.hir_maybe_body_owned_by(self.mir_def_id()) { let expr = body.value; let place = &self.move_data.move_paths[mpi].place; @@ -402,7 +401,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { if let Some(span) = span && let Some(expr) = finder.expr { - for (_, expr) in hir.parent_iter(expr.hir_id) { + for (_, expr) in tcx.hir_parent_iter(expr.hir_id) { if let hir::Node::Expr(expr) = expr { if expr.span.contains(span) { // If the let binding occurs within the same loop, then that @@ -969,7 +968,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { let mut parent = None; // The top-most loop where the moved expression could be moved to a new binding. let mut outer_most_loop: Option<&hir::Expr<'_>> = None; - for (_, node) in tcx.hir().parent_iter(expr.hir_id) { + for (_, node) in tcx.hir_parent_iter(expr.hir_id) { let e = match node { hir::Node::Expr(e) => e, hir::Node::LetStmt(hir::LetStmt { els: Some(els), .. }) => { @@ -1021,8 +1020,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { } } let loop_count: usize = tcx - .hir() - .parent_iter(expr.hir_id) + .hir_parent_iter(expr.hir_id) .map(|(_, node)| match node { hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Loop(..), .. }) => 1, _ => 0, @@ -1048,8 +1046,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { .collect::<Vec<Span>>(); // All of the spans for the loops above the expression with the move error. let loop_spans: Vec<_> = tcx - .hir() - .parent_iter(expr.hir_id) + .hir_parent_iter(expr.hir_id) .filter_map(|(_, node)| match node { hir::Node::Expr(hir::Expr { span, kind: hir::ExprKind::Loop(..), .. }) => { Some(*span) @@ -1334,7 +1331,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { } fn in_move_closure(&self, expr: &hir::Expr<'_>) -> bool { - for (_, node) in self.infcx.tcx.hir().parent_iter(expr.hir_id) { + for (_, node) in self.infcx.tcx.hir_parent_iter(expr.hir_id) { if let hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(closure), .. }) = node && let hir::CaptureBy::Value { .. } = closure.capture_clause { @@ -2118,7 +2115,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { issued_span: Span, ) { let tcx = self.infcx.tcx; - let hir = tcx.hir(); let has_split_at_mut = |ty: Ty<'tcx>| { let ty = ty.peel_refs(); @@ -2171,7 +2167,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { return; }; - let Some(object) = hir.parent_id_iter(index1.hir_id).find_map(|id| { + let Some(object) = tcx.hir_parent_id_iter(index1.hir_id).find_map(|id| { if let hir::Node::Expr(expr) = tcx.hir_node(id) && let hir::ExprKind::Index(obj, ..) = expr.kind { @@ -2189,7 +2185,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { return; }; - let Some(swap_call) = hir.parent_id_iter(object.hir_id).find_map(|id| { + let Some(swap_call) = tcx.hir_parent_id_iter(object.hir_id).find_map(|id| { if let hir::Node::Expr(call) = tcx.hir_node(id) && let hir::ExprKind::Call(callee, ..) = call.kind && let hir::ExprKind::Path(qpath) = callee.kind @@ -2621,7 +2617,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { if let hir::Pat { kind: hir::PatKind::Binding(_, hir_id, _ident, _), .. } = local.pat && let Some(init) = local.init - && let hir::Expr { + && let &hir::Expr { kind: hir::ExprKind::Closure(&hir::Closure { kind: hir::ClosureKind::Closure, diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index a88b27f2476..f77dda0d386 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -117,7 +117,7 @@ impl<'tcx> BorrowExplanation<'tcx> { let local_decl = &body.local_decls[dropped_local]; if let &LocalInfo::IfThenRescopeTemp { if_then } = local_decl.local_info() - && let Some((_, hir::Node::Expr(expr))) = tcx.hir().parent_iter(if_then).next() + && let Some((_, hir::Node::Expr(expr))) = tcx.hir_parent_iter(if_then).next() && let hir::ExprKind::If(cond, conseq, alt) = expr.kind && let hir::ExprKind::Let(&hir::LetExpr { span: _, @@ -262,7 +262,7 @@ impl<'tcx> BorrowExplanation<'tcx> { fn visit_expr(&mut self, expr: &'hir hir::Expr<'hir>) { if let hir::ExprKind::If(cond, _conseq, _alt) | hir::ExprKind::Loop( - hir::Block { + &hir::Block { expr: Some(&hir::Expr { kind: hir::ExprKind::If(cond, _conseq, _alt), @@ -522,7 +522,7 @@ fn suggest_rewrite_if_let<G: EmissionGuarantee>( ); if expr.span.can_be_used_for_suggestions() && conseq.span.can_be_used_for_suggestions() { let needs_block = if let Some(hir::Node::Expr(expr)) = - alt.and_then(|alt| tcx.hir().parent_iter(alt.hir_id).next()).map(|(_, node)| node) + alt.and_then(|alt| tcx.hir_parent_iter(alt.hir_id).next()).map(|(_, node)| node) { matches!(expr.kind, hir::ExprKind::If(..)) } else { diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index 7da089c5e8c..d1f238331d5 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -1126,7 +1126,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { let hir_id = self.infcx.tcx.local_def_id_to_hir_id(def_id); let expr = &self.infcx.tcx.hir().expect_expr(hir_id).kind; debug!("closure_span: hir_id={:?} expr={:?}", hir_id, expr); - if let hir::ExprKind::Closure(&hir::Closure { kind, fn_decl_span, .. }) = expr { + if let &hir::ExprKind::Closure(&hir::Closure { kind, fn_decl_span, .. }) = expr { for (captured_place, place) in self.infcx.tcx.closure_captures(def_id).iter().zip(places) { diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs index ddf6187a662..5e83d2ffa97 100644 --- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs @@ -388,7 +388,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { // Search for an appropriate place for the structured `.clone()` suggestion to be applied. // If we encounter a statement before the borrow error, we insert a statement there. - for (_, node) in tcx.hir().parent_iter(closure_expr.hir_id) { + for (_, node) in tcx.hir_parent_iter(closure_expr.hir_id) { if let Node::Stmt(stmt) = node { let padding = tcx .sess diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index be83e61f75d..be4a7736b1c 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -404,7 +404,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { pat.kind { if upvar_ident.name == kw::SelfLower { - for (_, node) in self.infcx.tcx.hir().parent_iter(upvar_hir_id) { + for (_, node) in self.infcx.tcx.hir_parent_iter(upvar_hir_id) { if let Some(fn_decl) = node.fn_decl() { if !matches!( fn_decl.implicit_self, @@ -934,7 +934,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { err.span_label(sp, format!("cannot {act}")); let tcx = self.infcx.tcx; - let hir = tcx.hir(); let closure_id = self.mir_hir_id(); let closure_span = tcx.def_span(self.mir_def_id()); let fn_call_id = tcx.parent_hir_id(closure_id); @@ -1017,10 +1016,10 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { } } - if look_at_return && hir.get_fn_id_for_return_block(closure_id).is_some() { + if look_at_return && tcx.hir_get_fn_id_for_return_block(closure_id).is_some() { // ...otherwise we are probably in the tail expression of the function, point at the // return type. - match tcx.hir_node_by_def_id(hir.get_parent_item(fn_call_id).def_id) { + match tcx.hir_node_by_def_id(tcx.hir_get_parent_item(fn_call_id).def_id) { hir::Node::Item(hir::Item { ident, kind: hir::ItemKind::Fn { sig, .. }, .. }) diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index b036e6e950b..be28f84debd 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -671,7 +671,6 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { #[instrument(level = "trace", skip(self))] fn give_name_if_anonymous_region_appears_in_output(&self, fr: RegionVid) -> Option<RegionName> { let tcx = self.infcx.tcx; - let hir = tcx.hir(); let return_ty = self.regioncx.universal_regions().unnormalized_output_ty; debug!("give_name_if_anonymous_region_appears_in_output: return_ty = {:?}", return_ty); @@ -682,7 +681,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { let mir_hir_id = self.mir_hir_id(); let (return_span, mir_description, hir_ty) = match tcx.hir_node(mir_hir_id) { - hir::Node::Expr(hir::Expr { + hir::Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure(&hir::Closure { fn_decl, kind, fn_decl_span, .. }), .. }) => { @@ -711,7 +710,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { hir::CoroutineSource::Fn, )) => { let parent_item = - tcx.hir_node_by_def_id(hir.get_parent_item(mir_hir_id).def_id); + tcx.hir_node_by_def_id(tcx.hir_get_parent_item(mir_hir_id).def_id); let output = &parent_item .fn_decl() .expect("coroutine lowered from async fn should be in fn") @@ -741,7 +740,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { hir::CoroutineSource::Fn, )) => { let parent_item = - tcx.hir_node_by_def_id(hir.get_parent_item(mir_hir_id).def_id); + tcx.hir_node_by_def_id(tcx.hir_get_parent_item(mir_hir_id).def_id); let output = &parent_item .fn_decl() .expect("coroutine lowered from gen fn should be in fn") @@ -768,7 +767,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { hir::CoroutineSource::Fn, )) => { let parent_item = - tcx.hir_node_by_def_id(hir.get_parent_item(mir_hir_id).def_id); + tcx.hir_node_by_def_id(tcx.hir_get_parent_item(mir_hir_id).def_id); let output = &parent_item .fn_decl() .expect("coroutine lowered from async gen fn should be in fn") @@ -874,7 +873,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { .name; let yield_span = match tcx.hir_node(self.mir_hir_id()) { - hir::Node::Expr(hir::Expr { + hir::Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure(&hir::Closure { fn_decl_span, .. }), .. }) => tcx.sess.source_map().end_point(fn_decl_span), diff --git a/compiler/rustc_borrowck/src/polonius/dump.rs b/compiler/rustc_borrowck/src/polonius/dump.rs index 5f9fa3612b8..aa64a7c4e2a 100644 --- a/compiler/rustc_borrowck/src/polonius/dump.rs +++ b/compiler/rustc_borrowck/src/polonius/dump.rs @@ -226,7 +226,7 @@ fn emit_polonius_mir<'tcx>( regioncx, closure_region_requirements, borrow_set, - pass_where.clone(), + pass_where, out, )?; diff --git a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs index 148e75aa84c..12e8be41614 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs @@ -613,9 +613,14 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> { // types, so there's no guarantee that it succeeds. We also // can't rely on the the `ErrorGuaranteed` from `fully_perform` here // because it comes from delay_span_bug. - let ocx = ObligationCtxt::new_with_diagnostics(&typeck.infcx); - let errors = - match dropck_outlives::compute_dropck_outlives_with_errors(&ocx, op, span) { + // + // Do this inside of a probe because we don't particularly care (or want) + // any region side-effects of this operation in our infcx. + typeck.infcx.probe(|_| { + let ocx = ObligationCtxt::new_with_diagnostics(&typeck.infcx); + let errors = match dropck_outlives::compute_dropck_outlives_with_errors( + &ocx, op, span, + ) { Ok(_) => ocx.select_all_or_error(), Err(e) => { if e.is_empty() { @@ -626,11 +631,12 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> { } }; - if !errors.is_empty() { - typeck.infcx.err_ctxt().report_fulfillment_errors(errors); - } else { - span_bug!(span, "Rerunning drop data query produced no error."); - } + if !errors.is_empty() { + typeck.infcx.err_ctxt().report_fulfillment_errors(errors); + } else { + span_bug!(span, "Rerunning drop data query produced no error."); + } + }); DropData { dropck_result: Default::default(), region_constraint_data: None } } } diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index 9a68eeb3326..c578eb4dc45 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -308,7 +308,7 @@ impl<'tcx> UniversalRegions<'tcx> { /// Returns an iterator over all the RegionVids corresponding to /// universally quantified free regions. - pub(crate) fn universal_regions_iter(&self) -> impl Iterator<Item = RegionVid> { + pub(crate) fn universal_regions_iter(&self) -> impl Iterator<Item = RegionVid> + use<> { (FIRST_GLOBAL_INDEX..self.num_universals).map(RegionVid::from_usize) } diff --git a/compiler/rustc_builtin_macros/Cargo.toml b/compiler/rustc_builtin_macros/Cargo.toml index b50cb35b8e9..f29be2ee818 100644 --- a/compiler/rustc_builtin_macros/Cargo.toml +++ b/compiler/rustc_builtin_macros/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_builtin_macros" version = "0.0.0" -edition = "2021" +edition = "2024" [lints.rust] diff --git a/compiler/rustc_codegen_cranelift/src/value_and_place.rs b/compiler/rustc_codegen_cranelift/src/value_and_place.rs index a9b8e1bd393..1b3f86c8405 100644 --- a/compiler/rustc_codegen_cranelift/src/value_and_place.rs +++ b/compiler/rustc_codegen_cranelift/src/value_and_place.rs @@ -638,9 +638,7 @@ impl<'tcx> CPlace<'tcx> { } CPlaceInner::Addr(_, Some(_)) => bug!("Can't write value to unsized place {:?}", self), CPlaceInner::Addr(to_ptr, None) => { - if dst_layout.size == Size::ZERO - || dst_layout.backend_repr == BackendRepr::Uninhabited - { + if dst_layout.size == Size::ZERO { return; } diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs index 5322b731d8b..433868e238a 100644 --- a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs +++ b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs @@ -315,7 +315,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc let layout = self.layout_of(tp_ty).layout; let _use_integer_compare = match layout.backend_repr() { Scalar(_) | ScalarPair(_, _) => true, - Uninhabited | Vector { .. } => false, + Vector { .. } => false, Memory { .. } => { // For rusty ABIs, small aggregates are actually passed // as `RegKind::Integer` (see `FnAbi::adjust_for_abi`), diff --git a/compiler/rustc_codegen_gcc/src/type_of.rs b/compiler/rustc_codegen_gcc/src/type_of.rs index 8b8b54753e7..bac4fc51300 100644 --- a/compiler/rustc_codegen_gcc/src/type_of.rs +++ b/compiler/rustc_codegen_gcc/src/type_of.rs @@ -84,7 +84,7 @@ fn uncached_gcc_type<'gcc, 'tcx>( false, ); } - BackendRepr::Uninhabited | BackendRepr::Memory { .. } => {} + BackendRepr::Memory { .. } => {} } let name = match *layout.ty.kind() { @@ -179,19 +179,16 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> { fn is_gcc_immediate(&self) -> bool { match self.backend_repr { BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => true, - BackendRepr::ScalarPair(..) | BackendRepr::Uninhabited | BackendRepr::Memory { .. } => { - false - } + BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => false, } } fn is_gcc_scalar_pair(&self) -> bool { match self.backend_repr { BackendRepr::ScalarPair(..) => true, - BackendRepr::Uninhabited - | BackendRepr::Scalar(_) - | BackendRepr::Vector { .. } - | BackendRepr::Memory { .. } => false, + BackendRepr::Scalar(_) | BackendRepr::Vector { .. } | BackendRepr::Memory { .. } => { + false + } } } diff --git a/compiler/rustc_codegen_llvm/Cargo.toml b/compiler/rustc_codegen_llvm/Cargo.toml index a8172270548..d3ce7c5a113 100644 --- a/compiler/rustc_codegen_llvm/Cargo.toml +++ b/compiler/rustc_codegen_llvm/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_codegen_llvm" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] test = false diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs index 7262fce4911..3e25b94961b 100644 --- a/compiler/rustc_codegen_llvm/src/back/lto.rs +++ b/compiler/rustc_codegen_llvm/src/back/lto.rs @@ -362,8 +362,8 @@ fn fat_lto( ptr as *const *const libc::c_char, symbols_below_threshold.len() as libc::size_t, ); - save_temp_bitcode(cgcx, &module, "lto.after-restriction"); } + save_temp_bitcode(cgcx, &module, "lto.after-restriction"); } Ok(LtoModuleCodegen::Fat(module)) diff --git a/compiler/rustc_codegen_llvm/src/callee.rs b/compiler/rustc_codegen_llvm/src/callee.rs index aa9a0f34f55..ea9ab5c02bd 100644 --- a/compiler/rustc_codegen_llvm/src/callee.rs +++ b/compiler/rustc_codegen_llvm/src/callee.rs @@ -66,9 +66,7 @@ pub(crate) fn get_fn<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'t // LLVM will prefix the name with `__imp_`. Ideally, we'd like the // existing logic below to set the Storage Class, but it has an // exemption for MinGW for backwards compatibility. - unsafe { - llvm::LLVMSetDLLStorageClass(llfn, llvm::DLLStorageClass::DllImport); - } + llvm::set_dllimport_storage_class(llfn); llfn } else { cx.declare_fn(sym, fn_abi, Some(instance)) @@ -99,65 +97,61 @@ pub(crate) fn get_fn<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'t // has been applied to the definition (wherever that definition may be). llvm::set_linkage(llfn, llvm::Linkage::ExternalLinkage); - unsafe { - let is_generic = instance.args.non_erasable_generics().next().is_some(); - - let is_hidden = if is_generic { - // This is a monomorphization of a generic function. - if !(cx.tcx.sess.opts.share_generics() - || tcx.codegen_fn_attrs(instance_def_id).inline - == rustc_attr_parsing::InlineAttr::Never) - { - // When not sharing generics, all instances are in the same - // crate and have hidden visibility. - true - } else { - if let Some(instance_def_id) = instance_def_id.as_local() { - // This is a monomorphization of a generic function - // defined in the current crate. It is hidden if: - // - the definition is unreachable for downstream - // crates, or - // - the current crate does not re-export generics - // (because the crate is a C library or executable) - cx.tcx.is_unreachable_local_definition(instance_def_id) - || !cx.tcx.local_crate_exports_generics() - } else { - // This is a monomorphization of a generic function - // defined in an upstream crate. It is hidden if: - // - it is instantiated in this crate, and - // - the current crate does not re-export generics - instance.upstream_monomorphization(tcx).is_none() - && !cx.tcx.local_crate_exports_generics() - } - } - } else { - // This is a non-generic function. It is hidden if: - // - it is instantiated in the local crate, and - // - it is defined an upstream crate (non-local), or - // - it is not reachable - cx.tcx.is_codegened_item(instance_def_id) - && (!instance_def_id.is_local() - || !cx.tcx.is_reachable_non_generic(instance_def_id)) - }; - if is_hidden { - llvm::set_visibility(llfn, llvm::Visibility::Hidden); - } + let is_generic = instance.args.non_erasable_generics().next().is_some(); - // MinGW: For backward compatibility we rely on the linker to decide whether it - // should use dllimport for functions. - if cx.use_dll_storage_attrs - && let Some(library) = tcx.native_library(instance_def_id) - && library.kind.is_dllimport() - && !matches!(tcx.sess.target.env.as_ref(), "gnu" | "uclibc") + let is_hidden = if is_generic { + // This is a monomorphization of a generic function. + if !(cx.tcx.sess.opts.share_generics() + || tcx.codegen_fn_attrs(instance_def_id).inline + == rustc_attr_parsing::InlineAttr::Never) { - llvm::LLVMSetDLLStorageClass(llfn, llvm::DLLStorageClass::DllImport); + // When not sharing generics, all instances are in the same + // crate and have hidden visibility. + true + } else { + if let Some(instance_def_id) = instance_def_id.as_local() { + // This is a monomorphization of a generic function + // defined in the current crate. It is hidden if: + // - the definition is unreachable for downstream + // crates, or + // - the current crate does not re-export generics + // (because the crate is a C library or executable) + cx.tcx.is_unreachable_local_definition(instance_def_id) + || !cx.tcx.local_crate_exports_generics() + } else { + // This is a monomorphization of a generic function + // defined in an upstream crate. It is hidden if: + // - it is instantiated in this crate, and + // - the current crate does not re-export generics + instance.upstream_monomorphization(tcx).is_none() + && !cx.tcx.local_crate_exports_generics() + } } + } else { + // This is a non-generic function. It is hidden if: + // - it is instantiated in the local crate, and + // - it is defined an upstream crate (non-local), or + // - it is not reachable + cx.tcx.is_codegened_item(instance_def_id) + && (!instance_def_id.is_local() + || !cx.tcx.is_reachable_non_generic(instance_def_id)) + }; + if is_hidden { + llvm::set_visibility(llfn, llvm::Visibility::Hidden); + } - if cx.should_assume_dso_local(llfn, true) { - llvm::LLVMRustSetDSOLocal(llfn, true); - } + // MinGW: For backward compatibility we rely on the linker to decide whether it + // should use dllimport for functions. + if cx.use_dll_storage_attrs + && let Some(library) = tcx.native_library(instance_def_id) + && library.kind.is_dllimport() + && !matches!(tcx.sess.target.env.as_ref(), "gnu" | "uclibc") + { + llvm::set_dllimport_storage_class(llfn); } + cx.assume_dso_local(llfn, true); + llfn }; diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index 4a5491ec7a1..330e8a8f406 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -336,12 +336,7 @@ impl<'ll> CodegenCx<'ll, '_> { llvm::set_thread_local_mode(g, self.tls_model); } - let dso_local = self.should_assume_dso_local(g, true); - if dso_local { - unsafe { - llvm::LLVMRustSetDSOLocal(g, true); - } - } + let dso_local = self.assume_dso_local(g, true); if !def_id.is_local() { let needs_dll_storage_attr = self.use_dll_storage_attrs @@ -375,9 +370,7 @@ impl<'ll> CodegenCx<'ll, '_> { // is actually present in the current crate. We can find out via the // is_codegened_item query. if !self.tcx.is_codegened_item(def_id) { - unsafe { - llvm::LLVMSetDLLStorageClass(g, llvm::DLLStorageClass::DllImport); - } + llvm::set_dllimport_storage_class(g); } } } @@ -387,9 +380,7 @@ impl<'ll> CodegenCx<'ll, '_> { && library.kind.is_dllimport() { // For foreign (native) libs we know the exact storage type to use. - unsafe { - llvm::LLVMSetDLLStorageClass(g, llvm::DLLStorageClass::DllImport); - } + llvm::set_dllimport_storage_class(g); } self.instances.borrow_mut().insert(instance, g); @@ -460,9 +451,7 @@ impl<'ll> CodegenCx<'ll, '_> { set_global_alignment(self, g, alloc.align); llvm::set_initializer(g, v); - if self.should_assume_dso_local(g, true) { - llvm::LLVMRustSetDSOLocal(g, true); - } + self.assume_dso_local(g, true); // Forward the allocation's mutability (picked by the const interner) to LLVM. if alloc.mutability.is_not() { diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 7e1a9d361e6..f68365f6c69 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -476,7 +476,7 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { let layout = self.layout_of(tp_ty).layout; let use_integer_compare = match layout.backend_repr() { Scalar(_) | ScalarPair(_, _) => true, - Uninhabited | Vector { .. } => false, + Vector { .. } => false, Memory { .. } => { // For rusty ABIs, small aggregates are actually passed // as `RegKind::Integer` (see `FnAbi::adjust_for_abi`), diff --git a/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs index 39bac13a968..9c740ab9868 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs @@ -7,7 +7,7 @@ use super::ffi::{BasicBlock, Metadata, Module, Type, Value}; use crate::llvm::Bool; #[link(name = "llvm-wrapper", kind = "static")] -extern "C" { +unsafe extern "C" { // Enzyme pub(crate) fn LLVMRustHasMetadata(I: &Value, KindID: c_uint) -> bool; pub(crate) fn LLVMRustEraseInstUntilInclusive(BB: &BasicBlock, I: &Value); @@ -18,7 +18,7 @@ extern "C" { pub(crate) fn LLVMRustVerifyFunction(V: &Value, action: LLVMRustVerifierFailureAction) -> Bool; } -extern "C" { +unsafe extern "C" { // Enzyme pub(crate) fn LLVMDumpModule(M: &Module); pub(crate) fn LLVMDumpValue(V: &Value); diff --git a/compiler/rustc_codegen_llvm/src/llvm/mod.rs b/compiler/rustc_codegen_llvm/src/llvm/mod.rs index efc9cf2ef69..5ec93424131 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/mod.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/mod.rs @@ -403,3 +403,15 @@ pub(crate) fn add_module_flag_str( ); } } + +pub(crate) fn set_dllimport_storage_class<'ll>(v: &'ll Value) { + unsafe { + LLVMSetDLLStorageClass(v, DLLStorageClass::DllImport); + } +} + +pub(crate) fn set_dso_local<'ll>(v: &'ll Value) { + unsafe { + LLVMRustSetDSOLocal(v, true); + } +} diff --git a/compiler/rustc_codegen_llvm/src/mono_item.rs b/compiler/rustc_codegen_llvm/src/mono_item.rs index 70edee21bd6..a64627eaf59 100644 --- a/compiler/rustc_codegen_llvm/src/mono_item.rs +++ b/compiler/rustc_codegen_llvm/src/mono_item.rs @@ -38,11 +38,7 @@ impl<'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> { llvm::set_linkage(g, base::linkage_to_llvm(linkage)); llvm::set_visibility(g, base::visibility_to_llvm(visibility)); - unsafe { - if self.should_assume_dso_local(g, false) { - llvm::LLVMRustSetDSOLocal(g, true); - } - } + self.assume_dso_local(g, false); self.instances.borrow_mut().insert(instance, g); } @@ -79,9 +75,7 @@ impl<'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> { debug!("predefine_fn: instance = {:?}", instance); - if self.should_assume_dso_local(lldecl, false) { - unsafe { llvm::LLVMRustSetDSOLocal(lldecl, true) }; - } + self.assume_dso_local(lldecl, false); self.instances.borrow_mut().insert(instance, lldecl); } @@ -90,11 +84,16 @@ impl<'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> { impl CodegenCx<'_, '_> { /// Whether a definition or declaration can be assumed to be local to a group of /// libraries that form a single DSO or executable. - pub(crate) fn should_assume_dso_local( - &self, - llval: &llvm::Value, - is_declaration: bool, - ) -> bool { + /// Marks the local as DSO if so. + pub(crate) fn assume_dso_local(&self, llval: &llvm::Value, is_declaration: bool) -> bool { + let assume = self.should_assume_dso_local(llval, is_declaration); + if assume { + llvm::set_dso_local(llval); + } + assume + } + + fn should_assume_dso_local(&self, llval: &llvm::Value, is_declaration: bool) -> bool { let linkage = llvm::get_linkage(llval); let visibility = llvm::get_visibility(llval); diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs index b0b6da869da..ba01fbff385 100644 --- a/compiler/rustc_codegen_llvm/src/type_of.rs +++ b/compiler/rustc_codegen_llvm/src/type_of.rs @@ -23,7 +23,7 @@ fn uncached_llvm_type<'a, 'tcx>( let element = layout.scalar_llvm_type_at(cx, element); return cx.type_vector(element, count); } - BackendRepr::Uninhabited | BackendRepr::Memory { .. } | BackendRepr::ScalarPair(..) => {} + BackendRepr::Memory { .. } | BackendRepr::ScalarPair(..) => {} } let name = match layout.ty.kind() { @@ -172,19 +172,16 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { fn is_llvm_immediate(&self) -> bool { match self.backend_repr { BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => true, - BackendRepr::ScalarPair(..) | BackendRepr::Uninhabited | BackendRepr::Memory { .. } => { - false - } + BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => false, } } fn is_llvm_scalar_pair(&self) -> bool { match self.backend_repr { BackendRepr::ScalarPair(..) => true, - BackendRepr::Uninhabited - | BackendRepr::Scalar(_) - | BackendRepr::Vector { .. } - | BackendRepr::Memory { .. } => false, + BackendRepr::Scalar(_) | BackendRepr::Vector { .. } | BackendRepr::Memory { .. } => { + false + } } } diff --git a/compiler/rustc_codegen_ssa/Cargo.toml b/compiler/rustc_codegen_ssa/Cargo.toml index 963d9258be6..83d847f2d15 100644 --- a/compiler/rustc_codegen_ssa/Cargo.toml +++ b/compiler/rustc_codegen_ssa/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_codegen_ssa" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 105a4cb81f0..a8d917f0fdb 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1990,6 +1990,7 @@ fn add_pre_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) if let Some(args) = sess.target.pre_link_args.get(&flavor) { cmd.verbatim_args(args.iter().map(Deref::deref)); } + cmd.verbatim_args(&sess.opts.unstable_opts.pre_link_args); } @@ -2518,6 +2519,12 @@ fn add_order_independent_options( "--target-cpu", &codegen_results.crate_info.target_cpu, ]); + if codegen_results.crate_info.target_features.len() > 0 { + cmd.link_arg(&format!( + "--target-feature={}", + &codegen_results.crate_info.target_features.join(",") + )); + } } else if flavor == LinkerFlavor::Ptx { cmd.link_args(&["--fallback-arch", &codegen_results.crate_info.target_cpu]); } else if flavor == LinkerFlavor::Bpf { diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index e3ace01c1eb..8900405c1b8 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -153,6 +153,7 @@ pub(crate) fn get_linker<'a>( hinted_static: None, is_ld: cc == Cc::No, is_gnu: flavor.is_gnu(), + uses_lld: flavor.uses_lld(), }) as Box<dyn Linker>, LinkerFlavor::Msvc(..) => Box::new(MsvcLinker { cmd, sess }) as Box<dyn Linker>, LinkerFlavor::EmCc => Box::new(EmLinker { cmd, sess }) as Box<dyn Linker>, @@ -361,6 +362,7 @@ struct GccLinker<'a> { // Link as ld is_ld: bool, is_gnu: bool, + uses_lld: bool, } impl<'a> GccLinker<'a> { @@ -552,6 +554,7 @@ impl<'a> Linker for GccLinker<'a> { self.link_args(&["--entry", "_initialize"]); } } + // VxWorks compiler driver introduced `--static-crt` flag specifically for rustc, // it switches linking for libc and similar system libraries to static without using // any `#[link]` attributes in the `libc` crate, see #72782 for details. @@ -567,6 +570,15 @@ impl<'a> Linker for GccLinker<'a> { { self.cc_arg("--static-crt"); } + + // avr-none doesn't have default ISA, users must specify which specific + // CPU (well, microcontroller) they are targetting using `-Ctarget-cpu`. + // + // Currently this makes sense only when using avr-gcc as a linker, since + // it brings a couple of hand-written important intrinsics from libgcc. + if self.sess.target.arch == "avr" && !self.uses_lld { + self.verbatim_arg(format!("-mmcu={}", self.target_cpu)); + } } fn link_dylib_by_name(&mut self, name: &str, verbatim: bool, as_needed: bool) { diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index 12ee872d531..459f4329d6e 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -183,11 +183,11 @@ fn exported_symbols_provider_local( }); let mut symbols: Vec<_> = - sorted.iter().map(|(&def_id, &info)| (ExportedSymbol::NonGeneric(def_id), info)).collect(); + sorted.iter().map(|&(&def_id, &info)| (ExportedSymbol::NonGeneric(def_id), info)).collect(); // Export TLS shims if !tcx.sess.target.dll_tls_export { - symbols.extend(sorted.iter().filter_map(|(&def_id, &info)| { + symbols.extend(sorted.iter().filter_map(|&(&def_id, &info)| { tcx.needs_thread_local_shim(def_id).then(|| { ( ExportedSymbol::ThreadLocalShim(def_id), diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index a989e9c64c0..40238f4b491 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -915,6 +915,7 @@ impl CrateInfo { let n_crates = crates.len(); let mut info = CrateInfo { target_cpu, + target_features: tcx.global_backend_features(()).clone(), crate_types, exported_symbols, linked_symbols, diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs index 3e9dfcea58b..286e5e17908 100644 --- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs +++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs @@ -894,7 +894,7 @@ fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> Option<AutoDiffAttrs> { let [mode, input_activities @ .., ret_activity] = &list[..] else { span_bug!(attr.span, "rustc_autodiff attribute must contain mode and activities"); }; - let mode = if let MetaItemInner::MetaItem(MetaItem { path: ref p1, .. }) = mode { + let mode = if let MetaItemInner::MetaItem(MetaItem { path: p1, .. }) = mode { p1.segments.first().unwrap().ident } else { span_bug!(attr.span, "rustc_autodiff attribute must contain mode"); @@ -910,7 +910,7 @@ fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> Option<AutoDiffAttrs> { }; // First read the ret symbol from the attribute - let ret_symbol = if let MetaItemInner::MetaItem(MetaItem { path: ref p1, .. }) = ret_activity { + let ret_symbol = if let MetaItemInner::MetaItem(MetaItem { path: p1, .. }) = ret_activity { p1.segments.first().unwrap().ident } else { span_bug!(attr.span, "rustc_autodiff attribute must contain the return activity"); @@ -924,7 +924,7 @@ fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> Option<AutoDiffAttrs> { // Now parse all the intermediate (input) activities let mut arg_activities: Vec<DiffActivity> = vec![]; for arg in input_activities { - let arg_symbol = if let MetaItemInner::MetaItem(MetaItem { path: ref p2, .. }) = arg { + let arg_symbol = if let MetaItemInner::MetaItem(MetaItem { path: p2, .. }) = arg { match p2.segments.first() { Some(x) => x.ident, None => { diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs index 428a45975f1..9d2ac219d59 100644 --- a/compiler/rustc_codegen_ssa/src/lib.rs +++ b/compiler/rustc_codegen_ssa/src/lib.rs @@ -190,6 +190,7 @@ impl From<&cstore::NativeLib> for NativeLib { #[derive(Debug, Encodable, Decodable)] pub struct CrateInfo { pub target_cpu: String, + pub target_features: Vec<String>, pub crate_types: Vec<CrateType>, pub exported_symbols: UnordMap<CrateType, Vec<String>>, pub linked_symbols: FxIndexMap<CrateType, Vec<(String, SymbolExportKind)>>, @@ -230,6 +231,7 @@ pub fn provide(providers: &mut Providers) { crate::base::provide(providers); crate::target_features::provide(providers); crate::codegen_attrs::provide(providers); + providers.queries.global_backend_features = |_tcx: TyCtxt<'_>, ()| vec![]; } /// Checks if the given filename ends with the `.rcgu.o` extension that `rustc` diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index 0620f08fc73..676a241c74b 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -4,9 +4,7 @@ use rustc_abi::{BackendRepr, ExternAbi, HasDataLayout, Reg, WrappingRange}; use rustc_ast as ast; use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; use rustc_hir::lang_items::LangItem; -use rustc_middle::mir::{ - self, AssertKind, BasicBlock, InlineAsmMacro, SwitchTargets, UnwindTerminateReason, -}; +use rustc_middle::mir::{self, AssertKind, InlineAsmMacro, SwitchTargets, UnwindTerminateReason}; use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, ValidityRequirement}; use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths}; use rustc_middle::ty::{self, Instance, Ty}; @@ -722,14 +720,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // Put together the arguments to the panic entry point. let (lang_item, args) = match msg { - AssertKind::BoundsCheck { ref len, ref index } => { + AssertKind::BoundsCheck { len, index } => { let len = self.codegen_operand(bx, len).immediate(); let index = self.codegen_operand(bx, index).immediate(); // It's `fn panic_bounds_check(index: usize, len: usize)`, // and `#[track_caller]` adds an implicit third argument. (LangItem::PanicBoundsCheck, vec![index, len, location]) } - AssertKind::MisalignedPointerDereference { ref required, ref found } => { + AssertKind::MisalignedPointerDereference { required, found } => { let required = self.codegen_operand(bx, required).immediate(); let found = self.codegen_operand(bx, found).immediate(); // It's `fn panic_misaligned_pointer_dereference(required: usize, found: usize)`, @@ -942,7 +940,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { &fn_abi.ret, &mut llargs, Some(intrinsic), - target, ); let dest = match ret_dest { _ if fn_abi.ret.is_indirect() => llargs[0], @@ -998,19 +995,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { }; let mut llargs = Vec::with_capacity(arg_count); - let destination = target.as_ref().map(|&target| { - ( - self.make_return_dest( - bx, - destination, - &fn_abi.ret, - &mut llargs, - None, - Some(target), - ), - target, - ) - }); + + // We still need to call `make_return_dest` even if there's no `target`, since + // `fn_abi.ret` could be `PassMode::Indirect`, even if it is uninhabited, + // and `make_return_dest` adds the return-place indirect pointer to `llargs`. + let return_dest = self.make_return_dest(bx, destination, &fn_abi.ret, &mut llargs, None); + let destination = target.map(|target| (return_dest, target)); // Split the rust-call tupled arguments off. let (first_args, untuple) = if abi == ExternAbi::RustCall && !args.is_empty() { @@ -1813,11 +1803,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { fn_ret: &ArgAbi<'tcx, Ty<'tcx>>, llargs: &mut Vec<Bx::Value>, intrinsic: Option<ty::IntrinsicDef>, - target: Option<BasicBlock>, ) -> ReturnDest<'tcx, Bx::Value> { - if target.is_none() { - return ReturnDest::Nothing; - } // If the return is ignored, we can just return a do-nothing `ReturnDest`. if fn_ret.is_ignore() { return ReturnDest::Nothing; diff --git a/compiler/rustc_codegen_ssa/src/mir/operand.rs b/compiler/rustc_codegen_ssa/src/mir/operand.rs index 958a52a2cb1..461cf1b8acd 100644 --- a/compiler/rustc_codegen_ssa/src/mir/operand.rs +++ b/compiler/rustc_codegen_ssa/src/mir/operand.rs @@ -358,19 +358,33 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { let field = self.layout.field(bx.cx(), i); let offset = self.layout.fields.offset(i); - let val = if field.is_zst() { - OperandValue::ZeroSized - } else if field.size == self.layout.size { - assert_eq!(offset.bytes(), 0); - if let Some(field_val) = fx.codegen_transmute_operand(bx, *self, field) { - field_val - } else { - // we have to go through memory for things like + if !bx.is_backend_ref(self.layout) && bx.is_backend_ref(field) { + if let BackendRepr::Vector { count, .. } = self.layout.backend_repr + && let BackendRepr::Memory { sized: true } = field.backend_repr + && count.is_power_of_two() + { + assert_eq!(field.size, self.layout.size); + // This is being deprecated, but for now stdarch still needs it for // Newtype vector of array, e.g. #[repr(simd)] struct S([i32; 4]); let place = PlaceRef::alloca(bx, field); self.val.store(bx, place.val.with_type(self.layout)); - bx.load_operand(place).val + return bx.load_operand(place); + } else { + // Part of https://github.com/rust-lang/compiler-team/issues/838 + bug!("Non-ref type {self:?} cannot project to ref field type {field:?}"); } + } + + let val = if field.is_zst() { + OperandValue::ZeroSized + } else if field.size == self.layout.size { + assert_eq!(offset.bytes(), 0); + fx.codegen_transmute_operand(bx, *self, field).unwrap_or_else(|| { + bug!( + "Expected `codegen_transmute_operand` to handle equal-size \ + field {i:?} projection from {self:?} to {field:?}" + ) + }) } else { let (in_scalar, imm) = match (self.val, self.layout.backend_repr) { // Extract a scalar component from a pair. @@ -385,11 +399,6 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { } } - // `#[repr(simd)]` types are also immediate. - (OperandValue::Immediate(llval), BackendRepr::Vector { .. }) => { - (None, bx.extract_element(llval, bx.cx().const_usize(i as u64))) - } - _ => { span_bug!(fx.mir.span, "OperandRef::extract_field({:?}): not applicable", self) } @@ -415,16 +424,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { imm } } - BackendRepr::Memory { sized: true } => { - span_bug!( - fx.mir.span, - "Projecting into a simd type with padding doesn't work; \ - See <https://github.com/rust-lang/rust/issues/137108>", - ); - } - BackendRepr::Uninhabited - | BackendRepr::ScalarPair(_, _) - | BackendRepr::Memory { sized: false } => bug!(), + BackendRepr::ScalarPair(_, _) | BackendRepr::Memory { .. } => bug!(), }) }; @@ -584,7 +584,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // Moves out of scalar and scalar pair fields are trivial. for elem in place_ref.projection.iter() { match elem { - mir::ProjectionElem::Field(ref f, _) => { + mir::ProjectionElem::Field(f, _) => { assert!( !o.layout.ty.is_any_ptr(), "Bad PlaceRef: destructing pointers should use cast/PtrMetadata, \ diff --git a/compiler/rustc_const_eval/Cargo.toml b/compiler/rustc_const_eval/Cargo.toml index 7717cd2c696..a0cc2c65e6e 100644 --- a/compiler/rustc_const_eval/Cargo.toml +++ b/compiler/rustc_const_eval/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_const_eval" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index 82e0a6e6666..4db862afd9f 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -502,12 +502,10 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> { RemainderByZero(op) => RemainderByZero(eval_to_int(op)?), ResumedAfterReturn(coroutine_kind) => ResumedAfterReturn(*coroutine_kind), ResumedAfterPanic(coroutine_kind) => ResumedAfterPanic(*coroutine_kind), - MisalignedPointerDereference { ref required, ref found } => { - MisalignedPointerDereference { - required: eval_to_int(required)?, - found: eval_to_int(found)?, - } - } + MisalignedPointerDereference { required, found } => MisalignedPointerDereference { + required: eval_to_int(required)?, + found: eval_to_int(found)?, + }, NullPointerDereference => NullPointerDereference, }; Err(ConstEvalErrKind::AssertFailure(err)).into() diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs index 5d905cff1f2..36da9037e43 100644 --- a/compiler/rustc_const_eval/src/interpret/operand.rs +++ b/compiler/rustc_const_eval/src/interpret/operand.rs @@ -385,7 +385,7 @@ impl<'tcx, Prov: Provenance> ImmTy<'tcx, Prov> { (Immediate::Uninit, _) => Immediate::Uninit, // If the field is uninhabited, we can forget the data (can happen in ConstProp). // `enum S { A(!), B, C }` is an example of an enum with Scalar layout that - // has an `Uninhabited` variant, which means this case is possible. + // has an uninhabited variant, which means this case is possible. _ if layout.is_uninhabited() => Immediate::Uninit, // the field contains no information, can be left uninit // (Scalar/ScalarPair can contain even aligned ZST, not just 1-ZST) diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index 0ac34f4633b..40dec0cb39e 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -1264,21 +1264,20 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValueVisitor<'tcx, M> for ValidityVisitor<'rt, } } - // *After* all of this, check the ABI. We need to check the ABI to handle - // types like `NonNull` where the `Scalar` info is more restrictive than what - // the fields say (`rustc_layout_scalar_valid_range_start`). - // But in most cases, this will just propagate what the fields say, - // and then we want the error to point at the field -- so, first recurse, - // then check ABI. + // *After* all of this, check further information stored in the layout. We need to check + // this to handle types like `NonNull` where the `Scalar` info is more restrictive than what + // the fields say (`rustc_layout_scalar_valid_range_start`). But in most cases, this will + // just propagate what the fields say, and then we want the error to point at the field -- + // so, we first recurse, then we do this check. // // FIXME: We could avoid some redundant checks here. For newtypes wrapping // scalars, we do the same check on every "level" (e.g., first we check // MyNewtype and then the scalar in there). + if val.layout.is_uninhabited() { + let ty = val.layout.ty; + throw_validation_failure!(self.path, UninhabitedVal { ty }); + } match val.layout.backend_repr { - BackendRepr::Uninhabited => { - let ty = val.layout.ty; - throw_validation_failure!(self.path, UninhabitedVal { ty }); - } BackendRepr::Scalar(scalar_layout) => { if !scalar_layout.is_uninit_valid() { // There is something to check here. diff --git a/compiler/rustc_const_eval/src/util/check_validity_requirement.rs b/compiler/rustc_const_eval/src/util/check_validity_requirement.rs index 79baf91c3ce..6426bca2332 100644 --- a/compiler/rustc_const_eval/src/util/check_validity_requirement.rs +++ b/compiler/rustc_const_eval/src/util/check_validity_requirement.rs @@ -111,13 +111,15 @@ fn check_validity_requirement_lax<'tcx>( }; // Check the ABI. - let valid = match this.backend_repr { - BackendRepr::Uninhabited => false, // definitely UB - BackendRepr::Scalar(s) => scalar_allows_raw_init(s), - BackendRepr::ScalarPair(s1, s2) => scalar_allows_raw_init(s1) && scalar_allows_raw_init(s2), - BackendRepr::Vector { element: s, count } => count == 0 || scalar_allows_raw_init(s), - BackendRepr::Memory { .. } => true, // Fields are checked below. - }; + let valid = !this.is_uninhabited() // definitely UB if uninhabited + && match this.backend_repr { + BackendRepr::Scalar(s) => scalar_allows_raw_init(s), + BackendRepr::ScalarPair(s1, s2) => { + scalar_allows_raw_init(s1) && scalar_allows_raw_init(s2) + } + BackendRepr::Vector { element: s, count } => count == 0 || scalar_allows_raw_init(s), + BackendRepr::Memory { .. } => true, // Fields are checked below. + }; if !valid { // This is definitely not okay. return Ok(false); diff --git a/compiler/rustc_data_structures/Cargo.toml b/compiler/rustc_data_structures/Cargo.toml index 1705af1e210..bdf5494f210 100644 --- a/compiler/rustc_data_structures/Cargo.toml +++ b/compiler/rustc_data_structures/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_data_structures" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_data_structures/src/graph/scc/mod.rs b/compiler/rustc_data_structures/src/graph/scc/mod.rs index 93f6192b10b..2241b538738 100644 --- a/compiler/rustc_data_structures/src/graph/scc/mod.rs +++ b/compiler/rustc_data_structures/src/graph/scc/mod.rs @@ -133,7 +133,7 @@ impl<N: Idx, S: Idx + Ord, A: Annotation> Sccs<N, S, A> { /// meaning that if `S1 -> S2`, we will visit `S2` first and `S1` after. /// This is convenient when the edges represent dependencies: when you visit /// `S1`, the value for `S2` will already have been computed. - pub fn all_sccs(&self) -> impl Iterator<Item = S> { + pub fn all_sccs(&self) -> impl Iterator<Item = S> + use<N, S, A> { (0..self.scc_data.len()).map(S::new) } diff --git a/compiler/rustc_data_structures/src/sorted_map/tests.rs b/compiler/rustc_data_structures/src/sorted_map/tests.rs index def7a7112fb..ea4d2f1feac 100644 --- a/compiler/rustc_data_structures/src/sorted_map/tests.rs +++ b/compiler/rustc_data_structures/src/sorted_map/tests.rs @@ -24,7 +24,7 @@ fn test_sorted_index_multi_map() { // `get_by_key` returns items in insertion order. let twos: Vec<_> = set.get_by_key_enumerated(2).collect(); let idxs: Vec<usize> = twos.iter().map(|(i, _)| *i).collect(); - let values: Vec<usize> = twos.iter().map(|(_, &v)| v).collect(); + let values: Vec<usize> = twos.iter().map(|&(_, &v)| v).collect(); assert_eq!(idxs, vec![0, 2, 4]); assert_eq!(values, vec![0, 1, 2]); diff --git a/compiler/rustc_data_structures/src/stack.rs b/compiler/rustc_data_structures/src/stack.rs index 102b3640911..3d6d0003483 100644 --- a/compiler/rustc_data_structures/src/stack.rs +++ b/compiler/rustc_data_structures/src/stack.rs @@ -17,18 +17,6 @@ const STACK_PER_RECURSION: usize = 16 * 1024 * 1024; // 16MB /// /// Should not be sprinkled around carelessly, as it causes a little bit of overhead. #[inline] -#[cfg(not(miri))] pub fn ensure_sufficient_stack<R>(f: impl FnOnce() -> R) -> R { stacker::maybe_grow(RED_ZONE, STACK_PER_RECURSION, f) } - -/// Grows the stack on demand to prevent stack overflow. Call this in strategic locations -/// to "break up" recursive calls. E.g. almost any call to `visit_expr` or equivalent can benefit -/// from this. -/// -/// Should not be sprinkled around carelessly, as it causes a little bit of overhead. -#[cfg(miri)] -#[inline] -pub fn ensure_sufficient_stack<R>(f: impl FnOnce() -> R) -> R { - f() -} diff --git a/compiler/rustc_driver/Cargo.toml b/compiler/rustc_driver/Cargo.toml index ae9712ad66d..e3ee8351295 100644 --- a/compiler/rustc_driver/Cargo.toml +++ b/compiler/rustc_driver/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_driver" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] crate-type = ["dylib"] diff --git a/compiler/rustc_driver_impl/Cargo.toml b/compiler/rustc_driver_impl/Cargo.toml index 0b45e5786e8..8593d1faba2 100644 --- a/compiler/rustc_driver_impl/Cargo.toml +++ b/compiler/rustc_driver_impl/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_driver_impl" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_error_codes/Cargo.toml b/compiler/rustc_error_codes/Cargo.toml index de668b81b7e..55b4e899051 100644 --- a/compiler/rustc_error_codes/Cargo.toml +++ b/compiler/rustc_error_codes/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_error_codes" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_error_messages/Cargo.toml b/compiler/rustc_error_messages/Cargo.toml index 6974c12f994..578af7fc51d 100644 --- a/compiler/rustc_error_messages/Cargo.toml +++ b/compiler/rustc_error_messages/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_error_messages" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_errors/Cargo.toml b/compiler/rustc_errors/Cargo.toml index 434f8c1c767..c1d8cd9bb9e 100644 --- a/compiler/rustc_errors/Cargo.toml +++ b/compiler/rustc_errors/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_errors" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 634afacf539..f7f84239308 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -2216,12 +2216,7 @@ impl HumanEmitter { if let DisplaySuggestion::Diff | DisplaySuggestion::Underline | DisplaySuggestion::Add = show_code_change { - for mut part in parts { - // If this is a replacement of, e.g. `"a"` into `"ab"`, adjust the - // suggestion and snippet to look as if we just suggested to add - // `"b"`, which is typically much easier for the user to understand. - part.trim_trivial_replacements(sm); - + for part in parts { let snippet = if let Ok(snippet) = sm.span_to_snippet(part.span) { snippet } else { diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 6fce1fade26..ceed0cd94fc 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -71,7 +71,7 @@ use rustc_macros::{Decodable, Encodable}; pub use rustc_span::ErrorGuaranteed; pub use rustc_span::fatal_error::{FatalError, FatalErrorMarker}; use rustc_span::source_map::SourceMap; -use rustc_span::{DUMMY_SP, Loc, Span}; +use rustc_span::{BytePos, DUMMY_SP, Loc, Span}; pub use snippet::Style; // Used by external projects such as `rust-gpu`. // See https://github.com/rust-lang/rust/pull/115393. @@ -237,10 +237,9 @@ impl SubstitutionPart { /// it with "abx" is, since the "c" character is lost. pub fn is_destructive_replacement(&self, sm: &SourceMap) -> bool { self.is_replacement(sm) - && !sm.span_to_snippet(self.span).is_ok_and(|snippet| { - self.snippet.trim_start().starts_with(snippet.trim_start()) - || self.snippet.trim_end().ends_with(snippet.trim_end()) - }) + && !sm + .span_to_snippet(self.span) + .is_ok_and(|snippet| as_substr(snippet.trim(), self.snippet.trim()).is_some()) } fn replaces_meaningful_content(&self, sm: &SourceMap) -> bool { @@ -257,16 +256,40 @@ impl SubstitutionPart { let Ok(snippet) = sm.span_to_snippet(self.span) else { return; }; - if self.snippet.starts_with(&snippet) { - self.span = self.span.shrink_to_hi(); - self.snippet = self.snippet[snippet.len()..].to_string(); - } else if self.snippet.ends_with(&snippet) { - self.span = self.span.shrink_to_lo(); - self.snippet = self.snippet[..self.snippet.len() - snippet.len()].to_string(); + + if let Some((prefix, substr, suffix)) = as_substr(&snippet, &self.snippet) { + self.span = Span::new( + self.span.lo() + BytePos(prefix as u32), + self.span.hi() - BytePos(suffix as u32), + self.span.ctxt(), + self.span.parent(), + ); + self.snippet = substr.to_string(); } } } +/// Given an original string like `AACC`, and a suggestion like `AABBCC`, try to detect +/// the case where a substring of the suggestion is "sandwiched" in the original, like +/// `BB` is. Return the length of the prefix, the "trimmed" suggestion, and the length +/// of the suffix. +fn as_substr<'a>(original: &'a str, suggestion: &'a str) -> Option<(usize, &'a str, usize)> { + let common_prefix = original + .chars() + .zip(suggestion.chars()) + .take_while(|(c1, c2)| c1 == c2) + .map(|(c, _)| c.len_utf8()) + .sum(); + let original = &original[common_prefix..]; + let suggestion = &suggestion[common_prefix..]; + if suggestion.ends_with(original) { + let common_suffix = original.len(); + Some((common_prefix, &suggestion[..suggestion.len() - original.len()], common_suffix)) + } else { + None + } +} + impl CodeSuggestion { /// Returns the assembled code suggestions, whether they should be shown with an underline /// and whether the substitution only differs in capitalization. @@ -380,7 +403,12 @@ impl CodeSuggestion { // or deleted code in order to point at the correct column *after* substitution. let mut acc = 0; let mut only_capitalization = false; - for part in &substitution.parts { + for part in &mut substitution.parts { + // If this is a replacement of, e.g. `"a"` into `"ab"`, adjust the + // suggestion and snippet to look as if we just suggested to add + // `"b"`, which is typically much easier for the user to understand. + part.trim_trivial_replacements(sm); + only_capitalization |= is_case_difference(sm, &part.snippet, part.span); let cur_lo = sm.lookup_char_pos(part.span.lo()); if prev_hi.line == cur_lo.line { diff --git a/compiler/rustc_expand/Cargo.toml b/compiler/rustc_expand/Cargo.toml index eb93972387d..33bada106ca 100644 --- a/compiler/rustc_expand/Cargo.toml +++ b/compiler/rustc_expand/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_expand" version = "0.0.0" -edition = "2021" +edition = "2024" build = false [lib] diff --git a/compiler/rustc_expand/src/mbe/transcribe.rs b/compiler/rustc_expand/src/mbe/transcribe.rs index 595c8c3279f..7fe9fa7937d 100644 --- a/compiler/rustc_expand/src/mbe/transcribe.rs +++ b/compiler/rustc_expand/src/mbe/transcribe.rs @@ -1,10 +1,13 @@ use std::mem; use std::sync::Arc; -use rustc_ast::ExprKind; use rustc_ast::mut_visit::{self, MutVisitor}; -use rustc_ast::token::{self, Delimiter, IdentIsRaw, Lit, LitKind, Nonterminal, Token, TokenKind}; +use rustc_ast::token::{ + self, Delimiter, IdentIsRaw, InvisibleOrigin, Lit, LitKind, MetaVarKind, Nonterminal, Token, + TokenKind, +}; use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree}; +use rustc_ast::{ExprKind, TyKind}; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{Diag, DiagCtxtHandle, PResult, pluralize}; use rustc_parse::lexer::nfc_normalize; @@ -255,7 +258,7 @@ pub(super) fn transcribe<'a>( } // Replace the meta-var with the matched token tree from the invocation. - mbe::TokenTree::MetaVar(mut sp, mut original_ident) => { + &mbe::TokenTree::MetaVar(mut sp, mut original_ident) => { // Find the matched nonterminal from the macro invocation, and use it to replace // the meta-var. // @@ -274,6 +277,33 @@ pub(super) fn transcribe<'a>( // some of the unnecessary whitespace. let ident = MacroRulesNormalizedIdent::new(original_ident); if let Some(cur_matched) = lookup_cur_matched(ident, interp, &repeats) { + // We wrap the tokens in invisible delimiters, unless they are already wrapped + // in invisible delimiters with the same `MetaVarKind`. Because some proc + // macros can't multiple layers of invisible delimiters of the same + // `MetaVarKind`. This loses some span info, though it hopefully won't matter. + let mut mk_delimited = |mv_kind, mut stream: TokenStream| { + if stream.len() == 1 { + let tree = stream.iter().next().unwrap(); + if let TokenTree::Delimited(_, _, delim, inner) = tree + && let Delimiter::Invisible(InvisibleOrigin::MetaVar(mvk)) = delim + && mv_kind == *mvk + { + stream = inner.clone(); + } + } + + // Emit as a token stream within `Delimiter::Invisible` to maintain + // parsing priorities. + marker.visit_span(&mut sp); + // Both the open delim and close delim get the same span, which covers the + // `$foo` in the decl macro RHS. + TokenTree::Delimited( + DelimSpan::from_single(sp), + DelimSpacing::new(Spacing::Alone, Spacing::Alone), + Delimiter::Invisible(InvisibleOrigin::MetaVar(mv_kind)), + stream, + ) + }; let tt = match cur_matched { MatchedSingle(ParseNtResult::Tt(tt)) => { // `tt`s are emitted into the output stream directly as "raw tokens", @@ -292,6 +322,13 @@ pub(super) fn transcribe<'a>( let kind = token::NtLifetime(*ident, *is_raw); TokenTree::token_alone(kind, sp) } + MatchedSingle(ParseNtResult::Ty(ty)) => { + let is_path = matches!(&ty.kind, TyKind::Path(None, _path)); + mk_delimited(MetaVarKind::Ty { is_path }, TokenStream::from_ast(ty)) + } + MatchedSingle(ParseNtResult::Vis(vis)) => { + mk_delimited(MetaVarKind::Vis, TokenStream::from_ast(vis)) + } MatchedSingle(ParseNtResult::Nt(nt)) => { // Other variables are emitted into the output stream as groups with // `Delimiter::Invisible` to maintain parsing priorities. @@ -339,7 +376,7 @@ pub(super) fn transcribe<'a>( // We will produce all of the results of the inside of the `Delimited` and then we will // jump back out of the Delimited, pop the result_stack and add the new results back to // the previous results (from outside the Delimited). - mbe::TokenTree::Delimited(mut span, spacing, delimited) => { + &mbe::TokenTree::Delimited(mut span, ref spacing, ref delimited) => { mut_visit::visit_delim_span(&mut marker, &mut span); stack.push(Frame::new_delimited(delimited, span, *spacing)); result_stack.push(mem::take(&mut result)); diff --git a/compiler/rustc_expand/src/proc_macro.rs b/compiler/rustc_expand/src/proc_macro.rs index dca0516f9f3..814d2b04d8d 100644 --- a/compiler/rustc_expand/src/proc_macro.rs +++ b/compiler/rustc_expand/src/proc_macro.rs @@ -31,7 +31,7 @@ impl<T> pm::bridge::server::MessagePipe<T> for MessagePipe<T> { } } -fn exec_strategy(ecx: &ExtCtxt<'_>) -> impl pm::bridge::server::ExecutionStrategy { +fn exec_strategy(ecx: &ExtCtxt<'_>) -> impl pm::bridge::server::ExecutionStrategy + use<> { pm::bridge::server::MaybeCrossThread::<MessagePipe<_>>::new( ecx.sess.opts.unstable_opts.proc_macro_execution_strategy == ProcMacroExecutionStrategy::CrossThread, diff --git a/compiler/rustc_feature/Cargo.toml b/compiler/rustc_feature/Cargo.toml index 77de7fabd4f..a5ae06473cb 100644 --- a/compiler/rustc_feature/Cargo.toml +++ b/compiler/rustc_feature/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_feature" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs index 2fb0c8e4344..60e7788f2c0 100644 --- a/compiler/rustc_feature/src/removed.rs +++ b/compiler/rustc_feature/src/removed.rs @@ -135,6 +135,8 @@ declare_features! ( Some("removed as it caused some confusion and discussion was inactive for years")), /// Lazily evaluate constants. This allows constants to depend on type parameters. (removed, lazy_normalization_consts, "1.46.0", Some(72219), Some("superseded by `generic_const_exprs`")), + /// Changes `impl Trait` to capture all lifetimes in scope. + (removed, lifetime_capture_rules_2024, "1.76.0", None, Some("unnecessary -- use edition 2024 instead")), /// Allows using the `#[link_args]` attribute. (removed, link_args, "1.53.0", Some(29596), Some("removed in favor of using `-C link-arg=ARG` on command line, \ diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index e852f239aa2..c7b44cecb9e 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -214,8 +214,6 @@ declare_features! ( (internal, intrinsics, "1.0.0", None), /// Allows using `#[lang = ".."]` attribute for linking items to special compiler logic. (internal, lang_items, "1.0.0", None), - /// Changes `impl Trait` to capture all lifetimes in scope. - (unstable, lifetime_capture_rules_2024, "1.76.0", None), /// Allows `#[link(..., cfg(..))]`; perma-unstable per #37406 (internal, link_cfg, "1.14.0", None), /// Allows using `?Trait` trait bounds in more contexts. diff --git a/compiler/rustc_fluent_macro/Cargo.toml b/compiler/rustc_fluent_macro/Cargo.toml index eeceaa4691a..ce76b2745ea 100644 --- a/compiler/rustc_fluent_macro/Cargo.toml +++ b/compiler/rustc_fluent_macro/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_fluent_macro" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] proc-macro = true diff --git a/compiler/rustc_fs_util/Cargo.toml b/compiler/rustc_fs_util/Cargo.toml index 4b76200c06c..baca3bc7d49 100644 --- a/compiler/rustc_fs_util/Cargo.toml +++ b/compiler/rustc_fs_util/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_fs_util" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_graphviz/Cargo.toml b/compiler/rustc_graphviz/Cargo.toml index 780004ae3fb..d84943760ba 100644 --- a/compiler/rustc_graphviz/Cargo.toml +++ b/compiler/rustc_graphviz/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_graphviz" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_hashes/Cargo.toml b/compiler/rustc_hashes/Cargo.toml index c2bae2fe8cb..c7a273cff88 100644 --- a/compiler/rustc_hashes/Cargo.toml +++ b/compiler/rustc_hashes/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_hashes" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_hir/Cargo.toml b/compiler/rustc_hir/Cargo.toml index b1516e53173..98300fc40fb 100644 --- a/compiler/rustc_hir/Cargo.toml +++ b/compiler/rustc_hir/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_hir" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_hir/src/hir/tests.rs b/compiler/rustc_hir/src/hir/tests.rs index 300d4435530..f75b9662132 100644 --- a/compiler/rustc_hir/src/hir/tests.rs +++ b/compiler/rustc_hir/src/hir/tests.rs @@ -9,11 +9,11 @@ macro_rules! define_tests { let unambig = $kind::$variant::<'_, ()> { $($init)* }; let unambig_to_ambig = unsafe { std::mem::transmute::<_, $kind<'_, AmbigArg>>(unambig) }; - assert!(matches!(&unambig_to_ambig, $kind::$variant { $($init)* })); + assert!(matches!(&unambig_to_ambig, &$kind::$variant { $($init)* })); let ambig_to_unambig = unsafe { std::mem::transmute::<_, $kind<'_, ()>>(unambig_to_ambig) }; - assert!(matches!(&ambig_to_unambig, $kind::$variant { $($init)* })); + assert!(matches!(&ambig_to_unambig, &$kind::$variant { $($init)* })); } )*}; } diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index bd96fe9ee32..f62ae5ed0d6 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -593,9 +593,9 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V:: defaultness: _, polarity: _, defaultness_span: _, - ref generics, - ref of_trait, - ref self_ty, + generics, + of_trait, + self_ty, items, }) => { try_visit!(visitor.visit_id(item.hir_id())); @@ -1045,7 +1045,7 @@ pub fn walk_generic_param<'v, V: Visitor<'v>>( } GenericParamKind::Const { ref ty, ref default, synthetic: _ } => { try_visit!(visitor.visit_ty_unambig(ty)); - if let Some(ref default) = default { + if let Some(default) = default { try_visit!(visitor.visit_const_param_default(param.hir_id, default)); } } @@ -1401,8 +1401,8 @@ pub fn walk_assoc_item_constraint<'v, V: Visitor<'v>>( try_visit!(visitor.visit_generic_args(constraint.gen_args)); match constraint.kind { AssocItemConstraintKind::Equality { ref term } => match term { - Term::Ty(ref ty) => try_visit!(visitor.visit_ty_unambig(ty)), - Term::Const(ref c) => try_visit!(visitor.visit_const_arg_unambig(c)), + Term::Ty(ty) => try_visit!(visitor.visit_ty_unambig(ty)), + Term::Const(c) => try_visit!(visitor.visit_const_arg_unambig(c)), }, AssocItemConstraintKind::Bound { bounds } => { walk_list!(visitor, visit_param_bound, bounds) diff --git a/compiler/rustc_hir_analysis/Cargo.toml b/compiler/rustc_hir_analysis/Cargo.toml index 196d7d99e93..55a816a855a 100644 --- a/compiler/rustc_hir_analysis/Cargo.toml +++ b/compiler/rustc_hir_analysis/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_hir_analysis" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] test = false diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 516ecbcfe0e..b1b046d7175 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -482,7 +482,7 @@ fn best_definition_site_of_opaque<'tcx>( None } hir::OpaqueTyOrigin::TyAlias { in_assoc_ty: false, .. } => { - let scope = tcx.hir().get_defining_scope(tcx.local_def_id_to_hir_id(opaque_def_id)); + let scope = tcx.hir_get_defining_scope(tcx.local_def_id_to_hir_id(opaque_def_id)); let found = if scope == hir::CRATE_HIR_ID { tcx.hir_walk_toplevel_module(&mut locator) } else { diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index 7b3c3ea2bb4..1c5455710db 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -127,7 +127,7 @@ fn get_owner_return_paths( def_id: LocalDefId, ) -> Option<(LocalDefId, ReturnsVisitor<'_>)> { let hir_id = tcx.local_def_id_to_hir_id(def_id); - let parent_id = tcx.hir().get_parent_item(hir_id).def_id; + let parent_id = tcx.hir_get_parent_item(hir_id).def_id; tcx.hir_node_by_def_id(parent_id).body_id().map(|body_id| { let body = tcx.hir_body(body_id); let mut visitor = ReturnsVisitor::default(); diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index f98504e19de..e6ea6eddcaa 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -853,7 +853,7 @@ fn could_be_self(trait_def_id: LocalDefId, ty: &hir::Ty<'_>) -> bool { /// In such cases, suggest using `Self` instead. fn check_dyn_incompatible_self_trait_by_name(tcx: TyCtxt<'_>, item: &hir::TraitItem<'_>) { let (trait_name, trait_def_id) = - match tcx.hir_node_by_def_id(tcx.hir().get_parent_item(item.hir_id()).def_id) { + match tcx.hir_node_by_def_id(tcx.hir_get_parent_item(item.hir_id()).def_id) { hir::Node::Item(item) => match item.kind { hir::ItemKind::Trait(..) => (item.ident, item.owner_id), _ => return, diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 75ea207a06b..5bb77c096dc 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -469,7 +469,7 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> { let item = self .tcx .hir() - .expect_item(self.tcx.hir().get_parent_item(self.hir_id()).def_id); + .expect_item(self.tcx.hir_get_parent_item(self.hir_id()).def_id); match &item.kind { hir::ItemKind::Enum(_, generics) | hir::ItemKind::Struct(_, generics) @@ -1349,7 +1349,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_, ty::PolyFn } Ctor(data) | Variant(hir::Variant { data, .. }) if data.ctor().is_some() => { - let adt_def_id = tcx.hir().get_parent_item(hir_id).def_id.to_def_id(); + let adt_def_id = tcx.hir_get_parent_item(hir_id).def_id.to_def_id(); let ty = tcx.type_of(adt_def_id).instantiate_identity(); let inputs = data.fields().iter().map(|f| tcx.type_of(f.def_id).instantiate_identity()); // constructors for structs with `layout_scalar_valid_range` are unsafe to call diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs index c0902398a54..a363076b75a 100644 --- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs @@ -71,7 +71,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { | Node::Variant(_) | Node::Ctor(..) | Node::Field(_) => { - let parent_id = tcx.hir().get_parent_item(hir_id); + let parent_id = tcx.hir_get_parent_item(hir_id); Some(parent_id.to_def_id()) } // FIXME(#43408) always enable this once `lazy_normalization` is @@ -90,12 +90,12 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { let parent_did = if let DefKind::AnonConst = tcx.def_kind(parent_did) { parent_did } else { - tcx.hir().get_parent_item(hir_id).to_def_id() + tcx.hir_get_parent_item(hir_id).to_def_id() }; debug!(?parent_did); let mut in_param_ty = false; - for (_parent, node) in tcx.hir().parent_iter(hir_id) { + for (_parent, node) in tcx.hir_parent_iter(hir_id) { if let Some(generics) = node.generics() { let mut visitor = AnonConstInParamTyDetector { in_param_ty: false, ct: hir_id }; diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index 7b1fff157b5..5b511d27074 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -382,8 +382,7 @@ fn const_evaluatable_predicates_of<'tcx>( fn is_const_param_default(tcx: TyCtxt<'_>, def: LocalDefId) -> bool { let hir_id = tcx.local_def_id_to_hir_id(def); let (_, parent_node) = tcx - .hir() - .parent_iter(hir_id) + .hir_parent_iter(hir_id) .skip_while(|(_, n)| matches!(n, Node::ConstArg(..))) .next() .unwrap(); diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index 759c981a8f7..fee3c6088ed 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -305,21 +305,15 @@ fn generic_param_def_as_bound_arg(param: &ty::GenericParamDef) -> ty::BoundVaria } /// Whether this opaque always captures lifetimes in scope. -/// Right now, this is all RPITIT and TAITs, and when `lifetime_capture_rules_2024` -/// is enabled. We don't check the span of the edition, since this is done -/// on a per-opaque basis to account for nested opaques. -fn opaque_captures_all_in_scope_lifetimes<'tcx>( - tcx: TyCtxt<'tcx>, - opaque: &'tcx hir::OpaqueTy<'tcx>, -) -> bool { +/// Right now, this is all RPITIT and TAITs, and when the opaque +/// is coming from a span corresponding to edition 2024. +fn opaque_captures_all_in_scope_lifetimes<'tcx>(opaque: &'tcx hir::OpaqueTy<'tcx>) -> bool { match opaque.origin { // if the opaque has the `use<...>` syntax, the user is telling us that they only want // to account for those lifetimes, so do not try to be clever. _ if opaque.bounds.iter().any(|bound| matches!(bound, hir::GenericBound::Use(..))) => false, hir::OpaqueTyOrigin::AsyncFn { .. } | hir::OpaqueTyOrigin::TyAlias { .. } => true, - _ if tcx.features().lifetime_capture_rules_2024() || opaque.span.at_least_rust_2024() => { - true - } + _ if opaque.span.at_least_rust_2024() => true, hir::OpaqueTyOrigin::FnReturn { in_trait_or_impl, .. } => in_trait_or_impl.is_some(), } } @@ -519,8 +513,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { fn visit_opaque_ty(&mut self, opaque: &'tcx rustc_hir::OpaqueTy<'tcx>) { let captures = RefCell::new(FxIndexMap::default()); - let capture_all_in_scope_lifetimes = - opaque_captures_all_in_scope_lifetimes(self.tcx, opaque); + let capture_all_in_scope_lifetimes = opaque_captures_all_in_scope_lifetimes(opaque); if capture_all_in_scope_lifetimes { let lifetime_ident = |def_id: LocalDefId| { let name = self.tcx.item_name(def_id.to_def_id()); @@ -2276,7 +2269,7 @@ fn is_late_bound_map( } let mut appears_in_output = - AllCollector { tcx, has_fully_capturing_opaque: false, regions: Default::default() }; + AllCollector { has_fully_capturing_opaque: false, regions: Default::default() }; intravisit::walk_fn_ret_ty(&mut appears_in_output, &sig.decl.output); if appears_in_output.has_fully_capturing_opaque { appears_in_output.regions.extend(generics.params.iter().map(|param| param.def_id)); @@ -2289,7 +2282,7 @@ fn is_late_bound_map( // Subtle point: because we disallow nested bindings, we can just // ignore binders here and scrape up all names we see. let mut appears_in_where_clause = - AllCollector { tcx, has_fully_capturing_opaque: true, regions: Default::default() }; + AllCollector { has_fully_capturing_opaque: true, regions: Default::default() }; appears_in_where_clause.visit_generics(generics); debug!(?appears_in_where_clause.regions); @@ -2455,23 +2448,21 @@ fn is_late_bound_map( } } - struct AllCollector<'tcx> { - tcx: TyCtxt<'tcx>, + struct AllCollector { has_fully_capturing_opaque: bool, regions: FxHashSet<LocalDefId>, } - impl<'v> Visitor<'v> for AllCollector<'v> { - fn visit_lifetime(&mut self, lifetime_ref: &'v hir::Lifetime) { + impl<'tcx> Visitor<'tcx> for AllCollector { + fn visit_lifetime(&mut self, lifetime_ref: &'tcx hir::Lifetime) { if let hir::LifetimeName::Param(def_id) = lifetime_ref.res { self.regions.insert(def_id); } } - fn visit_opaque_ty(&mut self, opaque: &'v hir::OpaqueTy<'v>) { + fn visit_opaque_ty(&mut self, opaque: &'tcx hir::OpaqueTy<'tcx>) { if !self.has_fully_capturing_opaque { - self.has_fully_capturing_opaque = - opaque_captures_all_in_scope_lifetimes(self.tcx, opaque); + self.has_fully_capturing_opaque = opaque_captures_all_in_scope_lifetimes(opaque); } intravisit::walk_opaque_ty(self, opaque); } diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index 293a095b41d..cd5cf3bc2df 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -106,8 +106,8 @@ fn anon_const_type_of<'tcx>(icx: &ItemCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx } } } - Node::Variant(Variant { disr_expr: Some(ref e), .. }) if e.hir_id == hir_id => { - tcx.adt_def(tcx.hir().get_parent_item(hir_id)).repr().discr_type().to_ty(tcx) + Node::Variant(Variant { disr_expr: Some(e), .. }) if e.hir_id == hir_id => { + tcx.adt_def(tcx.hir_get_parent_item(hir_id)).repr().discr_type().to_ty(tcx) } // Sort of affects the type system, but only for the purpose of diagnostics // so no need for ConstArg. @@ -257,7 +257,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_ } } ImplItemKind::Type(ty) => { - if tcx.impl_trait_ref(tcx.hir().get_parent_item(hir_id)).is_none() { + if tcx.impl_trait_ref(tcx.hir_get_parent_item(hir_id)).is_none() { check_feature_inherent_assoc_ty(tcx, item.span); } @@ -341,7 +341,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_ Node::Ctor(def) | Node::Variant(Variant { data: def, .. }) => match def { VariantData::Unit(..) | VariantData::Struct { .. } => { - tcx.type_of(tcx.hir().get_parent_item(hir_id)).instantiate_identity() + tcx.type_of(tcx.hir_get_parent_item(hir_id)).instantiate_identity() } VariantData::Tuple(_, _, ctor) => { let args = ty::GenericArgs::identity_for_item(tcx, def_id); diff --git a/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs b/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs index 0c36888f363..399c4fbe55a 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs @@ -83,7 +83,7 @@ pub(super) fn find_opaque_ty_constraints_for_impl_trait_in_assoc_type( #[instrument(skip(tcx), level = "debug")] pub(super) fn find_opaque_ty_constraints_for_tait(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> { let hir_id = tcx.local_def_id_to_hir_id(def_id); - let scope = tcx.hir().get_defining_scope(hir_id); + let scope = tcx.hir_get_defining_scope(hir_id); let mut locator = TaitConstraintLocator { def_id, tcx, found: None, typeck_types: vec![] }; debug!(?scope); diff --git a/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs b/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs index 681e8e36d58..610b293a114 100644 --- a/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs +++ b/compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs @@ -134,9 +134,9 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { // is from the 'of_trait' field of the enclosing impl let parent = self.tcx.parent_hir_node(self.path_segment.hir_id); - let parent_item = self.tcx.hir_node_by_def_id( - self.tcx.hir().get_parent_item(self.path_segment.hir_id).def_id, - ); + let parent_item = self + .tcx + .hir_node_by_def_id(self.tcx.hir_get_parent_item(self.path_segment.hir_id).def_id); // Get the HIR id of the trait ref let hir::Node::TraitRef(hir::TraitRef { hir_ref_id: trait_ref_id, .. }) = parent else { @@ -343,7 +343,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { let mut ret = Vec::new(); let mut ty_id = None; - for (id, node) in self.tcx.hir().parent_iter(path_hir_id) { + for (id, node) in self.tcx.hir_parent_iter(path_hir_id) { debug!(?id); if let hir::Node::Ty(_) = node { ty_id = Some(id); @@ -437,8 +437,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { ) -> String { let is_in_a_method_call = self .tcx - .hir() - .parent_iter(self.path_segment.hir_id) + .hir_parent_iter(self.path_segment.hir_id) .skip(1) .find_map(|(_, node)| match node { hir::Node::Expr(expr) => Some(expr), diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs index 75c97001c32..dd346ed1f97 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs @@ -736,8 +736,7 @@ fn check_assoc_const_binding_type<'tcx>( .map(|ty| crate::errors::TyOfAssocConstBindingNote { assoc_const, ty }); let enclosing_item_owner_id = tcx - .hir() - .parent_owner_iter(hir_id) + .hir_parent_owner_iter(hir_id) .find_map(|(owner_id, parent)| parent.generics().map(|_| owner_id)) .unwrap(); let generics = tcx.generics_of(enclosing_item_owner_id); diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs index 830dca0d3cd..3eb4945ebf8 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs @@ -1,4 +1,4 @@ -use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; +use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; use rustc_errors::codes::*; use rustc_errors::struct_span_code_err; use rustc_hir as hir; @@ -58,9 +58,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { } } - let (trait_bounds, mut projection_bounds) = + let (elaborated_trait_bounds, elaborated_projection_bounds) = traits::expand_trait_aliases(tcx, user_written_bounds.iter().copied()); - let (regular_traits, mut auto_traits): (Vec<_>, Vec<_>) = trait_bounds + let (regular_traits, mut auto_traits): (Vec<_>, Vec<_>) = elaborated_trait_bounds .into_iter() .partition(|(trait_ref, _)| !tcx.trait_is_auto(trait_ref.def_id())); @@ -103,29 +103,81 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { } } + // Map the projection bounds onto a key that makes it easy to remove redundant + // bounds that are constrained by supertraits of the principal def id. + // + // Also make sure we detect conflicting bounds from expanding a trait alias and + // also specifying it manually, like: + // ``` + // type Alias = Trait<Assoc = i32>; + // let _: &dyn Alias<Assoc = u32> = /* ... */; + // ``` + let mut projection_bounds = FxIndexMap::default(); + for (proj, proj_span) in elaborated_projection_bounds { + let key = ( + proj.skip_binder().projection_term.def_id, + tcx.anonymize_bound_vars( + proj.map_bound(|proj| proj.projection_term.trait_ref(tcx)), + ), + ); + if let Some((old_proj, old_proj_span)) = + projection_bounds.insert(key, (proj, proj_span)) + && tcx.anonymize_bound_vars(proj) != tcx.anonymize_bound_vars(old_proj) + { + let item = tcx.item_name(proj.item_def_id()); + self.dcx() + .struct_span_err( + span, + format!( + "conflicting associated type bounds for `{item}` when \ + expanding trait alias" + ), + ) + .with_span_label( + old_proj_span, + format!("`{item}` is specified to be `{}` here", old_proj.term()), + ) + .with_span_label( + proj_span, + format!("`{item}` is specified to be `{}` here", proj.term()), + ) + .emit(); + } + } + let principal_trait = regular_traits.into_iter().next(); - let mut needed_associated_types = FxIndexSet::default(); - if let Some((principal_trait, spans)) = &principal_trait { - let pred: ty::Predicate<'tcx> = (*principal_trait).upcast(tcx); - for ClauseWithSupertraitSpan { pred, supertrait_span } in traits::elaborate( + let mut needed_associated_types = vec![]; + if let Some((principal_trait, ref spans)) = principal_trait { + let principal_trait = principal_trait.map_bound(|trait_pred| { + assert_eq!(trait_pred.polarity, ty::PredicatePolarity::Positive); + trait_pred.trait_ref + }); + + for ClauseWithSupertraitSpan { clause, supertrait_span } in traits::elaborate( tcx, - [ClauseWithSupertraitSpan::new(pred, *spans.last().unwrap())], + [ClauseWithSupertraitSpan::new( + ty::TraitRef::identity(tcx, principal_trait.def_id()).upcast(tcx), + *spans.last().unwrap(), + )], ) .filter_only_self() { - debug!("observing object predicate `{pred:?}`"); + let clause = clause.instantiate_supertrait(tcx, principal_trait); + debug!("observing object predicate `{clause:?}`"); - let bound_predicate = pred.kind(); + let bound_predicate = clause.kind(); match bound_predicate.skip_binder() { - ty::PredicateKind::Clause(ty::ClauseKind::Trait(pred)) => { + ty::ClauseKind::Trait(pred) => { // FIXME(negative_bounds): Handle this correctly... let trait_ref = tcx.anonymize_bound_vars(bound_predicate.rebind(pred.trait_ref)); needed_associated_types.extend( - tcx.associated_items(trait_ref.def_id()) + tcx.associated_items(pred.trait_ref.def_id) .in_definition_order() + // We only care about associated types. .filter(|item| item.kind == ty::AssocKind::Type) + // No RPITITs -- even with `async_fn_in_dyn_trait`, they are implicit. .filter(|item| !item.is_impl_trait_in_trait()) // If the associated type has a `where Self: Sized` bound, // we do not need to constrain the associated type. @@ -133,7 +185,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { .map(|item| (item.def_id, trait_ref)), ); } - ty::PredicateKind::Clause(ty::ClauseKind::Projection(pred)) => { + ty::ClauseKind::Projection(pred) => { let pred = bound_predicate.rebind(pred); // A `Self` within the original bound will be instantiated with a // `trait_object_dummy_self`, so check for that. @@ -161,8 +213,15 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { // `dyn MyTrait<MyOutput = X, Output = X>`, which is uglier but works. See // the discussion in #56288 for alternatives. if !references_self { - // Include projections defined on supertraits. - projection_bounds.push((pred, supertrait_span)); + let key = ( + pred.skip_binder().projection_term.def_id, + tcx.anonymize_bound_vars( + pred.map_bound(|proj| proj.projection_term.trait_ref(tcx)), + ), + ); + if !projection_bounds.contains_key(&key) { + projection_bounds.insert(key, (pred, supertrait_span)); + } } self.check_elaborated_projection_mentions_input_lifetimes( @@ -182,12 +241,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { // types that we expect to be provided by the user, so the following loop // removes all the associated types that have a corresponding `Projection` // clause, either from expanding trait aliases or written by the user. - for &(projection_bound, span) in &projection_bounds { + for &(projection_bound, span) in projection_bounds.values() { let def_id = projection_bound.item_def_id(); - let trait_ref = tcx.anonymize_bound_vars( - projection_bound.map_bound(|p| p.projection_term.trait_ref(tcx)), - ); - needed_associated_types.swap_remove(&(def_id, trait_ref)); if tcx.generics_require_sized_self(def_id) { tcx.emit_node_span_lint( UNUSED_ASSOCIATED_TYPE_BOUNDS, @@ -198,9 +253,22 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { } } + let mut missing_assoc_types = FxIndexSet::default(); + let projection_bounds: Vec<_> = needed_associated_types + .into_iter() + .filter_map(|key| { + if let Some(assoc) = projection_bounds.get(&key) { + Some(*assoc) + } else { + missing_assoc_types.insert(key); + None + } + }) + .collect(); + if let Err(guar) = self.check_for_required_assoc_tys( principal_trait.as_ref().map_or(smallvec![], |(_, spans)| spans.clone()), - needed_associated_types, + missing_assoc_types, potential_assoc_types, hir_bounds, ) { @@ -266,7 +334,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { }) }); - let existential_projections = projection_bounds.iter().map(|(bound, _)| { + let existential_projections = projection_bounds.into_iter().map(|(bound, _)| { bound.map_bound(|mut b| { assert_eq!(b.projection_term.self_ty(), dummy_self); @@ -291,12 +359,16 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { }) }); - let auto_trait_predicates = auto_traits.into_iter().map(|(trait_pred, _)| { - assert_eq!(trait_pred.polarity(), ty::PredicatePolarity::Positive); - assert_eq!(trait_pred.self_ty().skip_binder(), dummy_self); + let mut auto_trait_predicates: Vec<_> = auto_traits + .into_iter() + .map(|(trait_pred, _)| { + assert_eq!(trait_pred.polarity(), ty::PredicatePolarity::Positive); + assert_eq!(trait_pred.self_ty().skip_binder(), dummy_self); - ty::Binder::dummy(ty::ExistentialPredicate::AutoTrait(trait_pred.def_id())) - }); + ty::Binder::dummy(ty::ExistentialPredicate::AutoTrait(trait_pred.def_id())) + }) + .collect(); + auto_trait_predicates.dedup(); // N.b. principal, projections, auto traits // FIXME: This is actually wrong with multiple principals in regards to symbol mangling @@ -306,7 +378,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { .chain(auto_trait_predicates) .collect::<SmallVec<[_; 8]>>(); v.sort_by(|a, b| a.skip_binder().stable_cmp(tcx, &b.skip_binder())); - v.dedup(); let existential_predicates = tcx.mk_poly_existential_predicates(&v); // Use explicitly-specified region bound, unless the bound is missing. diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs index d2789cc0fd6..d644a1f224c 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs @@ -223,7 +223,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { // inside an opaque type while we're interested in the overarching type alias (TAIT). // FIXME: However, for trait aliases, this incorrectly returns the enclosing module... && let item_def_id = - tcx.hir().get_parent_item(tcx.local_def_id_to_hir_id(ty_param_def_id)) + tcx.hir_get_parent_item(tcx.local_def_id_to_hir_id(ty_param_def_id)) // FIXME: ...which obviously won't have any generics. && let Some(generics) = tcx.hir_get_generics(item_def_id.def_id) { @@ -979,7 +979,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { qself: &hir::Ty<'_>, ) -> Result<(), ErrorGuaranteed> { let tcx = self.tcx(); - if let Some((_, node)) = tcx.hir().parent_iter(qself.hir_id).skip(1).next() + if let Some((_, node)) = tcx.hir_parent_iter(qself.hir_id).skip(1).next() && let hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Path(hir::QPath::TypeRelative( @@ -1278,8 +1278,7 @@ pub fn prohibit_assoc_item_constraint( // Get the parent impl block based on the binding we have // and the trait DefId let impl_block = tcx - .hir() - .parent_iter(constraint.hir_id) + .hir_parent_iter(constraint.hir_id) .find_map(|(_, node)| node.impl_block_of_trait(def_id)); let type_with_constraints = diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs index 17de64db629..8d58a3bfbd3 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs @@ -542,8 +542,7 @@ pub(crate) fn check_generic_arg_count( // ``` let parent_is_impl_block = cx .tcx() - .hir() - .parent_owner_iter(seg.hir_id) + .hir_parent_owner_iter(seg.hir_id) .next() .is_some_and(|(_, owner_node)| owner_node.is_impl_block()); if parent_is_impl_block { diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs index 44f7a035a10..f5e075367f3 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs @@ -130,7 +130,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { diag: &mut Diag<'_, G>, ) { let tcx = self.tcx(); - let parent_id = tcx.hir().get_parent_item(self_ty.hir_id).def_id; + let parent_id = tcx.hir_get_parent_item(self_ty.hir_id).def_id; if let hir::Node::Item(hir::Item { kind: hir::ItemKind::Impl(hir::Impl { self_ty: impl_self_ty, of_trait, generics, .. }), .. @@ -191,7 +191,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { /// Make sure that we are in the condition to suggest `impl Trait`. fn maybe_suggest_impl_trait(&self, self_ty: &hir::Ty<'_>, diag: &mut Diag<'_>) -> bool { let tcx = self.tcx(); - let parent_id = tcx.hir().get_parent_item(self_ty.hir_id).def_id; + let parent_id = tcx.hir_get_parent_item(self_ty.hir_id).def_id; // FIXME: If `type_alias_impl_trait` is enabled, also look for `Trait0<Ty = Trait1>` // and suggest `Trait0<Ty = impl Trait1>`. // Functions are found in three different contexts. @@ -321,7 +321,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { } fn maybe_suggest_assoc_ty_bound(&self, self_ty: &hir::Ty<'_>, diag: &mut Diag<'_>) { - let mut parents = self.tcx().hir().parent_iter(self_ty.hir_id); + let mut parents = self.tcx().hir_parent_iter(self_ty.hir_id); if let Some((_, hir::Node::AssocItemConstraint(constraint))) = parents.next() && let Some(obj_ty) = constraint.ty() diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index e9b99caf737..750770178ee 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -1226,11 +1226,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { adt_def.variants().iter().find(|s| s.name == variant_name) { let mut suggestion = vec![(assoc_ident.span, variant_name.to_string())]; - if let hir::Node::Stmt(hir::Stmt { - kind: hir::StmtKind::Semi(ref expr), - .. + if let hir::Node::Stmt(&hir::Stmt { + kind: hir::StmtKind::Semi(expr), .. }) - | hir::Node::Expr(ref expr) = tcx.parent_hir_node(hir_ref_id) + | hir::Node::Expr(expr) = tcx.parent_hir_node(hir_ref_id) && let hir::ExprKind::Struct(..) = expr.kind { match variant.ctor { @@ -1673,8 +1672,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { debug!(item_def_id = ?def_id); // FIXME: document why/how this is different from `tcx.local_parent(def_id)` - let parent_def_id = - tcx.hir().get_parent_item(tcx.local_def_id_to_hir_id(def_id)).to_def_id(); + let parent_def_id = tcx.hir_get_parent_item(tcx.local_def_id_to_hir_id(def_id)).to_def_id(); debug!(?parent_def_id); // If the trait in segment is the same as the trait defining the item, diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 0859a39b155..bdfbd540e40 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -251,7 +251,7 @@ pub fn lower_ty<'tcx>(tcx: TyCtxt<'tcx>, hir_ty: &hir::Ty<'tcx>) -> Ty<'tcx> { // In case there are any projections, etc., find the "environment" // def-ID that will be used to determine the traits/predicates in // scope. This is derived from the enclosing item-like thing. - let env_def_id = tcx.hir().get_parent_item(hir_ty.hir_id); + let env_def_id = tcx.hir_get_parent_item(hir_ty.hir_id); collect::ItemCtxt::new(tcx, env_def_id.def_id).lower_ty(hir_ty) } @@ -262,6 +262,6 @@ pub fn lower_const_arg_for_rustdoc<'tcx>( hir_ct: &hir::ConstArg<'tcx>, feed: FeedConstTy, ) -> Const<'tcx> { - let env_def_id = tcx.hir().get_parent_item(hir_ct.hir_id); + let env_def_id = tcx.hir_get_parent_item(hir_ct.hir_id); collect::ItemCtxt::new(tcx, env_def_id.def_id).lowerer().lower_const_arg(hir_ct, feed) } diff --git a/compiler/rustc_hir_analysis/src/outlives/mod.rs b/compiler/rustc_hir_analysis/src/outlives/mod.rs index c43917649de..32b05dcc569 100644 --- a/compiler/rustc_hir_analysis/src/outlives/mod.rs +++ b/compiler/rustc_hir_analysis/src/outlives/mod.rs @@ -37,7 +37,7 @@ fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[(ty::Clau // parent of generics returned by `generics_of` // // In the above code we want the anon const to have predicates in its param env for `'b: 'a` - let item_def_id = tcx.hir().get_parent_item(id); + let item_def_id = tcx.hir_get_parent_item(id); // In the above code example we would be calling `inferred_outlives_of(Foo)` here tcx.inferred_outlives_of(item_def_id) } else { diff --git a/compiler/rustc_hir_pretty/Cargo.toml b/compiler/rustc_hir_pretty/Cargo.toml index 9af1fb8279e..f5d7dbd3f96 100644 --- a/compiler/rustc_hir_pretty/Cargo.toml +++ b/compiler/rustc_hir_pretty/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_hir_pretty" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 34124a6aa11..82c4d37405a 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -1856,7 +1856,7 @@ impl<'a> State<'a> { self.word_space("="); match term { Term::Ty(ty) => self.print_type(ty), - Term::Const(ref c) => self.print_const_arg(c), + Term::Const(c) => self.print_const_arg(c), } } hir::AssocItemConstraintKind::Bound { bounds } => { diff --git a/compiler/rustc_hir_typeck/Cargo.toml b/compiler/rustc_hir_typeck/Cargo.toml index 0331a20f95b..f1afb7b712d 100644 --- a/compiler/rustc_hir_typeck/Cargo.toml +++ b/compiler/rustc_hir_typeck/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_hir_typeck" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 49ea2181b07..d18869b6d90 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -346,8 +346,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return; }; - let hir = self.tcx.hir(); - let fn_decl_span = if let hir::Node::Expr(hir::Expr { + let fn_decl_span = if let hir::Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure(&hir::Closure { fn_decl_span, .. }), .. }) = self.tcx.parent_hir_node(hir_id) @@ -368,11 +367,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }), .. }), - )) = hir.parent_iter(hir_id).nth(3) + )) = self.tcx.hir_parent_iter(hir_id).nth(3) { // Actually need to unwrap one more layer of HIR to get to // the _real_ closure... - if let hir::Node::Expr(hir::Expr { + if let hir::Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure(&hir::Closure { fn_decl_span, .. }), .. }) = self.tcx.parent_hir_node(parent_hir_id) diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index cf11bccae0a..a5108e7a032 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -1752,7 +1752,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { return false; } let Some((_, hir::Node::Expr(expr))) = - fcx.tcx.hir().parent_iter(id).nth(1) + fcx.tcx.hir_parent_iter(id).nth(1) else { return false; }; @@ -1887,7 +1887,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { let parent_id = fcx.tcx.parent_hir_id(block_or_return_id); let parent = fcx.tcx.hir_node(parent_id); if let Some(expr) = expression - && let hir::Node::Expr(hir::Expr { + && let hir::Node::Expr(&hir::Expr { kind: hir::ExprKind::Closure(&hir::Closure { body, .. }), .. }) = parent @@ -1909,7 +1909,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> { found, block_or_return_id, ); - if let Some(cond_expr) = fcx.tcx.hir().get_if_cause(expr.hir_id) + if let Some(cond_expr) = fcx.tcx.hir_get_if_cause(expr.hir_id) && expected.is_unit() && !pointing_at_return_type // If the block is from an external macro or try (`?`) desugaring, then diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs index 4dc736f72cf..85131f6195f 100644 --- a/compiler/rustc_hir_typeck/src/demand.rs +++ b/compiler/rustc_hir_typeck/src/demand.rs @@ -156,7 +156,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { && segment.ident.name.as_str() == name && let Res::Local(hir_id) = path.res && let Some((_, hir::Node::Expr(match_expr))) = - self.tcx.hir().parent_iter(hir_id).nth(2) + self.tcx.hir_parent_iter(hir_id).nth(2) && let hir::ExprKind::Match(scrutinee, _, _) = match_expr.kind && let hir::ExprKind::Tup(exprs) = scrutinee.kind && let hir::ExprKind::AddrOf(_, _, macro_arg) = exprs[idx].kind @@ -577,9 +577,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut parent; 'outer: loop { // Climb the HIR tree to see if the current `Expr` is part of a `break;` statement. - let (hir::Node::Stmt(hir::Stmt { kind: hir::StmtKind::Semi(&ref p), .. }) - | hir::Node::Block(hir::Block { expr: Some(&ref p), .. }) - | hir::Node::Expr(&ref p)) = self.tcx.hir_node(parent_id) + let (hir::Node::Stmt(&hir::Stmt { kind: hir::StmtKind::Semi(p), .. }) + | hir::Node::Block(&hir::Block { expr: Some(p), .. }) + | hir::Node::Expr(p)) = self.tcx.hir_node(parent_id) else { break; }; @@ -593,13 +593,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { loop { // Climb the HIR tree to find the (desugared) `loop` this `break` corresponds to. let parent = match self.tcx.hir_node(parent_id) { - hir::Node::Expr(&ref parent) => { + hir::Node::Expr(parent) => { parent_id = self.tcx.parent_hir_id(parent.hir_id); parent } hir::Node::Stmt(hir::Stmt { hir_id, - kind: hir::StmtKind::Semi(&ref parent) | hir::StmtKind::Expr(&ref parent), + kind: hir::StmtKind::Semi(parent) | hir::StmtKind::Expr(parent), .. }) => { parent_id = self.tcx.parent_hir_id(*hir_id); @@ -841,7 +841,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // The pattern we have is an fn argument. && let hir::Node::Param(hir::Param { ty_span, .. }) = self.tcx.parent_hir_node(pat.hir_id) - && let item = self.tcx.hir().get_parent_item(pat.hir_id) + && let item = self.tcx.hir_get_parent_item(pat.hir_id) && let item = self.tcx.hir_owner_node(item) && let Some(fn_decl) = item.fn_decl() diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 1c63b8b3655..277396da19c 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -1130,7 +1130,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { statement_kind: kind, }; - let encl_item_id = self.tcx.hir().get_parent_item(expr.hir_id); + let encl_item_id = self.tcx.hir_get_parent_item(expr.hir_id); if let hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn { .. }, @@ -1279,7 +1279,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Check if our original expression is a child of the condition of a while loop. // If it is, then we have a situation like `while Some(0) = value.get(0) {`, // where `while let` was more likely intended. - if self.tcx.hir().parent_id_iter(original_expr_id).any(|id| id == expr.hir_id) { + if self.tcx.hir_parent_id_iter(original_expr_id).any(|id| id == expr.hir_id) { then(expr); } break; @@ -1774,7 +1774,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } fn suggest_array_len(&self, expr: &'tcx hir::Expr<'tcx>, array_len: u64) { - let parent_node = self.tcx.hir().parent_iter(expr.hir_id).find(|(_, node)| { + let parent_node = self.tcx.hir_parent_iter(expr.hir_id).find(|(_, node)| { !matches!(node, hir::Node::Expr(hir::Expr { kind: hir::ExprKind::AddrOf(..), .. })) }); let Some((_, hir::Node::LetStmt(hir::LetStmt { ty: Some(ty), .. }))) = parent_node else { diff --git a/compiler/rustc_hir_typeck/src/fallback.rs b/compiler/rustc_hir_typeck/src/fallback.rs index e051fc7ac6c..759b5d9550c 100644 --- a/compiler/rustc_hir_typeck/src/fallback.rs +++ b/compiler/rustc_hir_typeck/src/fallback.rs @@ -503,7 +503,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> { let unit_errors = remaining_errors_if_fallback_to(self.tcx.types.unit); if unit_errors.is_empty() && let mut never_errors = remaining_errors_if_fallback_to(self.tcx.types.never) - && let [ref mut never_error, ..] = never_errors.as_mut_slice() + && let [never_error, ..] = never_errors.as_mut_slice() { self.adjust_fulfillment_error_for_expr_obligation(never_error); let sugg = self.try_to_suggest_annotations(diverging_vids, coercions); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index ff41a080d62..2d7d80e39bc 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -856,7 +856,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> Option<(LocalDefId, &'tcx hir::FnDecl<'tcx>)> { // Get enclosing Fn, if it is a function or a trait method, unless there's a `loop` or // `while` before reaching it, as block tail returns are not available in them. - self.tcx.hir().get_fn_id_for_return_block(blk_id).and_then(|item_id| { + self.tcx.hir_get_fn_id_for_return_block(blk_id).and_then(|item_id| { match self.tcx.hir_node(item_id) { Node::Item(&hir::Item { kind: hir::ItemKind::Fn { sig, .. }, owner_id, .. diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 7ca44d23e3e..cf61659479b 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -2052,7 +2052,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } fn parent_item_span(&self, id: HirId) -> Option<Span> { - let node = self.tcx.hir_node_by_def_id(self.tcx.hir().get_parent_item(id).def_id); + let node = self.tcx.hir_node_by_def_id(self.tcx.hir_get_parent_item(id).def_id); match node { Node::Item(&hir::Item { kind: hir::ItemKind::Fn { body: body_id, .. }, .. }) | Node::ImplItem(&hir::ImplItem { kind: hir::ImplItemKind::Fn(_, body_id), .. }) => { @@ -2179,7 +2179,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { { let mut block_num = 0; let mut found_semi = false; - for (hir_id, node) in self.tcx.hir().parent_iter(binding_hir_id) { + for (hir_id, node) in self.tcx.hir_parent_iter(binding_hir_id) { // Don't proceed into parent bodies if hir_id.owner != binding_hir_id.owner { break; @@ -2521,7 +2521,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Try to find earlier invocations of this closure to find if the type mismatch // is because of inference. If we find one, point at them. let mut call_finder = FindClosureArg { tcx: self.tcx, calls: vec![] }; - let parent_def_id = self.tcx.hir().get_parent_item(call_expr.hir_id).def_id; + let parent_def_id = self.tcx.hir_get_parent_item(call_expr.hir_id).def_id; match self.tcx.hir_node_by_def_id(parent_def_id) { hir::Node::Item(item) => call_finder.visit_item(item), hir::Node::TraitItem(item) => call_finder.visit_trait_item(item), diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index 347a6557c2a..f9fc1215936 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -308,7 +308,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; let mut tuple_indexes = Vec::new(); let mut expr_id = expr.hir_id; - for (parent_id, node) in self.tcx.hir().parent_iter(expr.hir_id) { + for (parent_id, node) in self.tcx.hir_parent_iter(expr.hir_id) { match node { Node::Expr(&Expr { kind: ExprKind::Tup(subs), .. }) => { tuple_indexes.push( @@ -565,7 +565,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { found: Ty<'tcx>, ) -> bool { // Do not suggest `Box::new` in const context. - if self.tcx.hir().is_inside_const_context(hir_id) || !expected.is_box() || found.is_box() { + if self.tcx.hir_is_inside_const_context(hir_id) || !expected.is_box() || found.is_box() { return false; } if self.may_coerce(Ty::new_box(self.tcx, found), expected) { @@ -645,7 +645,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) -> bool { // Handle #68197. - if self.tcx.hir().is_inside_const_context(expr.hir_id) { + if self.tcx.hir_is_inside_const_context(expr.hir_id) { // Do not suggest `Box::new` in const context. return false; } @@ -1084,8 +1084,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let in_loop = self.is_loop(id) || self .tcx - .hir() - .parent_iter(id) + .hir_parent_iter(id) .take_while(|(_, node)| { // look at parents until we find the first body owner node.body_id().is_none() @@ -1095,8 +1094,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let in_local_statement = self.is_local_statement(id) || self .tcx - .hir() - .parent_iter(id) + .hir_parent_iter(id) .any(|(parent_id, _)| self.is_local_statement(parent_id)); if in_loop && in_local_statement { @@ -1111,7 +1109,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return; } - let scope = self.tcx.hir().parent_iter(id).find(|(_, node)| { + let scope = self.tcx.hir_parent_iter(id).find(|(_, node)| { matches!( node, Node::Expr(Expr { kind: ExprKind::Closure(..), .. }) @@ -1168,7 +1166,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // -------------^^^^^^^- // Don't add semicolon `;` at the end of `dbg!(x)` expr fn is_in_arm<'tcx>(expr: &'tcx hir::Expr<'tcx>, tcx: TyCtxt<'tcx>) -> bool { - for (_, node) in tcx.hir().parent_iter(expr.hir_id) { + for (_, node) in tcx.hir_parent_iter(expr.hir_id) { match node { hir::Node::Block(block) => { if let Some(ret) = block.expr @@ -1411,8 +1409,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return false; } - let hir = self.tcx.hir(); - let cond_parent = hir.parent_iter(expr.hir_id).find(|(_, node)| { + let cond_parent = self.tcx.hir_parent_iter(expr.hir_id).find(|(_, node)| { !matches!(node, hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Binary(op, _, _), .. }) if op.node == hir::BinOpKind::And) }); // Don't suggest: @@ -2048,11 +2045,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expected: Ty<'tcx>, found: Ty<'tcx>, ) -> bool { - let map = self.tcx.hir(); let returned = matches!( self.tcx.parent_hir_node(expr.hir_id), hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Ret(_), .. }) - ) || map.get_fn_id_for_return_block(expr.hir_id).is_some(); + ) || self.tcx.hir_get_fn_id_for_return_block(expr.hir_id).is_some(); if returned && let ty::Adt(e, args_e) = expected.kind() && let ty::Adt(f, args_f) = found.kind() @@ -2095,9 +2091,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expected: Ty<'tcx>, ) -> bool { let tcx = self.tcx; - let hir = tcx.hir(); let enclosing_scope = - hir.get_enclosing_scope(expr.hir_id).map(|hir_id| tcx.hir_node(hir_id)); + tcx.hir_get_enclosing_scope(expr.hir_id).map(|hir_id| tcx.hir_node(hir_id)); // Get tail expr of the enclosing block or body let tail_expr = if let Some(Node::Block(hir::Block { expr, .. })) = enclosing_scope @@ -3098,7 +3093,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |expr: &hir::Expr<'_>| matches!(expr.kind, hir::ExprKind::Unary(hir::UnOp::Neg, ..)); let is_uint = |ty: Ty<'_>| matches!(ty.kind(), ty::Uint(..)); - let in_const_context = self.tcx.hir().is_inside_const_context(expr.hir_id); + let in_const_context = self.tcx.hir_is_inside_const_context(expr.hir_id); let suggest_fallible_into_or_lhs_from = |err: &mut Diag<'_>, exp_to_found_is_fallible: bool| { @@ -3142,7 +3137,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let suggest_to_change_suffix_or_into = |err: &mut Diag<'_>, found_to_exp_is_fallible: bool, exp_to_found_is_fallible: bool| { - let exp_is_lhs = expected_ty_expr.is_some_and(|e| self.tcx.hir().is_lhs(e.hir_id)); + let exp_is_lhs = expected_ty_expr.is_some_and(|e| self.tcx.hir_is_lhs(e.hir_id)); if exp_is_lhs { return; diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index 8fb425ff0c9..3b107fbf173 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -11,7 +11,7 @@ use rustc_hir_analysis::hir_ty_lowering::{ }; use rustc_infer::infer::{self, DefineOpaqueTypes, InferOk}; use rustc_lint::builtin::SUPERTRAIT_ITEM_SHADOWING_USAGE; -use rustc_middle::traits::{ObligationCauseCode, UnifyReceiverContext}; +use rustc_middle::traits::ObligationCauseCode; use rustc_middle::ty::adjustment::{ Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, PointerCoercion, }; @@ -136,7 +136,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { "confirm: self_ty={:?} method_sig_rcvr={:?} method_sig={:?} method_predicates={:?}", self_ty, method_sig_rcvr, method_sig, method_predicates ); - self.unify_receivers(self_ty, method_sig_rcvr, pick, all_args); + self.unify_receivers(self_ty, method_sig_rcvr, pick); let (method_sig, method_predicates) = self.normalize(self.span, (method_sig, method_predicates)); @@ -525,20 +525,12 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { self_ty: Ty<'tcx>, method_self_ty: Ty<'tcx>, pick: &probe::Pick<'tcx>, - args: GenericArgsRef<'tcx>, ) { debug!( "unify_receivers: self_ty={:?} method_self_ty={:?} span={:?} pick={:?}", self_ty, method_self_ty, self.span, pick ); - let cause = self.cause( - self.self_expr.span, - ObligationCauseCode::UnifyReceiver(Box::new(UnifyReceiverContext { - assoc_item: pick.item, - param_env: self.param_env, - args, - })), - ); + let cause = self.cause(self.self_expr.span, ObligationCauseCode::Misc); match self.at(&cause, self.param_env).sup(DefineOpaqueTypes::Yes, method_self_ty, self_ty) { Ok(InferOk { obligations, value: () }) => { self.register_predicates(obligations); diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index b3e48fd5bb5..f87e5b5202a 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -873,7 +873,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { #[instrument(level = "debug", skip(self))] fn assemble_inherent_candidates_from_object(&mut self, self_ty: Ty<'tcx>) { let principal = match self_ty.kind() { - ty::Dynamic(ref data, ..) => Some(data), + ty::Dynamic(data, ..) => Some(data), _ => None, } .and_then(|data| data.principal()) diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 780ab8c1833..8dd8398ba24 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -1586,10 +1586,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let SelfSource::QPath(ty) = source && let hir::Node::Expr(ref path_expr) = self.tcx.parent_hir_node(ty.hir_id) && let hir::ExprKind::Path(_) = path_expr.kind - && let hir::Node::Stmt(hir::Stmt { - kind: hir::StmtKind::Semi(ref parent), .. - }) - | hir::Node::Expr(ref parent) = self.tcx.parent_hir_node(path_expr.hir_id) + && let hir::Node::Stmt(&hir::Stmt { kind: hir::StmtKind::Semi(parent), .. }) + | hir::Node::Expr(parent) = self.tcx.parent_hir_node(path_expr.hir_id) { let replacement_span = if let hir::ExprKind::Call(..) | hir::ExprKind::Struct(..) = parent.kind { @@ -2390,7 +2388,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { long_ty_path: &mut Option<PathBuf>, ) -> Result<(), ErrorGuaranteed> { if let SelfSource::MethodCall(expr) = source { - for (_, parent) in tcx.hir().parent_iter(expr.hir_id).take(5) { + for (_, parent) in tcx.hir_parent_iter(expr.hir_id).take(5) { if let Node::Expr(parent_expr) = parent { let lang_item = match parent_expr.kind { ExprKind::Struct(qpath, _, _) => match *qpath { @@ -3149,8 +3147,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let mut derives_grouped = Vec::<(String, Span, String)>::new(); for (self_name, self_span, trait_name) in derives.into_iter() { - if let Some((last_self_name, _, ref mut last_trait_names)) = derives_grouped.last_mut() - { + if let Some((last_self_name, _, last_trait_names)) = derives_grouped.last_mut() { if last_self_name == &self_name { last_trait_names.push_str(format!(", {trait_name}").as_str()); continue; diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index e63cc090993..bd0848b9916 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -324,7 +324,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let PatInfo { binding_mode, max_ref_mutbl, top_info: ti, current_depth, .. } = pat_info; let path_res = match pat.kind { - PatKind::Expr(PatExpr { kind: PatExprKind::Path(ref qpath), hir_id, span }) => { + PatKind::Expr(PatExpr { kind: PatExprKind::Path(qpath), hir_id, span }) => { Some(self.resolve_ty_and_res_fully_qualified_call(qpath, *hir_id, *span)) } _ => None, @@ -344,7 +344,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { PatKind::Wild | PatKind::Err(_) => expected, // We allow any type here; we ensure that the type is uninhabited during match checking. PatKind::Never => expected, - PatKind::Expr(PatExpr { kind: PatExprKind::Path(ref qpath), hir_id, span }) => { + PatKind::Expr(PatExpr { kind: PatExprKind::Path(qpath), hir_id, span }) => { let ty = self.check_pat_path( *hir_id, pat.hir_id, @@ -946,7 +946,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let var_ty = self.resolve_vars_if_possible(var_ty); let msg = format!("first introduced with type `{var_ty}` here"); err.span_label(hir.span(var_id), msg); - let in_match = hir.parent_iter(var_id).any(|(_, n)| { + let in_match = self.tcx.hir_parent_iter(var_id).any(|(_, n)| { matches!( n, hir::Node::Expr(hir::Expr { diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index 762d04fdedd..9a0b2247058 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -1934,7 +1934,7 @@ fn apply_capture_kind_on_capture_ty<'tcx>( /// Returns the Span of where the value with the provided HirId would be dropped fn drop_location_span(tcx: TyCtxt<'_>, hir_id: HirId) -> Span { - let owner_id = tcx.hir().get_enclosing_scope(hir_id).unwrap(); + let owner_id = tcx.hir_get_enclosing_scope(hir_id).unwrap(); let owner_node = tcx.hir_node(owner_id); let owner_span = match owner_node { diff --git a/compiler/rustc_incremental/Cargo.toml b/compiler/rustc_incremental/Cargo.toml index 46a63b02e84..a2f88f19f53 100644 --- a/compiler/rustc_incremental/Cargo.toml +++ b/compiler/rustc_incremental/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_incremental" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_index/Cargo.toml b/compiler/rustc_index/Cargo.toml index f27db7a5400..3d83a3c98da 100644 --- a/compiler/rustc_index/Cargo.toml +++ b/compiler/rustc_index/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_index" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_index/src/bit_set.rs b/compiler/rustc_index/src/bit_set.rs index f12df831cb5..d7d90ea16e4 100644 --- a/compiler/rustc_index/src/bit_set.rs +++ b/compiler/rustc_index/src/bit_set.rs @@ -723,7 +723,7 @@ impl<T: Idx> ChunkedBitSet<T> { match self.chunks.get(chunk_index) { Some(Zeros(_chunk_domain_size)) => ChunkIter::Zeros, Some(Ones(chunk_domain_size)) => ChunkIter::Ones(0..*chunk_domain_size as usize), - Some(Mixed(chunk_domain_size, _, ref words)) => { + Some(Mixed(chunk_domain_size, _, words)) => { let num_words = num_words(*chunk_domain_size as usize); ChunkIter::Mixed(BitIter::new(&words[0..num_words])) } @@ -752,11 +752,7 @@ impl<T: Idx> BitRelations<ChunkedBitSet<T>> for ChunkedBitSet<T> { changed = true; } ( - Mixed( - self_chunk_domain_size, - ref mut self_chunk_count, - ref mut self_chunk_words, - ), + Mixed(self_chunk_domain_size, self_chunk_count, self_chunk_words), Mixed(_other_chunk_domain_size, _other_chunk_count, other_chunk_words), ) => { // First check if the operation would change @@ -836,11 +832,7 @@ impl<T: Idx> BitRelations<ChunkedBitSet<T>> for ChunkedBitSet<T> { Mixed(*self_chunk_domain_size, self_chunk_count, Rc::new(self_chunk_words)); } ( - Mixed( - self_chunk_domain_size, - ref mut self_chunk_count, - ref mut self_chunk_words, - ), + Mixed(self_chunk_domain_size, self_chunk_count, self_chunk_words), Mixed(_other_chunk_domain_size, _other_chunk_count, other_chunk_words), ) => { // See [`<Self as BitRelations<ChunkedBitSet<T>>>::union`] for the explanation @@ -891,11 +883,7 @@ impl<T: Idx> BitRelations<ChunkedBitSet<T>> for ChunkedBitSet<T> { *self_chunk = other_chunk.clone(); } ( - Mixed( - self_chunk_domain_size, - ref mut self_chunk_count, - ref mut self_chunk_words, - ), + Mixed(self_chunk_domain_size, self_chunk_count, self_chunk_words), Mixed(_other_chunk_domain_size, _other_chunk_count, other_chunk_words), ) => { // See [`<Self as BitRelations<ChunkedBitSet<T>>>::union`] for the explanation diff --git a/compiler/rustc_index_macros/Cargo.toml b/compiler/rustc_index_macros/Cargo.toml index 98bc1b6a29b..891e7ded619 100644 --- a/compiler/rustc_index_macros/Cargo.toml +++ b/compiler/rustc_index_macros/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_index_macros" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] proc-macro = true diff --git a/compiler/rustc_infer/Cargo.toml b/compiler/rustc_infer/Cargo.toml index baf5dbbfd42..08c03614884 100644 --- a/compiler/rustc_infer/Cargo.toml +++ b/compiler/rustc_infer/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_infer" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] doctest = false diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index c2513a1af19..de49c246c15 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -28,7 +28,6 @@ use rustc_middle::bug; use rustc_middle::infer::canonical::{CanonicalQueryInput, CanonicalVarValues}; use rustc_middle::mir::ConstraintCategory; use rustc_middle::traits::select; -pub use rustc_middle::ty::IntVarValue; use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::fold::{ BoundVarReplacerDelegate, TypeFoldable, TypeFolder, TypeSuperFoldable, fold_regions, @@ -950,7 +949,7 @@ impl<'tcx> InferCtxt<'tcx> { let inner = self.inner.borrow(); assert!(!UndoLogs::<UndoLog<'_>>::in_snapshot(&inner.undo_log)); let storage = inner.region_constraint_storage.as_ref().expect("regions already resolved"); - assert!(storage.data.is_empty()); + assert!(storage.data.is_empty(), "{:#?}", storage.data); // We clone instead of taking because borrowck still wants to use the // inference context after calling this for diagnostics and the new // trait solver. diff --git a/compiler/rustc_interface/Cargo.toml b/compiler/rustc_interface/Cargo.toml index 295a988d2da..9c9660cf504 100644 --- a/compiler/rustc_interface/Cargo.toml +++ b/compiler/rustc_interface/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_interface" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index c4b0e244c56..553215ca0af 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -171,13 +171,15 @@ fn configure_and_expand( new_path.push(path); } } - env::set_var( - "PATH", - &env::join_paths( - new_path.iter().filter(|p| env::join_paths(iter::once(p)).is_ok()), - ) - .unwrap(), - ); + unsafe { + env::set_var( + "PATH", + &env::join_paths( + new_path.iter().filter(|p| env::join_paths(iter::once(p)).is_ok()), + ) + .unwrap(), + ); + } } // Create the config for macro expansion @@ -216,7 +218,9 @@ fn configure_and_expand( } if cfg!(windows) { - env::set_var("PATH", &old_path); + unsafe { + env::set_var("PATH", &old_path); + } } krate diff --git a/compiler/rustc_lexer/Cargo.toml b/compiler/rustc_lexer/Cargo.toml index 4b3492fdeda..448a50faf45 100644 --- a/compiler/rustc_lexer/Cargo.toml +++ b/compiler/rustc_lexer/Cargo.toml @@ -2,7 +2,7 @@ name = "rustc_lexer" version = "0.0.0" license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" repository = "https://github.com/rust-lang/rust/" description = """ Rust lexer used by rustc. No stability guarantees are provided. diff --git a/compiler/rustc_lint/Cargo.toml b/compiler/rustc_lint/Cargo.toml index cc5a9029633..24e7b40c8a2 100644 --- a/compiler/rustc_lint/Cargo.toml +++ b/compiler/rustc_lint/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_lint" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index dbe24c9cdf2..67936763427 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -630,7 +630,8 @@ lint_opaque_hidden_inferred_bound_sugg = add this bound lint_or_patterns_back_compat = the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro .suggestion = use pat_param to preserve semantics -lint_out_of_scope_macro_calls = cannot find macro `{$path}` in this scope +lint_out_of_scope_macro_calls = cannot find macro `{$path}` in the current scope when looking from {$location} + .label = not found from {$location} .help = import `macro_rules` with `use` to make it callable above its definition lint_overflowing_bin_hex = literal out of range for `{$ty}` diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index e449f110613..681a76e26f0 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -466,7 +466,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc { MethodLateContext::TraitAutoImpl => {} // If the method is an impl for an item with docs_hidden, don't doc. MethodLateContext::PlainImpl => { - let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id()); + let parent = cx.tcx.hir_get_parent_item(impl_item.hir_id()); let impl_ty = cx.tcx.type_of(parent).instantiate_identity(); let outerdef = match impl_ty.kind() { ty::Adt(def, _) => Some(def.did()), @@ -975,10 +975,8 @@ declare_lint! { /// ### Example /// /// ```rust - /// #[no_mangle] - /// fn foo<T>(t: T) { - /// - /// } + /// #[unsafe(no_mangle)] + /// fn foo<T>(t: T) {} /// ``` /// /// {{produces}} diff --git a/compiler/rustc_lint/src/drop_forget_useless.rs b/compiler/rustc_lint/src/drop_forget_useless.rs index 1ca2e4e74ea..7f098893f7d 100644 --- a/compiler/rustc_lint/src/drop_forget_useless.rs +++ b/compiler/rustc_lint/src/drop_forget_useless.rs @@ -147,7 +147,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless { let is_copy = cx.type_is_copy_modulo_regions(arg_ty); let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr); let let_underscore_ignore_sugg = || { - if let Some((_, node)) = cx.tcx.hir().parent_iter(expr.hir_id).nth(0) + if let Some((_, node)) = cx.tcx.hir_parent_iter(expr.hir_id).nth(0) && let Node::Stmt(stmt) = node && let StmtKind::Semi(e) = stmt.kind && e.hir_id == expr.hir_id diff --git a/compiler/rustc_lint/src/early/diagnostics.rs b/compiler/rustc_lint/src/early/diagnostics.rs index aeb5a03a4f7..40ca9e05d95 100644 --- a/compiler/rustc_lint/src/early/diagnostics.rs +++ b/compiler/rustc_lint/src/early/diagnostics.rs @@ -444,8 +444,8 @@ pub(super) fn decorate_lint( lints::InnerAttributeUnstable::CustomInnerAttribute } .decorate_lint(diag), - BuiltinLintDiag::OutOfScopeMacroCalls { path } => { - lints::OutOfScopeMacroCalls { path }.decorate_lint(diag) + BuiltinLintDiag::OutOfScopeMacroCalls { span, path, location } => { + lints::OutOfScopeMacroCalls { span, path, location }.decorate_lint(diag) } BuiltinLintDiag::UnexpectedBuiltinCfg { cfg, cfg_name, controlled_by } => { lints::UnexpectedBuiltinCfg { cfg, cfg_name, controlled_by }.decorate_lint(diag) diff --git a/compiler/rustc_lint/src/foreign_modules.rs b/compiler/rustc_lint/src/foreign_modules.rs index 636779fe9b4..49c34d0edcc 100644 --- a/compiler/rustc_lint/src/foreign_modules.rs +++ b/compiler/rustc_lint/src/foreign_modules.rs @@ -35,12 +35,12 @@ declare_lint! { /// /// ```rust /// mod m { - /// extern "C" { + /// unsafe extern "C" { /// fn foo(); /// } /// } /// - /// extern "C" { + /// unsafe extern "C" { /// fn foo(_: u32); /// } /// ``` diff --git a/compiler/rustc_lint/src/if_let_rescope.rs b/compiler/rustc_lint/src/if_let_rescope.rs index 869dab6799d..c1aa95667da 100644 --- a/compiler/rustc_lint/src/if_let_rescope.rs +++ b/compiler/rustc_lint/src/if_let_rescope.rs @@ -95,7 +95,7 @@ pub(crate) struct IfLetRescope { } fn expr_parent_is_else(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool { - let Some((_, hir::Node::Expr(expr))) = tcx.hir().parent_iter(hir_id).next() else { + let Some((_, hir::Node::Expr(expr))) = tcx.hir_parent_iter(hir_id).next() else { return false; }; let hir::ExprKind::If(_cond, _conseq, Some(alt)) = expr.kind else { return false }; @@ -103,7 +103,7 @@ fn expr_parent_is_else(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool { } fn expr_parent_is_stmt(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool { - let mut parents = tcx.hir().parent_iter(hir_id); + let mut parents = tcx.hir_parent_iter(hir_id); let stmt = match parents.next() { Some((_, hir::Node::Stmt(stmt))) => stmt, Some((_, hir::Node::Block(_) | hir::Node::Arm(_))) => return true, diff --git a/compiler/rustc_lint/src/impl_trait_overcaptures.rs b/compiler/rustc_lint/src/impl_trait_overcaptures.rs index d2956d94685..0b3af7d6aba 100644 --- a/compiler/rustc_lint/src/impl_trait_overcaptures.rs +++ b/compiler/rustc_lint/src/impl_trait_overcaptures.rs @@ -86,8 +86,7 @@ declare_lint! { /// /// ### Example /// - /// ```rust,compile_fail - /// # #![feature(lifetime_capture_rules_2024)] + /// ```rust,edition2024,compile_fail /// # #![deny(impl_trait_redundant_captures)] /// fn test<'a>(x: &'a i32) -> impl Sized + use<'a> { x } /// ``` @@ -268,8 +267,7 @@ where && parent == self.parent_def_id { let opaque_span = self.tcx.def_span(opaque_def_id); - let new_capture_rules = opaque_span.at_least_rust_2024() - || self.tcx.features().lifetime_capture_rules_2024(); + let new_capture_rules = opaque_span.at_least_rust_2024(); if !new_capture_rules && !opaque.bounds.iter().any(|bound| matches!(bound, hir::GenericBound::Use(..))) { diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index ddc9ae1594f..1f999bbea5f 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -497,7 +497,7 @@ impl Diagnostics { return; }; - for (hir_id, _parent) in cx.tcx.hir().parent_iter(current_id) { + for (hir_id, _parent) in cx.tcx.hir_parent_iter(current_id) { if let Some(owner_did) = hir_id.as_owner() && cx.tcx.has_attr(owner_did, sym::rustc_lint_diagnostics) { @@ -512,7 +512,7 @@ impl Diagnostics { // // Otherwise, emit a `DIAGNOSTIC_OUTSIDE_OF_IMPL` lint. let mut is_inside_appropriate_impl = false; - for (_hir_id, parent) in cx.tcx.hir().parent_iter(current_id) { + for (_hir_id, parent) in cx.tcx.hir_parent_iter(current_id) { debug!(?parent); if let Node::Item(Item { kind: ItemKind::Impl(impl_), .. }) = parent && let Impl { of_trait: Some(of_trait), .. } = impl_ diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 368d36bfdd0..00586309572 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -3108,7 +3108,10 @@ pub(crate) struct UnsafeAttrOutsideUnsafeSuggestion { #[diag(lint_out_of_scope_macro_calls)] #[help] pub(crate) struct OutOfScopeMacroCalls { + #[label] + pub span: Span, pub path: String, + pub location: String, } #[derive(LintDiagnostic)] diff --git a/compiler/rustc_lint/src/non_ascii_idents.rs b/compiler/rustc_lint/src/non_ascii_idents.rs index 2f9cf98848e..66e207a451e 100644 --- a/compiler/rustc_lint/src/non_ascii_idents.rs +++ b/compiler/rustc_lint/src/non_ascii_idents.rs @@ -183,7 +183,7 @@ impl EarlyLintPass for NonAsciiIdents { #[allow(rustc::potential_query_instability)] let mut symbols: Vec<_> = symbols.iter().collect(); symbols.sort_by_key(|k| k.1); - for (symbol, &sp) in symbols.iter() { + for &(ref symbol, &sp) in symbols.iter() { let symbol_str = symbol.as_str(); if symbol_str.is_ascii() { continue; @@ -242,7 +242,7 @@ impl EarlyLintPass for NonAsciiIdents { UnordMap::with_capacity(symbols.len()); let mut skeleton_buf = String::new(); - for (&symbol, &sp) in symbols.iter() { + for &(&symbol, &sp) in symbols.iter() { use unicode_security::confusable_detection::skeleton; let symbol_str = symbol.as_str(); @@ -298,7 +298,7 @@ impl EarlyLintPass for NonAsciiIdents { script_states.insert(latin_augmented_script_set, ScriptSetUsage::Verified); let mut has_suspicious = false; - for (symbol, &sp) in symbols.iter() { + for &(ref symbol, &sp) in symbols.iter() { let symbol_str = symbol.as_str(); for ch in symbol_str.chars() { if ch.is_ascii() { diff --git a/compiler/rustc_lint/src/nonstandard_style.rs b/compiler/rustc_lint/src/nonstandard_style.rs index 5636f80d600..bc35e2f0538 100644 --- a/compiler/rustc_lint/src/nonstandard_style.rs +++ b/compiler/rustc_lint/src/nonstandard_style.rs @@ -344,7 +344,7 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase { ast::attr::find_by_name(cx.tcx.hir().attrs(hir::CRATE_HIR_ID), sym::crate_name) .and_then(|attr| { if let AttrKind::Normal(n) = &attr.kind - && let AttrItem { args: AttrArgs::Eq { eq_span: _, expr: ref lit }, .. } = + && let AttrItem { args: AttrArgs::Eq { eq_span: _, expr: lit }, .. } = n.as_ref() && let ast::LitKind::Str(name, ..) = lit.kind { diff --git a/compiler/rustc_lint/src/shadowed_into_iter.rs b/compiler/rustc_lint/src/shadowed_into_iter.rs index 7cc35e20fcb..571cab934fd 100644 --- a/compiler/rustc_lint/src/shadowed_into_iter.rs +++ b/compiler/rustc_lint/src/shadowed_into_iter.rs @@ -128,7 +128,7 @@ impl<'tcx> LateLintPass<'tcx> for ShadowedIntoIter { // we should just suggest removing the `.into_iter()` or changing it to `.iter()` // to disambiguate if we want to iterate by-value or by-ref. let sub = if let Some((_, hir::Node::Expr(parent_expr))) = - cx.tcx.hir().parent_iter(expr.hir_id).nth(1) + cx.tcx.hir_parent_iter(expr.hir_id).nth(1) && let hir::ExprKind::Match(arg, [_], hir::MatchSource::ForLoopDesugar) = &parent_expr.kind && let hir::ExprKind::Call(path, [_]) = &arg.kind diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 68b1f435a4c..fa019a12469 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -696,7 +696,7 @@ declare_lint! { /// ### Example /// /// ```rust - /// extern "C" { + /// unsafe extern "C" { /// static STATIC: String; /// } /// ``` @@ -1791,7 +1791,7 @@ impl<'tcx> LateLintPass<'tcx> for VariantSizeDifferences { let t = cx.tcx.type_of(it.owner_id).instantiate_identity(); let ty = cx.tcx.erase_regions(t); let Ok(layout) = cx.layout_of(ty) else { return }; - let Variants::Multiple { tag_encoding: TagEncoding::Direct, tag, ref variants, .. } = + let Variants::Multiple { tag_encoding: TagEncoding::Direct, tag, variants, .. } = &layout.variants else { return; diff --git a/compiler/rustc_lint/src/unqualified_local_imports.rs b/compiler/rustc_lint/src/unqualified_local_imports.rs index b27398a950c..50c5119285f 100644 --- a/compiler/rustc_lint/src/unqualified_local_imports.rs +++ b/compiler/rustc_lint/src/unqualified_local_imports.rs @@ -68,7 +68,7 @@ impl<'tcx> LateLintPass<'tcx> for UnqualifiedLocalImports { return; } - let encl_item_id = cx.tcx.hir().get_parent_item(item.hir_id()); + let encl_item_id = cx.tcx.hir_get_parent_item(item.hir_id()); let encl_item = cx.tcx.hir_node_by_def_id(encl_item_id.def_id); if encl_item.fn_kind().is_some() { // `use` in a method -- don't lint, that leads to too many undesirable lints diff --git a/compiler/rustc_lint_defs/Cargo.toml b/compiler/rustc_lint_defs/Cargo.toml index 450885e7164..9ab350daf69 100644 --- a/compiler/rustc_lint_defs/Cargo.toml +++ b/compiler/rustc_lint_defs/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_lint_defs" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 10bf4ec77ed..97850a2afc1 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -2780,7 +2780,7 @@ declare_lint! { /// /// ```rust /// enum Void {} - /// extern { + /// unsafe extern { /// static EXTERN: Void; /// } /// ``` @@ -4011,7 +4011,7 @@ declare_lint! { /// ```rust /// #![warn(ffi_unwind_calls)] /// - /// extern "C-unwind" { + /// unsafe extern "C-unwind" { /// fn foo(); /// } /// @@ -4755,7 +4755,7 @@ declare_lint! { /// /// ### Example /// - /// ```rust + /// ```rust,edition2021 /// #![warn(missing_unsafe_on_extern)] /// #![allow(dead_code)] /// @@ -4792,7 +4792,7 @@ declare_lint! { /// /// ### Example /// - /// ```rust + /// ```rust,edition2021 /// #![warn(unsafe_attr_outside_unsafe)] /// /// #[no_mangle] diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 7ffe4e4e490..ff3dae08ffc 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -134,8 +134,8 @@ impl LintExpectationId { } pub fn set_lint_index(&mut self, new_lint_index: Option<u16>) { - let (LintExpectationId::Unstable { ref mut lint_index, .. } - | LintExpectationId::Stable { ref mut lint_index, .. }) = self; + let (LintExpectationId::Unstable { lint_index, .. } + | LintExpectationId::Stable { lint_index, .. }) = self; *lint_index = new_lint_index } @@ -819,7 +819,9 @@ pub enum BuiltinLintDiag { is_macro: bool, }, OutOfScopeMacroCalls { + span: Span, path: String, + location: String, }, UnexpectedBuiltinCfg { cfg: String, diff --git a/compiler/rustc_llvm/Cargo.toml b/compiler/rustc_llvm/Cargo.toml index 2168a0df9ec..4f3ce77efc4 100644 --- a/compiler/rustc_llvm/Cargo.toml +++ b/compiler/rustc_llvm/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_llvm" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index 48806888b43..3d1f3b2cd4d 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -51,9 +51,13 @@ fn detect_llvm_link() -> (&'static str, &'static str) { fn restore_library_path() { let key = tracked_env_var_os("REAL_LIBRARY_PATH_VAR").expect("REAL_LIBRARY_PATH_VAR"); if let Some(env) = tracked_env_var_os("REAL_LIBRARY_PATH") { - env::set_var(&key, env); + unsafe { + env::set_var(&key, env); + } } else { - env::remove_var(&key); + unsafe { + env::remove_var(&key); + } } } diff --git a/compiler/rustc_log/Cargo.toml b/compiler/rustc_log/Cargo.toml index fe399bc77e3..30f6e9ba805 100644 --- a/compiler/rustc_log/Cargo.toml +++ b/compiler/rustc_log/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_log" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_macros/Cargo.toml b/compiler/rustc_macros/Cargo.toml index d8d2bef4964..f9d3b758359 100644 --- a/compiler/rustc_macros/Cargo.toml +++ b/compiler/rustc_macros/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_macros" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] proc-macro = true diff --git a/compiler/rustc_macros/src/diagnostics/utils.rs b/compiler/rustc_macros/src/diagnostics/utils.rs index 612a36ba9aa..060799e981d 100644 --- a/compiler/rustc_macros/src/diagnostics/utils.rs +++ b/compiler/rustc_macros/src/diagnostics/utils.rs @@ -760,8 +760,8 @@ impl SubdiagnosticVariant { } ( "applicability", - SubdiagnosticKind::Suggestion { ref mut applicability, .. } - | SubdiagnosticKind::MultipartSuggestion { ref mut applicability, .. }, + SubdiagnosticKind::Suggestion { applicability, .. } + | SubdiagnosticKind::MultipartSuggestion { applicability, .. }, ) => { let value = get_string!(); let value = Applicability::from_str(&value.value()).unwrap_or_else(|()| { diff --git a/compiler/rustc_metadata/Cargo.toml b/compiler/rustc_metadata/Cargo.toml index 0b9fdbbd3da..a8821640f04 100644 --- a/compiler/rustc_metadata/Cargo.toml +++ b/compiler/rustc_metadata/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_metadata" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index 389c861c3b5..aebd2181f31 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_middle" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_middle/src/hir/map.rs b/compiler/rustc_middle/src/hir/map.rs index 3436c2f372f..40dd6aa73fd 100644 --- a/compiler/rustc_middle/src/hir/map.rs +++ b/compiler/rustc_middle/src/hir/map.rs @@ -28,22 +28,22 @@ pub struct Map<'hir> { } /// An iterator that walks up the ancestor tree of a given `HirId`. -/// Constructed using `tcx.hir().parent_iter(hir_id)`. -struct ParentHirIterator<'hir> { +/// Constructed using `tcx.hir_parent_iter(hir_id)`. +struct ParentHirIterator<'tcx> { current_id: HirId, - map: Map<'hir>, + tcx: TyCtxt<'tcx>, // Cache the current value of `hir_owner_nodes` to avoid repeatedly calling the same query for // the same owner, which will uselessly record many times the same query dependency. - current_owner_nodes: Option<&'hir OwnerNodes<'hir>>, + current_owner_nodes: Option<&'tcx OwnerNodes<'tcx>>, } -impl<'hir> ParentHirIterator<'hir> { - fn new(map: Map<'hir>, current_id: HirId) -> ParentHirIterator<'hir> { - ParentHirIterator { current_id, map, current_owner_nodes: None } +impl<'tcx> ParentHirIterator<'tcx> { + fn new(tcx: TyCtxt<'tcx>, current_id: HirId) -> ParentHirIterator<'tcx> { + ParentHirIterator { current_id, tcx, current_owner_nodes: None } } } -impl<'hir> Iterator for ParentHirIterator<'hir> { +impl<'tcx> Iterator for ParentHirIterator<'tcx> { type Item = HirId; fn next(&mut self) -> Option<Self::Item> { @@ -56,10 +56,10 @@ impl<'hir> Iterator for ParentHirIterator<'hir> { let parent_id = if local_id == ItemLocalId::ZERO { // We go from an owner to its parent, so clear the cache. self.current_owner_nodes = None; - self.map.tcx.hir_owner_parent(owner) + self.tcx.hir_owner_parent(owner) } else { let owner_nodes = - self.current_owner_nodes.get_or_insert_with(|| self.map.tcx.hir_owner_nodes(owner)); + self.current_owner_nodes.get_or_insert_with(|| self.tcx.hir_owner_nodes(owner)); let parent_local_id = owner_nodes.nodes[local_id].parent; // HIR indexing should have checked that. debug_assert_ne!(parent_local_id, local_id); @@ -74,33 +74,33 @@ impl<'hir> Iterator for ParentHirIterator<'hir> { } /// An iterator that walks up the ancestor tree of a given `HirId`. -/// Constructed using `tcx.hir().parent_owner_iter(hir_id)`. -pub struct ParentOwnerIterator<'hir> { +/// Constructed using `tcx.hir_parent_owner_iter(hir_id)`. +pub struct ParentOwnerIterator<'tcx> { current_id: HirId, - map: Map<'hir>, + tcx: TyCtxt<'tcx>, } -impl<'hir> Iterator for ParentOwnerIterator<'hir> { - type Item = (OwnerId, OwnerNode<'hir>); +impl<'tcx> Iterator for ParentOwnerIterator<'tcx> { + type Item = (OwnerId, OwnerNode<'tcx>); fn next(&mut self) -> Option<Self::Item> { if self.current_id.local_id.index() != 0 { self.current_id.local_id = ItemLocalId::ZERO; - let node = self.map.tcx.hir_owner_node(self.current_id.owner); + let node = self.tcx.hir_owner_node(self.current_id.owner); return Some((self.current_id.owner, node)); } if self.current_id == CRATE_HIR_ID { return None; } - let parent_id = self.map.tcx.hir_def_key(self.current_id.owner.def_id).parent; + let parent_id = self.tcx.hir_def_key(self.current_id.owner.def_id).parent; let parent_id = parent_id.map_or(CRATE_OWNER_ID, |local_def_index| { let def_id = LocalDefId { local_def_index }; - self.map.tcx.local_def_id_to_hir_id(def_id).owner + self.tcx.local_def_id_to_hir_id(def_id).owner }); self.current_id = HirId::make_owner(parent_id.def_id); - let node = self.map.tcx.hir_owner_node(self.current_id.owner); + let node = self.tcx.hir_owner_node(self.current_id.owner); Some((self.current_id.owner, node)) } } @@ -146,7 +146,7 @@ impl<'tcx> TyCtxt<'tcx> { /// Returns `HirId` of the parent HIR node of node with this `hir_id`. /// Returns the same `hir_id` if and only if `hir_id == CRATE_HIR_ID`. /// - /// If calling repeatedly and iterating over parents, prefer [`Map::parent_iter`]. + /// If calling repeatedly and iterating over parents, prefer [`TyCtxt::hir_parent_iter`]. pub fn parent_hir_id(self, hir_id: HirId) -> HirId { let HirId { owner, local_id } = hir_id; if local_id == ItemLocalId::ZERO { @@ -242,7 +242,7 @@ impl<'tcx> TyCtxt<'tcx> { #[track_caller] pub fn hir_enclosing_body_owner(self, hir_id: HirId) -> LocalDefId { - for (_, node) in self.hir().parent_iter(hir_id) { + for (_, node) in self.hir_parent_iter(hir_id) { if let Some((def_id, _)) = node.associated_body() { return def_id; } @@ -498,33 +498,31 @@ impl<'tcx> TyCtxt<'tcx> { f(LocalModDefId::new_unchecked(module.def_id)) }) } -} -impl<'hir> Map<'hir> { /// Returns an iterator for the nodes in the ancestor tree of the `current_id` /// until the crate root is reached. Prefer this over your own loop using `parent_id`. #[inline] - pub fn parent_id_iter(self, current_id: HirId) -> impl Iterator<Item = HirId> + 'hir { + pub fn hir_parent_id_iter(self, current_id: HirId) -> impl Iterator<Item = HirId> + 'tcx { ParentHirIterator::new(self, current_id) } /// Returns an iterator for the nodes in the ancestor tree of the `current_id` /// until the crate root is reached. Prefer this over your own loop using `parent_id`. #[inline] - pub fn parent_iter(self, current_id: HirId) -> impl Iterator<Item = (HirId, Node<'hir>)> { - self.parent_id_iter(current_id).map(move |id| (id, self.tcx.hir_node(id))) + pub fn hir_parent_iter(self, current_id: HirId) -> impl Iterator<Item = (HirId, Node<'tcx>)> { + self.hir_parent_id_iter(current_id).map(move |id| (id, self.hir_node(id))) } /// Returns an iterator for the nodes in the ancestor tree of the `current_id` /// until the crate root is reached. Prefer this over your own loop using `parent_id`. #[inline] - pub fn parent_owner_iter(self, current_id: HirId) -> ParentOwnerIterator<'hir> { - ParentOwnerIterator { current_id, map: self } + pub fn hir_parent_owner_iter(self, current_id: HirId) -> ParentOwnerIterator<'tcx> { + ParentOwnerIterator { current_id, tcx: self } } /// Checks if the node is left-hand side of an assignment. - pub fn is_lhs(self, id: HirId) -> bool { - match self.tcx.parent_hir_node(id) { + pub fn hir_is_lhs(self, id: HirId) -> bool { + match self.parent_hir_node(id) { Node::Expr(expr) => match expr.kind { ExprKind::Assign(lhs, _rhs, _span) => lhs.hir_id == id, _ => false, @@ -535,8 +533,8 @@ impl<'hir> Map<'hir> { /// Whether the expression pointed at by `hir_id` belongs to a `const` evaluation context. /// Used exclusively for diagnostics, to avoid suggestion function calls. - pub fn is_inside_const_context(self, hir_id: HirId) -> bool { - self.tcx.hir_body_const_context(self.tcx.hir_enclosing_body_owner(hir_id)).is_some() + pub fn hir_is_inside_const_context(self, hir_id: HirId) -> bool { + self.hir_body_const_context(self.hir_enclosing_body_owner(hir_id)).is_some() } /// Retrieves the `HirId` for `id`'s enclosing function *if* the `id` block or return is @@ -561,12 +559,11 @@ impl<'hir> Map<'hir> { /// false /// } /// ``` - pub fn get_fn_id_for_return_block(self, id: HirId) -> Option<HirId> { - let enclosing_body_owner = - self.tcx.local_def_id_to_hir_id(self.tcx.hir_enclosing_body_owner(id)); + pub fn hir_get_fn_id_for_return_block(self, id: HirId) -> Option<HirId> { + let enclosing_body_owner = self.local_def_id_to_hir_id(self.hir_enclosing_body_owner(id)); // Return `None` if the `id` expression is not the returned value of the enclosing body - let mut iter = [id].into_iter().chain(self.parent_id_iter(id)).peekable(); + let mut iter = [id].into_iter().chain(self.hir_parent_id_iter(id)).peekable(); while let Some(cur_id) = iter.next() { if enclosing_body_owner == cur_id { break; @@ -574,14 +571,16 @@ impl<'hir> Map<'hir> { // A return statement is always the value returned from the enclosing body regardless of // what the parent expressions are. - if let Node::Expr(Expr { kind: ExprKind::Ret(_), .. }) = self.tcx.hir_node(cur_id) { + if let Node::Expr(Expr { kind: ExprKind::Ret(_), .. }) = self.hir_node(cur_id) { break; } - // If the current expression's value doesnt get used as the parent expressions value then return `None` + // If the current expression's value doesnt get used as the parent expressions value + // then return `None` if let Some(&parent_id) = iter.peek() { - match self.tcx.hir_node(parent_id) { - // The current node is not the tail expression of the block expression parent expr. + match self.hir_node(parent_id) { + // The current node is not the tail expression of the block expression parent + // expr. Node::Block(Block { expr: Some(e), .. }) if cur_id != e.hir_id => return None, Node::Block(Block { expr: Some(e), .. }) if matches!(e.kind, ExprKind::If(_, _, None)) => @@ -589,7 +588,8 @@ impl<'hir> Map<'hir> { return None; } - // The current expression's value does not pass up through these parent expressions + // The current expression's value does not pass up through these parent + // expressions. Node::Block(Block { expr: None, .. }) | Node::Expr(Expr { kind: ExprKind::Loop(..), .. }) | Node::LetStmt(..) => return None, @@ -606,11 +606,11 @@ impl<'hir> Map<'hir> { /// parent item is in this map. The "parent item" is the closest parent node /// in the HIR which is recorded by the map and is an item, either an item /// in a module, trait, or impl. - pub fn get_parent_item(self, hir_id: HirId) -> OwnerId { + pub fn hir_get_parent_item(self, hir_id: HirId) -> OwnerId { if hir_id.local_id != ItemLocalId::ZERO { // If this is a child of a HIR owner, return the owner. hir_id.owner - } else if let Some((def_id, _node)) = self.parent_owner_iter(hir_id).next() { + } else if let Some((def_id, _node)) = self.hir_parent_owner_iter(hir_id).next() { def_id } else { CRATE_OWNER_ID @@ -622,8 +622,8 @@ impl<'hir> Map<'hir> { /// /// Used by error reporting when there's a type error in an if or match arm caused by the /// expression needing to be unit. - pub fn get_if_cause(self, hir_id: HirId) -> Option<&'hir Expr<'hir>> { - for (_, node) in self.parent_iter(hir_id) { + pub fn hir_get_if_cause(self, hir_id: HirId) -> Option<&'tcx Expr<'tcx>> { + for (_, node) in self.hir_parent_iter(hir_id) { match node { Node::Item(_) | Node::ForeignItem(_) @@ -640,8 +640,8 @@ impl<'hir> Map<'hir> { } /// Returns the nearest enclosing scope. A scope is roughly an item or block. - pub fn get_enclosing_scope(self, hir_id: HirId) -> Option<HirId> { - for (hir_id, node) in self.parent_iter(hir_id) { + pub fn hir_get_enclosing_scope(self, hir_id: HirId) -> Option<HirId> { + for (hir_id, node) in self.hir_parent_iter(hir_id) { if let Node::Item(Item { kind: ItemKind::Fn { .. } @@ -667,18 +667,20 @@ impl<'hir> Map<'hir> { } /// Returns the defining scope for an opaque type definition. - pub fn get_defining_scope(self, id: HirId) -> HirId { + pub fn hir_get_defining_scope(self, id: HirId) -> HirId { let mut scope = id; loop { - scope = self.get_enclosing_scope(scope).unwrap_or(CRATE_HIR_ID); - if scope == CRATE_HIR_ID || !matches!(self.tcx.hir_node(scope), Node::Block(_)) { + scope = self.hir_get_enclosing_scope(scope).unwrap_or(CRATE_HIR_ID); + if scope == CRATE_HIR_ID || !matches!(self.hir_node(scope), Node::Block(_)) { return scope; } } } +} +impl<'hir> Map<'hir> { pub fn get_foreign_abi(self, hir_id: HirId) -> ExternAbi { - let parent = self.get_parent_item(hir_id); + let parent = self.tcx.hir_get_parent_item(hir_id); if let OwnerNode::Item(Item { kind: ItemKind::ForeignMod { abi, .. }, .. }) = self.tcx.hir_owner_node(parent) { diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index ab711aca573..88bf17070b9 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -131,7 +131,7 @@ impl ShallowLintLevelMap { let mut owner = start.owner; let mut specs = &self.specs; - for parent in tcx.hir().parent_id_iter(start) { + for parent in tcx.hir_parent_id_iter(start) { if parent.owner != owner { owner = parent.owner; specs = &tcx.shallow_lint_levels_on(owner).specs; diff --git a/compiler/rustc_middle/src/middle/mod.rs b/compiler/rustc_middle/src/middle/mod.rs index 9f71971ea08..4587dcaddc4 100644 --- a/compiler/rustc_middle/src/middle/mod.rs +++ b/compiler/rustc_middle/src/middle/mod.rs @@ -25,7 +25,7 @@ pub mod lib_features { self.stability .to_sorted_stable_ord() .iter() - .map(|(&sym, &(stab, _))| (sym, stab)) + .map(|&(&sym, &(stab, _))| (sym, stab)) .collect() } } diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs index 93bbf6d7fa4..2260cad41b9 100644 --- a/compiler/rustc_middle/src/middle/stability.rs +++ b/compiler/rustc_middle/src/middle/stability.rs @@ -373,7 +373,7 @@ impl<'tcx> TyCtxt<'tcx> { // Deprecated attributes apply in-crate and cross-crate. if let Some(id) = id { if let Some(depr_entry) = self.lookup_deprecation_entry(def_id) { - let parent_def_id = self.hir().get_parent_item(id); + let parent_def_id = self.hir_get_parent_item(id); let skip = self .lookup_deprecation_entry(parent_def_id.to_def_id()) .is_some_and(|parent_depr| parent_depr.same_origin(&depr_entry)); diff --git a/compiler/rustc_middle/src/mir/basic_blocks.rs b/compiler/rustc_middle/src/mir/basic_blocks.rs index 107c3198525..171542d1279 100644 --- a/compiler/rustc_middle/src/mir/basic_blocks.rs +++ b/compiler/rustc_middle/src/mir/basic_blocks.rs @@ -79,7 +79,7 @@ impl<'tcx> BasicBlocks<'tcx> { #[inline] pub fn reverse_postorder(&self) -> &[BasicBlock] { self.cache.reverse_postorder.get_or_init(|| { - let mut rpo: Vec<_> = Postorder::new(&self.basic_blocks, START_BLOCK, ()).collect(); + let mut rpo: Vec<_> = Postorder::new(&self.basic_blocks, START_BLOCK, None).collect(); rpo.reverse(); rpo }) diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 71fed4b3e1e..227cb97c76b 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -30,7 +30,6 @@ use rustc_span::{DUMMY_SP, Span, Symbol}; use tracing::{debug, trace}; pub use self::query::*; -use self::visit::TyContext; use crate::mir::interpret::{AllocRange, Scalar}; use crate::ty::codec::{TyDecoder, TyEncoder}; use crate::ty::print::{FmtPrinter, Printer, pretty_print_const, with_no_trimmed_paths}; @@ -98,24 +97,17 @@ impl<'tcx> HasLocalDecls<'tcx> for Body<'tcx> { } impl MirPhase { - /// Gets the index of the current MirPhase within the set of all `MirPhase`s. - /// - /// FIXME(JakobDegen): Return a `(usize, usize)` instead. - pub fn phase_index(&self) -> usize { - const BUILT_PHASE_COUNT: usize = 1; - const ANALYSIS_PHASE_COUNT: usize = 2; - match self { - MirPhase::Built => 1, - MirPhase::Analysis(analysis_phase) => { - 1 + BUILT_PHASE_COUNT + (*analysis_phase as usize) - } - MirPhase::Runtime(runtime_phase) => { - 1 + BUILT_PHASE_COUNT + ANALYSIS_PHASE_COUNT + (*runtime_phase as usize) - } + /// Gets the (dialect, phase) index of the current `MirPhase`. Both numbers + /// are 1-indexed. + pub fn index(&self) -> (usize, usize) { + match *self { + MirPhase::Built => (1, 1), + MirPhase::Analysis(analysis_phase) => (2, 1 + analysis_phase as usize), + MirPhase::Runtime(runtime_phase) => (3, 1 + runtime_phase as usize), } } - /// Parses an `MirPhase` from a pair of strings. Panics if this isn't possible for any reason. + /// Parses a `MirPhase` from a pair of strings. Panics if this isn't possible for any reason. pub fn parse(dialect: String, phase: Option<String>) -> Self { match &*dialect.to_ascii_lowercase() { "built" => { @@ -539,17 +531,6 @@ impl<'tcx> Body<'tcx> { } } - pub fn span_for_ty_context(&self, ty_context: TyContext) -> Span { - match ty_context { - TyContext::UserTy(span) => span, - TyContext::ReturnTy(source_info) - | TyContext::LocalDecl { source_info, .. } - | TyContext::YieldTy(source_info) - | TyContext::ResumeTy(source_info) => source_info.span, - TyContext::Location(loc) => self.source_info(loc).span, - } - } - /// Returns the return type; it always return first element from `local_decls` array. #[inline] pub fn return_ty(&self) -> Ty<'tcx> { @@ -791,7 +772,7 @@ impl<T> ClearCrossCrate<T> { } } - pub fn assert_crate_local(self) -> T { + pub fn unwrap_crate_local(self) -> T { match self { ClearCrossCrate::Clear => bug!("unwrapping cross-crate data"), ClearCrossCrate::Set(v) => v, @@ -948,7 +929,7 @@ mod binding_form_impl { /// involved in borrow_check errors, e.g., explanations of where the /// temporaries come from, when their destructors are run, and/or how /// one might revise the code to satisfy the borrow checker's rules. -#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)] pub struct BlockTailInfo { /// If `true`, then the value resulting from evaluating this tail /// expression is ignored by the block's expression context. @@ -972,7 +953,6 @@ pub struct LocalDecl<'tcx> { /// Temporaries and the return place are always mutable. pub mutability: Mutability, - // FIXME(matthewjasper) Don't store in this in `Body` pub local_info: ClearCrossCrate<Box<LocalInfo<'tcx>>>, /// The type of this local. @@ -982,7 +962,6 @@ pub struct LocalDecl<'tcx> { /// e.g., via `let x: T`, then we carry that type here. The MIR /// borrow checker needs this information since it can affect /// region inference. - // FIXME(matthewjasper) Don't store in this in `Body` pub user_ty: Option<Box<UserTypeProjections>>, /// The *syntactic* (i.e., not visibility) source scope the local is defined @@ -1090,7 +1069,6 @@ pub enum LocalInfo<'tcx> { AggregateTemp, /// A temporary created for evaluation of some subexpression of some block's tail expression /// (with no intervening statement context). - // FIXME(matthewjasper) Don't store in this in `Body` BlockTailTemp(BlockTailInfo), /// A temporary created during evaluating `if` predicate, possibly for pattern matching for `let`s, /// and subject to Edition 2024 temporary lifetime rules @@ -1105,7 +1083,7 @@ pub enum LocalInfo<'tcx> { impl<'tcx> LocalDecl<'tcx> { pub fn local_info(&self) -> &LocalInfo<'tcx> { - self.local_info.as_ref().assert_crate_local() + self.local_info.as_ref().unwrap_crate_local() } /// Returns `true` only if local is a binding that can itself be diff --git a/compiler/rustc_middle/src/mir/mono.rs b/compiler/rustc_middle/src/mir/mono.rs index 4a21b6ad237..58d5c94d033 100644 --- a/compiler/rustc_middle/src/mir/mono.rs +++ b/compiler/rustc_middle/src/mir/mono.rs @@ -243,7 +243,7 @@ impl<'tcx> MonoItem<'tcx> { /// Returns the item's `CrateNum` pub fn krate(&self) -> CrateNum { match self { - MonoItem::Fn(ref instance) => instance.def_id().krate, + MonoItem::Fn(instance) => instance.def_id().krate, MonoItem::Static(def_id) => def_id.krate, MonoItem::GlobalAsm(..) => LOCAL_CRATE, } diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs index 1e3b8d029e1..1d61cf48ad2 100644 --- a/compiler/rustc_middle/src/mir/pretty.rs +++ b/compiler/rustc_middle/src/mir/pretty.rs @@ -22,7 +22,7 @@ pub(crate) const ALIGN: usize = 40; /// An indication of where we are in the control flow graph. Used for printing /// extra information in `dump_mir` -#[derive(Clone)] +#[derive(Clone, Copy)] pub enum PassWhere { /// We have not started dumping the control flow graph, but we are about to. BeforeCFG, @@ -231,7 +231,8 @@ fn dump_path<'tcx>( let pass_num = if tcx.sess.opts.unstable_opts.dump_mir_exclude_pass_number { String::new() } else if pass_num { - format!(".{:03}-{:03}", body.phase.phase_index(), body.pass_count) + let (dialect_index, phase_index) = body.phase.index(); + format!(".{}-{}-{:03}", dialect_index, phase_index, body.pass_count) } else { ".-------".to_string() }; @@ -969,7 +970,7 @@ impl<'tcx> TerminatorKind<'tcx> { } FalseEdge { .. } => write!(fmt, "falseEdge"), FalseUnwind { .. } => write!(fmt, "falseUnwind"), - InlineAsm { template, ref operands, options, .. } => { + InlineAsm { template, operands, options, .. } => { write!(fmt, "asm!(\"{}\"", InlineAsmTemplatePiece::to_string(template))?; for op in operands { write!(fmt, ", ")?; diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index 389792a04f8..af6f0e4c551 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -23,68 +23,77 @@ use crate::ty::{self, GenericArgsRef, List, Region, Ty, UserTypeAnnotationIndex} /// Represents the "flavors" of MIR. /// -/// All flavors of MIR use the same data structure, but there are some important differences. These -/// differences come in two forms: Dialects and phases. +/// The MIR pipeline is structured into a few major dialects, with one or more phases within each +/// dialect. A MIR flavor is identified by a dialect-phase pair. A single `MirPhase` value +/// specifies such a pair. All flavors of MIR use the same data structure to represent the program. /// -/// Dialects represent a stronger distinction than phases. This is because the transitions between -/// dialects are semantic changes, and therefore technically *lowerings* between distinct IRs. In -/// other words, the same [`Body`](crate::mir::Body) might be well-formed for multiple dialects, but -/// have different semantic meaning and different behavior at runtime. +/// Different MIR dialects have different semantics. (The differences between dialects are small, +/// but they do exist.) The progression from one MIR dialect to the next is technically a lowering +/// from one IR to another. In other words, a single well-formed [`Body`](crate::mir::Body) might +/// have different semantic meaning and different behavior at runtime in the different dialects. +/// The specific differences between dialects are described on the variants below. /// -/// Each dialect additionally has a number of phases. However, phase changes never involve semantic -/// changes. If some MIR is well-formed both before and after a phase change, it is also guaranteed -/// that it has the same semantic meaning. In this sense, phase changes can only add additional -/// restrictions on what MIR is well-formed. +/// Phases exist only to place restrictions on what language constructs are permitted in +/// well-formed MIR, and subsequent phases mostly increase those restrictions. I.e. to convert MIR +/// from one phase to the next might require removing/replacing certain MIR constructs. /// -/// When adding phases, remember to update [`MirPhase::phase_index`]. +/// When adding dialects or phases, remember to update [`MirPhase::index`]. #[derive(Copy, Clone, TyEncodable, TyDecodable, Debug, PartialEq, Eq, PartialOrd, Ord)] #[derive(HashStable)] pub enum MirPhase { - /// The MIR that is generated by MIR building. + /// The "built MIR" dialect, as generated by MIR building. /// /// The only things that operate on this dialect are unsafeck, the various MIR lints, and const /// qualifs. /// - /// This has no distinct phases. + /// This dialect has just the one (implicit) phase, which places few restrictions on what MIR + /// constructs are allowed. Built, - /// The MIR used for most analysis. + + /// The "analysis MIR" dialect, used for borrowck and friends. /// - /// The only semantic change between analysis and built MIR is constant promotion. In built MIR, - /// sequences of statements that would generally be subject to constant promotion are - /// semantically constants, while in analysis MIR all constants are explicit. + /// The only semantic difference between built MIR and analysis MIR relates to constant + /// promotion. In built MIR, sequences of statements that would generally be subject to + /// constant promotion are semantically constants, while in analysis MIR all constants are + /// explicit. /// - /// The result of const promotion is available from the `mir_promoted` and `promoted_mir` queries. + /// The result of const promotion is available from the `mir_promoted` and `promoted_mir` + /// queries. /// - /// This is the version of MIR used by borrowck and friends. + /// The phases of this dialect are described in `AnalysisPhase`. Analysis(AnalysisPhase), - /// The MIR used for CTFE, optimizations, and codegen. - /// - /// The semantic changes that occur in the lowering from analysis to runtime MIR are as follows: - /// - /// - Drops: In analysis MIR, `Drop` terminators represent *conditional* drops; roughly speaking, - /// if dataflow analysis determines that the place being dropped is uninitialized, the drop will - /// not be executed. The exact semantics of this aren't written down anywhere, which means they - /// are essentially "what drop elaboration does." In runtime MIR, the drops are unconditional; - /// when a `Drop` terminator is reached, if the type has drop glue that drop glue is always - /// executed. This may be UB if the underlying place is not initialized. - /// - Packed drops: Places might in general be misaligned - in most cases this is UB, the exception - /// is fields of packed structs. In analysis MIR, `Drop(P)` for a `P` that might be misaligned - /// for this reason implicitly moves `P` to a temporary before dropping. Runtime MIR has no such - /// rules, and dropping a misaligned place is simply UB. - /// - Unwinding: in analysis MIR, unwinding from a function which may not unwind aborts. In runtime - /// MIR, this is UB. - /// - Retags: If `-Zmir-emit-retag` is enabled, analysis MIR has "implicit" retags in the same way - /// that Rust itself has them. Where exactly these are is generally subject to change, and so we - /// don't document this here. Runtime MIR has most retags explicit (though implicit retags - /// can still occur at `Rvalue::{Ref,AddrOf}`). - /// - Coroutine bodies: In analysis MIR, locals may actually be behind a pointer that user code has - /// access to. This occurs in coroutine bodies. Such locals do not behave like other locals, - /// because they eg may be aliased in surprising ways. Runtime MIR has no such special locals - - /// all coroutine bodies are lowered and so all places that look like locals really are locals. + + /// The "runtime MIR" dialect, used for CTFE, optimizations, and codegen. + /// + /// The semantic differences between analysis MIR and runtime MIR are as follows. + /// + /// - Drops: In analysis MIR, `Drop` terminators represent *conditional* drops; roughly + /// speaking, if dataflow analysis determines that the place being dropped is uninitialized, + /// the drop will not be executed. The exact semantics of this aren't written down anywhere, + /// which means they are essentially "what drop elaboration does." In runtime MIR, the drops + /// are unconditional; when a `Drop` terminator is reached, if the type has drop glue that + /// drop glue is always executed. This may be UB if the underlying place is not initialized. + /// - Packed drops: Places might in general be misaligned - in most cases this is UB, the + /// exception is fields of packed structs. In analysis MIR, `Drop(P)` for a `P` that might be + /// misaligned for this reason implicitly moves `P` to a temporary before dropping. Runtime + /// MIR has no such rules, and dropping a misaligned place is simply UB. + /// - Unwinding: in analysis MIR, unwinding from a function which may not unwind aborts. In + /// runtime MIR, this is UB. + /// - Retags: If `-Zmir-emit-retag` is enabled, analysis MIR has "implicit" retags in the same + /// way that Rust itself has them. Where exactly these are is generally subject to change, + /// and so we don't document this here. Runtime MIR has most retags explicit (though implicit + /// retags can still occur at `Rvalue::{Ref,AddrOf}`). + /// - Coroutine bodies: In analysis MIR, locals may actually be behind a pointer that user code + /// has access to. This occurs in coroutine bodies. Such locals do not behave like other + /// locals, because they e.g. may be aliased in surprising ways. Runtime MIR has no such + /// special locals. All coroutine bodies are lowered and so all places that look like locals + /// really are locals. /// /// Also note that the lint pass which reports eg `200_u8 + 200_u8` as an error is run as a part /// of analysis to runtime MIR lowering. To ensure lints are reported reliably, this means that - /// transformations which may suppress such errors should not run on analysis MIR. + /// transformations that can suppress such errors should not run on analysis MIR. + /// + /// The phases of this dialect are described in `RuntimePhase`. Runtime(RuntimePhase), } @@ -111,7 +120,8 @@ pub enum AnalysisPhase { /// * [`TerminatorKind::FalseEdge`] /// * [`StatementKind::FakeRead`] /// * [`StatementKind::AscribeUserType`] - /// * [`StatementKind::Coverage`] with [`CoverageKind::BlockMarker`] or [`CoverageKind::SpanMarker`] + /// * [`StatementKind::Coverage`] with [`CoverageKind::BlockMarker`] or + /// [`CoverageKind::SpanMarker`] /// * [`Rvalue::Ref`] with `BorrowKind::Fake` /// * [`CastKind::PointerCoercion`] with any of the following: /// * [`PointerCoercion::ArrayToPointer`] diff --git a/compiler/rustc_middle/src/mir/terminator.rs b/compiler/rustc_middle/src/mir/terminator.rs index 9357e19f7c5..fdfcb128778 100644 --- a/compiler/rustc_middle/src/mir/terminator.rs +++ b/compiler/rustc_middle/src/mir/terminator.rs @@ -86,7 +86,7 @@ impl SwitchTargets { self.iter().find_map(|(v, t)| (v == value).then_some(t)).unwrap_or_else(|| self.otherwise()) } - /// Adds a new target to the switch. But You cannot add an already present value. + /// Adds a new target to the switch. Panics if you add an already present value. #[inline] pub fn add_target(&mut self, value: u128, bb: BasicBlock) { let value = Pu128(value); @@ -226,7 +226,7 @@ impl<O> AssertKind<O> { { use AssertKind::*; match self { - BoundsCheck { ref len, ref index } => write!( + BoundsCheck { len, index } => write!( f, "\"index out of bounds: the length is {{}} but the index is {{}}\", {len:?}, {index:?}" ), diff --git a/compiler/rustc_middle/src/mir/traversal.rs b/compiler/rustc_middle/src/mir/traversal.rs index 0e7dcc24daf..5950ac295af 100644 --- a/compiler/rustc_middle/src/mir/traversal.rs +++ b/compiler/rustc_middle/src/mir/traversal.rs @@ -104,23 +104,21 @@ impl<'a, 'tcx> Iterator for Preorder<'a, 'tcx> { /// ``` /// /// A Postorder traversal of this graph is `D B C A` or `D C B A` -pub struct Postorder<'a, 'tcx, C> { +pub struct Postorder<'a, 'tcx> { basic_blocks: &'a IndexSlice<BasicBlock, BasicBlockData<'tcx>>, visited: DenseBitSet<BasicBlock>, visit_stack: Vec<(BasicBlock, Successors<'a>)>, root_is_start_block: bool, - extra: C, + /// A non-empty `extra` allows for a precise calculation of the successors. + extra: Option<(TyCtxt<'tcx>, Instance<'tcx>)>, } -impl<'a, 'tcx, C> Postorder<'a, 'tcx, C> -where - C: Customization<'tcx>, -{ +impl<'a, 'tcx> Postorder<'a, 'tcx> { pub fn new( basic_blocks: &'a IndexSlice<BasicBlock, BasicBlockData<'tcx>>, root: BasicBlock, - extra: C, - ) -> Postorder<'a, 'tcx, C> { + extra: Option<(TyCtxt<'tcx>, Instance<'tcx>)>, + ) -> Postorder<'a, 'tcx> { let mut po = Postorder { basic_blocks, visited: DenseBitSet::new_empty(basic_blocks.len()), @@ -140,7 +138,11 @@ where return; } let data = &self.basic_blocks[bb]; - let successors = C::successors(data, self.extra); + let successors = if let Some(extra) = self.extra { + data.mono_successors(extra.0, extra.1) + } else { + data.terminator().successors() + }; self.visit_stack.push((bb, successors)); } @@ -198,10 +200,7 @@ where } } -impl<'tcx, C> Iterator for Postorder<'_, 'tcx, C> -where - C: Customization<'tcx>, -{ +impl<'tcx> Iterator for Postorder<'_, 'tcx> { type Item = BasicBlock; fn next(&mut self) -> Option<BasicBlock> { @@ -241,32 +240,12 @@ pub fn postorder<'a, 'tcx>( reverse_postorder(body).rev() } -/// Lets us plug in some additional logic and data into a Postorder traversal. Or not. -pub trait Customization<'tcx>: Copy { - fn successors<'a>(_: &'a BasicBlockData<'tcx>, _: Self) -> Successors<'a>; -} - -impl<'tcx> Customization<'tcx> for () { - fn successors<'a>(data: &'a BasicBlockData<'tcx>, _: ()) -> Successors<'a> { - data.terminator().successors() - } -} - -impl<'tcx> Customization<'tcx> for (TyCtxt<'tcx>, Instance<'tcx>) { - fn successors<'a>( - data: &'a BasicBlockData<'tcx>, - (tcx, instance): (TyCtxt<'tcx>, Instance<'tcx>), - ) -> Successors<'a> { - data.mono_successors(tcx, instance) - } -} - pub fn mono_reachable_reverse_postorder<'a, 'tcx>( body: &'a Body<'tcx>, tcx: TyCtxt<'tcx>, instance: Instance<'tcx>, ) -> Vec<BasicBlock> { - let mut iter = Postorder::new(&body.basic_blocks, START_BLOCK, (tcx, instance)); + let mut iter = Postorder::new(&body.basic_blocks, START_BLOCK, Some((tcx, instance))); let mut items = Vec::with_capacity(body.basic_blocks.len()); while let Some(block) = iter.next() { items.push(block); diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs index 98e8f269c57..3c83d962900 100644 --- a/compiler/rustc_middle/src/mir/visit.rs +++ b/compiler/rustc_middle/src/mir/visit.rs @@ -443,7 +443,7 @@ macro_rules! make_mir_visitor { location ) } - StatementKind::Intrinsic(box ref $($mutability)? intrinsic) => { + StatementKind::Intrinsic(box intrinsic) => { match intrinsic { NonDivergingIntrinsic::Assume(op) => self.visit_operand(op, location), NonDivergingIntrinsic::CopyNonOverlapping(CopyNonOverlapping { @@ -886,8 +886,8 @@ macro_rules! make_mir_visitor { self.visit_source_info(source_info); let location = Location::START; if let Some(box VarDebugInfoFragment { - ref $($mutability)? ty, - ref $($mutability)? projection + ty, + projection }) = composite { self.visit_ty($(& $mutability)? *ty, TyContext::Location(location)); for elem in projection { @@ -1364,13 +1364,13 @@ impl PlaceContext { matches!(self, PlaceContext::MutatingUse(MutatingUseContext::Drop)) } - /// Returns `true` if this place context represents a borrow. + /// Returns `true` if this place context represents a borrow, excluding fake borrows + /// (which are an artifact of borrowck and not actually borrows in runtime MIR). pub fn is_borrow(self) -> bool { matches!( self, - PlaceContext::NonMutatingUse( - NonMutatingUseContext::SharedBorrow | NonMutatingUseContext::FakeBorrow - ) | PlaceContext::MutatingUse(MutatingUseContext::Borrow) + PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow) + | PlaceContext::MutatingUse(MutatingUseContext::Borrow) ) } diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index 98cc00c367c..c67ed356818 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -678,8 +678,7 @@ impl<'tcx> Pat<'tcx> { subpatterns.iter().for_each(|field| field.pattern.walk_(it)) } Or { pats } => pats.iter().for_each(|p| p.walk_(it)), - Array { box ref prefix, ref slice, box ref suffix } - | Slice { box ref prefix, ref slice, box ref suffix } => { + Array { box prefix, slice, box suffix } | Slice { box prefix, slice, box suffix } => { prefix.iter().chain(slice.as_deref()).chain(suffix.iter()).for_each(|p| p.walk_(it)) } } diff --git a/compiler/rustc_middle/src/thir/visit.rs b/compiler/rustc_middle/src/thir/visit.rs index 13b8af55e51..afe24b55a83 100644 --- a/compiler/rustc_middle/src/thir/visit.rs +++ b/compiler/rustc_middle/src/thir/visit.rs @@ -194,7 +194,7 @@ pub fn walk_stmt<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>( initializer, remainder_scope: _, init_scope: _, - ref pattern, + pattern, lint_level: _, else_block, span: _, diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index f039da772fd..d033ecc75db 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -12,7 +12,7 @@ use std::borrow::Cow; use std::hash::{Hash, Hasher}; use std::sync::Arc; -use rustc_errors::{Applicability, Diag, EmissionGuarantee}; +use rustc_errors::{Applicability, Diag, EmissionGuarantee, ErrorGuaranteed}; use rustc_hir as hir; use rustc_hir::HirId; use rustc_hir::def_id::DefId; @@ -51,7 +51,7 @@ pub struct ObligationCause<'tcx> { /// information. pub body_id: LocalDefId, - code: InternedObligationCauseCode<'tcx>, + code: ObligationCauseCodeHandle<'tcx>, } // This custom hash function speeds up hashing for `Obligation` deduplication @@ -97,7 +97,7 @@ impl<'tcx> ObligationCause<'tcx> { pub fn map_code( &mut self, - f: impl FnOnce(InternedObligationCauseCode<'tcx>) -> ObligationCauseCode<'tcx>, + f: impl FnOnce(ObligationCauseCodeHandle<'tcx>) -> ObligationCauseCode<'tcx>, ) { self.code = f(std::mem::take(&mut self.code)).into(); } @@ -144,23 +144,16 @@ impl<'tcx> ObligationCause<'tcx> { } } -#[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)] -#[derive(TypeVisitable, TypeFoldable)] -pub struct UnifyReceiverContext<'tcx> { - pub assoc_item: ty::AssocItem, - pub param_env: ty::ParamEnv<'tcx>, - pub args: GenericArgsRef<'tcx>, -} - +/// A compact form of `ObligationCauseCode`. #[derive(Clone, PartialEq, Eq, Default, HashStable)] #[derive(TypeVisitable, TypeFoldable, TyEncodable, TyDecodable)] -pub struct InternedObligationCauseCode<'tcx> { +pub struct ObligationCauseCodeHandle<'tcx> { /// `None` for `ObligationCauseCode::Misc` (a common case, occurs ~60% of /// the time). `Some` otherwise. code: Option<Arc<ObligationCauseCode<'tcx>>>, } -impl<'tcx> std::fmt::Debug for InternedObligationCauseCode<'tcx> { +impl<'tcx> std::fmt::Debug for ObligationCauseCodeHandle<'tcx> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let cause: &ObligationCauseCode<'_> = self; cause.fmt(f) @@ -169,14 +162,14 @@ impl<'tcx> std::fmt::Debug for InternedObligationCauseCode<'tcx> { impl<'tcx> ObligationCauseCode<'tcx> { #[inline(always)] - fn into(self) -> InternedObligationCauseCode<'tcx> { - InternedObligationCauseCode { + fn into(self) -> ObligationCauseCodeHandle<'tcx> { + ObligationCauseCodeHandle { code: if let ObligationCauseCode::Misc = self { None } else { Some(Arc::new(self)) }, } } } -impl<'tcx> std::ops::Deref for InternedObligationCauseCode<'tcx> { +impl<'tcx> std::ops::Deref for ObligationCauseCodeHandle<'tcx> { type Target = ObligationCauseCode<'tcx>; fn deref(&self) -> &Self::Target { @@ -305,7 +298,7 @@ pub enum ObligationCauseCode<'tcx> { /// The node of the function call. call_hir_id: HirId, /// The obligation introduced by this argument. - parent_code: InternedObligationCauseCode<'tcx>, + parent_code: ObligationCauseCodeHandle<'tcx>, }, /// Error derived when checking an impl item is compatible with @@ -359,8 +352,6 @@ pub enum ObligationCauseCode<'tcx> { /// Method receiver MethodReceiver, - UnifyReceiver(Box<UnifyReceiverContext<'tcx>>), - /// `return` with no expression ReturnNoExpression, @@ -390,7 +381,8 @@ pub enum ObligationCauseCode<'tcx> { /// `WellFormed(None)`. WellFormed(Option<WellFormedLoc>), - /// From `match_impl`. The cause for us having to match an impl, and the DefId we are matching against. + /// From `match_impl`. The cause for us having to match an impl, and the DefId we are matching + /// against. MatchImpl(ObligationCause<'tcx>, DefId), BinOp { @@ -413,7 +405,7 @@ pub enum ObligationCauseCode<'tcx> { ConstParam(Ty<'tcx>), /// Obligations emitted during the normalization of a weak type alias. - TypeAlias(InternedObligationCauseCode<'tcx>, Span, DefId), + TypeAlias(ObligationCauseCodeHandle<'tcx>, Span, DefId), } /// Whether a value can be extracted into a const. @@ -514,12 +506,6 @@ impl<'tcx> ObligationCauseCode<'tcx> { #[cfg(target_pointer_width = "64")] rustc_data_structures::static_assert_size!(ObligationCauseCode<'_>, 48); -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] -pub enum StatementAsExpression { - CorrectType, - NeedsBoxing, -} - #[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)] #[derive(TypeVisitable, TypeFoldable)] pub struct MatchExpressionArmCause<'tcx> { @@ -584,7 +570,7 @@ pub struct DerivedCause<'tcx> { pub parent_trait_pred: ty::PolyTraitPredicate<'tcx>, /// The parent trait had this cause. - pub parent_code: InternedObligationCauseCode<'tcx>, + pub parent_code: ObligationCauseCodeHandle<'tcx>, } #[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)] @@ -592,9 +578,9 @@ pub struct DerivedCause<'tcx> { pub struct ImplDerivedCause<'tcx> { pub derived: DerivedCause<'tcx>, /// The `DefId` of the `impl` that gave rise to the `derived` obligation. - /// If the `derived` obligation arose from a trait alias, which conceptually has a synthetic impl, - /// then this will be the `DefId` of that trait alias. Care should therefore be taken to handle - /// that exceptional case where appropriate. + /// If the `derived` obligation arose from a trait alias, which conceptually has a synthetic + /// impl, then this will be the `DefId` of that trait alias. Care should therefore be taken to + /// handle that exceptional case where appropriate. pub impl_or_alias_def_id: DefId, /// The index of the derived predicate in the parent impl's predicates. pub impl_def_predicate_index: Option<usize>, @@ -611,7 +597,7 @@ pub struct DerivedHostCause<'tcx> { pub parent_host_pred: ty::Binder<'tcx, ty::HostEffectPredicate<'tcx>>, /// The parent trait had this cause. - pub parent_code: InternedObligationCauseCode<'tcx>, + pub parent_code: ObligationCauseCodeHandle<'tcx>, } #[derive(Clone, Debug, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)] @@ -790,7 +776,7 @@ impl DynCompatibilityViolation { pub fn error_msg(&self) -> Cow<'static, str> { match self { DynCompatibilityViolation::SizedSelf(_) => "it requires `Self: Sized`".into(), - DynCompatibilityViolation::SupertraitSelf(ref spans) => { + DynCompatibilityViolation::SupertraitSelf(spans) => { if spans.iter().any(|sp| *sp != DUMMY_SP) { "it uses `Self` as a type parameter".into() } else { @@ -1000,4 +986,7 @@ pub enum CodegenObligationError { /// but was included during typeck due to the trivial_bounds feature. Unimplemented, FulfillmentError, + /// The selected impl has unconstrained generic parameters. This will emit an error + /// during impl WF checking. + UnconstrainedParam(ErrorGuaranteed), } diff --git a/compiler/rustc_middle/src/traits/query.rs b/compiler/rustc_middle/src/traits/query.rs index 4203c8fd861..76f3d2bab9c 100644 --- a/compiler/rustc_middle/src/traits/query.rs +++ b/compiler/rustc_middle/src/traits/query.rs @@ -75,12 +75,6 @@ pub type CanonicalPredicateGoal<'tcx> = pub type CanonicalTypeOpAscribeUserTypeGoal<'tcx> = CanonicalQueryInput<'tcx, ty::ParamEnvAnd<'tcx, type_op::AscribeUserType<'tcx>>>; -pub type CanonicalTypeOpEqGoal<'tcx> = - CanonicalQueryInput<'tcx, ty::ParamEnvAnd<'tcx, type_op::Eq<'tcx>>>; - -pub type CanonicalTypeOpSubtypeGoal<'tcx> = - CanonicalQueryInput<'tcx, ty::ParamEnvAnd<'tcx, type_op::Subtype<'tcx>>>; - pub type CanonicalTypeOpProvePredicateGoal<'tcx> = CanonicalQueryInput<'tcx, ty::ParamEnvAnd<'tcx, type_op::ProvePredicate<'tcx>>>; diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 35893ad953d..32a9e67f9ad 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1370,7 +1370,6 @@ pub struct GlobalCtxt<'tcx> { // Internal caches for metadata decoding. No need to track deps on this. pub ty_rcache: Lock<FxHashMap<ty::CReaderCacheKey, Ty<'tcx>>>, - pub pred_rcache: Lock<FxHashMap<ty::CReaderCacheKey, Predicate<'tcx>>>, /// Caches the results of trait selection. This cache is used /// for things that do not have to do with the parameters in scope. @@ -1601,7 +1600,6 @@ impl<'tcx> TyCtxt<'tcx> { query_system, query_kinds, ty_rcache: Default::default(), - pred_rcache: Default::default(), selection_cache: Default::default(), evaluation_cache: Default::default(), new_solver_evaluation_cache: Default::default(), @@ -3019,7 +3017,7 @@ impl<'tcx> TyCtxt<'tcx> { /// Find the crate root and the appropriate span where `use` and outer attributes can be /// inserted at. pub fn crate_level_attribute_injection_span(self, hir_id: HirId) -> Option<Span> { - for (_hir_id, node) in self.hir().parent_iter(hir_id) { + for (_hir_id, node) in self.hir_parent_iter(hir_id) { if let hir::Node::Crate(m) = node { return Some(m.spans.inject_use_span.shrink_to_lo()); } diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 19fa8323574..eb14ed20fba 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -794,8 +794,9 @@ where Some(fields) => FieldsShape::Union(fields), None => FieldsShape::Arbitrary { offsets: IndexVec::new(), memory_index: IndexVec::new() }, }, - backend_repr: BackendRepr::Uninhabited, + backend_repr: BackendRepr::Memory { sized: true }, largest_niche: None, + uninhabited: true, align: tcx.data_layout.i8_align, size: Size::ZERO, max_repr_align: None, diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index a1d44882e63..bd1fb0ca41c 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -179,7 +179,7 @@ pub struct ResolverGlobalCtxt { pub confused_type_with_std_module: FxIndexMap<Span, Span>, pub doc_link_resolutions: FxIndexMap<LocalDefId, DocLinkResMap>, pub doc_link_traits_in_scope: FxIndexMap<LocalDefId, Vec<DefId>>, - pub all_macro_rules: FxHashMap<Symbol, Res<ast::NodeId>>, + pub all_macro_rules: FxHashSet<Symbol>, pub stripped_cfg_items: Steal<Vec<StrippedCfgItem>>, } diff --git a/compiler/rustc_middle/src/ty/relate.rs b/compiler/rustc_middle/src/ty/relate.rs index afdec7a86d4..839c1c346a4 100644 --- a/compiler/rustc_middle/src/ty/relate.rs +++ b/compiler/rustc_middle/src/ty/relate.rs @@ -79,20 +79,14 @@ impl<'tcx> Relate<TyCtxt<'tcx>> for &'tcx ty::List<ty::PolyExistentialPredicate< b: Self, ) -> RelateResult<'tcx, Self> { let tcx = relation.cx(); - - // FIXME: this is wasteful, but want to do a perf run to see how slow it is. - // We need to perform this deduplication as we sometimes generate duplicate projections - // in `a`. - let mut a_v: Vec<_> = a.into_iter().collect(); - let mut b_v: Vec<_> = b.into_iter().collect(); - a_v.dedup(); - b_v.dedup(); - if a_v.len() != b_v.len() { + // Fast path for when the auto traits do not match, or if the principals + // are from different traits and therefore the projections definitely don't + // match up. + if a.len() != b.len() { return Err(TypeError::ExistentialMismatch(ExpectedFound::new(a, b))); } - - let v = iter::zip(a_v, b_v).map(|(ep_a, ep_b)| { - match (ep_a.skip_binder(), ep_b.skip_binder()) { + let v = + iter::zip(a, b).map(|(ep_a, ep_b)| match (ep_a.skip_binder(), ep_b.skip_binder()) { (ty::ExistentialPredicate::Trait(a), ty::ExistentialPredicate::Trait(b)) => { Ok(ep_a.rebind(ty::ExistentialPredicate::Trait( relation.relate(ep_a.rebind(a), ep_b.rebind(b))?.skip_binder(), @@ -109,8 +103,7 @@ impl<'tcx> Relate<TyCtxt<'tcx>> for &'tcx ty::List<ty::PolyExistentialPredicate< ty::ExistentialPredicate::AutoTrait(b), ) if a == b => Ok(ep_a.rebind(ty::ExistentialPredicate::AutoTrait(a))), _ => Err(TypeError::ExistentialMismatch(ExpectedFound::new(a, b))), - } - }); + }); tcx.mk_poly_existential_predicates_from_iter(v) } } diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index b2286c74402..db9e9fbc643 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -447,23 +447,23 @@ impl<'tcx> TypeSuperVisitable<TyCtxt<'tcx>> for Ty<'tcx> { } ty::Slice(typ) => typ.visit_with(visitor), ty::Adt(_, args) => args.visit_with(visitor), - ty::Dynamic(ref trait_ty, ref reg, _) => { + ty::Dynamic(trait_ty, reg, _) => { try_visit!(trait_ty.visit_with(visitor)); reg.visit_with(visitor) } ty::Tuple(ts) => ts.visit_with(visitor), ty::FnDef(_, args) => args.visit_with(visitor), - ty::FnPtr(ref sig_tys, _) => sig_tys.visit_with(visitor), - ty::UnsafeBinder(ref f) => f.visit_with(visitor), + ty::FnPtr(sig_tys, _) => sig_tys.visit_with(visitor), + ty::UnsafeBinder(f) => f.visit_with(visitor), ty::Ref(r, ty, _) => { try_visit!(r.visit_with(visitor)); ty.visit_with(visitor) } - ty::Coroutine(_did, ref args) => args.visit_with(visitor), - ty::CoroutineWitness(_did, ref args) => args.visit_with(visitor), - ty::Closure(_did, ref args) => args.visit_with(visitor), - ty::CoroutineClosure(_did, ref args) => args.visit_with(visitor), - ty::Alias(_, ref data) => data.visit_with(visitor), + ty::Coroutine(_did, args) => args.visit_with(visitor), + ty::CoroutineWitness(_did, args) => args.visit_with(visitor), + ty::Closure(_did, args) => args.visit_with(visitor), + ty::CoroutineClosure(_did, args) => args.visit_with(visitor), + ty::Alias(_, data) => data.visit_with(visitor), ty::Pat(ty, pat) => { try_visit!(ty.visit_with(visitor)); diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 8a31b296018..dd4da2cf4ac 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -18,7 +18,7 @@ use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, extension use rustc_span::{DUMMY_SP, Span, Symbol, sym}; use rustc_type_ir::TyKind::*; use rustc_type_ir::visit::TypeVisitableExt; -use rustc_type_ir::{self as ir, BoundVar, CollectAndApply, DynKind}; +use rustc_type_ir::{self as ir, BoundVar, CollectAndApply, DynKind, elaborate}; use tracing::instrument; use ty::util::{AsyncDropGlueMorphology, IntTypeExt}; @@ -720,6 +720,34 @@ impl<'tcx> Ty<'tcx> { reg: ty::Region<'tcx>, repr: DynKind, ) -> Ty<'tcx> { + if cfg!(debug_assertions) { + let projection_count = obj.projection_bounds().count(); + let expected_count: usize = obj + .principal_def_id() + .into_iter() + .flat_map(|principal_def_id| { + // NOTE: This should agree with `needed_associated_types` in + // dyn trait lowering, or else we'll have ICEs. + elaborate::supertraits( + tcx, + ty::Binder::dummy(ty::TraitRef::identity(tcx, principal_def_id)), + ) + .map(|principal| { + tcx.associated_items(principal.def_id()) + .in_definition_order() + .filter(|item| item.kind == ty::AssocKind::Type) + .filter(|item| !item.is_impl_trait_in_trait()) + .filter(|item| !tcx.generics_require_sized_self(item.def_id)) + .count() + }) + }) + .sum(); + assert_eq!( + projection_count, expected_count, + "expected {obj:?} to have {expected_count} projections, \ + but it has {projection_count}" + ); + } Ty::new(tcx, Dynamic(obj, reg, repr)) } @@ -1121,7 +1149,7 @@ impl<'tcx> Ty<'tcx> { #[inline] pub fn is_param(self, index: u32) -> bool { match self.kind() { - ty::Param(ref data) => data.index == index, + ty::Param(data) => data.index == index, _ => false, } } diff --git a/compiler/rustc_mir_build/Cargo.toml b/compiler/rustc_mir_build/Cargo.toml index 1f3689926bc..d70d70a31a4 100644 --- a/compiler/rustc_mir_build/Cargo.toml +++ b/compiler/rustc_mir_build/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_mir_build" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_mir_build/src/builder/block.rs b/compiler/rustc_mir_build/src/builder/block.rs index ba63a97de89..7c76e02fcef 100644 --- a/compiler/rustc_mir_build/src/builder/block.rs +++ b/compiler/rustc_mir_build/src/builder/block.rs @@ -244,7 +244,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { StmtKind::Let { remainder_scope, init_scope, - ref pattern, + pattern, initializer, lint_level, else_block: None, @@ -331,8 +331,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let expr = &this.thir[expr_id]; let tail_result_is_ignored = destination_ty.is_unit() || this.block_context.currently_ignores_tail_results(); - this.block_context - .push(BlockFrame::TailExpr { tail_result_is_ignored, span: expr.span }); + this.block_context.push(BlockFrame::TailExpr { + info: BlockTailInfo { tail_result_is_ignored, span: expr.span }, + }); block = this.expr_into_dest(destination, block, expr_id).into_block(); let popped = this.block_context.pop(); diff --git a/compiler/rustc_mir_build/src/builder/expr/as_operand.rs b/compiler/rustc_mir_build/src/builder/expr/as_operand.rs index 63e9b1dc6cd..2059610ee47 100644 --- a/compiler/rustc_mir_build/src/builder/expr/as_operand.rs +++ b/compiler/rustc_mir_build/src/builder/expr/as_operand.rs @@ -142,7 +142,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // Overwrite temp local info if we have something more interesting to record. if !matches!(local_info, LocalInfo::Boring) { let decl_info = - this.local_decls[operand].local_info.as_mut().assert_crate_local(); + this.local_decls[operand].local_info.as_mut().unwrap_crate_local(); if let LocalInfo::Boring | LocalInfo::BlockTailTemp(_) = **decl_info { **decl_info = local_info; } diff --git a/compiler/rustc_mir_build/src/builder/expr/as_temp.rs b/compiler/rustc_mir_build/src/builder/expr/as_temp.rs index 2927f5b0c45..0bd61168fba 100644 --- a/compiler/rustc_mir_build/src/builder/expr/as_temp.rs +++ b/compiler/rustc_mir_build/src/builder/expr/as_temp.rs @@ -85,7 +85,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { _ => LocalInfo::Boring, }; - **local_decl.local_info.as_mut().assert_crate_local() = local_info; + **local_decl.local_info.as_mut().unwrap_crate_local() = local_info; this.local_decls.push(local_decl) }; debug!(?temp); diff --git a/compiler/rustc_mir_build/src/builder/expr/stmt.rs b/compiler/rustc_mir_build/src/builder/expr/stmt.rs index 58090d3748b..7f8a0a34c31 100644 --- a/compiler/rustc_mir_build/src/builder/expr/stmt.rs +++ b/compiler/rustc_mir_build/src/builder/expr/stmt.rs @@ -164,8 +164,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } this.block_context.push(BlockFrame::TailExpr { - tail_result_is_ignored: true, - span: expr.span, + info: BlockTailInfo { tail_result_is_ignored: true, span: expr.span }, }); Some(expr.span) } else { diff --git a/compiler/rustc_mir_build/src/builder/matches/mod.rs b/compiler/rustc_mir_build/src/builder/matches/mod.rs index 6334612eced..d05d5b151ff 100644 --- a/compiler/rustc_mir_build/src/builder/matches/mod.rs +++ b/compiler/rustc_mir_build/src/builder/matches/mod.rs @@ -722,7 +722,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { if let LocalInfo::User(BindingForm::Var(VarBindingForm { opt_match_place: Some((ref mut match_place, _)), .. - })) = **self.local_decls[local].local_info.as_mut().assert_crate_local() + })) = **self.local_decls[local].local_info.as_mut().unwrap_crate_local() { *match_place = Some(place); } else { diff --git a/compiler/rustc_mir_build/src/builder/mod.rs b/compiler/rustc_mir_build/src/builder/mod.rs index fb0aa354913..4348b7a4b4c 100644 --- a/compiler/rustc_mir_build/src/builder/mod.rs +++ b/compiler/rustc_mir_build/src/builder/mod.rs @@ -112,16 +112,7 @@ enum BlockFrame { /// Evaluation is currently within the tail expression of a block. /// /// Example: `{ STMT_1; STMT_2; EXPR }` - TailExpr { - /// If true, then the surrounding context of the block ignores - /// the result of evaluating the block's tail expression. - /// - /// Example: `let _ = { STMT_1; EXPR };` - tail_result_is_ignored: bool, - - /// `Span` of the tail expression. - span: Span, - }, + TailExpr { info: BlockTailInfo }, /// Generic mark meaning that the block occurred as a subexpression /// where the result might be used. @@ -277,9 +268,7 @@ impl BlockContext { match bf { BlockFrame::SubExpr => continue, BlockFrame::Statement { .. } => break, - &BlockFrame::TailExpr { tail_result_is_ignored, span } => { - return Some(BlockTailInfo { tail_result_is_ignored, span }); - } + &BlockFrame::TailExpr { info } => return Some(info), } } @@ -302,9 +291,9 @@ impl BlockContext { // otherwise: use accumulated is_ignored state. Some( - BlockFrame::TailExpr { tail_result_is_ignored: ignored, .. } - | BlockFrame::Statement { ignores_expr_result: ignored }, - ) => *ignored, + BlockFrame::TailExpr { info: BlockTailInfo { tail_result_is_ignored: ign, .. } } + | BlockFrame::Statement { ignores_expr_result: ign }, + ) => *ign, } } } @@ -967,7 +956,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } => { self.local_decls[local].mutability = mutability; self.local_decls[local].source_info.scope = self.source_scope; - **self.local_decls[local].local_info.as_mut().assert_crate_local() = + **self.local_decls[local].local_info.as_mut().unwrap_crate_local() = if let Some(kind) = param.self_kind { LocalInfo::User(BindingForm::ImplicitSelf(kind)) } else { @@ -1032,7 +1021,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let parent_id = self.source_scopes[original_source_scope] .local_data .as_ref() - .assert_crate_local() + .unwrap_crate_local() .lint_root; self.maybe_new_source_scope(pattern_span, arg_hir_id, parent_id); } diff --git a/compiler/rustc_mir_build/src/builder/scope.rs b/compiler/rustc_mir_build/src/builder/scope.rs index d3551ea3a97..81561239491 100644 --- a/compiler/rustc_mir_build/src/builder/scope.rs +++ b/compiler/rustc_mir_build/src/builder/scope.rs @@ -604,7 +604,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let source_scope = self.source_scope; if let LintLevel::Explicit(current_hir_id) = lint_level { let parent_id = - self.source_scopes[source_scope].local_data.as_ref().assert_crate_local().lint_root; + self.source_scopes[source_scope].local_data.as_ref().unwrap_crate_local().lint_root; self.maybe_new_source_scope(region_scope.1.span, current_hir_id, parent_id); } self.push_scope(region_scope); @@ -992,7 +992,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { lint_root: if let LintLevel::Explicit(lint_root) = lint_level { lint_root } else { - self.source_scopes[parent].local_data.as_ref().assert_crate_local().lint_root + self.source_scopes[parent].local_data.as_ref().unwrap_crate_local().lint_root }, }; self.source_scopes.push(SourceScopeData { diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index 84f58f1968d..d65c2097d22 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -751,7 +751,7 @@ impl UnsafeOpKind { span: Span, suggest_unsafe_block: bool, ) { - let parent_id = tcx.hir().get_parent_item(hir_id); + let parent_id = tcx.hir_get_parent_item(hir_id); let parent_owner = tcx.hir_owner_node(parent_id); let should_suggest = parent_owner.fn_sig().is_some_and(|sig| { // Do not suggest for safe target_feature functions @@ -921,7 +921,7 @@ impl UnsafeOpKind { hir_context: HirId, unsafe_op_in_unsafe_fn_allowed: bool, ) { - let note_non_inherited = tcx.hir().parent_iter(hir_context).find(|(id, node)| { + let note_non_inherited = tcx.hir_parent_iter(hir_context).find(|(id, node)| { if let hir::Node::Expr(block) = node && let hir::ExprKind::Block(block, _) = block.kind && let hir::BlockCheckMode::UnsafeBlock(_) = block.rules diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index d0fca76fcf0..eb00b95f3c8 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -429,9 +429,7 @@ impl<'tcx> ThirBuildCx<'tcx> { let user_provided_types = self.typeck_results.user_provided_types(); let user_ty = user_provided_types.get(fun.hir_id).copied().map(|mut u_ty| { - if let ty::UserTypeKind::TypeOf(ref mut did, _) = - &mut u_ty.value.kind - { + if let ty::UserTypeKind::TypeOf(did, _) = &mut u_ty.value.kind { *did = adt_def.did(); } Box::new(u_ty) diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index 6dbb460d8b1..d60ae6484af 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -1041,7 +1041,7 @@ fn find_fallback_pattern_typo<'tcx>( let mut imported = vec![]; let mut imported_spans = vec![]; let (infcx, param_env) = cx.tcx.infer_ctxt().build_with_typing_env(cx.typing_env); - let parent = cx.tcx.hir().get_parent_item(hir_id); + let parent = cx.tcx.hir_get_parent_item(hir_id); for item in cx.tcx.hir_crate_items(()).free_items() { if let DefKind::Use = cx.tcx.def_kind(item.owner_id) { @@ -1097,7 +1097,7 @@ fn find_fallback_pattern_typo<'tcx>( } } if let Some((i, &const_name)) = - accessible.iter().enumerate().find(|(_, &const_name)| const_name == name) + accessible.iter().enumerate().find(|&(_, &const_name)| const_name == name) { // The pattern name is an exact match, so the pattern needed to be imported. lint.wanted_constant = Some(WantedConstant { @@ -1115,7 +1115,7 @@ fn find_fallback_pattern_typo<'tcx>( const_path: name.to_string(), }); } else if let Some(i) = - imported.iter().enumerate().find(|(_, &const_name)| const_name == name).map(|(i, _)| i) + imported.iter().enumerate().find(|&(_, &const_name)| const_name == name).map(|(i, _)| i) { // The const with the exact name wasn't re-exported from an import in this // crate, we point at the import. @@ -1137,7 +1137,7 @@ fn find_fallback_pattern_typo<'tcx>( } else { // Look for local bindings for people that might have gotten confused with how // `let` and `const` works. - for (_, node) in cx.tcx.hir().parent_iter(hir_id) { + for (_, node) in cx.tcx.hir_parent_iter(hir_id) { match node { hir::Node::Stmt(hir::Stmt { kind: hir::StmtKind::Let(let_stmt), .. }) => { if let hir::PatKind::Binding(_, _, binding_name, _) = let_stmt.pat.kind { diff --git a/compiler/rustc_mir_build/src/thir/util.rs b/compiler/rustc_mir_build/src/thir/util.rs index 4dff093afd0..60a47a94e3a 100644 --- a/compiler/rustc_mir_build/src/thir/util.rs +++ b/compiler/rustc_mir_build/src/thir/util.rs @@ -16,7 +16,7 @@ pub(crate) fn user_args_applied_to_ty_of_hir_id<'tcx>( let ty = typeck_results.node_type(hir_id); match ty.kind() { ty::Adt(adt_def, ..) => { - if let ty::UserTypeKind::TypeOf(ref mut did, _) = &mut user_ty.value.kind { + if let ty::UserTypeKind::TypeOf(did, _) = &mut user_ty.value.kind { *did = adt_def.did(); } Some(user_ty) diff --git a/compiler/rustc_mir_dataflow/Cargo.toml b/compiler/rustc_mir_dataflow/Cargo.toml index f84a0663897..293bcbef21b 100644 --- a/compiler/rustc_mir_dataflow/Cargo.toml +++ b/compiler/rustc_mir_dataflow/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_mir_dataflow" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_mir_dataflow/src/un_derefer.rs b/compiler/rustc_mir_dataflow/src/un_derefer.rs index b803ecc575e..bb15b8106a1 100644 --- a/compiler/rustc_mir_dataflow/src/un_derefer.rs +++ b/compiler/rustc_mir_dataflow/src/un_derefer.rs @@ -91,7 +91,7 @@ impl<T: Copy> SlicePlusOne<'_, T> { #[inline] fn advance(&mut self) { match self.slice { - [_, ref remainder @ ..] => { + [_, remainder @ ..] => { self.slice = remainder; } [] => self.last = None, diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index 104a2e8c091..9cba07e15a4 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -125,7 +125,7 @@ impl<V: Clone + HasBottom> State<V> { pub fn all_bottom(&self) -> bool { match self { State::Unreachable => false, - State::Reachable(ref values) => + State::Reachable(values) => { #[allow(rustc::potential_query_instability)] values.map.values().all(V::is_bottom) @@ -349,7 +349,7 @@ impl<V: JoinSemiLattice + Clone> JoinSemiLattice for State<V> { *self = other.clone(); true } - (State::Reachable(this), State::Reachable(ref other)) => this.join(other), + (State::Reachable(this), State::Reachable(other)) => this.join(other), } } } diff --git a/compiler/rustc_mir_transform/Cargo.toml b/compiler/rustc_mir_transform/Cargo.toml index 2f233f787f0..fb8d0ac5e74 100644 --- a/compiler/rustc_mir_transform/Cargo.toml +++ b/compiler/rustc_mir_transform/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_mir_transform" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_mir_transform/src/check_const_item_mutation.rs b/compiler/rustc_mir_transform/src/check_const_item_mutation.rs index 3affe4abbfa..ceea72c6755 100644 --- a/compiler/rustc_mir_transform/src/check_const_item_mutation.rs +++ b/compiler/rustc_mir_transform/src/check_const_item_mutation.rs @@ -79,7 +79,7 @@ impl<'tcx> ConstMutationChecker<'_, 'tcx> { let lint_root = self.body.source_scopes[source_info.scope] .local_data .as_ref() - .assert_crate_local() + .unwrap_crate_local() .lint_root; Some((lint_root, source_info.span, self.tcx.def_span(const_item))) diff --git a/compiler/rustc_mir_transform/src/coroutine.rs b/compiler/rustc_mir_transform/src/coroutine.rs index f3f3a65cd80..04d96f11707 100644 --- a/compiler/rustc_mir_transform/src/coroutine.rs +++ b/compiler/rustc_mir_transform/src/coroutine.rs @@ -945,7 +945,7 @@ fn compute_layout<'tcx>( let decl = &body.local_decls[local]; debug!(?decl); - // Do not `assert_crate_local` here, as post-borrowck cleanup may have already cleared + // Do not `unwrap_crate_local` here, as post-borrowck cleanup may have already cleared // the information. This is alright, since `ignore_for_traits` is only relevant when // this code runs on pre-cleanup MIR, and `ignore_for_traits = false` is the safer // default. diff --git a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs index 5d21d687a35..7b3553e7afd 100644 --- a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs +++ b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs @@ -85,7 +85,7 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool { let lint_root = body.source_scopes[terminator.source_info.scope] .local_data .as_ref() - .assert_crate_local() + .unwrap_crate_local() .lint_root; let span = terminator.source_info.span; diff --git a/compiler/rustc_mir_transform/src/function_item_references.rs b/compiler/rustc_mir_transform/src/function_item_references.rs index 73e47bb79f0..38b5ccdb32e 100644 --- a/compiler/rustc_mir_transform/src/function_item_references.rs +++ b/compiler/rustc_mir_transform/src/function_item_references.rs @@ -154,7 +154,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> { let lint_root = self.body.source_scopes[source_info.scope] .local_data .as_ref() - .assert_crate_local() + .unwrap_crate_local() .lint_root; // FIXME: use existing printing routines to print the function signature let fn_sig = self.tcx.fn_sig(fn_id).instantiate(self.tcx, fn_args); diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index 77a3854ebde..2f8a3050199 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -1558,8 +1558,11 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { return true; }; + if layout.uninhabited { + return true; + } + match layout.backend_repr { - BackendRepr::Uninhabited => true, BackendRepr::Scalar(a) => !a.is_always_valid(&self.ecx), BackendRepr::ScalarPair(a, b) => { !a.is_always_valid(&self.ecx) || !b.is_always_valid(&self.ecx) diff --git a/compiler/rustc_mir_transform/src/jump_threading.rs b/compiler/rustc_mir_transform/src/jump_threading.rs index 17084eca6e3..bd310b07897 100644 --- a/compiler/rustc_mir_transform/src/jump_threading.rs +++ b/compiler/rustc_mir_transform/src/jump_threading.rs @@ -467,7 +467,7 @@ impl<'a, 'tcx> TOFinder<'a, 'tcx> { state.insert_place_idx(rhs, lhs, &self.map); } // If we expect `lhs ?= A`, we have an opportunity if we assume `constant == A`. - Rvalue::Aggregate(box ref kind, ref operands) => { + Rvalue::Aggregate(box kind, operands) => { let agg_ty = lhs_place.ty(self.body, self.tcx).ty; let lhs = match kind { // Do not support unions. diff --git a/compiler/rustc_mir_transform/src/known_panics_lint.rs b/compiler/rustc_mir_transform/src/known_panics_lint.rs index 59de6ca84a7..f8db8de4e82 100644 --- a/compiler/rustc_mir_transform/src/known_panics_lint.rs +++ b/compiler/rustc_mir_transform/src/known_panics_lint.rs @@ -509,7 +509,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { // other overflow checks. AssertKind::Overflow(*bin_op, eval_to_int(op1), eval_to_int(op2)) } - AssertKind::BoundsCheck { ref len, ref index } => { + AssertKind::BoundsCheck { len, index } => { let len = eval_to_int(len); let index = eval_to_int(index); AssertKind::BoundsCheck { len, index } @@ -782,10 +782,10 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> { fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) { self.super_terminator(terminator, location); match &terminator.kind { - TerminatorKind::Assert { expected, ref msg, ref cond, .. } => { + TerminatorKind::Assert { expected, msg, cond, .. } => { self.check_assertion(*expected, msg, cond, location); } - TerminatorKind::SwitchInt { ref discr, ref targets } => { + TerminatorKind::SwitchInt { discr, targets } => { if let Some(ref value) = self.eval_operand(discr) && let Some(value_const) = self.use_ecx(|this| this.ecx.read_scalar(value)) && let Some(constant) = value_const.to_bits(value_const.size()).discard_err() diff --git a/compiler/rustc_mir_transform/src/mentioned_items.rs b/compiler/rustc_mir_transform/src/mentioned_items.rs index f5c57418467..9fd8d81d64a 100644 --- a/compiler/rustc_mir_transform/src/mentioned_items.rs +++ b/compiler/rustc_mir_transform/src/mentioned_items.rs @@ -51,7 +51,7 @@ impl<'tcx> Visitor<'tcx> for MentionedItemsVisitor<'_, 'tcx> { let ty = place.ty(self.body, self.tcx).ty; self.mentioned_items.push(Spanned { node: MentionedItem::Drop(ty), span: span() }); } - mir::TerminatorKind::InlineAsm { ref operands, .. } => { + mir::TerminatorKind::InlineAsm { operands, .. } => { for op in operands { match *op { mir::InlineAsmOperand::SymFn { ref value } => { diff --git a/compiler/rustc_mir_transform/src/patch.rs b/compiler/rustc_mir_transform/src/patch.rs index d3d181f6cb2..6a177faeac8 100644 --- a/compiler/rustc_mir_transform/src/patch.rs +++ b/compiler/rustc_mir_transform/src/patch.rs @@ -158,7 +158,7 @@ impl<'tcx> MirPatch<'tcx> { let index = self.next_local; self.next_local += 1; let mut new_decl = LocalDecl::new(ty, span); - **new_decl.local_info.as_mut().assert_crate_local() = local_info; + **new_decl.local_info.as_mut().unwrap_crate_local() = local_info; self.new_locals.push(new_decl); Local::new(index) } diff --git a/compiler/rustc_mir_transform/src/simplify.rs b/compiler/rustc_mir_transform/src/simplify.rs index 67070f03ded..84905f4a400 100644 --- a/compiler/rustc_mir_transform/src/simplify.rs +++ b/compiler/rustc_mir_transform/src/simplify.rs @@ -568,9 +568,9 @@ fn remove_unused_definitions_helper(used_locals: &mut UsedLocals, body: &mut Bod } StatementKind::Assign(box (place, _)) => used_locals.is_used(place.local), - StatementKind::SetDiscriminant { ref place, .. } - | StatementKind::BackwardIncompatibleDropHint { ref place, reason: _ } - | StatementKind::Deinit(ref place) => used_locals.is_used(place.local), + StatementKind::SetDiscriminant { place, .. } + | StatementKind::BackwardIncompatibleDropHint { place, reason: _ } + | StatementKind::Deinit(place) => used_locals.is_used(place.local), StatementKind::Nop => false, _ => true, }; diff --git a/compiler/rustc_mir_transform/src/simplify_branches.rs b/compiler/rustc_mir_transform/src/simplify_branches.rs index 12c3503879f..886f4d6e509 100644 --- a/compiler/rustc_mir_transform/src/simplify_branches.rs +++ b/compiler/rustc_mir_transform/src/simplify_branches.rs @@ -24,7 +24,7 @@ impl<'tcx> crate::MirPass<'tcx> for SimplifyConstCondition { // Simplify `assume` of a known value: either a NOP or unreachable. if let StatementKind::Intrinsic(box ref intrinsic) = stmt.kind && let NonDivergingIntrinsic::Assume(discr) = intrinsic - && let Operand::Constant(ref c) = discr + && let Operand::Constant(c) = discr && let Some(constant) = c.const_.try_eval_bool(tcx, typing_env) { if constant { diff --git a/compiler/rustc_mir_transform/src/simplify_comparison_integral.rs b/compiler/rustc_mir_transform/src/simplify_comparison_integral.rs index 21bc51ecca1..bd008230731 100644 --- a/compiler/rustc_mir_transform/src/simplify_comparison_integral.rs +++ b/compiler/rustc_mir_transform/src/simplify_comparison_integral.rs @@ -89,10 +89,10 @@ impl<'tcx> crate::MirPass<'tcx> for SimplifyComparisonIntegral { use Operand::*; match rhs { - Rvalue::BinaryOp(_, box (ref mut left @ Move(_), Constant(_))) => { + Rvalue::BinaryOp(_, box (left @ Move(_), Constant(_))) => { *left = Copy(opt.to_switch_on); } - Rvalue::BinaryOp(_, box (Constant(_), ref mut right @ Move(_))) => { + Rvalue::BinaryOp(_, box (Constant(_), right @ Move(_))) => { *right = Copy(opt.to_switch_on); } _ => (), diff --git a/compiler/rustc_monomorphize/Cargo.toml b/compiler/rustc_monomorphize/Cargo.toml index 5462105e5e8..36b76d261de 100644 --- a/compiler/rustc_monomorphize/Cargo.toml +++ b/compiler/rustc_monomorphize/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_monomorphize" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index d826d03918e..b1b6f10e0fe 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -1269,7 +1269,7 @@ fn dump_mono_items_stats<'tcx>( output_directory: &Option<PathBuf>, crate_name: Symbol, ) -> Result<(), Box<dyn std::error::Error>> { - let output_directory = if let Some(ref directory) = output_directory { + let output_directory = if let Some(directory) = output_directory { fs::create_dir_all(directory)?; directory } else { diff --git a/compiler/rustc_next_trait_solver/Cargo.toml b/compiler/rustc_next_trait_solver/Cargo.toml index eacb6002f5a..63aa60f2f26 100644 --- a/compiler/rustc_next_trait_solver/Cargo.toml +++ b/compiler/rustc_next_trait_solver/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_next_trait_solver" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_next_trait_solver/src/canonicalizer.rs b/compiler/rustc_next_trait_solver/src/canonicalizer.rs index 7eeed721d5a..9cae7f27947 100644 --- a/compiler/rustc_next_trait_solver/src/canonicalizer.rs +++ b/compiler/rustc_next_trait_solver/src/canonicalizer.rs @@ -1,6 +1,6 @@ use std::cmp::Ordering; -use rustc_type_ir::data_structures::HashMap; +use rustc_type_ir::data_structures::{HashMap, ensure_sufficient_stack}; use rustc_type_ir::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable}; use rustc_type_ir::inherent::*; use rustc_type_ir::solve::{Goal, QueryInput}; @@ -389,7 +389,7 @@ impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> { | ty::Alias(_, _) | ty::Bound(_, _) | ty::Error(_) => { - return t.super_fold_with(self); + return ensure_sufficient_stack(|| t.super_fold_with(self)); } }; diff --git a/compiler/rustc_parse/Cargo.toml b/compiler/rustc_parse/Cargo.toml index 2360914a0ab..c9dcab0c871 100644 --- a/compiler/rustc_parse/Cargo.toml +++ b/compiler/rustc_parse/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_parse" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 1de452dcf39..bbd73dec2e4 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -117,12 +117,15 @@ macro_rules! maybe_recover_from_interpolated_ty_qpath { ($self: expr, $allow_qpath_recovery: expr) => { if $allow_qpath_recovery && $self.may_recover() - && $self.look_ahead(1, |t| t == &token::PathSep) - && let token::Interpolated(nt) = &$self.token.kind - && let token::NtTy(ty) = &**nt + && let Some(mv_kind) = $self.token.is_metavar_seq() + && let token::MetaVarKind::Ty { .. } = mv_kind + && $self.check_noexpect_past_close_delim(&token::PathSep) { - let ty = ty.clone(); - $self.bump(); + // Reparse the type, then move to recovery. + let ty = $self + .eat_metavar_seq(mv_kind, |this| this.parse_ty_no_question_mark_recover()) + .expect("metavar seq ty"); + return $self.maybe_recover_from_bad_qpath_stage_2($self.prev_token.span, ty); } }; @@ -614,6 +617,24 @@ impl<'a> Parser<'a> { self.token == *tok } + // Check the first token after the delimiter that closes the current + // delimited sequence. (Panics if used in the outermost token stream, which + // has no delimiters.) It uses a clone of the relevant tree cursor to skip + // past the entire `TokenTree::Delimited` in a single step, avoiding the + // need for unbounded token lookahead. + // + // Primarily used when `self.token` matches + // `OpenDelim(Delimiter::Invisible(_))`, to look ahead through the current + // metavar expansion. + fn check_noexpect_past_close_delim(&self, tok: &TokenKind) -> bool { + let mut tree_cursor = self.token_cursor.stack.last().unwrap().clone(); + tree_cursor.bump(); + matches!( + tree_cursor.curr(), + Some(TokenTree::Token(token::Token { kind, .. }, _)) if kind == tok + ) + } + /// Consumes a token 'tok' if it exists. Returns whether the given token was present. /// /// the main purpose of this function is to reduce the cluttering of the suggestions list @@ -721,6 +742,43 @@ impl<'a> Parser<'a> { if !self.eat_keyword(exp) { self.unexpected() } else { Ok(()) } } + /// Consume a sequence produced by a metavar expansion, if present. + fn eat_metavar_seq<T>( + &mut self, + mv_kind: MetaVarKind, + f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>, + ) -> Option<T> { + self.eat_metavar_seq_with_matcher(|mvk| mvk == mv_kind, f) + } + + /// A slightly more general form of `eat_metavar_seq`, for use with the + /// `MetaVarKind` variants that have parameters, where an exact match isn't + /// desired. + fn eat_metavar_seq_with_matcher<T>( + &mut self, + match_mv_kind: impl Fn(MetaVarKind) -> bool, + mut f: impl FnMut(&mut Parser<'a>) -> PResult<'a, T>, + ) -> Option<T> { + if let token::OpenDelim(delim) = self.token.kind + && let Delimiter::Invisible(InvisibleOrigin::MetaVar(mv_kind)) = delim + && match_mv_kind(mv_kind) + { + self.bump(); + let res = f(self).expect("failed to reparse {mv_kind:?}"); + if let token::CloseDelim(delim) = self.token.kind + && let Delimiter::Invisible(InvisibleOrigin::MetaVar(mv_kind)) = delim + && match_mv_kind(mv_kind) + { + self.bump(); + Some(res) + } else { + panic!("no close delim when reparsing {mv_kind:?}"); + } + } else { + None + } + } + /// Is the given keyword `kw` followed by a non-reserved identifier? fn is_kw_followed_by_ident(&self, kw: Symbol) -> bool { self.token.is_keyword(kw) && self.look_ahead(1, |t| t.is_ident() && !t.is_reserved_ident()) @@ -1455,7 +1513,11 @@ impl<'a> Parser<'a> { /// so emit a proper diagnostic. // Public for rustfmt usage. pub fn parse_visibility(&mut self, fbt: FollowedByType) -> PResult<'a, Visibility> { - maybe_whole!(self, NtVis, |vis| vis.into_inner()); + if let Some(vis) = self + .eat_metavar_seq(MetaVarKind::Vis, |this| this.parse_visibility(FollowedByType::Yes)) + { + return Ok(vis); + } if !self.eat_keyword(exp!(Pub)) { // We need a span for our `Spanned<VisibilityKind>`, but there's inherently no @@ -1683,7 +1745,9 @@ pub enum ParseNtResult { Tt(TokenTree), Ident(Ident, IdentIsRaw), Lifetime(Ident, IdentIsRaw), + Ty(P<ast::Ty>), + Vis(P<ast::Visibility>), - /// This case will eventually be removed, along with `Token::Interpolate`. + /// This variant will eventually be removed, along with `Token::Interpolate`. Nt(Arc<Nonterminal>), } diff --git a/compiler/rustc_parse/src/parser/nonterminal.rs b/compiler/rustc_parse/src/parser/nonterminal.rs index eefdb641da2..f202f85752e 100644 --- a/compiler/rustc_parse/src/parser/nonterminal.rs +++ b/compiler/rustc_parse/src/parser/nonterminal.rs @@ -30,7 +30,7 @@ impl<'a> Parser<'a> { MetaVarKind::Stmt | MetaVarKind::Pat(_) | MetaVarKind::Expr { .. } - | MetaVarKind::Ty + | MetaVarKind::Ty { .. } | MetaVarKind::Literal // `true`, `false` | MetaVarKind::Meta | MetaVarKind::Path => true, @@ -51,14 +51,11 @@ impl<'a> Parser<'a> { NtStmt(_) | NtPat(_) | NtExpr(_) - | NtTy(_) | NtLiteral(_) // `true`, `false` | NtMeta(_) | NtPath(_) => true, - NtItem(_) - | NtBlock(_) - | NtVis(_) => false, + NtItem(_) | NtBlock(_) => false, } } @@ -88,7 +85,7 @@ impl<'a> Parser<'a> { NonterminalKind::Ident => get_macro_ident(token).is_some(), NonterminalKind::Literal => token.can_begin_literal_maybe_minus(), NonterminalKind::Vis => match token.kind { - // The follow-set of :vis + "priv" keyword + interpolated + // The follow-set of :vis + "priv" keyword + interpolated/metavar-expansion. token::Comma | token::Ident(..) | token::NtIdent(..) @@ -102,7 +99,7 @@ impl<'a> Parser<'a> { token::NtLifetime(..) => true, token::Interpolated(nt) => match &**nt { NtBlock(_) | NtStmt(_) | NtExpr(_) | NtLiteral(_) => true, - NtItem(_) | NtPat(_) | NtTy(_) | NtMeta(_) | NtPath(_) | NtVis(_) => false, + NtItem(_) | NtPat(_) | NtMeta(_) | NtPath(_) => false, }, token::OpenDelim(Delimiter::Invisible(InvisibleOrigin::MetaVar(k))) => match k { MetaVarKind::Block @@ -111,7 +108,7 @@ impl<'a> Parser<'a> { | MetaVarKind::Literal => true, MetaVarKind::Item | MetaVarKind::Pat(_) - | MetaVarKind::Ty + | MetaVarKind::Ty { .. } | MetaVarKind::Meta | MetaVarKind::Path | MetaVarKind::Vis => false, @@ -189,7 +186,9 @@ impl<'a> Parser<'a> { NtLiteral(self.collect_tokens_no_attrs(|this| this.parse_literal_maybe_minus())?) } NonterminalKind::Ty => { - NtTy(self.collect_tokens_no_attrs(|this| this.parse_ty_no_question_mark_recover())?) + return Ok(ParseNtResult::Ty( + self.collect_tokens_no_attrs(|this| this.parse_ty_no_question_mark_recover())?, + )); } // this could be handled like a token, since it is one NonterminalKind::Ident => { @@ -208,8 +207,9 @@ impl<'a> Parser<'a> { } NonterminalKind::Meta => NtMeta(P(self.parse_attr_item(ForceCollect::Yes)?)), NonterminalKind::Vis => { - NtVis(P(self - .collect_tokens_no_attrs(|this| this.parse_visibility(FollowedByType::Yes))?)) + return Ok(ParseNtResult::Vis(P(self.collect_tokens_no_attrs(|this| { + this.parse_visibility(FollowedByType::Yes) + })?))); } NonterminalKind::Lifetime => { // We want to keep `'keyword` parsing, just like `keyword` is still diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index b241aa892db..c24305ea9a8 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -2,7 +2,7 @@ use std::mem; use ast::token::IdentIsRaw; use rustc_ast::ptr::P; -use rustc_ast::token::{self, Delimiter, Token, TokenKind}; +use rustc_ast::token::{self, Delimiter, MetaVarKind, Token, TokenKind}; use rustc_ast::{ self as ast, AngleBracketedArg, AngleBracketedArgs, AnonConst, AssocItemConstraint, AssocItemConstraintKind, BlockCheckMode, GenericArg, GenericArgs, Generics, ParenthesizedArgs, @@ -196,14 +196,12 @@ impl<'a> Parser<'a> { maybe_whole!(self, NtPath, |path| reject_generics_if_mod_style(self, path.into_inner())); - if let token::Interpolated(nt) = &self.token.kind { - if let token::NtTy(ty) = &**nt { - if let ast::TyKind::Path(None, path) = &ty.kind { - let path = path.clone(); - self.bump(); - return Ok(reject_generics_if_mod_style(self, path)); - } - } + // If we have a `ty` metavar in the form of a path, reparse it directly as a path, instead + // of reparsing it as a `ty` and then extracting the path. + if let Some(path) = self.eat_metavar_seq(MetaVarKind::Ty { is_path: true }, |this| { + this.parse_path(PathStyle::Type) + }) { + return Ok(reject_generics_if_mod_style(self, path)); } let lo = self.token.span; diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index dc5919b3630..18af0a1c79a 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -1,5 +1,5 @@ use rustc_ast::ptr::P; -use rustc_ast::token::{self, BinOpToken, Delimiter, IdentIsRaw, Token, TokenKind}; +use rustc_ast::token::{self, BinOpToken, Delimiter, IdentIsRaw, MetaVarKind, Token, TokenKind}; use rustc_ast::util::case::Case; use rustc_ast::{ self as ast, BareFnTy, BoundAsyncness, BoundConstness, BoundPolarity, DUMMY_NODE_ID, FnRetTy, @@ -18,7 +18,7 @@ use crate::errors::{ HelpUseLatestEdition, InvalidDynKeyword, LifetimeAfterMut, NeedPlusAfterTraitObjectLifetime, NestedCVariadicType, ReturnTypesUseThinArrow, }; -use crate::{exp, maybe_recover_from_interpolated_ty_qpath, maybe_whole}; +use crate::{exp, maybe_recover_from_interpolated_ty_qpath}; /// Signals whether parsing a type should allow `+`. /// @@ -183,7 +183,8 @@ impl<'a> Parser<'a> { ) } - /// Parse a type without recovering `:` as `->` to avoid breaking code such as `where fn() : for<'a>` + /// Parse a type without recovering `:` as `->` to avoid breaking code such + /// as `where fn() : for<'a>`. pub(super) fn parse_ty_for_where_clause(&mut self) -> PResult<'a, P<Ty>> { self.parse_ty_common( AllowPlus::Yes, @@ -247,7 +248,13 @@ impl<'a> Parser<'a> { ) -> PResult<'a, P<Ty>> { let allow_qpath_recovery = recover_qpath == RecoverQPath::Yes; maybe_recover_from_interpolated_ty_qpath!(self, allow_qpath_recovery); - maybe_whole!(self, NtTy, |ty| ty); + + if let Some(ty) = self.eat_metavar_seq_with_matcher( + |mv_kind| matches!(mv_kind, MetaVarKind::Ty { .. }), + |this| this.parse_ty_no_question_mark_recover(), + ) { + return Ok(ty); + } let lo = self.token.span; let mut impl_dyn_multi = false; diff --git a/compiler/rustc_parse_format/Cargo.toml b/compiler/rustc_parse_format/Cargo.toml index 707c4e31847..a39cca716d2 100644 --- a/compiler/rustc_parse_format/Cargo.toml +++ b/compiler/rustc_parse_format/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_parse_format" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_passes/Cargo.toml b/compiler/rustc_passes/Cargo.toml index f592a12ab75..ba81ef3103b 100644 --- a/compiler/rustc_passes/Cargo.toml +++ b/compiler/rustc_passes/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_passes" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 74c48a45f18..9a4db612cfe 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -48,7 +48,7 @@ fn target_from_impl_item<'tcx>(tcx: TyCtxt<'tcx>, impl_item: &hir::ImplItem<'_>) match impl_item.kind { hir::ImplItemKind::Const(..) => Target::AssocConst, hir::ImplItemKind::Fn(..) => { - let parent_def_id = tcx.hir().get_parent_item(impl_item.hir_id()).def_id; + let parent_def_id = tcx.hir_get_parent_item(impl_item.hir_id()).def_id; let containing_item = tcx.hir().expect_item(parent_def_id); let containing_impl_is_for_trait = match &containing_item.kind { hir::ItemKind::Impl(impl_) => impl_.of_trait.is_some(), @@ -868,7 +868,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { let span = meta.span(); if let Some(location) = match target { Target::AssocTy => { - let parent_def_id = self.tcx.hir().get_parent_item(hir_id).def_id; + let parent_def_id = self.tcx.hir_get_parent_item(hir_id).def_id; let containing_item = self.tcx.hir().expect_item(parent_def_id); if Target::from_item(containing_item) == Target::Impl { Some("type alias in implementation block") @@ -877,7 +877,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } } Target::AssocConst => { - let parent_def_id = self.tcx.hir().get_parent_item(hir_id).def_id; + let parent_def_id = self.tcx.hir_get_parent_item(hir_id).def_id; let containing_item = self.tcx.hir().expect_item(parent_def_id); // We can't link to trait impl's consts. let err = "associated constant in trait implementation block"; @@ -1161,7 +1161,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { // insert a bang between `#` and `[...` let bang_span = attr.span.lo() + BytePos(1); let sugg = (attr.style == AttrStyle::Outer - && self.tcx.hir().get_parent_item(hir_id) == CRATE_OWNER_ID) + && self.tcx.hir_get_parent_item(hir_id) == CRATE_OWNER_ID) .then_some(errors::AttrCrateLevelOnlySugg { attr: attr.span.with_lo(bang_span).with_hi(bang_span), }); @@ -1449,7 +1449,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { // `#[must_use]` can be applied to a trait method definition with a default body if let Target::Method(MethodKind::Trait { body: true }) = target - && let parent_def_id = self.tcx.hir().get_parent_item(hir_id).def_id + && let parent_def_id = self.tcx.hir_get_parent_item(hir_id).def_id && let containing_item = self.tcx.hir().expect_item(parent_def_id) && let hir::ItemKind::Trait(..) = containing_item.kind { @@ -2580,7 +2580,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { .. }) ); - let parent_did = self.tcx.hir().get_parent_item(hir_id).to_def_id(); + let parent_did = self.tcx.hir_get_parent_item(hir_id).to_def_id(); let parent_span = self.tcx.def_span(parent_did); let parent_force_inline_attr = self.tcx.get_attr(parent_did, sym::rustc_force_inline); diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 7b4fecf2ed1..7a14a7a5db2 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -184,7 +184,7 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { rhs: &'tcx hir::Expr<'tcx>, ) -> bool { match (&lhs.kind, &rhs.kind) { - (hir::ExprKind::Path(ref qpath_l), hir::ExprKind::Path(ref qpath_r)) => { + (hir::ExprKind::Path(qpath_l), hir::ExprKind::Path(qpath_r)) => { if let (Res::Local(id_l), Res::Local(id_r)) = ( typeck_results.qpath_res(qpath_l, lhs.hir_id), typeck_results.qpath_res(qpath_r, rhs.hir_id), diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs index a7bca67e4e4..24dc018c661 100644 --- a/compiler/rustc_passes/src/liveness.rs +++ b/compiler/rustc_passes/src/liveness.rs @@ -1623,7 +1623,7 @@ impl<'tcx> Liveness<'_, 'tcx> { && let hir::Node::Pat(pat) = self.ir.tcx.hir_node(var_hid) && let hir::Node::Param(hir::Param { ty_span, .. }) = self.ir.tcx.parent_hir_node(pat.hir_id) - && let item_id = self.ir.tcx.hir().get_parent_item(pat.hir_id) + && let item_id = self.ir.tcx.hir_get_parent_item(pat.hir_id) && let item = self.ir.tcx.hir_owner_node(item_id) && let Some(fn_decl) = item.fn_decl() && let hir::PatKind::Binding(hir::BindingMode::MUT, _hir_id, ident, _) = pat.kind diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index a6585946656..d92edf959af 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -645,7 +645,7 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> { } fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem<'tcx>) { - let impl_def_id = self.tcx.hir().get_parent_item(ii.hir_id()); + let impl_def_id = self.tcx.hir_get_parent_item(ii.hir_id()); if self.tcx.impl_trait_ref(impl_def_id).is_none() { self.check_missing_stability(ii.owner_id.def_id, ii.span); self.check_missing_const_stability(ii.owner_id.def_id, ii.span); @@ -780,11 +780,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> { // individually as it's possible to have a stable trait with unstable // items. hir::ItemKind::Impl(hir::Impl { - of_trait: Some(ref t), - self_ty, - items, - constness, - .. + of_trait: Some(t), self_ty, items, constness, .. }) => { let features = self.tcx.features(); if features.staged_api() { diff --git a/compiler/rustc_pattern_analysis/Cargo.toml b/compiler/rustc_pattern_analysis/Cargo.toml index 16eea9e4ff9..40d549630ac 100644 --- a/compiler/rustc_pattern_analysis/Cargo.toml +++ b/compiler/rustc_pattern_analysis/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_pattern_analysis" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_privacy/Cargo.toml b/compiler/rustc_privacy/Cargo.toml index eb48155919f..242c67d732a 100644 --- a/compiler/rustc_privacy/Cargo.toml +++ b/compiler/rustc_privacy/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_privacy" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_query_impl/Cargo.toml b/compiler/rustc_query_impl/Cargo.toml index fd1d21b6a89..d89e1355ca6 100644 --- a/compiler/rustc_query_impl/Cargo.toml +++ b/compiler/rustc_query_impl/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_query_impl" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_query_system/Cargo.toml b/compiler/rustc_query_system/Cargo.toml index d9560f3eb0f..839465f9273 100644 --- a/compiler/rustc_query_system/Cargo.toml +++ b/compiler/rustc_query_system/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_query_system" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_resolve/Cargo.toml b/compiler/rustc_resolve/Cargo.toml index 309227176d4..f4771f1af2c 100644 --- a/compiler/rustc_resolve/Cargo.toml +++ b/compiler/rustc_resolve/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_resolve" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index c6781ecc566..87f7eda391d 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -1241,7 +1241,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> { }; let binding = (res, vis, span, expansion).to_name_binding(self.r.arenas); self.r.set_binding_parent_module(binding, parent_scope.module); - self.r.all_macro_rules.insert(ident.name, res); + self.r.all_macro_rules.insert(ident.name); if is_macro_export { let import = self.r.arenas.alloc_import(ImportData { kind: ImportKind::MacroExport, diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 46e52e1f131..6b8a7493cd4 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -98,13 +98,13 @@ impl<'ra> std::fmt::Debug for ImportKind<'ra> { use ImportKind::*; match self { Single { - ref source, - ref target, - ref source_bindings, - ref target_bindings, - ref type_ns_only, - ref nested, - ref id, + source, + target, + source_bindings, + target_bindings, + type_ns_only, + nested, + id, } => f .debug_struct("Single") .field("source", source) @@ -122,13 +122,13 @@ impl<'ra> std::fmt::Debug for ImportKind<'ra> { .field("nested", nested) .field("id", id) .finish(), - Glob { ref is_prelude, ref max_vis, ref id } => f + Glob { is_prelude, max_vis, id } => f .debug_struct("Glob") .field("is_prelude", is_prelude) .field("max_vis", max_vis) .field("id", id) .finish(), - ExternCrate { ref source, ref target, ref id } => f + ExternCrate { source, target, id } => f .debug_struct("ExternCrate") .field("source", source) .field("target", target) diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 03aeb8720ca..ad9c3465f0c 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -1191,7 +1191,7 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r debug!("visit_generic_arg({:?})", arg); let prev = replace(&mut self.diag_metadata.currently_processing_generic_args, true); match arg { - GenericArg::Type(ref ty) => { + GenericArg::Type(ty) => { // We parse const arguments as path types as we cannot distinguish them during // parsing. We try to resolve that ambiguity by attempting resolution the type // namespace first, and if that fails we try again in the value namespace. If @@ -1583,7 +1583,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { this.visit_param_bound(bound, BoundKind::Bound); } - if let Some(ref ty) = default { + if let Some(ty) = default { this.ribs[TypeNS].push(forward_ty_ban_rib); this.ribs[ValueNS].push(forward_const_ban_rib); this.visit_ty(ty); @@ -1608,7 +1608,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { this.ribs[TypeNS].pop().unwrap(); this.ribs[ValueNS].pop().unwrap(); - if let Some(ref expr) = default { + if let Some(expr) = default { this.ribs[TypeNS].push(forward_ty_ban_rib); this.ribs[ValueNS].push(forward_const_ban_rib); this.resolve_anon_const( @@ -5044,16 +5044,16 @@ impl ItemInfoCollector<'_, '_, '_> { impl<'ast> Visitor<'ast> for ItemInfoCollector<'_, '_, '_> { fn visit_item(&mut self, item: &'ast Item) { match &item.kind { - ItemKind::TyAlias(box TyAlias { ref generics, .. }) - | ItemKind::Const(box ConstItem { ref generics, .. }) - | ItemKind::Fn(box Fn { ref generics, .. }) - | ItemKind::Enum(_, ref generics) - | ItemKind::Struct(_, ref generics) - | ItemKind::Union(_, ref generics) - | ItemKind::Impl(box Impl { ref generics, .. }) - | ItemKind::Trait(box Trait { ref generics, .. }) - | ItemKind::TraitAlias(ref generics, _) => { - if let ItemKind::Fn(box Fn { ref sig, .. }) = &item.kind { + ItemKind::TyAlias(box TyAlias { generics, .. }) + | ItemKind::Const(box ConstItem { generics, .. }) + | ItemKind::Fn(box Fn { generics, .. }) + | ItemKind::Enum(_, generics) + | ItemKind::Struct(_, generics) + | ItemKind::Union(_, generics) + | ItemKind::Impl(box Impl { generics, .. }) + | ItemKind::Trait(box Trait { generics, .. }) + | ItemKind::TraitAlias(generics, _) => { + if let ItemKind::Fn(box Fn { sig, .. }) = &item.kind { self.collect_fn_info(sig, item.id, &item.attrs); } @@ -5086,7 +5086,7 @@ impl<'ast> Visitor<'ast> for ItemInfoCollector<'_, '_, '_> { } fn visit_assoc_item(&mut self, item: &'ast AssocItem, ctxt: AssocCtxt) { - if let AssocItemKind::Fn(box Fn { ref sig, .. }) = &item.kind { + if let AssocItemKind::Fn(box Fn { sig, .. }) = &item.kind { self.collect_fn_info(sig, item.id, &item.attrs); } visit::walk_assoc_item(self, item, ctxt); diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index b37c684a055..fa9c42e3593 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -516,7 +516,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { let Some(params) = &segment.args else { continue; }; - let ast::GenericArgs::AngleBracketed(ref params) = params.deref() else { + let ast::GenericArgs::AngleBracketed(params) = params.deref() else { continue; }; for param in ¶ms.args { @@ -1668,7 +1668,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { ); } if let PathSource::Expr(Some(Expr { - kind: ExprKind::Call(path, ref args), + kind: ExprKind::Call(path, args), span: call_span, .. })) = source @@ -1802,7 +1802,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { } // e.g. `let _ = Enum::TupleVariant(field1, field2);` PathSource::Expr(Some(Expr { - kind: ExprKind::Call(path, ref args), + kind: ExprKind::Call(path, args), span: call_span, .. })) => { diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 5bc37e09f08..eb4ac6ce77c 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -1220,7 +1220,7 @@ pub struct Resolver<'ra, 'tcx> { effective_visibilities: EffectiveVisibilities, doc_link_resolutions: FxIndexMap<LocalDefId, DocLinkResMap>, doc_link_traits_in_scope: FxIndexMap<LocalDefId, Vec<DefId>>, - all_macro_rules: FxHashMap<Symbol, Res>, + all_macro_rules: FxHashSet<Symbol>, /// Invocation ids of all glob delegations. glob_delegation_invoc_ids: FxHashSet<LocalExpnId>, diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index cca01a01e98..a70def2f6c9 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -857,8 +857,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { ), path_res @ (PathResult::NonModule(..) | PathResult::Failed { .. }) => { let mut suggestion = None; - let (span, label, module) = - if let PathResult::Failed { span, label, module, .. } = path_res { + let (span, label, module, segment) = + if let PathResult::Failed { span, label, module, segment_name, .. } = + path_res + { // try to suggest if it's not a macro, maybe a function if let PathResult::NonModule(partial_res) = self.maybe_resolve_path(&path, Some(ValueNS), &parent_scope, None) @@ -876,7 +878,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { Applicability::MaybeIncorrect, )); } - (span, label, module) + (span, label, module, segment_name) } else { ( path_span, @@ -886,12 +888,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { kind.descr() ), None, + path.last().map(|segment| segment.ident.name).unwrap(), ) }; self.report_error( span, ResolutionError::FailedToResolve { - segment: path.last().map(|segment| segment.ident.name), + segment: Some(segment), label, suggestion, module, @@ -1067,11 +1070,24 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { None, ); if fallback_binding.ok().and_then(|b| b.res().opt_def_id()) != Some(def_id) { + let location = match parent_scope.module.kind { + ModuleKind::Def(_, _, name) if name == kw::Empty => { + "the crate root".to_string() + } + ModuleKind::Def(kind, def_id, name) => { + format!("{} `{name}`", kind.descr(def_id)) + } + ModuleKind::Block => "this scope".to_string(), + }; self.tcx.sess.psess.buffer_lint( OUT_OF_SCOPE_MACRO_CALLS, path.span, node_id, - BuiltinLintDiag::OutOfScopeMacroCalls { path: pprust::path_to_string(path) }, + BuiltinLintDiag::OutOfScopeMacroCalls { + span: path.span, + path: pprust::path_to_string(path), + location, + }, ); } } diff --git a/compiler/rustc_sanitizers/Cargo.toml b/compiler/rustc_sanitizers/Cargo.toml index 5623a493cf0..66488bc9625 100644 --- a/compiler/rustc_sanitizers/Cargo.toml +++ b/compiler/rustc_sanitizers/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_sanitizers" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] bitflags = "2.5.0" diff --git a/compiler/rustc_serialize/Cargo.toml b/compiler/rustc_serialize/Cargo.toml index a6815c7a447..948242352e7 100644 --- a/compiler/rustc_serialize/Cargo.toml +++ b/compiler/rustc_serialize/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_serialize" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_session/Cargo.toml b/compiler/rustc_session/Cargo.toml index 31892c13438..a087725d34d 100644 --- a/compiler/rustc_session/Cargo.toml +++ b/compiler/rustc_session/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_session" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index c4d45ee02ee..8e5ff1d3bc4 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -1019,8 +1019,7 @@ pub fn build_session( let self_profiler = if let SwitchWithOptPath::Enabled(ref d) = sopts.unstable_opts.self_profile { - let directory = - if let Some(ref directory) = d { directory } else { std::path::Path::new(".") }; + let directory = if let Some(directory) = d { directory } else { std::path::Path::new(".") }; let profiler = SelfProfiler::new( directory, diff --git a/compiler/rustc_smir/Cargo.toml b/compiler/rustc_smir/Cargo.toml index 29ce24e8b78..a11df9a9c9b 100644 --- a/compiler/rustc_smir/Cargo.toml +++ b/compiler/rustc_smir/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_smir" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_smir/src/rustc_smir/convert/abi.rs b/compiler/rustc_smir/src/rustc_smir/convert/abi.rs index fb2e838cdc9..a627e0e69b6 100644 --- a/compiler/rustc_smir/src/rustc_smir/convert/abi.rs +++ b/compiler/rustc_smir/src/rustc_smir/convert/abi.rs @@ -202,7 +202,6 @@ impl<'tcx> Stable<'tcx> for rustc_abi::BackendRepr { fn stable(&self, tables: &mut Tables<'_>) -> Self::T { match *self { - rustc_abi::BackendRepr::Uninhabited => ValueAbi::Uninhabited, rustc_abi::BackendRepr::Scalar(scalar) => ValueAbi::Scalar(scalar.stable(tables)), rustc_abi::BackendRepr::ScalarPair(first, second) => { ValueAbi::ScalarPair(first.stable(tables), second.stable(tables)) diff --git a/compiler/rustc_span/Cargo.toml b/compiler/rustc_span/Cargo.toml index 991c75cc98d..43a2d692577 100644 --- a/compiler/rustc_span/Cargo.toml +++ b/compiler/rustc_span/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_span" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 695edc956cd..c09669d959c 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -404,7 +404,7 @@ impl fmt::Display for FileNameDisplay<'_> { impl<'a> FileNameDisplay<'a> { pub fn to_string_lossy(&self) -> Cow<'a, str> { match self.inner { - FileName::Real(ref inner) => inner.to_string_lossy(self.display_pref), + FileName::Real(inner) => inner.to_string_lossy(self.display_pref), _ => Cow::from(self.to_string()), } } @@ -1442,7 +1442,7 @@ pub enum ExternalSourceKind { impl ExternalSource { pub fn get_source(&self) -> Option<&str> { match self { - ExternalSource::Foreign { kind: ExternalSourceKind::Present(ref src), .. } => Some(src), + ExternalSource::Foreign { kind: ExternalSourceKind::Present(src), .. } => Some(src), _ => None, } } diff --git a/compiler/rustc_symbol_mangling/Cargo.toml b/compiler/rustc_symbol_mangling/Cargo.toml index 4c51c908f54..12fe6b719f9 100644 --- a/compiler/rustc_symbol_mangling/Cargo.toml +++ b/compiler/rustc_symbol_mangling/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_symbol_mangling" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_target/Cargo.toml b/compiler/rustc_target/Cargo.toml index e33431ba122..189b19b0286 100644 --- a/compiler/rustc_target/Cargo.toml +++ b/compiler/rustc_target/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_target" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_target/src/callconv/loongarch.rs b/compiler/rustc_target/src/callconv/loongarch.rs index 47566bde6b4..3fa67c624a7 100644 --- a/compiler/rustc_target/src/callconv/loongarch.rs +++ b/compiler/rustc_target/src/callconv/loongarch.rs @@ -80,7 +80,7 @@ where } } }, - BackendRepr::Vector { .. } | BackendRepr::Uninhabited => return Err(CannotUseFpConv), + BackendRepr::Vector { .. } => return Err(CannotUseFpConv), BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => match arg_layout.fields { FieldsShape::Primitive => { unreachable!("aggregates can't have `FieldsShape::Primitive`") diff --git a/compiler/rustc_target/src/callconv/mod.rs b/compiler/rustc_target/src/callconv/mod.rs index c2a176facdf..1c044fe98b3 100644 --- a/compiler/rustc_target/src/callconv/mod.rs +++ b/compiler/rustc_target/src/callconv/mod.rs @@ -38,7 +38,7 @@ mod xtensa; pub enum PassMode { /// Ignore the argument. /// - /// The argument is either uninhabited or a ZST. + /// The argument is a ZST. Ignore, /// Pass the argument directly. /// @@ -350,7 +350,6 @@ impl<'a, Ty> ArgAbi<'a, Ty> { scalar_attrs: impl Fn(&TyAndLayout<'a, Ty>, Scalar, Size) -> ArgAttributes, ) -> Self { let mode = match layout.backend_repr { - BackendRepr::Uninhabited => PassMode::Ignore, BackendRepr::Scalar(scalar) => { PassMode::Direct(scalar_attrs(&layout, scalar, Size::ZERO)) } @@ -737,7 +736,9 @@ impl<'a, Ty> FnAbi<'a, Ty> { // to 128-bit-sized vectors. "x86" if spec.rustc_abi == Some(RustcAbi::X86Sse2) => arg.layout.size.bits() <= 128, "x86_64" if spec.rustc_abi != Some(RustcAbi::X86Softfloat) => { - arg.layout.size.bits() <= 128 + // FIXME once https://github.com/bytecodealliance/wasmtime/issues/10254 is fixed + // accept vectors up to 128bit rather than vectors of exactly 128bit. + arg.layout.size.bits() == 128 } // So far, we haven't implemented this logic for any other target. _ => false, diff --git a/compiler/rustc_target/src/callconv/riscv.rs b/compiler/rustc_target/src/callconv/riscv.rs index 265ae20f991..785175229b0 100644 --- a/compiler/rustc_target/src/callconv/riscv.rs +++ b/compiler/rustc_target/src/callconv/riscv.rs @@ -86,7 +86,7 @@ where } } }, - BackendRepr::Vector { .. } | BackendRepr::Uninhabited => return Err(CannotUseFpConv), + BackendRepr::Vector { .. } => return Err(CannotUseFpConv), BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => match arg_layout.fields { FieldsShape::Primitive => { unreachable!("aggregates can't have `FieldsShape::Primitive`") diff --git a/compiler/rustc_target/src/callconv/x86.rs b/compiler/rustc_target/src/callconv/x86.rs index 5f4f4cd57f6..7e5aab0201b 100644 --- a/compiler/rustc_target/src/callconv/x86.rs +++ b/compiler/rustc_target/src/callconv/x86.rs @@ -108,9 +108,7 @@ where Ty: TyAbiInterface<'a, C> + Copy, { match layout.backend_repr { - BackendRepr::Uninhabited - | BackendRepr::Scalar(_) - | BackendRepr::ScalarPair(..) => false, + BackendRepr::Scalar(_) | BackendRepr::ScalarPair(..) => false, BackendRepr::Vector { .. } => true, BackendRepr::Memory { .. } => { for i in 0..layout.fields.count() { diff --git a/compiler/rustc_target/src/callconv/x86_64.rs b/compiler/rustc_target/src/callconv/x86_64.rs index b15d82c26da..ab306e20239 100644 --- a/compiler/rustc_target/src/callconv/x86_64.rs +++ b/compiler/rustc_target/src/callconv/x86_64.rs @@ -51,8 +51,6 @@ where } let mut c = match layout.backend_repr { - BackendRepr::Uninhabited => return Ok(()), - BackendRepr::Scalar(scalar) => match scalar.primitive() { Primitive::Int(..) | Primitive::Pointer(_) => Class::Int, Primitive::Float(_) => Class::Sse, diff --git a/compiler/rustc_target/src/callconv/x86_win64.rs b/compiler/rustc_target/src/callconv/x86_win64.rs index 2ef5127de04..4d99a9f9ba0 100644 --- a/compiler/rustc_target/src/callconv/x86_win64.rs +++ b/compiler/rustc_target/src/callconv/x86_win64.rs @@ -8,7 +8,7 @@ use crate::spec::{HasTargetSpec, RustcAbi}; pub(crate) fn compute_abi_info<Ty>(cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<'_, Ty>) { let fixup = |a: &mut ArgAbi<'_, Ty>, is_ret: bool| { match a.layout.backend_repr { - BackendRepr::Uninhabited | BackendRepr::Memory { sized: false } => {} + BackendRepr::Memory { sized: false } => {} BackendRepr::ScalarPair(..) | BackendRepr::Memory { sized: true } => { match a.layout.size.bits() { 8 => a.cast_to(Reg::i8()), diff --git a/compiler/rustc_target/src/spec/base/avr_gnu.rs b/compiler/rustc_target/src/spec/base/avr.rs index 3554dcfcb4a..85b73e61e52 100644 --- a/compiler/rustc_target/src/spec/base/avr_gnu.rs +++ b/compiler/rustc_target/src/spec/base/avr.rs @@ -1,45 +1,5 @@ use object::elf; -use crate::spec::{Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions}; - -/// A base target for AVR devices using the GNU toolchain. -/// -/// Requires GNU avr-gcc and avr-binutils on the host system. -/// FIXME: Remove the second parameter when const string concatenation is possible. -pub(crate) fn target(target_cpu: &'static str, mmcu: &'static str) -> Target { - Target { - arch: "avr".into(), - metadata: crate::spec::TargetMetadata { - description: None, - tier: None, - host_tools: None, - std: None, - }, - data_layout: "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8".into(), - llvm_target: "avr-unknown-unknown".into(), - pointer_width: 16, - options: TargetOptions { - env: "gnu".into(), - - c_int_width: "16".into(), - cpu: target_cpu.into(), - exe_suffix: ".elf".into(), - - linker: Some("avr-gcc".into()), - eh_frame_header: false, - pre_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[mmcu]), - late_link_args: TargetOptions::link_args( - LinkerFlavor::Gnu(Cc::Yes, Lld::No), - &["-lgcc"], - ), - max_atomic_width: Some(16), - atomic_cas: false, - relocation_model: RelocModel::Static, - ..TargetOptions::default() - }, - } -} - /// Resolve the value of the EF_AVR_ARCH field for AVR ELF files, given the /// name of the target CPU / MCU. /// diff --git a/compiler/rustc_target/src/spec/base/mod.rs b/compiler/rustc_target/src/spec/base/mod.rs index b9139c8452c..6f88be5d37f 100644 --- a/compiler/rustc_target/src/spec/base/mod.rs +++ b/compiler/rustc_target/src/spec/base/mod.rs @@ -1,7 +1,7 @@ pub(crate) mod aix; pub(crate) mod android; pub(crate) mod apple; -pub(crate) mod avr_gnu; +pub(crate) mod avr; pub(crate) mod bpf; pub(crate) mod cygwin; pub(crate) mod dragonfly; diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index f7e467b0c11..65736770efb 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -60,7 +60,7 @@ pub mod crt_objects; mod base; mod json; -pub use base::avr_gnu::ef_avr_arch; +pub use base::avr::ef_avr_arch; /// Linker is called through a C/C++ compiler. #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] @@ -303,15 +303,16 @@ impl LinkerFlavor { } } - fn infer_linker_hints(linker_stem: &str) -> (Option<Cc>, Option<Lld>) { + fn infer_linker_hints(linker_stem: &str) -> Result<Self, (Option<Cc>, Option<Lld>)> { // Remove any version postfix. let stem = linker_stem .rsplit_once('-') .and_then(|(lhs, rhs)| rhs.chars().all(char::is_numeric).then_some(lhs)) .unwrap_or(linker_stem); - // GCC/Clang can have an optional target prefix. - if stem == "emcc" + if stem == "llvm-bitcode-linker" { + Ok(Self::Llbc) + } else if stem == "emcc" // GCC/Clang can have an optional target prefix. || stem == "gcc" || stem.ends_with("-gcc") || stem == "g++" @@ -321,7 +322,7 @@ impl LinkerFlavor { || stem == "clang++" || stem.ends_with("-clang++") { - (Some(Cc::Yes), Some(Lld::No)) + Err((Some(Cc::Yes), Some(Lld::No))) } else if stem == "wasm-ld" || stem.ends_with("-wasm-ld") || stem == "ld.lld" @@ -329,11 +330,11 @@ impl LinkerFlavor { || stem == "rust-lld" || stem == "lld-link" { - (Some(Cc::No), Some(Lld::Yes)) + Err((Some(Cc::No), Some(Lld::Yes))) } else if stem == "ld" || stem.ends_with("-ld") || stem == "link" { - (Some(Cc::No), Some(Lld::No)) + Err((Some(Cc::No), Some(Lld::No))) } else { - (None, None) + Err((None, None)) } } @@ -357,7 +358,10 @@ impl LinkerFlavor { } pub fn with_linker_hints(self, linker_stem: &str) -> LinkerFlavor { - self.with_hints(LinkerFlavor::infer_linker_hints(linker_stem)) + match LinkerFlavor::infer_linker_hints(linker_stem) { + Ok(linker_flavor) => linker_flavor, + Err(hints) => self.with_hints(hints), + } } pub fn check_compatibility(self, cli: LinkerFlavorCli) -> Option<String> { @@ -1797,7 +1801,7 @@ supported_targets! { ("riscv64gc-unknown-fuchsia", riscv64gc_unknown_fuchsia), ("x86_64-unknown-fuchsia", x86_64_unknown_fuchsia), - ("avr-unknown-gnu-atmega328", avr_unknown_gnu_atmega328), + ("avr-none", avr_none), ("x86_64-unknown-l4re-uclibc", x86_64_unknown_l4re_uclibc), @@ -2001,7 +2005,7 @@ supported_targets! { ("x86_64-pc-nto-qnx710", x86_64_pc_nto_qnx710), ("x86_64-pc-nto-qnx710_iosock", x86_64_pc_nto_qnx710_iosock), ("x86_64-pc-nto-qnx800", x86_64_pc_nto_qnx800), - ("i586-pc-nto-qnx700", i586_pc_nto_qnx700), + ("i686-pc-nto-qnx700", i686_pc_nto_qnx700), ("aarch64-unknown-linux-ohos", aarch64_unknown_linux_ohos), ("armv7-unknown-linux-ohos", armv7_unknown_linux_ohos), @@ -3062,7 +3066,10 @@ impl Target { &self.post_link_args, ] { for (&flavor, flavor_args) in args { - check!(!flavor_args.is_empty(), "linker flavor args must not be empty"); + check!( + !flavor_args.is_empty() || self.arch == "avr", + "linker flavor args must not be empty" + ); // Check that flavors mentioned in link args are compatible with the default flavor. match self.linker_flavor { LinkerFlavor::Gnu(..) => { diff --git a/compiler/rustc_target/src/spec/targets/avr_none.rs b/compiler/rustc_target/src/spec/targets/avr_none.rs new file mode 100644 index 00000000000..91d3197d099 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/avr_none.rs @@ -0,0 +1,32 @@ +use crate::spec::{Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions}; + +pub(crate) fn target() -> Target { + Target { + arch: "avr".into(), + metadata: crate::spec::TargetMetadata { + description: None, + tier: None, + host_tools: None, + std: None, + }, + data_layout: "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8".into(), + llvm_target: "avr-unknown-unknown".into(), + pointer_width: 16, + options: TargetOptions { + c_int_width: "16".into(), + exe_suffix: ".elf".into(), + linker: Some("avr-gcc".into()), + eh_frame_header: false, + pre_link_args: TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[]), + late_link_args: TargetOptions::link_args( + LinkerFlavor::Gnu(Cc::Yes, Lld::No), + &["-lgcc"], + ), + max_atomic_width: Some(16), + atomic_cas: false, + relocation_model: RelocModel::Static, + need_explicit_cpu: true, + ..TargetOptions::default() + }, + } +} diff --git a/compiler/rustc_target/src/spec/targets/avr_unknown_gnu_atmega328.rs b/compiler/rustc_target/src/spec/targets/avr_unknown_gnu_atmega328.rs deleted file mode 100644 index c3d6fb72273..00000000000 --- a/compiler/rustc_target/src/spec/targets/avr_unknown_gnu_atmega328.rs +++ /dev/null @@ -1,5 +0,0 @@ -use crate::spec::{Target, base}; - -pub(crate) fn target() -> Target { - base::avr_gnu::target("atmega328", "-mmcu=atmega328") -} diff --git a/compiler/rustc_target/src/spec/targets/i586_pc_nto_qnx700.rs b/compiler/rustc_target/src/spec/targets/i686_pc_nto_qnx700.rs index 6a98a763b36..6a98a763b36 100644 --- a/compiler/rustc_target/src/spec/targets/i586_pc_nto_qnx700.rs +++ b/compiler/rustc_target/src/spec/targets/i686_pc_nto_qnx700.rs diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index bb41d03e87f..b98bca60c9d 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -611,7 +611,26 @@ static LOONGARCH_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ const IBMZ_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ // tidy-alphabetical-start ("backchain", Unstable(sym::s390x_target_feature), &[]), + ("deflate-conversion", Unstable(sym::s390x_target_feature), &[]), + ("enhanced-sort", Unstable(sym::s390x_target_feature), &[]), + ("guarded-storage", Unstable(sym::s390x_target_feature), &[]), + ("high-word", Unstable(sym::s390x_target_feature), &[]), + ("nnp-assist", Unstable(sym::s390x_target_feature), &["vector"]), + ("transactional-execution", Unstable(sym::s390x_target_feature), &[]), ("vector", Unstable(sym::s390x_target_feature), &[]), + ("vector-enhancements-1", Unstable(sym::s390x_target_feature), &["vector"]), + ("vector-enhancements-2", Unstable(sym::s390x_target_feature), &["vector-enhancements-1"]), + ("vector-packed-decimal", Unstable(sym::s390x_target_feature), &["vector"]), + ( + "vector-packed-decimal-enhancement", + Unstable(sym::s390x_target_feature), + &["vector-packed-decimal"], + ), + ( + "vector-packed-decimal-enhancement-2", + Unstable(sym::s390x_target_feature), + &["vector-packed-decimal-enhancement"], + ), // tidy-alphabetical-end ]; @@ -768,7 +787,7 @@ impl Target { /// the first list contains target features that must be enabled for ABI reasons, /// and the second list contains target feature that must be disabled for ABI reasons. /// - /// These features are automatically appended to whatever the target spec sats as default + /// These features are automatically appended to whatever the target spec sets as default /// features for the target. /// /// All features enabled/disabled via `-Ctarget-features` and `#[target_features]` are checked diff --git a/compiler/rustc_trait_selection/Cargo.toml b/compiler/rustc_trait_selection/Cargo.toml index 2f2361609a2..1c61e23362a 100644 --- a/compiler/rustc_trait_selection/Cargo.toml +++ b/compiler/rustc_trait_selection/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_trait_selection" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_trait_selection/messages.ftl b/compiler/rustc_trait_selection/messages.ftl index 055a3edcc32..4db9d9915b1 100644 --- a/compiler/rustc_trait_selection/messages.ftl +++ b/compiler/rustc_trait_selection/messages.ftl @@ -225,14 +225,6 @@ trait_selection_mismatched_static_lifetime = incompatible lifetime on type trait_selection_missing_options_for_on_unimplemented_attr = missing options for `on_unimplemented` attribute .help = at least one of the `message`, `note` and `label` options are expected -trait_selection_more_targeted = {$has_param_name -> - [true] `{$param_name}` - *[false] `fn` parameter -} has {$has_lifetime -> - [true] lifetime `{$lifetime}` - *[false] an anonymous lifetime `'_` -} but calling `{$ident}` introduces an implicit `'static` lifetime requirement - trait_selection_msl_introduces_static = introduces a `'static` lifetime requirement trait_selection_msl_unmet_req = because this has an unmet lifetime requirement diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mismatched_static_lifetime.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mismatched_static_lifetime.rs index ad2f7f00fa5..0904177ea8b 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mismatched_static_lifetime.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mismatched_static_lifetime.rs @@ -33,11 +33,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { }; // If we added a "points at argument expression" obligation, we remove it here, we care // about the original obligation only. - let code = match cause.code() { - ObligationCauseCode::FunctionArg { parent_code, .. } => &*parent_code, - code => code, - }; - let ObligationCauseCode::MatchImpl(parent, impl_def_id) = code else { + let ObligationCauseCode::MatchImpl(parent, impl_def_id) = cause.code() else { return None; }; let (ObligationCauseCode::WhereClause(_, binding_span) diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs index 5b8d48e3ca9..083ce022238 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs @@ -1,27 +1,21 @@ //! Error Reporting for static impl Traits. use rustc_data_structures::fx::FxIndexSet; -use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan, Subdiagnostic}; +use rustc_errors::{Applicability, Diag, ErrorGuaranteed}; use rustc_hir::def_id::DefId; use rustc_hir::intravisit::{Visitor, VisitorExt, walk_ty}; use rustc_hir::{ self as hir, AmbigArg, GenericBound, GenericParam, GenericParamKind, Item, ItemKind, Lifetime, LifetimeName, LifetimeParamKind, MissingLifetimeKind, Node, TyKind, }; -use rustc_middle::ty::{ - self, AssocItemContainer, StaticLifetimeVisitor, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor, -}; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor}; use rustc_span::def_id::LocalDefId; use rustc_span::{Ident, Span}; use tracing::debug; use crate::error_reporting::infer::nice_region_error::NiceRegionError; -use crate::errors::{ - ButCallingIntroduces, ButNeedsToSatisfy, DynTraitConstraintSuggestion, MoreTargeted, - ReqIntroducedLocations, -}; -use crate::infer::{RegionResolutionError, SubregionOrigin, TypeTrace}; -use crate::traits::{ObligationCauseCode, UnifyReceiverContext}; +use crate::errors::ButNeedsToSatisfy; +use crate::infer::{RegionResolutionError, SubregionOrigin}; impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { /// Print the error message for lifetime errors when the return type is a static `impl Trait`, @@ -39,52 +33,6 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { sup_r, spans, ) if sub_r.is_static() => (var_origin, sub_origin, sub_r, sup_origin, sup_r, spans), - RegionResolutionError::ConcreteFailure( - SubregionOrigin::Subtype(box TypeTrace { cause, .. }), - sub_r, - sup_r, - ) if sub_r.is_static() => { - // This is for an implicit `'static` requirement coming from `impl dyn Trait {}`. - if let ObligationCauseCode::UnifyReceiver(ctxt) = cause.code() { - // This may have a closure and it would cause ICE - // through `find_param_with_region` (#78262). - let anon_reg_sup = tcx.is_suitable_region(self.generic_param_scope, *sup_r)?; - let fn_returns = tcx.return_type_impl_or_dyn_traits(anon_reg_sup.scope); - if fn_returns.is_empty() { - return None; - } - - let param = self.find_param_with_region(*sup_r, *sub_r)?; - let simple_ident = param.param.pat.simple_ident(); - - let (has_impl_path, impl_path) = match ctxt.assoc_item.container { - AssocItemContainer::Trait => { - let id = ctxt.assoc_item.container_id(tcx); - (true, tcx.def_path_str(id)) - } - AssocItemContainer::Impl => (false, String::new()), - }; - - let mut err = self.tcx().dcx().create_err(ButCallingIntroduces { - param_ty_span: param.param_ty_span, - cause_span: cause.span, - has_param_name: simple_ident.is_some(), - param_name: simple_ident.map(|x| x.to_string()).unwrap_or_default(), - has_lifetime: sup_r.has_name(), - lifetime: sup_r.to_string(), - assoc_item: ctxt.assoc_item.name, - has_impl_path, - impl_path, - }); - if self.find_impl_on_dyn_trait(&mut err, param.param_ty, ctxt) { - let reported = err.emit(); - return Some(reported); - } else { - err.cancel() - } - } - return None; - } _ => return None, }; debug!( @@ -140,39 +88,6 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { None }; - let mut subdiag = None; - - if let SubregionOrigin::Subtype(box TypeTrace { cause, .. }) = sub_origin { - if let ObligationCauseCode::ReturnValue(hir_id) - | ObligationCauseCode::BlockTailExpression(hir_id, ..) = cause.code() - { - let parent_id = tcx.hir().get_parent_item(*hir_id); - if let Some(fn_decl) = tcx.hir_fn_decl_by_hir_id(parent_id.into()) { - let mut span: MultiSpan = fn_decl.output.span().into(); - let mut spans = Vec::new(); - let mut add_label = true; - if let hir::FnRetTy::Return(ty) = fn_decl.output { - let mut v = StaticLifetimeVisitor(vec![], tcx.hir()); - v.visit_ty_unambig(ty); - if !v.0.is_empty() { - span = v.0.clone().into(); - spans = v.0; - add_label = false; - } - } - let fn_decl_span = fn_decl.output.span(); - - subdiag = Some(ReqIntroducedLocations { - span, - spans, - fn_decl_span, - cause_span: cause.span, - add_label, - }); - } - } - } - let diag = ButNeedsToSatisfy { sp, influencer_point, @@ -183,7 +98,6 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { require_span_as_note: require_as_note.then_some(require_span), // We don't need a note, it's already at the end, it can be shown as a `span_label`. require_span_as_label: (!require_as_note).then_some(require_span), - req_introduces_loc: subdiag, has_lifetime: sup_r.has_name(), lifetime: lifetime_name.clone(), @@ -197,45 +111,6 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { let fn_returns = tcx.return_type_impl_or_dyn_traits(anon_reg_sup.scope); - let mut override_error_code = None; - if let SubregionOrigin::Subtype(box TypeTrace { cause, .. }) = &sup_origin - && let ObligationCauseCode::UnifyReceiver(ctxt) = cause.code() - // Handle case of `impl Foo for dyn Bar { fn qux(&self) {} }` introducing a - // `'static` lifetime when called as a method on a binding: `bar.qux()`. - && self.find_impl_on_dyn_trait(&mut err, param.param_ty, ctxt) - { - override_error_code = Some(ctxt.assoc_item.name); - } - - if let SubregionOrigin::Subtype(box TypeTrace { cause, .. }) = &sub_origin - && let code = match cause.code() { - ObligationCauseCode::MatchImpl(parent, ..) => parent.code(), - _ => cause.code(), - } - && let ( - &ObligationCauseCode::WhereClause(item_def_id, _) - | &ObligationCauseCode::WhereClauseInExpr(item_def_id, ..), - None, - ) = (code, override_error_code) - { - // Same case of `impl Foo for dyn Bar { fn qux(&self) {} }` introducing a `'static` - // lifetime as above, but called using a fully-qualified path to the method: - // `Foo::qux(bar)`. - let mut v = TraitObjectVisitor(FxIndexSet::default()); - v.visit_ty(param.param_ty); - if let Some((ident, self_ty)) = - NiceRegionError::get_impl_ident_and_self_ty_from_trait(tcx, item_def_id, &v.0) - && self.suggest_constrain_dyn_trait_in_impl(&mut err, &v.0, ident, self_ty) - { - override_error_code = Some(ident.name); - } - } - if let (Some(ident), true) = (override_error_code, fn_returns.is_empty()) { - // Provide a more targeted error code and description. - let retarget_subdiag = MoreTargeted { ident }; - retarget_subdiag.add_to_diag(&mut err); - } - let arg = match param.param.pat.simple_ident() { Some(simple_ident) => format!("argument `{simple_ident}`"), None => "the argument".to_string(), @@ -472,7 +347,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { ) -> Option<(Ident, &'tcx hir::Ty<'tcx>)> { match tcx.hir_get_if_local(def_id)? { Node::ImplItem(impl_item) => { - let impl_did = tcx.hir().get_parent_item(impl_item.hir_id()); + let impl_did = tcx.hir_get_parent_item(impl_item.hir_id()); if let hir::OwnerNode::Item(Item { kind: ItemKind::Impl(hir::Impl { self_ty, .. }), .. @@ -484,7 +359,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { } } Node::TraitItem(trait_item) => { - let trait_id = tcx.hir().get_parent_item(trait_item.hir_id()); + let trait_id = tcx.hir_get_parent_item(trait_item.hir_id()); debug_assert_eq!(tcx.def_kind(trait_id.def_id), hir::def::DefKind::Trait); // The method being called is defined in the `trait`, but the `'static` // obligation comes from the `impl`. Find that `impl` so that we can point @@ -495,8 +370,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { kind: ItemKind::Impl(hir::Impl { self_ty, .. }), .. }) = tcx.hir_node_by_def_id(impl_did) && trait_objects.iter().all(|did| { - // FIXME: we should check `self_ty` against the receiver - // type in the `UnifyReceiver` context, but for now, use + // FIXME: we should check `self_ty`, but for now, use // this imperfect proxy. This will fail if there are // multiple `impl`s for the same trait like // `impl Foo for Box<dyn Bar>` and `impl Foo for dyn Bar`. @@ -516,62 +390,6 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { _ => None, } } - - /// When we call a method coming from an `impl Foo for dyn Bar`, `dyn Bar` introduces a default - /// `'static` obligation. Suggest relaxing that implicit bound. - fn find_impl_on_dyn_trait( - &self, - err: &mut Diag<'_>, - ty: Ty<'_>, - ctxt: &UnifyReceiverContext<'tcx>, - ) -> bool { - let tcx = self.tcx(); - - // Find the method being called. - let Ok(Some(instance)) = ty::Instance::try_resolve( - tcx, - self.cx.typing_env(ctxt.param_env), - ctxt.assoc_item.def_id, - self.cx.resolve_vars_if_possible(ctxt.args), - ) else { - return false; - }; - - let mut v = TraitObjectVisitor(FxIndexSet::default()); - v.visit_ty(ty); - - // Get the `Ident` of the method being called and the corresponding `impl` (to point at - // `Bar` in `impl Foo for dyn Bar {}` and the definition of the method being called). - let Some((ident, self_ty)) = - NiceRegionError::get_impl_ident_and_self_ty_from_trait(tcx, instance.def_id(), &v.0) - else { - return false; - }; - - // Find the trait object types in the argument, so we point at *only* the trait object. - self.suggest_constrain_dyn_trait_in_impl(err, &v.0, ident, self_ty) - } - - fn suggest_constrain_dyn_trait_in_impl( - &self, - err: &mut Diag<'_>, - found_dids: &FxIndexSet<DefId>, - ident: Ident, - self_ty: &hir::Ty<'_>, - ) -> bool { - let mut suggested = false; - for found_did in found_dids { - let mut traits = vec![]; - let mut hir_v = HirTraitObjectVisitor(&mut traits, *found_did); - hir_v.visit_ty_unambig(self_ty); - for &span in &traits { - let subdiag = DynTraitConstraintSuggestion { span, ident }; - subdiag.add_to_diag(err); - suggested = true; - } - } - suggested - } } /// Collect all the trait objects in a type that could have received an implicit `'static` lifetime. diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs index 37032b53901..36726cc6cae 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs @@ -586,7 +586,7 @@ impl<T> Trait<T> for X { hir::Node::TraitItem(item) => item.hir_id(), _ => return false, }; - let parent = tcx.hir().get_parent_item(hir_id).def_id; + let parent = tcx.hir_get_parent_item(hir_id).def_id; self.suggest_constraint(diag, msg, parent.into(), proj_ty, ty) } @@ -820,7 +820,7 @@ fn foo(&self) -> Self::T { String::new() } // When `body_owner` is an `impl` or `trait` item, look in its associated types for // `expected` and point at it. let hir_id = tcx.local_def_id_to_hir_id(def_id); - let parent_id = tcx.hir().get_parent_item(hir_id); + let parent_id = tcx.hir_get_parent_item(hir_id); let item = tcx.hir_node_by_def_id(parent_id.def_id); debug!("expected_projection parent item {:?}", item); diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs index 628888c8d45..a7e68e6419d 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs @@ -10,7 +10,6 @@ use rustc_hir::def::Res; use rustc_hir::{MatchSource, Node}; use rustc_middle::traits::{ IfExpressionCause, MatchExpressionArmCause, ObligationCause, ObligationCauseCode, - StatementAsExpression, }; use rustc_middle::ty::error::TypeError; use rustc_middle::ty::print::with_no_trimmed_paths; @@ -26,8 +25,14 @@ use crate::errors::{ SuggestTuplePatternMany, SuggestTuplePatternOne, TypeErrorAdditionalDiags, }; +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] +enum StatementAsExpression { + CorrectType, + NeedsBoxing, +} + #[derive(Clone, Copy)] -pub enum SuggestAsRefKind { +enum SuggestAsRefKind { Option, Result, } @@ -232,7 +237,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { Some(ConsiderAddingAwait::FutureSugg { span: then_span.shrink_to_hi() }) } ObligationCauseCode::MatchExpressionArm(box MatchExpressionArmCause { - ref prior_non_diverging_arms, + prior_non_diverging_arms, .. }) => Some({ ConsiderAddingAwait::FutureSuggMultiple { @@ -382,7 +387,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } } - pub fn suggest_function_pointers_impl( + pub(crate) fn suggest_function_pointers_impl( &self, span: Option<Span>, exp_found: &ty::error::ExpectedFound<Ty<'tcx>>, @@ -518,7 +523,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } } - pub fn should_suggest_as_ref_kind( + fn should_suggest_as_ref_kind( &self, expected: Ty<'tcx>, found: Ty<'tcx>, @@ -588,8 +593,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { ) -> Option<TypeErrorAdditionalDiags> { /// Find the if expression with given span struct IfVisitor { - pub found_if: bool, - pub err_span: Span, + found_if: bool, + err_span: Span, } impl<'v> Visitor<'v> for IfVisitor { @@ -736,7 +741,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { impl<'tcx> TypeErrCtxt<'_, 'tcx> { /// Be helpful when the user wrote `{... expr; }` and taking the `;` off /// is enough to fix the error. - pub fn could_remove_semicolon( + fn could_remove_semicolon( &self, blk: &'tcx hir::Block<'tcx>, expected_ty: Ty<'tcx>, @@ -816,7 +821,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { /// Suggest returning a local binding with a compatible type if the block /// has no return expression. - pub fn consider_returning_binding_diag( + fn consider_returning_binding_diag( &self, blk: &'tcx hir::Block<'tcx>, expected_ty: Ty<'tcx>, 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 a8ee4d61e65..596f794568c 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 @@ -192,19 +192,38 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let have_alt_message = message.is_some() || label.is_some(); let is_try_conversion = self.is_try_conversion(span, main_trait_predicate.def_id()); + let is_question_mark = matches!( + root_obligation.cause.code().peel_derives(), + ObligationCauseCode::QuestionMark, + ) && !( + self.tcx.is_diagnostic_item(sym::FromResidual, main_trait_predicate.def_id()) + || self.tcx.is_lang_item(main_trait_predicate.def_id(), LangItem::Try) + ); let is_unsize = self.tcx.is_lang_item(leaf_trait_predicate.def_id(), LangItem::Unsize); + let question_mark_message = "the question mark operation (`?`) implicitly \ + performs a conversion on the error value \ + using the `From` trait"; let (message, notes, append_const_msg) = if is_try_conversion { + // We have a `-> Result<_, E1>` and `gives_E2()?`. ( Some(format!( "`?` couldn't convert the error to `{}`", main_trait_predicate.skip_binder().self_ty(), )), - vec![ - "the question mark operation (`?`) implicitly performs a \ - conversion on the error value using the `From` trait" - .to_owned(), - ], + vec![question_mark_message.to_owned()], + Some(AppendConstMessage::Default), + ) + } else if is_question_mark { + // Similar to the case above, but in this case the conversion is for a + // trait object: `-> Result<_, Box<dyn Error>` and `gives_E()?` when + // `E: Error` isn't met. + ( + Some(format!( + "`?` couldn't convert the error: `{main_trait_predicate}` is \ + not satisfied", + )), + vec![question_mark_message.to_owned()], Some(AppendConstMessage::Default), ) } else { @@ -220,8 +239,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { &mut long_ty_file, ); - let (err_msg, safe_transmute_explanation) = if self.tcx.is_lang_item(main_trait_predicate.def_id(), LangItem::TransmuteTrait) - { + let (err_msg, safe_transmute_explanation) = if self.tcx.is_lang_item( + main_trait_predicate.def_id(), + LangItem::TransmuteTrait, + ) { // Recompute the safe transmute reason and use that for the error reporting match self.get_safe_transmute_error_and_reason( obligation.clone(), @@ -249,18 +270,22 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { *err.long_ty_path() = long_ty_file; let mut suggested = false; - if is_try_conversion { + if is_try_conversion || is_question_mark { suggested = self.try_conversion_context(&obligation, main_trait_predicate, &mut err); } - if is_try_conversion && let Some(ret_span) = self.return_type_span(&obligation) { - err.span_label( - ret_span, - format!( - "expected `{}` because of this", - main_trait_predicate.skip_binder().self_ty() - ), - ); + if let Some(ret_span) = self.return_type_span(&obligation) { + if is_try_conversion { + err.span_label( + ret_span, + format!( + "expected `{}` because of this", + main_trait_predicate.skip_binder().self_ty() + ), + ); + } else if is_question_mark { + err.span_label(ret_span, format!("required `{main_trait_predicate}` because of this")); + } } if tcx.is_lang_item(leaf_trait_predicate.def_id(), LangItem::Tuple) { @@ -302,10 +327,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { // If it has a custom `#[rustc_on_unimplemented]` // error message, let's display it as the label! err.span_label(span, s); - if !matches!(leaf_trait_predicate.skip_binder().self_ty().kind(), ty::Param(_)) { + if !matches!(leaf_trait_predicate.skip_binder().self_ty().kind(), ty::Param(_)) // When the self type is a type param We don't need to "the trait // `std::marker::Sized` is not implemented for `T`" as we will point // at the type param with a label to suggest constraining it. + && !self.tcx.is_diagnostic_item(sym::FromResidual, leaf_trait_predicate.def_id()) + // Don't say "the trait `FromResidual<Option<Infallible>>` is + // not implemented for `Result<T, E>`". + { err.help(explanation); } } else if let Some(custom_explanation) = safe_transmute_explanation { @@ -932,16 +961,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let Some(typeck) = &self.typeck_results else { return false; }; - let Some((ObligationCauseCode::QuestionMark, Some(y))) = - obligation.cause.code().parent_with_predicate() - else { + let ObligationCauseCode::QuestionMark = obligation.cause.code().peel_derives() else { return false; }; - if !self.tcx.is_diagnostic_item(sym::FromResidual, y.def_id()) { - return false; - } let self_ty = trait_pred.skip_binder().self_ty(); let found_ty = trait_pred.skip_binder().trait_ref.args.get(1).and_then(|a| a.as_type()); + self.note_missing_impl_for_question_mark(err, self_ty, found_ty, trait_pred); let mut prev_ty = self.resolve_vars_if_possible( typeck.expr_ty_adjusted_opt(expr).unwrap_or(Ty::new_misc_error(self.tcx)), @@ -1106,6 +1131,56 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { suggested } + fn note_missing_impl_for_question_mark( + &self, + err: &mut Diag<'_>, + self_ty: Ty<'_>, + found_ty: Option<Ty<'_>>, + trait_pred: ty::PolyTraitPredicate<'tcx>, + ) { + match (self_ty.kind(), found_ty) { + (ty::Adt(def, _), Some(ty)) + if let ty::Adt(found, _) = ty.kind() + && def.did().is_local() + && found.did().is_local() => + { + err.span_note( + self.tcx.def_span(def.did()), + format!("`{self_ty}` needs to implement `From<{ty}>`"), + ); + err.span_note( + self.tcx.def_span(found.did()), + format!("alternatively, `{ty}` needs to implement `Into<{self_ty}>`"), + ); + } + (ty::Adt(def, _), None) if def.did().is_local() => { + err.span_note( + self.tcx.def_span(def.did()), + format!( + "`{self_ty}` needs to implement `{}`", + trait_pred.skip_binder().trait_ref.print_only_trait_path(), + ), + ); + } + (ty::Adt(def, _), Some(ty)) if def.did().is_local() => { + err.span_note( + self.tcx.def_span(def.did()), + format!("`{self_ty}` needs to implement `From<{ty}>`"), + ); + } + (_, Some(ty)) + if let ty::Adt(def, _) = ty.kind() + && def.did().is_local() => + { + err.span_note( + self.tcx.def_span(def.did()), + format!("`{ty}` needs to implement `Into<{self_ty}>`"), + ); + } + _ => {} + } + } + fn report_const_param_not_wf( &self, ty: Ty<'tcx>, @@ -2035,6 +2110,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { return false; } if let &[cand] = &candidates[..] { + if self.tcx.is_diagnostic_item(sym::FromResidual, cand.def_id) + && !self.tcx.features().enabled(sym::try_trait_v2) + { + return false; + } let (desc, mention_castable) = match (cand.self_ty().kind(), trait_pred.self_ty().skip_binder().kind()) { (ty::FnPtr(..), ty::FnDef(..)) => { @@ -2357,7 +2437,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { obligated_types: &mut Vec<Ty<'tcx>>, cause_code: &ObligationCauseCode<'tcx>, ) -> bool { - if let ObligationCauseCode::BuiltinDerived(ref data) = cause_code { + if let ObligationCauseCode::BuiltinDerived(data) = cause_code { let parent_trait_ref = self.resolve_vars_if_possible(data.parent_trait_pred); let self_ty = parent_trait_ref.skip_binder().self_ty(); if obligated_types.iter().any(|ot| ot == &self_ty) { diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs index 22d219cd64d..4d87a93be0c 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs @@ -587,7 +587,7 @@ fn attempt_dyn_to_impl_suggestion(tcx: TyCtxt<'_>, hir_id: Option<hir::HirId>, e // `type Alias = Box<dyn DynIncompatibleTrait>;` to // `type Alias = Box<impl DynIncompatibleTrait>;` let Some((_id, first_non_type_parent_node)) = - tcx.hir().parent_iter(hir_id).find(|(_id, node)| !matches!(node, hir::Node::Ty(_))) + tcx.hir_parent_iter(hir_id).find(|(_id, node)| !matches!(node, hir::Node::Ty(_))) else { return; }; diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index ee0ab0dfbb8..c7e71a626dc 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -974,7 +974,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { hir::ExprKind::MethodCall( hir::PathSegment { ident, .. }, _receiver, - &[], + [], call_span, ), hir_id, @@ -1552,7 +1552,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { obligation: &PredicateObligation<'tcx>, err: &mut Diag<'_>, ) { - let hir = self.tcx.hir(); if let ObligationCauseCode::AwaitableExpr(hir_id) = obligation.cause.code().peel_derives() && let hir::Node::Expr(expr) = self.tcx.hir_node(*hir_id) { @@ -1562,7 +1561,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { // it is from the local crate. // use nth(1) to skip one layer of desugaring from `IntoIter::into_iter` - if let Some((_, hir::Node::Expr(await_expr))) = hir.parent_iter(*hir_id).nth(1) + if let Some((_, hir::Node::Expr(await_expr))) = self.tcx.hir_parent_iter(*hir_id).nth(1) && let Some(expr_span) = expr.span.find_ancestor_inside_same_ctxt(await_expr.span) { let removal_span = self @@ -2681,7 +2680,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { | ObligationCauseCode::IntrinsicType | ObligationCauseCode::MethodReceiver | ObligationCauseCode::ReturnNoExpression - | ObligationCauseCode::UnifyReceiver(..) | ObligationCauseCode::Misc | ObligationCauseCode::WellFormed(..) | ObligationCauseCode::MatchImpl(..) @@ -4118,8 +4116,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let ty::Param(..) = ty.kind() else { continue; }; - let hir = tcx.hir(); - let node = tcx.hir_node_by_def_id(hir.get_parent_item(expr.hir_id).def_id); + let node = + tcx.hir_node_by_def_id(tcx.hir_get_parent_item(expr.hir_id).def_id); let pred = ty::Binder::dummy(ty::TraitPredicate { trait_ref: ty::TraitRef::new( diff --git a/compiler/rustc_trait_selection/src/errors.rs b/compiler/rustc_trait_selection/src/errors.rs index ac4399750f5..23aa3800660 100644 --- a/compiler/rustc_trait_selection/src/errors.rs +++ b/compiler/rustc_trait_selection/src/errors.rs @@ -509,21 +509,18 @@ impl Subdiagnostic for AddLifetimeParamsSuggestion<'_> { let node = self.tcx.hir_node_by_def_id(anon_reg.scope); let is_impl = matches!(&node, hir::Node::ImplItem(_)); let (generics, parent_generics) = match node { - hir::Node::Item(&hir::Item { - kind: hir::ItemKind::Fn { ref generics, .. }, - .. - }) - | hir::Node::TraitItem(&hir::TraitItem { ref generics, .. }) - | hir::Node::ImplItem(&hir::ImplItem { ref generics, .. }) => ( + hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn { generics, .. }, .. }) + | hir::Node::TraitItem(hir::TraitItem { generics, .. }) + | hir::Node::ImplItem(hir::ImplItem { generics, .. }) => ( generics, match self.tcx.parent_hir_node(self.tcx.local_def_id_to_hir_id(anon_reg.scope)) { hir::Node::Item(hir::Item { - kind: hir::ItemKind::Trait(_, _, ref generics, ..), + kind: hir::ItemKind::Trait(_, _, generics, ..), .. }) | hir::Node::Item(hir::Item { - kind: hir::ItemKind::Impl(hir::Impl { ref generics, .. }), + kind: hir::ItemKind::Impl(hir::Impl { generics, .. }), .. }) => Some(generics), _ => None, @@ -1119,22 +1116,6 @@ impl Subdiagnostic for ReqIntroducedLocations { } } -pub struct MoreTargeted { - pub ident: Symbol, -} - -impl Subdiagnostic for MoreTargeted { - fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>( - self, - diag: &mut Diag<'_, G>, - _f: &F, - ) { - diag.code(E0772); - diag.primary_message(fluent::trait_selection_more_targeted); - diag.arg("ident", self.ident); - } -} - #[derive(Diagnostic)] #[diag(trait_selection_but_needs_to_satisfy, code = E0759)] pub struct ButNeedsToSatisfy { @@ -1151,9 +1132,6 @@ pub struct ButNeedsToSatisfy { #[note(trait_selection_introduced_by_bound)] pub bound: Option<Span>, - #[subdiagnostic] - pub req_introduces_loc: Option<ReqIntroducedLocations>, - pub has_param_name: bool, pub param_name: String, pub spans_empty: bool, @@ -1880,8 +1858,7 @@ pub fn impl_trait_overcapture_suggestion<'tcx>( let opaque_hir_id = tcx.local_def_id_to_hir_id(opaque_def_id); // FIXME: This is a bit too conservative, since it ignores parens already written in AST. let (lparen, rparen) = match tcx - .hir() - .parent_iter(opaque_hir_id) + .hir_parent_iter(opaque_hir_id) .nth(1) .expect("expected ty to have a parent always") .1 diff --git a/compiler/rustc_trait_selection/src/solve/fulfill.rs b/compiler/rustc_trait_selection/src/solve/fulfill.rs index c238e708ab8..51d560d4c43 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill.rs @@ -67,7 +67,9 @@ impl<'tcx> ObligationStorage<'tcx> { obligations } - fn unstalled_for_select(&mut self) -> impl Iterator<Item = PredicateObligation<'tcx>> { + fn unstalled_for_select( + &mut self, + ) -> impl Iterator<Item = PredicateObligation<'tcx>> + use<'tcx> { mem::take(&mut self.pending).into_iter() } diff --git a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs index efe2386d014..740f44ebcad 100644 --- a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs +++ b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs @@ -698,11 +698,11 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for IllegalSelfTypeVisitor<'tcx> { ControlFlow::Continue(()) } } - ty::Alias(ty::Projection, ref data) if self.tcx.is_impl_trait_in_trait(data.def_id) => { + ty::Alias(ty::Projection, data) if self.tcx.is_impl_trait_in_trait(data.def_id) => { // We'll deny these later in their own pass ControlFlow::Continue(()) } - ty::Alias(ty::Projection, ref data) => { + ty::Alias(ty::Projection, data) => { match self.allow_self_projections { AllowSelfProjections::Yes => { // This is a projected type `<Foo as SomeTrait>::X`. diff --git a/compiler/rustc_traits/Cargo.toml b/compiler/rustc_traits/Cargo.toml index 9c788116d98..04aef4e7b9e 100644 --- a/compiler/rustc_traits/Cargo.toml +++ b/compiler/rustc_traits/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_traits" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_traits/src/codegen.rs b/compiler/rustc_traits/src/codegen.rs index e5276e6d515..cc329ca3328 100644 --- a/compiler/rustc_traits/src/codegen.rs +++ b/compiler/rustc_traits/src/codegen.rs @@ -80,16 +80,14 @@ pub(crate) fn codegen_select_candidate<'tcx>( // but never resolved, causing the return value of a query to contain inference // vars. We do not have a concept for this and will in fact ICE in stable hashing // of the return value. So bail out instead. - match impl_source { - ImplSource::UserDefined(impl_) => { - tcx.dcx().span_delayed_bug( - tcx.def_span(impl_.impl_def_id), - "this impl has unconstrained generic parameters", - ); - } + let guar = match impl_source { + ImplSource::UserDefined(impl_) => tcx.dcx().span_delayed_bug( + tcx.def_span(impl_.impl_def_id), + "this impl has unconstrained generic parameters", + ), _ => unreachable!(), - } - return Err(CodegenObligationError::FulfillmentError); + }; + return Err(CodegenObligationError::UnconstrainedParam(guar)); } Ok(&*tcx.arena.alloc(impl_source)) diff --git a/compiler/rustc_transmute/Cargo.toml b/compiler/rustc_transmute/Cargo.toml index 94c7695117c..e9daf6b0c38 100644 --- a/compiler/rustc_transmute/Cargo.toml +++ b/compiler/rustc_transmute/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_transmute" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_ty_utils/Cargo.toml b/compiler/rustc_ty_utils/Cargo.toml index ab903c6ed73..4c7a57f2931 100644 --- a/compiler/rustc_ty_utils/Cargo.toml +++ b/compiler/rustc_ty_utils/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_ty_utils" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index c5d2d0afbfa..0ff82f0c256 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -464,7 +464,7 @@ fn fn_abi_sanity_check<'tcx>( match &arg.mode { PassMode::Ignore => { - assert!(arg.layout.is_zst() || arg.layout.is_uninhabited()); + assert!(arg.layout.is_zst()); } PassMode::Direct(_) => { // Here the Rust type is used to determine the actual ABI, so we have to be very @@ -472,9 +472,7 @@ fn fn_abi_sanity_check<'tcx>( // `layout.backend_repr` and ignore everything else. We should just reject //`Aggregate` entirely here, but some targets need to be fixed first. match arg.layout.backend_repr { - BackendRepr::Uninhabited - | BackendRepr::Scalar(_) - | BackendRepr::Vector { .. } => {} + BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => {} BackendRepr::ScalarPair(..) => { panic!("`PassMode::Direct` used for ScalarPair type {}", arg.layout.ty) } diff --git a/compiler/rustc_ty_utils/src/assoc.rs b/compiler/rustc_ty_utils/src/assoc.rs index f71b924b177..c8034f4e7b9 100644 --- a/compiler/rustc_ty_utils/src/assoc.rs +++ b/compiler/rustc_ty_utils/src/assoc.rs @@ -95,7 +95,7 @@ fn impl_item_implementor_ids(tcx: TyCtxt<'_>, impl_id: DefId) -> DefIdMap<DefId> fn associated_item(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::AssocItem { let id = tcx.local_def_id_to_hir_id(def_id); - let parent_def_id = tcx.hir().get_parent_item(id); + let parent_def_id = tcx.hir_get_parent_item(id); let parent_item = tcx.hir().expect_item(parent_def_id.def_id); match parent_item.kind { hir::ItemKind::Impl(impl_) => { diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index 8c6e3c86bf5..d059d6dcd13 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -112,6 +112,7 @@ fn resolve_associated_item<'tcx>( | CodegenObligationError::Unimplemented | CodegenObligationError::FulfillmentError, ) => return Ok(None), + Err(CodegenObligationError::UnconstrainedParam(guar)) => return Err(guar), }; // Now that we know which impl is being used, we can dispatch to diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index 556512e0236..c8b3c8a796f 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -147,12 +147,25 @@ fn extract_const_value<'tcx>( ) -> Result<ty::Value<'tcx>, &'tcx LayoutError<'tcx>> { match ct.kind() { ty::ConstKind::Value(cv) => Ok(cv), - ty::ConstKind::Param(_) | ty::ConstKind::Expr(_) | ty::ConstKind::Unevaluated(_) => { + ty::ConstKind::Param(_) | ty::ConstKind::Expr(_) => { if !ct.has_param() { bug!("failed to normalize const, but it is not generic: {ct:?}"); } Err(error(cx, LayoutError::TooGeneric(ty))) } + ty::ConstKind::Unevaluated(_) => { + let err = if ct.has_param() { + LayoutError::TooGeneric(ty) + } else { + // This case is reachable with unsatisfiable predicates and GCE (which will + // cause anon consts to inherit the unsatisfiable predicates). For example + // if we have an unsatisfiable `u8: Trait` bound, then it's not a compile + // error to mention `[u8; <u8 as Trait>::CONST]`, but we can't compute its + // layout. + LayoutError::Unknown(ty) + }; + Err(error(cx, err)) + } ty::ConstKind::Infer(_) | ty::ConstKind::Bound(..) | ty::ConstKind::Placeholder(_) @@ -348,19 +361,17 @@ fn layout_of_uncached<'tcx>( .checked_mul(count, dl) .ok_or_else(|| error(cx, LayoutError::SizeOverflow(ty)))?; - let abi = if count != 0 && ty.is_privately_uninhabited(tcx, cx.typing_env) { - BackendRepr::Uninhabited - } else { - BackendRepr::Memory { sized: true } - }; + let abi = BackendRepr::Memory { sized: true }; let largest_niche = if count != 0 { element.largest_niche } else { None }; + let uninhabited = if count != 0 { element.uninhabited } else { false }; tcx.mk_layout(LayoutData { variants: Variants::Single { index: FIRST_VARIANT }, fields: FieldsShape::Array { stride: element.size, count }, backend_repr: abi, largest_niche, + uninhabited, align: element.align, size, max_repr_align: None, @@ -375,6 +386,7 @@ fn layout_of_uncached<'tcx>( fields: FieldsShape::Array { stride: element.size, count: 0 }, backend_repr: BackendRepr::Memory { sized: false }, largest_niche: None, + uninhabited: false, align: element.align, size: Size::ZERO, max_repr_align: None, @@ -390,6 +402,7 @@ fn layout_of_uncached<'tcx>( fields: FieldsShape::Array { stride: Size::from_bytes(1), count: 0 }, backend_repr: BackendRepr::Memory { sized: false }, largest_niche: None, + uninhabited: false, align: dl.i8_align, size: Size::ZERO, max_repr_align: None, @@ -555,6 +568,7 @@ fn layout_of_uncached<'tcx>( fields, backend_repr: abi, largest_niche: e_ly.largest_niche, + uninhabited: false, size, align, max_repr_align: None, @@ -1014,13 +1028,8 @@ fn coroutine_layout<'tcx>( size = size.align_to(align.abi); - let abi = if prefix.backend_repr.is_uninhabited() - || variants.iter().all(|v| v.backend_repr.is_uninhabited()) - { - BackendRepr::Uninhabited - } else { - BackendRepr::Memory { sized: true } - }; + let uninhabited = prefix.uninhabited || variants.iter().all(|v| v.is_uninhabited()); + let abi = BackendRepr::Memory { sized: true }; // this is similar to how ReprOptions populates its field_shuffle_seed let def_hash = tcx.def_path_hash(def_id).0.to_smaller_hash(); @@ -1041,6 +1050,7 @@ fn coroutine_layout<'tcx>( // See <https://github.com/rust-lang/rust/issues/63818>, <https://github.com/rust-lang/miri/issues/3780>. // FIXME: Remove when <https://github.com/rust-lang/rust/issues/125735> is implemented and aliased coroutine fields are wrapped in `UnsafePinned`. largest_niche: None, + uninhabited, size, align, max_repr_align: None, diff --git a/compiler/rustc_ty_utils/src/layout/invariant.rs b/compiler/rustc_ty_utils/src/layout/invariant.rs index 8d5403ed324..5ea6716c5ca 100644 --- a/compiler/rustc_ty_utils/src/layout/invariant.rs +++ b/compiler/rustc_ty_utils/src/layout/invariant.rs @@ -10,7 +10,11 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou // Type-level uninhabitedness should always imply ABI uninhabitedness. if layout.ty.is_privately_uninhabited(tcx, cx.typing_env) { - assert!(layout.is_uninhabited()); + assert!( + layout.is_uninhabited(), + "{:?} is type-level uninhabited but not ABI-uninhabited?", + layout.ty + ); } if layout.size.bytes() % layout.align.abi.bytes() != 0 { @@ -71,7 +75,7 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou let Some((align, size)) = align.zip(size) else { assert_matches!( layout.layout.backend_repr(), - BackendRepr::Uninhabited | BackendRepr::Memory { .. }, + BackendRepr::Memory { .. }, "ABI unexpectedly missing alignment and/or size in {layout:#?}" ); return; @@ -235,7 +239,7 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou assert!(align >= element.align(cx).abi); // just sanity-checking `vector_align`. // FIXME: Do some kind of check of the inner type, like for Scalar and ScalarPair. } - BackendRepr::Uninhabited | BackendRepr::Memory { .. } => {} // Nothing to check. + BackendRepr::Memory { .. } => {} // Nothing to check. } } @@ -291,8 +295,8 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou || variant.is_uninhabited() { // These are never actually accessed anyway, so we can skip the coherence check - // for them. They also fail that check, since they have - // `Aggregate`/`Uninhabited` ABI even when the main type is + // for them. They also fail that check, since they may have + // a different ABI even when the main type is // `Scalar`/`ScalarPair`. (Note that sometimes, variants with fields have size // 0, and sometimes, variants without fields have non-0 size.) continue; @@ -306,7 +310,6 @@ pub(super) fn layout_sanity_check<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLayou (BackendRepr::ScalarPair(a1, b1), BackendRepr::ScalarPair(a2, b2)) => { scalar_coherent(a1, a2) && scalar_coherent(b1, b2) } - (BackendRepr::Uninhabited, _) => true, (BackendRepr::Memory { .. }, _) => true, _ => false, }; diff --git a/compiler/rustc_ty_utils/src/opaque_types.rs b/compiler/rustc_ty_utils/src/opaque_types.rs index 7ce72c76e5c..98881905bcf 100644 --- a/compiler/rustc_ty_utils/src/opaque_types.rs +++ b/compiler/rustc_ty_utils/src/opaque_types.rs @@ -98,10 +98,10 @@ impl<'tcx> OpaqueTypeCollector<'tcx> { let opaque_hir_id = self.tcx.local_def_id_to_hir_id(opaque_def_id); // Named opaque types can be defined by any siblings or children of siblings. - let scope = self.tcx.hir().get_defining_scope(opaque_hir_id); + let scope = self.tcx.hir_get_defining_scope(opaque_hir_id); // We walk up the node tree until we hit the root or the scope of the opaque type. while hir_id != scope && hir_id != CRATE_HIR_ID { - hir_id = self.tcx.hir().get_parent_item(hir_id).into(); + hir_id = self.tcx.hir_get_parent_item(hir_id).into(); } // Syntactically, we are allowed to define the concrete type if: hir_id == scope diff --git a/compiler/rustc_type_ir/Cargo.toml b/compiler/rustc_type_ir/Cargo.toml index 8d97ec72830..d8184da927c 100644 --- a/compiler/rustc_type_ir/Cargo.toml +++ b/compiler/rustc_type_ir/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_type_ir" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_type_ir/src/elaborate.rs b/compiler/rustc_type_ir/src/elaborate.rs index 923b74abdfd..b11bcff1d8b 100644 --- a/compiler/rustc_type_ir/src/elaborate.rs +++ b/compiler/rustc_type_ir/src/elaborate.rs @@ -44,25 +44,22 @@ pub trait Elaboratable<I: Interner> { } pub struct ClauseWithSupertraitSpan<I: Interner> { - pub pred: I::Predicate, + pub clause: I::Clause, // Span of the supertrait predicatae that lead to this clause. pub supertrait_span: I::Span, } impl<I: Interner> ClauseWithSupertraitSpan<I> { - pub fn new(pred: I::Predicate, span: I::Span) -> Self { - ClauseWithSupertraitSpan { pred, supertrait_span: span } + pub fn new(clause: I::Clause, span: I::Span) -> Self { + ClauseWithSupertraitSpan { clause, supertrait_span: span } } } impl<I: Interner> Elaboratable<I> for ClauseWithSupertraitSpan<I> { fn predicate(&self) -> <I as Interner>::Predicate { - self.pred + self.clause.as_predicate() } fn child(&self, clause: <I as Interner>::Clause) -> Self { - ClauseWithSupertraitSpan { - pred: clause.as_predicate(), - supertrait_span: self.supertrait_span, - } + ClauseWithSupertraitSpan { clause, supertrait_span: self.supertrait_span } } fn child_with_derived_cause( @@ -72,7 +69,7 @@ impl<I: Interner> Elaboratable<I> for ClauseWithSupertraitSpan<I> { _parent_trait_pred: crate::Binder<I, crate::TraitPredicate<I>>, _index: usize, ) -> Self { - ClauseWithSupertraitSpan { pred: clause.as_predicate(), supertrait_span } + ClauseWithSupertraitSpan { clause, supertrait_span } } } diff --git a/compiler/rustc_type_ir_macros/Cargo.toml b/compiler/rustc_type_ir_macros/Cargo.toml index cb95ca68346..15a55575099 100644 --- a/compiler/rustc_type_ir_macros/Cargo.toml +++ b/compiler/rustc_type_ir_macros/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_type_ir_macros" version = "0.0.0" -edition = "2021" +edition = "2024" [lib] proc-macro = true diff --git a/compiler/stable_mir/Cargo.toml b/compiler/stable_mir/Cargo.toml index 2edb3f140d7..d691a0e4f22 100644 --- a/compiler/stable_mir/Cargo.toml +++ b/compiler/stable_mir/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "stable_mir" version = "0.1.0-preview" -edition = "2021" +edition = "2024" [dependencies] scoped-tls = "1.0" diff --git a/compiler/stable_mir/src/abi.rs b/compiler/stable_mir/src/abi.rs index 861b6692b53..091f3e1a95e 100644 --- a/compiler/stable_mir/src/abi.rs +++ b/compiler/stable_mir/src/abi.rs @@ -227,7 +227,6 @@ pub enum TagEncoding { /// in terms of categories of C types there are ABI rules for. #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)] pub enum ValueAbi { - Uninhabited, Scalar(Scalar), ScalarPair(Scalar, Scalar), Vector { @@ -244,10 +243,7 @@ impl ValueAbi { /// Returns `true` if the layout corresponds to an unsized type. pub fn is_unsized(&self) -> bool { match *self { - ValueAbi::Uninhabited - | ValueAbi::Scalar(_) - | ValueAbi::ScalarPair(..) - | ValueAbi::Vector { .. } => false, + ValueAbi::Scalar(_) | ValueAbi::ScalarPair(..) | ValueAbi::Vector { .. } => false, ValueAbi::Aggregate { sized } => !sized, } } diff --git a/config.example.toml b/config.example.toml index fd27b24e461..a17d3ec9f88 100644 --- a/config.example.toml +++ b/config.example.toml @@ -793,12 +793,12 @@ # C compiler to be used to compile C code. Note that the # default value is platform specific, and if not specified it may also depend on # what platform is crossing to what platform. -# See `src/bootstrap/cc_detect.rs` for details. +# See `src/bootstrap/src/utils/cc_detect.rs` for details. #cc = "cc" (path) # C++ compiler to be used to compile C++ code (e.g. LLVM and our LLVM shims). # This is only used for host targets. -# See `src/bootstrap/cc_detect.rs` for details. +# See `src/bootstrap/src/utils/cc_detect.rs` for details. #cxx = "c++" (path) # Archiver to be used to assemble static libraries compiled from C/C++ code. diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 4b124b5a3b3..5a3c1b74dad 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -1689,7 +1689,20 @@ impl<T: Default> Default for Box<T> { /// Creates a `Box<T>`, with the `Default` value for T. #[inline] fn default() -> Self { - Box::write(Box::new_uninit(), T::default()) + let mut x: Box<mem::MaybeUninit<T>> = Box::new_uninit(); + unsafe { + // SAFETY: `x` is valid for writing and has the same layout as `T`. + // If `T::default()` panics, dropping `x` will just deallocate the Box as `MaybeUninit<T>` + // does not have a destructor. + // + // We use `ptr::write` as `MaybeUninit::write` creates + // extra stack copies of `T` in debug mode. + // + // See https://github.com/rust-lang/rust/issues/136043 for more context. + ptr::write(&raw mut *x as *mut T, T::default()); + // SAFETY: `x` was just initialized above. + x.assume_init() + } } } diff --git a/library/core/Cargo.toml b/library/core/Cargo.toml index b7c6db6c78d..e49d978a367 100644 --- a/library/core/Cargo.toml +++ b/library/core/Cargo.toml @@ -23,6 +23,8 @@ optimize_for_size = [] # Make `RefCell` store additional debugging information, which is printed out when # a borrow error occurs debug_refcell = [] +# Make `TypeId` store a reference to the name of the type, so that it can print that name. +debug_typeid = [] [lints.rust.unexpected_cfgs] level = "warn" diff --git a/library/core/src/any.rs b/library/core/src/any.rs index f90de1f5ced..9ed2c8e9f3a 100644 --- a/library/core/src/any.rs +++ b/library/core/src/any.rs @@ -711,6 +711,8 @@ pub struct TypeId { // We avoid using `u128` because that imposes higher alignment requirements on many platforms. // See issue #115620 for more information. t: (u64, u64), + #[cfg(feature = "debug_typeid")] + name: &'static str, } #[stable(feature = "rust1", since = "1.0.0")] @@ -741,10 +743,14 @@ impl TypeId { #[rustc_const_unstable(feature = "const_type_id", issue = "77125")] pub const fn of<T: ?Sized + 'static>() -> TypeId { let t: u128 = intrinsics::type_id::<T>(); - let t1 = (t >> 64) as u64; let t2 = t as u64; - TypeId { t: (t1, t2) } + + TypeId { + t: (t1, t2), + #[cfg(feature = "debug_typeid")] + name: type_name::<T>(), + } } fn as_u128(self) -> u128 { @@ -775,7 +781,15 @@ impl hash::Hash for TypeId { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for TypeId { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { - write!(f, "TypeId({:#034x})", self.as_u128()) + #[cfg(feature = "debug_typeid")] + { + write!(f, "TypeId({:#034x} = {})", self.as_u128(), self.name)?; + } + #[cfg(not(feature = "debug_typeid"))] + { + write!(f, "TypeId({:#034x})", self.as_u128())?; + } + Ok(()) } } diff --git a/library/core/src/net/ip_addr.rs b/library/core/src/net/ip_addr.rs index b11ba056853..8e4417ec461 100644 --- a/library/core/src/net/ip_addr.rs +++ b/library/core/src/net/ip_addr.rs @@ -451,6 +451,28 @@ impl IpAddr { IpAddr::V6(v6) => v6.to_canonical(), } } + + /// Returns the eight-bit integers this address consists of as a slice. + /// + /// # Examples + /// + /// ``` + /// #![feature(ip_as_octets)] + /// + /// use std::net::{Ipv4Addr, Ipv6Addr, IpAddr}; + /// + /// assert_eq!(IpAddr::V4(Ipv4Addr::LOCALHOST).as_octets(), &[127, 0, 0, 1]); + /// assert_eq!(IpAddr::V6(Ipv6Addr::LOCALHOST).as_octets(), + /// &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) + /// ``` + #[unstable(feature = "ip_as_octets", issue = "137259")] + #[inline] + pub const fn as_octets(&self) -> &[u8] { + match self { + IpAddr::V4(ip) => ip.as_octets().as_slice(), + IpAddr::V6(ip) => ip.as_octets().as_slice(), + } + } } impl Ipv4Addr { @@ -616,6 +638,25 @@ impl Ipv4Addr { Ipv4Addr { octets } } + /// Returns the four eight-bit integers that make up this address + /// as a slice. + /// + /// # Examples + /// + /// ``` + /// #![feature(ip_as_octets)] + /// + /// use std::net::Ipv4Addr; + /// + /// let addr = Ipv4Addr::new(127, 0, 0, 1); + /// assert_eq!(addr.as_octets(), &[127, 0, 0, 1]); + /// ``` + #[unstable(feature = "ip_as_octets", issue = "137259")] + #[inline] + pub const fn as_octets(&self) -> &[u8; 4] { + &self.octets + } + /// Returns [`true`] for the special 'unspecified' address (`0.0.0.0`). /// /// This property is defined in _UNIX Network Programming, Second Edition_, @@ -2001,6 +2042,25 @@ impl Ipv6Addr { pub const fn from_octets(octets: [u8; 16]) -> Ipv6Addr { Ipv6Addr { octets } } + + /// Returns the sixteen eight-bit integers the IPv6 address consists of + /// as a slice. + /// + /// # Examples + /// + /// ``` + /// #![feature(ip_as_octets)] + /// + /// use std::net::Ipv6Addr; + /// + /// assert_eq!(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0).as_octets(), + /// &[255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) + /// ``` + #[unstable(feature = "ip_as_octets", issue = "137259")] + #[inline] + pub const fn as_octets(&self) -> &[u8; 16] { + &self.octets + } } /// Writes an Ipv6Addr, conforming to the canonical style described by diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index 296b5ebdfaf..74221e21687 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -183,6 +183,52 @@ macro_rules! int_impl { (self as $UnsignedT).trailing_ones() } + /// Returns `self` with only the most significant bit set, or `0` if + /// the input is `0`. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// #![feature(isolate_most_least_significant_one)] + /// + #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] + /// + /// assert_eq!(n.isolate_most_significant_one(), 0b_01000000); + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_most_significant_one(), 0);")] + /// ``` + #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn isolate_most_significant_one(self) -> Self { + self & (((1 as $SelfT) << (<$SelfT>::BITS - 1)).wrapping_shr(self.leading_zeros())) + } + + /// Returns `self` with only the least significant bit set, or `0` if + /// the input is `0`. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// #![feature(isolate_most_least_significant_one)] + /// + #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] + /// + /// assert_eq!(n.isolate_least_significant_one(), 0b_00000100); + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_least_significant_one(), 0);")] + /// ``` + #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn isolate_least_significant_one(self) -> Self { + self & self.wrapping_neg() + } + /// Returns the bit pattern of `self` reinterpreted as an unsigned integer of the same size. /// /// This produces the same result as an `as` cast, but ensures that the bit-width remains diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index 55f4ccd958e..80a38a6013d 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs @@ -163,14 +163,14 @@ macro_rules! midpoint_impl { /// # Examples /// /// ``` - /// #![feature(num_midpoint_signed)] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(4), 2);")] #[doc = concat!("assert_eq!((-1", stringify!($SelfT), ").midpoint(2), 0);")] #[doc = concat!("assert_eq!((-7", stringify!($SelfT), ").midpoint(0), -3);")] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(-7), -3);")] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(7), 3);")] /// ``` - #[unstable(feature = "num_midpoint_signed", issue = "110840")] + #[stable(feature = "num_midpoint_signed", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "num_midpoint_signed", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -215,14 +215,14 @@ macro_rules! midpoint_impl { /// # Examples /// /// ``` - /// #![feature(num_midpoint_signed)] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(4), 2);")] #[doc = concat!("assert_eq!((-1", stringify!($SelfT), ").midpoint(2), 0);")] #[doc = concat!("assert_eq!((-7", stringify!($SelfT), ").midpoint(0), -3);")] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(-7), -3);")] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(7), 3);")] /// ``` - #[unstable(feature = "num_midpoint_signed", issue = "110840")] + #[stable(feature = "num_midpoint_signed", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "num_midpoint_signed", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index b59451d7c75..b94b492e8e1 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -605,6 +605,70 @@ macro_rules! nonzero_integer { } } + /// Returns `self` with only the most significant bit set. + /// + /// # Example + /// + /// Basic usage: + /// + /// ``` + /// #![feature(isolate_most_least_significant_one)] + /// + /// # use core::num::NonZero; + /// # fn main() { test().unwrap(); } + /// # fn test() -> Option<()> { + #[doc = concat!("let a = NonZero::<", stringify!($Int), ">::new(0b_01100100)?;")] + #[doc = concat!("let b = NonZero::<", stringify!($Int), ">::new(0b_01000000)?;")] + /// + /// assert_eq!(a.isolate_most_significant_one(), b); + /// # Some(()) + /// # } + /// ``` + #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn isolate_most_significant_one(self) -> Self { + let n = self.get() & (((1 as $Int) << (<$Int>::BITS - 1)).wrapping_shr(self.leading_zeros())); + + // SAFETY: + // `self` is non-zero, so masking to preserve only the most + // significant set bit will result in a non-zero `n`. + unsafe { NonZero::new_unchecked(n) } + } + + /// Returns `self` with only the least significant bit set. + /// + /// # Example + /// + /// Basic usage: + /// + /// ``` + /// #![feature(isolate_most_least_significant_one)] + /// + /// # use core::num::NonZero; + /// # fn main() { test().unwrap(); } + /// # fn test() -> Option<()> { + #[doc = concat!("let a = NonZero::<", stringify!($Int), ">::new(0b_01100100)?;")] + #[doc = concat!("let b = NonZero::<", stringify!($Int), ">::new(0b_00000100)?;")] + /// + /// assert_eq!(a.isolate_least_significant_one(), b); + /// # Some(()) + /// # } + /// ``` + #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn isolate_least_significant_one(self) -> Self { + let n = self.get(); + let n = n & n.wrapping_neg(); + + // SAFETY: `self` is non-zero, so `self` with only its least + // significant set bit will remain non-zero. + unsafe { NonZero::new_unchecked(n) } + } + /// Returns the number of ones in the binary representation of `self`. /// /// # Examples diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index 74d3ae699f6..289bc48acde 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -213,6 +213,52 @@ macro_rules! uint_impl { (!self).trailing_zeros() } + /// Returns `self` with only the most significant bit set, or `0` if + /// the input is `0`. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// #![feature(isolate_most_least_significant_one)] + /// + #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] + /// + /// assert_eq!(n.isolate_most_significant_one(), 0b_01000000); + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_most_significant_one(), 0);")] + /// ``` + #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn isolate_most_significant_one(self) -> Self { + self & (((1 as $SelfT) << (<$SelfT>::BITS - 1)).wrapping_shr(self.leading_zeros())) + } + + /// Returns `self` with only the least significant bit set, or `0` if + /// the input is `0`. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// #![feature(isolate_most_least_significant_one)] + /// + #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] + /// + /// assert_eq!(n.isolate_least_significant_one(), 0b_00000100); + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_least_significant_one(), 0);")] + /// ``` + #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn isolate_least_significant_one(self) -> Self { + self & self.wrapping_neg() + } + /// Returns the bit pattern of `self` reinterpreted as a signed integer of the same size. /// /// This produces the same result as an `as` cast, but ensures that the bit-width remains diff --git a/library/core/src/slice/iter/macros.rs b/library/core/src/slice/iter/macros.rs index 45e320e66bc..b1456a1bc1d 100644 --- a/library/core/src/slice/iter/macros.rs +++ b/library/core/src/slice/iter/macros.rs @@ -154,16 +154,39 @@ macro_rules! iterator { #[inline] fn next(&mut self) -> Option<$elem> { - // could be implemented with slices, but this avoids bounds checks + // intentionally not using the helpers because this is + // one of the most mono'd things in the library. - // SAFETY: The call to `next_unchecked` is - // safe since we check if the iterator is empty first. + let ptr = self.ptr; + let end_or_len = self.end_or_len; + // SAFETY: See inner comments. (For some reason having multiple + // block breaks inlining this -- if you can fix that please do!) unsafe { - if is_empty!(self) { - None + if T::IS_ZST { + let len = end_or_len.addr(); + if len == 0 { + return None; + } + // SAFETY: just checked that it's not zero, so subtracting one + // cannot wrap. (Ideally this would be `checked_sub`, which + // does the same thing internally, but as of 2025-02 that + // doesn't optimize quite as small in MIR.) + self.end_or_len = without_provenance_mut(len.unchecked_sub(1)); } else { - Some(self.next_unchecked()) + // SAFETY: by type invariant, the `end_or_len` field is always + // non-null for a non-ZST pointee. (This transmute ensures we + // get `!nonnull` metadata on the load of the field.) + if ptr == crate::intrinsics::transmute::<$ptr, NonNull<T>>(end_or_len) { + return None; + } + // SAFETY: since it's not empty, per the check above, moving + // forward one keeps us inside the slice, and this is valid. + self.ptr = ptr.add(1); } + // SAFETY: Now that we know it wasn't empty and we've moved past + // the first one (to avoid giving a duplicate `&mut` next time), + // we can give out a reference to it. + Some({ptr}.$into_ref()) } } diff --git a/library/core/src/time.rs b/library/core/src/time.rs index 22bd46c567e..8b211b442ea 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -1168,6 +1168,7 @@ impl Div<u32> for Duration { type Output = Duration; #[inline] + #[track_caller] fn div(self, rhs: u32) -> Duration { self.checked_div(rhs).expect("divide by zero error when dividing duration by scalar") } @@ -1176,6 +1177,7 @@ impl Div<u32> for Duration { #[stable(feature = "time_augmented_assignment", since = "1.9.0")] impl DivAssign<u32> for Duration { #[inline] + #[track_caller] fn div_assign(&mut self, rhs: u32) { *self = *self / rhs; } diff --git a/library/coretests/tests/any.rs b/library/coretests/tests/any.rs index 25002617d0b..117ef004238 100644 --- a/library/coretests/tests/any.rs +++ b/library/coretests/tests/any.rs @@ -118,6 +118,14 @@ fn any_unsized() { is_any::<[i32]>(); } +#[cfg(feature = "debug_typeid")] +#[test] +fn debug_typeid_includes_name() { + let type_id = TypeId::of::<[usize; 2]>(); + let debug_str = format!("{type_id:?}"); + assert!(debug_str.ends_with("= [usize; 2])"), "{debug_str:?} did not match"); +} + #[test] fn distinct_type_names() { // https://github.com/rust-lang/rust/issues/84666 diff --git a/library/coretests/tests/lib.rs b/library/coretests/tests/lib.rs index 25c7d10e0bd..eb6a8d85a30 100644 --- a/library/coretests/tests/lib.rs +++ b/library/coretests/tests/lib.rs @@ -44,6 +44,7 @@ #![feature(ip)] #![feature(ip_from)] #![feature(is_ascii_octdigit)] +#![feature(isolate_most_least_significant_one)] #![feature(iter_advance_by)] #![feature(iter_array_chunks)] #![feature(iter_chain)] @@ -63,7 +64,6 @@ #![feature(maybe_uninit_write_slice)] #![feature(min_specialization)] #![feature(never_type)] -#![feature(num_midpoint_signed)] #![feature(numfmt)] #![feature(pattern)] #![feature(pointer_is_aligned_to)] diff --git a/library/coretests/tests/nonzero.rs b/library/coretests/tests/nonzero.rs index 43c279053d8..bdc5701d9fd 100644 --- a/library/coretests/tests/nonzero.rs +++ b/library/coretests/tests/nonzero.rs @@ -322,6 +322,106 @@ fn nonzero_trailing_zeros() { } #[test] +fn test_nonzero_isolate_most_significant_one() { + // Signed most significant one + macro_rules! nonzero_int_impl { + ($($T:ty),+) => { + $( + { + const BITS: $T = -1; + const MOST_SIG_ONE: $T = 1 << (<$T>::BITS - 1); + + // Right shift the most significant one through each + // bit position, starting with all bits set + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + NonZero::<$T>::new(BITS >> i).unwrap().isolate_most_significant_one(), + NonZero::<$T>::new(MOST_SIG_ONE >> i).unwrap().isolate_most_significant_one() + ); + i += 1; + } + } + )+ + }; + } + + // Unsigned most significant one + macro_rules! nonzero_uint_impl { + ($($T:ty),+) => { + $( + { + const BITS: $T = <$T>::MAX; + const MOST_SIG_ONE: $T = 1 << (<$T>::BITS - 1); + + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + NonZero::<$T>::new(BITS >> i).unwrap().isolate_most_significant_one(), + NonZero::<$T>::new(MOST_SIG_ONE >> i).unwrap().isolate_most_significant_one(), + ); + i += 1; + } + } + )+ + }; + } + + nonzero_int_impl!(i8, i16, i32, i64, i128, isize); + nonzero_uint_impl!(u8, u16, u32, u64, u128, usize); +} + +#[test] +fn test_nonzero_isolate_least_significant_one() { + // Signed least significant one + macro_rules! nonzero_int_impl { + ($($T:ty),+) => { + $( + { + const BITS: $T = -1; + const LEAST_SIG_ONE: $T = 1; + + // Left shift the least significant one through each + // bit position, starting with all bits set + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + NonZero::<$T>::new(BITS << i).unwrap().isolate_least_significant_one(), + NonZero::<$T>::new(LEAST_SIG_ONE << i).unwrap().isolate_least_significant_one() + ); + i += 1; + } + } + )+ + }; + } + + // Unsigned least significant one + macro_rules! nonzero_uint_impl { + ($($T:ty),+) => { + $( + { + const BITS: $T = <$T>::MAX; + const LEAST_SIG_ONE: $T = 1; + + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + NonZero::<$T>::new(BITS << i).unwrap().isolate_least_significant_one(), + NonZero::<$T>::new(LEAST_SIG_ONE << i).unwrap().isolate_least_significant_one(), + ); + i += 1; + } + } + )+ + }; + } + + nonzero_int_impl!(i8, i16, i32, i64, i128, isize); + nonzero_uint_impl!(u8, u16, u32, u64, u128, usize); +} + +#[test] fn test_nonzero_uint_div() { let nz = NonZero::new(1).unwrap(); diff --git a/library/coretests/tests/num/int_macros.rs b/library/coretests/tests/num/int_macros.rs index f13b836378b..392704e7509 100644 --- a/library/coretests/tests/num/int_macros.rs +++ b/library/coretests/tests/num/int_macros.rs @@ -193,6 +193,40 @@ macro_rules! int_module { } #[test] + fn test_isolate_most_significant_one() { + const BITS: $T = -1; + const MOST_SIG_ONE: $T = 1 << (<$T>::BITS - 1); + + // Right shift the most significant one through each + // bit position, starting with all bits set + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + (BITS >> i).isolate_most_significant_one(), + (MOST_SIG_ONE >> i).isolate_most_significant_one() + ); + i += 1; + } + } + + #[test] + fn test_isolate_least_significant_one() { + const BITS: $T = -1; + const LEAST_SIG_ONE: $T = 1; + + // Left shift the least significant one through each + // bit position, starting with all bits set + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + (BITS << i).isolate_least_significant_one(), + (LEAST_SIG_ONE << i).isolate_least_significant_one() + ); + i += 1; + } + } + + #[test] fn test_from_str() { fn from_str<T: std::str::FromStr>(t: &str) -> Option<T> { std::str::FromStr::from_str(t).ok() diff --git a/library/coretests/tests/num/uint_macros.rs b/library/coretests/tests/num/uint_macros.rs index 99a2d4cd462..c085ba5a249 100644 --- a/library/coretests/tests/num/uint_macros.rs +++ b/library/coretests/tests/num/uint_macros.rs @@ -141,6 +141,40 @@ macro_rules! uint_module { } } + #[test] + fn test_isolate_most_significant_one() { + const BITS: $T = <$T>::MAX; + const MOST_SIG_ONE: $T = 1 << (<$T>::BITS - 1); + + // Right shift the most significant one through each + // bit position, starting with all bits set + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + (BITS >> i).isolate_most_significant_one(), + (MOST_SIG_ONE >> i).isolate_most_significant_one(), + ); + i += 1; + } + } + + #[test] + fn test_isolate_least_significant_one() { + const BITS: $T = <$T>::MAX; + const LEAST_SIG_ONE: $T = 1; + + // Left shift the least significant one through each + // bit position, starting with all bits set + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + (BITS << i).isolate_least_significant_one(), + (LEAST_SIG_ONE << i).isolate_least_significant_one(), + ); + i += 1; + } + } + fn from_str<T: core::str::FromStr>(t: &str) -> Option<T> { core::str::FromStr::from_str(t).ok() } diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 36a0a59d939..228ee6eea05 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -110,6 +110,13 @@ panic_immediate_abort = [ # Choose algorithms that are optimized for binary size instead of runtime performance optimize_for_size = ["core/optimize_for_size", "alloc/optimize_for_size"] +# Make `RefCell` store additional debugging information, which is printed out when +# a borrow error occurs +debug_refcell = ["core/debug_refcell"] +# Make `TypeId` store a reference to the name of the type, so that it can print that name. +debug_typeid = ["core/debug_typeid"] + + # Enable std_detect default features for stdarch/crates/std_detect: # https://github.com/rust-lang/stdarch/blob/master/crates/std_detect/Cargo.toml std_detect_file_io = ["std_detect/std_detect_file_io"] diff --git a/library/std/src/ffi/mod.rs b/library/std/src/ffi/mod.rs index 7d7cce09a3f..860ec3a6be1 100644 --- a/library/std/src/ffi/mod.rs +++ b/library/std/src/ffi/mod.rs @@ -201,5 +201,5 @@ pub use self::c_str::{CStr, CString}; #[doc(inline)] pub use self::os_str::{OsStr, OsString}; -#[unstable(feature = "os_str_display", issue = "120048")] +#[stable(feature = "os_str_display", since = "CURRENT_RUSTC_VERSION")] pub mod os_str; diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index c4c8dbccd7a..f4a02802336 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -1204,13 +1204,12 @@ impl OsStr { /// # Examples /// /// ``` - /// #![feature(os_str_display)] /// use std::ffi::OsStr; /// /// let s = OsStr::new("Hello, world!"); /// println!("{}", s.display()); /// ``` - #[unstable(feature = "os_str_display", issue = "120048")] + #[stable(feature = "os_str_display", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this does not display the `OsStr`; \ it returns an object that can be displayed"] #[inline] @@ -1559,7 +1558,6 @@ impl fmt::Debug for OsStr { /// # Examples /// /// ``` -/// #![feature(os_str_display)] /// use std::ffi::OsStr; /// /// let s = OsStr::new("Hello, world!"); @@ -1568,19 +1566,19 @@ impl fmt::Debug for OsStr { /// /// [`Display`]: fmt::Display /// [`format!`]: crate::format -#[unstable(feature = "os_str_display", issue = "120048")] +#[stable(feature = "os_str_display", since = "CURRENT_RUSTC_VERSION")] pub struct Display<'a> { os_str: &'a OsStr, } -#[unstable(feature = "os_str_display", issue = "120048")] +#[stable(feature = "os_str_display", since = "CURRENT_RUSTC_VERSION")] impl fmt::Debug for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self.os_str, f) } } -#[unstable(feature = "os_str_display", issue = "120048")] +#[stable(feature = "os_str_display", since = "CURRENT_RUSTC_VERSION")] impl fmt::Display for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.os_str.inner, f) diff --git a/library/std/src/sys/pal/wasi/stdio.rs b/library/std/src/sys/pal/wasi/stdio.rs index d08b772e5fc..fb21cb4d393 100644 --- a/library/std/src/sys/pal/wasi/stdio.rs +++ b/library/std/src/sys/pal/wasi/stdio.rs @@ -1,7 +1,7 @@ #![forbid(unsafe_op_in_unsafe_fn)] use super::fd::WasiFd; -use crate::io::{self, IoSlice, IoSliceMut}; +use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; use crate::mem::ManuallyDrop; use crate::os::raw; use crate::os::wasi::io::{AsRawFd, FromRawFd}; @@ -28,6 +28,10 @@ impl io::Read for Stdin { self.read_vectored(&mut [IoSliceMut::new(data)]) } + fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> io::Result<()> { + ManuallyDrop::new(unsafe { WasiFd::from_raw_fd(self.as_raw_fd()) }).read_buf(buf) + } + fn read_vectored(&mut self, data: &mut [IoSliceMut<'_>]) -> io::Result<usize> { ManuallyDrop::new(unsafe { WasiFd::from_raw_fd(self.as_raw_fd()) }).read(data) } @@ -64,6 +68,7 @@ impl io::Write for Stdout { fn is_write_vectored(&self) -> bool { true } + fn flush(&mut self) -> io::Result<()> { Ok(()) } diff --git a/library/std/src/sys/pal/windows/c.rs b/library/std/src/sys/pal/windows/c.rs index 8dc61edb603..4fbdc839939 100644 --- a/library/std/src/sys/pal/windows/c.rs +++ b/library/std/src/sys/pal/windows/c.rs @@ -204,7 +204,7 @@ compat_fn_with_fallback! { pub fn NtReleaseKeyedEvent( EventHandle: HANDLE, Key: *const c_void, - Alertable: BOOLEAN, + Alertable: bool, Timeout: *mut i64 ) -> NTSTATUS { panic!("keyed events not available") @@ -213,7 +213,7 @@ compat_fn_with_fallback! { pub fn NtWaitForKeyedEvent( EventHandle: HANDLE, Key: *const c_void, - Alertable: BOOLEAN, + Alertable: bool, Timeout: *mut i64 ) -> NTSTATUS { panic!("keyed events not available") diff --git a/library/std/src/sys/random/windows.rs b/library/std/src/sys/random/windows.rs index 7566000f9e6..f5da637f56c 100644 --- a/library/std/src/sys/random/windows.rs +++ b/library/std/src/sys/random/windows.rs @@ -14,7 +14,7 @@ pub fn fill_bytes(mut bytes: &mut [u8]) { while !bytes.is_empty() { let len = bytes.len().try_into().unwrap_or(u32::MAX); let ret = unsafe { c::RtlGenRandom(bytes.as_mut_ptr().cast(), len) }; - assert_ne!(ret, 0, "failed to generate random data"); + assert!(ret, "failed to generate random data"); bytes = &mut bytes[len as usize..]; } } diff --git a/library/std/src/sys/sync/mutex/windows7.rs b/library/std/src/sys/sync/mutex/windows7.rs index 689dba10f01..0b57de78ba6 100644 --- a/library/std/src/sys/sync/mutex/windows7.rs +++ b/library/std/src/sys/sync/mutex/windows7.rs @@ -44,7 +44,7 @@ impl Mutex { #[inline] pub fn try_lock(&self) -> bool { - unsafe { c::TryAcquireSRWLockExclusive(raw(self)) != 0 } + unsafe { c::TryAcquireSRWLockExclusive(raw(self)) } } #[inline] diff --git a/library/std/src/sys/sync/thread_parking/windows7.rs b/library/std/src/sys/sync/thread_parking/windows7.rs index f7585e882f0..a1a0f8427cd 100644 --- a/library/std/src/sys/sync/thread_parking/windows7.rs +++ b/library/std/src/sys/sync/thread_parking/windows7.rs @@ -195,7 +195,7 @@ mod keyed_events { pub unsafe fn park(parker: Pin<&Parker>) { // Wait for unpark() to produce this event. - c::NtWaitForKeyedEvent(keyed_event_handle(), parker.ptr(), 0, ptr::null_mut()); + c::NtWaitForKeyedEvent(keyed_event_handle(), parker.ptr(), false, ptr::null_mut()); // Set the state back to EMPTY (from either PARKED or NOTIFIED). // Note that we don't just write EMPTY, but use swap() to also // include an acquire-ordered read to synchronize with unpark()'s @@ -218,7 +218,7 @@ mod keyed_events { // Wait for unpark() to produce this event. let unparked = - c::NtWaitForKeyedEvent(handle, parker.ptr(), 0, &mut timeout) == c::STATUS_SUCCESS; + c::NtWaitForKeyedEvent(handle, parker.ptr(), false, &mut timeout) == c::STATUS_SUCCESS; // Set the state back to EMPTY (from either PARKED or NOTIFIED). let prev_state = parker.state.swap(EMPTY, Acquire); @@ -228,7 +228,7 @@ mod keyed_events { // was set to NOTIFIED, which means we *just* missed an // unpark(), which is now blocked on us to wait for it. // Wait for it to consume the event and unblock that thread. - c::NtWaitForKeyedEvent(handle, parker.ptr(), 0, ptr::null_mut()); + c::NtWaitForKeyedEvent(handle, parker.ptr(), false, ptr::null_mut()); } } pub unsafe fn unpark(parker: Pin<&Parker>) { @@ -239,7 +239,7 @@ mod keyed_events { // To prevent this thread from blocking indefinitely in that case, // park_impl() will, after seeing the state set to NOTIFIED after // waking up, call NtWaitForKeyedEvent again to unblock us. - c::NtReleaseKeyedEvent(keyed_event_handle(), parker.ptr(), 0, ptr::null_mut()); + c::NtReleaseKeyedEvent(keyed_event_handle(), parker.ptr(), false, ptr::null_mut()); } fn keyed_event_handle() -> c::HANDLE { diff --git a/library/std/src/sys/thread_local/os.rs b/library/std/src/sys/thread_local/os.rs index 00d2e30bd60..fe6af27db3a 100644 --- a/library/std/src/sys/thread_local/os.rs +++ b/library/std/src/sys/thread_local/os.rs @@ -28,9 +28,7 @@ pub macro thread_local_inner { // user provided type or type alias with a matching name. Please update the shadowing test // in `tests/thread.rs` if these types are renamed. unsafe { - // Inlining does not work on windows-gnu due to linking errors around - // dllimports. See https://github.com/rust-lang/rust/issues/109797. - $crate::thread::LocalKey::new(#[cfg_attr(windows, inline(never))] |init| { + $crate::thread::LocalKey::new(|init| { static VAL: $crate::thread::local_impl::Storage<$t> = $crate::thread::local_impl::Storage::new(); VAL.get(init, __init) diff --git a/library/sysroot/Cargo.toml b/library/sysroot/Cargo.toml index aa6c3dc32e2..6ed2756e526 100644 --- a/library/sysroot/Cargo.toml +++ b/library/sysroot/Cargo.toml @@ -19,11 +19,13 @@ compiler-builtins-mem = ["std/compiler-builtins-mem"] compiler-builtins-no-asm = ["std/compiler-builtins-no-asm"] compiler-builtins-no-f16-f128 = ["std/compiler-builtins-no-f16-f128"] compiler-builtins-mangled-names = ["std/compiler-builtins-mangled-names"] +debug_refcell = ["std/debug_refcell"] +debug_typeid = ["std/debug_typeid"] llvm-libunwind = ["std/llvm-libunwind"] system-llvm-libunwind = ["std/system-llvm-libunwind"] +optimize_for_size = ["std/optimize_for_size"] panic-unwind = ["std/panic_unwind"] panic_immediate_abort = ["std/panic_immediate_abort"] -optimize_for_size = ["std/optimize_for_size"] profiler = ["dep:profiler_builtins"] std_detect_file_io = ["std/std_detect_file_io"] std_detect_dlsym_getauxval = ["std/std_detect_dlsym_getauxval"] diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 85b224771bb..795f9506a25 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -1029,6 +1029,17 @@ impl Step for PlainSourceTarball { ], plain_dst_src, ); + // We keep something in src/gcc because it is a registered submodule, + // and if it misses completely it can cause issues elsewhere + // (see https://github.com/rust-lang/rust/issues/137332). + // We can also let others know why is the source code missing. + if !builder.config.dry_run() { + builder.create_dir(&plain_dst_src.join("src/gcc")); + t!(std::fs::write( + plain_dst_src.join("src/gcc/notice.txt"), + "The GCC source code is not included due to unclear licensing implications\n" + )); + } // Copy the files normally for item in &src_files { diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index b3f4a7bad99..5fc3e8469bb 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1762,7 +1762,9 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the cmd.arg("--coverage-dump-path").arg(coverage_dump); } - cmd.arg("--src-base").arg(builder.src.join("tests").join(suite)); + cmd.arg("--src-root").arg(&builder.src); + cmd.arg("--src-test-suite-root").arg(builder.src.join("tests").join(suite)); + cmd.arg("--build-base").arg(testdir(builder, compiler.host).join(suite)); // When top stage is 0, that means that we're testing an externally provided compiler. diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 64a510240f8..172b8d78764 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -2767,7 +2767,7 @@ impl Config { ), )] pub(crate) fn update_submodule(&self, relative_path: &str) { - if !self.submodules() { + if self.rust_info.is_from_tarball() || !self.submodules() { return; } diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index dfaf0418d9a..da48b924ce4 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -481,6 +481,10 @@ impl Build { ), )] pub fn require_submodule(&self, submodule: &str, err_hint: Option<&str>) { + if self.rust_info().is_from_tarball() { + return; + } + // When testing bootstrap itself, it is much faster to ignore // submodules. Almost all Steps work fine without their submodules. if cfg!(test) && !self.config.submodules() { @@ -488,7 +492,7 @@ impl Build { } self.config.update_submodule(submodule); let absolute_path = self.config.src.join(submodule); - if dir_is_empty(&absolute_path) { + if !absolute_path.exists() || dir_is_empty(&absolute_path) { let maybe_enable = if !self.config.submodules() && self.config.rust_info.is_managed_git_subrepository() { diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index b5cd3864620..c4e5c1aac2f 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -301,7 +301,7 @@ target | std | host | notes [`armv8r-none-eabihf`](platform-support/armv8r-none-eabihf.md) | * | | Bare Armv8-R, hardfloat [`armv7a-nuttx-eabi`](platform-support/nuttx.md) | ✓ | | ARMv7-A with NuttX [`armv7a-nuttx-eabihf`](platform-support/nuttx.md) | ✓ | | ARMv7-A with NuttX, hardfloat -`avr-unknown-gnu-atmega328` | * | | AVR. Requires `-Z build-std=core` +`avr-none` | * | | AVR; requires `-Zbuild-std=core` and `-Ctarget-cpu=...` `bpfeb-unknown-none` | * | | BPF (big endian) `bpfel-unknown-none` | * | | BPF (little endian) `csky-unknown-linux-gnuabiv2` | ✓ | | C-SKY abiv2 Linux (little endian) @@ -309,10 +309,10 @@ target | std | host | notes [`hexagon-unknown-linux-musl`](platform-support/hexagon-unknown-linux-musl.md) | ✓ | | Hexagon Linux with musl 1.2.3 [`hexagon-unknown-none-elf`](platform-support/hexagon-unknown-none-elf.md)| * | | Bare Hexagon (v60+, HVX) [`i386-apple-ios`](platform-support/apple-ios.md) | ✓ | | 32-bit x86 iOS (Penryn) [^x86_32-floats-return-ABI] -[`i586-pc-nto-qnx700`](platform-support/nto-qnx.md) | * | | 32-bit x86 QNX Neutrino 7.0 RTOS (Pentium 4) [^x86_32-floats-return-ABI] [`i586-unknown-netbsd`](platform-support/netbsd.md) | ✓ | | 32-bit x86 (original Pentium) [^x86_32-floats-x87] [`i586-unknown-redox`](platform-support/redox.md) | ✓ | | 32-bit x86 Redox OS (PentiumPro) [^x86_32-floats-x87] [`i686-apple-darwin`](platform-support/apple-darwin.md) | ✓ | ✓ | 32-bit macOS (10.12+, Sierra+, Penryn) [^x86_32-floats-return-ABI] +[`i686-pc-nto-qnx700`](platform-support/nto-qnx.md) | * | | 32-bit x86 QNX Neutrino 7.0 RTOS (Pentium 4) [^x86_32-floats-return-ABI] `i686-unknown-haiku` | ✓ | ✓ | 32-bit Haiku (Pentium 4) [^x86_32-floats-return-ABI] [`i686-unknown-hurd-gnu`](platform-support/hurd.md) | ✓ | ✓ | 32-bit GNU/Hurd (Pentium 4) [^x86_32-floats-return-ABI] [`i686-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | NetBSD/i386 (Pentium 4) [^x86_32-floats-return-ABI] diff --git a/src/doc/rustc/src/platform-support/avr-none.md b/src/doc/rustc/src/platform-support/avr-none.md new file mode 100644 index 00000000000..9c1836222c1 --- /dev/null +++ b/src/doc/rustc/src/platform-support/avr-none.md @@ -0,0 +1,81 @@ +# `avr-none` + +Series of microcontrollers from Atmel: ATmega8, ATmega328p etc. + +**Tier: 3** + +## Target maintainers + +- [Patryk Wychowaniec](https://github.com/Patryk27) <pwychowaniec@pm.me> + +## Requirements + +This target is only cross-compiled; x86-64 Linux, x86-64 macOS and aarch64 macOS +hosts are confirmed to work, but in principle any machine able to run rustc and +avr-gcc should be good. + +Compiling for this target requires `avr-gcc` installed, because a couple of +intrinsics (like 32-bit multiplication) rely on [`libgcc`](https://github.com/gcc-mirror/gcc/blob/3269a722b7a03613e9c4e2862bc5088c4a17cc11/libgcc/config/avr/lib1funcs.S) +and can't be provided through `compiler-builtins` yet. This is a limitation that +[we hope to lift in the future](https://github.com/rust-lang/compiler-builtins/issues/711). + +You'll also need to setup the `.cargo/config` file - see below for details. + +## Building the target + +Rust comes with AVR support enabled, you don't have to rebuild the compiler. + +## Building Rust programs + +Install `avr-gcc`: + +```console +# Ubuntu: +$ sudo apt-get install gcc-avr + +# Mac: +$ brew tap osx-cross/avr && brew install avr-gcc + +# NixOS (takes a couple of minutes, since it's not provided through Hydra): +$ nix shell nixpkgs#pkgsCross.avr.buildPackages.gcc11 +``` + +... setup `.cargo/config` for your project: + +```toml +[build] +target = "avr-none" +rustflags = ["-C", "target-cpu=atmega328p"] + +[unstable] +build-std = ["core"] +``` + +... and then simply run: + +```console +$ cargo build --release +``` + +The final binary will be placed into +`./target/avr-none/release/your-project.elf`. + +Note that since AVRs have rather small amounts of registers, ROM and RAM, it's +recommended to always use `--release` to avoid running out of space. + +Also, please note that specifying `-C target-cpu` is required - here's a list of +the possible variants: + +https://github.com/llvm/llvm-project/blob/093d4db2f3c874d4683fb01194b00dbb20e5c713/clang/lib/Basic/Targets/AVR.cpp#L32 + +## Testing + +You can use [`simavr`](https://github.com/buserror/simavr) to emulate the +resulting firmware on your machine: + +```console +$ simavr -m atmega328p ./target/avr-none/release/your-project.elf +``` + +Alternatively, if you want to write a couple of actual `#[test]`s, you can use +[`avr-tester`](https://github.com/Patryk27/avr-tester). diff --git a/src/doc/rustc/src/platform-support/nto-qnx.md b/src/doc/rustc/src/platform-support/nto-qnx.md index 339741f1472..77e8caaee4c 100644 --- a/src/doc/rustc/src/platform-support/nto-qnx.md +++ b/src/doc/rustc/src/platform-support/nto-qnx.md @@ -31,7 +31,7 @@ Currently, the following QNX versions and compilation targets are supported: | `aarch64-unknown-nto-qnx710_iosock` | QNX Neutrino 7.1 with io-sock | AArch64 | ? | ✓ | | `x86_64-pc-nto-qnx710_iosock` | QNX Neutrino 7.1 with io-sock | x86_64 | ? | ✓ | | `aarch64-unknown-nto-qnx700` | QNX Neutrino 7.0 | AArch64 | ? | ✓ | -| `i586-pc-nto-qnx700` | QNX Neutrino 7.0 | x86 | | ✓ | +| `i686-pc-nto-qnx700` | QNX Neutrino 7.0 | x86 | | ✓ | On QNX Neutrino 7.0 and 7.1, `io-pkt` is used as network stack by default. QNX Neutrino 7.1 includes the optional network stack `io-sock`. diff --git a/src/doc/rustc/src/platform-support/wasm32-unknown-unknown.md b/src/doc/rustc/src/platform-support/wasm32-unknown-unknown.md index 73264aba858..ba95ab7af6d 100644 --- a/src/doc/rustc/src/platform-support/wasm32-unknown-unknown.md +++ b/src/doc/rustc/src/platform-support/wasm32-unknown-unknown.md @@ -129,6 +129,8 @@ As of the time of this writing the proposals that are enabled by default (the * `mutable-globals` * `reference-types` * `sign-ext` +* `nontrapping-fptoint` (Rust 1.87.0+, LLVM 20+) +* `bulk-memory` (Rust 1.87.0+, LLVM 20+) If you're compiling WebAssembly code for an engine that does not support a feature in LLVM's default feature set then the feature must be disabled at diff --git a/src/doc/rustdoc/src/command-line-arguments.md b/src/doc/rustdoc/src/command-line-arguments.md index 1af5e2b0e1d..872592d669d 100644 --- a/src/doc/rustdoc/src/command-line-arguments.md +++ b/src/doc/rustdoc/src/command-line-arguments.md @@ -100,7 +100,8 @@ mod private { // this item is private and will not be documented } ``` -`--document-private-items` documents all items, even if they're not public. +`--document-private-items` includes all non-public items in the generated documentation except for `#[doc(hidden)]` items. Private items will be shown with a 🔒 icon. + ## `-L`/`--library-path`: where to look for dependencies diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 3abd538d372..d4ff69a9933 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -262,6 +262,25 @@ themselves marked as unstable. To use any of these options, pass `-Z unstable-op the flag in question to Rustdoc on the command-line. To do this from Cargo, you can either use the `RUSTDOCFLAGS` environment variable or the `cargo rustdoc` command. +### `--document-hidden-items`: Show items that are `#[doc(hidden)]` +<span id="document-hidden-items"></span> + +By default, `rustdoc` does not document items that are annotated with +[`#[doc(hidden)]`](write-documentation/the-doc-attribute.html#hidden). + +`--document-hidden-items` causes all items to be documented as if they did not have `#[doc(hidden)]`, except that hidden items will be shown with a 👻 icon. + +Here is a table that fully describes which items are documented with each combination of `--document-hidden-items` and `--document-private-items`: + + +| rustdoc flags | items that will be documented | +|---------------------------------|---------------------------------------| +| neither flag | only public items that are not hidden | +| only `--document-hidden-items` | all public items | +| only `--document-private-items` | all items that are not hidden | +| both flags | all items | + + ### `--markdown-before-content`: include rendered Markdown before the content * Tracking issue: [#44027](https://github.com/rust-lang/rust/issues/44027) diff --git a/src/doc/rustdoc/src/write-documentation/the-doc-attribute.md b/src/doc/rustdoc/src/write-documentation/the-doc-attribute.md index ff033aa14b8..45146993371 100644 --- a/src/doc/rustdoc/src/write-documentation/the-doc-attribute.md +++ b/src/doc/rustdoc/src/write-documentation/the-doc-attribute.md @@ -230,9 +230,8 @@ If you want to know more about inlining rules, take a look at the <span id="dochidden"></span> -Any item annotated with `#[doc(hidden)]` will not appear in the documentation, unless -the `strip-hidden` pass is removed. Re-exported items where one of its ancestors has -`#[doc(hidden)]` will be considered the same as private. +Any item annotated with `#[doc(hidden)]` will not appear in the documentation, +unless the [`--document-hidden-items`](../unstable-features.md#document-hidden-items) flag is used. You can find more information in the [`re-exports` chapter](./re-exports.md). diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index e4acbcf2c62..1f2f8f7d33a 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -13,7 +13,6 @@ #![feature(iter_intersperse)] #![feature(let_chains)] #![feature(never_type)] -#![feature(os_str_display)] #![feature(round_char_boundary)] #![feature(test)] #![feature(type_alias_impl_trait)] diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 9fe8b99e8af..97e6d314642 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -1983,7 +1983,7 @@ fn resolution_failure( .tcx .resolutions(()) .all_macro_rules - .contains_key(&Symbol::intern(path_str)) + .contains(&Symbol::intern(path_str)) { diag.note(format!( "`macro_rules` named `{path_str}` exists in this crate, \ diff --git a/src/librustdoc/scrape_examples.rs b/src/librustdoc/scrape_examples.rs index a36dcb0d30e..44551d75903 100644 --- a/src/librustdoc/scrape_examples.rs +++ b/src/librustdoc/scrape_examples.rs @@ -177,7 +177,7 @@ where // If the enclosing item has a span coming from a proc macro, then we also don't want to // include the example. let enclosing_item_span = - tcx.hir().span_with_body(tcx.hir().get_parent_item(ex.hir_id).into()); + tcx.hir().span_with_body(tcx.hir_get_parent_item(ex.hir_id).into()); if enclosing_item_span.from_expansion() { trace!("Rejecting expr ({call_span:?}) from macro item: {enclosing_item_span:?}"); return; diff --git a/src/tools/clippy/clippy_lints/src/assigning_clones.rs b/src/tools/clippy/clippy_lints/src/assigning_clones.rs index c01155ca86e..348495f97a2 100644 --- a/src/tools/clippy/clippy_lints/src/assigning_clones.rs +++ b/src/tools/clippy/clippy_lints/src/assigning_clones.rs @@ -107,7 +107,7 @@ impl<'tcx> LateLintPass<'tcx> for AssigningClones { && !cx.tcx.is_builtin_derived(resolved_impl) // Don't suggest calling a function we're implementing. && resolved_impl.as_local().is_none_or(|block_id| { - cx.tcx.hir().parent_owner_iter(e.hir_id).all(|(id, _)| id.def_id != block_id) + cx.tcx.hir_parent_owner_iter(e.hir_id).all(|(id, _)| id.def_id != block_id) }) && let resolved_assoc_items = cx.tcx.associated_items(resolved_impl) // Only suggest if `clone_from`/`clone_into` is explicitly implemented diff --git a/src/tools/clippy/clippy_lints/src/doc/missing_headers.rs b/src/tools/clippy/clippy_lints/src/doc/missing_headers.rs index d1ffbb6ffe2..e8638595c4b 100644 --- a/src/tools/clippy/clippy_lints/src/doc/missing_headers.rs +++ b/src/tools/clippy/clippy_lints/src/doc/missing_headers.rs @@ -24,8 +24,7 @@ pub fn check( if !check_private_items && cx .tcx - .hir() - .parent_iter(owner_id.into()) + .hir_parent_iter(owner_id.into()) .any(|(id, _node)| is_doc_hidden(cx.tcx.hir().attrs(id))) { return; diff --git a/src/tools/clippy/clippy_lints/src/doc/mod.rs b/src/tools/clippy/clippy_lints/src/doc/mod.rs index 93c2b7a2d18..713d62a8801 100644 --- a/src/tools/clippy/clippy_lints/src/doc/mod.rs +++ b/src/tools/clippy/clippy_lints/src/doc/mod.rs @@ -1057,7 +1057,7 @@ impl<'tcx> Visitor<'tcx> for FindPanicUnwrap<'_, 'tcx> { "assert" | "assert_eq" | "assert_ne" ) { - self.is_const = self.cx.tcx.hir().is_inside_const_context(expr.hir_id); + self.is_const = self.cx.tcx.hir_is_inside_const_context(expr.hir_id); self.panic_span = Some(macro_call.span); } } diff --git a/src/tools/clippy/clippy_lints/src/escape.rs b/src/tools/clippy/clippy_lints/src/escape.rs index c55d4387d69..0c06c9117d7 100644 --- a/src/tools/clippy/clippy_lints/src/escape.rs +++ b/src/tools/clippy/clippy_lints/src/escape.rs @@ -80,8 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal { let parent_id = cx .tcx - .hir() - .get_parent_item(cx.tcx.local_def_id_to_hir_id(fn_def_id)) + .hir_get_parent_item(cx.tcx.local_def_id_to_hir_id(fn_def_id)) .def_id; let mut trait_self_ty = None; diff --git a/src/tools/clippy/clippy_lints/src/exit.rs b/src/tools/clippy/clippy_lints/src/exit.rs index e6ddcd107d9..cc8e4d7d9e2 100644 --- a/src/tools/clippy/clippy_lints/src/exit.rs +++ b/src/tools/clippy/clippy_lints/src/exit.rs @@ -47,7 +47,7 @@ impl<'tcx> LateLintPass<'tcx> for Exit { && let ExprKind::Path(ref path) = path_expr.kind && let Some(def_id) = cx.qpath_res(path, path_expr.hir_id).opt_def_id() && cx.tcx.is_diagnostic_item(sym::process_exit, def_id) - && let parent = cx.tcx.hir().get_parent_item(e.hir_id) + && let parent = cx.tcx.hir_get_parent_item(e.hir_id) && let OwnerNode::Item(Item{kind: ItemKind::Fn{ .. }, ..}) = cx.tcx.hir_owner_node(parent) // If the next item up is a function we check if it is an entry point // and only then emit a linter warning diff --git a/src/tools/clippy/clippy_lints/src/indexing_slicing.rs b/src/tools/clippy/clippy_lints/src/indexing_slicing.rs index f666ed0a440..33431385c7d 100644 --- a/src/tools/clippy/clippy_lints/src/indexing_slicing.rs +++ b/src/tools/clippy/clippy_lints/src/indexing_slicing.rs @@ -112,7 +112,7 @@ impl IndexingSlicing { impl<'tcx> LateLintPass<'tcx> for IndexingSlicing { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { if let ExprKind::Index(array, index, _) = &expr.kind - && (!self.suppress_restriction_lint_in_const || !cx.tcx.hir().is_inside_const_context(expr.hir_id)) + && (!self.suppress_restriction_lint_in_const || !cx.tcx.hir_is_inside_const_context(expr.hir_id)) && let expr_ty = cx.typeck_results().expr_ty(array) && let mut deref = deref_chain(cx, expr_ty) && deref.any(|l| { @@ -181,7 +181,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing { span_lint_and_then(cx, INDEXING_SLICING, expr.span, "slicing may panic", |diag| { diag.help(help_msg); - if cx.tcx.hir().is_inside_const_context(expr.hir_id) { + if cx.tcx.hir_is_inside_const_context(expr.hir_id) { diag.note(note); } }); @@ -223,7 +223,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing { span_lint_and_then(cx, INDEXING_SLICING, expr.span, "indexing may panic", |diag| { diag.help("consider using `.get(n)` or `.get_mut(n)` instead"); - if cx.tcx.hir().is_inside_const_context(expr.hir_id) { + if cx.tcx.hir_is_inside_const_context(expr.hir_id) { diag.note(note); } }); diff --git a/src/tools/clippy/clippy_lints/src/large_stack_arrays.rs b/src/tools/clippy/clippy_lints/src/large_stack_arrays.rs index c68499ce9f7..620e27fa67c 100644 --- a/src/tools/clippy/clippy_lints/src/large_stack_arrays.rs +++ b/src/tools/clippy/clippy_lints/src/large_stack_arrays.rs @@ -83,7 +83,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackArrays { && let ty::Array(element_type, cst) = cx.typeck_results().expr_ty(expr).kind() && let Some(element_count) = cst.try_to_target_usize(cx.tcx) && let Ok(element_size) = cx.layout_of(*element_type).map(|l| l.size.bytes()) - && !cx.tcx.hir().parent_iter(expr.hir_id).any(|(_, node)| { + && !cx.tcx.hir_parent_iter(expr.hir_id).any(|(_, node)| { matches!( node, Node::Item(Item { diff --git a/src/tools/clippy/clippy_lints/src/loops/infinite_loop.rs b/src/tools/clippy/clippy_lints/src/loops/infinite_loop.rs index 4d206850c99..797ff1f3986 100644 --- a/src/tools/clippy/clippy_lints/src/loops/infinite_loop.rs +++ b/src/tools/clippy/clippy_lints/src/loops/infinite_loop.rs @@ -61,7 +61,7 @@ pub(super) fn check<'tcx>( } fn get_parent_fn_ret_ty<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>) -> Option<FnRetTy<'tcx>> { - for (_, parent_node) in cx.tcx.hir().parent_iter(expr.hir_id) { + for (_, parent_node) in cx.tcx.hir_parent_iter(expr.hir_id) { match parent_node { // Skip `Coroutine` closures, these are the body of `async fn`, not async closures. // This is because we still need to backtrack one parent node to get the `OpaqueDef` ty. diff --git a/src/tools/clippy/clippy_lints/src/loops/manual_find.rs b/src/tools/clippy/clippy_lints/src/loops/manual_find.rs index 1721f569541..aa8a2934f89 100644 --- a/src/tools/clippy/clippy_lints/src/loops/manual_find.rs +++ b/src/tools/clippy/clippy_lints/src/loops/manual_find.rs @@ -134,7 +134,7 @@ fn last_stmt_and_ret<'tcx>( } None } - let mut parent_iter = cx.tcx.hir().parent_iter(expr.hir_id); + let mut parent_iter = cx.tcx.hir_parent_iter(expr.hir_id); if let Some((node_hir, Node::Stmt(..))) = parent_iter.next() // This should be the loop // This should be the function body diff --git a/src/tools/clippy/clippy_lints/src/loops/needless_range_loop.rs b/src/tools/clippy/clippy_lints/src/loops/needless_range_loop.rs index e98c3c9698b..0f62183eb33 100644 --- a/src/tools/clippy/clippy_lints/src/loops/needless_range_loop.rs +++ b/src/tools/clippy/clippy_lints/src/loops/needless_range_loop.rs @@ -56,7 +56,7 @@ pub(super) fn check<'tcx>( // ensure that the indexed variable was declared before the loop, see #601 if let Some(indexed_extent) = indexed_extent { - let parent_def_id = cx.tcx.hir().get_parent_item(expr.hir_id); + let parent_def_id = cx.tcx.hir_get_parent_item(expr.hir_id); let region_scope_tree = cx.tcx.region_scope_tree(parent_def_id); let pat_extent = region_scope_tree.var_scope(pat.hir_id.local_id).unwrap(); if region_scope_tree.is_subscope_of(indexed_extent, pat_extent) { @@ -256,7 +256,7 @@ impl<'tcx> VarVisitor<'_, 'tcx> { let res = self.cx.qpath_res(seqpath, seqexpr.hir_id); match res { Res::Local(hir_id) => { - let parent_def_id = self.cx.tcx.hir().get_parent_item(expr.hir_id); + let parent_def_id = self.cx.tcx.hir_get_parent_item(expr.hir_id); let extent = self .cx .tcx diff --git a/src/tools/clippy/clippy_lints/src/matches/redundant_pattern_match.rs b/src/tools/clippy/clippy_lints/src/matches/redundant_pattern_match.rs index 39339966013..722ea7042dd 100644 --- a/src/tools/clippy/clippy_lints/src/matches/redundant_pattern_match.rs +++ b/src/tools/clippy/clippy_lints/src/matches/redundant_pattern_match.rs @@ -199,7 +199,7 @@ fn find_method_sugg_for_if_let<'tcx>( // type needs to be considered, not just the inner type of the branch being matched on. // Note the last expression in a block is dropped after all local bindings. let check_ty = if has_else - || (keyword == "if" && matches!(cx.tcx.hir().parent_iter(expr.hir_id).next(), Some((_, Node::Block(..))))) + || (keyword == "if" && matches!(cx.tcx.hir_parent_iter(expr.hir_id).next(), Some((_, Node::Block(..))))) { op_ty } else { diff --git a/src/tools/clippy/clippy_lints/src/methods/is_empty.rs b/src/tools/clippy/clippy_lints/src/methods/is_empty.rs index 92c81b3c49d..1c64f78678a 100644 --- a/src/tools/clippy/clippy_lints/src/methods/is_empty.rs +++ b/src/tools/clippy/clippy_lints/src/methods/is_empty.rs @@ -40,8 +40,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &'_ Expr<'_>, receiver: &Expr<'_ fn is_under_cfg(cx: &LateContext<'_>, id: HirId) -> bool { cx.tcx - .hir() - .parent_id_iter(id) + .hir_parent_id_iter(id) .any(|id| cx.tcx.hir().attrs(id).iter().any(|attr| attr.has_name(sym::cfg))) } diff --git a/src/tools/clippy/clippy_lints/src/methods/iter_nth_zero.rs b/src/tools/clippy/clippy_lints/src/methods/iter_nth_zero.rs index 9ff6eaa3487..4bdf589f487 100644 --- a/src/tools/clippy/clippy_lints/src/methods/iter_nth_zero.rs +++ b/src/tools/clippy/clippy_lints/src/methods/iter_nth_zero.rs @@ -11,7 +11,7 @@ use rustc_span::sym; use super::ITER_NTH_ZERO; pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr<'_>, arg: &hir::Expr<'_>) { - if let OwnerNode::Item(item) = cx.tcx.hir_owner_node(cx.tcx.hir().get_parent_item(expr.hir_id)) + if let OwnerNode::Item(item) = cx.tcx.hir_owner_node(cx.tcx.hir_get_parent_item(expr.hir_id)) && let def_id = item.owner_id.to_def_id() && is_trait_method(cx, expr, sym::Iterator) && let Some(Constant::Int(0)) = ConstEvalCtxt::new(cx).eval(arg) diff --git a/src/tools/clippy/clippy_lints/src/methods/manual_c_str_literals.rs b/src/tools/clippy/clippy_lints/src/methods/manual_c_str_literals.rs index 7d5ebdedd0c..e1ebca0b09d 100644 --- a/src/tools/clippy/clippy_lints/src/methods/manual_c_str_literals.rs +++ b/src/tools/clippy/clippy_lints/src/methods/manual_c_str_literals.rs @@ -187,7 +187,7 @@ fn peel_ptr_cast<'tcx>(e: &'tcx Expr<'tcx>) -> &'tcx Expr<'tcx> { /// ^ given this `x` expression, returns the `foo(...)` expression fn peel_ptr_cast_ancestors<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'tcx>) -> &'tcx Expr<'tcx> { let mut prev = e; - for (_, node) in cx.tcx.hir().parent_iter(e.hir_id) { + for (_, node) in cx.tcx.hir_parent_iter(e.hir_id) { if let Node::Expr(e) = node && get_cast_target(e).is_some() { diff --git a/src/tools/clippy/clippy_lints/src/methods/manual_inspect.rs b/src/tools/clippy/clippy_lints/src/methods/manual_inspect.rs index de37df2394d..09ccb386a20 100644 --- a/src/tools/clippy/clippy_lints/src/methods/manual_inspect.rs +++ b/src/tools/clippy/clippy_lints/src/methods/manual_inspect.rs @@ -123,7 +123,7 @@ pub(crate) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, arg: &Expr<'_>, name: }; let mut prev_expr = e; - for (_, parent) in cx.tcx.hir().parent_iter(e.hir_id) { + for (_, parent) in cx.tcx.hir_parent_iter(e.hir_id) { if let Node::Expr(e) = parent { match e.kind { ExprKind::Field(_, name) diff --git a/src/tools/clippy/clippy_lints/src/methods/mod.rs b/src/tools/clippy/clippy_lints/src/methods/mod.rs index ccc5cd4fa41..b58e8ba32e7 100644 --- a/src/tools/clippy/clippy_lints/src/methods/mod.rs +++ b/src/tools/clippy/clippy_lints/src/methods/mod.rs @@ -4671,7 +4671,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods { return; } let name = impl_item.ident.name.as_str(); - let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id()).def_id; + let parent = cx.tcx.hir_get_parent_item(impl_item.hir_id()).def_id; let item = cx.tcx.hir().expect_item(parent); let self_ty = cx.tcx.type_of(item.owner_id).instantiate_identity(); diff --git a/src/tools/clippy/clippy_lints/src/methods/or_fun_call.rs b/src/tools/clippy/clippy_lints/src/methods/or_fun_call.rs index f5f404070ca..69f933fee68 100644 --- a/src/tools/clippy/clippy_lints/src/methods/or_fun_call.rs +++ b/src/tools/clippy/clippy_lints/src/methods/or_fun_call.rs @@ -92,7 +92,7 @@ pub(super) fn check<'tcx>( let in_sugg_method_implementation = { matches!( suggested_method_def_id.as_local(), - Some(local_def_id) if local_def_id == cx.tcx.hir().get_parent_item(receiver.hir_id).def_id + Some(local_def_id) if local_def_id == cx.tcx.hir_get_parent_item(receiver.hir_id).def_id ) }; if in_sugg_method_implementation { diff --git a/src/tools/clippy/clippy_lints/src/methods/str_splitn.rs b/src/tools/clippy/clippy_lints/src/methods/str_splitn.rs index 8a99974394c..8389c2e3f98 100644 --- a/src/tools/clippy/clippy_lints/src/methods/str_splitn.rs +++ b/src/tools/clippy/clippy_lints/src/methods/str_splitn.rs @@ -35,7 +35,7 @@ pub(super) fn check( }; let manual = count == 2 && msrv.meets(msrvs::STR_SPLIT_ONCE); - match parse_iter_usage(cx, expr.span.ctxt(), cx.tcx.hir().parent_iter(expr.hir_id)) { + match parse_iter_usage(cx, expr.span.ctxt(), cx.tcx.hir_parent_iter(expr.hir_id)) { Some(usage) if needless(usage.kind) => lint_needless(cx, method_name, expr, self_arg, pat_arg), Some(usage) if manual => check_manual_split_once(cx, method_name, expr, self_arg, pat_arg, &usage), None if manual => { @@ -127,7 +127,7 @@ fn check_manual_split_once_indirect( pat_arg: &Expr<'_>, ) -> Option<()> { let ctxt = expr.span.ctxt(); - let mut parents = cx.tcx.hir().parent_iter(expr.hir_id); + let mut parents = cx.tcx.hir_parent_iter(expr.hir_id); if let (_, Node::LetStmt(local)) = parents.next()? && let PatKind::Binding(BindingMode::MUT, iter_binding_id, _, None) = local.pat.kind && let (iter_stmt_id, Node::Stmt(_)) = parents.next()? @@ -220,7 +220,7 @@ fn indirect_usage<'tcx>( ControlFlow::Continue(Descend::from(path_to_binding.is_none())) }); - let mut parents = cx.tcx.hir().parent_iter(path_to_binding?.hir_id); + let mut parents = cx.tcx.hir_parent_iter(path_to_binding?.hir_id); let iter_usage = parse_iter_usage(cx, ctxt, &mut parents)?; let (parent_id, _) = parents.find(|(_, node)| { diff --git a/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs b/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs index e80d99dca56..ea134c05705 100644 --- a/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs +++ b/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs @@ -494,7 +494,7 @@ fn get_input_traits_and_projections<'tcx>( #[expect(clippy::too_many_lines)] fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<'a>) -> bool { - for (_, node) in cx.tcx.hir().parent_iter(expr.hir_id) { + for (_, node) in cx.tcx.hir_parent_iter(expr.hir_id) { match node { Node::Stmt(_) => return true, Node::Block(..) => {}, diff --git a/src/tools/clippy/clippy_lints/src/min_ident_chars.rs b/src/tools/clippy/clippy_lints/src/min_ident_chars.rs index 4119b1d1051..e5801124db4 100644 --- a/src/tools/clippy/clippy_lints/src/min_ident_chars.rs +++ b/src/tools/clippy/clippy_lints/src/min_ident_chars.rs @@ -121,9 +121,9 @@ impl Visitor<'_> for IdentVisitor<'_, '_> { // Check whether the node is part of a `use` statement. We don't want to emit a warning if the user // has no control over the type. let usenode = opt_as_use_node(node).or_else(|| { - cx.tcx - .hir() - .parent_iter(hir_id) + cx + .tcx + .hir_parent_iter(hir_id) .find_map(|(_, node)| opt_as_use_node(node)) }); diff --git a/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs b/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs index ba4af134ccd..8d751c2c0ac 100644 --- a/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs +++ b/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs @@ -143,7 +143,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn { // Const fns are not allowed as methods in a trait. { - let parent = cx.tcx.hir().get_parent_item(hir_id).def_id; + let parent = cx.tcx.hir_get_parent_item(hir_id).def_id; if parent != CRATE_DEF_ID { if let hir::Node::Item(item) = cx.tcx.hir_node_by_def_id(parent) { if let hir::ItemKind::Trait(..) = &item.kind { diff --git a/src/tools/clippy/clippy_lints/src/missing_const_for_thread_local.rs b/src/tools/clippy/clippy_lints/src/missing_const_for_thread_local.rs index e2ca4458eda..d4181c677af 100644 --- a/src/tools/clippy/clippy_lints/src/missing_const_for_thread_local.rs +++ b/src/tools/clippy/clippy_lints/src/missing_const_for_thread_local.rs @@ -81,7 +81,7 @@ fn is_unreachable(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { | sym::core_panic_2015_macro | sym::std_panic_2015_macro | sym::core_panic_2021_macro - ) && !cx.tcx.hir().is_inside_const_context(expr.hir_id)) + ) && !cx.tcx.hir_is_inside_const_context(expr.hir_id)) || matches!( diag_name, sym::unimplemented_macro | sym::todo_macro | sym::unreachable_macro | sym::unreachable_2015_macro diff --git a/src/tools/clippy/clippy_lints/src/needless_borrowed_ref.rs b/src/tools/clippy/clippy_lints/src/needless_borrowed_ref.rs index 098098718af..1b6896827fe 100644 --- a/src/tools/clippy/clippy_lints/src/needless_borrowed_ref.rs +++ b/src/tools/clippy/clippy_lints/src/needless_borrowed_ref.rs @@ -41,8 +41,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBorrowedRef { && !ref_pat.span.from_expansion() && cx .tcx - .hir() - .parent_iter(ref_pat.hir_id) + .hir_parent_iter(ref_pat.hir_id) .map_while(|(_, parent)| if let Node::Pat(pat) = parent { Some(pat) } else { None }) // Do not lint patterns that are part of an OR `|` pattern, the binding mode must match in all arms .all(|pat| !matches!(pat.kind, PatKind::Or(_))) diff --git a/src/tools/clippy/clippy_lints/src/needless_late_init.rs b/src/tools/clippy/clippy_lints/src/needless_late_init.rs index 4e19a2f409d..863a1f895c9 100644 --- a/src/tools/clippy/clippy_lints/src/needless_late_init.rs +++ b/src/tools/clippy/clippy_lints/src/needless_late_init.rs @@ -347,7 +347,7 @@ fn check<'tcx>( impl<'tcx> LateLintPass<'tcx> for NeedlessLateInit { fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx LetStmt<'tcx>) { - let mut parents = cx.tcx.hir().parent_iter(local.hir_id); + let mut parents = cx.tcx.hir_parent_iter(local.hir_id); if let LetStmt { init: None, pat: diff --git a/src/tools/clippy/clippy_lints/src/needless_pass_by_ref_mut.rs b/src/tools/clippy/clippy_lints/src/needless_pass_by_ref_mut.rs index 5e85d23718a..36a0738cbc9 100644 --- a/src/tools/clippy/clippy_lints/src/needless_pass_by_ref_mut.rs +++ b/src/tools/clippy/clippy_lints/src/needless_pass_by_ref_mut.rs @@ -350,8 +350,7 @@ impl MutablyUsedVariablesCtxt<'_> { // The goal here is to find if the current scope is unsafe or not. It stops when it finds // a function or an unsafe block. fn is_in_unsafe_block(&self, item: HirId) -> bool { - let hir = self.tcx.hir(); - for (parent, node) in hir.parent_iter(item) { + for (parent, node) in self.tcx.hir_parent_iter(item) { if let Some(fn_sig) = self.tcx.hir_fn_sig_by_hir_id(parent) { return fn_sig.header.is_unsafe(); } else if let Node::Block(block) = node { diff --git a/src/tools/clippy/clippy_lints/src/new_without_default.rs b/src/tools/clippy/clippy_lints/src/new_without_default.rs index cf407e51f7a..f0ee613791f 100644 --- a/src/tools/clippy/clippy_lints/src/new_without_default.rs +++ b/src/tools/clippy/clippy_lints/src/new_without_default.rs @@ -90,7 +90,7 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault { if sig.decl.inputs.is_empty() && name == sym::new && cx.effective_visibilities.is_reachable(impl_item.owner_id.def_id) - && let self_def_id = cx.tcx.hir().get_parent_item(id.into()) + && let self_def_id = cx.tcx.hir_get_parent_item(id.into()) && let self_ty = cx.tcx.type_of(self_def_id).instantiate_identity() && self_ty == return_ty(cx, id) && let Some(default_trait_id) = cx.tcx.get_diagnostic_item(sym::Default) diff --git a/src/tools/clippy/clippy_lints/src/no_effect.rs b/src/tools/clippy/clippy_lints/src/no_effect.rs index 4d3e6aa79d0..7187a8f2c11 100644 --- a/src/tools/clippy/clippy_lints/src/no_effect.rs +++ b/src/tools/clippy/clippy_lints/src/no_effect.rs @@ -141,7 +141,7 @@ impl NoEffect { stmt.span, "statement with no effect", |diag| { - for parent in cx.tcx.hir().parent_iter(stmt.hir_id) { + for parent in cx.tcx.hir_parent_iter(stmt.hir_id) { if let Node::Item(item) = parent.1 && let ItemKind::Fn { .. } = item.kind && let Node::Block(block) = cx.tcx.parent_hir_node(stmt.hir_id) diff --git a/src/tools/clippy/clippy_lints/src/non_copy_const.rs b/src/tools/clippy/clippy_lints/src/non_copy_const.rs index f965ab90da2..4007ca88a00 100644 --- a/src/tools/clippy/clippy_lints/src/non_copy_const.rs +++ b/src/tools/clippy/clippy_lints/src/non_copy_const.rs @@ -344,7 +344,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst<'tcx> { fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx ImplItem<'_>) { if let ImplItemKind::Const(_, body_id) = &impl_item.kind { - let item_def_id = cx.tcx.hir().get_parent_item(impl_item.hir_id()).def_id; + let item_def_id = cx.tcx.hir_get_parent_item(impl_item.hir_id()).def_id; let item = cx.tcx.hir().expect_item(item_def_id); match &item.kind { diff --git a/src/tools/clippy/clippy_lints/src/non_zero_suggestions.rs b/src/tools/clippy/clippy_lints/src/non_zero_suggestions.rs index f6ce1d1d586..16c4391c0fb 100644 --- a/src/tools/clippy/clippy_lints/src/non_zero_suggestions.rs +++ b/src/tools/clippy/clippy_lints/src/non_zero_suggestions.rs @@ -55,7 +55,7 @@ impl<'tcx> LateLintPass<'tcx> for NonZeroSuggestions { check_non_zero_conversion(cx, rhs, Applicability::MachineApplicable); } else { // Check if the parent expression is a binary operation - let parent_is_binary = cx.tcx.hir().parent_iter(expr.hir_id).any(|(_, node)| { + let parent_is_binary = cx.tcx.hir_parent_iter(expr.hir_id).any(|(_, node)| { matches!(node, rustc_hir::Node::Expr(parent_expr) if matches!(parent_expr.kind, ExprKind::Binary(..))) }); diff --git a/src/tools/clippy/clippy_lints/src/operators/assign_op_pattern.rs b/src/tools/clippy/clippy_lints/src/operators/assign_op_pattern.rs index 1315c3dfc12..5737a91031d 100644 --- a/src/tools/clippy/clippy_lints/src/operators/assign_op_pattern.rs +++ b/src/tools/clippy/clippy_lints/src/operators/assign_op_pattern.rs @@ -26,7 +26,7 @@ pub(super) fn check<'tcx>( let rty = cx.typeck_results().expr_ty(rhs); if let Some((_, lang_item)) = binop_traits(op.node) && let Some(trait_id) = cx.tcx.lang_items().get(lang_item) - && let parent_fn = cx.tcx.hir().get_parent_item(e.hir_id).def_id + && let parent_fn = cx.tcx.hir_get_parent_item(e.hir_id).def_id && trait_ref_of_method(cx, parent_fn).is_none_or(|t| t.path.res.def_id() != trait_id) && implements_trait(cx, ty, trait_id, &[rty.into()]) { diff --git a/src/tools/clippy/clippy_lints/src/operators/identity_op.rs b/src/tools/clippy/clippy_lints/src/operators/identity_op.rs index 1c2d6e90fc9..03582322827 100644 --- a/src/tools/clippy/clippy_lints/src/operators/identity_op.rs +++ b/src/tools/clippy/clippy_lints/src/operators/identity_op.rs @@ -120,7 +120,7 @@ fn needs_parenthesis(cx: &LateContext<'_>, binary: &Expr<'_>, child: &Expr<'_>) // the parent HIR node is an expression, or if the parent HIR node // is a Block or Stmt, and the new left hand side would need // parenthesis be treated as a statement rather than an expression. - if let Some((_, parent)) = cx.tcx.hir().parent_iter(binary.hir_id).next() { + if let Some((_, parent)) = cx.tcx.hir_parent_iter(binary.hir_id).next() { match parent { Node::Expr(_) => return Parens::Needed, Node::Block(_) | Node::Stmt(_) => { @@ -142,7 +142,7 @@ fn needs_parenthesis(cx: &LateContext<'_>, binary: &Expr<'_>, child: &Expr<'_>) // This would mean that the rustfix suggestion will appear at the start of a line, which causes // these expressions to be interpreted as statements if they do not have parenthesis. let mut prev_id = binary.hir_id; - for (_, parent) in cx.tcx.hir().parent_iter(binary.hir_id) { + for (_, parent) in cx.tcx.hir_parent_iter(binary.hir_id) { if let Node::Expr(expr) = parent && let ExprKind::Binary(_, lhs, _) | ExprKind::Cast(lhs, _) | ExprKind::Unary(_, lhs) = expr.kind && lhs.hir_id == prev_id diff --git a/src/tools/clippy/clippy_lints/src/panic_unimplemented.rs b/src/tools/clippy/clippy_lints/src/panic_unimplemented.rs index fa5b02a5a41..c9bdeed660e 100644 --- a/src/tools/clippy/clippy_lints/src/panic_unimplemented.rs +++ b/src/tools/clippy/clippy_lints/src/panic_unimplemented.rs @@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for PanicUnimplemented { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { if let Some(macro_call) = root_macro_call_first_node(cx, expr) { if is_panic(cx, macro_call.def_id) { - if cx.tcx.hir().is_inside_const_context(expr.hir_id) + if cx.tcx.hir_is_inside_const_context(expr.hir_id) || self.allow_panic_in_tests && is_in_test(cx.tcx, expr.hir_id) { return; @@ -139,7 +139,7 @@ impl<'tcx> LateLintPass<'tcx> for PanicUnimplemented { && let Res::Def(DefKind::Fn, def_id) = expr_path.res && match_def_path(cx, def_id, &paths::PANIC_ANY) { - if cx.tcx.hir().is_inside_const_context(expr.hir_id) + if cx.tcx.hir_is_inside_const_context(expr.hir_id) || self.allow_panic_in_tests && is_in_test(cx.tcx, expr.hir_id) { return; diff --git a/src/tools/clippy/clippy_lints/src/ptr.rs b/src/tools/clippy/clippy_lints/src/ptr.rs index 9b241edf4cc..ef4948a05b7 100644 --- a/src/tools/clippy/clippy_lints/src/ptr.rs +++ b/src/tools/clippy/clippy_lints/src/ptr.rs @@ -186,8 +186,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr { } fn check_body(&mut self, cx: &LateContext<'tcx>, body: &Body<'tcx>) { - let hir = cx.tcx.hir(); - let mut parents = hir.parent_iter(body.value.hir_id); + let mut parents = cx.tcx.hir_parent_iter(body.value.hir_id); let (item_id, sig, is_trait_item) = match parents.next() { Some((_, Node::Item(i))) => { if let ItemKind::Fn { sig, .. } = &i.kind { diff --git a/src/tools/clippy/clippy_lints/src/redundant_clone.rs b/src/tools/clippy/clippy_lints/src/redundant_clone.rs index fb1bc494bd9..cfa622aea58 100644 --- a/src/tools/clippy/clippy_lints/src/redundant_clone.rs +++ b/src/tools/clippy/clippy_lints/src/redundant_clone.rs @@ -205,7 +205,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClone { let node = mir.source_scopes[scope] .local_data .as_ref() - .assert_crate_local() + .unwrap_crate_local() .lint_root; if let Some(snip) = span.get_source_text(cx) diff --git a/src/tools/clippy/clippy_lints/src/redundant_locals.rs b/src/tools/clippy/clippy_lints/src/redundant_locals.rs index e15e1262920..f3ccc9e38f4 100644 --- a/src/tools/clippy/clippy_lints/src/redundant_locals.rs +++ b/src/tools/clippy/clippy_lints/src/redundant_locals.rs @@ -122,8 +122,7 @@ fn find_binding(pat: &Pat<'_>, name: Ident) -> Option<BindingMode> { /// Check if a rebinding of a local changes the effect of assignments to the binding. fn affects_assignments(cx: &LateContext<'_>, mutability: Mutability, bind: HirId, rebind: HirId) -> bool { - let hir = cx.tcx.hir(); - // the binding is mutable and the rebinding is in a different scope than the original binding - mutability == Mutability::Mut && hir.get_enclosing_scope(bind) != hir.get_enclosing_scope(rebind) + mutability == Mutability::Mut + && cx.tcx.hir_get_enclosing_scope(bind) != cx.tcx.hir_get_enclosing_scope(rebind) } diff --git a/src/tools/clippy/clippy_lints/src/returns.rs b/src/tools/clippy/clippy_lints/src/returns.rs index 9f0ea84246d..152739c2973 100644 --- a/src/tools/clippy/clippy_lints/src/returns.rs +++ b/src/tools/clippy/clippy_lints/src/returns.rs @@ -177,8 +177,7 @@ declare_lint_pass!(Return => [LET_AND_RETURN, NEEDLESS_RETURN, NEEDLESS_RETURN_W /// because of the never-ness of `return` expressions fn stmt_needs_never_type(cx: &LateContext<'_>, stmt_hir_id: HirId) -> bool { cx.tcx - .hir() - .parent_iter(stmt_hir_id) + .hir_parent_iter(stmt_hir_id) .find_map(|(_, node)| if let Node::Expr(expr) = node { Some(expr) } else { None }) .is_some_and(|e| { cx.typeck_results() @@ -203,7 +202,7 @@ impl<'tcx> LateLintPass<'tcx> for Return { && is_res_lang_ctor(cx, path_res(cx, maybe_constr), ResultErr) // Ensure this is not the final stmt, otherwise removing it would cause a compile error - && let OwnerNode::Item(item) = cx.tcx.hir_owner_node(cx.tcx.hir().get_parent_item(expr.hir_id)) + && let OwnerNode::Item(item) = cx.tcx.hir_owner_node(cx.tcx.hir_get_parent_item(expr.hir_id)) && let ItemKind::Fn { body, .. } = item.kind && let block = cx.tcx.hir_body(body).value && let ExprKind::Block(block, _) = block.kind diff --git a/src/tools/clippy/clippy_lints/src/self_named_constructors.rs b/src/tools/clippy/clippy_lints/src/self_named_constructors.rs index 23b47606f8a..fc02c3a5171 100644 --- a/src/tools/clippy/clippy_lints/src/self_named_constructors.rs +++ b/src/tools/clippy/clippy_lints/src/self_named_constructors.rs @@ -51,7 +51,7 @@ impl<'tcx> LateLintPass<'tcx> for SelfNamedConstructors { _ => return, } - let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id()).def_id; + let parent = cx.tcx.hir_get_parent_item(impl_item.hir_id()).def_id; let item = cx.tcx.hir().expect_item(parent); let self_ty = cx.tcx.type_of(item.owner_id).instantiate_identity(); let ret_ty = return_ty(cx, impl_item.owner_id); diff --git a/src/tools/clippy/clippy_lints/src/shadow.rs b/src/tools/clippy/clippy_lints/src/shadow.rs index a931e39bac9..ee282ee1dfb 100644 --- a/src/tools/clippy/clippy_lints/src/shadow.rs +++ b/src/tools/clippy/clippy_lints/src/shadow.rs @@ -224,9 +224,9 @@ fn lint_shadow(cx: &LateContext<'_>, pat: &Pat<'_>, shadowed: HirId, span: Span) /// Returns true if the expression is a simple transformation of a local binding such as `&x` fn is_self_shadow(cx: &LateContext<'_>, pat: &Pat<'_>, mut expr: &Expr<'_>, hir_id: HirId) -> bool { - let hir = cx.tcx.hir(); - let is_direct_binding = hir - .parent_iter(pat.hir_id) + let is_direct_binding = cx + .tcx + .hir_parent_iter(pat.hir_id) .map_while(|(_id, node)| match node { Node::Pat(pat) => Some(pat), _ => None, @@ -259,14 +259,14 @@ fn is_self_shadow(cx: &LateContext<'_>, pat: &Pat<'_>, mut expr: &Expr<'_>, hir_ /// For closure arguments passed to a method call, returns the method call, and the `HirId` of the /// closure (which will later be skipped). This is for <https://github.com/rust-lang/rust-clippy/issues/10780> fn find_init<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<(&'tcx Expr<'tcx>, Option<HirId>)> { - for (hir_id, node) in cx.tcx.hir().parent_iter(hir_id) { + for (hir_id, node) in cx.tcx.hir_parent_iter(hir_id) { let init = match node { Node::Arm(_) | Node::Pat(_) | Node::PatField(_) | Node::Param(_) => continue, Node::Expr(expr) => match expr.kind { ExprKind::Match(e, _, _) | ExprKind::Let(&LetExpr { init: e, .. }) => Some((e, None)), // If we're a closure argument, then a parent call is also an associated item. ExprKind::Closure(_) => { - if let Some((_, node)) = cx.tcx.hir().parent_iter(hir_id).next() { + if let Some((_, node)) = cx.tcx.hir_parent_iter(hir_id).next() { match node { Node::Expr(expr) => match expr.kind { ExprKind::MethodCall(_, _, _, _) | ExprKind::Call(_, _) => Some((expr, Some(hir_id))), diff --git a/src/tools/clippy/clippy_lints/src/significant_drop_tightening.rs b/src/tools/clippy/clippy_lints/src/significant_drop_tightening.rs index 597bfddecbc..e9db7c9d031 100644 --- a/src/tools/clippy/clippy_lints/src/significant_drop_tightening.rs +++ b/src/tools/clippy/clippy_lints/src/significant_drop_tightening.rs @@ -232,8 +232,7 @@ impl<'ap, 'lc, 'others, 'stmt, 'tcx> StmtsChecker<'ap, 'lc, 'others, 'stmt, 'tcx let block_is_ancestor = self .cx .tcx - .hir() - .parent_iter(self.ap.curr_block_hir_id) + .hir_parent_iter(self.ap.curr_block_hir_id) .any(|(id, _)| id == apa.first_block_hir_id); if last_stmt_is_not_dummy && last_stmt_is_not_curr && (block_equals_curr || block_is_ancestor) { apa.has_expensive_expr_after_last_attr = true; diff --git a/src/tools/clippy/clippy_lints/src/suspicious_trait_impl.rs b/src/tools/clippy/clippy_lints/src/suspicious_trait_impl.rs index 9326b2adaff..fb426e91bf0 100644 --- a/src/tools/clippy/clippy_lints/src/suspicious_trait_impl.rs +++ b/src/tools/clippy/clippy_lints/src/suspicious_trait_impl.rs @@ -63,11 +63,11 @@ impl<'tcx> LateLintPass<'tcx> for SuspiciousImpl { // Check for more than one binary operation in the implemented function // Linting when multiple operations are involved can result in false positives - && let parent_fn = cx.tcx.hir().get_parent_item(expr.hir_id).def_id + && let parent_fn = cx.tcx.hir_get_parent_item(expr.hir_id).def_id && let hir::Node::ImplItem(impl_item) = cx.tcx.hir_node_by_def_id(parent_fn) && let hir::ImplItemKind::Fn(_, body_id) = impl_item.kind && let body = cx.tcx.hir_body(body_id) - && let parent_fn = cx.tcx.hir().get_parent_item(expr.hir_id).def_id + && let parent_fn = cx.tcx.hir_get_parent_item(expr.hir_id).def_id && let Some(trait_ref) = trait_ref_of_method(cx, parent_fn) && let trait_id = trait_ref.path.res.def_id() && ![binop_trait_id, op_assign_trait_id].contains(&trait_id) diff --git a/src/tools/clippy/clippy_lints/src/transmute/eager_transmute.rs b/src/tools/clippy/clippy_lints/src/transmute/eager_transmute.rs index 1209bd5b34f..81c0a57083e 100644 --- a/src/tools/clippy/clippy_lints/src/transmute/eager_transmute.rs +++ b/src/tools/clippy/clippy_lints/src/transmute/eager_transmute.rs @@ -10,7 +10,7 @@ use rustc_middle::ty::Ty; use super::EAGER_TRANSMUTE; fn peel_parent_unsafe_blocks<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Option<&'tcx Expr<'tcx>> { - for (_, parent) in cx.tcx.hir().parent_iter(expr.hir_id) { + for (_, parent) in cx.tcx.hir_parent_iter(expr.hir_id) { match parent { Node::Block(_) => {}, Node::Expr(e) if let ExprKind::Block(..) = e.kind => {}, diff --git a/src/tools/clippy/clippy_lints/src/transmute/missing_transmute_annotations.rs b/src/tools/clippy/clippy_lints/src/transmute/missing_transmute_annotations.rs index 0b5d83ef58c..96286fcf73d 100644 --- a/src/tools/clippy/clippy_lints/src/transmute/missing_transmute_annotations.rs +++ b/src/tools/clippy/clippy_lints/src/transmute/missing_transmute_annotations.rs @@ -7,7 +7,7 @@ use rustc_middle::ty::Ty; use crate::transmute::MISSING_TRANSMUTE_ANNOTATIONS; fn get_parent_local_binding_ty<'tcx>(cx: &LateContext<'tcx>, expr_hir_id: HirId) -> Option<LetStmt<'tcx>> { - let mut parent_iter = cx.tcx.hir().parent_iter(expr_hir_id); + let mut parent_iter = cx.tcx.hir_parent_iter(expr_hir_id); if let Some((_, node)) = parent_iter.next() { match node { Node::LetStmt(local) => Some(*local), diff --git a/src/tools/clippy/clippy_lints/src/types/mod.rs b/src/tools/clippy/clippy_lints/src/types/mod.rs index 579cbf447a2..71e6e75c1bd 100644 --- a/src/tools/clippy/clippy_lints/src/types/mod.rs +++ b/src/tools/clippy/clippy_lints/src/types/mod.rs @@ -375,8 +375,7 @@ impl<'tcx> LateLintPass<'tcx> for Types { ) { let is_in_trait_impl = if let hir::Node::Item(item) = cx.tcx.hir_node_by_def_id( cx.tcx - .hir() - .get_parent_item(cx.tcx.local_def_id_to_hir_id(def_id)) + .hir_get_parent_item(cx.tcx.local_def_id_to_hir_id(def_id)) .def_id, ) { matches!(item.kind, ItemKind::Impl(hir::Impl { of_trait: Some(_), .. })) @@ -420,7 +419,7 @@ impl<'tcx> LateLintPass<'tcx> for Types { ImplItemKind::Const(ty, _) => { let is_in_trait_impl = if let hir::Node::Item(item) = cx .tcx - .hir_node_by_def_id(cx.tcx.hir().get_parent_item(item.hir_id()).def_id) + .hir_node_by_def_id(cx.tcx.hir_get_parent_item(item.hir_id()).def_id) { matches!(item.kind, ItemKind::Impl(hir::Impl { of_trait: Some(_), .. })) } else { diff --git a/src/tools/clippy/clippy_lints/src/unconditional_recursion.rs b/src/tools/clippy/clippy_lints/src/unconditional_recursion.rs index 76a0b927df4..a443043bef9 100644 --- a/src/tools/clippy/clippy_lints/src/unconditional_recursion.rs +++ b/src/tools/clippy/clippy_lints/src/unconditional_recursion.rs @@ -111,7 +111,7 @@ fn get_impl_trait_def_id(cx: &LateContext<'_>, method_def_id: LocalDefId) -> Opt owner_id, .. }), - )) = cx.tcx.hir().parent_iter(hir_id).next() + )) = cx.tcx.hir_parent_iter(hir_id).next() // We exclude `impl` blocks generated from rustc's proc macros. && !cx.tcx.has_attr(*owner_id, sym::automatically_derived) // It is a implementation of a trait. @@ -216,7 +216,7 @@ fn check_to_string(cx: &LateContext<'_>, method_span: Span, method_def_id: Local owner_id, .. }), - )) = cx.tcx.hir().parent_iter(hir_id).next() + )) = cx.tcx.hir_parent_iter(hir_id).next() // We exclude `impl` blocks generated from rustc's proc macros. && !cx.tcx.has_attr(*owner_id, sym::automatically_derived) // It is a implementation of a trait. @@ -367,7 +367,7 @@ impl UnconditionalRecursion { kind: ItemKind::Impl(impl_), .. }), - )) = cx.tcx.hir().parent_iter(hir_id).next() + )) = cx.tcx.hir_parent_iter(hir_id).next() && let Some(implemented_ty_id) = get_hir_ty_def_id(cx.tcx, *impl_.self_ty) && { self.init_default_impl_for_type_if_needed(cx); diff --git a/src/tools/clippy/clippy_lints/src/undocumented_unsafe_blocks.rs b/src/tools/clippy/clippy_lints/src/undocumented_unsafe_blocks.rs index c8e3c46f2f6..93abf95e357 100644 --- a/src/tools/clippy/clippy_lints/src/undocumented_unsafe_blocks.rs +++ b/src/tools/clippy/clippy_lints/src/undocumented_unsafe_blocks.rs @@ -291,7 +291,7 @@ fn expr_has_unnecessary_safety_comment<'tcx>( expr: &'tcx hir::Expr<'tcx>, comment_pos: BytePos, ) -> Option<Span> { - if cx.tcx.hir().parent_iter(expr.hir_id).any(|(_, ref node)| { + if cx.tcx.hir_parent_iter(expr.hir_id).any(|(_, ref node)| { matches!( node, Node::Block(Block { @@ -604,10 +604,9 @@ fn span_from_macro_expansion_has_safety_comment(cx: &LateContext<'_>, span: Span fn get_body_search_span(cx: &LateContext<'_>) -> Option<Span> { let body = cx.enclosing_body?; - let map = cx.tcx.hir(); let mut span = cx.tcx.hir_body(body).value.span; let mut maybe_global_var = false; - for (_, node) in map.parent_iter(body.hir_id) { + for (_, node) in cx.tcx.hir_parent_iter(body.hir_id) { match node { Node::Expr(e) => span = e.span, Node::Block(_) | Node::Arm(_) | Node::Stmt(_) | Node::LetStmt(_) => (), diff --git a/src/tools/clippy/clippy_lints/src/unused_io_amount.rs b/src/tools/clippy/clippy_lints/src/unused_io_amount.rs index e65123b8a94..0687fc319af 100644 --- a/src/tools/clippy/clippy_lints/src/unused_io_amount.rs +++ b/src/tools/clippy/clippy_lints/src/unused_io_amount.rs @@ -224,7 +224,7 @@ fn is_unreachable_or_panic(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool { return false; }; if is_panic(cx, macro_call.def_id) { - return !cx.tcx.hir().is_inside_const_context(expr.hir_id); + return !cx.tcx.hir_is_inside_const_context(expr.hir_id); } matches!(cx.tcx.item_name(macro_call.def_id).as_str(), "unreachable") } diff --git a/src/tools/clippy/clippy_lints/src/unused_peekable.rs b/src/tools/clippy/clippy_lints/src/unused_peekable.rs index 0f9b05c84d4..7487e273caa 100644 --- a/src/tools/clippy/clippy_lints/src/unused_peekable.rs +++ b/src/tools/clippy/clippy_lints/src/unused_peekable.rs @@ -118,7 +118,7 @@ impl<'tcx> Visitor<'tcx> for PeekableVisitor<'_, 'tcx> { fn visit_expr(&mut self, ex: &'tcx Expr<'tcx>) -> ControlFlow<()> { if path_to_local_id(ex, self.expected_hir_id) { - for (_, node) in self.cx.tcx.hir().parent_iter(ex.hir_id) { + for (_, node) in self.cx.tcx.hir_parent_iter(ex.hir_id) { match node { Node::Expr(expr) => { match expr.kind { diff --git a/src/tools/clippy/clippy_lints/src/unused_self.rs b/src/tools/clippy/clippy_lints/src/unused_self.rs index d8305a62829..2c6c7569316 100644 --- a/src/tools/clippy/clippy_lints/src/unused_self.rs +++ b/src/tools/clippy/clippy_lints/src/unused_self.rs @@ -56,7 +56,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedSelf { if impl_item.span.from_expansion() { return; } - let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id()).def_id; + let parent = cx.tcx.hir_get_parent_item(impl_item.hir_id()).def_id; let parent_item = cx.tcx.hir().expect_item(parent); let assoc_item = cx.tcx.associated_item(impl_item.owner_id); let contains_todo = |cx, body: &'_ Body<'_>| -> bool { diff --git a/src/tools/clippy/clippy_lints/src/zero_sized_map_values.rs b/src/tools/clippy/clippy_lints/src/zero_sized_map_values.rs index 1221abec1ab..4c9a7f0e16d 100644 --- a/src/tools/clippy/clippy_lints/src/zero_sized_map_values.rs +++ b/src/tools/clippy/clippy_lints/src/zero_sized_map_values.rs @@ -73,8 +73,8 @@ impl LateLintPass<'_> for ZeroSizedMapValues { } fn in_trait_impl(cx: &LateContext<'_>, hir_id: HirId) -> bool { - let parent_id = cx.tcx.hir().get_parent_item(hir_id); - let second_parent_id = cx.tcx.hir().get_parent_item(parent_id.into()).def_id; + let parent_id = cx.tcx.hir_get_parent_item(hir_id); + let second_parent_id = cx.tcx.hir_get_parent_item(parent_id.into()).def_id; if let Node::Item(item) = cx.tcx.hir_node_by_def_id(second_parent_id) { if let ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }) = item.kind { return true; diff --git a/src/tools/clippy/clippy_utils/src/higher.rs b/src/tools/clippy/clippy_utils/src/higher.rs index 6bb876322f2..c4d00002292 100644 --- a/src/tools/clippy/clippy_utils/src/higher.rs +++ b/src/tools/clippy/clippy_utils/src/higher.rs @@ -117,7 +117,7 @@ impl<'hir> IfLet<'hir> { if_else, ) = expr.kind { - let mut iter = cx.tcx.hir().parent_iter(expr.hir_id); + let mut iter = cx.tcx.hir_parent_iter(expr.hir_id); if let Some((_, Node::Block(Block { stmts: [], .. }))) = iter.next() { if let Some(( _, diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index 15e395731ad..40ddd75b7fa 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -212,7 +212,7 @@ pub fn find_binding_init<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option< /// /// e.g. returns true for `x` in `fn f(x: usize) { .. }` and `let x = 1;` but false for `let x;` pub fn local_is_initialized(cx: &LateContext<'_>, local: HirId) -> bool { - for (_, node) in cx.tcx.hir().parent_iter(local) { + for (_, node) in cx.tcx.hir_parent_iter(local) { match node { Node::Pat(..) | Node::PatField(..) => {}, Node::LetStmt(let_stmt) => return let_stmt.init.is_some(), @@ -227,7 +227,7 @@ pub fn local_is_initialized(cx: &LateContext<'_>, local: HirId) -> bool { /// /// The current context is determined based on the current body which is set before calling a lint's /// entry point (any function on `LateLintPass`). If you need to check in a different context use -/// `tcx.hir().is_inside_const_context(_)`. +/// `tcx.hir_is_inside_const_context(_)`. /// /// Do not call this unless the `LateContext` has an enclosing body. For release build this case /// will safely return `false`, but debug builds will ICE. Note that `check_expr`, `check_block`, @@ -806,7 +806,7 @@ pub fn get_trait_def_id(tcx: TyCtxt<'_>, path: &[&str]) -> Option<DefId> { pub fn trait_ref_of_method<'tcx>(cx: &LateContext<'tcx>, def_id: LocalDefId) -> Option<&'tcx TraitRef<'tcx>> { // Get the implemented trait for the current function let hir_id = cx.tcx.local_def_id_to_hir_id(def_id); - let parent_impl = cx.tcx.hir().get_parent_item(hir_id); + let parent_impl = cx.tcx.hir_get_parent_item(hir_id); if parent_impl != hir::CRATE_OWNER_ID && let Node::Item(item) = cx.tcx.hir_node_by_def_id(parent_impl.def_id) && let ItemKind::Impl(impl_) = &item.kind @@ -1117,7 +1117,7 @@ pub fn capture_local_usage(cx: &LateContext<'_>, e: &Expr<'_>) -> CaptureKind { let mut capture = CaptureKind::Value; let mut capture_expr_ty = e; - for (parent_id, parent) in cx.tcx.hir().parent_iter(e.hir_id) { + for (parent_id, parent) in cx.tcx.hir_parent_iter(e.hir_id) { if let [ Adjustment { kind: Adjust::Deref(_) | Adjust::Borrow(AutoBorrow::Ref(..)), @@ -1336,13 +1336,13 @@ pub fn is_entrypoint_fn(cx: &LateContext<'_>, def_id: DefId) -> bool { /// Returns `true` if the expression is in the program's `#[panic_handler]`. pub fn is_in_panic_handler(cx: &LateContext<'_>, e: &Expr<'_>) -> bool { - let parent = cx.tcx.hir().get_parent_item(e.hir_id); + let parent = cx.tcx.hir_get_parent_item(e.hir_id); Some(parent.to_def_id()) == cx.tcx.lang_items().panic_impl() } /// Gets the name of the item the expression is in, if available. pub fn get_item_name(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<Symbol> { - let parent_id = cx.tcx.hir().get_parent_item(expr.hir_id).def_id; + let parent_id = cx.tcx.hir_get_parent_item(expr.hir_id).def_id; match cx.tcx.hir_node_by_def_id(parent_id) { Node::Item(Item { ident, .. }) | Node::TraitItem(TraitItem { ident, .. }) @@ -1407,9 +1407,9 @@ pub fn get_parent_expr_for_hir<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> O /// Gets the enclosing block, if any. pub fn get_enclosing_block<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<&'tcx Block<'tcx>> { - let map = &cx.tcx.hir(); - let enclosing_node = map - .get_enclosing_scope(hir_id) + let enclosing_node = cx + .tcx + .hir_get_enclosing_scope(hir_id) .map(|enclosing_id| cx.tcx.hir_node(enclosing_id)); enclosing_node.and_then(|node| match node { Node::Block(block) => Some(block), @@ -1433,7 +1433,7 @@ pub fn get_enclosing_loop_or_multi_call_closure<'tcx>( cx: &LateContext<'tcx>, expr: &Expr<'_>, ) -> Option<&'tcx Expr<'tcx>> { - for (_, node) in cx.tcx.hir().parent_iter(expr.hir_id) { + for (_, node) in cx.tcx.hir_parent_iter(expr.hir_id) { match node { Node::Expr(e) => match e.kind { ExprKind::Closure { .. } @@ -1453,7 +1453,7 @@ pub fn get_enclosing_loop_or_multi_call_closure<'tcx>( /// Gets the parent node if it's an impl block. pub fn get_parent_as_impl(tcx: TyCtxt<'_>, id: HirId) -> Option<&Impl<'_>> { - match tcx.hir().parent_iter(id).next() { + match tcx.hir_parent_iter(id).next() { Some(( _, Node::Item(Item { @@ -1531,7 +1531,7 @@ pub fn peel_blocks_with_stmt<'a>(mut expr: &'a Expr<'a>) -> &'a Expr<'a> { /// Checks if the given expression is the else clause of either an `if` or `if let` expression. pub fn is_else_clause(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool { - let mut iter = tcx.hir().parent_iter(expr.hir_id); + let mut iter = tcx.hir_parent_iter(expr.hir_id); match iter.next() { Some(( _, @@ -1548,7 +1548,7 @@ pub fn is_else_clause(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool { /// returns `true` for both the `init` and the `else` part pub fn is_inside_let_else(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool { let mut child_id = expr.hir_id; - for (parent_id, node) in tcx.hir().parent_iter(child_id) { + for (parent_id, node) in tcx.hir_parent_iter(child_id) { if let Node::LetStmt(LetStmt { init: Some(init), els: Some(els), @@ -1568,7 +1568,7 @@ pub fn is_inside_let_else(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool { /// Checks if the given expression is the else clause of a `let else` expression pub fn is_else_clause_in_let_else(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool { let mut child_id = expr.hir_id; - for (parent_id, node) in tcx.hir().parent_iter(child_id) { + for (parent_id, node) in tcx.hir_parent_iter(child_id) { if let Node::LetStmt(LetStmt { els: Some(els), .. }) = node && els.hir_id == child_id { @@ -1961,7 +1961,7 @@ pub fn any_parent_has_attr(tcx: TyCtxt<'_>, node: HirId, symbol: Symbol) -> bool return true; } prev_enclosing_node = Some(enclosing_node); - enclosing_node = map.get_parent_item(enclosing_node).into(); + enclosing_node = tcx.hir_get_parent_item(enclosing_node).into(); } false @@ -1970,8 +1970,8 @@ pub fn any_parent_has_attr(tcx: TyCtxt<'_>, node: HirId, symbol: Symbol) -> bool /// Checks if the given HIR node is inside an `impl` block with the `automatically_derived` /// attribute. pub fn in_automatically_derived(tcx: TyCtxt<'_>, id: HirId) -> bool { - tcx.hir() - .parent_owner_iter(id) + tcx + .hir_parent_owner_iter(id) .filter(|(_, node)| matches!(node, OwnerNode::Item(item) if matches!(item.kind, ItemKind::Impl(_)))) .any(|(id, _)| { has_attr( @@ -2202,7 +2202,7 @@ pub fn is_expr_identity_function(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool /// Returns both the node and the `HirId` of the closest child node. pub fn get_expr_use_or_unification_node<'tcx>(tcx: TyCtxt<'tcx>, expr: &Expr<'_>) -> Option<(Node<'tcx>, HirId)> { let mut child_id = expr.hir_id; - let mut iter = tcx.hir().parent_iter(child_id); + let mut iter = tcx.hir_parent_iter(child_id); loop { match iter.next() { None => break None, @@ -2581,7 +2581,7 @@ pub fn is_in_test_function(tcx: TyCtxt<'_>, id: HirId) -> bool { with_test_item_names(tcx, tcx.parent_module(id), |names| { let node = tcx.hir_node(id); once((id, node)) - .chain(tcx.hir().parent_iter(id)) + .chain(tcx.hir_parent_iter(id)) // Since you can nest functions we need to collect all until we leave // function scope .any(|(_id, node)| { @@ -2617,8 +2617,8 @@ pub fn is_cfg_test(tcx: TyCtxt<'_>, id: HirId) -> bool { /// Checks if any parent node of `HirId` has `#[cfg(test)]` attribute applied pub fn is_in_cfg_test(tcx: TyCtxt<'_>, id: HirId) -> bool { - tcx.hir() - .parent_id_iter(id) + tcx + .hir_parent_id_iter(id) .any(|parent_id| is_cfg_test(tcx, parent_id)) } @@ -2632,8 +2632,8 @@ pub fn inherits_cfg(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { let hir = tcx.hir(); tcx.has_attr(def_id, sym::cfg) - || hir - .parent_iter(tcx.local_def_id_to_hir_id(def_id)) + || tcx + .hir_parent_iter(tcx.local_def_id_to_hir_id(def_id)) .flat_map(|(parent_id, _)| hir.attrs(parent_id)) .any(|attr| attr.has_name(sym::cfg)) } @@ -2653,8 +2653,7 @@ pub fn walk_to_expr_usage<'tcx, T>( e: &Expr<'tcx>, mut f: impl FnMut(HirId, Node<'tcx>, HirId) -> ControlFlow<T>, ) -> Option<ControlFlow<T, (Node<'tcx>, HirId)>> { - let map = cx.tcx.hir(); - let mut iter = map.parent_iter(e.hir_id); + let mut iter = cx.tcx.hir_parent_iter(e.hir_id); let mut child_id = e.hir_id; while let Some((parent_id, parent)) = iter.next() { @@ -2677,7 +2676,7 @@ pub fn walk_to_expr_usage<'tcx, T>( ExprKind::If(child, ..) | ExprKind::Match(child, ..) if child.hir_id != child_id => child_id = parent_id, ExprKind::Break(Destination { target_id: Ok(id), .. }, _) => { child_id = id; - iter = map.parent_iter(id); + iter = cx.tcx.hir_parent_iter(id); }, ExprKind::Block(..) | ExprKind::DropTemps(_) => child_id = parent_id, _ => return Some(ControlFlow::Continue((parent, child_id))), diff --git a/src/tools/clippy/clippy_utils/src/macros.rs b/src/tools/clippy/clippy_utils/src/macros.rs index 30fd48fc060..9ce0fd8318f 100644 --- a/src/tools/clippy/clippy_utils/src/macros.rs +++ b/src/tools/clippy/clippy_utils/src/macros.rs @@ -178,7 +178,7 @@ pub fn first_node_in_macro(cx: &LateContext<'_>, node: &impl HirNode) -> Option< // get the parent node, possibly skipping over a statement // if the parent is not found, it is sensible to return `Some(root)` let hir = cx.tcx.hir(); - let mut parent_iter = hir.parent_iter(node.hir_id()); + let mut parent_iter = cx.tcx.hir_parent_iter(node.hir_id()); let (parent_id, _) = match parent_iter.next() { None => return Some(ExpnId::root()), Some((_, Node::Stmt(_))) => match parent_iter.next() { diff --git a/src/tools/clippy/clippy_utils/src/mir/mod.rs b/src/tools/clippy/clippy_utils/src/mir/mod.rs index 637c0bafd96..ffcfcd240ea 100644 --- a/src/tools/clippy/clippy_utils/src/mir/mod.rs +++ b/src/tools/clippy/clippy_utils/src/mir/mod.rs @@ -30,7 +30,7 @@ pub fn visit_local_usage(locals: &[Local], mir: &Body<'_>, location: Location) - locals.len() ]; - traversal::Postorder::new(&mir.basic_blocks, location.block, ()) + traversal::Postorder::new(&mir.basic_blocks, location.block, None) .collect::<Vec<_>>() .into_iter() .rev() diff --git a/src/tools/clippy/tests/ui/async_yields_async.stderr b/src/tools/clippy/tests/ui/async_yields_async.stderr index 474914299d0..8c023d0d61f 100644 --- a/src/tools/clippy/tests/ui/async_yields_async.stderr +++ b/src/tools/clippy/tests/ui/async_yields_async.stderr @@ -14,9 +14,9 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::async_yields_async)]` help: consider awaiting this value | -LL ~ async { -LL + 3 -LL + }.await +LL | async { +LL | 3 +LL ~ }.await | error: an async construct yields a type which is itself awaitable @@ -46,9 +46,9 @@ LL | | }; | help: consider awaiting this value | -LL ~ async { -LL + 3 -LL + }.await +LL | async { +LL | 3 +LL ~ }.await | error: an async construct yields a type which is itself awaitable diff --git a/src/tools/clippy/tests/ui/borrow_deref_ref_unfixable.stderr b/src/tools/clippy/tests/ui/borrow_deref_ref_unfixable.stderr index 71f43af46c2..b8a0eedeb9e 100644 --- a/src/tools/clippy/tests/ui/borrow_deref_ref_unfixable.stderr +++ b/src/tools/clippy/tests/ui/borrow_deref_ref_unfixable.stderr @@ -13,9 +13,8 @@ LL + let x: &str = s; | help: if you would like to deref, try using `&**` | -LL - let x: &str = &*s; -LL + let x: &str = &**s; - | +LL | let x: &str = &**s; + | + error: aborting due to 1 previous error diff --git a/src/tools/clippy/tests/ui/fn_to_numeric_cast_any.stderr b/src/tools/clippy/tests/ui/fn_to_numeric_cast_any.stderr index c069c9d1672..0238e3a9136 100644 --- a/src/tools/clippy/tests/ui/fn_to_numeric_cast_any.stderr +++ b/src/tools/clippy/tests/ui/fn_to_numeric_cast_any.stderr @@ -8,9 +8,8 @@ LL | let _ = foo as i8; = help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast_any)]` help: did you mean to invoke the function? | -LL - let _ = foo as i8; -LL + let _ = foo() as i8; - | +LL | let _ = foo() as i8; + | ++ error: casting function pointer `foo` to `i16` --> tests/ui/fn_to_numeric_cast_any.rs:26:13 @@ -20,9 +19,8 @@ LL | let _ = foo as i16; | help: did you mean to invoke the function? | -LL - let _ = foo as i16; -LL + let _ = foo() as i16; - | +LL | let _ = foo() as i16; + | ++ error: casting function pointer `foo` to `i32` --> tests/ui/fn_to_numeric_cast_any.rs:28:13 @@ -32,9 +30,8 @@ LL | let _ = foo as i32; | help: did you mean to invoke the function? | -LL - let _ = foo as i32; -LL + let _ = foo() as i32; - | +LL | let _ = foo() as i32; + | ++ error: casting function pointer `foo` to `i64` --> tests/ui/fn_to_numeric_cast_any.rs:30:13 @@ -44,9 +41,8 @@ LL | let _ = foo as i64; | help: did you mean to invoke the function? | -LL - let _ = foo as i64; -LL + let _ = foo() as i64; - | +LL | let _ = foo() as i64; + | ++ error: casting function pointer `foo` to `i128` --> tests/ui/fn_to_numeric_cast_any.rs:32:13 @@ -56,9 +52,8 @@ LL | let _ = foo as i128; | help: did you mean to invoke the function? | -LL - let _ = foo as i128; -LL + let _ = foo() as i128; - | +LL | let _ = foo() as i128; + | ++ error: casting function pointer `foo` to `isize` --> tests/ui/fn_to_numeric_cast_any.rs:34:13 @@ -68,9 +63,8 @@ LL | let _ = foo as isize; | help: did you mean to invoke the function? | -LL - let _ = foo as isize; -LL + let _ = foo() as isize; - | +LL | let _ = foo() as isize; + | ++ error: casting function pointer `foo` to `u8` --> tests/ui/fn_to_numeric_cast_any.rs:37:13 @@ -80,9 +74,8 @@ LL | let _ = foo as u8; | help: did you mean to invoke the function? | -LL - let _ = foo as u8; -LL + let _ = foo() as u8; - | +LL | let _ = foo() as u8; + | ++ error: casting function pointer `foo` to `u16` --> tests/ui/fn_to_numeric_cast_any.rs:39:13 @@ -92,9 +85,8 @@ LL | let _ = foo as u16; | help: did you mean to invoke the function? | -LL - let _ = foo as u16; -LL + let _ = foo() as u16; - | +LL | let _ = foo() as u16; + | ++ error: casting function pointer `foo` to `u32` --> tests/ui/fn_to_numeric_cast_any.rs:41:13 @@ -104,9 +96,8 @@ LL | let _ = foo as u32; | help: did you mean to invoke the function? | -LL - let _ = foo as u32; -LL + let _ = foo() as u32; - | +LL | let _ = foo() as u32; + | ++ error: casting function pointer `foo` to `u64` --> tests/ui/fn_to_numeric_cast_any.rs:43:13 @@ -116,9 +107,8 @@ LL | let _ = foo as u64; | help: did you mean to invoke the function? | -LL - let _ = foo as u64; -LL + let _ = foo() as u64; - | +LL | let _ = foo() as u64; + | ++ error: casting function pointer `foo` to `u128` --> tests/ui/fn_to_numeric_cast_any.rs:45:13 @@ -128,9 +118,8 @@ LL | let _ = foo as u128; | help: did you mean to invoke the function? | -LL - let _ = foo as u128; -LL + let _ = foo() as u128; - | +LL | let _ = foo() as u128; + | ++ error: casting function pointer `foo` to `usize` --> tests/ui/fn_to_numeric_cast_any.rs:47:13 @@ -140,9 +129,8 @@ LL | let _ = foo as usize; | help: did you mean to invoke the function? | -LL - let _ = foo as usize; -LL + let _ = foo() as usize; - | +LL | let _ = foo() as usize; + | ++ error: casting function pointer `Struct::static_method` to `usize` --> tests/ui/fn_to_numeric_cast_any.rs:52:13 @@ -152,9 +140,8 @@ LL | let _ = Struct::static_method as usize; | help: did you mean to invoke the function? | -LL - let _ = Struct::static_method as usize; -LL + let _ = Struct::static_method() as usize; - | +LL | let _ = Struct::static_method() as usize; + | ++ error: casting function pointer `f` to `usize` --> tests/ui/fn_to_numeric_cast_any.rs:57:5 @@ -164,9 +151,8 @@ LL | f as usize | help: did you mean to invoke the function? | -LL - f as usize -LL + f() as usize - | +LL | f() as usize + | ++ error: casting function pointer `T::static_method` to `usize` --> tests/ui/fn_to_numeric_cast_any.rs:62:5 @@ -176,9 +162,8 @@ LL | T::static_method as usize | help: did you mean to invoke the function? | -LL - T::static_method as usize -LL + T::static_method() as usize - | +LL | T::static_method() as usize + | ++ error: casting function pointer `(clos as fn(u32) -> u32)` to `usize` --> tests/ui/fn_to_numeric_cast_any.rs:69:13 @@ -188,9 +173,8 @@ LL | let _ = (clos as fn(u32) -> u32) as usize; | help: did you mean to invoke the function? | -LL - let _ = (clos as fn(u32) -> u32) as usize; -LL + let _ = (clos as fn(u32) -> u32)() as usize; - | +LL | let _ = (clos as fn(u32) -> u32)() as usize; + | ++ error: casting function pointer `foo` to `*const ()` --> tests/ui/fn_to_numeric_cast_any.rs:74:13 @@ -200,9 +184,8 @@ LL | let _ = foo as *const (); | help: did you mean to invoke the function? | -LL - let _ = foo as *const (); -LL + let _ = foo() as *const (); - | +LL | let _ = foo() as *const (); + | ++ error: aborting due to 17 previous errors diff --git a/src/tools/clippy/tests/ui/implicit_hasher.stderr b/src/tools/clippy/tests/ui/implicit_hasher.stderr index 6e964c65a2e..01d08a1bd9b 100644 --- a/src/tools/clippy/tests/ui/implicit_hasher.stderr +++ b/src/tools/clippy/tests/ui/implicit_hasher.stderr @@ -78,9 +78,8 @@ LL | pub fn map(map: &mut HashMap<i32, i32>) {} | help: add a type parameter for `BuildHasher` | -LL - pub fn map(map: &mut HashMap<i32, i32>) {} -LL + pub fn map<S: ::std::hash::BuildHasher>(map: &mut HashMap<i32, i32, S>) {} - | +LL | pub fn map<S: ::std::hash::BuildHasher>(map: &mut HashMap<i32, i32, S>) {} + | +++++++++++++++++++++++++++++ +++ error: parameter of type `HashSet` should be generalized over different hashers --> tests/ui/implicit_hasher.rs:70:22 @@ -90,9 +89,8 @@ LL | pub fn set(set: &mut HashSet<i32>) {} | help: add a type parameter for `BuildHasher` | -LL - pub fn set(set: &mut HashSet<i32>) {} -LL + pub fn set<S: ::std::hash::BuildHasher>(set: &mut HashSet<i32, S>) {} - | +LL | pub fn set<S: ::std::hash::BuildHasher>(set: &mut HashSet<i32, S>) {} + | +++++++++++++++++++++++++++++ +++ error: impl for `HashMap` should be generalized over different hashers --> tests/ui/implicit_hasher.rs:76:43 @@ -116,9 +114,8 @@ LL | pub async fn election_vote(_data: HashMap<i32, i32>) {} | help: add a type parameter for `BuildHasher` | -LL - pub async fn election_vote(_data: HashMap<i32, i32>) {} -LL + pub async fn election_vote<S: ::std::hash::BuildHasher>(_data: HashMap<i32, i32, S>) {} - | +LL | pub async fn election_vote<S: ::std::hash::BuildHasher>(_data: HashMap<i32, i32, S>) {} + | +++++++++++++++++++++++++++++ +++ error: aborting due to 9 previous errors diff --git a/src/tools/clippy/tests/ui/implicit_return.stderr b/src/tools/clippy/tests/ui/implicit_return.stderr index 7ea72307450..936a779fa74 100644 --- a/src/tools/clippy/tests/ui/implicit_return.stderr +++ b/src/tools/clippy/tests/ui/implicit_return.stderr @@ -9,7 +9,7 @@ LL | true help: add `return` as shown | LL | return true - | + | ++++++ error: missing `return` statement --> tests/ui/implicit_return.rs:19:15 @@ -122,7 +122,7 @@ LL | format!("test {}", "test") help: add `return` as shown | LL | return format!("test {}", "test") - | + | ++++++ error: missing `return` statement --> tests/ui/implicit_return.rs:90:5 @@ -133,7 +133,7 @@ LL | m!(true, false) help: add `return` as shown | LL | return m!(true, false) - | + | ++++++ error: missing `return` statement --> tests/ui/implicit_return.rs:96:13 @@ -169,10 +169,8 @@ LL | | } | help: add `return` as shown | -LL ~ return loop { -LL + m!(true); -LL + } - | +LL | return loop { + | ++++++ error: missing `return` statement --> tests/ui/implicit_return.rs:130:5 @@ -183,7 +181,7 @@ LL | true help: add `return` as shown | LL | return true - | + | ++++++ error: aborting due to 16 previous errors diff --git a/src/tools/clippy/tests/ui/literals.stderr b/src/tools/clippy/tests/ui/literals.stderr index a9192825b35..576b38a47d2 100644 --- a/src/tools/clippy/tests/ui/literals.stderr +++ b/src/tools/clippy/tests/ui/literals.stderr @@ -99,9 +99,8 @@ LL + let fail8 = 123; | help: if you mean to use an octal constant, use `0o` | -LL - let fail8 = 0123; -LL + let fail8 = 0o123; - | +LL | let fail8 = 0o123; + | + error: integer type suffix should not be separated by an underscore --> tests/ui/literals.rs:48:16 diff --git a/src/tools/clippy/tests/ui/manual_flatten.stderr b/src/tools/clippy/tests/ui/manual_flatten.stderr index cf1b0a1c8bb..93f7f11b5e6 100644 --- a/src/tools/clippy/tests/ui/manual_flatten.stderr +++ b/src/tools/clippy/tests/ui/manual_flatten.stderr @@ -196,11 +196,9 @@ LL | | } | |_________^ help: try | -LL ~ for n in vec![ -LL + -LL + Some(1), -LL + Some(2), -LL + Some(3) +LL | for n in vec![ +... +LL | Some(3) LL ~ ].iter().flatten() { | diff --git a/src/tools/clippy/tests/ui/octal_escapes.stderr b/src/tools/clippy/tests/ui/octal_escapes.stderr index c8a89ac8bea..61c781e316e 100644 --- a/src/tools/clippy/tests/ui/octal_escapes.stderr +++ b/src/tools/clippy/tests/ui/octal_escapes.stderr @@ -14,9 +14,8 @@ LL + let _bad1 = "\x1b[0m"; | help: if a null escape is intended, disambiguate using | -LL - let _bad1 = "\033[0m"; -LL + let _bad1 = "\x0033[0m"; - | +LL | let _bad1 = "\x0033[0m"; + | ++ error: octal-looking escape in a literal --> tests/ui/octal_escapes.rs:6:19 @@ -31,9 +30,8 @@ LL + let _bad2 = b"\x1b[0m"; | help: if a null escape is intended, disambiguate using | -LL - let _bad2 = b"\033[0m"; -LL + let _bad2 = b"\x0033[0m"; - | +LL | let _bad2 = b"\x0033[0m"; + | ++ error: octal-looking escape in a literal --> tests/ui/octal_escapes.rs:7:20 @@ -48,9 +46,8 @@ LL + let _bad3 = "\\\x1b[0m"; | help: if a null escape is intended, disambiguate using | -LL - let _bad3 = "\\\033[0m"; -LL + let _bad3 = "\\\x0033[0m"; - | +LL | let _bad3 = "\\\x0033[0m"; + | ++ error: octal-looking escape in a literal --> tests/ui/octal_escapes.rs:9:18 @@ -65,9 +62,8 @@ LL + let _bad4 = "\x0a34567"; | help: if a null escape is intended, disambiguate using | -LL - let _bad4 = "\01234567"; -LL + let _bad4 = "\x001234567"; - | +LL | let _bad4 = "\x001234567"; + | ++ error: octal-looking escape in a literal --> tests/ui/octal_escapes.rs:10:20 @@ -77,14 +73,12 @@ LL | let _bad5 = "\0\03"; | help: if an octal escape is intended, use a hex escape instead | -LL - let _bad5 = "\0\03"; -LL + let _bad5 = "\0\x03"; - | +LL | let _bad5 = "\0\x03"; + | + help: if a null escape is intended, disambiguate using | -LL - let _bad5 = "\0\03"; -LL + let _bad5 = "\0\x0003"; - | +LL | let _bad5 = "\0\x0003"; + | +++ error: octal-looking escape in a literal --> tests/ui/octal_escapes.rs:11:23 @@ -99,9 +93,8 @@ LL + let _bad6 = "Text-\x2d\077-MoreText"; | help: if a null escape is intended, disambiguate using | -LL - let _bad6 = "Text-\055\077-MoreText"; -LL + let _bad6 = "Text-\x0055\077-MoreText"; - | +LL | let _bad6 = "Text-\x0055\077-MoreText"; + | ++ error: octal-looking escape in a literal --> tests/ui/octal_escapes.rs:11:27 @@ -116,9 +109,8 @@ LL + let _bad6 = "Text-\055\x3f-MoreText"; | help: if a null escape is intended, disambiguate using | -LL - let _bad6 = "Text-\055\077-MoreText"; -LL + let _bad6 = "Text-\055\x0077-MoreText"; - | +LL | let _bad6 = "Text-\055\x0077-MoreText"; + | ++ error: octal-looking escape in a literal --> tests/ui/octal_escapes.rs:14:31 @@ -128,14 +120,12 @@ LL | let _bad7 = "EvenMoreText-\01\02-ShortEscapes"; | help: if an octal escape is intended, use a hex escape instead | -LL - let _bad7 = "EvenMoreText-\01\02-ShortEscapes"; -LL + let _bad7 = "EvenMoreText-\x01\02-ShortEscapes"; - | +LL | let _bad7 = "EvenMoreText-\x01\02-ShortEscapes"; + | + help: if a null escape is intended, disambiguate using | -LL - let _bad7 = "EvenMoreText-\01\02-ShortEscapes"; -LL + let _bad7 = "EvenMoreText-\x0001\02-ShortEscapes"; - | +LL | let _bad7 = "EvenMoreText-\x0001\02-ShortEscapes"; + | +++ error: octal-looking escape in a literal --> tests/ui/octal_escapes.rs:14:34 @@ -145,14 +135,12 @@ LL | let _bad7 = "EvenMoreText-\01\02-ShortEscapes"; | help: if an octal escape is intended, use a hex escape instead | -LL - let _bad7 = "EvenMoreText-\01\02-ShortEscapes"; -LL + let _bad7 = "EvenMoreText-\01\x02-ShortEscapes"; - | +LL | let _bad7 = "EvenMoreText-\01\x02-ShortEscapes"; + | + help: if a null escape is intended, disambiguate using | -LL - let _bad7 = "EvenMoreText-\01\02-ShortEscapes"; -LL + let _bad7 = "EvenMoreText-\01\x0002-ShortEscapes"; - | +LL | let _bad7 = "EvenMoreText-\01\x0002-ShortEscapes"; + | +++ error: octal-looking escape in a literal --> tests/ui/octal_escapes.rs:17:19 @@ -162,14 +150,12 @@ LL | let _bad8 = "锈\01锈"; | help: if an octal escape is intended, use a hex escape instead | -LL - let _bad8 = "锈\01锈"; -LL + let _bad8 = "锈\x01锈"; - | +LL | let _bad8 = "锈\x01锈"; + | + help: if a null escape is intended, disambiguate using | -LL - let _bad8 = "锈\01锈"; -LL + let _bad8 = "锈\x0001锈"; - | +LL | let _bad8 = "锈\x0001锈"; + | +++ error: octal-looking escape in a literal --> tests/ui/octal_escapes.rs:18:19 @@ -184,9 +170,8 @@ LL + let _bad9 = "锈\x09锈"; | help: if a null escape is intended, disambiguate using | -LL - let _bad9 = "锈\011锈"; -LL + let _bad9 = "锈\x0011锈"; - | +LL | let _bad9 = "锈\x0011锈"; + | ++ error: aborting due to 11 previous errors diff --git a/src/tools/clippy/tests/ui/suspicious_to_owned.stderr b/src/tools/clippy/tests/ui/suspicious_to_owned.stderr index 74bbcfcca51..2c26565d5ef 100644 --- a/src/tools/clippy/tests/ui/suspicious_to_owned.stderr +++ b/src/tools/clippy/tests/ui/suspicious_to_owned.stderr @@ -8,9 +8,8 @@ LL | let _ = cow.to_owned(); = help: to override `-D warnings` add `#[allow(clippy::suspicious_to_owned)]` help: depending on intent, either make the Cow an Owned variant | -LL - let _ = cow.to_owned(); -LL + let _ = cow.into_owned(); - | +LL | let _ = cow.into_owned(); + | ++ help: or clone the Cow itself | LL - let _ = cow.to_owned(); @@ -25,9 +24,8 @@ LL | let _ = cow.to_owned(); | help: depending on intent, either make the Cow an Owned variant | -LL - let _ = cow.to_owned(); -LL + let _ = cow.into_owned(); - | +LL | let _ = cow.into_owned(); + | ++ help: or clone the Cow itself | LL - let _ = cow.to_owned(); @@ -42,9 +40,8 @@ LL | let _ = cow.to_owned(); | help: depending on intent, either make the Cow an Owned variant | -LL - let _ = cow.to_owned(); -LL + let _ = cow.into_owned(); - | +LL | let _ = cow.into_owned(); + | ++ help: or clone the Cow itself | LL - let _ = cow.to_owned(); @@ -59,9 +56,8 @@ LL | let _ = cow.to_owned(); | help: depending on intent, either make the Cow an Owned variant | -LL - let _ = cow.to_owned(); -LL + let _ = cow.into_owned(); - | +LL | let _ = cow.into_owned(); + | ++ help: or clone the Cow itself | LL - let _ = cow.to_owned(); diff --git a/src/tools/clippy/tests/ui/too_long_first_doc_paragraph-fix.stderr b/src/tools/clippy/tests/ui/too_long_first_doc_paragraph-fix.stderr index 6ef333f0cfd..84a574017a9 100644 --- a/src/tools/clippy/tests/ui/too_long_first_doc_paragraph-fix.stderr +++ b/src/tools/clippy/tests/ui/too_long_first_doc_paragraph-fix.stderr @@ -12,7 +12,7 @@ LL | | /// 200 characters so I needed to write something longeeeeeeer. = help: to override `-D warnings` add `#[allow(clippy::too_long_first_doc_paragraph)]` help: add an empty line | -LL ~ /// A very short summary. +LL | /// A very short summary. LL + /// | diff --git a/src/tools/clippy/tests/ui/too_long_first_doc_paragraph.stderr b/src/tools/clippy/tests/ui/too_long_first_doc_paragraph.stderr index 95f42349b9b..8bc853132ec 100644 --- a/src/tools/clippy/tests/ui/too_long_first_doc_paragraph.stderr +++ b/src/tools/clippy/tests/ui/too_long_first_doc_paragraph.stderr @@ -12,8 +12,8 @@ LL | | //! 200 characters so I needed to write something longeeeeeeer. = help: to override `-D warnings` add `#[allow(clippy::too_long_first_doc_paragraph)]` help: add an empty line | -LL ~ //! A very short summary. -LL + //! +LL | //! A very short summary. +LL ~ //! LL ~ //! A much longer explanation that goes into a lot more detail about | diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 1614c35cb1c..98ab7adf5a7 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -215,8 +215,10 @@ pub struct Config { /// `None` then these tests will be ignored. pub run_clang_based_tests_with: Option<String>, - /// The directory containing the tests to run - pub src_base: PathBuf, + /// The directory containing the sources. + pub src_root: PathBuf, + /// The directory containing the test suite sources. Must be a subdirectory of `src_root`. + pub src_test_suite_root: PathBuf, /// The directory where programs should be built pub build_base: PathBuf, diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 452a2e9a9d5..3bdf37a1f29 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -1026,19 +1026,6 @@ impl Config { } } - pub fn find_rust_src_root(&self) -> Option<PathBuf> { - let mut path = self.src_base.clone(); - let path_postfix = Path::new("src/etc/lldb_batchmode.py"); - - while path.pop() { - if path.join(&path_postfix).is_file() { - return Some(path); - } - } - - None - } - fn parse_edition(&self, line: &str) -> Option<String> { self.parse_name_value_directive(line, "edition") } @@ -1098,7 +1085,7 @@ fn expand_variables(mut value: String, config: &Config) -> String { } if value.contains(SRC_BASE) { - value = value.replace(SRC_BASE, &config.src_base.to_string_lossy()); + value = value.replace(SRC_BASE, &config.src_test_suite_root.to_str().unwrap()); } if value.contains(BUILD_BASE) { diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index 55292c46bba..c9536b7a19b 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -153,7 +153,8 @@ impl ConfigBuilder { "--run-lib-path=", "--python=", "--jsondocck-path=", - "--src-base=", + "--src-root=", + "--src-test-suite-root=", "--build-base=", "--sysroot-base=", "--cc=c", @@ -465,7 +466,10 @@ fn profiler_runtime() { #[test] fn asm_support() { let asms = [ + #[cfg(bootstrap)] ("avr-unknown-gnu-atmega328", false), + #[cfg(not(bootstrap))] + ("avr-none", false), ("i686-unknown-netbsd", true), ("riscv32gc-unknown-linux-gnu", true), ("riscv64imac-unknown-none-elf", true), diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index d0a83cab9cd..97982170138 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -61,7 +61,8 @@ pub fn parse_config(args: Vec<String>) -> Config { .optopt("", "jsondoclint-path", "path to jsondoclint to use for doc tests", "PATH") .optopt("", "run-clang-based-tests-with", "path to Clang executable", "PATH") .optopt("", "llvm-filecheck", "path to LLVM's FileCheck binary", "DIR") - .reqopt("", "src-base", "directory to scan for test files", "PATH") + .reqopt("", "src-root", "directory containing sources", "PATH") + .reqopt("", "src-test-suite-root", "directory containing test suite sources", "PATH") .reqopt("", "build-base", "directory to deposit test outputs", "PATH") .reqopt("", "sysroot-base", "directory containing the compiler sysroot", "PATH") .reqopt("", "stage", "stage number under test", "N") @@ -243,7 +244,6 @@ pub fn parse_config(args: Vec<String>) -> Config { || header::extract_llvm_version_from_binary(&matches.opt_str("llvm-filecheck")?), ); - let src_base = opt_path(matches, "src-base"); let run_ignored = matches.opt_present("ignored"); let with_rustc_debug_assertions = matches.opt_present("with-rustc-debug-assertions"); let with_std_debug_assertions = matches.opt_present("with-std-debug-assertions"); @@ -300,6 +300,15 @@ pub fn parse_config(args: Vec<String>) -> Config { None => panic!("`--stage` is required"), }; + let src_root = opt_path(matches, "src-root"); + let src_test_suite_root = opt_path(matches, "src-test-suite-root"); + assert!( + src_test_suite_root.starts_with(&src_root), + "`src-root` must be a parent of `src-test-suite-root`: `src-root`=`{}`, `src-test-suite-root` = `{}`", + src_root.display(), + src_test_suite_root.display() + ); + Config { bless: matches.opt_present("bless"), compile_lib_path: make_absolute(opt_path(matches, "compile-lib-path")), @@ -314,7 +323,10 @@ pub fn parse_config(args: Vec<String>) -> Config { run_clang_based_tests_with: matches.opt_str("run-clang-based-tests-with"), llvm_filecheck: matches.opt_str("llvm-filecheck").map(PathBuf::from), llvm_bin_dir: matches.opt_str("llvm-bin-dir").map(PathBuf::from), - src_base, + + src_root, + src_test_suite_root, + build_base: opt_path(matches, "build-base"), sysroot_base: opt_path(matches, "sysroot-base"), @@ -422,7 +434,10 @@ pub fn log_config(config: &Config) { logv(c, format!("rustc_path: {:?}", config.rustc_path.display())); logv(c, format!("cargo_path: {:?}", config.cargo_path)); logv(c, format!("rustdoc_path: {:?}", config.rustdoc_path)); - logv(c, format!("src_base: {:?}", config.src_base.display())); + + logv(c, format!("src_root: {}", config.src_root.display())); + logv(c, format!("src_test_suite_root: {}", config.src_test_suite_root.display())); + logv(c, format!("build_base: {:?}", config.build_base.display())); logv(c, format!("stage: {}", config.stage)); logv(c, format!("stage_id: {}", config.stage_id)); @@ -620,20 +635,29 @@ struct TestCollector { /// regardless of whether any filters/tests were specified on the command-line, /// because filtering is handled later by libtest. pub fn collect_and_make_tests(config: Arc<Config>) -> Vec<test::TestDescAndFn> { - debug!("making tests from {:?}", config.src_base.display()); + debug!("making tests from {}", config.src_test_suite_root.display()); let common_inputs_stamp = common_inputs_stamp(&config); - let modified_tests = modified_tests(&config, &config.src_base).unwrap_or_else(|err| { - panic!("modified_tests got error from dir: {}, error: {}", config.src_base.display(), err) - }); + let modified_tests = + modified_tests(&config, &config.src_test_suite_root).unwrap_or_else(|err| { + panic!( + "modified_tests got error from dir: {}, error: {}", + config.src_test_suite_root.display(), + err + ) + }); let cache = HeadersCache::load(&config); let cx = TestCollectorCx { config, cache, common_inputs_stamp, modified_tests }; let mut collector = TestCollector { tests: vec![], found_path_stems: HashSet::new(), poisoned: false }; - collect_tests_from_dir(&cx, &mut collector, &cx.config.src_base, Path::new("")).unwrap_or_else( - |reason| panic!("Could not read tests from {}: {reason}", cx.config.src_base.display()), - ); + collect_tests_from_dir(&cx, &mut collector, &cx.config.src_test_suite_root, Path::new("")) + .unwrap_or_else(|reason| { + panic!( + "Could not read tests from {}: {reason}", + cx.config.src_test_suite_root.display() + ) + }); let TestCollector { tests, found_path_stems, poisoned } = collector; @@ -655,7 +679,7 @@ pub fn collect_and_make_tests(config: Arc<Config>) -> Vec<test::TestDescAndFn> { /// common to some subset of tests, and are hopefully unlikely to be modified /// while working on other tests.) fn common_inputs_stamp(config: &Config) -> Stamp { - let rust_src_dir = config.find_rust_src_root().expect("Could not find Rust source root"); + let src_root = &config.src_root; let mut stamp = Stamp::from_path(&config.rustc_path); @@ -670,17 +694,17 @@ fn common_inputs_stamp(config: &Config) -> Stamp { "src/etc/lldb_providers.py", ]; for file in &pretty_printer_files { - let path = rust_src_dir.join(file); + let path = src_root.join(file); stamp.add_path(&path); } - stamp.add_dir(&rust_src_dir.join("src/etc/natvis")); + stamp.add_dir(&src_root.join("src/etc/natvis")); stamp.add_dir(&config.run_lib_path); if let Some(ref rustdoc_path) = config.rustdoc_path { stamp.add_path(&rustdoc_path); - stamp.add_path(&rust_src_dir.join("src/etc/htmldocck.py")); + stamp.add_path(&src_root.join("src/etc/htmldocck.py")); } // Re-run coverage tests if the `coverage-dump` tool was modified, @@ -689,10 +713,10 @@ fn common_inputs_stamp(config: &Config) -> Stamp { stamp.add_path(coverage_dump_path) } - stamp.add_dir(&rust_src_dir.join("src/tools/run-make-support")); + stamp.add_dir(&src_root.join("src/tools/run-make-support")); // Compiletest itself. - stamp.add_dir(&rust_src_dir.join("src/tools/compiletest/")); + stamp.add_dir(&src_root.join("src/tools/compiletest")); stamp } @@ -933,10 +957,7 @@ fn files_related_to_test( } // `minicore.rs` test auxiliary: we need to make sure tests get rerun if this changes. - // - // FIXME(jieyouxu): untangle these paths, we should provide both a path to root `tests/` or - // `tests/auxiliary/` and the test suite in question. `src_base` is also a terrible name. - related.push(config.src_base.parent().unwrap().join("auxiliary").join("minicore.rs")); + related.push(config.src_root.join("tests").join("auxiliary").join("minicore.rs")); related } @@ -1026,10 +1047,8 @@ fn make_test_name( testpaths: &TestPaths, revision: Option<&str>, ) -> test::TestName { - // Print the name of the file, relative to the repository root. - // `src_base` looks like `/path/to/rust/tests/ui` - let root_directory = config.src_base.parent().unwrap().parent().unwrap(); - let path = testpaths.file.strip_prefix(root_directory).unwrap(); + // Print the name of the file, relative to the sources root. + let path = testpaths.file.strip_prefix(&config.src_root).unwrap(); let debugger = match config.debugger { Some(d) => format!("-{}", d), None => String::new(), diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 0e2da2b02ca..536e19bc493 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1365,7 +1365,7 @@ impl<'test> TestCx<'test> { // // Note: avoid adding a subdirectory of an already filtered directory here, otherwise the // same slice of text will be double counted and the truncation might not happen. - add_path(&self.config.src_base); + add_path(&self.config.src_test_suite_root); add_path(&self.config.build_base); read2_abbreviated(child, &filter_paths_from_len).expect("failed to read output") @@ -1471,7 +1471,7 @@ impl<'test> TestCx<'test> { // Similarly, vendored sources shouldn't be shown when running from a dist tarball. rustc.arg("-Z").arg(format!( "ignore-directory-in-diagnostics-source-blocks={}", - self.config.find_rust_src_root().unwrap().join("vendor").display(), + self.config.src_root.join("vendor").to_str().unwrap(), )); // Optionally prevent default --sysroot if specified in test compile-flags. @@ -1632,7 +1632,7 @@ impl<'test> TestCx<'test> { if self.props.remap_src_base { rustc.arg(format!( "--remap-path-prefix={}={}", - self.config.src_base.display(), + self.config.src_test_suite_root.to_str().unwrap(), FAKE_SRC_BASE, )); } diff --git a/src/tools/compiletest/src/runtest/debuginfo.rs b/src/tools/compiletest/src/runtest/debuginfo.rs index b236b067569..170b8a80996 100644 --- a/src/tools/compiletest/src/runtest/debuginfo.rs +++ b/src/tools/compiletest/src/runtest/debuginfo.rs @@ -257,11 +257,8 @@ impl TestCx<'_> { println!("Adb process is already finished."); } } else { - let rust_src_root = - self.config.find_rust_src_root().expect("Could not find Rust source root"); - let rust_pp_module_rel_path = Path::new("./src/etc"); - let rust_pp_module_abs_path = - rust_src_root.join(rust_pp_module_rel_path).to_str().unwrap().to_owned(); + let rust_pp_module_abs_path = self.config.src_root.join("src").join("etc"); + let rust_pp_module_abs_path = rust_pp_module_abs_path.to_str().unwrap(); // write debugger script let mut script_str = String::with_capacity(2048); script_str.push_str(&format!("set charset {}\n", Self::charset())); @@ -338,7 +335,7 @@ impl TestCx<'_> { let pythonpath = if let Ok(pp) = std::env::var("PYTHONPATH") { format!("{pp}:{rust_pp_module_abs_path}") } else { - rust_pp_module_abs_path + rust_pp_module_abs_path.to_string() }; gdb.args(debugger_opts).env("PYTHONPATH", pythonpath); @@ -407,11 +404,8 @@ impl TestCx<'_> { // Make LLDB emit its version, so we have it documented in the test output script_str.push_str("version\n"); - // Switch LLDB into "Rust mode" - let rust_src_root = - self.config.find_rust_src_root().expect("Could not find Rust source root"); - let rust_pp_module_rel_path = Path::new("./src/etc"); - let rust_pp_module_abs_path = rust_src_root.join(rust_pp_module_rel_path); + // Switch LLDB into "Rust mode". + let rust_pp_module_abs_path = self.config.src_root.join("src/etc"); script_str.push_str(&format!( "command script import {}/lldb_lookup.py\n", @@ -445,7 +439,7 @@ impl TestCx<'_> { let debugger_script = self.make_out_name("debugger.script"); // Let LLDB execute the script via lldb_batchmode.py - let debugger_run_result = self.run_lldb(&exe_file, &debugger_script, &rust_src_root); + let debugger_run_result = self.run_lldb(&exe_file, &debugger_script); if !debugger_run_result.status.success() { self.fatal_proc_rec("Error while running LLDB", &debugger_run_result); @@ -456,18 +450,13 @@ impl TestCx<'_> { } } - fn run_lldb( - &self, - test_executable: &Path, - debugger_script: &Path, - rust_src_root: &Path, - ) -> ProcRes { + fn run_lldb(&self, test_executable: &Path, debugger_script: &Path) -> ProcRes { // Prepare the lldb_batchmode which executes the debugger script - let lldb_script_path = rust_src_root.join("src/etc/lldb_batchmode.py"); + let lldb_script_path = self.config.src_root.join("src/etc/lldb_batchmode.py"); let pythonpath = if let Ok(pp) = std::env::var("PYTHONPATH") { format!("{pp}:{}", self.config.lldb_python_dir.as_ref().unwrap()) } else { - self.config.lldb_python_dir.as_ref().unwrap().to_string() + self.config.lldb_python_dir.clone().unwrap() }; self.run_command_to_procres( Command::new(&self.config.python) diff --git a/src/tools/compiletest/src/runtest/js_doc.rs b/src/tools/compiletest/src/runtest/js_doc.rs index a83bcd70c87..d630affbec1 100644 --- a/src/tools/compiletest/src/runtest/js_doc.rs +++ b/src/tools/compiletest/src/runtest/js_doc.rs @@ -9,12 +9,11 @@ impl TestCx<'_> { self.document(&out_dir, &self.testpaths); - let root = self.config.find_rust_src_root().unwrap(); let file_stem = self.testpaths.file.file_stem().and_then(|f| f.to_str()).expect("no file stem"); let res = self.run_command_to_procres( Command::new(&nodejs) - .arg(root.join("src/tools/rustdoc-js/tester.js")) + .arg(self.config.src_root.join("src/tools/rustdoc-js/tester.js")) .arg("--doc-folder") .arg(out_dir) .arg("--crate-name") diff --git a/src/tools/compiletest/src/runtest/run_make.rs b/src/tools/compiletest/src/runtest/run_make.rs index 16c46fc1339..74e6af36ea1 100644 --- a/src/tools/compiletest/src/runtest/run_make.rs +++ b/src/tools/compiletest/src/runtest/run_make.rs @@ -21,8 +21,6 @@ impl TestCx<'_> { fn run_rmake_legacy_test(&self) { let cwd = env::current_dir().unwrap(); - let src_root = self.config.src_base.parent().unwrap().parent().unwrap(); - let src_root = cwd.join(&src_root); // FIXME(Zalathar): This should probably be `output_base_dir` to avoid // an unnecessary extra subdirectory, but since legacy Makefile tests @@ -51,7 +49,7 @@ impl TestCx<'_> { .stderr(Stdio::piped()) .env("TARGET", &self.config.target) .env("PYTHON", &self.config.python) - .env("S", src_root) + .env("S", &self.config.src_root) .env("RUST_BUILD_STAGE", &self.config.stage_id) .env("RUSTC", cwd.join(&self.config.rustc_path)) .env("TMPDIR", &tmpdir) @@ -181,28 +179,10 @@ impl TestCx<'_> { // library. // 2. We need to run the recipe binary. - // So we assume the rust-lang/rust project setup looks like the following (our `.` is the - // top-level directory, irrelevant entries to our purposes omitted): - // - // ``` - // . // <- `source_root` - // ├── build/ // <- `build_root` - // ├── compiler/ - // ├── library/ - // ├── src/ - // │ └── tools/ - // │ └── run_make_support/ - // └── tests - // └── run-make/ - // ``` - - // `source_root` is the top-level directory containing the rust-lang/rust checkout. - let source_root = - self.config.find_rust_src_root().expect("could not determine rust source root"); // `self.config.build_base` is actually the build base folder + "test" + test suite name, it // looks like `build/<host_triple>/test/run-make`. But we want `build/<host_triple>/`. Note // that the `build` directory does not need to be called `build`, nor does it need to be - // under `source_root`, so we must compute it based off of `self.config.build_base`. + // under `src_root`, so we must compute it based off of `self.config.build_base`. let build_root = self.config.build_base.parent().and_then(Path::parent).unwrap().to_path_buf(); @@ -389,10 +369,9 @@ impl TestCx<'_> { .env("TARGET", &self.config.target) // Some tests unfortunately still need Python, so provide path to a Python interpreter. .env("PYTHON", &self.config.python) - // Provide path to checkout root. This is the top-level directory containing - // rust-lang/rust checkout. - .env("SOURCE_ROOT", &source_root) - // Path to the build directory. This is usually the same as `source_root.join("build").join("host")`. + // Provide path to sources root. + .env("SOURCE_ROOT", &self.config.src_root) + // Path to the host build directory. .env("BUILD_ROOT", &build_root) // Provide path to stage-corresponding rustc. .env("RUSTC", &self.config.rustc_path) @@ -408,11 +387,11 @@ impl TestCx<'_> { .env("LLVM_COMPONENTS", &self.config.llvm_components); if let Some(ref cargo) = self.config.cargo_path { - cmd.env("CARGO", source_root.join(cargo)); + cmd.env("CARGO", cargo); } if let Some(ref rustdoc) = self.config.rustdoc_path { - cmd.env("RUSTDOC", source_root.join(rustdoc)); + cmd.env("RUSTDOC", rustdoc); } if let Some(ref node) = self.config.nodejs { diff --git a/src/tools/compiletest/src/runtest/rustdoc.rs b/src/tools/compiletest/src/runtest/rustdoc.rs index 3f33862d2cf..2583ae96a67 100644 --- a/src/tools/compiletest/src/runtest/rustdoc.rs +++ b/src/tools/compiletest/src/runtest/rustdoc.rs @@ -17,9 +17,10 @@ impl TestCx<'_> { if self.props.check_test_line_numbers_match { self.check_rustdoc_test_option(proc_res); } else { - let root = self.config.find_rust_src_root().unwrap(); let mut cmd = Command::new(&self.config.python); - cmd.arg(root.join("src/etc/htmldocck.py")).arg(&out_dir).arg(&self.testpaths.file); + cmd.arg(self.config.src_root.join("src/etc/htmldocck.py")) + .arg(&out_dir) + .arg(&self.testpaths.file); if self.config.bless { cmd.arg("--bless"); } diff --git a/src/tools/llvm-bitcode-linker/src/bin/llvm-bitcode-linker.rs b/src/tools/llvm-bitcode-linker/src/bin/llvm-bitcode-linker.rs index fdbf6171c53..608c6605304 100644 --- a/src/tools/llvm-bitcode-linker/src/bin/llvm-bitcode-linker.rs +++ b/src/tools/llvm-bitcode-linker/src/bin/llvm-bitcode-linker.rs @@ -27,6 +27,10 @@ pub struct Args { #[arg(long)] target_cpu: Option<String>, + /// The target features + #[arg(long)] + target_feature: Option<String>, + /// Write output to the filename #[arg(short, long)] output: PathBuf, @@ -49,7 +53,7 @@ fn main() -> anyhow::Result<()> { let args = Args::parse(); - let mut linker = Session::new(args.target, args.target_cpu, args.output); + let mut linker = Session::new(args.target, args.target_cpu, args.target_feature, args.output); linker.add_exported_symbols(args.export_symbol); diff --git a/src/tools/llvm-bitcode-linker/src/linker.rs b/src/tools/llvm-bitcode-linker/src/linker.rs index 9f579d10094..dafd847e768 100644 --- a/src/tools/llvm-bitcode-linker/src/linker.rs +++ b/src/tools/llvm-bitcode-linker/src/linker.rs @@ -8,6 +8,7 @@ use crate::{Optimization, Target}; pub struct Session { target: Target, cpu: Option<String>, + feature: Option<String>, symbols: Vec<String>, /// A file that `llvm-link` supports, like a bitcode file or an archive. @@ -21,7 +22,12 @@ pub struct Session { } impl Session { - pub fn new(target: crate::Target, cpu: Option<String>, out_path: PathBuf) -> Self { + pub fn new( + target: crate::Target, + cpu: Option<String>, + feature: Option<String>, + out_path: PathBuf, + ) -> Self { let link_path = out_path.with_extension("o"); let opt_path = out_path.with_extension("optimized.o"); let sym_path = out_path.with_extension("symbols.txt"); @@ -29,6 +35,7 @@ impl Session { Session { target, cpu, + feature, symbols: Vec::new(), files: Vec::new(), link_path, @@ -134,6 +141,10 @@ impl Session { lcc_command.arg("--mcpu").arg(mcpu); } + if let Some(mattr) = &self.feature { + lcc_command.arg(&format!("--mattr={}", mattr)); + } + let lcc_output = lcc_command .arg(&self.opt_path) .arg("-o").arg(&self.out_path) diff --git a/src/tools/run-make-support/src/external_deps/rustc.rs b/src/tools/run-make-support/src/external_deps/rustc.rs index fd4a20278ad..710ba025830 100644 --- a/src/tools/run-make-support/src/external_deps/rustc.rs +++ b/src/tools/run-make-support/src/external_deps/rustc.rs @@ -253,6 +253,13 @@ impl Rustc { self } + /// Specify the target CPU. + pub fn target_cpu<S: AsRef<str>>(&mut self, target_cpu: S) -> &mut Self { + let target_cpu = target_cpu.as_ref(); + self.cmd.arg(format!("-Ctarget-cpu={target_cpu}")); + self + } + /// Specify the crate type. pub fn crate_type(&mut self, crate_type: &str) -> &mut Self { self.cmd.arg("--crate-type"); diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs index b6f7c44c2ae..f5a7b658123 100644 --- a/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs +++ b/src/tools/rust-analyzer/crates/hir-ty/src/layout.rs @@ -194,6 +194,7 @@ fn layout_of_simd_ty( fields, backend_repr: BackendRepr::Vector { element: e_abi, count: e_len }, largest_niche: e_ly.largest_niche, + uninhabited: false, size, align, max_repr_align: None, @@ -297,20 +298,17 @@ pub fn layout_of_ty_query( .checked_mul(count, dl) .ok_or(LayoutError::BadCalc(LayoutCalculatorError::SizeOverflow))?; - let backend_repr = - if count != 0 && matches!(element.backend_repr, BackendRepr::Uninhabited) { - BackendRepr::Uninhabited - } else { - BackendRepr::Memory { sized: true } - }; + let backend_repr = BackendRepr::Memory { sized: true }; let largest_niche = if count != 0 { element.largest_niche } else { None }; + let uninhabited = if count != 0 { element.uninhabited } else { false }; Layout { variants: Variants::Single { index: struct_variant_idx() }, fields: FieldsShape::Array { stride: element.size, count }, backend_repr, largest_niche, + uninhabited, align: element.align, size, max_repr_align: None, @@ -325,6 +323,7 @@ pub fn layout_of_ty_query( fields: FieldsShape::Array { stride: element.size, count: 0 }, backend_repr: BackendRepr::Memory { sized: false }, largest_niche: None, + uninhabited: false, align: element.align, size: Size::ZERO, max_repr_align: None, @@ -337,6 +336,7 @@ pub fn layout_of_ty_query( fields: FieldsShape::Array { stride: Size::from_bytes(1), count: 0 }, backend_repr: BackendRepr::Memory { sized: false }, largest_niche: None, + uninhabited: false, align: dl.i8_align, size: Size::ZERO, max_repr_align: None, diff --git a/tests/assembly/asm/avr-modifiers.rs b/tests/assembly/asm/avr-modifiers.rs index 585fdd7b725..124cad9bef6 100644 --- a/tests/assembly/asm/avr-modifiers.rs +++ b/tests/assembly/asm/avr-modifiers.rs @@ -1,6 +1,6 @@ //@ add-core-stubs //@ assembly-output: emit-asm -//@ compile-flags: --target avr-unknown-gnu-atmega328 +//@ compile-flags: --target avr-none -C target-cpu=atmega328p //@ needs-llvm-components: avr #![feature(no_core, asm_experimental_arch)] diff --git a/tests/assembly/asm/avr-types.rs b/tests/assembly/asm/avr-types.rs index 25cf3ec3b4b..309405f4d51 100644 --- a/tests/assembly/asm/avr-types.rs +++ b/tests/assembly/asm/avr-types.rs @@ -1,6 +1,6 @@ //@ add-core-stubs //@ assembly-output: emit-asm -//@ compile-flags: --target avr-unknown-gnu-atmega328 +//@ compile-flags: --target avr-none -C target-cpu=atmega328p //@ needs-llvm-components: avr #![feature(no_core, asm_experimental_arch)] diff --git a/tests/assembly/targets/targets-elf.rs b/tests/assembly/targets/targets-elf.rs index b5c0ee5a107..3e73d2c6eb7 100644 --- a/tests/assembly/targets/targets-elf.rs +++ b/tests/assembly/targets/targets-elf.rs @@ -216,9 +216,9 @@ //@ revisions: hexagon_unknown_none_elf //@ [hexagon_unknown_none_elf] compile-flags: --target hexagon-unknown-none-elf //@ [hexagon_unknown_none_elf] needs-llvm-components: hexagon -//@ revisions: i586_pc_nto_qnx700 -//@ [i586_pc_nto_qnx700] compile-flags: --target i586-pc-nto-qnx700 -//@ [i586_pc_nto_qnx700] needs-llvm-components: x86 +//@ revisions: i686_pc_nto_qnx700 +//@ [i686_pc_nto_qnx700] compile-flags: --target i686-pc-nto-qnx700 +//@ [i686_pc_nto_qnx700] needs-llvm-components: x86 //@ revisions: i586_unknown_linux_gnu //@ [i586_unknown_linux_gnu] compile-flags: --target i586-unknown-linux-gnu //@ [i586_unknown_linux_gnu] needs-llvm-components: x86 diff --git a/tests/assembly/targets/targets-pe.rs b/tests/assembly/targets/targets-pe.rs index 1fa4dc821dd..b74d0181c4d 100644 --- a/tests/assembly/targets/targets-pe.rs +++ b/tests/assembly/targets/targets-pe.rs @@ -15,9 +15,9 @@ //@ revisions: arm64ec_pc_windows_msvc //@ [arm64ec_pc_windows_msvc] compile-flags: --target arm64ec-pc-windows-msvc //@ [arm64ec_pc_windows_msvc] needs-llvm-components: aarch64 -//@ revisions: avr_unknown_gnu_atmega328 -//@ [avr_unknown_gnu_atmega328] compile-flags: --target avr-unknown-gnu-atmega328 -//@ [avr_unknown_gnu_atmega328] needs-llvm-components: avr +//@ revisions: avr_none +//@ [avr_none] compile-flags: --target avr-none -C target-cpu=atmega328p +//@ [avr_none] needs-llvm-components: avr //@ revisions: bpfeb_unknown_none //@ [bpfeb_unknown_none] compile-flags: --target bpfeb-unknown-none //@ [bpfeb_unknown_none] needs-llvm-components: bpf diff --git a/tests/codegen/asm/avr-clobbers.rs b/tests/codegen/asm/avr-clobbers.rs index 56218cd7bcf..9451127bf04 100644 --- a/tests/codegen/asm/avr-clobbers.rs +++ b/tests/codegen/asm/avr-clobbers.rs @@ -1,6 +1,6 @@ //@ add-core-stubs //@ assembly-output: emit-asm -//@ compile-flags: --target avr-unknown-gnu-atmega328 +//@ compile-flags: --target avr-none -C target-cpu=atmega328p //@ needs-llvm-components: avr #![crate_type = "rlib"] diff --git a/tests/codegen/avr/avr-func-addrspace.rs b/tests/codegen/avr/avr-func-addrspace.rs index ed8acccb1ad..2ec7c86b5f4 100644 --- a/tests/codegen/avr/avr-func-addrspace.rs +++ b/tests/codegen/avr/avr-func-addrspace.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Copt-level=3 --target=avr-unknown-gnu-atmega328 --crate-type=rlib -C panic=abort +//@ compile-flags: -Copt-level=3 --target=avr-none -C target-cpu=atmega328p --crate-type=rlib -C panic=abort //@ needs-llvm-components: avr // This test validates that function pointers can be stored in global variables diff --git a/tests/codegen/box-default-debug-copies.rs b/tests/codegen/box-default-debug-copies.rs new file mode 100644 index 00000000000..06cc41b21c0 --- /dev/null +++ b/tests/codegen/box-default-debug-copies.rs @@ -0,0 +1,28 @@ +//@ compile-flags: -Copt-level=0 + +// Test to make sure that `<Box<T>>::default` does not create too many copies of `T` on the stack. +// in debug mode. This regressed in dd0620b86721ae8cae86736443acd3f72ba6fc32 to +// four `T` allocas. +// +// See https://github.com/rust-lang/rust/issues/136043 for more context. +// +// FIXME: This test only wants to ensure that there are at most two allocas of `T` created, instead +// of checking for exactly two. + +#![crate_type = "lib"] + +#[allow(dead_code)] +pub struct Thing([u8; 1000000]); + +impl Default for Thing { + fn default() -> Self { + Thing([0; 1000000]) + } +} + +// CHECK-COUNT-2: %{{.*}} = alloca {{.*}}1000000 +// CHECK-NOT: %{{.*}} = alloca {{.*}}1000000 +#[no_mangle] +pub fn box_default_single_copy() -> Box<Thing> { + Box::default() +} diff --git a/tests/codegen/slice-iter-nonnull.rs b/tests/codegen/slice-iter-nonnull.rs index 98a1b961a64..87907e7ad0a 100644 --- a/tests/codegen/slice-iter-nonnull.rs +++ b/tests/codegen/slice-iter-nonnull.rs @@ -14,11 +14,11 @@ // CHECK-LABEL: @slice_iter_next( #[no_mangle] pub fn slice_iter_next<'a>(it: &mut std::slice::Iter<'a, u32>) -> Option<&'a u32> { - // CHECK: %[[ENDP:.+]] = getelementptr inbounds{{( nuw)?}} i8, ptr %it, {{i32 4|i64 8}} - // CHECK: %[[END:.+]] = load ptr, ptr %[[ENDP]] + // CHECK: %[[START:.+]] = load ptr, ptr %it, // CHECK-SAME: !nonnull // CHECK-SAME: !noundef - // CHECK: %[[START:.+]] = load ptr, ptr %it, + // CHECK: %[[ENDP:.+]] = getelementptr inbounds{{( nuw)?}} i8, ptr %it, {{i32 4|i64 8}} + // CHECK: %[[END:.+]] = load ptr, ptr %[[ENDP]] // CHECK-SAME: !nonnull // CHECK-SAME: !noundef // CHECK: icmp eq ptr %[[START]], %[[END]] diff --git a/tests/codegen/uninhabited-transparent-return-abi.rs b/tests/codegen/uninhabited-transparent-return-abi.rs new file mode 100644 index 00000000000..6e8b1683163 --- /dev/null +++ b/tests/codegen/uninhabited-transparent-return-abi.rs @@ -0,0 +1,44 @@ +//@ compile-flags: -Copt-level=3 + +// See https://github.com/rust-lang/rust/issues/135802 + +#![crate_type = "lib"] + +enum Void {} + +// Should be ABI-compatible with T, but wasn't prior to the PR adding this test. +#[repr(transparent)] +struct NoReturn<T>(T, Void); + +// Returned by invisible reference (in most ABIs) +#[allow(dead_code)] +struct Large(u64, u64, u64); + +extern "Rust" { + fn opaque() -> NoReturn<Large>; + fn opaque_with_arg(rsi: u32) -> NoReturn<Large>; +} + +// CHECK-LABEL: @test_uninhabited_ret_by_ref +#[no_mangle] +pub fn test_uninhabited_ret_by_ref() { + // CHECK: %_1 = alloca [24 x i8], align {{8|4}} + // CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %_1) + // CHECK-NEXT: call void @opaque(ptr noalias nocapture noundef nonnull sret([24 x i8]) align {{8|4}} dereferenceable(24) %_1) #2 + // CHECK-NEXT: unreachable + unsafe { + opaque(); + } +} + +// CHECK-LABEL: @test_uninhabited_ret_by_ref_with_arg +#[no_mangle] +pub fn test_uninhabited_ret_by_ref_with_arg(rsi: u32) { + // CHECK: %_2 = alloca [24 x i8], align {{8|4}} + // CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %_2) + // CHECK-NEXT: call void @opaque_with_arg(ptr noalias nocapture noundef nonnull sret([24 x i8]) align {{8|4}} dereferenceable(24) %_2, i32 noundef %rsi) #2 + // CHECK-NEXT: unreachable + unsafe { + opaque_with_arg(rsi); + } +} diff --git a/tests/crashes/125957.rs b/tests/crashes/125957.rs deleted file mode 100644 index e3abe5262eb..00000000000 --- a/tests/crashes/125957.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ known-bug: rust-lang/rust#125957 -#![feature(generic_const_exprs)] -#![allow(incomplete_features)] -#![feature(associated_const_equality)] - -pub struct Equal<const T: usize, const R: usize>(); - -pub enum ParseMode { - Raw, -} -pub trait Parse { - const PARSE_MODE: ParseMode; -} -pub trait RenderRaw: Parse<PARSE_MODE = { ParseMode::Raw }> {} - -trait GenericVec<T> { - fn unwrap() -> dyn RenderRaw; -} - -fn main() {} diff --git a/tests/crashes/132330.rs b/tests/crashes/132330.rs deleted file mode 100644 index 3432685749d..00000000000 --- a/tests/crashes/132330.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ known-bug: #132330 -//@compile-flags: -Znext-solver=globally - -trait Service { - type S; -} - -trait Framing { - type F; -} - -impl Framing for () { - type F = (); -} - -trait HttpService<F: Framing>: Service<S = F::F> {} - -type BoxService = Box<dyn HttpService<(), S = ()>>; - -fn build_server<F: FnOnce() -> BoxService>(_: F) {} - -fn make_server<F: Framing>() -> Box<dyn HttpService<F, S = F::F>> { - unimplemented!() -} - -fn main() { - build_server(|| make_server()) -} diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir index b7a9b4a1fe0..7ef532d222d 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir @@ -4,28 +4,30 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _11: std::slice::Iter<'_, T>; - let mut _12: std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _13: std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _21: std::option::Option<(usize, &T)>; - let mut _24: &impl Fn(usize, &T); - let mut _25: (usize, &T); - let _26: (); + let mut _11: std::ptr::NonNull<T>; + let mut _12: *const T; + let mut _13: usize; + let mut _32: std::option::Option<(usize, &T)>; + let mut _35: &impl Fn(usize, &T); + let mut _36: (usize, &T); + let _37: (); scope 1 { - debug iter => _13; - let _22: usize; - let _23: &T; + debug (((iter: Enumerate<std::slice::Iter<'_, T>>).0: std::slice::Iter<'_, T>).0: std::ptr::NonNull<T>) => _11; + debug (((iter: Enumerate<std::slice::Iter<'_, T>>).0: std::slice::Iter<'_, T>).1: *const T) => _12; + debug (((iter: Enumerate<std::slice::Iter<'_, T>>).0: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>; + debug ((iter: Enumerate<std::slice::Iter<'_, T>>).1: usize) => _13; + let _33: usize; + let _34: &T; scope 2 { - debug i => _22; - debug x => _23; + debug i => _33; + debug x => _34; } scope 19 (inlined <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next) { - let mut _14: &mut std::slice::Iter<'_, T>; - let mut _15: std::option::Option<&T>; - let mut _19: (usize, bool); - let mut _20: (usize, &T); + let mut _27: std::option::Option<&T>; + let mut _30: (usize, bool); + let mut _31: (usize, &T); scope 20 { - let _18: usize; + let _29: usize; scope 25 { } } @@ -40,11 +42,59 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 26 (inlined <Option<&T> as Try>::branch) { - let mut _16: isize; - let _17: &T; + let _28: &T; scope 27 { } } + scope 29 (inlined <std::slice::Iter<'_, T> as Iterator>::next) { + let _14: std::ptr::NonNull<T>; + let _16: std::ptr::NonNull<T>; + let mut _19: bool; + let mut _22: std::ptr::NonNull<T>; + let mut _24: usize; + let _26: &T; + scope 30 { + let _15: *const T; + scope 31 { + let _23: usize; + scope 32 { + scope 35 (inlined core::num::<impl usize>::unchecked_sub) { + scope 36 (inlined core::ub_checks::check_language_ub) { + scope 37 (inlined core::ub_checks::check_language_ub::runtime) { + } + } + } + scope 38 (inlined without_provenance_mut::<T>) { + } + } + scope 33 (inlined std::ptr::const_ptr::<impl *const T>::addr) { + scope 34 (inlined std::ptr::const_ptr::<impl *const T>::cast::<()>) { + } + } + scope 39 (inlined <NonNull<T> as PartialEq>::eq) { + let mut _17: *mut T; + let mut _18: *mut T; + scope 40 (inlined NonNull::<T>::as_ptr) { + } + scope 41 (inlined NonNull::<T>::as_ptr) { + } + } + scope 42 (inlined NonNull::<T>::add) { + let mut _20: *const T; + let mut _21: *const T; + scope 43 (inlined NonNull::<T>::as_ptr) { + } + } + scope 44 (inlined NonNull::<T>::as_ref::<'_>) { + let _25: *const T; + scope 45 (inlined NonNull::<T>::as_ptr) { + } + scope 46 (inlined std::ptr::mut_ptr::<impl *mut T>::cast_const) { + } + } + } + } + } } } scope 3 (inlined core::slice::<impl [T]>::iter) { @@ -89,9 +139,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb0: { - StorageLive(_11); StorageLive(_3); - StorageLive(_6); StorageLive(_4); _3 = PtrMetadata(copy _1); _4 = &raw const (*_1); @@ -120,86 +168,150 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb3: { - StorageLive(_10); _10 = copy _9; - _11 = std::slice::Iter::<'_, T> { ptr: copy _6, end_or_len: move _10, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_10); StorageDead(_9); StorageDead(_4); - StorageDead(_6); StorageDead(_3); - _12 = Enumerate::<std::slice::Iter<'_, T>> { iter: copy _11, count: const 0_usize }; - StorageDead(_11); + StorageLive(_11); + StorageLive(_12); StorageLive(_13); - _13 = copy _12; + _11 = copy _6; + _12 = copy _10; + _13 = const 0_usize; goto -> bb4; } bb4: { - StorageLive(_21); - StorageLive(_18); - StorageLive(_19); - StorageLive(_15); + StorageLive(_32); + StorageLive(_29); + StorageLive(_30); + StorageLive(_27); StorageLive(_14); - _14 = &mut (_13.0: std::slice::Iter<'_, T>); - _15 = <std::slice::Iter<'_, T> as Iterator>::next(move _14) -> [return: bb5, unwind unreachable]; + StorageLive(_15); + StorageLive(_23); + StorageLive(_24); + StorageLive(_16); + StorageLive(_26); + _14 = copy _11; + _15 = copy _12; + switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb5, otherwise: bb8]; } bb5: { - StorageDead(_14); - StorageLive(_16); - _16 = discriminant(_15); - switchInt(move _16) -> [0: bb6, 1: bb8, otherwise: bb11]; + StorageLive(_19); + _16 = copy _15 as std::ptr::NonNull<T> (Transmute); + StorageLive(_17); + _17 = copy _14 as *mut T (Transmute); + StorageLive(_18); + _18 = copy _16 as *mut T (Transmute); + _19 = Eq(move _17, move _18); + StorageDead(_18); + StorageDead(_17); + switchInt(move _19) -> [0: bb6, otherwise: bb7]; } bb6: { - StorageDead(_16); - StorageDead(_15); StorageDead(_19); - StorageDead(_18); + StorageLive(_22); + StorageLive(_21); + StorageLive(_20); + _20 = copy _14 as *const T (Transmute); + _21 = Offset(move _20, const 1_usize); + StorageDead(_20); + _22 = NonNull::<T> { pointer: move _21 }; StorageDead(_21); - StorageDead(_13); - drop(_2) -> [return: bb7, unwind unreachable]; + _11 = move _22; + StorageDead(_22); + goto -> bb13; } bb7: { - return; + StorageDead(_19); + StorageDead(_26); + StorageDead(_16); + StorageDead(_24); + StorageDead(_23); + StorageDead(_15); + StorageDead(_14); + goto -> bb10; } bb8: { - _17 = move ((_15 as Some).0: &T); - StorageDead(_16); - StorageDead(_15); - _18 = copy (_13.1: usize); - _19 = AddWithOverflow(copy (_13.1: usize), const 1_usize); - assert(!move (_19.1: bool), "attempt to compute `{} + {}`, which would overflow", copy (_13.1: usize), const 1_usize) -> [success: bb9, unwind unreachable]; + _23 = copy _15 as usize (Transmute); + switchInt(copy _23) -> [0: bb9, otherwise: bb12]; } bb9: { - (_13.1: usize) = move (_19.0: usize); - StorageLive(_20); - _20 = (copy _18, copy _17); - _21 = Option::<(usize, &T)>::Some(move _20); - StorageDead(_20); - StorageDead(_19); - StorageDead(_18); - _22 = copy (((_21 as Some).0: (usize, &T)).0: usize); - _23 = copy (((_21 as Some).0: (usize, &T)).1: &T); - StorageLive(_24); - _24 = &_2; - StorageLive(_25); - _25 = (copy _22, copy _23); - _26 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _24, move _25) -> [return: bb10, unwind unreachable]; + StorageDead(_26); + StorageDead(_16); + StorageDead(_24); + StorageDead(_23); + StorageDead(_15); + StorageDead(_14); + goto -> bb10; } bb10: { + StorageDead(_27); + StorageDead(_30); + StorageDead(_29); + StorageDead(_32); + StorageDead(_11); + StorageDead(_12); + StorageDead(_13); + drop(_2) -> [return: bb11, unwind unreachable]; + } + + bb11: { + return; + } + + bb12: { + _24 = SubUnchecked(copy _23, const 1_usize); + _12 = copy _24 as *const T (Transmute); + goto -> bb13; + } + + bb13: { + StorageLive(_25); + _25 = copy _14 as *const T (Transmute); + _26 = &(*_25); StorageDead(_25); + _27 = Option::<&T>::Some(copy _26); + StorageDead(_26); + StorageDead(_16); StorageDead(_24); - StorageDead(_21); - goto -> bb4; + StorageDead(_23); + StorageDead(_15); + StorageDead(_14); + _28 = move ((_27 as Some).0: &T); + StorageDead(_27); + _29 = copy _13; + _30 = AddWithOverflow(copy _13, const 1_usize); + assert(!move (_30.1: bool), "attempt to compute `{} + {}`, which would overflow", copy _13, const 1_usize) -> [success: bb14, unwind unreachable]; } - bb11: { - unreachable; + bb14: { + _13 = move (_30.0: usize); + StorageLive(_31); + _31 = (copy _29, copy _28); + _32 = Option::<(usize, &T)>::Some(move _31); + StorageDead(_31); + StorageDead(_30); + StorageDead(_29); + _33 = copy (((_32 as Some).0: (usize, &T)).0: usize); + _34 = copy (((_32 as Some).0: (usize, &T)).1: &T); + StorageLive(_35); + _35 = &_2; + StorageLive(_36); + _36 = (copy _33, copy _34); + _37 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _35, move _36) -> [return: bb15, unwind unreachable]; + } + + bb15: { + StorageDead(_36); + StorageDead(_35); + StorageDead(_32); + goto -> bb4; } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir index dc13bb23c31..62787f3447c 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -4,19 +4,68 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _11: std::slice::Iter<'_, T>; - let mut _12: std::slice::Iter<'_, T>; - let mut _13: &mut std::slice::Iter<'_, T>; - let mut _14: std::option::Option<&T>; - let mut _15: isize; - let mut _17: &impl Fn(&T); - let mut _18: (&T,); - let _19: (); + let mut _11: std::ptr::NonNull<T>; + let mut _12: *const T; + let mut _26: std::option::Option<&T>; + let mut _28: &impl Fn(&T); + let mut _29: (&T,); + let _30: (); scope 1 { - debug iter => _12; - let _16: &T; + debug ((iter: std::slice::Iter<'_, T>).0: std::ptr::NonNull<T>) => _11; + debug ((iter: std::slice::Iter<'_, T>).1: *const T) => _12; + debug ((iter: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>; + let _27: &T; scope 2 { - debug x => _16; + debug x => _27; + } + scope 17 (inlined <std::slice::Iter<'_, T> as Iterator>::next) { + let _13: std::ptr::NonNull<T>; + let _15: std::ptr::NonNull<T>; + let mut _18: bool; + let mut _21: std::ptr::NonNull<T>; + let mut _23: usize; + let _25: &T; + scope 18 { + let _14: *const T; + scope 19 { + let _22: usize; + scope 20 { + scope 23 (inlined core::num::<impl usize>::unchecked_sub) { + scope 24 (inlined core::ub_checks::check_language_ub) { + scope 25 (inlined core::ub_checks::check_language_ub::runtime) { + } + } + } + scope 26 (inlined without_provenance_mut::<T>) { + } + } + scope 21 (inlined std::ptr::const_ptr::<impl *const T>::addr) { + scope 22 (inlined std::ptr::const_ptr::<impl *const T>::cast::<()>) { + } + } + scope 27 (inlined <NonNull<T> as PartialEq>::eq) { + let mut _16: *mut T; + let mut _17: *mut T; + scope 28 (inlined NonNull::<T>::as_ptr) { + } + scope 29 (inlined NonNull::<T>::as_ptr) { + } + } + scope 30 (inlined NonNull::<T>::add) { + let mut _19: *const T; + let mut _20: *const T; + scope 31 (inlined NonNull::<T>::as_ptr) { + } + } + scope 32 (inlined NonNull::<T>::as_ref::<'_>) { + let _24: *const T; + scope 33 (inlined NonNull::<T>::as_ptr) { + } + scope 34 (inlined std::ptr::mut_ptr::<impl *mut T>::cast_const) { + } + } + } + } } } scope 3 (inlined core::slice::<impl [T]>::iter) { @@ -58,7 +107,6 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb0: { StorageLive(_3); - StorageLive(_6); StorageLive(_4); _3 = PtrMetadata(copy _1); _4 = &raw const (*_1); @@ -87,57 +135,125 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb3: { - StorageLive(_10); _10 = copy _9; - _11 = std::slice::Iter::<'_, T> { ptr: copy _6, end_or_len: move _10, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_10); StorageDead(_9); StorageDead(_4); - StorageDead(_6); StorageDead(_3); + StorageLive(_11); StorageLive(_12); - _12 = copy _11; + _11 = copy _6; + _12 = copy _10; goto -> bb4; } bb4: { + StorageLive(_26); + StorageLive(_13); StorageLive(_14); - _13 = &mut _12; - _14 = <std::slice::Iter<'_, T> as Iterator>::next(move _13) -> [return: bb5, unwind unreachable]; + StorageLive(_22); + StorageLive(_23); + StorageLive(_15); + StorageLive(_25); + _13 = copy _11; + _14 = copy _12; + switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb5, otherwise: bb8]; } bb5: { - _15 = discriminant(_14); - switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageLive(_18); + _15 = copy _14 as std::ptr::NonNull<T> (Transmute); + StorageLive(_16); + _16 = copy _13 as *mut T (Transmute); + StorageLive(_17); + _17 = copy _15 as *mut T (Transmute); + _18 = Eq(move _16, move _17); + StorageDead(_17); + StorageDead(_16); + switchInt(move _18) -> [0: bb6, otherwise: bb7]; } bb6: { - StorageDead(_14); - StorageDead(_12); - drop(_2) -> [return: bb7, unwind unreachable]; + StorageDead(_18); + StorageLive(_21); + StorageLive(_20); + StorageLive(_19); + _19 = copy _13 as *const T (Transmute); + _20 = Offset(move _19, const 1_usize); + StorageDead(_19); + _21 = NonNull::<T> { pointer: move _20 }; + StorageDead(_20); + _11 = move _21; + StorageDead(_21); + goto -> bb13; } bb7: { - return; + StorageDead(_18); + StorageDead(_25); + StorageDead(_15); + StorageDead(_23); + StorageDead(_22); + StorageDead(_14); + StorageDead(_13); + goto -> bb10; } bb8: { - _16 = copy ((_14 as Some).0: &T); - StorageLive(_17); - _17 = &_2; - StorageLive(_18); - _18 = (copy _16,); - _19 = <impl Fn(&T) as Fn<(&T,)>>::call(move _17, move _18) -> [return: bb9, unwind unreachable]; + _22 = copy _14 as usize (Transmute); + switchInt(copy _22) -> [0: bb9, otherwise: bb12]; } bb9: { - StorageDead(_18); - StorageDead(_17); + StorageDead(_25); + StorageDead(_15); + StorageDead(_23); + StorageDead(_22); StorageDead(_14); - goto -> bb4; + StorageDead(_13); + goto -> bb10; } bb10: { - unreachable; + StorageDead(_26); + StorageDead(_11); + StorageDead(_12); + drop(_2) -> [return: bb11, unwind unreachable]; + } + + bb11: { + return; + } + + bb12: { + _23 = SubUnchecked(copy _22, const 1_usize); + _12 = copy _23 as *const T (Transmute); + goto -> bb13; + } + + bb13: { + StorageLive(_24); + _24 = copy _13 as *const T (Transmute); + _25 = &(*_24); + StorageDead(_24); + _26 = Option::<&T>::Some(copy _25); + StorageDead(_25); + StorageDead(_15); + StorageDead(_23); + StorageDead(_22); + StorageDead(_14); + StorageDead(_13); + _27 = copy ((_26 as Some).0: &T); + StorageLive(_28); + _28 = &_2; + StorageLive(_29); + _29 = (copy _27,); + _30 = <impl Fn(&T) as Fn<(&T,)>>::call(move _28, move _29) -> [return: bb14, unwind unreachable]; + } + + bb14: { + StorageDead(_29); + StorageDead(_28); + StorageDead(_26); + goto -> bb4; } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir index 3f1e0e0f746..e5478e27918 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -4,19 +4,68 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _11: std::slice::Iter<'_, T>; - let mut _12: std::slice::Iter<'_, T>; - let mut _13: &mut std::slice::Iter<'_, T>; - let mut _14: std::option::Option<&T>; - let mut _15: isize; - let mut _17: &impl Fn(&T); - let mut _18: (&T,); - let _19: (); + let mut _11: std::ptr::NonNull<T>; + let mut _12: *const T; + let mut _26: std::option::Option<&T>; + let mut _28: &impl Fn(&T); + let mut _29: (&T,); + let _30: (); scope 1 { - debug iter => _12; - let _16: &T; + debug ((iter: std::slice::Iter<'_, T>).0: std::ptr::NonNull<T>) => _11; + debug ((iter: std::slice::Iter<'_, T>).1: *const T) => _12; + debug ((iter: std::slice::Iter<'_, T>).2: std::marker::PhantomData<&T>) => const ZeroSized: PhantomData<&T>; + let _27: &T; scope 2 { - debug x => _16; + debug x => _27; + } + scope 17 (inlined <std::slice::Iter<'_, T> as Iterator>::next) { + let _13: std::ptr::NonNull<T>; + let _15: std::ptr::NonNull<T>; + let mut _18: bool; + let mut _21: std::ptr::NonNull<T>; + let mut _23: usize; + let _25: &T; + scope 18 { + let _14: *const T; + scope 19 { + let _22: usize; + scope 20 { + scope 23 (inlined core::num::<impl usize>::unchecked_sub) { + scope 24 (inlined core::ub_checks::check_language_ub) { + scope 25 (inlined core::ub_checks::check_language_ub::runtime) { + } + } + } + scope 26 (inlined without_provenance_mut::<T>) { + } + } + scope 21 (inlined std::ptr::const_ptr::<impl *const T>::addr) { + scope 22 (inlined std::ptr::const_ptr::<impl *const T>::cast::<()>) { + } + } + scope 27 (inlined <NonNull<T> as PartialEq>::eq) { + let mut _16: *mut T; + let mut _17: *mut T; + scope 28 (inlined NonNull::<T>::as_ptr) { + } + scope 29 (inlined NonNull::<T>::as_ptr) { + } + } + scope 30 (inlined NonNull::<T>::add) { + let mut _19: *const T; + let mut _20: *const T; + scope 31 (inlined NonNull::<T>::as_ptr) { + } + } + scope 32 (inlined NonNull::<T>::as_ref::<'_>) { + let _24: *const T; + scope 33 (inlined NonNull::<T>::as_ptr) { + } + scope 34 (inlined std::ptr::mut_ptr::<impl *mut T>::cast_const) { + } + } + } + } } } scope 3 (inlined core::slice::<impl [T]>::iter) { @@ -58,7 +107,6 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb0: { StorageLive(_3); - StorageLive(_6); StorageLive(_4); _3 = PtrMetadata(copy _1); _4 = &raw const (*_1); @@ -87,65 +135,133 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb3: { - StorageLive(_10); _10 = copy _9; - _11 = std::slice::Iter::<'_, T> { ptr: copy _6, end_or_len: move _10, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_10); StorageDead(_9); StorageDead(_4); - StorageDead(_6); StorageDead(_3); + StorageLive(_11); StorageLive(_12); - _12 = copy _11; + _11 = copy _6; + _12 = copy _10; goto -> bb4; } bb4: { + StorageLive(_26); + StorageLive(_13); StorageLive(_14); - _13 = &mut _12; - _14 = <std::slice::Iter<'_, T> as Iterator>::next(move _13) -> [return: bb5, unwind: bb11]; + StorageLive(_22); + StorageLive(_23); + StorageLive(_15); + StorageLive(_25); + _13 = copy _11; + _14 = copy _12; + switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb5, otherwise: bb8]; } bb5: { - _15 = discriminant(_14); - switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageLive(_18); + _15 = copy _14 as std::ptr::NonNull<T> (Transmute); + StorageLive(_16); + _16 = copy _13 as *mut T (Transmute); + StorageLive(_17); + _17 = copy _15 as *mut T (Transmute); + _18 = Eq(move _16, move _17); + StorageDead(_17); + StorageDead(_16); + switchInt(move _18) -> [0: bb6, otherwise: bb7]; } bb6: { - StorageDead(_14); - StorageDead(_12); - drop(_2) -> [return: bb7, unwind continue]; + StorageDead(_18); + StorageLive(_21); + StorageLive(_20); + StorageLive(_19); + _19 = copy _13 as *const T (Transmute); + _20 = Offset(move _19, const 1_usize); + StorageDead(_19); + _21 = NonNull::<T> { pointer: move _20 }; + StorageDead(_20); + _11 = move _21; + StorageDead(_21); + goto -> bb13; } bb7: { - return; + StorageDead(_18); + StorageDead(_25); + StorageDead(_15); + StorageDead(_23); + StorageDead(_22); + StorageDead(_14); + StorageDead(_13); + goto -> bb10; } bb8: { - _16 = copy ((_14 as Some).0: &T); - StorageLive(_17); - _17 = &_2; - StorageLive(_18); - _18 = (copy _16,); - _19 = <impl Fn(&T) as Fn<(&T,)>>::call(move _17, move _18) -> [return: bb9, unwind: bb11]; + _22 = copy _14 as usize (Transmute); + switchInt(copy _22) -> [0: bb9, otherwise: bb12]; } bb9: { - StorageDead(_18); - StorageDead(_17); + StorageDead(_25); + StorageDead(_15); + StorageDead(_23); + StorageDead(_22); StorageDead(_14); - goto -> bb4; + StorageDead(_13); + goto -> bb10; } bb10: { - unreachable; + StorageDead(_26); + StorageDead(_11); + StorageDead(_12); + drop(_2) -> [return: bb11, unwind continue]; + } + + bb11: { + return; + } + + bb12: { + _23 = SubUnchecked(copy _22, const 1_usize); + _12 = copy _23 as *const T (Transmute); + goto -> bb13; + } + + bb13: { + StorageLive(_24); + _24 = copy _13 as *const T (Transmute); + _25 = &(*_24); + StorageDead(_24); + _26 = Option::<&T>::Some(copy _25); + StorageDead(_25); + StorageDead(_15); + StorageDead(_23); + StorageDead(_22); + StorageDead(_14); + StorageDead(_13); + _27 = copy ((_26 as Some).0: &T); + StorageLive(_28); + _28 = &_2; + StorageLive(_29); + _29 = (copy _27,); + _30 = <impl Fn(&T) as Fn<(&T,)>>::call(move _28, move _29) -> [return: bb14, unwind: bb15]; + } + + bb14: { + StorageDead(_29); + StorageDead(_28); + StorageDead(_26); + goto -> bb4; } - bb11 (cleanup): { - drop(_2) -> [return: bb12, unwind terminate(cleanup)]; + bb15 (cleanup): { + drop(_2) -> [return: bb16, unwind terminate(cleanup)]; } - bb12 (cleanup): { + bb16 (cleanup): { resume; } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir index 8edac638ccd..b6df2300efb 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-abort.mir @@ -3,12 +3,134 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { debug it => _1; let mut _0: std::option::Option<&T>; + scope 1 (inlined <std::slice::Iter<'_, T> as Iterator>::next) { + let _2: std::ptr::NonNull<T>; + let _4: std::ptr::NonNull<T>; + let mut _7: bool; + let mut _10: std::ptr::NonNull<T>; + let mut _12: usize; + let _14: &T; + scope 2 { + let _3: *const T; + scope 3 { + let _11: usize; + scope 4 { + scope 7 (inlined core::num::<impl usize>::unchecked_sub) { + scope 8 (inlined core::ub_checks::check_language_ub) { + scope 9 (inlined core::ub_checks::check_language_ub::runtime) { + } + } + } + scope 10 (inlined without_provenance_mut::<T>) { + } + } + scope 5 (inlined std::ptr::const_ptr::<impl *const T>::addr) { + scope 6 (inlined std::ptr::const_ptr::<impl *const T>::cast::<()>) { + } + } + scope 11 (inlined <NonNull<T> as PartialEq>::eq) { + let mut _5: *mut T; + let mut _6: *mut T; + scope 12 (inlined NonNull::<T>::as_ptr) { + } + scope 13 (inlined NonNull::<T>::as_ptr) { + } + } + scope 14 (inlined NonNull::<T>::add) { + let mut _8: *const T; + let mut _9: *const T; + scope 15 (inlined NonNull::<T>::as_ptr) { + } + } + scope 16 (inlined NonNull::<T>::as_ref::<'_>) { + let _13: *const T; + scope 17 (inlined NonNull::<T>::as_ptr) { + } + scope 18 (inlined std::ptr::mut_ptr::<impl *mut T>::cast_const) { + } + } + } + } + } bb0: { - _0 = <std::slice::Iter<'_, T> as Iterator>::next(move _1) -> [return: bb1, unwind unreachable]; + StorageLive(_2); + StorageLive(_3); + StorageLive(_11); + StorageLive(_12); + StorageLive(_4); + StorageLive(_14); + _2 = copy ((*_1).0: std::ptr::NonNull<T>); + _3 = copy ((*_1).1: *const T); + switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb1, otherwise: bb4]; } bb1: { + StorageLive(_7); + _4 = copy _3 as std::ptr::NonNull<T> (Transmute); + StorageLive(_5); + _5 = copy _2 as *mut T (Transmute); + StorageLive(_6); + _6 = copy _4 as *mut T (Transmute); + _7 = Eq(move _5, move _6); + StorageDead(_6); + StorageDead(_5); + switchInt(move _7) -> [0: bb2, otherwise: bb3]; + } + + bb2: { + StorageDead(_7); + StorageLive(_10); + StorageLive(_9); + StorageLive(_8); + _8 = copy _2 as *const T (Transmute); + _9 = Offset(move _8, const 1_usize); + StorageDead(_8); + _10 = NonNull::<T> { pointer: move _9 }; + StorageDead(_9); + ((*_1).0: std::ptr::NonNull<T>) = move _10; + StorageDead(_10); + goto -> bb7; + } + + bb3: { + _0 = const {transmute(0x0000000000000000): Option<&T>}; + StorageDead(_7); + goto -> bb8; + } + + bb4: { + _11 = copy _3 as usize (Transmute); + switchInt(copy _11) -> [0: bb5, otherwise: bb6]; + } + + bb5: { + _0 = const {transmute(0x0000000000000000): Option<&T>}; + goto -> bb8; + } + + bb6: { + _12 = SubUnchecked(copy _11, const 1_usize); + ((*_1).1: *const T) = copy _12 as *const T (Transmute); + goto -> bb7; + } + + bb7: { + StorageLive(_13); + _13 = copy _2 as *const T (Transmute); + _14 = &(*_13); + StorageDead(_13); + _0 = Option::<&T>::Some(copy _14); + goto -> bb8; + } + + bb8: { + StorageDead(_14); + StorageDead(_4); + StorageDead(_12); + StorageDead(_11); + StorageDead(_3); + StorageDead(_2); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir index fdde0717343..b6df2300efb 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir @@ -3,12 +3,134 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { debug it => _1; let mut _0: std::option::Option<&T>; + scope 1 (inlined <std::slice::Iter<'_, T> as Iterator>::next) { + let _2: std::ptr::NonNull<T>; + let _4: std::ptr::NonNull<T>; + let mut _7: bool; + let mut _10: std::ptr::NonNull<T>; + let mut _12: usize; + let _14: &T; + scope 2 { + let _3: *const T; + scope 3 { + let _11: usize; + scope 4 { + scope 7 (inlined core::num::<impl usize>::unchecked_sub) { + scope 8 (inlined core::ub_checks::check_language_ub) { + scope 9 (inlined core::ub_checks::check_language_ub::runtime) { + } + } + } + scope 10 (inlined without_provenance_mut::<T>) { + } + } + scope 5 (inlined std::ptr::const_ptr::<impl *const T>::addr) { + scope 6 (inlined std::ptr::const_ptr::<impl *const T>::cast::<()>) { + } + } + scope 11 (inlined <NonNull<T> as PartialEq>::eq) { + let mut _5: *mut T; + let mut _6: *mut T; + scope 12 (inlined NonNull::<T>::as_ptr) { + } + scope 13 (inlined NonNull::<T>::as_ptr) { + } + } + scope 14 (inlined NonNull::<T>::add) { + let mut _8: *const T; + let mut _9: *const T; + scope 15 (inlined NonNull::<T>::as_ptr) { + } + } + scope 16 (inlined NonNull::<T>::as_ref::<'_>) { + let _13: *const T; + scope 17 (inlined NonNull::<T>::as_ptr) { + } + scope 18 (inlined std::ptr::mut_ptr::<impl *mut T>::cast_const) { + } + } + } + } + } bb0: { - _0 = <std::slice::Iter<'_, T> as Iterator>::next(move _1) -> [return: bb1, unwind continue]; + StorageLive(_2); + StorageLive(_3); + StorageLive(_11); + StorageLive(_12); + StorageLive(_4); + StorageLive(_14); + _2 = copy ((*_1).0: std::ptr::NonNull<T>); + _3 = copy ((*_1).1: *const T); + switchInt(const <T as std::mem::SizedTypeProperties>::IS_ZST) -> [0: bb1, otherwise: bb4]; } bb1: { + StorageLive(_7); + _4 = copy _3 as std::ptr::NonNull<T> (Transmute); + StorageLive(_5); + _5 = copy _2 as *mut T (Transmute); + StorageLive(_6); + _6 = copy _4 as *mut T (Transmute); + _7 = Eq(move _5, move _6); + StorageDead(_6); + StorageDead(_5); + switchInt(move _7) -> [0: bb2, otherwise: bb3]; + } + + bb2: { + StorageDead(_7); + StorageLive(_10); + StorageLive(_9); + StorageLive(_8); + _8 = copy _2 as *const T (Transmute); + _9 = Offset(move _8, const 1_usize); + StorageDead(_8); + _10 = NonNull::<T> { pointer: move _9 }; + StorageDead(_9); + ((*_1).0: std::ptr::NonNull<T>) = move _10; + StorageDead(_10); + goto -> bb7; + } + + bb3: { + _0 = const {transmute(0x0000000000000000): Option<&T>}; + StorageDead(_7); + goto -> bb8; + } + + bb4: { + _11 = copy _3 as usize (Transmute); + switchInt(copy _11) -> [0: bb5, otherwise: bb6]; + } + + bb5: { + _0 = const {transmute(0x0000000000000000): Option<&T>}; + goto -> bb8; + } + + bb6: { + _12 = SubUnchecked(copy _11, const 1_usize); + ((*_1).1: *const T) = copy _12 as *const T (Transmute); + goto -> bb7; + } + + bb7: { + StorageLive(_13); + _13 = copy _2 as *const T (Transmute); + _14 = &(*_13); + StorageDead(_13); + _0 = Option::<&T>::Some(copy _14); + goto -> bb8; + } + + bb8: { + StorageDead(_14); + StorageDead(_4); + StorageDead(_12); + StorageDead(_11); + StorageDead(_3); + StorageDead(_2); return; } } diff --git a/tests/run-make/avr-rjmp-offset/rmake.rs b/tests/run-make/avr-rjmp-offset/rmake.rs index de64b724eed..da314f26ca7 100644 --- a/tests/run-make/avr-rjmp-offset/rmake.rs +++ b/tests/run-make/avr-rjmp-offset/rmake.rs @@ -22,7 +22,12 @@ fn main() { .input("avr-rjmp-offsets.rs") .opt_level("s") .panic("abort") - .target("avr-unknown-gnu-atmega328") + .target("avr-none") + // rust-lld has some troubles understanding the -mmcu flag, so for the + // time being let's tell rustc to emit binary that's compatible with the + // target CPU that lld defaults to, i.e. just `avr` (that's simply the + // minimal common instruction set across all AVRs) + .target_cpu("avr") // normally one links with `avr-gcc`, but this is not available in CI, // hence this test diverges from the default behavior to enable linking // at all, which is necessary for the test (to resolve the labels). To @@ -49,6 +54,7 @@ fn main() { // of the Rust compiler did produce a label `rjmp .-4` (misses the first // instruction in the loop). assert!(disassembly.contains("<main>"), "no main function in output"); + disassembly .trim() .lines() diff --git a/tests/ui/abi/c-zst.aarch64-darwin.stderr b/tests/ui/abi/c-zst.aarch64-darwin.stderr index c8f7d0a517c..57cc48aa9cf 100644 --- a/tests/ui/abi/c-zst.aarch64-darwin.stderr +++ b/tests/ui/abi/c-zst.aarch64-darwin.stderr @@ -17,6 +17,7 @@ error: fn_abi_of(pass_zst) = FnAbi { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -45,6 +46,7 @@ error: fn_abi_of(pass_zst) = FnAbi { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, diff --git a/tests/ui/abi/c-zst.powerpc-linux.stderr b/tests/ui/abi/c-zst.powerpc-linux.stderr index 1015f7d8898..67380176730 100644 --- a/tests/ui/abi/c-zst.powerpc-linux.stderr +++ b/tests/ui/abi/c-zst.powerpc-linux.stderr @@ -17,6 +17,7 @@ error: fn_abi_of(pass_zst) = FnAbi { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -56,6 +57,7 @@ error: fn_abi_of(pass_zst) = FnAbi { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, diff --git a/tests/ui/abi/c-zst.s390x-linux.stderr b/tests/ui/abi/c-zst.s390x-linux.stderr index 1015f7d8898..67380176730 100644 --- a/tests/ui/abi/c-zst.s390x-linux.stderr +++ b/tests/ui/abi/c-zst.s390x-linux.stderr @@ -17,6 +17,7 @@ error: fn_abi_of(pass_zst) = FnAbi { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -56,6 +57,7 @@ error: fn_abi_of(pass_zst) = FnAbi { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, diff --git a/tests/ui/abi/c-zst.sparc64-linux.stderr b/tests/ui/abi/c-zst.sparc64-linux.stderr index 1015f7d8898..67380176730 100644 --- a/tests/ui/abi/c-zst.sparc64-linux.stderr +++ b/tests/ui/abi/c-zst.sparc64-linux.stderr @@ -17,6 +17,7 @@ error: fn_abi_of(pass_zst) = FnAbi { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -56,6 +57,7 @@ error: fn_abi_of(pass_zst) = FnAbi { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, diff --git a/tests/ui/abi/c-zst.x86_64-linux.stderr b/tests/ui/abi/c-zst.x86_64-linux.stderr index c8f7d0a517c..57cc48aa9cf 100644 --- a/tests/ui/abi/c-zst.x86_64-linux.stderr +++ b/tests/ui/abi/c-zst.x86_64-linux.stderr @@ -17,6 +17,7 @@ error: fn_abi_of(pass_zst) = FnAbi { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -45,6 +46,7 @@ error: fn_abi_of(pass_zst) = FnAbi { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, diff --git a/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr b/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr index 1015f7d8898..67380176730 100644 --- a/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr +++ b/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr @@ -17,6 +17,7 @@ error: fn_abi_of(pass_zst) = FnAbi { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -56,6 +57,7 @@ error: fn_abi_of(pass_zst) = FnAbi { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, diff --git a/tests/ui/abi/debug.stderr b/tests/ui/abi/debug.stderr index e550e5bfcf3..5f73ff7d6bd 100644 --- a/tests/ui/abi/debug.stderr +++ b/tests/ui/abi/debug.stderr @@ -20,6 +20,7 @@ error: fn_abi_of(test) = FnAbi { ), fields: Primitive, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -67,6 +68,7 @@ error: fn_abi_of(test) = FnAbi { valid_range: 0..=1, }, ), + uninhabited: false, variants: Single { index: 0, }, @@ -125,6 +127,7 @@ error: fn_abi_of(TestFnPtr) = FnAbi { valid_range: 0..=1, }, ), + uninhabited: false, variants: Single { index: 0, }, @@ -163,6 +166,7 @@ error: fn_abi_of(TestFnPtr) = FnAbi { ), fields: Primitive, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -213,6 +217,7 @@ error: fn_abi_of(test_generic) = FnAbi { ), fields: Primitive, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -248,6 +253,7 @@ error: fn_abi_of(test_generic) = FnAbi { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -297,6 +303,7 @@ error: ABIs are not compatible ), fields: Primitive, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -332,6 +339,7 @@ error: ABIs are not compatible memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -369,6 +377,7 @@ error: ABIs are not compatible ), fields: Primitive, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -404,6 +413,7 @@ error: ABIs are not compatible memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -444,6 +454,7 @@ error: ABIs are not compatible count: 32, }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -483,6 +494,7 @@ error: ABIs are not compatible memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -517,6 +529,7 @@ error: ABIs are not compatible count: 32, }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -556,6 +569,7 @@ error: ABIs are not compatible memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -598,6 +612,7 @@ error: ABIs are not compatible ), fields: Primitive, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -633,6 +648,7 @@ error: ABIs are not compatible memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -670,6 +686,7 @@ error: ABIs are not compatible ), fields: Primitive, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -705,6 +722,7 @@ error: ABIs are not compatible memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -748,6 +766,7 @@ error: ABIs are not compatible ), fields: Primitive, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -783,6 +802,7 @@ error: ABIs are not compatible memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -820,6 +840,7 @@ error: ABIs are not compatible ), fields: Primitive, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -855,6 +876,7 @@ error: ABIs are not compatible memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -923,6 +945,7 @@ error: fn_abi_of(assoc_test) = FnAbi { valid_range: $NON_NULL, }, ), + uninhabited: false, variants: Single { index: 0, }, @@ -960,6 +983,7 @@ error: fn_abi_of(assoc_test) = FnAbi { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, diff --git a/tests/ui/abi/sysv64-zst.stderr b/tests/ui/abi/sysv64-zst.stderr index 781e9b2f4c9..ec85030c106 100644 --- a/tests/ui/abi/sysv64-zst.stderr +++ b/tests/ui/abi/sysv64-zst.stderr @@ -17,6 +17,7 @@ error: fn_abi_of(pass_zst) = FnAbi { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -45,6 +46,7 @@ error: fn_abi_of(pass_zst) = FnAbi { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, diff --git a/tests/ui/argument-suggestions/basic.stderr b/tests/ui/argument-suggestions/basic.stderr index 9a639d4b5e4..a71b6ab0e99 100644 --- a/tests/ui/argument-suggestions/basic.stderr +++ b/tests/ui/argument-suggestions/basic.stderr @@ -42,9 +42,8 @@ LL | fn missing(_i: u32) {} | ^^^^^^^ ------- help: provide the argument | -LL - missing(); -LL + missing(/* u32 */); - | +LL | missing(/* u32 */); + | +++++++++ error[E0308]: arguments to this function are incorrect --> $DIR/basic.rs:23:5 @@ -98,9 +97,8 @@ LL | let closure = |x| x; | ^^^ help: provide the argument | -LL - closure(); -LL + closure(/* x */); - | +LL | closure(/* x */); + | +++++++ error: aborting due to 6 previous errors diff --git a/tests/ui/argument-suggestions/display-is-suggestable.stderr b/tests/ui/argument-suggestions/display-is-suggestable.stderr index bb5df1ec234..921cc123338 100644 --- a/tests/ui/argument-suggestions/display-is-suggestable.stderr +++ b/tests/ui/argument-suggestions/display-is-suggestable.stderr @@ -11,9 +11,8 @@ LL | fn foo(x: &(dyn Display + Send)) {} | ^^^ ------------------------ help: provide the argument | -LL - foo(); -LL + foo(/* &dyn std::fmt::Display + Send */); - | +LL | foo(/* &dyn std::fmt::Display + Send */); + | +++++++++++++++++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/argument-suggestions/extern-fn-arg-names.stderr b/tests/ui/argument-suggestions/extern-fn-arg-names.stderr index 62670316cd1..28500908e7e 100644 --- a/tests/ui/argument-suggestions/extern-fn-arg-names.stderr +++ b/tests/ui/argument-suggestions/extern-fn-arg-names.stderr @@ -17,9 +17,8 @@ LL | fn dstfn(src: i32, dst: err); | ^^^^^ --- help: provide the argument | -LL - dstfn(1); -LL + dstfn(1, /* dst */); - | +LL | dstfn(1, /* dst */); + | +++++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/argument-suggestions/issue-97197.stderr b/tests/ui/argument-suggestions/issue-97197.stderr index acaf4f15107..ae56e12c975 100644 --- a/tests/ui/argument-suggestions/issue-97197.stderr +++ b/tests/ui/argument-suggestions/issue-97197.stderr @@ -11,9 +11,8 @@ LL | pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {} | ^ -------- -------- -------- -------- help: provide the arguments | -LL - g((), ()); -LL + g((), /* bool */, /* bool */, /* bool */, /* bool */, ()); - | +LL | g((), /* bool */, /* bool */, /* bool */, /* bool */, ()); + | +++++++++++++++++++++++++++++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/argument-suggestions/issue-98894.stderr b/tests/ui/argument-suggestions/issue-98894.stderr index 44353cb3338..141355ff153 100644 --- a/tests/ui/argument-suggestions/issue-98894.stderr +++ b/tests/ui/argument-suggestions/issue-98894.stderr @@ -11,9 +11,8 @@ LL | (|_, ()| ())(if true {} else {return;}); | ^^^^^^^ help: provide the argument | -LL - (|_, ()| ())(if true {} else {return;}); -LL + (|_, ()| ())(if true {} else {return;}, ()); - | +LL | (|_, ()| ())(if true {} else {return;}, ()); + | ++++ error: aborting due to 1 previous error diff --git a/tests/ui/argument-suggestions/issue-98897.stderr b/tests/ui/argument-suggestions/issue-98897.stderr index fd3ef467b1c..a85e7233689 100644 --- a/tests/ui/argument-suggestions/issue-98897.stderr +++ b/tests/ui/argument-suggestions/issue-98897.stderr @@ -11,9 +11,8 @@ LL | (|_, ()| ())([return, ()]); | ^^^^^^^ help: provide the argument | -LL - (|_, ()| ())([return, ()]); -LL + (|_, ()| ())([return, ()], ()); - | +LL | (|_, ()| ())([return, ()], ()); + | ++++ error: aborting due to 1 previous error diff --git a/tests/ui/argument-suggestions/issue-99482.stderr b/tests/ui/argument-suggestions/issue-99482.stderr index b3c39604a99..972ab401958 100644 --- a/tests/ui/argument-suggestions/issue-99482.stderr +++ b/tests/ui/argument-suggestions/issue-99482.stderr @@ -11,9 +11,8 @@ LL | let f = |_: (), f: fn()| f; | ^^^^^^^^^^^^^^^^ help: provide the argument | -LL - let _f = f(main); -LL + let _f = f((), main); - | +LL | let _f = f((), main); + | +++ error: aborting due to 1 previous error diff --git a/tests/ui/argument-suggestions/missing_arguments.stderr b/tests/ui/argument-suggestions/missing_arguments.stderr index 264c485cbe1..9dc13c41113 100644 --- a/tests/ui/argument-suggestions/missing_arguments.stderr +++ b/tests/ui/argument-suggestions/missing_arguments.stderr @@ -11,9 +11,8 @@ LL | fn one_arg(_a: i32) {} | ^^^^^^^ ------- help: provide the argument | -LL - one_arg(); -LL + one_arg(/* i32 */); - | +LL | one_arg(/* i32 */); + | +++++++++ error[E0061]: this function takes 2 arguments but 0 arguments were supplied --> $DIR/missing_arguments.rs:14:3 diff --git a/tests/ui/associated-consts/associated-const-ambiguity-report.stderr b/tests/ui/associated-consts/associated-const-ambiguity-report.stderr index e68ba503c50..041c9b485f0 100644 --- a/tests/ui/associated-consts/associated-const-ambiguity-report.stderr +++ b/tests/ui/associated-consts/associated-const-ambiguity-report.stderr @@ -16,12 +16,10 @@ LL | const ID: i32 = 1; | ^^^^^^^^^^^^^ help: use fully-qualified syntax to disambiguate | -LL - const X: i32 = <i32>::ID; -LL + const X: i32 = <i32 as Bar>::ID; - | -LL - const X: i32 = <i32>::ID; -LL + const X: i32 = <i32 as Foo>::ID; - | +LL | const X: i32 = <i32 as Bar>::ID; + | ++++++ +LL | const X: i32 = <i32 as Foo>::ID; + | ++++++ error: aborting due to 1 previous error diff --git a/tests/ui/associated-consts/issue-93775.rs b/tests/ui/associated-consts/issue-93775.rs index 88e88b55987..a9b8d10a83f 100644 --- a/tests/ui/associated-consts/issue-93775.rs +++ b/tests/ui/associated-consts/issue-93775.rs @@ -2,11 +2,13 @@ // Similar to stress testing, the test case requires a larger call stack, // so we ignore rustc's debug assertions. -//@ build-pass -// ignore-tidy-linelength - // Regression for #93775, needs build-pass to test it. +//@ build-pass +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + #![recursion_limit = "1001"] use std::marker::PhantomData; @@ -14,7 +16,64 @@ use std::marker::PhantomData; struct Z; struct S<T>(PhantomData<T>); -type Nested = S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<Z>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; +type Nested = S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S +<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<S<Z>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>; trait AsNum { const NUM: u32; diff --git a/tests/ui/associated-consts/issue-93835.rs b/tests/ui/associated-consts/issue-93835.rs index 9cc33d53f9c..048681f0477 100644 --- a/tests/ui/associated-consts/issue-93835.rs +++ b/tests/ui/associated-consts/issue-93835.rs @@ -3,9 +3,11 @@ fn e() { type_ascribe!(p, a<p:p<e=6>>); //~^ ERROR cannot find type `a` in this scope + //~| ERROR path separator must be a double colon //~| ERROR cannot find value //~| ERROR associated const equality - //~| ERROR cannot find trait `p` in this scope + //~| ERROR associated const equality + //~| ERROR failed to resolve: use of unresolved module or unlinked crate `p` } fn main() {} diff --git a/tests/ui/associated-consts/issue-93835.stderr b/tests/ui/associated-consts/issue-93835.stderr index dfe78b3d1f3..e154ae25de2 100644 --- a/tests/ui/associated-consts/issue-93835.stderr +++ b/tests/ui/associated-consts/issue-93835.stderr @@ -1,3 +1,15 @@ +error: path separator must be a double colon + --> $DIR/issue-93835.rs:4:25 + | +LL | type_ascribe!(p, a<p:p<e=6>>); + | ^ + | + = note: if you meant to annotate an expression with a type, the type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728> +help: use a double colon instead + | +LL | type_ascribe!(p, a<p::p<e=6>>); + | + + error[E0425]: cannot find value `p` in this scope --> $DIR/issue-93835.rs:4:19 | @@ -10,11 +22,15 @@ error[E0412]: cannot find type `a` in this scope LL | type_ascribe!(p, a<p:p<e=6>>); | ^ not found in this scope -error[E0405]: cannot find trait `p` in this scope - --> $DIR/issue-93835.rs:4:26 +error[E0658]: associated const equality is incomplete + --> $DIR/issue-93835.rs:4:28 | LL | type_ascribe!(p, a<p:p<e=6>>); - | ^ not found in this scope + | ^^^ + | + = note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information + = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: associated const equality is incomplete --> $DIR/issue-93835.rs:4:28 @@ -25,8 +41,17 @@ LL | type_ascribe!(p, a<p:p<e=6>>); = note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0433]: failed to resolve: use of unresolved module or unlinked crate `p` + --> $DIR/issue-93835.rs:4:24 + | +LL | type_ascribe!(p, a<p:p<e=6>>); + | ^ use of unresolved module or unlinked crate `p` + | + = help: you might be missing a crate named `p` -error: aborting due to 4 previous errors +error: aborting due to 6 previous errors -Some errors have detailed explanations: E0405, E0412, E0425, E0658. -For more information about an error, try `rustc --explain E0405`. +Some errors have detailed explanations: E0412, E0425, E0433, E0658. +For more information about an error, try `rustc --explain E0412`. diff --git a/tests/ui/associated-inherent-types/issue-109768.stderr b/tests/ui/associated-inherent-types/issue-109768.stderr index 18455f4669e..59f8526a73e 100644 --- a/tests/ui/associated-inherent-types/issue-109768.stderr +++ b/tests/ui/associated-inherent-types/issue-109768.stderr @@ -43,9 +43,8 @@ LL | struct Wrapper<T>(T); | ^^^^^^^ help: provide the argument | -LL - const WRAPPED_ASSOC_3: Wrapper<Self::AssocType3> = Wrapper(); -LL + const WRAPPED_ASSOC_3: Wrapper<Self::AssocType3> = Wrapper(/* value */); - | +LL | const WRAPPED_ASSOC_3: Wrapper<Self::AssocType3> = Wrapper(/* value */); + | +++++++++++ error: aborting due to 4 previous errors diff --git a/tests/ui/associated-item/associated-item-enum.stderr b/tests/ui/associated-item/associated-item-enum.stderr index 49f168b8544..c3ce7c34d05 100644 --- a/tests/ui/associated-item/associated-item-enum.stderr +++ b/tests/ui/associated-item/associated-item-enum.stderr @@ -9,9 +9,8 @@ LL | Enum::mispellable(); | help: there is an associated function `misspellable` with a similar name | -LL - Enum::mispellable(); -LL + Enum::misspellable(); - | +LL | Enum::misspellable(); + | + error[E0599]: no variant or associated item named `mispellable_trait` found for enum `Enum` in the current scope --> $DIR/associated-item-enum.rs:18:11 @@ -24,9 +23,8 @@ LL | Enum::mispellable_trait(); | help: there is an associated function `misspellable_trait` with a similar name | -LL - Enum::mispellable_trait(); -LL + Enum::misspellable_trait(); - | +LL | Enum::misspellable_trait(); + | + error[E0599]: no variant or associated item named `MISPELLABLE` found for enum `Enum` in the current scope --> $DIR/associated-item-enum.rs:19:11 @@ -39,9 +37,8 @@ LL | Enum::MISPELLABLE; | help: there is an associated constant `MISSPELLABLE` with a similar name | -LL - Enum::MISPELLABLE; -LL + Enum::MISSPELLABLE; - | +LL | Enum::MISSPELLABLE; + | + error: aborting due to 3 previous errors diff --git a/tests/ui/associated-types/associated-types-overridden-binding-2.rs b/tests/ui/associated-types/associated-types-overridden-binding-2.rs index fed60ccf089..247724eaaf1 100644 --- a/tests/ui/associated-types/associated-types-overridden-binding-2.rs +++ b/tests/ui/associated-types/associated-types-overridden-binding-2.rs @@ -4,5 +4,5 @@ trait I32Iterator = Iterator<Item = i32>; fn main() { let _: &dyn I32Iterator<Item = u32> = &vec![42].into_iter(); - //~^ ERROR expected `IntoIter<u32>` to be an iterator that yields `i32`, but it yields `u32` + //~^ ERROR conflicting associated type bounds } diff --git a/tests/ui/associated-types/associated-types-overridden-binding-2.stderr b/tests/ui/associated-types/associated-types-overridden-binding-2.stderr index 4dfd275a190..71a4a2610aa 100644 --- a/tests/ui/associated-types/associated-types-overridden-binding-2.stderr +++ b/tests/ui/associated-types/associated-types-overridden-binding-2.stderr @@ -1,11 +1,13 @@ -error[E0271]: expected `IntoIter<u32>` to be an iterator that yields `i32`, but it yields `u32` - --> $DIR/associated-types-overridden-binding-2.rs:6:43 +error: conflicting associated type bounds for `Item` when expanding trait alias + --> $DIR/associated-types-overridden-binding-2.rs:6:13 | +LL | trait I32Iterator = Iterator<Item = i32>; + | ---------- `Item` is specified to be `i32` here +... LL | let _: &dyn I32Iterator<Item = u32> = &vec![42].into_iter(); - | ^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `u32` - | - = note: required for the cast from `&std::vec::IntoIter<u32>` to `&dyn Iterator<Item = u32, Item = i32>` + | ^^^^^^^^^^^^^^^^----------^ + | | + | `Item` is specified to be `u32` here error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/associated-types/associated-types-overridden-binding.rs b/tests/ui/associated-types/associated-types-overridden-binding.rs index 9a64a06c31b..333a3e30c7d 100644 --- a/tests/ui/associated-types/associated-types-overridden-binding.rs +++ b/tests/ui/associated-types/associated-types-overridden-binding.rs @@ -8,4 +8,5 @@ trait U32Iterator = I32Iterator<Item = u32>; //~ ERROR type annotations needed fn main() { let _: &dyn I32Iterator<Item = u32>; + //~^ ERROR conflicting associated type bounds } diff --git a/tests/ui/associated-types/associated-types-overridden-binding.stderr b/tests/ui/associated-types/associated-types-overridden-binding.stderr index dc087e4185f..3b20015dfca 100644 --- a/tests/ui/associated-types/associated-types-overridden-binding.stderr +++ b/tests/ui/associated-types/associated-types-overridden-binding.stderr @@ -22,6 +22,17 @@ note: required by a bound in `I32Iterator` LL | trait I32Iterator = Iterator<Item = i32>; | ^^^^^^^^^^ required by this bound in `I32Iterator` -error: aborting due to 2 previous errors +error: conflicting associated type bounds for `Item` when expanding trait alias + --> $DIR/associated-types-overridden-binding.rs:10:13 + | +LL | trait I32Iterator = Iterator<Item = i32>; + | ---------- `Item` is specified to be `i32` here +... +LL | let _: &dyn I32Iterator<Item = u32>; + | ^^^^^^^^^^^^^^^^----------^ + | | + | `Item` is specified to be `u32` here + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/async-await/issue-84841.stderr b/tests/ui/async-await/issue-84841.stderr index 69c1c882d60..0d008477310 100644 --- a/tests/ui/async-await/issue-84841.stderr +++ b/tests/ui/async-await/issue-84841.stderr @@ -17,8 +17,6 @@ LL | | test()?; ... | LL | | } | |_- this function should return `Result` or `Option` to accept `?` - | - = help: the trait `FromResidual<_>` is not implemented for `()` error: aborting due to 2 previous errors diff --git a/tests/ui/async-await/try-on-option-in-async.stderr b/tests/ui/async-await/try-on-option-in-async.stderr index 9e0bb42a697..332f4d4ec0c 100644 --- a/tests/ui/async-await/try-on-option-in-async.stderr +++ b/tests/ui/async-await/try-on-option-in-async.stderr @@ -6,8 +6,6 @@ LL | async { LL | let x: Option<u32> = None; LL | x?; | ^ cannot use the `?` operator in an async block that returns `{integer}` - | - = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `{integer}` error[E0277]: the `?` operator can only be used in an async closure that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-on-option-in-async.rs:16:10 @@ -20,8 +18,6 @@ LL | | x?; LL | | 22_u32 LL | | }; | |_____- this function should return `Result` or `Option` to accept `?` - | - = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32` error[E0277]: the `?` operator can only be used in an async function that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-on-option-in-async.rs:25:6 @@ -34,8 +30,6 @@ LL | | x?; LL | | 22 LL | | } | |_- this function should return `Result` or `Option` to accept `?` - | - = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32` error: aborting due to 3 previous errors diff --git a/tests/ui/attributes/key-value-expansion-scope.rs b/tests/ui/attributes/key-value-expansion-scope.rs index b6eab1571d4..49a59502377 100644 --- a/tests/ui/attributes/key-value-expansion-scope.rs +++ b/tests/ui/attributes/key-value-expansion-scope.rs @@ -1,7 +1,7 @@ -#![doc = in_root!()] //~ WARN cannot find macro `in_root` in this scope +#![doc = in_root!()] //~ WARN cannot find macro `in_root` //~| WARN this was previously accepted by the compiler #![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope -#![doc = in_mod_escape!()] //~ WARN cannot find macro `in_mod_escape` in this scope +#![doc = in_mod_escape!()] //~ WARN cannot find macro `in_mod_escape` //~| WARN this was previously accepted by the compiler #![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope @@ -18,10 +18,10 @@ fn before() { macro_rules! in_root { () => { "" } } -#[doc = in_mod!()] //~ WARN cannot find macro `in_mod` in this scope +#[doc = in_mod!()] //~ WARN cannot find macro `in_mod` //~| WARN this was previously accepted by the compiler mod macros_stay { - #![doc = in_mod!()] //~ WARN cannot find macro `in_mod` in this scope + #![doc = in_mod!()] //~ WARN cannot find macro `in_mod` //~| WARN this was previously accepted by the compiler macro_rules! in_mod { () => { "" } } @@ -33,10 +33,10 @@ mod macros_stay { } #[macro_use] -#[doc = in_mod_escape!()] //~ WARN cannot find macro `in_mod_escape` in this scope +#[doc = in_mod_escape!()] //~ WARN cannot find macro `in_mod_escape` //~| WARN this was previously accepted by the compiler mod macros_escape { - #![doc = in_mod_escape!()] //~ WARN cannot find macro `in_mod_escape` in this scope + #![doc = in_mod_escape!()] //~ WARN cannot find macro `in_mod_escape` //~| WARN this was previously accepted by the compiler macro_rules! in_mod_escape { () => { "" } } diff --git a/tests/ui/attributes/key-value-expansion-scope.stderr b/tests/ui/attributes/key-value-expansion-scope.stderr index d22fef7dd25..91a602e57d9 100644 --- a/tests/ui/attributes/key-value-expansion-scope.stderr +++ b/tests/ui/attributes/key-value-expansion-scope.stderr @@ -126,62 +126,62 @@ LL | #![doc = in_block!()] | = help: have you added the `#[macro_use]` on the module/import? -warning: cannot find macro `in_root` in this scope +warning: cannot find macro `in_root` in the current scope when looking from the crate root --> $DIR/key-value-expansion-scope.rs:1:10 | LL | #![doc = in_root!()] - | ^^^^^^^ + | ^^^^^^^ not found from the crate root | = 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 #124535 <https://github.com/rust-lang/rust/issues/124535> = help: import `macro_rules` with `use` to make it callable above its definition = note: `#[warn(out_of_scope_macro_calls)]` on by default -warning: cannot find macro `in_mod_escape` in this scope +warning: cannot find macro `in_mod_escape` in the current scope when looking from the crate root --> $DIR/key-value-expansion-scope.rs:4:10 | LL | #![doc = in_mod_escape!()] - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ not found from the crate root | = 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 #124535 <https://github.com/rust-lang/rust/issues/124535> = help: import `macro_rules` with `use` to make it callable above its definition -warning: cannot find macro `in_mod` in this scope +warning: cannot find macro `in_mod` in the current scope when looking from module `macros_stay` --> $DIR/key-value-expansion-scope.rs:21:9 | LL | #[doc = in_mod!()] - | ^^^^^^ + | ^^^^^^ not found from module `macros_stay` | = 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 #124535 <https://github.com/rust-lang/rust/issues/124535> = help: import `macro_rules` with `use` to make it callable above its definition -warning: cannot find macro `in_mod` in this scope +warning: cannot find macro `in_mod` in the current scope when looking from module `macros_stay` --> $DIR/key-value-expansion-scope.rs:24:14 | LL | #![doc = in_mod!()] - | ^^^^^^ + | ^^^^^^ not found from module `macros_stay` | = 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 #124535 <https://github.com/rust-lang/rust/issues/124535> = help: import `macro_rules` with `use` to make it callable above its definition -warning: cannot find macro `in_mod_escape` in this scope +warning: cannot find macro `in_mod_escape` in the current scope when looking from module `macros_escape` --> $DIR/key-value-expansion-scope.rs:36:9 | LL | #[doc = in_mod_escape!()] - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ not found from module `macros_escape` | = 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 #124535 <https://github.com/rust-lang/rust/issues/124535> = help: import `macro_rules` with `use` to make it callable above its definition -warning: cannot find macro `in_mod_escape` in this scope +warning: cannot find macro `in_mod_escape` in the current scope when looking from module `macros_escape` --> $DIR/key-value-expansion-scope.rs:39:14 | LL | #![doc = in_mod_escape!()] - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ not found from module `macros_escape` | = 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 #124535 <https://github.com/rust-lang/rust/issues/124535> diff --git a/tests/ui/binop/placement-syntax.stderr b/tests/ui/binop/placement-syntax.stderr index e398c0b0702..c07ee7184c7 100644 --- a/tests/ui/binop/placement-syntax.stderr +++ b/tests/ui/binop/placement-syntax.stderr @@ -6,9 +6,8 @@ LL | if x<-1 { | help: if you meant to write a comparison against a negative value, add a space in between `<` and `-` | -LL - if x<-1 { -LL + if x< -1 { - | +LL | if x< -1 { + | + error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/bad-drop-side-effects.rs b/tests/ui/borrowck/bad-drop-side-effects.rs new file mode 100644 index 00000000000..a09b7087608 --- /dev/null +++ b/tests/ui/borrowck/bad-drop-side-effects.rs @@ -0,0 +1,18 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/137288>. + +trait B { + type C; +} + +impl<U> B for &Missing { +//~^ ERROR cannot find type `Missing` in this scope + type C = (); +} + +struct E<T: B> { + g: <T as B>::C, +} + +fn h(i: Box<E<&()>>) {} + +fn main() {} diff --git a/tests/ui/borrowck/bad-drop-side-effects.stderr b/tests/ui/borrowck/bad-drop-side-effects.stderr new file mode 100644 index 00000000000..0a5998c7e48 --- /dev/null +++ b/tests/ui/borrowck/bad-drop-side-effects.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `Missing` in this scope + --> $DIR/bad-drop-side-effects.rs:7:16 + | +LL | impl<U> B for &Missing { + | ^^^^^^^ not found in this scope + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/borrowck/borrowck-struct-update-with-dtor.stderr b/tests/ui/borrowck/borrowck-struct-update-with-dtor.stderr index d953ed2ad3e..5cc5b87cd44 100644 --- a/tests/ui/borrowck/borrowck-struct-update-with-dtor.stderr +++ b/tests/ui/borrowck/borrowck-struct-update-with-dtor.stderr @@ -116,9 +116,8 @@ LL | let _s2 = T { ..s0 }; | help: clone the value from the field instead of using the functional record update syntax | -LL - let _s2 = T { ..s0 }; -LL + let _s2 = T { b: s0.b.clone(), ..s0 }; - | +LL | let _s2 = T { b: s0.b.clone(), ..s0 }; + | ++++++++++++++++ error[E0509]: cannot move out of type `T`, which implements the `Drop` trait --> $DIR/borrowck-struct-update-with-dtor.rs:47:32 diff --git a/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr b/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr index 1e3570fc855..a392177ffe2 100644 --- a/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr +++ b/tests/ui/borrowck/borrowck-unsafe-static-mutable-borrows.stderr @@ -9,9 +9,8 @@ LL | let sfoo: *mut Foo = &mut SFOO; = note: `#[warn(static_mut_refs)]` on by default help: use `&raw mut` instead to create a raw pointer | -LL - let sfoo: *mut Foo = &mut SFOO; -LL + let sfoo: *mut Foo = &raw mut SFOO; - | +LL | let sfoo: *mut Foo = &raw mut SFOO; + | +++ warning: 1 warning emitted diff --git a/tests/ui/borrowck/issue-85765-closure.stderr b/tests/ui/borrowck/issue-85765-closure.stderr index fa4e5441508..cd2544ec5c9 100644 --- a/tests/ui/borrowck/issue-85765-closure.stderr +++ b/tests/ui/borrowck/issue-85765-closure.stderr @@ -6,9 +6,8 @@ LL | rofl.push(Vec::new()); | help: consider changing this binding's type | -LL - let rofl: &Vec<Vec<i32>> = &mut test; -LL + let rofl: &mut Vec<Vec<i32>> = &mut test; - | +LL | let rofl: &mut Vec<Vec<i32>> = &mut test; + | +++ error[E0594]: cannot assign to `*r`, which is behind a `&` reference --> $DIR/issue-85765-closure.rs:13:9 @@ -29,9 +28,8 @@ LL | *x = 1; | help: consider changing this binding's type | -LL - let x: &usize = &mut{0}; -LL + let x: &mut usize = &mut{0}; - | +LL | let x: &mut usize = &mut{0}; + | +++ error[E0594]: cannot assign to `*y`, which is behind a `&` reference --> $DIR/issue-85765-closure.rs:27:9 @@ -41,9 +39,8 @@ LL | *y = 1; | help: consider changing this binding's type | -LL - let y: &usize = &mut(0); -LL + let y: &mut usize = &mut(0); - | +LL | let y: &mut usize = &mut(0); + | +++ error: aborting due to 4 previous errors diff --git a/tests/ui/borrowck/issue-85765.stderr b/tests/ui/borrowck/issue-85765.stderr index 9354294f52b..e252f3d44d9 100644 --- a/tests/ui/borrowck/issue-85765.stderr +++ b/tests/ui/borrowck/issue-85765.stderr @@ -6,9 +6,8 @@ LL | rofl.push(Vec::new()); | help: consider changing this binding's type | -LL - let rofl: &Vec<Vec<i32>> = &mut test; -LL + let rofl: &mut Vec<Vec<i32>> = &mut test; - | +LL | let rofl: &mut Vec<Vec<i32>> = &mut test; + | +++ error[E0594]: cannot assign to `*r`, which is behind a `&` reference --> $DIR/issue-85765.rs:12:5 @@ -29,9 +28,8 @@ LL | *x = 1; | help: consider changing this binding's type | -LL - let x: &usize = &mut{0}; -LL + let x: &mut usize = &mut{0}; - | +LL | let x: &mut usize = &mut{0}; + | +++ error[E0594]: cannot assign to `*y`, which is behind a `&` reference --> $DIR/issue-85765.rs:26:5 @@ -41,9 +39,8 @@ LL | *y = 1; | help: consider changing this binding's type | -LL - let y: &usize = &mut(0); -LL + let y: &mut usize = &mut(0); - | +LL | let y: &mut usize = &mut(0); + | +++ error: aborting due to 4 previous errors diff --git a/tests/ui/c-variadic/variadic-ffi-1.stderr b/tests/ui/c-variadic/variadic-ffi-1.stderr index 061eae9729e..39dfb2548a3 100644 --- a/tests/ui/c-variadic/variadic-ffi-1.stderr +++ b/tests/ui/c-variadic/variadic-ffi-1.stderr @@ -17,9 +17,8 @@ LL | fn foo(f: isize, x: u8, ...); | ^^^ - - help: provide the arguments | -LL - foo(); -LL + foo(/* isize */, /* u8 */); - | +LL | foo(/* isize */, /* u8 */); + | +++++++++++++++++++++ error[E0060]: this function takes at least 2 arguments but 1 argument was supplied --> $DIR/variadic-ffi-1.rs:23:9 @@ -34,9 +33,8 @@ LL | fn foo(f: isize, x: u8, ...); | ^^^ - help: provide the argument | -LL - foo(1); -LL + foo(1, /* u8 */); - | +LL | foo(1, /* u8 */); + | ++++++++++ error[E0308]: mismatched types --> $DIR/variadic-ffi-1.rs:25:56 diff --git a/tests/ui/cast/ice-cast-type-with-error-124848.stderr b/tests/ui/cast/ice-cast-type-with-error-124848.stderr index 402ee27386d..0b2ab1dfc4c 100644 --- a/tests/ui/cast/ice-cast-type-with-error-124848.stderr +++ b/tests/ui/cast/ice-cast-type-with-error-124848.stderr @@ -48,9 +48,8 @@ LL | struct MyType<'a>(Cell<Option<&'unpinned mut MyType<'a>>>, Pin); | ^^^^^^ help: provide the argument | -LL - let mut unpinned = MyType(Cell::new(None)); -LL + let mut unpinned = MyType(Cell::new(None), /* value */); - | +LL | let mut unpinned = MyType(Cell::new(None), /* value */); + | +++++++++++++ error[E0606]: casting `&MyType<'_>` as `*const Cell<Option<&mut MyType<'_>>>` is invalid --> $DIR/ice-cast-type-with-error-124848.rs:14:20 diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr index 70852423bdb..51808c5c7bc 100644 --- a/tests/ui/check-cfg/target_feature.stderr +++ b/tests/ui/check-cfg/target_feature.stderr @@ -58,6 +58,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `cssc` `d` `d32` +`deflate-conversion` `dit` `doloop` `dotprod` @@ -72,6 +73,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `ecv` `edsp` `elrw` +`enhanced-sort` `ermsb` `exception-handling` `extended-const` @@ -109,11 +111,13 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `frintts` `fxsr` `gfni` +`guarded-storage` `hard-float` `hard-float-abi` `hard-tp` `hbc` `high-registers` +`high-word` `hvx` `hvx-length128b` `hwdiv` @@ -151,6 +155,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `multivalue` `mutable-globals` `neon` +`nnp-assist` `nontrapping-fptoint` `nvic` `paca` @@ -229,6 +234,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `thumb-mode` `thumb2` `tme` +`transactional-execution` `trust` `trustzone` `ual` @@ -262,6 +268,11 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `vdspv1` `vdspv2` `vector` +`vector-enhancements-1` +`vector-enhancements-2` +`vector-packed-decimal` +`vector-packed-decimal-enhancement` +`vector-packed-decimal-enhancement-2` `vfp2` `vfp3` `vfp4` diff --git a/tests/ui/closures/deduce-from-object-supertrait.rs b/tests/ui/closures/deduce-from-object-supertrait.rs new file mode 100644 index 00000000000..aff750dc62e --- /dev/null +++ b/tests/ui/closures/deduce-from-object-supertrait.rs @@ -0,0 +1,18 @@ +//@ check-pass + +// This test checks that we look at consider the super traits of trait objects +// when deducing closure signatures. + +trait Foo: Fn(Bar) {} +impl<T> Foo for T where T: Fn(Bar) {} + +struct Bar; +impl Bar { + fn bar(&self) {} +} + +fn main() { + let x: &dyn Foo = &|x| { + x.bar(); + }; +} diff --git a/tests/ui/conditional-compilation/cfg-attr-parse.stderr b/tests/ui/conditional-compilation/cfg-attr-parse.stderr index 1605761e591..76f199caace 100644 --- a/tests/ui/conditional-compilation/cfg-attr-parse.stderr +++ b/tests/ui/conditional-compilation/cfg-attr-parse.stderr @@ -7,9 +7,8 @@ LL | #[cfg_attr()] = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute> help: missing condition and attribute | -LL - #[cfg_attr()] -LL + #[cfg_attr(condition, attribute, other_attribute, ...)] - | +LL | #[cfg_attr(condition, attribute, other_attribute, ...)] + | ++++++++++++++++++++++++++++++++++++++++++ error: expected `,`, found end of `cfg_attr` input --> $DIR/cfg-attr-parse.rs:8:17 diff --git a/tests/ui/consts/const_let_assign2.stderr b/tests/ui/consts/const_let_assign2.stderr index be0ffefc80d..0d76f142d17 100644 --- a/tests/ui/consts/const_let_assign2.stderr +++ b/tests/ui/consts/const_let_assign2.stderr @@ -9,9 +9,8 @@ LL | let ptr = unsafe { &mut BB }; = note: `#[warn(static_mut_refs)]` on by default help: use `&raw mut` instead to create a raw pointer | -LL - let ptr = unsafe { &mut BB }; -LL + let ptr = unsafe { &raw mut BB }; - | +LL | let ptr = unsafe { &raw mut BB }; + | +++ warning: 1 warning emitted diff --git a/tests/ui/coroutine/issue-102645.stderr b/tests/ui/coroutine/issue-102645.stderr index bec0518d8c6..be16674668e 100644 --- a/tests/ui/coroutine/issue-102645.stderr +++ b/tests/ui/coroutine/issue-102645.stderr @@ -8,9 +8,8 @@ note: method defined here --> $SRC_DIR/core/src/ops/coroutine.rs:LL:COL help: provide the argument | -LL - Pin::new(&mut b).resume(); -LL + Pin::new(&mut b).resume(()); - | +LL | Pin::new(&mut b).resume(()); + | ++ error: aborting due to 1 previous error diff --git a/tests/ui/coroutine/resume-arg-outlives.stderr b/tests/ui/coroutine/resume-arg-outlives.stderr index 0150009c8fa..045c77e8d05 100644 --- a/tests/ui/coroutine/resume-arg-outlives.stderr +++ b/tests/ui/coroutine/resume-arg-outlives.stderr @@ -9,9 +9,8 @@ LL | generator | help: consider changing `impl Coroutine<&'not_static str> + 'static`'s explicit `'static` bound to the lifetime of argument `s` | -LL - fn demo<'not_static>(s: &'not_static str) -> Pin<Box<impl Coroutine<&'not_static str> + 'static>> { -LL + fn demo<'not_static>(s: &'not_static str) -> Pin<Box<impl Coroutine<&'not_static str> + 'not_static>> { - | +LL | fn demo<'not_static>(s: &'not_static str) -> Pin<Box<impl Coroutine<&'not_static str> + 'not_static>> { + | ++++ help: alternatively, add an explicit `'static` bound to this reference | LL - fn demo<'not_static>(s: &'not_static str) -> Pin<Box<impl Coroutine<&'not_static str> + 'static>> { diff --git a/tests/ui/coverage-attr/bad-attr-ice.feat.stderr b/tests/ui/coverage-attr/bad-attr-ice.feat.stderr index a8a70e363b7..dc84394fe3c 100644 --- a/tests/ui/coverage-attr/bad-attr-ice.feat.stderr +++ b/tests/ui/coverage-attr/bad-attr-ice.feat.stderr @@ -6,12 +6,10 @@ LL | #[coverage] | help: the following are the possible correct uses | -LL - #[coverage] -LL + #[coverage(off)] - | -LL - #[coverage] -LL + #[coverage(on)] - | +LL | #[coverage(off)] + | +++++ +LL | #[coverage(on)] + | ++++ error: aborting due to 1 previous error diff --git a/tests/ui/coverage-attr/bad-attr-ice.nofeat.stderr b/tests/ui/coverage-attr/bad-attr-ice.nofeat.stderr index 6443fafef3e..49b8974bfdf 100644 --- a/tests/ui/coverage-attr/bad-attr-ice.nofeat.stderr +++ b/tests/ui/coverage-attr/bad-attr-ice.nofeat.stderr @@ -6,12 +6,10 @@ LL | #[coverage] | help: the following are the possible correct uses | -LL - #[coverage] -LL + #[coverage(off)] - | -LL - #[coverage] -LL + #[coverage(on)] - | +LL | #[coverage(off)] + | +++++ +LL | #[coverage(on)] + | ++++ error[E0658]: the `#[coverage]` attribute is an experimental feature --> $DIR/bad-attr-ice.rs:11:1 diff --git a/tests/ui/coverage-attr/bad-syntax.stderr b/tests/ui/coverage-attr/bad-syntax.stderr index 3123066e7bf..fa500b54209 100644 --- a/tests/ui/coverage-attr/bad-syntax.stderr +++ b/tests/ui/coverage-attr/bad-syntax.stderr @@ -6,12 +6,10 @@ LL | #[coverage] | help: the following are the possible correct uses | -LL - #[coverage] -LL + #[coverage(off)] - | -LL - #[coverage] -LL + #[coverage(on)] - | +LL | #[coverage(off)] + | +++++ +LL | #[coverage(on)] + | ++++ error: malformed `coverage` attribute input --> $DIR/bad-syntax.rs:20:1 @@ -36,12 +34,10 @@ LL | #[coverage()] | help: the following are the possible correct uses | -LL - #[coverage()] -LL + #[coverage(off)] - | -LL - #[coverage()] -LL + #[coverage(on)] - | +LL | #[coverage(off)] + | +++ +LL | #[coverage(on)] + | ++ error: malformed `coverage` attribute input --> $DIR/bad-syntax.rs:26:1 diff --git a/tests/ui/coverage-attr/word-only.stderr b/tests/ui/coverage-attr/word-only.stderr index c034149d8ec..612301885dc 100644 --- a/tests/ui/coverage-attr/word-only.stderr +++ b/tests/ui/coverage-attr/word-only.stderr @@ -6,12 +6,10 @@ LL | #[coverage] | help: the following are the possible correct uses | -LL - #[coverage] -LL + #[coverage(off)] - | -LL - #[coverage] -LL + #[coverage(on)] - | +LL | #[coverage(off)] + | +++++ +LL | #[coverage(on)] + | ++++ error: malformed `coverage` attribute input --> $DIR/word-only.rs:17:5 @@ -21,12 +19,10 @@ LL | #![coverage] | help: the following are the possible correct uses | -LL - #![coverage] -LL + #![coverage(off)] - | -LL - #![coverage] -LL + #![coverage(on)] - | +LL | #![coverage(off)] + | +++++ +LL | #![coverage(on)] + | ++++ error: malformed `coverage` attribute input --> $DIR/word-only.rs:21:1 @@ -36,12 +32,10 @@ LL | #[coverage] | help: the following are the possible correct uses | -LL - #[coverage] -LL + #[coverage(off)] - | -LL - #[coverage] -LL + #[coverage(on)] - | +LL | #[coverage(off)] + | +++++ +LL | #[coverage(on)] + | ++++ error: malformed `coverage` attribute input --> $DIR/word-only.rs:29:5 @@ -51,12 +45,10 @@ LL | #[coverage] | help: the following are the possible correct uses | -LL - #[coverage] -LL + #[coverage(off)] - | -LL - #[coverage] -LL + #[coverage(on)] - | +LL | #[coverage(off)] + | +++++ +LL | #[coverage(on)] + | ++++ error: malformed `coverage` attribute input --> $DIR/word-only.rs:26:1 @@ -66,12 +58,10 @@ LL | #[coverage] | help: the following are the possible correct uses | -LL - #[coverage] -LL + #[coverage(off)] - | -LL - #[coverage] -LL + #[coverage(on)] - | +LL | #[coverage(off)] + | +++++ +LL | #[coverage(on)] + | ++++ error: malformed `coverage` attribute input --> $DIR/word-only.rs:39:5 @@ -81,12 +71,10 @@ LL | #[coverage] | help: the following are the possible correct uses | -LL - #[coverage] -LL + #[coverage(off)] - | -LL - #[coverage] -LL + #[coverage(on)] - | +LL | #[coverage(off)] + | +++++ +LL | #[coverage(on)] + | ++++ error: malformed `coverage` attribute input --> $DIR/word-only.rs:44:5 @@ -96,12 +84,10 @@ LL | #[coverage] | help: the following are the possible correct uses | -LL - #[coverage] -LL + #[coverage(off)] - | -LL - #[coverage] -LL + #[coverage(on)] - | +LL | #[coverage(off)] + | +++++ +LL | #[coverage(on)] + | ++++ error: malformed `coverage` attribute input --> $DIR/word-only.rs:35:1 @@ -111,12 +97,10 @@ LL | #[coverage] | help: the following are the possible correct uses | -LL - #[coverage] -LL + #[coverage(off)] - | -LL - #[coverage] -LL + #[coverage(on)] - | +LL | #[coverage(off)] + | +++++ +LL | #[coverage(on)] + | ++++ error: malformed `coverage` attribute input --> $DIR/word-only.rs:53:5 @@ -126,12 +110,10 @@ LL | #[coverage] | help: the following are the possible correct uses | -LL - #[coverage] -LL + #[coverage(off)] - | -LL - #[coverage] -LL + #[coverage(on)] - | +LL | #[coverage(off)] + | +++++ +LL | #[coverage(on)] + | ++++ error: malformed `coverage` attribute input --> $DIR/word-only.rs:58:5 @@ -141,12 +123,10 @@ LL | #[coverage] | help: the following are the possible correct uses | -LL - #[coverage] -LL + #[coverage(off)] - | -LL - #[coverage] -LL + #[coverage(on)] - | +LL | #[coverage(off)] + | +++++ +LL | #[coverage(on)] + | ++++ error: malformed `coverage` attribute input --> $DIR/word-only.rs:50:1 @@ -156,12 +136,10 @@ LL | #[coverage] | help: the following are the possible correct uses | -LL - #[coverage] -LL + #[coverage(off)] - | -LL - #[coverage] -LL + #[coverage(on)] - | +LL | #[coverage(off)] + | +++++ +LL | #[coverage(on)] + | ++++ error: malformed `coverage` attribute input --> $DIR/word-only.rs:64:1 @@ -171,12 +149,10 @@ LL | #[coverage] | help: the following are the possible correct uses | -LL - #[coverage] -LL + #[coverage(off)] - | -LL - #[coverage] -LL + #[coverage(on)] - | +LL | #[coverage(off)] + | +++++ +LL | #[coverage(on)] + | ++++ error[E0788]: coverage attribute not allowed here --> $DIR/word-only.rs:21:1 diff --git a/tests/ui/destructuring-assignment/struct_destructure_fail.stderr b/tests/ui/destructuring-assignment/struct_destructure_fail.stderr index 7efc0b20e54..2d02e33b258 100644 --- a/tests/ui/destructuring-assignment/struct_destructure_fail.stderr +++ b/tests/ui/destructuring-assignment/struct_destructure_fail.stderr @@ -31,9 +31,8 @@ LL + Struct { a, b } = Struct { a: 1, b: 2 }; | help: if you don't care about this missing field, you can explicitly ignore it | -LL - Struct { a, _ } = Struct { a: 1, b: 2 }; -LL + Struct { a, b: _ } = Struct { a: 1, b: 2 }; - | +LL | Struct { a, b: _ } = Struct { a: 1, b: 2 }; + | ++ help: or always ignore missing fields here | LL - Struct { a, _ } = Struct { a: 1, b: 2 }; diff --git a/tests/ui/diagnostic_namespace/suggest_typos.stderr b/tests/ui/diagnostic_namespace/suggest_typos.stderr index f41e2f65556..86d778c6ec0 100644 --- a/tests/ui/diagnostic_namespace/suggest_typos.stderr +++ b/tests/ui/diagnostic_namespace/suggest_typos.stderr @@ -11,9 +11,8 @@ LL | #![deny(unknown_or_malformed_diagnostic_attributes)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: an attribute with a similar name exists | -LL - #[diagnostic::onunimplemented] -LL + #[diagnostic::on_unimplemented] - | +LL | #[diagnostic::on_unimplemented] + | + error: unknown diagnostic attribute --> $DIR/suggest_typos.rs:9:15 @@ -35,9 +34,8 @@ LL | #[diagnostic::on_implemented] | help: an attribute with a similar name exists | -LL - #[diagnostic::on_implemented] -LL + #[diagnostic::on_unimplemented] - | +LL | #[diagnostic::on_unimplemented] + | ++ error: aborting due to 3 previous errors diff --git a/tests/ui/dyn-compatibility/multiple-supers-should-work.rs b/tests/ui/dyn-compatibility/multiple-supers-should-work.rs new file mode 100644 index 00000000000..6f381da9a22 --- /dev/null +++ b/tests/ui/dyn-compatibility/multiple-supers-should-work.rs @@ -0,0 +1,21 @@ +//@ check-pass + +// We previously incorrectly deduplicated the list of projection bounds +// of trait objects, causing us to incorrectly reject this code, cc #136458. + +trait Sup<T> { + type Assoc; +} + +impl<T> Sup<T> for () { + type Assoc = T; +} + +trait Trait<A, B>: Sup<A, Assoc = A> + Sup<B, Assoc = B> {} + +impl<T, U> Trait<T, U> for () {} + +fn main() { + let x: &dyn Trait<(), _> = &(); + let y: &dyn Trait<_, ()> = x; +} diff --git a/tests/ui/error-codes/E0027.stderr b/tests/ui/error-codes/E0027.stderr index 3a1ebf29719..72f20a84556 100644 --- a/tests/ui/error-codes/E0027.stderr +++ b/tests/ui/error-codes/E0027.stderr @@ -25,19 +25,16 @@ LL | Dog { name: x, } => {} | help: include the missing field in the pattern | -LL - Dog { name: x, } => {} -LL + Dog { name: x, age } => {} - | +LL | Dog { name: x, age } => {} + | +++ help: if you don't care about this missing field, you can explicitly ignore it | -LL - Dog { name: x, } => {} -LL + Dog { name: x, age: _ } => {} - | +LL | Dog { name: x, age: _ } => {} + | ++++++ help: or always ignore missing fields here | -LL - Dog { name: x, } => {} -LL + Dog { name: x, .. } => {} - | +LL | Dog { name: x, .. } => {} + | ++ error[E0027]: pattern does not mention field `age` --> $DIR/E0027.rs:19:9 @@ -47,19 +44,16 @@ LL | Dog { name: x , } => {} | help: include the missing field in the pattern | -LL - Dog { name: x , } => {} -LL + Dog { name: x, age } => {} - | +LL | Dog { name: x, age } => {} + | ~~~~~~~ help: if you don't care about this missing field, you can explicitly ignore it | -LL - Dog { name: x , } => {} -LL + Dog { name: x, age: _ } => {} - | +LL | Dog { name: x, age: _ } => {} + | ~~~~~~~~~~ help: or always ignore missing fields here | -LL - Dog { name: x , } => {} -LL + Dog { name: x, .. } => {} - | +LL | Dog { name: x, .. } => {} + | ~~~~~~ error[E0027]: pattern does not mention fields `name`, `age` --> $DIR/E0027.rs:22:9 @@ -69,19 +63,16 @@ LL | Dog {} => {} | help: include the missing fields in the pattern | -LL - Dog {} => {} -LL + Dog { name, age } => {} - | +LL | Dog { name, age } => {} + | +++++++++ help: if you don't care about these missing fields, you can explicitly ignore them | -LL - Dog {} => {} -LL + Dog { name: _, age: _ } => {} - | +LL | Dog { name: _, age: _ } => {} + | +++++++++++++++ help: or always ignore missing fields here | -LL - Dog {} => {} -LL + Dog { .. } => {} - | +LL | Dog { .. } => {} + | ++ error: aborting due to 4 previous errors diff --git a/tests/ui/error-codes/E0057.stderr b/tests/ui/error-codes/E0057.stderr index 35bd842b2cf..26c9689b9c5 100644 --- a/tests/ui/error-codes/E0057.stderr +++ b/tests/ui/error-codes/E0057.stderr @@ -11,9 +11,8 @@ LL | let f = |x| x * 3; | ^^^ help: provide the argument | -LL - let a = f(); -LL + let a = f(/* x */); - | +LL | let a = f(/* x */); + | +++++++ error[E0057]: this function takes 1 argument but 2 arguments were supplied --> $DIR/E0057.rs:5:13 diff --git a/tests/ui/error-codes/E0060.stderr b/tests/ui/error-codes/E0060.stderr index fc52c6fc5ea..7065b623ad3 100644 --- a/tests/ui/error-codes/E0060.stderr +++ b/tests/ui/error-codes/E0060.stderr @@ -11,9 +11,8 @@ LL | fn printf(_: *const u8, ...) -> u32; | ^^^^^^ - help: provide the argument | -LL - unsafe { printf(); } -LL + unsafe { printf(/* *const u8 */); } - | +LL | unsafe { printf(/* *const u8 */); } + | +++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0061.stderr b/tests/ui/error-codes/E0061.stderr index b70d607ebeb..cab72a984a6 100644 --- a/tests/ui/error-codes/E0061.stderr +++ b/tests/ui/error-codes/E0061.stderr @@ -11,9 +11,8 @@ LL | fn f(a: u16, b: &str) {} | ^ ------- help: provide the argument | -LL - f(0); -LL + f(0, /* &str */); - | +LL | f(0, /* &str */); + | ++++++++++++ error[E0061]: this function takes 1 argument but 0 arguments were supplied --> $DIR/E0061.rs:9:5 @@ -28,9 +27,8 @@ LL | fn f2(a: u16) {} | ^^ ------ help: provide the argument | -LL - f2(); -LL + f2(/* u16 */); - | +LL | f2(/* u16 */); + | +++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/error-codes/E0259.stderr b/tests/ui/error-codes/E0259.stderr index 08d3deb68d2..1833fe90f3d 100644 --- a/tests/ui/error-codes/E0259.stderr +++ b/tests/ui/error-codes/E0259.stderr @@ -10,9 +10,8 @@ LL | extern crate test as alloc; = note: `alloc` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | -LL - extern crate test as alloc; -LL + extern crate test as other_alloc; - | +LL | extern crate test as other_alloc; + | ++++++ error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0260.stderr b/tests/ui/error-codes/E0260.stderr index cb47b77904a..10811d1f318 100644 --- a/tests/ui/error-codes/E0260.stderr +++ b/tests/ui/error-codes/E0260.stderr @@ -10,9 +10,8 @@ LL | mod alloc { = note: `alloc` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | -LL - extern crate alloc; -LL + extern crate alloc as other_alloc; - | +LL | extern crate alloc as other_alloc; + | ++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/errors/issue-89280-emitter-overflow-splice-lines.stderr b/tests/ui/errors/issue-89280-emitter-overflow-splice-lines.stderr index 54bde98b57f..d9acdbea3fc 100644 --- a/tests/ui/errors/issue-89280-emitter-overflow-splice-lines.stderr +++ b/tests/ui/errors/issue-89280-emitter-overflow-splice-lines.stderr @@ -12,11 +12,8 @@ LL | | )) {} = note: `#[warn(anonymous_parameters)]` on by default help: try naming the parameter or explicitly ignoring it | -LL ~ fn test(x: u32, _: ( -LL + -LL + -LL ~ )) {} - | +LL | fn test(x: u32, _: ( + | ++ warning: 1 warning emitted diff --git a/tests/ui/extern/extern-crate-rename.stderr b/tests/ui/extern/extern-crate-rename.stderr index 4d4a585de60..88b78a07485 100644 --- a/tests/ui/extern/extern-crate-rename.stderr +++ b/tests/ui/extern/extern-crate-rename.stderr @@ -9,9 +9,8 @@ LL | extern crate m2 as m1; = note: `m1` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | -LL - extern crate m2 as m1; -LL + extern crate m2 as other_m1; - | +LL | extern crate m2 as other_m1; + | ++++++ error: aborting due to 1 previous error diff --git a/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.rs b/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.rs index 5386628a8e0..ce3d3fc645d 100644 --- a/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.rs +++ b/tests/ui/feature-gates/feature-gate-abi-avr-interrupt.rs @@ -1,5 +1,5 @@ //@ needs-llvm-components: avr -//@ compile-flags: --target=avr-unknown-gnu-atmega328 --crate-type=rlib +//@ compile-flags: --target=avr-none -C target-cpu=atmega328p --crate-type=rlib #![no_core] #![feature(no_core, lang_items)] #[lang="sized"] diff --git a/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr index 214725b77c0..7768c25bd2c 100644 --- a/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr +++ b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr @@ -165,9 +165,8 @@ LL | extern "rust-call" fn call_mut(&self, args: ()) -> () {} found signature `extern "rust-call" fn(&Bar, ()) -> ()` help: change the self-receiver type to match the trait | -LL - extern "rust-call" fn call_mut(&self, args: ()) -> () {} -LL + extern "rust-call" fn call_mut(&mut self, args: ()) -> () {} - | +LL | extern "rust-call" fn call_mut(&mut self, args: ()) -> () {} + | +++ error[E0046]: not all trait items implemented, missing: `Output` --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:35:1 diff --git a/tests/ui/fmt/no-inline-literals-out-of-range.stderr b/tests/ui/fmt/no-inline-literals-out-of-range.stderr index e1702388704..0800fb24976 100644 --- a/tests/ui/fmt/no-inline-literals-out-of-range.stderr +++ b/tests/ui/fmt/no-inline-literals-out-of-range.stderr @@ -13,9 +13,8 @@ LL + format_args!("{}", 0x8f_u8); // issue #115423 | help: to use as a negative number (decimal `-113`), consider using the type `u8` for the literal and cast it to `i8` | -LL - format_args!("{}", 0x8f_i8); // issue #115423 -LL + format_args!("{}", 0x8f_u8 as i8); // issue #115423 - | +LL | format_args!("{}", 0x8f_u8 as i8); // issue #115423 + | +++++ error: literal out of range for `u8` --> $DIR/no-inline-literals-out-of-range.rs:6:24 diff --git a/tests/ui/fn/issue-3044.stderr b/tests/ui/fn/issue-3044.stderr index 8351818dc89..787eeec09cc 100644 --- a/tests/ui/fn/issue-3044.stderr +++ b/tests/ui/fn/issue-3044.stderr @@ -11,8 +11,8 @@ note: method defined here --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL help: provide the argument | -LL ~ needlesArr.iter().fold(|x, y| { -LL + +LL | needlesArr.iter().fold(|x, y| { +LL | LL ~ }, /* f */); | diff --git a/tests/ui/fn/param-mismatch-foreign.stderr b/tests/ui/fn/param-mismatch-foreign.stderr index 88aa3cd0368..835e0a3343e 100644 --- a/tests/ui/fn/param-mismatch-foreign.stderr +++ b/tests/ui/fn/param-mismatch-foreign.stderr @@ -11,9 +11,8 @@ LL | fn foo(x: i32, y: u32, z: i32); | ^^^ - help: provide the argument | -LL - foo(1i32, 2i32); -LL + foo(1i32, /* u32 */, 2i32); - | +LL | foo(1i32, /* u32 */, 2i32); + | ++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/higher-ranked/trait-bounds/issue-58451.stderr b/tests/ui/higher-ranked/trait-bounds/issue-58451.stderr index 4f9fc0ac649..9f94b3aff88 100644 --- a/tests/ui/higher-ranked/trait-bounds/issue-58451.stderr +++ b/tests/ui/higher-ranked/trait-bounds/issue-58451.stderr @@ -11,9 +11,8 @@ LL | fn f<I>(i: I) | ^ ---- help: provide the argument | -LL - f(&[f()]); -LL + f(&[f(/* i */)]); - | +LL | f(&[f(/* i */)]); + | +++++++ error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/implicit-capture-late.rs b/tests/ui/impl-trait/implicit-capture-late.rs index 986620b101b..13cbcd66f8d 100644 --- a/tests/ui/impl-trait/implicit-capture-late.rs +++ b/tests/ui/impl-trait/implicit-capture-late.rs @@ -1,13 +1,13 @@ -//@ known-bug: #117647 +//@ edition: 2024 -#![feature(lifetime_capture_rules_2024)] #![feature(rustc_attrs)] #![allow(internal_features)] #![rustc_variance_of_opaques] use std::ops::Deref; -fn foo(x: Vec<i32>) -> Box<dyn for<'a> Deref<Target = impl ?Sized>> { +fn foo(x: Vec<i32>) -> Box<dyn for<'a> Deref<Target = impl ?Sized>> { //~ ['a: o] + //~^ ERROR cannot capture higher-ranked lifetime Box::new(x) } diff --git a/tests/ui/impl-trait/implicit-capture-late.stderr b/tests/ui/impl-trait/implicit-capture-late.stderr index 3adf78322d2..085d3eaedd4 100644 --- a/tests/ui/impl-trait/implicit-capture-late.stderr +++ b/tests/ui/impl-trait/implicit-capture-late.stderr @@ -1,17 +1,17 @@ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type - --> $DIR/implicit-capture-late.rs:10:55 + --> $DIR/implicit-capture-late.rs:9:55 | LL | fn foo(x: Vec<i32>) -> Box<dyn for<'a> Deref<Target = impl ?Sized>> { | ^^^^^^^^^^^ `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here - --> $DIR/implicit-capture-late.rs:10:36 + --> $DIR/implicit-capture-late.rs:9:36 | LL | fn foo(x: Vec<i32>) -> Box<dyn for<'a> Deref<Target = impl ?Sized>> { | ^^ error: ['a: o] - --> $DIR/implicit-capture-late.rs:10:55 + --> $DIR/implicit-capture-late.rs:9:55 | LL | fn foo(x: Vec<i32>) -> Box<dyn for<'a> Deref<Target = impl ?Sized>> { | ^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/in-trait/expeced-refree-to-map-to-reearlybound-ice-108580.stderr b/tests/ui/impl-trait/in-trait/expeced-refree-to-map-to-reearlybound-ice-108580.stderr index b7797317ea6..7c064cc7176 100644 --- a/tests/ui/impl-trait/in-trait/expeced-refree-to-map-to-reearlybound-ice-108580.stderr +++ b/tests/ui/impl-trait/in-trait/expeced-refree-to-map-to-reearlybound-ice-108580.stderr @@ -12,9 +12,8 @@ LL | fn bar(&self) -> impl Iterator + '_ { = note: `#[warn(refining_impl_trait_internal)]` on by default help: replace the return type so that it matches the trait | -LL - fn bar(&self) -> impl Iterator + '_ { -LL + fn bar(&self) -> impl Iterator<Item = impl Sized> + '_ { - | +LL | fn bar(&self) -> impl Iterator<Item = impl Sized> + '_ { + | +++++++++++++++++++ warning: 1 warning emitted diff --git a/tests/ui/impl-trait/in-trait/refine-captures.stderr b/tests/ui/impl-trait/in-trait/refine-captures.stderr index 8a5c8d3c77b..166991894d1 100644 --- a/tests/ui/impl-trait/in-trait/refine-captures.stderr +++ b/tests/ui/impl-trait/in-trait/refine-captures.stderr @@ -9,9 +9,8 @@ LL | fn test() -> impl Sized + use<> {} = note: `#[warn(refining_impl_trait_internal)]` on by default help: modify the `use<..>` bound to capture the same lifetimes that the trait does | -LL - fn test() -> impl Sized + use<> {} -LL + fn test() -> impl Sized + use<'a> {} - | +LL | fn test() -> impl Sized + use<'a> {} + | ++ warning: impl trait in impl method captures fewer lifetimes than in trait --> $DIR/refine-captures.rs:22:31 @@ -23,9 +22,8 @@ LL | fn test() -> impl Sized + use<> {} = note: we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information help: modify the `use<..>` bound to capture the same lifetimes that the trait does | -LL - fn test() -> impl Sized + use<> {} -LL + fn test() -> impl Sized + use<'a> {} - | +LL | fn test() -> impl Sized + use<'a> {} + | ++ warning: impl trait in impl method captures fewer lifetimes than in trait --> $DIR/refine-captures.rs:27:31 @@ -37,9 +35,8 @@ LL | fn test() -> impl Sized + use<'b> {} = note: we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information help: modify the `use<..>` bound to capture the same lifetimes that the trait does | -LL - fn test() -> impl Sized + use<'b> {} -LL + fn test() -> impl Sized + use<'a, 'b> {} - | +LL | fn test() -> impl Sized + use<'a, 'b> {} + | ++++ error: `impl Trait` must mention all type parameters in scope in `use<...>` --> $DIR/refine-captures.rs:32:18 diff --git a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr index 46561b66c8e..ba7d7770e50 100644 --- a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr +++ b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr @@ -41,9 +41,8 @@ LL + fn elided2(x: &i32) -> impl Copy + '_ { x } | help: alternatively, add an explicit `'static` bound to this reference | -LL - fn elided2(x: &i32) -> impl Copy + 'static { x } -LL + fn elided2(x: &'static i32) -> impl Copy + 'static { x } - | +LL | fn elided2(x: &'static i32) -> impl Copy + 'static { x } + | +++++++ error: lifetime may not live long enough --> $DIR/must_outlive_least_region_or_bound.rs:12:55 @@ -172,9 +171,8 @@ LL + fn elided4(x: &i32) -> Box<dyn Debug + '_> { Box::new(x) } | help: alternatively, add an explicit `'static` bound to this reference | -LL - fn elided4(x: &i32) -> Box<dyn Debug + 'static> { Box::new(x) } -LL + fn elided4(x: &'static i32) -> Box<dyn Debug + 'static> { Box::new(x) } - | +LL | fn elided4(x: &'static i32) -> Box<dyn Debug + 'static> { Box::new(x) } + | +++++++ error: lifetime may not live long enough --> $DIR/must_outlive_least_region_or_bound.rs:27:60 diff --git a/tests/ui/impl-trait/precise-capturing/higher-ranked.rs b/tests/ui/impl-trait/precise-capturing/higher-ranked.rs index 3dc8523e963..925f03589e8 100644 --- a/tests/ui/impl-trait/precise-capturing/higher-ranked.rs +++ b/tests/ui/impl-trait/precise-capturing/higher-ranked.rs @@ -1,9 +1,8 @@ //@ check-pass +//@ edition: 2024 // Show how precise captures allow us to skip capturing a higher-ranked lifetime -#![feature(lifetime_capture_rules_2024)] - trait Trait<'a> { type Item; } diff --git a/tests/ui/impl-trait/precise-capturing/outlives.rs b/tests/ui/impl-trait/precise-capturing/outlives.rs index f86a61be1e0..45e46848eea 100644 --- a/tests/ui/impl-trait/precise-capturing/outlives.rs +++ b/tests/ui/impl-trait/precise-capturing/outlives.rs @@ -1,9 +1,8 @@ //@ check-pass +//@ edition: 2024 // Show that precise captures allow us to skip a lifetime param for outlives -#![feature(lifetime_capture_rules_2024)] - fn hello<'a: 'a, 'b: 'b>() -> impl Sized + use<'a> { } fn outlives<'a, T: 'a>(_: T) {} diff --git a/tests/ui/impl-trait/variance.e2024.stderr b/tests/ui/impl-trait/variance.e2024.stderr index 361a165da66..adbe8b91e86 100644 --- a/tests/ui/impl-trait/variance.e2024.stderr +++ b/tests/ui/impl-trait/variance.e2024.stderr @@ -1,23 +1,23 @@ error: ['a: *, 'a: o] - --> $DIR/variance.rs:13:36 + --> $DIR/variance.rs:11:36 | LL | fn not_captured_early<'a: 'a>() -> impl Sized {} | ^^^^^^^^^^ error: ['a: *, 'a: o] - --> $DIR/variance.rs:18:32 + --> $DIR/variance.rs:15:32 | LL | fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: ['a: o] - --> $DIR/variance.rs:20:40 + --> $DIR/variance.rs:17:40 | LL | fn not_captured_late<'a>(_: &'a ()) -> impl Sized {} | ^^^^^^^^^^ error: ['a: o] - --> $DIR/variance.rs:25:36 + --> $DIR/variance.rs:21:36 | LL | fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/variance.new.stderr b/tests/ui/impl-trait/variance.new.stderr deleted file mode 100644 index 361a165da66..00000000000 --- a/tests/ui/impl-trait/variance.new.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error: ['a: *, 'a: o] - --> $DIR/variance.rs:13:36 - | -LL | fn not_captured_early<'a: 'a>() -> impl Sized {} - | ^^^^^^^^^^ - -error: ['a: *, 'a: o] - --> $DIR/variance.rs:18:32 - | -LL | fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: ['a: o] - --> $DIR/variance.rs:20:40 - | -LL | fn not_captured_late<'a>(_: &'a ()) -> impl Sized {} - | ^^^^^^^^^^ - -error: ['a: o] - --> $DIR/variance.rs:25:36 - | -LL | fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 4 previous errors - diff --git a/tests/ui/impl-trait/variance.old.stderr b/tests/ui/impl-trait/variance.old.stderr index 578d6fd14cd..57ffa7cde31 100644 --- a/tests/ui/impl-trait/variance.old.stderr +++ b/tests/ui/impl-trait/variance.old.stderr @@ -1,23 +1,23 @@ error: ['a: *] - --> $DIR/variance.rs:13:36 + --> $DIR/variance.rs:11:36 | LL | fn not_captured_early<'a: 'a>() -> impl Sized {} | ^^^^^^^^^^ error: ['a: *, 'a: o] - --> $DIR/variance.rs:18:32 + --> $DIR/variance.rs:15:32 | LL | fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: [] - --> $DIR/variance.rs:20:40 + --> $DIR/variance.rs:17:40 | LL | fn not_captured_late<'a>(_: &'a ()) -> impl Sized {} | ^^^^^^^^^^ error: ['a: o] - --> $DIR/variance.rs:25:36 + --> $DIR/variance.rs:21:36 | LL | fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/variance.rs b/tests/ui/impl-trait/variance.rs index 1e359f033ff..bde3a886a4d 100644 --- a/tests/ui/impl-trait/variance.rs +++ b/tests/ui/impl-trait/variance.rs @@ -1,8 +1,6 @@ -//@ revisions: old new e2024 +//@ revisions: old e2024 //@[e2024] edition: 2024 -#![cfg_attr(new, feature(lifetime_capture_rules_2024))] - #![feature(rustc_attrs)] #![allow(internal_features)] #![rustc_variance_of_opaques] @@ -12,15 +10,13 @@ impl<T> Captures<'_> for T {} fn not_captured_early<'a: 'a>() -> impl Sized {} //[old]~^ ['a: *] -//[new]~^^ ['a: *, 'a: o] -//[e2024]~^^^ ['a: *, 'a: o] +//[e2024]~^^ ['a: *, 'a: o] fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {} //~ ['a: *, 'a: o] fn not_captured_late<'a>(_: &'a ()) -> impl Sized {} //[old]~^ [] -//[new]~^^ ['a: o] -//[e2024]~^^^ ['a: o] +//[e2024]~^^ ['a: o] fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {} //~ ['a: o] diff --git a/tests/ui/imports/extern-crate-self/extern-crate-self-fail.stderr b/tests/ui/imports/extern-crate-self/extern-crate-self-fail.stderr index 9a3ebfddc49..ec700cf7e59 100644 --- a/tests/ui/imports/extern-crate-self/extern-crate-self-fail.stderr +++ b/tests/ui/imports/extern-crate-self/extern-crate-self-fail.stderr @@ -6,9 +6,8 @@ LL | extern crate self; | help: rename the `self` crate to be able to import it | -LL - extern crate self; -LL + extern crate self as name; - | +LL | extern crate self as name; + | +++++++ error: `#[macro_use]` is not supported on `extern crate self` --> $DIR/extern-crate-self-fail.rs:3:1 diff --git a/tests/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr b/tests/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr index def0676a0f8..2621f913186 100644 --- a/tests/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr +++ b/tests/ui/imports/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr @@ -7,9 +7,8 @@ LL | extern crate std; = note: `std` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | -LL - extern crate std; -LL + extern crate std as other_std; - | +LL | extern crate std as other_std; + | ++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-45829/import-self.stderr b/tests/ui/imports/issue-45829/import-self.stderr index b392d93c154..5094a50635d 100644 --- a/tests/ui/imports/issue-45829/import-self.stderr +++ b/tests/ui/imports/issue-45829/import-self.stderr @@ -62,9 +62,8 @@ LL | use foo::{self as A}; = note: `A` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | -LL - use foo::{self as A}; -LL + use foo::{self as OtherA}; - | +LL | use foo::{self as OtherA}; + | +++++ error: aborting due to 5 previous errors diff --git a/tests/ui/imports/issue-45829/issue-45829.stderr b/tests/ui/imports/issue-45829/issue-45829.stderr index 9fd0e5a7672..618fac350f0 100644 --- a/tests/ui/imports/issue-45829/issue-45829.stderr +++ b/tests/ui/imports/issue-45829/issue-45829.stderr @@ -9,9 +9,8 @@ LL | use foo::{A, B as A}; = note: `A` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | -LL - use foo::{A, B as A}; -LL + use foo::{A, B as OtherA}; - | +LL | use foo::{A, B as OtherA}; + | +++++ error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-45829/rename-extern-vs-use.stderr b/tests/ui/imports/issue-45829/rename-extern-vs-use.stderr index 98fe16824ff..f33b093725f 100644 --- a/tests/ui/imports/issue-45829/rename-extern-vs-use.stderr +++ b/tests/ui/imports/issue-45829/rename-extern-vs-use.stderr @@ -9,9 +9,8 @@ LL | extern crate issue_45829_b as bar; = note: `bar` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | -LL - extern crate issue_45829_b as bar; -LL + extern crate issue_45829_b as other_bar; - | +LL | extern crate issue_45829_b as other_bar; + | ++++++ error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-45829/rename-extern.stderr b/tests/ui/imports/issue-45829/rename-extern.stderr index f99f433c642..2a3a05d1e7b 100644 --- a/tests/ui/imports/issue-45829/rename-extern.stderr +++ b/tests/ui/imports/issue-45829/rename-extern.stderr @@ -9,9 +9,8 @@ LL | extern crate issue_45829_b as issue_45829_a; = note: `issue_45829_a` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | -LL - extern crate issue_45829_b as issue_45829_a; -LL + extern crate issue_45829_b as other_issue_45829_a; - | +LL | extern crate issue_45829_b as other_issue_45829_a; + | ++++++ error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-45829/rename-use-vs-extern.stderr b/tests/ui/imports/issue-45829/rename-use-vs-extern.stderr index e0647cd3ab6..399de74a591 100644 --- a/tests/ui/imports/issue-45829/rename-use-vs-extern.stderr +++ b/tests/ui/imports/issue-45829/rename-use-vs-extern.stderr @@ -9,9 +9,8 @@ LL | use std as issue_45829_b; = note: `issue_45829_b` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | -LL - use std as issue_45829_b; -LL + use std as other_issue_45829_b; - | +LL | use std as other_issue_45829_b; + | ++++++ error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-45829/rename-with-path.stderr b/tests/ui/imports/issue-45829/rename-with-path.stderr index 45fdd46850e..fc30eb1cf8d 100644 --- a/tests/ui/imports/issue-45829/rename-with-path.stderr +++ b/tests/ui/imports/issue-45829/rename-with-path.stderr @@ -9,9 +9,8 @@ LL | use std::{collections::HashMap as A, sync::Arc as A}; = note: `A` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | -LL - use std::{collections::HashMap as A, sync::Arc as A}; -LL + use std::{collections::HashMap as A, sync::Arc as OtherA}; - | +LL | use std::{collections::HashMap as A, sync::Arc as OtherA}; + | +++++ error: aborting due to 1 previous error diff --git a/tests/ui/imports/issue-45829/rename.stderr b/tests/ui/imports/issue-45829/rename.stderr index dc5775e3d56..a17dc6964da 100644 --- a/tests/ui/imports/issue-45829/rename.stderr +++ b/tests/ui/imports/issue-45829/rename.stderr @@ -9,9 +9,8 @@ LL | use std as core; = note: `core` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | -LL - use std as core; -LL + use std as other_core; - | +LL | use std as other_core; + | ++++++ error: aborting due to 1 previous error diff --git a/tests/ui/imports/multiple-extern-by-macro-for-buitlin.stderr b/tests/ui/imports/multiple-extern-by-macro-for-buitlin.stderr index 4a5c85479d3..bc975573281 100644 --- a/tests/ui/imports/multiple-extern-by-macro-for-buitlin.stderr +++ b/tests/ui/imports/multiple-extern-by-macro-for-buitlin.stderr @@ -14,9 +14,8 @@ LL | m!(); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) help: you can use `as` to change the binding name of the import | -LL - extern crate std as core; -LL + extern crate std as other_core; - | +LL | extern crate std as other_core; + | ++++++ error: aborting due to 1 previous error diff --git a/tests/ui/imports/multiple-extern-by-macro-for-custom.stderr b/tests/ui/imports/multiple-extern-by-macro-for-custom.stderr index 8b87ae93b4d..f1b60bbe39d 100644 --- a/tests/ui/imports/multiple-extern-by-macro-for-custom.stderr +++ b/tests/ui/imports/multiple-extern-by-macro-for-custom.stderr @@ -14,9 +14,8 @@ LL | m!(); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) help: you can use `as` to change the binding name of the import | -LL - extern crate std as empty; -LL + extern crate std as other_empty; - | +LL | extern crate std as other_empty; + | ++++++ error: aborting due to 1 previous error diff --git a/tests/ui/imports/multiple-extern-by-macro-for-inexist.stderr b/tests/ui/imports/multiple-extern-by-macro-for-inexist.stderr index 9a9e538740d..13e1aaacd70 100644 --- a/tests/ui/imports/multiple-extern-by-macro-for-inexist.stderr +++ b/tests/ui/imports/multiple-extern-by-macro-for-inexist.stderr @@ -20,9 +20,8 @@ LL | m!(); = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) help: you can use `as` to change the binding name of the import | -LL - extern crate std as non_existent; -LL + extern crate std as other_non_existent; - | +LL | extern crate std as other_non_existent; + | ++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/imports/no-std-inject.stderr b/tests/ui/imports/no-std-inject.stderr index d3952a50cd3..7299c2e8a9f 100644 --- a/tests/ui/imports/no-std-inject.stderr +++ b/tests/ui/imports/no-std-inject.stderr @@ -7,9 +7,8 @@ LL | extern crate core; = note: `core` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | -LL - extern crate core; -LL + extern crate core as other_core; - | +LL | extern crate core as other_core; + | +++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/include-macros/parent_dir.stderr b/tests/ui/include-macros/parent_dir.stderr index 23029e91120..d0a1f4fd3b9 100644 --- a/tests/ui/include-macros/parent_dir.stderr +++ b/tests/ui/include-macros/parent_dir.stderr @@ -20,9 +20,8 @@ LL | let _ = include_str!("hello.rs"); = note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info) help: there is a file with the same name in a different directory | -LL - let _ = include_str!("hello.rs"); -LL + let _ = include_str!("../hello.rs"); - | +LL | let _ = include_str!("../hello.rs"); + | +++ error: couldn't read `$DIR/../../data.bin`: $FILE_NOT_FOUND_MSG --> $DIR/parent_dir.rs:8:13 diff --git a/tests/ui/issues/issue-20225.stderr b/tests/ui/issues/issue-20225.stderr index 6a3c4e2a836..775f23dd7e6 100644 --- a/tests/ui/issues/issue-20225.stderr +++ b/tests/ui/issues/issue-20225.stderr @@ -10,9 +10,8 @@ LL | extern "rust-call" fn call(&self, (_,): (T,)) {} found signature `extern "rust-call" fn(&Foo, (_,))` help: change the parameter type to match the trait | -LL - extern "rust-call" fn call(&self, (_,): (T,)) {} -LL + extern "rust-call" fn call(&self, (_,): (&'a T,)) {} - | +LL | extern "rust-call" fn call(&self, (_,): (&'a T,)) {} + | +++ error[E0053]: method `call_mut` has an incompatible type for trait --> $DIR/issue-20225.rs:11:51 @@ -26,9 +25,8 @@ LL | extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {} found signature `extern "rust-call" fn(&mut Foo, (_,))` help: change the parameter type to match the trait | -LL - extern "rust-call" fn call_mut(&mut self, (_,): (T,)) {} -LL + extern "rust-call" fn call_mut(&mut self, (_,): (&'a T,)) {} - | +LL | extern "rust-call" fn call_mut(&mut self, (_,): (&'a T,)) {} + | +++ error[E0053]: method `call_once` has an incompatible type for trait --> $DIR/issue-20225.rs:18:47 @@ -43,9 +41,8 @@ LL | extern "rust-call" fn call_once(self, (_,): (T,)) {} found signature `extern "rust-call" fn(Foo, (_,))` help: change the parameter type to match the trait | -LL - extern "rust-call" fn call_once(self, (_,): (T,)) {} -LL + extern "rust-call" fn call_once(self, (_,): (&'a T,)) {} - | +LL | extern "rust-call" fn call_once(self, (_,): (&'a T,)) {} + | +++ error: aborting due to 3 previous errors diff --git a/tests/ui/issues/issue-23073.stderr b/tests/ui/issues/issue-23073.stderr index 8aa86887bcf..87dcf3b3289 100644 --- a/tests/ui/issues/issue-23073.stderr +++ b/tests/ui/issues/issue-23073.stderr @@ -6,9 +6,8 @@ LL | type FooT = <<Self as Bar>::Foo>::T; | help: if there were a trait named `Example` with associated type `T` implemented for `<Self as Bar>::Foo`, you could use the fully-qualified path | -LL - type FooT = <<Self as Bar>::Foo>::T; -LL + type FooT = <<Self as Bar>::Foo as Example>::T; - | +LL | type FooT = <<Self as Bar>::Foo as Example>::T; + | ++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-76077-inaccesible-private-fields/issue-76077-1.stderr b/tests/ui/issues/issue-76077-inaccesible-private-fields/issue-76077-1.stderr index eabb0842112..f54990d5d86 100644 --- a/tests/ui/issues/issue-76077-inaccesible-private-fields/issue-76077-1.stderr +++ b/tests/ui/issues/issue-76077-inaccesible-private-fields/issue-76077-1.stderr @@ -6,9 +6,8 @@ LL | let foo::Foo {} = foo::Foo::default(); | help: ignore the inaccessible and unused fields | -LL - let foo::Foo {} = foo::Foo::default(); -LL + let foo::Foo { .. } = foo::Foo::default(); - | +LL | let foo::Foo { .. } = foo::Foo::default(); + | ++ error: pattern requires `..` due to inaccessible fields --> $DIR/issue-76077-1.rs:16:9 diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr index 0daf2d3b9e7..07cad776692 100644 --- a/tests/ui/layout/debug.stderr +++ b/tests/ui/layout/debug.stderr @@ -31,6 +31,7 @@ error: layout_of(E) = Layout { valid_range: 0..=0, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -56,6 +57,7 @@ error: layout_of(E) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -69,7 +71,9 @@ error: layout_of(E) = Layout { abi: Align(4 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: Memory { + sized: true, + }, fields: Arbitrary { offsets: [ Size(4 bytes), @@ -83,6 +87,7 @@ error: layout_of(E) = Layout { ], }, largest_niche: None, + uninhabited: true, variants: Single { index: 1, }, @@ -136,6 +141,7 @@ error: layout_of(S) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -161,6 +167,7 @@ error: layout_of(U) = Layout { 2, ), largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -213,6 +220,7 @@ error: layout_of(Result<i32, i32>) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -255,6 +263,7 @@ error: layout_of(Result<i32, i32>) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -293,6 +302,7 @@ error: layout_of(Result<i32, i32>) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 1, }, @@ -328,6 +338,7 @@ error: layout_of(i32) = Layout { ), fields: Primitive, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -353,6 +364,7 @@ error: layout_of(V) = Layout { 2, ), largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -378,6 +390,7 @@ error: layout_of(W) = Layout { 2, ), largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -403,6 +416,7 @@ error: layout_of(Y) = Layout { 2, ), largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -428,6 +442,7 @@ error: layout_of(P1) = Layout { 1, ), largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -453,6 +468,7 @@ error: layout_of(P2) = Layout { 1, ), largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -478,6 +494,7 @@ error: layout_of(P3) = Layout { 1, ), largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -503,6 +520,7 @@ error: layout_of(P4) = Layout { 1, ), largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -533,6 +551,7 @@ error: layout_of(P5) = Layout { 2, ), largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -563,6 +582,7 @@ error: layout_of(MaybeUninit<u8>) = Layout { 2, ), largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, diff --git a/tests/ui/layout/gce-rigid-const-in-array-len.rs b/tests/ui/layout/gce-rigid-const-in-array-len.rs new file mode 100644 index 00000000000..8e57907a2c5 --- /dev/null +++ b/tests/ui/layout/gce-rigid-const-in-array-len.rs @@ -0,0 +1,27 @@ +//! With `feature(generic_const_exprs)`, anon consts (e.g. length in array types) will +//! inherit their parent's predicates. When combined with `feature(trivial_bounds)`, it +//! is possible to have an unevaluated constant that is rigid, but not generic. +//! +//! This is what happens below: `u8: A` does not hold in the global environment, but +//! with trivial bounds + GCE it it possible that `<u8 as A>::B` can appear in an array +//! length without causing a compile error. This constant is *rigid* (i.e. it cannot be +//! normalized further), but it is *not generic* (i.e. it does not depend on any generic +//! parameters). +//! +//! This test ensures that we do not ICE in layout computation when encountering such a +//! constant. + +#![feature(rustc_attrs)] +#![feature(generic_const_exprs)] //~ WARNING: the feature `generic_const_exprs` is incomplete +#![feature(trivial_bounds)] + +#![crate_type = "lib"] + +trait A { + const B: usize; +} + +#[rustc_layout(debug)] +struct S([u8; <u8 as A>::B]) //~ ERROR: the type `[u8; <u8 as A>::B]` has an unknown layout +where + u8: A; diff --git a/tests/ui/layout/gce-rigid-const-in-array-len.stderr b/tests/ui/layout/gce-rigid-const-in-array-len.stderr new file mode 100644 index 00000000000..6149debdfe8 --- /dev/null +++ b/tests/ui/layout/gce-rigid-const-in-array-len.stderr @@ -0,0 +1,17 @@ +warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/gce-rigid-const-in-array-len.rs:15:12 + | +LL | #![feature(generic_const_exprs)] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information + = note: `#[warn(incomplete_features)]` on by default + +error: the type `[u8; <u8 as A>::B]` has an unknown layout + --> $DIR/gce-rigid-const-in-array-len.rs:25:1 + | +LL | struct S([u8; <u8 as A>::B]) + | ^^^^^^^^ + +error: aborting due to 1 previous error; 1 warning emitted + diff --git a/tests/ui/layout/hexagon-enum.stderr b/tests/ui/layout/hexagon-enum.stderr index 96f0a8c8740..90c06ba1f83 100644 --- a/tests/ui/layout/hexagon-enum.stderr +++ b/tests/ui/layout/hexagon-enum.stderr @@ -31,6 +31,7 @@ error: layout_of(A) = Layout { valid_range: 0..=0, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -56,6 +57,7 @@ error: layout_of(A) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -107,6 +109,7 @@ error: layout_of(B) = Layout { valid_range: 255..=255, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -132,6 +135,7 @@ error: layout_of(B) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -183,6 +187,7 @@ error: layout_of(C) = Layout { valid_range: 256..=256, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -208,6 +213,7 @@ error: layout_of(C) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -259,6 +265,7 @@ error: layout_of(P) = Layout { valid_range: 268435456..=268435456, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -284,6 +291,7 @@ error: layout_of(P) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -335,6 +343,7 @@ error: layout_of(T) = Layout { valid_range: 2164260864..=2164260864, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -360,6 +369,7 @@ error: layout_of(T) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, diff --git a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr index cd9e4c02781..3bdb9c5c143 100644 --- a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr +++ b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr @@ -37,6 +37,7 @@ error: layout_of(MissingPayloadField) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -78,6 +79,7 @@ error: layout_of(MissingPayloadField) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -99,6 +101,7 @@ error: layout_of(MissingPayloadField) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 1, }, @@ -157,6 +160,7 @@ error: layout_of(CommonPayloadField) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -199,6 +203,7 @@ error: layout_of(CommonPayloadField) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -237,6 +242,7 @@ error: layout_of(CommonPayloadField) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 1, }, @@ -294,6 +300,7 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -335,6 +342,7 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -372,6 +380,7 @@ error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 1, }, @@ -429,6 +438,7 @@ error: layout_of(NicheFirst) = Layout { valid_range: 0..=4, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -486,6 +496,7 @@ error: layout_of(NicheFirst) = Layout { valid_range: 0..=2, }, ), + uninhabited: false, variants: Single { index: 0, }, @@ -507,6 +518,7 @@ error: layout_of(NicheFirst) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 1, }, @@ -528,6 +540,7 @@ error: layout_of(NicheFirst) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 2, }, @@ -585,6 +598,7 @@ error: layout_of(NicheSecond) = Layout { valid_range: 0..=4, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -642,6 +656,7 @@ error: layout_of(NicheSecond) = Layout { valid_range: 0..=2, }, ), + uninhabited: false, variants: Single { index: 0, }, @@ -663,6 +678,7 @@ error: layout_of(NicheSecond) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 1, }, @@ -684,6 +700,7 @@ error: layout_of(NicheSecond) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 2, }, diff --git a/tests/ui/layout/issue-96185-overaligned-enum.stderr b/tests/ui/layout/issue-96185-overaligned-enum.stderr index 15a3f6004f5..1d4e4436448 100644 --- a/tests/ui/layout/issue-96185-overaligned-enum.stderr +++ b/tests/ui/layout/issue-96185-overaligned-enum.stderr @@ -25,6 +25,7 @@ error: layout_of(Aligned1) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -50,6 +51,7 @@ error: layout_of(Aligned1) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -73,6 +75,7 @@ error: layout_of(Aligned1) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 1, }, @@ -128,6 +131,7 @@ error: layout_of(Aligned2) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -153,6 +157,7 @@ error: layout_of(Aligned2) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -176,6 +181,7 @@ error: layout_of(Aligned2) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 1, }, diff --git a/tests/ui/layout/thumb-enum.stderr b/tests/ui/layout/thumb-enum.stderr index 120081d193c..0c343318564 100644 --- a/tests/ui/layout/thumb-enum.stderr +++ b/tests/ui/layout/thumb-enum.stderr @@ -31,6 +31,7 @@ error: layout_of(A) = Layout { valid_range: 0..=0, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -56,6 +57,7 @@ error: layout_of(A) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -107,6 +109,7 @@ error: layout_of(B) = Layout { valid_range: 255..=255, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -132,6 +135,7 @@ error: layout_of(B) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -183,6 +187,7 @@ error: layout_of(C) = Layout { valid_range: 256..=256, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -208,6 +213,7 @@ error: layout_of(C) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -259,6 +265,7 @@ error: layout_of(P) = Layout { valid_range: 268435456..=268435456, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -284,6 +291,7 @@ error: layout_of(P) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -335,6 +343,7 @@ error: layout_of(T) = Layout { valid_range: 2164260864..=2164260864, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -360,6 +369,7 @@ error: layout_of(T) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, diff --git a/tests/ui/layout/unconstrained-param-ice-137308.rs b/tests/ui/layout/unconstrained-param-ice-137308.rs new file mode 100644 index 00000000000..c9b1e0a4b9e --- /dev/null +++ b/tests/ui/layout/unconstrained-param-ice-137308.rs @@ -0,0 +1,18 @@ +//! Regression test for <https://github.com/rust-lang/rust/issues/137308>. +//! +//! This used to ICE in layout computation, because `<u8 as A>::B` fails to normalize +//! due to the unconstrained param on the impl. + +#![feature(rustc_attrs)] +#![crate_type = "lib"] + +trait A { + const B: usize; +} + +impl<C: ?Sized> A for u8 { //~ ERROR: the type parameter `C` is not constrained + const B: usize = 42; +} + +#[rustc_layout(debug)] +struct S([u8; <u8 as A>::B]); //~ ERROR: the type has an unknown layout diff --git a/tests/ui/layout/unconstrained-param-ice-137308.stderr b/tests/ui/layout/unconstrained-param-ice-137308.stderr new file mode 100644 index 00000000000..615c131eb90 --- /dev/null +++ b/tests/ui/layout/unconstrained-param-ice-137308.stderr @@ -0,0 +1,15 @@ +error[E0207]: the type parameter `C` is not constrained by the impl trait, self type, or predicates + --> $DIR/unconstrained-param-ice-137308.rs:13:6 + | +LL | impl<C: ?Sized> A for u8 { + | ^ unconstrained type parameter + +error: the type has an unknown layout + --> $DIR/unconstrained-param-ice-137308.rs:18:1 + | +LL | struct S([u8; <u8 as A>::B]); + | ^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/layout/zero-sized-array-enum-niche.stderr b/tests/ui/layout/zero-sized-array-enum-niche.stderr index b6fcc14c063..33d2eede220 100644 --- a/tests/ui/layout/zero-sized-array-enum-niche.stderr +++ b/tests/ui/layout/zero-sized-array-enum-niche.stderr @@ -25,6 +25,7 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -54,6 +55,7 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -88,6 +90,7 @@ error: layout_of(Result<[u32; 0], bool>) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Single { index: 1, }, @@ -133,6 +136,7 @@ error: layout_of(MultipleAlignments) = Layout { valid_range: 0..=2, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -162,6 +166,7 @@ error: layout_of(MultipleAlignments) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -187,6 +192,7 @@ error: layout_of(MultipleAlignments) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 1, }, @@ -221,6 +227,7 @@ error: layout_of(MultipleAlignments) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Single { index: 2, }, @@ -266,6 +273,7 @@ error: layout_of(Result<[u32; 0], Packed<NonZero<u16>>>) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -295,6 +303,7 @@ error: layout_of(Result<[u32; 0], Packed<NonZero<u16>>>) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -329,6 +338,7 @@ error: layout_of(Result<[u32; 0], Packed<NonZero<u16>>>) = Layout { valid_range: 1..=65535, }, ), + uninhabited: false, variants: Single { index: 1, }, @@ -374,6 +384,7 @@ error: layout_of(Result<[u32; 0], Packed<U16IsZero>>) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -407,6 +418,7 @@ error: layout_of(Result<[u32; 0], Packed<U16IsZero>>) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -441,6 +453,7 @@ error: layout_of(Result<[u32; 0], Packed<U16IsZero>>) = Layout { valid_range: 0..=0, }, ), + uninhabited: false, variants: Single { index: 1, }, diff --git a/tests/ui/lifetimes/borrowck-let-suggestion.stderr b/tests/ui/lifetimes/borrowck-let-suggestion.stderr index 4703d7f10dc..9020ee22f9b 100644 --- a/tests/ui/lifetimes/borrowck-let-suggestion.stderr +++ b/tests/ui/lifetimes/borrowck-let-suggestion.stderr @@ -13,7 +13,7 @@ LL | x.use_mut(); help: consider consuming the `Vec<i32>` when turning it into an `Iterator` | LL | let mut x = vec![1].into_iter(); - | +++++ + | +++++ help: consider using a `let` binding to create a longer lived value | LL ~ let binding = vec![1]; diff --git a/tests/ui/lifetimes/issue-26638.stderr b/tests/ui/lifetimes/issue-26638.stderr index 8aa94f66812..bdf91136765 100644 --- a/tests/ui/lifetimes/issue-26638.stderr +++ b/tests/ui/lifetimes/issue-26638.stderr @@ -56,9 +56,8 @@ LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() } | help: provide the argument | -LL - fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter() } -LL + fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter(/* &u8 */) } - | +LL | fn parse_type_2(iter: fn(&u8)->&u8) -> &str { iter(/* &u8 */) } + | +++++++++ error[E0308]: mismatched types --> $DIR/issue-26638.rs:4:47 diff --git a/tests/ui/lint/static-mut-refs.e2021.stderr b/tests/ui/lint/static-mut-refs.e2021.stderr index 337d5d0b307..00a2ca99f24 100644 --- a/tests/ui/lint/static-mut-refs.e2021.stderr +++ b/tests/ui/lint/static-mut-refs.e2021.stderr @@ -22,9 +22,8 @@ LL | let _y = &mut X; = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives help: use `&raw mut` instead to create a raw pointer | -LL - let _y = &mut X; -LL + let _y = &raw mut X; - | +LL | let _y = &raw mut X; + | +++ warning: creating a shared reference to mutable static is discouraged --> $DIR/static-mut-refs.rs:50:22 diff --git a/tests/ui/lint/static-mut-refs.e2024.stderr b/tests/ui/lint/static-mut-refs.e2024.stderr index cf7f0a86f4f..ff41f316250 100644 --- a/tests/ui/lint/static-mut-refs.e2024.stderr +++ b/tests/ui/lint/static-mut-refs.e2024.stderr @@ -22,9 +22,8 @@ LL | let _y = &mut X; = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives help: use `&raw mut` instead to create a raw pointer | -LL - let _y = &mut X; -LL + let _y = &raw mut X; - | +LL | let _y = &raw mut X; + | +++ error: creating a shared reference to mutable static is discouraged --> $DIR/static-mut-refs.rs:50:22 diff --git a/tests/ui/lint/type-overflow.stderr b/tests/ui/lint/type-overflow.stderr index 6ba0c9d907c..4d6403b1e7d 100644 --- a/tests/ui/lint/type-overflow.stderr +++ b/tests/ui/lint/type-overflow.stderr @@ -26,9 +26,8 @@ LL + let fail = 0b1000_0001u8; | help: to use as a negative number (decimal `-127`), consider using the type `u8` for the literal and cast it to `i8` | -LL - let fail = 0b1000_0001i8; -LL + let fail = 0b1000_0001u8 as i8; - | +LL | let fail = 0b1000_0001u8 as i8; + | +++++ warning: literal out of range for `i64` --> $DIR/type-overflow.rs:15:16 @@ -44,9 +43,8 @@ LL + let fail = 0x8000_0000_0000_0000u64; | help: to use as a negative number (decimal `-9223372036854775808`), consider using the type `u64` for the literal and cast it to `i64` | -LL - let fail = 0x8000_0000_0000_0000i64; -LL + let fail = 0x8000_0000_0000_0000u64 as i64; - | +LL | let fail = 0x8000_0000_0000_0000u64 as i64; + | ++++++ warning: literal out of range for `u32` --> $DIR/type-overflow.rs:19:16 diff --git a/tests/ui/lint/unaligned_references_fake_borrow.rs b/tests/ui/lint/unaligned_references_fake_borrow.rs new file mode 100644 index 00000000000..b0ef8b471ca --- /dev/null +++ b/tests/ui/lint/unaligned_references_fake_borrow.rs @@ -0,0 +1,27 @@ +//@ check-pass + +// Regression test for <https://github.com/rust-lang/rust/issues/137250>. + +// Ensure that we don't emit unaligned packed field reference errors for the fake +// borrows that we generate during match lowering. These fake borrows are there to +// ensure in *borrow-checking* that we don't modify the value being matched, but +// they are removed after the MIR is processed by `CleanupPostBorrowck`. + +#[repr(packed)] +pub struct Packed(i32); + +fn f(x: Packed) { + match &x { + Packed(4) => {}, + _ if true => {}, + _ => {} + } + + match x { + Packed(4) => {}, + _ if true => {}, + _ => {} + } +} + +fn main() {} diff --git a/tests/ui/macros/block-to-expr-metavar.rs b/tests/ui/macros/block-to-expr-metavar.rs new file mode 100644 index 00000000000..04f10ad0f98 --- /dev/null +++ b/tests/ui/macros/block-to-expr-metavar.rs @@ -0,0 +1,17 @@ +//@ check-pass +// +// A test case where a `block` fragment specifier is interpreted as an `expr` +// fragment specifier. It's an interesting case for the handling of invisible +// delimiters. + +macro_rules! m_expr { + ($e:expr) => { const _CURRENT: u32 = $e; }; +} + +macro_rules! m_block { + ($b:block) => ( m_expr!($b); ); +} + +fn main() { + m_block!({ 1 }); +} diff --git a/tests/ui/macros/macro-interpolation.rs b/tests/ui/macros/macro-interpolation.rs index 48c1f19e777..b5d2322c805 100644 --- a/tests/ui/macros/macro-interpolation.rs +++ b/tests/ui/macros/macro-interpolation.rs @@ -19,7 +19,7 @@ macro_rules! qpath { (ty, <$type:ty as $trait:ty>::$name:ident) => { <$type as $trait>::$name - //~^ ERROR expected identifier, found `!` + //~^ ERROR expected identifier, found metavariable }; } diff --git a/tests/ui/macros/macro-interpolation.stderr b/tests/ui/macros/macro-interpolation.stderr index e6b39dfef85..bc24a158612 100644 --- a/tests/ui/macros/macro-interpolation.stderr +++ b/tests/ui/macros/macro-interpolation.stderr @@ -1,8 +1,8 @@ -error: expected identifier, found `!` +error: expected identifier, found metavariable --> $DIR/macro-interpolation.rs:21:19 | LL | <$type as $trait>::$name - | ^^^^^^ expected identifier + | ^^^^^^ expected identifier, found metavariable ... LL | let _: qpath!(ty, <str as !>::Owned); | ----------------------------- diff --git a/tests/ui/macros/syntax-error-recovery.rs b/tests/ui/macros/syntax-error-recovery.rs index 016e4def284..6cf9d54e826 100644 --- a/tests/ui/macros/syntax-error-recovery.rs +++ b/tests/ui/macros/syntax-error-recovery.rs @@ -9,8 +9,8 @@ macro_rules! values { } }; } -//~^^^^^ ERROR expected one of `(`, `,`, `=`, `{`, or `}`, found type `(String)` -//~| ERROR macro expansion ignores type `(String)` and any tokens following +//~^^^^^ ERROR expected one of `(`, `,`, `=`, `{`, or `}`, found `ty` metavariable +//~| ERROR macro expansion ignores `ty` metavariable and any tokens following values!(STRING(1) as (String) => cfg(test),); //~^ ERROR expected one of `!` or `::`, found `<eof>` diff --git a/tests/ui/macros/syntax-error-recovery.stderr b/tests/ui/macros/syntax-error-recovery.stderr index 3cfbd8ce82b..61758fb9d7d 100644 --- a/tests/ui/macros/syntax-error-recovery.stderr +++ b/tests/ui/macros/syntax-error-recovery.stderr @@ -1,4 +1,4 @@ -error: expected one of `(`, `,`, `=`, `{`, or `}`, found type `(String)` +error: expected one of `(`, `,`, `=`, `{`, or `}`, found `ty` metavariable --> $DIR/syntax-error-recovery.rs:7:26 | LL | $token $($inner)? = $value, @@ -10,7 +10,7 @@ LL | values!(STRING(1) as (String) => cfg(test),); = help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }` = note: this error originates in the macro `values` (in Nightly builds, run with -Z macro-backtrace for more info) -error: macro expansion ignores type `(String)` and any tokens following +error: macro expansion ignores `ty` metavariable and any tokens following --> $DIR/syntax-error-recovery.rs:7:26 | LL | $token $($inner)? = $value, diff --git a/tests/ui/malformed/malformed-special-attrs.stderr b/tests/ui/malformed/malformed-special-attrs.stderr index a6220710cf9..b6a1a6b50e4 100644 --- a/tests/ui/malformed/malformed-special-attrs.stderr +++ b/tests/ui/malformed/malformed-special-attrs.stderr @@ -7,9 +7,8 @@ LL | #[cfg_attr] = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute> help: missing condition and attribute | -LL - #[cfg_attr] -LL + #[cfg_attr(condition, attribute, other_attribute, ...)] - | +LL | #[cfg_attr(condition, attribute, other_attribute, ...)] + | ++++++++++++++++++++++++++++++++++++++++++++ error: malformed `cfg_attr` attribute input --> $DIR/malformed-special-attrs.rs:4:1 diff --git a/tests/ui/methods/method-call-err-msg.stderr b/tests/ui/methods/method-call-err-msg.stderr index 7cda928aca9..95de40ff891 100644 --- a/tests/ui/methods/method-call-err-msg.stderr +++ b/tests/ui/methods/method-call-err-msg.stderr @@ -28,9 +28,8 @@ LL | fn one(self, _: isize) -> Foo { self } | ^^^ -------- help: provide the argument | -LL - .one() -LL + .one(/* isize */) - | +LL | .one(/* isize */) + | +++++++++++ error[E0061]: this method takes 2 arguments but 1 argument was supplied --> $DIR/method-call-err-msg.rs:15:7 @@ -45,9 +44,8 @@ LL | fn two(self, _: isize, _: isize) -> Foo { self } | ^^^ -------- help: provide the argument | -LL - .two(0); -LL + .two(0, /* isize */); - | +LL | .two(0, /* isize */); + | +++++++++++++ error[E0599]: `Foo` is not an iterator --> $DIR/method-call-err-msg.rs:19:7 @@ -84,9 +82,8 @@ LL | fn three<T>(self, _: T, _: T, _: T) -> Foo { self } | ^^^^^ ---- ---- ---- help: provide the arguments | -LL - y.three::<usize>(); -LL + y.three::<usize>(/* usize */, /* usize */, /* usize */); - | +LL | y.three::<usize>(/* usize */, /* usize */, /* usize */); + | +++++++++++++++++++++++++++++++++++++ error: aborting due to 5 previous errors diff --git a/tests/ui/mismatched_types/closure-arg-count.stderr b/tests/ui/mismatched_types/closure-arg-count.stderr index 8704d0f661b..e0fcf9beb3c 100644 --- a/tests/ui/mismatched_types/closure-arg-count.stderr +++ b/tests/ui/mismatched_types/closure-arg-count.stderr @@ -8,9 +8,8 @@ LL | [1, 2, 3].sort_by(|| panic!()); | help: consider changing the closure to take and ignore the expected arguments | -LL - [1, 2, 3].sort_by(|| panic!()); -LL + [1, 2, 3].sort_by(|_, _| panic!()); - | +LL | [1, 2, 3].sort_by(|_, _| panic!()); + | ++++ error[E0593]: closure is expected to take 2 arguments, but it takes 1 argument --> $DIR/closure-arg-count.rs:7:15 @@ -64,9 +63,8 @@ LL | fn f<F: Fn<(usize,)>>(_: F) {} | ^^^^^^^^^^^^ required by this bound in `f` help: consider changing the closure to take and ignore the expected argument | -LL - f(|| panic!()); -LL + f(|_| panic!()); - | +LL | f(|_| panic!()); + | + error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments --> $DIR/closure-arg-count.rs:15:5 @@ -84,9 +82,8 @@ LL | fn f<F: Fn<(usize,)>>(_: F) {} | ^^^^^^^^^^^^ required by this bound in `f` help: consider changing the closure to take and ignore the expected argument | -LL - f( move || panic!()); -LL + f( move |_| panic!()); - | +LL | f( move |_| panic!()); + | + error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments --> $DIR/closure-arg-count.rs:18:53 diff --git a/tests/ui/mismatched_types/issue-13033.stderr b/tests/ui/mismatched_types/issue-13033.stderr index 7756217b560..61786ef14c2 100644 --- a/tests/ui/mismatched_types/issue-13033.stderr +++ b/tests/ui/mismatched_types/issue-13033.stderr @@ -13,9 +13,8 @@ LL | fn bar(&mut self, other: &mut dyn Foo); found signature `fn(&mut Baz, &dyn Foo)` help: change the parameter type to match the trait | -LL - fn bar(&mut self, other: &dyn Foo) {} -LL + fn bar(&mut self, other: &mut dyn Foo) {} - | +LL | fn bar(&mut self, other: &mut dyn Foo) {} + | +++ error: aborting due to 1 previous error diff --git a/tests/ui/mismatched_types/mismatch-args-crash-issue-128848.stderr b/tests/ui/mismatched_types/mismatch-args-crash-issue-128848.stderr index dbd313fada9..13f51cb7b09 100644 --- a/tests/ui/mismatched_types/mismatch-args-crash-issue-128848.stderr +++ b/tests/ui/mismatched_types/mismatch-args-crash-issue-128848.stderr @@ -8,9 +8,8 @@ note: method defined here --> $SRC_DIR/core/src/ops/function.rs:LL:COL help: provide the argument | -LL - f.call_once() -LL + f.call_once(/* args */) - | +LL | f.call_once(/* args */) + | ++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/mismatched_types/mismatch-args-crash-issue-130400.stderr b/tests/ui/mismatched_types/mismatch-args-crash-issue-130400.stderr index d9d99f3d1cf..8ed4530e85e 100644 --- a/tests/ui/mismatched_types/mismatch-args-crash-issue-130400.stderr +++ b/tests/ui/mismatched_types/mismatch-args-crash-issue-130400.stderr @@ -11,9 +11,8 @@ LL | fn foo(&mut self) -> _ { | ^^^ --------- help: provide the argument | -LL - Self::foo() -LL + Self::foo(/* value */) - | +LL | Self::foo(/* value */) + | +++++++++++ error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/mismatch-args-crash-issue-130400.rs:2:26 diff --git a/tests/ui/mismatched_types/mismatch-args-vargs-issue-130372.stderr b/tests/ui/mismatched_types/mismatch-args-vargs-issue-130372.stderr index 7acc361fdb8..b949b4ea298 100644 --- a/tests/ui/mismatched_types/mismatch-args-vargs-issue-130372.stderr +++ b/tests/ui/mismatched_types/mismatch-args-vargs-issue-130372.stderr @@ -11,9 +11,8 @@ LL | unsafe extern "C" fn test_va_copy(_: u64, mut ap: ...) {} | ^^^^^^^^^^^^ ------ help: provide the argument | -LL - test_va_copy(); -LL + test_va_copy(/* u64 */); - | +LL | test_va_copy(/* u64 */); + | +++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/mismatched_types/overloaded-calls-bad.stderr b/tests/ui/mismatched_types/overloaded-calls-bad.stderr index 9f5c35a3009..0a872da6014 100644 --- a/tests/ui/mismatched_types/overloaded-calls-bad.stderr +++ b/tests/ui/mismatched_types/overloaded-calls-bad.stderr @@ -25,9 +25,8 @@ LL | impl FnMut<(isize,)> for S { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: provide the argument | -LL - let ans = s(); -LL + let ans = s(/* isize */); - | +LL | let ans = s(/* isize */); + | +++++++++++ error[E0057]: this function takes 1 argument but 2 arguments were supplied --> $DIR/overloaded-calls-bad.rs:37:15 diff --git a/tests/ui/mismatched_types/trait-impl-fn-incompatibility.stderr b/tests/ui/mismatched_types/trait-impl-fn-incompatibility.stderr index d232cc50e52..45a02982289 100644 --- a/tests/ui/mismatched_types/trait-impl-fn-incompatibility.stderr +++ b/tests/ui/mismatched_types/trait-impl-fn-incompatibility.stderr @@ -32,9 +32,8 @@ LL | fn bar(&mut self, bar: &mut Bar); found signature `fn(&mut Bar, &Bar)` help: change the parameter type to match the trait | -LL - fn bar(&mut self, bar: &Bar) { } -LL + fn bar(&mut self, bar: &mut Bar) { } - | +LL | fn bar(&mut self, bar: &mut Bar) { } + | +++ error: aborting due to 2 previous errors diff --git a/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.stderr b/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.stderr index 7e11b23d681..9dbd6769693 100644 --- a/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.stderr +++ b/tests/ui/nll/borrowck-thread-local-static-mut-borrow-outlives-fn.stderr @@ -9,9 +9,8 @@ LL | S1 { a: unsafe { &mut X1 } } = note: `#[warn(static_mut_refs)]` on by default help: use `&raw mut` instead to create a raw pointer | -LL - S1 { a: unsafe { &mut X1 } } -LL + S1 { a: unsafe { &raw mut X1 } } - | +LL | S1 { a: unsafe { &raw mut X1 } } + | +++ warning: 1 warning emitted diff --git a/tests/ui/not-enough-arguments.stderr b/tests/ui/not-enough-arguments.stderr index 637c2774d5a..099d82eb935 100644 --- a/tests/ui/not-enough-arguments.stderr +++ b/tests/ui/not-enough-arguments.stderr @@ -11,9 +11,8 @@ LL | fn foo(a: isize, b: isize, c: isize, d:isize) { | ^^^ ------- help: provide the argument | -LL - foo(1, 2, 3); -LL + foo(1, 2, 3, /* isize */); - | +LL | foo(1, 2, 3, /* isize */); + | +++++++++++++ error[E0061]: this function takes 6 arguments but 3 arguments were supplied --> $DIR/not-enough-arguments.rs:29:3 @@ -35,9 +34,8 @@ LL | f: i32, | ------ help: provide the arguments | -LL - bar(1, 2, 3); -LL + bar(1, 2, 3, /* i32 */, /* i32 */, /* i32 */); - | +LL | bar(1, 2, 3, /* i32 */, /* i32 */, /* i32 */); + | +++++++++++++++++++++++++++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/obsolete-in-place/bad.stderr b/tests/ui/obsolete-in-place/bad.stderr index 1409a663789..a1321a46351 100644 --- a/tests/ui/obsolete-in-place/bad.stderr +++ b/tests/ui/obsolete-in-place/bad.stderr @@ -6,9 +6,8 @@ LL | x <- y; | help: if you meant to write a comparison against a negative value, add a space in between `<` and `-` | -LL - x <- y; -LL + x < - y; - | +LL | x < - y; + | + error: expected expression, found keyword `in` --> $DIR/bad.rs:10:5 diff --git a/tests/ui/on-unimplemented/bad-annotation.stderr b/tests/ui/on-unimplemented/bad-annotation.stderr index 0482a5c5855..4ceea779b29 100644 --- a/tests/ui/on-unimplemented/bad-annotation.stderr +++ b/tests/ui/on-unimplemented/bad-annotation.stderr @@ -6,12 +6,10 @@ LL | #[rustc_on_unimplemented] | help: the following are the possible correct uses | -LL - #[rustc_on_unimplemented] -LL + #[rustc_on_unimplemented = "message"] - | -LL - #[rustc_on_unimplemented] -LL + #[rustc_on_unimplemented(/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...")] - | +LL | #[rustc_on_unimplemented = "message"] + | +++++++++++ +LL | #[rustc_on_unimplemented(/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...")] + | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ error[E0230]: there is no parameter `C` on trait `BadAnnotation2` --> $DIR/bad-annotation.rs:22:1 diff --git a/tests/ui/on-unimplemented/issue-104140.stderr b/tests/ui/on-unimplemented/issue-104140.stderr index 5c9d5e8d553..3c317135dd4 100644 --- a/tests/ui/on-unimplemented/issue-104140.stderr +++ b/tests/ui/on-unimplemented/issue-104140.stderr @@ -6,12 +6,10 @@ LL | #[rustc_on_unimplemented] | help: the following are the possible correct uses | -LL - #[rustc_on_unimplemented] -LL + #[rustc_on_unimplemented = "message"] - | -LL - #[rustc_on_unimplemented] -LL + #[rustc_on_unimplemented(/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...")] - | +LL | #[rustc_on_unimplemented = "message"] + | +++++++++++ +LL | #[rustc_on_unimplemented(/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...")] + | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/panic-handler/weak-lang-item.stderr b/tests/ui/panic-handler/weak-lang-item.stderr index e9d444c1c4d..5dcb37df689 100644 --- a/tests/ui/panic-handler/weak-lang-item.stderr +++ b/tests/ui/panic-handler/weak-lang-item.stderr @@ -7,9 +7,8 @@ LL | extern crate core; = note: `core` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | -LL - extern crate core; -LL + extern crate core as other_core; - | +LL | extern crate core as other_core; + | +++++++++++++ error: `#[panic_handler]` function required, but not found diff --git a/tests/ui/parser/emoji-identifiers.stderr b/tests/ui/parser/emoji-identifiers.stderr index f0e90082bff..ef4e647b9f5 100644 --- a/tests/ui/parser/emoji-identifiers.stderr +++ b/tests/ui/parser/emoji-identifiers.stderr @@ -81,9 +81,8 @@ LL | fn full_of_✨() -> 👀 { | ^^^^^^^^^^^^^^^^^^^^^ help: there is an associated function `full_of_✨` with a similar name | -LL - 👀::full_of✨() -LL + 👀::full_of_✨() - | +LL | 👀::full_of_✨() + | + error[E0425]: cannot find function `i_like_to_😄_a_lot` in this scope --> $DIR/emoji-identifiers.rs:13:13 diff --git a/tests/ui/parser/extern-crate-unexpected-token.stderr b/tests/ui/parser/extern-crate-unexpected-token.stderr index 3d48f0adfa1..033db85a6c7 100644 --- a/tests/ui/parser/extern-crate-unexpected-token.stderr +++ b/tests/ui/parser/extern-crate-unexpected-token.stderr @@ -6,9 +6,8 @@ LL | extern crte foo; | help: there is a keyword `crate` with a similar name | -LL - extern crte foo; -LL + extern crate foo; - | +LL | extern crate foo; + | + error: aborting due to 1 previous error diff --git a/tests/ui/parser/macro/issue-37113.rs b/tests/ui/parser/macro/issue-37113.rs index 0044aa5610f..e0957542f8f 100644 --- a/tests/ui/parser/macro/issue-37113.rs +++ b/tests/ui/parser/macro/issue-37113.rs @@ -1,7 +1,7 @@ macro_rules! test_macro { ( $( $t:ty ),* $(),*) => { enum SomeEnum { - $( $t, )* //~ ERROR expected identifier, found `String` + $( $t, )* //~ ERROR expected identifier, found metavariable }; }; } diff --git a/tests/ui/parser/macro/issue-37113.stderr b/tests/ui/parser/macro/issue-37113.stderr index 1f2fe23106a..560329df5cc 100644 --- a/tests/ui/parser/macro/issue-37113.stderr +++ b/tests/ui/parser/macro/issue-37113.stderr @@ -1,10 +1,10 @@ -error: expected identifier, found `String` +error: expected identifier, found metavariable --> $DIR/issue-37113.rs:4:16 | LL | enum SomeEnum { | -------- while parsing this enum LL | $( $t, )* - | ^^ expected identifier + | ^^ expected identifier, found metavariable ... LL | test_macro!(String,); | -------------------- in this macro invocation diff --git a/tests/ui/parser/macro/trait-object-macro-matcher.rs b/tests/ui/parser/macro/trait-object-macro-matcher.rs index 560195977d0..d4ec199070e 100644 --- a/tests/ui/parser/macro/trait-object-macro-matcher.rs +++ b/tests/ui/parser/macro/trait-object-macro-matcher.rs @@ -10,5 +10,6 @@ macro_rules! m { fn main() { m!('static); //~^ ERROR lifetime in trait object type must be followed by `+` + //~| ERROR lifetime in trait object type must be followed by `+` //~| ERROR at least one trait is required for an object type } diff --git a/tests/ui/parser/macro/trait-object-macro-matcher.stderr b/tests/ui/parser/macro/trait-object-macro-matcher.stderr index 40082564bad..81dca6f71c4 100644 --- a/tests/ui/parser/macro/trait-object-macro-matcher.stderr +++ b/tests/ui/parser/macro/trait-object-macro-matcher.stderr @@ -4,12 +4,20 @@ error: lifetime in trait object type must be followed by `+` LL | m!('static); | ^^^^^^^ +error: lifetime in trait object type must be followed by `+` + --> $DIR/trait-object-macro-matcher.rs:11:8 + | +LL | m!('static); + | ^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0224]: at least one trait is required for an object type --> $DIR/trait-object-macro-matcher.rs:11:8 | LL | m!('static); | ^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0224`. diff --git a/tests/ui/parser/misspelled-keywords/const-fn.stderr b/tests/ui/parser/misspelled-keywords/const-fn.stderr index 46a6d8ca779..cc4c0f92917 100644 --- a/tests/ui/parser/misspelled-keywords/const-fn.stderr +++ b/tests/ui/parser/misspelled-keywords/const-fn.stderr @@ -6,9 +6,8 @@ LL | cnst fn code() {} | help: there is a keyword `const` with a similar name | -LL - cnst fn code() {} -LL + const fn code() {} - | +LL | const fn code() {} + | + error: aborting due to 1 previous error diff --git a/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr index 23821decd6e..d241f417553 100644 --- a/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr @@ -37,7 +37,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match ref_never { LL + _ => todo!(), -LL + } +LL ~ } | error: unreachable pattern @@ -100,7 +100,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match res_u32_never { LL + Ok(_) => todo!(), -LL + } +LL ~ } | error: unreachable pattern @@ -374,7 +374,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match slice_never { LL + _ => todo!(), -LL + } +LL ~ } | error[E0004]: non-exhaustive patterns: `&[]` not covered @@ -415,7 +415,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match *slice_never { LL + _ => todo!(), -LL + } +LL ~ } | error: unreachable pattern @@ -462,7 +462,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match array_0_never { LL + _ => todo!(), -LL + } +LL ~ } | error: unreachable pattern diff --git a/tests/ui/pattern/usefulness/empty-types.never_pats.stderr b/tests/ui/pattern/usefulness/empty-types.never_pats.stderr index 84aefe7d963..ea63d7ba1af 100644 --- a/tests/ui/pattern/usefulness/empty-types.never_pats.stderr +++ b/tests/ui/pattern/usefulness/empty-types.never_pats.stderr @@ -46,7 +46,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match ref_never { LL + _ => todo!(), -LL + } +LL ~ } | error: unreachable pattern @@ -76,7 +76,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match res_u32_never { LL + Ok(_) => todo!(), -LL + } +LL ~ } | error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered @@ -321,7 +321,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match slice_never { LL + _ => todo!(), -LL + } +LL ~ } | error[E0004]: non-exhaustive patterns: `&[!, ..]` not covered @@ -376,7 +376,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match *slice_never { LL + _ => todo!(), -LL + } +LL ~ } | error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty @@ -390,7 +390,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match array_0_never { LL + _ => todo!(), -LL + } +LL ~ } | error: unreachable pattern @@ -502,7 +502,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match *ref_tuple_half_never { LL + _ => todo!(), -LL + } +LL ~ } | error: unreachable pattern diff --git a/tests/ui/pattern/usefulness/empty-types.normal.stderr b/tests/ui/pattern/usefulness/empty-types.normal.stderr index f3af74c16c3..a1a44e77744 100644 --- a/tests/ui/pattern/usefulness/empty-types.normal.stderr +++ b/tests/ui/pattern/usefulness/empty-types.normal.stderr @@ -37,7 +37,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match ref_never { LL + _ => todo!(), -LL + } +LL ~ } | error: unreachable pattern @@ -67,7 +67,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match res_u32_never { LL + Ok(_) => todo!(), -LL + } +LL ~ } | error[E0004]: non-exhaustive patterns: `Ok(1_u32..=u32::MAX)` not covered @@ -312,7 +312,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match slice_never { LL + _ => todo!(), -LL + } +LL ~ } | error[E0004]: non-exhaustive patterns: `&[_, ..]` not covered @@ -367,7 +367,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match *slice_never { LL + _ => todo!(), -LL + } +LL ~ } | error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty @@ -381,7 +381,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match array_0_never { LL + _ => todo!(), -LL + } +LL ~ } | error: unreachable pattern @@ -493,7 +493,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match *ref_tuple_half_never { LL + _ => todo!(), -LL + } +LL ~ } | error: unreachable pattern diff --git a/tests/ui/pattern/usefulness/impl-trait.stderr b/tests/ui/pattern/usefulness/impl-trait.stderr index 34f8eb1e163..c3e1c267b61 100644 --- a/tests/ui/pattern/usefulness/impl-trait.stderr +++ b/tests/ui/pattern/usefulness/impl-trait.stderr @@ -36,7 +36,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match return_never_rpit(x) { LL + _ => todo!(), -LL + } +LL ~ } | error: unreachable pattern @@ -118,7 +118,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match return_never_tait(x) { LL + _ => todo!(), -LL + } +LL ~ } | error: unreachable pattern diff --git a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr index 914c6ed60c8..7caee64a33f 100644 --- a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr +++ b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr @@ -154,7 +154,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match 7usize { LL + _ => todo!(), -LL + } +LL ~ } | error: aborting due to 12 previous errors diff --git a/tests/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.stderr b/tests/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.stderr index 2acde849650..c37a9a51579 100644 --- a/tests/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.stderr +++ b/tests/ui/pattern/usefulness/issue-78123-non-exhaustive-reference.stderr @@ -15,7 +15,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match a { LL + _ => todo!(), -LL + } +LL ~ } | error: aborting due to 1 previous error diff --git a/tests/ui/pattern/usefulness/unstable-gated-fields.stderr b/tests/ui/pattern/usefulness/unstable-gated-fields.stderr index 4487f273534..bd51aca65ee 100644 --- a/tests/ui/pattern/usefulness/unstable-gated-fields.stderr +++ b/tests/ui/pattern/usefulness/unstable-gated-fields.stderr @@ -6,19 +6,16 @@ LL | let UnstableStruct { stable, stable2, } = UnstableStruct::default(); | help: include the missing field in the pattern | -LL - let UnstableStruct { stable, stable2, } = UnstableStruct::default(); -LL + let UnstableStruct { stable, stable2, unstable } = UnstableStruct::default(); - | +LL | let UnstableStruct { stable, stable2, unstable } = UnstableStruct::default(); + | ++++++++ help: if you don't care about this missing field, you can explicitly ignore it | -LL - let UnstableStruct { stable, stable2, } = UnstableStruct::default(); -LL + let UnstableStruct { stable, stable2, unstable: _ } = UnstableStruct::default(); - | +LL | let UnstableStruct { stable, stable2, unstable: _ } = UnstableStruct::default(); + | +++++++++++ help: or always ignore missing fields here | -LL - let UnstableStruct { stable, stable2, } = UnstableStruct::default(); -LL + let UnstableStruct { stable, stable2, .. } = UnstableStruct::default(); - | +LL | let UnstableStruct { stable, stable2, .. } = UnstableStruct::default(); + | ++ error[E0027]: pattern does not mention field `stable2` --> $DIR/unstable-gated-fields.rs:13:9 @@ -28,19 +25,16 @@ LL | let UnstableStruct { stable, unstable, } = UnstableStruct::default(); | help: include the missing field in the pattern | -LL - let UnstableStruct { stable, unstable, } = UnstableStruct::default(); -LL + let UnstableStruct { stable, unstable, stable2 } = UnstableStruct::default(); - | +LL | let UnstableStruct { stable, unstable, stable2 } = UnstableStruct::default(); + | +++++++ help: if you don't care about this missing field, you can explicitly ignore it | -LL - let UnstableStruct { stable, unstable, } = UnstableStruct::default(); -LL + let UnstableStruct { stable, unstable, stable2: _ } = UnstableStruct::default(); - | +LL | let UnstableStruct { stable, unstable, stable2: _ } = UnstableStruct::default(); + | ++++++++++ help: or always ignore missing fields here | -LL - let UnstableStruct { stable, unstable, } = UnstableStruct::default(); -LL + let UnstableStruct { stable, unstable, .. } = UnstableStruct::default(); - | +LL | let UnstableStruct { stable, unstable, .. } = UnstableStruct::default(); + | ++ error: aborting due to 2 previous errors diff --git a/tests/ui/regions/region-object-lifetime-in-coercion.stderr b/tests/ui/regions/region-object-lifetime-in-coercion.stderr index 3880ae82283..5f6a11786cc 100644 --- a/tests/ui/regions/region-object-lifetime-in-coercion.stderr +++ b/tests/ui/regions/region-object-lifetime-in-coercion.stderr @@ -13,9 +13,8 @@ LL + fn a(v: &[u8]) -> Box<dyn Foo + '_> { | help: alternatively, add an explicit `'static` bound to this reference | -LL - fn a(v: &[u8]) -> Box<dyn Foo + 'static> { -LL + fn a(v: &'static [u8]) -> Box<dyn Foo + 'static> { - | +LL | fn a(v: &'static [u8]) -> Box<dyn Foo + 'static> { + | +++++++ error: lifetime may not live long enough --> $DIR/region-object-lifetime-in-coercion.rs:14:5 @@ -32,9 +31,8 @@ LL + fn b(v: &[u8]) -> Box<dyn Foo + '_> { | help: alternatively, add an explicit `'static` bound to this reference | -LL - fn b(v: &[u8]) -> Box<dyn Foo + 'static> { -LL + fn b(v: &'static [u8]) -> Box<dyn Foo + 'static> { - | +LL | fn b(v: &'static [u8]) -> Box<dyn Foo + 'static> { + | +++++++ error: lifetime may not live long enough --> $DIR/region-object-lifetime-in-coercion.rs:21:5 diff --git a/tests/ui/regions/regions-proc-bound-capture.stderr b/tests/ui/regions/regions-proc-bound-capture.stderr index 3149cd8c9a1..75e04bcb7c2 100644 --- a/tests/ui/regions/regions-proc-bound-capture.stderr +++ b/tests/ui/regions/regions-proc-bound-capture.stderr @@ -14,9 +14,8 @@ LL + fn static_proc(x: &isize) -> Box<dyn FnMut() -> (isize) + '_> { | help: alternatively, add an explicit `'static` bound to this reference | -LL - fn static_proc(x: &isize) -> Box<dyn FnMut() -> (isize) + 'static> { -LL + fn static_proc(x: &'static isize) -> Box<dyn FnMut() -> (isize) + 'static> { - | +LL | fn static_proc(x: &'static isize) -> Box<dyn FnMut() -> (isize) + 'static> { + | +++++++ error: aborting due to 1 previous error diff --git a/tests/ui/repr/16-bit-repr-c-enum.rs b/tests/ui/repr/16-bit-repr-c-enum.rs index 2b6bbf12650..011076882d2 100644 --- a/tests/ui/repr/16-bit-repr-c-enum.rs +++ b/tests/ui/repr/16-bit-repr-c-enum.rs @@ -2,7 +2,7 @@ //@ revisions: avr msp430 // //@ [avr] needs-llvm-components: avr -//@ [avr] compile-flags: --target=avr-unknown-gnu-atmega328 --crate-type=rlib +//@ [avr] compile-flags: --target=avr-none -C target-cpu=atmega328p --crate-type=rlib //@ [msp430] needs-llvm-components: msp430 //@ [msp430] compile-flags: --target=msp430-none-elf --crate-type=rlib #![feature(no_core, lang_items, intrinsics, staged_api, rustc_attrs)] diff --git a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr index 8e8f1d159b7..204db30786e 100644 --- a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr @@ -4,7 +4,15 @@ error: layout_of(Univariant) = Layout { abi: Align(4 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: Scalar( + Initialized { + value: Int( + I32, + false, + ), + valid_range: 0..=0, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -23,6 +31,7 @@ error: layout_of(Univariant) = Layout { valid_range: 0..=0, }, ), + uninhabited: true, variants: Multiple { tag: Initialized { value: Int( @@ -40,7 +49,15 @@ error: layout_of(Univariant) = Layout { abi: Align(4 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: Scalar( + Initialized { + value: Int( + I32, + false, + ), + valid_range: 0..=0, + }, + ), fields: Arbitrary { offsets: [ Size(4 bytes), @@ -50,6 +67,7 @@ error: layout_of(Univariant) = Layout { ], }, largest_niche: None, + uninhabited: true, variants: Single { index: 0, }, @@ -107,6 +125,7 @@ error: layout_of(TwoVariants) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -119,12 +138,26 @@ error: layout_of(TwoVariants) = Layout { tag_field: 0, variants: [ Layout { - size: Size(4 bytes), + size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: ScalarPair( + Initialized { + value: Int( + I32, + false, + ), + valid_range: 0..=1, + }, + Union { + value: Int( + I8, + false, + ), + }, + ), fields: Arbitrary { offsets: [ Size(4 bytes), @@ -134,6 +167,7 @@ error: layout_of(TwoVariants) = Layout { ], }, largest_niche: None, + uninhabited: true, variants: Single { index: 0, }, @@ -171,6 +205,7 @@ error: layout_of(TwoVariants) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 1, }, @@ -216,6 +251,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -233,7 +269,9 @@ error: layout_of(DeadBranchHasOtherField) = Layout { abi: Align(8 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: Memory { + sized: true, + }, fields: Arbitrary { offsets: [ Size(8 bytes), @@ -245,6 +283,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { ], }, largest_niche: None, + uninhabited: true, variants: Single { index: 0, }, @@ -272,6 +311,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 1, }, diff --git a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr index 2cd0960ce3e..1fab00bf50c 100644 --- a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr +++ b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr @@ -4,7 +4,15 @@ error: layout_of(Univariant) = Layout { abi: Align(1 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: Scalar( + Initialized { + value: Int( + I8, + false, + ), + valid_range: 0..=0, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -23,6 +31,7 @@ error: layout_of(Univariant) = Layout { valid_range: 0..=0, }, ), + uninhabited: true, variants: Multiple { tag: Initialized { value: Int( @@ -40,7 +49,15 @@ error: layout_of(Univariant) = Layout { abi: Align(1 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: Scalar( + Initialized { + value: Int( + I8, + false, + ), + valid_range: 0..=0, + }, + ), fields: Arbitrary { offsets: [ Size(1 bytes), @@ -50,6 +67,7 @@ error: layout_of(Univariant) = Layout { ], }, largest_niche: None, + uninhabited: true, variants: Single { index: 0, }, @@ -107,6 +125,7 @@ error: layout_of(TwoVariants) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -119,12 +138,26 @@ error: layout_of(TwoVariants) = Layout { tag_field: 0, variants: [ Layout { - size: Size(1 bytes), + size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: ScalarPair( + Initialized { + value: Int( + I8, + false, + ), + valid_range: 0..=1, + }, + Union { + value: Int( + I8, + false, + ), + }, + ), fields: Arbitrary { offsets: [ Size(1 bytes), @@ -134,6 +167,7 @@ error: layout_of(TwoVariants) = Layout { ], }, largest_niche: None, + uninhabited: true, variants: Single { index: 0, }, @@ -171,6 +205,7 @@ error: layout_of(TwoVariants) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 1, }, @@ -216,6 +251,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -233,7 +269,9 @@ error: layout_of(DeadBranchHasOtherField) = Layout { abi: Align(8 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: Memory { + sized: true, + }, fields: Arbitrary { offsets: [ Size(8 bytes), @@ -245,6 +283,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { ], }, largest_niche: None, + uninhabited: true, variants: Single { index: 0, }, @@ -272,6 +311,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 1, }, diff --git a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr index 8e8f1d159b7..204db30786e 100644 --- a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr +++ b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr @@ -4,7 +4,15 @@ error: layout_of(Univariant) = Layout { abi: Align(4 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: Scalar( + Initialized { + value: Int( + I32, + false, + ), + valid_range: 0..=0, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -23,6 +31,7 @@ error: layout_of(Univariant) = Layout { valid_range: 0..=0, }, ), + uninhabited: true, variants: Multiple { tag: Initialized { value: Int( @@ -40,7 +49,15 @@ error: layout_of(Univariant) = Layout { abi: Align(4 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: Scalar( + Initialized { + value: Int( + I32, + false, + ), + valid_range: 0..=0, + }, + ), fields: Arbitrary { offsets: [ Size(4 bytes), @@ -50,6 +67,7 @@ error: layout_of(Univariant) = Layout { ], }, largest_niche: None, + uninhabited: true, variants: Single { index: 0, }, @@ -107,6 +125,7 @@ error: layout_of(TwoVariants) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -119,12 +138,26 @@ error: layout_of(TwoVariants) = Layout { tag_field: 0, variants: [ Layout { - size: Size(4 bytes), + size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: ScalarPair( + Initialized { + value: Int( + I32, + false, + ), + valid_range: 0..=1, + }, + Union { + value: Int( + I8, + false, + ), + }, + ), fields: Arbitrary { offsets: [ Size(4 bytes), @@ -134,6 +167,7 @@ error: layout_of(TwoVariants) = Layout { ], }, largest_niche: None, + uninhabited: true, variants: Single { index: 0, }, @@ -171,6 +205,7 @@ error: layout_of(TwoVariants) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 1, }, @@ -216,6 +251,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -233,7 +269,9 @@ error: layout_of(DeadBranchHasOtherField) = Layout { abi: Align(8 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: Memory { + sized: true, + }, fields: Arbitrary { offsets: [ Size(8 bytes), @@ -245,6 +283,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { ], }, largest_niche: None, + uninhabited: true, variants: Single { index: 0, }, @@ -272,6 +311,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 1, }, diff --git a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr index 8e8f1d159b7..204db30786e 100644 --- a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr +++ b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr @@ -4,7 +4,15 @@ error: layout_of(Univariant) = Layout { abi: Align(4 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: Scalar( + Initialized { + value: Int( + I32, + false, + ), + valid_range: 0..=0, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -23,6 +31,7 @@ error: layout_of(Univariant) = Layout { valid_range: 0..=0, }, ), + uninhabited: true, variants: Multiple { tag: Initialized { value: Int( @@ -40,7 +49,15 @@ error: layout_of(Univariant) = Layout { abi: Align(4 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: Scalar( + Initialized { + value: Int( + I32, + false, + ), + valid_range: 0..=0, + }, + ), fields: Arbitrary { offsets: [ Size(4 bytes), @@ -50,6 +67,7 @@ error: layout_of(Univariant) = Layout { ], }, largest_niche: None, + uninhabited: true, variants: Single { index: 0, }, @@ -107,6 +125,7 @@ error: layout_of(TwoVariants) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -119,12 +138,26 @@ error: layout_of(TwoVariants) = Layout { tag_field: 0, variants: [ Layout { - size: Size(4 bytes), + size: Size(8 bytes), align: AbiAndPrefAlign { abi: Align(4 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: ScalarPair( + Initialized { + value: Int( + I32, + false, + ), + valid_range: 0..=1, + }, + Union { + value: Int( + I8, + false, + ), + }, + ), fields: Arbitrary { offsets: [ Size(4 bytes), @@ -134,6 +167,7 @@ error: layout_of(TwoVariants) = Layout { ], }, largest_niche: None, + uninhabited: true, variants: Single { index: 0, }, @@ -171,6 +205,7 @@ error: layout_of(TwoVariants) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 1, }, @@ -216,6 +251,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -233,7 +269,9 @@ error: layout_of(DeadBranchHasOtherField) = Layout { abi: Align(8 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: Memory { + sized: true, + }, fields: Arbitrary { offsets: [ Size(8 bytes), @@ -245,6 +283,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { ], }, largest_niche: None, + uninhabited: true, variants: Single { index: 0, }, @@ -272,6 +311,7 @@ error: layout_of(DeadBranchHasOtherField) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 1, }, diff --git a/tests/ui/repr/repr-c-int-dead-variants.stderr b/tests/ui/repr/repr-c-int-dead-variants.stderr index fa08b323dec..f852212deb9 100644 --- a/tests/ui/repr/repr-c-int-dead-variants.stderr +++ b/tests/ui/repr/repr-c-int-dead-variants.stderr @@ -4,7 +4,15 @@ error: layout_of(UnivariantU8) = Layout { abi: Align(1 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: Scalar( + Initialized { + value: Int( + I8, + false, + ), + valid_range: 0..=0, + }, + ), fields: Arbitrary { offsets: [ Size(0 bytes), @@ -23,6 +31,7 @@ error: layout_of(UnivariantU8) = Layout { valid_range: 0..=0, }, ), + uninhabited: true, variants: Multiple { tag: Initialized { value: Int( @@ -40,7 +49,15 @@ error: layout_of(UnivariantU8) = Layout { abi: Align(1 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: Scalar( + Initialized { + value: Int( + I8, + false, + ), + valid_range: 0..=0, + }, + ), fields: Arbitrary { offsets: [ Size(1 bytes), @@ -50,6 +67,7 @@ error: layout_of(UnivariantU8) = Layout { ], }, largest_niche: None, + uninhabited: true, variants: Single { index: 0, }, @@ -107,6 +125,7 @@ error: layout_of(TwoVariantsU8) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -119,12 +138,26 @@ error: layout_of(TwoVariantsU8) = Layout { tag_field: 0, variants: [ Layout { - size: Size(1 bytes), + size: Size(2 bytes), align: AbiAndPrefAlign { abi: Align(1 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: ScalarPair( + Initialized { + value: Int( + I8, + false, + ), + valid_range: 0..=1, + }, + Union { + value: Int( + I8, + false, + ), + }, + ), fields: Arbitrary { offsets: [ Size(1 bytes), @@ -134,6 +167,7 @@ error: layout_of(TwoVariantsU8) = Layout { ], }, largest_niche: None, + uninhabited: true, variants: Single { index: 0, }, @@ -171,6 +205,7 @@ error: layout_of(TwoVariantsU8) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 1, }, @@ -216,6 +251,7 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { valid_range: 0..=1, }, ), + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -233,7 +269,9 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { abi: Align(8 bytes), pref: $SOME_ALIGN, }, - abi: Uninhabited, + abi: Memory { + sized: true, + }, fields: Arbitrary { offsets: [ Size(8 bytes), @@ -245,6 +283,7 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { ], }, largest_niche: None, + uninhabited: true, variants: Single { index: 0, }, @@ -272,6 +311,7 @@ error: layout_of(DeadBranchHasOtherFieldU8) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Single { index: 1, }, diff --git a/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr b/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr index f1db2d71b6a..a9b45a18af3 100644 --- a/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr +++ b/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr @@ -3,9 +3,8 @@ error[E0259]: the name `std` is defined multiple times = note: `std` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | -LL - extern crate std; -LL + extern crate std as other_std; - | +LL | extern crate std as other_std; + | ++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr b/tests/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr index 40c76821bb8..ef8723408da 100644 --- a/tests/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr +++ b/tests/ui/resolve/resolve-conflict-import-vs-extern-crate.stderr @@ -7,9 +7,8 @@ LL | use std::slice as std; = note: `std` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import | -LL - use std::slice as std; -LL + use std::slice as other_std; - | +LL | use std::slice as other_std; + | ++++++ error: aborting due to 1 previous error diff --git a/tests/ui/return/return-from-residual-sugg-issue-125997.stderr b/tests/ui/return/return-from-residual-sugg-issue-125997.stderr index e22f33fd242..877995dfe12 100644 --- a/tests/ui/return/return-from-residual-sugg-issue-125997.stderr +++ b/tests/ui/return/return-from-residual-sugg-issue-125997.stderr @@ -6,7 +6,6 @@ LL | fn test1() { LL | let mut _file = File::create("foo.txt")?; | ^ cannot use the `?` operator in a function that returns `()` | - = help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()` help: consider adding return type | LL ~ fn test1() -> Result<(), Box<dyn std::error::Error>> { @@ -23,7 +22,6 @@ LL | fn test2() { LL | let mut _file = File::create("foo.txt")?; | ^ cannot use the `?` operator in a function that returns `()` | - = help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()` help: consider adding return type | LL ~ fn test2() -> Result<(), Box<dyn std::error::Error>> { @@ -41,7 +39,6 @@ LL | fn test4(&self) { LL | let mut _file = File::create("foo.txt")?; | ^ cannot use the `?` operator in a method that returns `()` | - = help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()` help: consider adding return type | LL ~ fn test4(&self) -> Result<(), Box<dyn std::error::Error>> { @@ -59,7 +56,6 @@ LL | fn test5(&self) { LL | let mut _file = File::create("foo.txt")?; | ^ cannot use the `?` operator in a method that returns `()` | - = help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()` help: consider adding return type | LL ~ fn test5(&self) -> Result<(), Box<dyn std::error::Error>> { @@ -78,7 +74,6 @@ LL | fn main() { LL | let mut _file = File::create("foo.txt")?; | ^ cannot use the `?` operator in a function that returns `()` | - = help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()` help: consider adding return type | LL ~ fn main() -> Result<(), Box<dyn std::error::Error>> { @@ -99,7 +94,6 @@ LL | let mut _file = File::create("foo.txt")?; LL | mac!(); | ------ in this macro invocation | - = help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()` = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider adding return type | diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr index 45a0ca01a56..100e0a501e0 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/enum_same_crate_empty_match.stderr @@ -38,7 +38,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match NonExhaustiveEnum::Unit { LL + NonExhaustiveEnum::Unit | NonExhaustiveEnum::Tuple(_) | NonExhaustiveEnum::Struct { .. } => todo!(), -LL + } +LL ~ } | error[E0004]: non-exhaustive patterns: `NormalEnum::Unit`, `NormalEnum::Tuple(_)` and `NormalEnum::Struct { .. }` not covered @@ -65,7 +65,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match NormalEnum::Unit { LL + NormalEnum::Unit | NormalEnum::Tuple(_) | NormalEnum::Struct { .. } => todo!(), -LL + } +LL ~ } | error: aborting due to 3 previous errors diff --git a/tests/ui/self/arbitrary_self_types_not_allow_call_with_no_deref.stderr b/tests/ui/self/arbitrary_self_types_not_allow_call_with_no_deref.stderr index 8843efc6ff8..a30cf605829 100644 --- a/tests/ui/self/arbitrary_self_types_not_allow_call_with_no_deref.stderr +++ b/tests/ui/self/arbitrary_self_types_not_allow_call_with_no_deref.stderr @@ -13,9 +13,8 @@ LL | foo_cpp_ref.0.frobnicate_ref(); | ++ help: there is a method `frobnicate_cpp_ref` with a similar name | -LL - foo_cpp_ref.frobnicate_ref(); -LL + foo_cpp_ref.frobnicate_cpp_ref(); - | +LL | foo_cpp_ref.frobnicate_cpp_ref(); + | ++++ error[E0599]: no method named `frobnicate_self` found for struct `CppRef` in the current scope --> $DIR/arbitrary_self_types_not_allow_call_with_no_deref.rs:32:17 diff --git a/tests/ui/span/missing-unit-argument.stderr b/tests/ui/span/missing-unit-argument.stderr index e77ec3c8447..e83f7b6cb70 100644 --- a/tests/ui/span/missing-unit-argument.stderr +++ b/tests/ui/span/missing-unit-argument.stderr @@ -8,9 +8,8 @@ note: tuple variant defined here --> $SRC_DIR/core/src/result.rs:LL:COL help: provide the argument | -LL - let _: Result<(), String> = Ok(); -LL + let _: Result<(), String> = Ok(()); - | +LL | let _: Result<(), String> = Ok(()); + | ++ error[E0061]: this function takes 2 arguments but 0 arguments were supplied --> $DIR/missing-unit-argument.rs:12:5 @@ -25,9 +24,8 @@ LL | fn foo(():(), ():()) {} | ^^^ ----- ----- help: provide the arguments | -LL - foo(); -LL + foo((), ()); - | +LL | foo((), ()); + | ++++++ error[E0061]: this function takes 2 arguments but 1 argument was supplied --> $DIR/missing-unit-argument.rs:13:5 @@ -42,9 +40,8 @@ LL | fn foo(():(), ():()) {} | ^^^ ----- help: provide the argument | -LL - foo(()); -LL + foo((), ()); - | +LL | foo((), ()); + | ++++ error[E0061]: this function takes 1 argument but 0 arguments were supplied --> $DIR/missing-unit-argument.rs:14:5 @@ -59,9 +56,8 @@ LL | fn bar(():()) {} | ^^^ ----- help: provide the argument | -LL - bar(); -LL + bar(()); - | +LL | bar(()); + | ++ error[E0061]: this method takes 1 argument but 0 arguments were supplied --> $DIR/missing-unit-argument.rs:15:7 @@ -76,9 +72,8 @@ LL | fn baz(self, (): ()) { } | ^^^ ------ help: provide the argument | -LL - S.baz(); -LL + S.baz(()); - | +LL | S.baz(()); + | ++ error[E0061]: this method takes 1 argument but 0 arguments were supplied --> $DIR/missing-unit-argument.rs:16:7 @@ -93,9 +88,8 @@ LL | fn generic<T>(self, _: T) { } | ^^^^^^^ ---- help: provide the argument | -LL - S.generic::<()>(); -LL + S.generic::<()>(()); - | +LL | S.generic::<()>(()); + | ++ error: aborting due to 6 previous errors diff --git a/tests/ui/statics/static-mut-shared-parens.stderr b/tests/ui/statics/static-mut-shared-parens.stderr index 3d4b55909cd..30a586c286a 100644 --- a/tests/ui/statics/static-mut-shared-parens.stderr +++ b/tests/ui/statics/static-mut-shared-parens.stderr @@ -22,9 +22,8 @@ LL | let _ = unsafe { ((&mut TEST)) as *const usize }; = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives help: use `&raw mut` instead to create a raw pointer | -LL - let _ = unsafe { ((&mut TEST)) as *const usize }; -LL + let _ = unsafe { ((&raw mut TEST)) as *const usize }; - | +LL | let _ = unsafe { ((&raw mut TEST)) as *const usize }; + | +++ warning: 2 warnings emitted diff --git a/tests/ui/statics/static-mut-xc.stderr b/tests/ui/statics/static-mut-xc.stderr index 48cac28a6eb..69f334a5636 100644 --- a/tests/ui/statics/static-mut-xc.stderr +++ b/tests/ui/statics/static-mut-xc.stderr @@ -67,9 +67,8 @@ LL | static_bound_set(&mut static_mut_xc::a); = note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives help: use `&raw mut` instead to create a raw pointer | -LL - static_bound_set(&mut static_mut_xc::a); -LL + static_bound_set(&raw mut static_mut_xc::a); - | +LL | static_bound_set(&raw mut static_mut_xc::a); + | +++ warning: 7 warnings emitted diff --git a/tests/ui/structs/default-field-values/non-exhaustive-ctor.disabled.stderr b/tests/ui/structs/default-field-values/non-exhaustive-ctor.disabled.stderr index c7689cfd323..09506703b7e 100644 --- a/tests/ui/structs/default-field-values/non-exhaustive-ctor.disabled.stderr +++ b/tests/ui/structs/default-field-values/non-exhaustive-ctor.disabled.stderr @@ -66,9 +66,8 @@ LL | let _ = S { }; | help: all remaining fields have default values, if you added `#![feature(default_field_values)]` to your crate you could use those values with `..` | -LL - let _ = S { }; -LL + let _ = S { .. }; - | +LL | let _ = S { .. }; + | ++ error[E0063]: missing fields `field1` and `field2` in initializer of `S` --> $DIR/non-exhaustive-ctor.rs:26:13 diff --git a/tests/ui/structs/default-field-values/non-exhaustive-ctor.enabled.stderr b/tests/ui/structs/default-field-values/non-exhaustive-ctor.enabled.stderr index d9b8e76aa0d..229f47093ad 100644 --- a/tests/ui/structs/default-field-values/non-exhaustive-ctor.enabled.stderr +++ b/tests/ui/structs/default-field-values/non-exhaustive-ctor.enabled.stderr @@ -6,9 +6,8 @@ LL | let _ = S { }; | help: all remaining fields have default values, you can use those values with `..` | -LL - let _ = S { }; -LL + let _ = S { .. }; - | +LL | let _ = S { .. }; + | ++ error[E0063]: missing fields `field1` and `field2` in initializer of `S` --> $DIR/non-exhaustive-ctor.rs:26:13 diff --git a/tests/ui/suggestions/args-instead-of-tuple-errors.stderr b/tests/ui/suggestions/args-instead-of-tuple-errors.stderr index 8644f4a1dd4..2ad9c807e48 100644 --- a/tests/ui/suggestions/args-instead-of-tuple-errors.stderr +++ b/tests/ui/suggestions/args-instead-of-tuple-errors.stderr @@ -60,9 +60,8 @@ note: tuple variant defined here --> $SRC_DIR/core/src/option.rs:LL:COL help: provide the argument | -LL - let _: Option<(i8,)> = Some(); -LL + let _: Option<(i8,)> = Some(/* (i8,) */); - | +LL | let _: Option<(i8,)> = Some(/* (i8,) */); + | +++++++++++ error[E0308]: mismatched types --> $DIR/args-instead-of-tuple-errors.rs:14:34 diff --git a/tests/ui/suggestions/args-instead-of-tuple.stderr b/tests/ui/suggestions/args-instead-of-tuple.stderr index 4b0bab971ee..4093d06970e 100644 --- a/tests/ui/suggestions/args-instead-of-tuple.stderr +++ b/tests/ui/suggestions/args-instead-of-tuple.stderr @@ -34,9 +34,8 @@ note: tuple variant defined here --> $SRC_DIR/core/src/option.rs:LL:COL help: provide the argument | -LL - let _: Option<()> = Some(); -LL + let _: Option<()> = Some(()); - | +LL | let _: Option<()> = Some(()); + | ++ error[E0308]: mismatched types --> $DIR/args-instead-of-tuple.rs:14:34 diff --git a/tests/ui/suggestions/bad-hex-float-lit.stderr b/tests/ui/suggestions/bad-hex-float-lit.stderr index 94c0715a4e6..351dc879be3 100644 --- a/tests/ui/suggestions/bad-hex-float-lit.stderr +++ b/tests/ui/suggestions/bad-hex-float-lit.stderr @@ -8,9 +8,8 @@ LL | let _f: f32 = 0xAAf32; | help: rewrite this as a decimal floating point literal, or use `as` to turn a hex literal into a float | -LL - let _f: f32 = 0xAAf32; -LL + let _f: f32 = 0xAA as f32; - | +LL | let _f: f32 = 0xAA as f32; + | ++ LL - let _f: f32 = 0xAAf32; LL + let _f: f32 = 170_f32; | diff --git a/tests/ui/suggestions/incorrect-variant-literal.svg b/tests/ui/suggestions/incorrect-variant-literal.svg index 0f2ade633c5..279fd30f216 100644 --- a/tests/ui/suggestions/incorrect-variant-literal.svg +++ b/tests/ui/suggestions/incorrect-variant-literal.svg @@ -1,4 +1,4 @@ -<svg width="886px" height="9542px" xmlns="http://www.w3.org/2000/svg"> +<svg width="886px" height="9524px" xmlns="http://www.w3.org/2000/svg"> <style> .fg { fill: #AAAAAA } .bg { background: #000000 } @@ -103,981 +103,979 @@ </tspan> <tspan x="10px" y="748px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="766px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::Tuple</tspan><tspan class="fg-ansi256-009">()</tspan><tspan>;</tspan> + <tspan x="10px" y="766px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">| </tspan><tspan> Enum::Tuple(</tspan><tspan class="fg-ansi256-010">/* i32 */</tspan><tspan>);</tspan> </tspan> - <tspan x="10px" y="784px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::Tuple</tspan><tspan class="fg-ansi256-010">(/* i32 */)</tspan><tspan>;</tspan> + <tspan x="10px" y="784px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+++++++++</tspan> </tspan> - <tspan x="10px" y="802px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="802px"> </tspan> - <tspan x="10px" y="820px"> + <tspan x="10px" y="820px"><tspan class="fg-ansi256-009 bold">error[E0533]</tspan><tspan class="bold">: expected value, found struct variant `Enum::Struct`</tspan> </tspan> - <tspan x="10px" y="838px"><tspan class="fg-ansi256-009 bold">error[E0533]</tspan><tspan class="bold">: expected value, found struct variant `Enum::Struct`</tspan> + <tspan x="10px" y="838px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:16:5</tspan> </tspan> - <tspan x="10px" y="856px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:16:5</tspan> + <tspan x="10px" y="856px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="874px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="874px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Struct();</tspan> </tspan> - <tspan x="10px" y="892px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Struct();</tspan> + <tspan x="10px" y="892px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">not a value</tspan> </tspan> - <tspan x="10px" y="910px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">not a value</tspan> + <tspan x="10px" y="910px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="928px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="928px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: you might have meant to create a new value of the struct</tspan> </tspan> - <tspan x="10px" y="946px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: you might have meant to create a new value of the struct</tspan> + <tspan x="10px" y="946px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="964px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="964px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::Struct</tspan><tspan class="fg-ansi256-009">()</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="982px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::Struct</tspan><tspan class="fg-ansi256-009">()</tspan><tspan>;</tspan> + <tspan x="10px" y="982px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::Struct</tspan><tspan class="fg-ansi256-010"> { x: /* value */ }</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="1000px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::Struct</tspan><tspan class="fg-ansi256-010"> { x: /* value */ }</tspan><tspan>;</tspan> + <tspan x="10px" y="1000px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="1018px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="1018px"> </tspan> - <tspan x="10px" y="1036px"> + <tspan x="10px" y="1036px"><tspan class="fg-ansi256-009 bold">error[E0063]</tspan><tspan class="bold">: missing field `0` in initializer of `Enum`</tspan> </tspan> - <tspan x="10px" y="1054px"><tspan class="fg-ansi256-009 bold">error[E0063]</tspan><tspan class="bold">: missing field `0` in initializer of `Enum`</tspan> + <tspan x="10px" y="1054px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:18:5</tspan> </tspan> - <tspan x="10px" y="1072px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:18:5</tspan> + <tspan x="10px" y="1072px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="1090px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="1090px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Tuple {};</tspan> </tspan> - <tspan x="10px" y="1108px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Tuple {};</tspan> + <tspan x="10px" y="1108px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">missing `0`</tspan> </tspan> - <tspan x="10px" y="1126px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">missing `0`</tspan> + <tspan x="10px" y="1126px"> </tspan> - <tspan x="10px" y="1144px"> + <tspan x="10px" y="1144px"><tspan class="fg-ansi256-009 bold">error[E0063]</tspan><tspan class="bold">: missing field `x` in initializer of `Enum`</tspan> </tspan> - <tspan x="10px" y="1162px"><tspan class="fg-ansi256-009 bold">error[E0063]</tspan><tspan class="bold">: missing field `x` in initializer of `Enum`</tspan> + <tspan x="10px" y="1162px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:19:5</tspan> </tspan> - <tspan x="10px" y="1180px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:19:5</tspan> + <tspan x="10px" y="1180px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="1198px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="1198px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Struct {};</tspan> </tspan> - <tspan x="10px" y="1216px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Struct {};</tspan> + <tspan x="10px" y="1216px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">missing `x`</tspan> </tspan> - <tspan x="10px" y="1234px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">missing `x`</tspan> + <tspan x="10px" y="1234px"> </tspan> - <tspan x="10px" y="1252px"> + <tspan x="10px" y="1252px"><tspan class="fg-ansi256-009 bold">error[E0618]</tspan><tspan class="bold">: expected function, found `Enum`</tspan> </tspan> - <tspan x="10px" y="1270px"><tspan class="fg-ansi256-009 bold">error[E0618]</tspan><tspan class="bold">: expected function, found `Enum`</tspan> + <tspan x="10px" y="1270px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:20:5</tspan> </tspan> - <tspan x="10px" y="1288px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:20:5</tspan> + <tspan x="10px" y="1288px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="1306px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="1306px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Unit,</tspan> </tspan> - <tspan x="10px" y="1324px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Unit,</tspan> + <tspan x="10px" y="1324px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">----</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">`Enum::Unit` defined here</tspan> </tspan> - <tspan x="10px" y="1342px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">----</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">`Enum::Unit` defined here</tspan> + <tspan x="10px" y="1342px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="1360px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="1360px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Unit(0);</tspan> </tspan> - <tspan x="10px" y="1378px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Unit(0);</tspan> + <tspan x="10px" y="1378px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^^^</tspan><tspan class="fg-ansi256-012 bold">---</tspan> </tspan> - <tspan x="10px" y="1396px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^^^</tspan><tspan class="fg-ansi256-012 bold">---</tspan> + <tspan x="10px" y="1396px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="1414px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="1414px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">call expression requires function</tspan> </tspan> - <tspan x="10px" y="1432px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">call expression requires function</tspan> + <tspan x="10px" y="1432px"> </tspan> - <tspan x="10px" y="1450px"> + <tspan x="10px" y="1450px"><tspan class="fg-ansi256-009 bold">error[E0533]</tspan><tspan class="bold">: expected value, found struct variant `Enum::Struct`</tspan> </tspan> - <tspan x="10px" y="1468px"><tspan class="fg-ansi256-009 bold">error[E0533]</tspan><tspan class="bold">: expected value, found struct variant `Enum::Struct`</tspan> + <tspan x="10px" y="1468px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:22:5</tspan> </tspan> - <tspan x="10px" y="1486px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:22:5</tspan> + <tspan x="10px" y="1486px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="1504px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="1504px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Struct(0);</tspan> </tspan> - <tspan x="10px" y="1522px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Struct(0);</tspan> + <tspan x="10px" y="1522px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">not a value</tspan> </tspan> - <tspan x="10px" y="1540px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">not a value</tspan> + <tspan x="10px" y="1540px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="1558px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="1558px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: you might have meant to create a new value of the struct</tspan> </tspan> - <tspan x="10px" y="1576px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: you might have meant to create a new value of the struct</tspan> + <tspan x="10px" y="1576px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="1594px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="1594px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::Struct</tspan><tspan class="fg-ansi256-009">(0)</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="1612px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::Struct</tspan><tspan class="fg-ansi256-009">(0)</tspan><tspan>;</tspan> + <tspan x="10px" y="1612px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::Struct</tspan><tspan class="fg-ansi256-010"> { x: /* value */ }</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="1630px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::Struct</tspan><tspan class="fg-ansi256-010"> { x: /* value */ }</tspan><tspan>;</tspan> + <tspan x="10px" y="1630px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="1648px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="1648px"> </tspan> - <tspan x="10px" y="1666px"> + <tspan x="10px" y="1666px"><tspan class="fg-ansi256-009 bold">error[E0559]</tspan><tspan class="bold">: variant `Enum::Unit` has no field named `x`</tspan> </tspan> - <tspan x="10px" y="1684px"><tspan class="fg-ansi256-009 bold">error[E0559]</tspan><tspan class="bold">: variant `Enum::Unit` has no field named `x`</tspan> + <tspan x="10px" y="1684px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:23:18</tspan> </tspan> - <tspan x="10px" y="1702px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:23:18</tspan> + <tspan x="10px" y="1702px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="1720px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="1720px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Unit { x: 0 };</tspan> </tspan> - <tspan x="10px" y="1738px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Unit { x: 0 };</tspan> + <tspan x="10px" y="1738px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">`Enum::Unit` does not have this field</tspan> </tspan> - <tspan x="10px" y="1756px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">`Enum::Unit` does not have this field</tspan> + <tspan x="10px" y="1756px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="1774px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="1774px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">= </tspan><tspan class="bold">note</tspan><tspan>: all struct fields are already assigned</tspan> </tspan> - <tspan x="10px" y="1792px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">= </tspan><tspan class="bold">note</tspan><tspan>: all struct fields are already assigned</tspan> + <tspan x="10px" y="1792px"> </tspan> - <tspan x="10px" y="1810px"> + <tspan x="10px" y="1810px"><tspan class="fg-ansi256-009 bold">error[E0559]</tspan><tspan class="bold">: variant `Enum::Tuple` has no field named `x`</tspan> </tspan> - <tspan x="10px" y="1828px"><tspan class="fg-ansi256-009 bold">error[E0559]</tspan><tspan class="bold">: variant `Enum::Tuple` has no field named `x`</tspan> + <tspan x="10px" y="1828px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:24:19</tspan> </tspan> - <tspan x="10px" y="1846px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:24:19</tspan> + <tspan x="10px" y="1846px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="1864px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="1864px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Tuple(i32),</tspan> </tspan> - <tspan x="10px" y="1882px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Tuple(i32),</tspan> + <tspan x="10px" y="1882px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">-----</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">`Enum::Tuple` defined here</tspan> </tspan> - <tspan x="10px" y="1900px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">-----</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">`Enum::Tuple` defined here</tspan> + <tspan x="10px" y="1900px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="1918px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="1918px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Tuple { x: 0 };</tspan> </tspan> - <tspan x="10px" y="1936px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Tuple { x: 0 };</tspan> + <tspan x="10px" y="1936px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">field does not exist</tspan> </tspan> - <tspan x="10px" y="1954px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">field does not exist</tspan> + <tspan x="10px" y="1954px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="1972px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="1972px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: `Enum::Tuple` is a tuple variant, use the appropriate syntax</tspan> </tspan> - <tspan x="10px" y="1990px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: `Enum::Tuple` is a tuple variant, use the appropriate syntax</tspan> + <tspan x="10px" y="1990px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="2008px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="2008px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::Tuple</tspan><tspan class="fg-ansi256-009"> { x: 0 }</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="2026px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::Tuple</tspan><tspan class="fg-ansi256-009"> { x: 0 }</tspan><tspan>;</tspan> + <tspan x="10px" y="2026px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::Tuple</tspan><tspan class="fg-ansi256-010">(/* i32 */)</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="2044px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::Tuple</tspan><tspan class="fg-ansi256-010">(/* i32 */)</tspan><tspan>;</tspan> + <tspan x="10px" y="2044px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="2062px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="2062px"> </tspan> - <tspan x="10px" y="2080px"> + <tspan x="10px" y="2080px"><tspan class="fg-ansi256-009 bold">error[E0618]</tspan><tspan class="bold">: expected function, found `Enum`</tspan> </tspan> - <tspan x="10px" y="2098px"><tspan class="fg-ansi256-009 bold">error[E0618]</tspan><tspan class="bold">: expected function, found `Enum`</tspan> + <tspan x="10px" y="2098px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:26:5</tspan> </tspan> - <tspan x="10px" y="2116px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:26:5</tspan> + <tspan x="10px" y="2116px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="2134px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="2134px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Unit,</tspan> </tspan> - <tspan x="10px" y="2152px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Unit,</tspan> + <tspan x="10px" y="2152px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">----</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">`Enum::Unit` defined here</tspan> </tspan> - <tspan x="10px" y="2170px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">----</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">`Enum::Unit` defined here</tspan> + <tspan x="10px" y="2170px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="2188px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="2188px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Unit(0, 0);</tspan> </tspan> - <tspan x="10px" y="2206px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Unit(0, 0);</tspan> + <tspan x="10px" y="2206px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^^^</tspan><tspan class="fg-ansi256-012 bold">------</tspan> </tspan> - <tspan x="10px" y="2224px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^^^</tspan><tspan class="fg-ansi256-012 bold">------</tspan> + <tspan x="10px" y="2224px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="2242px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="2242px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">call expression requires function</tspan> </tspan> - <tspan x="10px" y="2260px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">call expression requires function</tspan> + <tspan x="10px" y="2260px"> </tspan> - <tspan x="10px" y="2278px"> + <tspan x="10px" y="2278px"><tspan class="fg-ansi256-009 bold">error[E0061]</tspan><tspan class="bold">: this enum variant takes 1 argument but 2 arguments were supplied</tspan> </tspan> - <tspan x="10px" y="2296px"><tspan class="fg-ansi256-009 bold">error[E0061]</tspan><tspan class="bold">: this enum variant takes 1 argument but 2 arguments were supplied</tspan> + <tspan x="10px" y="2296px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:27:5</tspan> </tspan> - <tspan x="10px" y="2314px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:27:5</tspan> + <tspan x="10px" y="2314px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="2332px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="2332px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Tuple(0, 0);</tspan> </tspan> - <tspan x="10px" y="2350px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Tuple(0, 0);</tspan> + <tspan x="10px" y="2350px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">-</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">unexpected argument #2 of type `{integer}`</tspan> </tspan> - <tspan x="10px" y="2368px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">-</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">unexpected argument #2 of type `{integer}`</tspan> + <tspan x="10px" y="2368px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="2386px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="2386px"><tspan class="fg-ansi256-010 bold">note</tspan><tspan>: tuple variant defined here</tspan> </tspan> - <tspan x="10px" y="2404px"><tspan class="fg-ansi256-010 bold">note</tspan><tspan>: tuple variant defined here</tspan> + <tspan x="10px" y="2404px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:6:5</tspan> </tspan> - <tspan x="10px" y="2422px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:6:5</tspan> + <tspan x="10px" y="2422px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="2440px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="2440px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Tuple(i32),</tspan> </tspan> - <tspan x="10px" y="2458px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Tuple(i32),</tspan> + <tspan x="10px" y="2458px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-010 bold">^^^^^</tspan> </tspan> - <tspan x="10px" y="2476px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-010 bold">^^^^^</tspan> + <tspan x="10px" y="2476px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: remove the extra argument</tspan> </tspan> - <tspan x="10px" y="2494px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: remove the extra argument</tspan> + <tspan x="10px" y="2494px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="2512px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="2512px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::Tuple(0</tspan><tspan class="fg-ansi256-009">, 0</tspan><tspan>);</tspan> </tspan> - <tspan x="10px" y="2530px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::Tuple(0</tspan><tspan class="fg-ansi256-009">, 0</tspan><tspan>);</tspan> + <tspan x="10px" y="2530px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::Tuple(0);</tspan> </tspan> - <tspan x="10px" y="2548px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::Tuple(0);</tspan> + <tspan x="10px" y="2548px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="2566px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="2566px"> </tspan> - <tspan x="10px" y="2584px"> + <tspan x="10px" y="2584px"><tspan class="fg-ansi256-009 bold">error[E0533]</tspan><tspan class="bold">: expected value, found struct variant `Enum::Struct`</tspan> </tspan> - <tspan x="10px" y="2602px"><tspan class="fg-ansi256-009 bold">error[E0533]</tspan><tspan class="bold">: expected value, found struct variant `Enum::Struct`</tspan> + <tspan x="10px" y="2602px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:28:5</tspan> </tspan> - <tspan x="10px" y="2620px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:28:5</tspan> + <tspan x="10px" y="2620px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="2638px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="2638px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Struct(0, 0);</tspan> </tspan> - <tspan x="10px" y="2656px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Struct(0, 0);</tspan> + <tspan x="10px" y="2656px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">not a value</tspan> </tspan> - <tspan x="10px" y="2674px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">not a value</tspan> + <tspan x="10px" y="2674px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="2692px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="2692px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: you might have meant to create a new value of the struct</tspan> </tspan> - <tspan x="10px" y="2710px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: you might have meant to create a new value of the struct</tspan> + <tspan x="10px" y="2710px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="2728px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="2728px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::Struct</tspan><tspan class="fg-ansi256-009">(0, 0)</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="2746px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::Struct</tspan><tspan class="fg-ansi256-009">(0, 0)</tspan><tspan>;</tspan> + <tspan x="10px" y="2746px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::Struct</tspan><tspan class="fg-ansi256-010"> { x: /* value */ }</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="2764px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::Struct</tspan><tspan class="fg-ansi256-010"> { x: /* value */ }</tspan><tspan>;</tspan> + <tspan x="10px" y="2764px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="2782px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="2782px"> </tspan> - <tspan x="10px" y="2800px"> + <tspan x="10px" y="2800px"><tspan class="fg-ansi256-009 bold">error[E0559]</tspan><tspan class="bold">: variant `Enum::Unit` has no field named `x`</tspan> </tspan> - <tspan x="10px" y="2818px"><tspan class="fg-ansi256-009 bold">error[E0559]</tspan><tspan class="bold">: variant `Enum::Unit` has no field named `x`</tspan> + <tspan x="10px" y="2818px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:29:18</tspan> </tspan> - <tspan x="10px" y="2836px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:29:18</tspan> + <tspan x="10px" y="2836px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="2854px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="2854px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Unit { x: 0, y: 0 };</tspan> </tspan> - <tspan x="10px" y="2872px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Unit { x: 0, y: 0 };</tspan> + <tspan x="10px" y="2872px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">`Enum::Unit` does not have this field</tspan> </tspan> - <tspan x="10px" y="2890px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">`Enum::Unit` does not have this field</tspan> + <tspan x="10px" y="2890px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="2908px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="2908px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">= </tspan><tspan class="bold">note</tspan><tspan>: all struct fields are already assigned</tspan> </tspan> - <tspan x="10px" y="2926px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">= </tspan><tspan class="bold">note</tspan><tspan>: all struct fields are already assigned</tspan> + <tspan x="10px" y="2926px"> </tspan> - <tspan x="10px" y="2944px"> + <tspan x="10px" y="2944px"><tspan class="fg-ansi256-009 bold">error[E0559]</tspan><tspan class="bold">: variant `Enum::Unit` has no field named `y`</tspan> </tspan> - <tspan x="10px" y="2962px"><tspan class="fg-ansi256-009 bold">error[E0559]</tspan><tspan class="bold">: variant `Enum::Unit` has no field named `y`</tspan> + <tspan x="10px" y="2962px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:29:24</tspan> </tspan> - <tspan x="10px" y="2980px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:29:24</tspan> + <tspan x="10px" y="2980px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="2998px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="2998px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Unit { x: 0, y: 0 };</tspan> </tspan> - <tspan x="10px" y="3016px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Unit { x: 0, y: 0 };</tspan> + <tspan x="10px" y="3016px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">`Enum::Unit` does not have this field</tspan> </tspan> - <tspan x="10px" y="3034px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">`Enum::Unit` does not have this field</tspan> + <tspan x="10px" y="3034px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="3052px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="3052px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">= </tspan><tspan class="bold">note</tspan><tspan>: all struct fields are already assigned</tspan> </tspan> - <tspan x="10px" y="3070px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">= </tspan><tspan class="bold">note</tspan><tspan>: all struct fields are already assigned</tspan> + <tspan x="10px" y="3070px"> </tspan> - <tspan x="10px" y="3088px"> + <tspan x="10px" y="3088px"><tspan class="fg-ansi256-009 bold">error[E0559]</tspan><tspan class="bold">: variant `Enum::Tuple` has no field named `x`</tspan> </tspan> - <tspan x="10px" y="3106px"><tspan class="fg-ansi256-009 bold">error[E0559]</tspan><tspan class="bold">: variant `Enum::Tuple` has no field named `x`</tspan> + <tspan x="10px" y="3106px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:31:19</tspan> </tspan> - <tspan x="10px" y="3124px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:31:19</tspan> + <tspan x="10px" y="3124px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="3142px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="3142px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Tuple(i32),</tspan> </tspan> - <tspan x="10px" y="3160px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Tuple(i32),</tspan> + <tspan x="10px" y="3160px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">-----</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">`Enum::Tuple` defined here</tspan> </tspan> - <tspan x="10px" y="3178px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">-----</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">`Enum::Tuple` defined here</tspan> + <tspan x="10px" y="3178px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="3196px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="3196px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Tuple { x: 0, y: 0 };</tspan> </tspan> - <tspan x="10px" y="3214px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Tuple { x: 0, y: 0 };</tspan> + <tspan x="10px" y="3214px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">field does not exist</tspan> </tspan> - <tspan x="10px" y="3232px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">field does not exist</tspan> + <tspan x="10px" y="3232px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="3250px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="3250px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: `Enum::Tuple` is a tuple variant, use the appropriate syntax</tspan> </tspan> - <tspan x="10px" y="3268px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: `Enum::Tuple` is a tuple variant, use the appropriate syntax</tspan> + <tspan x="10px" y="3268px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="3286px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="3286px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::Tuple</tspan><tspan class="fg-ansi256-009"> { x: 0, y: 0 }</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="3304px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::Tuple</tspan><tspan class="fg-ansi256-009"> { x: 0, y: 0 }</tspan><tspan>;</tspan> + <tspan x="10px" y="3304px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::Tuple</tspan><tspan class="fg-ansi256-010">(/* i32 */)</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="3322px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::Tuple</tspan><tspan class="fg-ansi256-010">(/* i32 */)</tspan><tspan>;</tspan> + <tspan x="10px" y="3322px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="3340px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="3340px"> </tspan> - <tspan x="10px" y="3358px"> + <tspan x="10px" y="3358px"><tspan class="fg-ansi256-009 bold">error[E0559]</tspan><tspan class="bold">: variant `Enum::Tuple` has no field named `y`</tspan> </tspan> - <tspan x="10px" y="3376px"><tspan class="fg-ansi256-009 bold">error[E0559]</tspan><tspan class="bold">: variant `Enum::Tuple` has no field named `y`</tspan> + <tspan x="10px" y="3376px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:31:25</tspan> </tspan> - <tspan x="10px" y="3394px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:31:25</tspan> + <tspan x="10px" y="3394px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="3412px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="3412px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Tuple(i32),</tspan> </tspan> - <tspan x="10px" y="3430px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Tuple(i32),</tspan> + <tspan x="10px" y="3430px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">-----</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">`Enum::Tuple` defined here</tspan> </tspan> - <tspan x="10px" y="3448px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">-----</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">`Enum::Tuple` defined here</tspan> + <tspan x="10px" y="3448px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="3466px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="3466px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Tuple { x: 0, y: 0 };</tspan> </tspan> - <tspan x="10px" y="3484px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Tuple { x: 0, y: 0 };</tspan> + <tspan x="10px" y="3484px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">field does not exist</tspan> </tspan> - <tspan x="10px" y="3502px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">field does not exist</tspan> + <tspan x="10px" y="3502px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="3520px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="3520px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: `Enum::Tuple` is a tuple variant, use the appropriate syntax</tspan> </tspan> - <tspan x="10px" y="3538px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: `Enum::Tuple` is a tuple variant, use the appropriate syntax</tspan> + <tspan x="10px" y="3538px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="3556px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="3556px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::Tuple</tspan><tspan class="fg-ansi256-009"> { x: 0, y: 0 }</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="3574px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::Tuple</tspan><tspan class="fg-ansi256-009"> { x: 0, y: 0 }</tspan><tspan>;</tspan> + <tspan x="10px" y="3574px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::Tuple</tspan><tspan class="fg-ansi256-010">(/* i32 */)</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="3592px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::Tuple</tspan><tspan class="fg-ansi256-010">(/* i32 */)</tspan><tspan>;</tspan> + <tspan x="10px" y="3592px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="3610px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="3610px"> </tspan> - <tspan x="10px" y="3628px"> + <tspan x="10px" y="3628px"><tspan class="fg-ansi256-009 bold">error[E0559]</tspan><tspan class="bold">: variant `Enum::Struct` has no field named `y`</tspan> </tspan> - <tspan x="10px" y="3646px"><tspan class="fg-ansi256-009 bold">error[E0559]</tspan><tspan class="bold">: variant `Enum::Struct` has no field named `y`</tspan> + <tspan x="10px" y="3646px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:33:26</tspan> </tspan> - <tspan x="10px" y="3664px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:33:26</tspan> + <tspan x="10px" y="3664px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="3682px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="3682px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Struct { x: 0, y: 0 };</tspan> </tspan> - <tspan x="10px" y="3700px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::Struct { x: 0, y: 0 };</tspan> + <tspan x="10px" y="3700px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">`Enum::Struct` does not have this field</tspan> </tspan> - <tspan x="10px" y="3718px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">`Enum::Struct` does not have this field</tspan> + <tspan x="10px" y="3718px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="3736px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="3736px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">= </tspan><tspan class="bold">note</tspan><tspan>: all struct fields are already assigned</tspan> </tspan> - <tspan x="10px" y="3754px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">= </tspan><tspan class="bold">note</tspan><tspan>: all struct fields are already assigned</tspan> + <tspan x="10px" y="3754px"> </tspan> - <tspan x="10px" y="3772px"> + <tspan x="10px" y="3772px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `unit` found for enum `Enum` in the current scope</tspan> </tspan> - <tspan x="10px" y="3790px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `unit` found for enum `Enum` in the current scope</tspan> + <tspan x="10px" y="3790px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:34:11</tspan> </tspan> - <tspan x="10px" y="3808px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:34:11</tspan> + <tspan x="10px" y="3808px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="3826px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="3826px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="3844px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="3844px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `unit` not found for this enum</tspan> </tspan> - <tspan x="10px" y="3862px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `unit` not found for this enum</tspan> + <tspan x="10px" y="3862px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="3880px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="3880px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::unit;</tspan> </tspan> - <tspan x="10px" y="3898px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::unit;</tspan> + <tspan x="10px" y="3898px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> </tspan> - <tspan x="10px" y="3916px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> + <tspan x="10px" y="3916px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="3934px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="3934px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name (notice the capitalization difference)</tspan> </tspan> - <tspan x="10px" y="3952px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name (notice the capitalization difference)</tspan> + <tspan x="10px" y="3952px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="3970px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="3970px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">unit</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="3988px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">unit</tspan><tspan>;</tspan> + <tspan x="10px" y="3988px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Unit</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="4006px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Unit</tspan><tspan>;</tspan> + <tspan x="10px" y="4006px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="4024px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="4024px"> </tspan> - <tspan x="10px" y="4042px"> + <tspan x="10px" y="4042px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `tuple` found for enum `Enum` in the current scope</tspan> </tspan> - <tspan x="10px" y="4060px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `tuple` found for enum `Enum` in the current scope</tspan> + <tspan x="10px" y="4060px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:35:11</tspan> </tspan> - <tspan x="10px" y="4078px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:35:11</tspan> + <tspan x="10px" y="4078px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="4096px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="4096px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="4114px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="4114px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `tuple` not found for this enum</tspan> </tspan> - <tspan x="10px" y="4132px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `tuple` not found for this enum</tspan> + <tspan x="10px" y="4132px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="4150px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="4150px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::tuple;</tspan> </tspan> - <tspan x="10px" y="4168px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::tuple;</tspan> + <tspan x="10px" y="4168px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> </tspan> - <tspan x="10px" y="4186px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> + <tspan x="10px" y="4186px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="4204px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="4204px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="4222px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="4222px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="4240px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="4240px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">tuple</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="4258px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">tuple</tspan><tspan>;</tspan> + <tspan x="10px" y="4258px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Tuple(/* i32 */)</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="4276px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Tuple(/* i32 */)</tspan><tspan>;</tspan> + <tspan x="10px" y="4276px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="4294px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="4294px"> </tspan> - <tspan x="10px" y="4312px"> + <tspan x="10px" y="4312px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `r#struct` found for enum `Enum` in the current scope</tspan> </tspan> - <tspan x="10px" y="4330px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `r#struct` found for enum `Enum` in the current scope</tspan> + <tspan x="10px" y="4330px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:36:11</tspan> </tspan> - <tspan x="10px" y="4348px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:36:11</tspan> + <tspan x="10px" y="4348px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="4366px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="4366px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="4384px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="4384px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `r#struct` not found for this enum</tspan> </tspan> - <tspan x="10px" y="4402px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `r#struct` not found for this enum</tspan> + <tspan x="10px" y="4402px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="4420px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="4420px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::r#struct;</tspan> </tspan> - <tspan x="10px" y="4438px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::r#struct;</tspan> + <tspan x="10px" y="4438px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> </tspan> - <tspan x="10px" y="4456px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> + <tspan x="10px" y="4456px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="4474px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="4474px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="4492px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="4492px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="4510px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="4510px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">r#struct</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="4528px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">r#struct</tspan><tspan>;</tspan> + <tspan x="10px" y="4528px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Struct { x: /* value */ }</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="4546px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Struct { x: /* value */ }</tspan><tspan>;</tspan> + <tspan x="10px" y="4546px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="4564px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="4564px"> </tspan> - <tspan x="10px" y="4582px"> + <tspan x="10px" y="4582px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `unit` found for enum `Enum` in the current scope</tspan> </tspan> - <tspan x="10px" y="4600px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `unit` found for enum `Enum` in the current scope</tspan> + <tspan x="10px" y="4600px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:37:11</tspan> </tspan> - <tspan x="10px" y="4618px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:37:11</tspan> + <tspan x="10px" y="4618px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="4636px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="4636px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="4654px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="4654px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `unit` not found for this enum</tspan> </tspan> - <tspan x="10px" y="4672px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `unit` not found for this enum</tspan> + <tspan x="10px" y="4672px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="4690px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="4690px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::unit();</tspan> </tspan> - <tspan x="10px" y="4708px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::unit();</tspan> + <tspan x="10px" y="4708px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> </tspan> - <tspan x="10px" y="4726px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> + <tspan x="10px" y="4726px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="4744px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="4744px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="4762px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="4762px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="4780px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="4780px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">unit()</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="4798px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">unit()</tspan><tspan>;</tspan> + <tspan x="10px" y="4798px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Unit</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="4816px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Unit</tspan><tspan>;</tspan> + <tspan x="10px" y="4816px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="4834px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="4834px"> </tspan> - <tspan x="10px" y="4852px"> + <tspan x="10px" y="4852px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `tuple` found for enum `Enum` in the current scope</tspan> </tspan> - <tspan x="10px" y="4870px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `tuple` found for enum `Enum` in the current scope</tspan> + <tspan x="10px" y="4870px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:38:11</tspan> </tspan> - <tspan x="10px" y="4888px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:38:11</tspan> + <tspan x="10px" y="4888px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="4906px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="4906px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="4924px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="4924px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `tuple` not found for this enum</tspan> </tspan> - <tspan x="10px" y="4942px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `tuple` not found for this enum</tspan> + <tspan x="10px" y="4942px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="4960px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="4960px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::tuple();</tspan> </tspan> - <tspan x="10px" y="4978px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::tuple();</tspan> + <tspan x="10px" y="4978px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> </tspan> - <tspan x="10px" y="4996px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> + <tspan x="10px" y="4996px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="5014px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="5014px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="5032px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="5032px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="5050px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="5050px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">tuple</tspan><tspan>();</tspan> </tspan> - <tspan x="10px" y="5068px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">tuple()</tspan><tspan>;</tspan> + <tspan x="10px" y="5068px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Tuple</tspan><tspan>(</tspan><tspan class="fg-ansi256-010">/* i32 */</tspan><tspan>);</tspan> </tspan> - <tspan x="10px" y="5086px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Tuple(/* i32 */)</tspan><tspan>;</tspan> + <tspan x="10px" y="5086px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="5104px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="5104px"> </tspan> - <tspan x="10px" y="5122px"> + <tspan x="10px" y="5122px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `r#struct` found for enum `Enum` in the current scope</tspan> </tspan> - <tspan x="10px" y="5140px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `r#struct` found for enum `Enum` in the current scope</tspan> + <tspan x="10px" y="5140px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:39:11</tspan> </tspan> - <tspan x="10px" y="5158px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:39:11</tspan> + <tspan x="10px" y="5158px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="5176px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="5176px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="5194px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="5194px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `r#struct` not found for this enum</tspan> </tspan> - <tspan x="10px" y="5212px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `r#struct` not found for this enum</tspan> + <tspan x="10px" y="5212px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="5230px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="5230px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::r#struct();</tspan> </tspan> - <tspan x="10px" y="5248px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::r#struct();</tspan> + <tspan x="10px" y="5248px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> </tspan> - <tspan x="10px" y="5266px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> + <tspan x="10px" y="5266px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="5284px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="5284px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="5302px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="5302px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="5320px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="5320px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">r#struct()</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="5338px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">r#struct()</tspan><tspan>;</tspan> + <tspan x="10px" y="5338px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Struct { x: /* value */ }</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="5356px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Struct { x: /* value */ }</tspan><tspan>;</tspan> + <tspan x="10px" y="5356px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="5374px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="5374px"> </tspan> - <tspan x="10px" y="5392px"> + <tspan x="10px" y="5392px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant named `unit` found for enum `Enum`</tspan> </tspan> - <tspan x="10px" y="5410px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant named `unit` found for enum `Enum`</tspan> + <tspan x="10px" y="5410px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:40:11</tspan> </tspan> - <tspan x="10px" y="5428px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:40:11</tspan> + <tspan x="10px" y="5428px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="5446px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="5446px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="5464px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="5464px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant `unit` not found here</tspan> </tspan> - <tspan x="10px" y="5482px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant `unit` not found here</tspan> + <tspan x="10px" y="5482px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="5500px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="5500px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::unit {};</tspan> </tspan> - <tspan x="10px" y="5518px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::unit {};</tspan> + <tspan x="10px" y="5518px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^</tspan> </tspan> - <tspan x="10px" y="5536px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^</tspan> + <tspan x="10px" y="5536px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="5554px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="5554px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="5572px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="5572px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="5590px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="5590px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">unit {}</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="5608px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">unit {}</tspan><tspan>;</tspan> + <tspan x="10px" y="5608px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Unit</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="5626px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Unit</tspan><tspan>;</tspan> + <tspan x="10px" y="5626px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="5644px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="5644px"> </tspan> - <tspan x="10px" y="5662px"> + <tspan x="10px" y="5662px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant named `tuple` found for enum `Enum`</tspan> </tspan> - <tspan x="10px" y="5680px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant named `tuple` found for enum `Enum`</tspan> + <tspan x="10px" y="5680px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:41:11</tspan> </tspan> - <tspan x="10px" y="5698px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:41:11</tspan> + <tspan x="10px" y="5698px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="5716px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="5716px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="5734px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="5734px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant `tuple` not found here</tspan> </tspan> - <tspan x="10px" y="5752px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant `tuple` not found here</tspan> + <tspan x="10px" y="5752px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="5770px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="5770px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::tuple {};</tspan> </tspan> - <tspan x="10px" y="5788px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::tuple {};</tspan> + <tspan x="10px" y="5788px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^</tspan> </tspan> - <tspan x="10px" y="5806px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^</tspan> + <tspan x="10px" y="5806px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="5824px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="5824px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="5842px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="5842px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="5860px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="5860px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">tuple {}</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="5878px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">tuple {}</tspan><tspan>;</tspan> + <tspan x="10px" y="5878px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Tuple(/* i32 */)</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="5896px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Tuple(/* i32 */)</tspan><tspan>;</tspan> + <tspan x="10px" y="5896px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="5914px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="5914px"> </tspan> - <tspan x="10px" y="5932px"> + <tspan x="10px" y="5932px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant named `r#struct` found for enum `Enum`</tspan> </tspan> - <tspan x="10px" y="5950px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant named `r#struct` found for enum `Enum`</tspan> + <tspan x="10px" y="5950px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:42:11</tspan> </tspan> - <tspan x="10px" y="5968px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:42:11</tspan> + <tspan x="10px" y="5968px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="5986px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="5986px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="6004px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="6004px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant `r#struct` not found here</tspan> </tspan> - <tspan x="10px" y="6022px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant `r#struct` not found here</tspan> + <tspan x="10px" y="6022px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="6040px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="6040px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::r#struct {};</tspan> </tspan> - <tspan x="10px" y="6058px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::r#struct {};</tspan> + <tspan x="10px" y="6058px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^</tspan> </tspan> - <tspan x="10px" y="6076px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^</tspan> + <tspan x="10px" y="6076px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="6094px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="6094px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="6112px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="6112px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="6130px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="6130px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">r#struct {}</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="6148px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">r#struct {}</tspan><tspan>;</tspan> + <tspan x="10px" y="6148px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Struct { x: /* value */ }</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="6166px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Struct { x: /* value */ }</tspan><tspan>;</tspan> + <tspan x="10px" y="6166px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="6184px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="6184px"> </tspan> - <tspan x="10px" y="6202px"> + <tspan x="10px" y="6202px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `unit` found for enum `Enum` in the current scope</tspan> </tspan> - <tspan x="10px" y="6220px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `unit` found for enum `Enum` in the current scope</tspan> + <tspan x="10px" y="6220px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:43:11</tspan> </tspan> - <tspan x="10px" y="6238px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:43:11</tspan> + <tspan x="10px" y="6238px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="6256px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="6256px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="6274px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="6274px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `unit` not found for this enum</tspan> </tspan> - <tspan x="10px" y="6292px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `unit` not found for this enum</tspan> + <tspan x="10px" y="6292px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="6310px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="6310px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::unit(0);</tspan> </tspan> - <tspan x="10px" y="6328px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::unit(0);</tspan> + <tspan x="10px" y="6328px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> </tspan> - <tspan x="10px" y="6346px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> + <tspan x="10px" y="6346px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="6364px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="6364px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="6382px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="6382px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="6400px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="6400px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">unit(0)</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="6418px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">unit(0)</tspan><tspan>;</tspan> + <tspan x="10px" y="6418px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Unit</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="6436px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Unit</tspan><tspan>;</tspan> + <tspan x="10px" y="6436px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="6454px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="6454px"> </tspan> - <tspan x="10px" y="6472px"> + <tspan x="10px" y="6472px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `tuple` found for enum `Enum` in the current scope</tspan> </tspan> - <tspan x="10px" y="6490px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `tuple` found for enum `Enum` in the current scope</tspan> + <tspan x="10px" y="6490px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:44:11</tspan> </tspan> - <tspan x="10px" y="6508px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:44:11</tspan> + <tspan x="10px" y="6508px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="6526px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="6526px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="6544px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="6544px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `tuple` not found for this enum</tspan> </tspan> - <tspan x="10px" y="6562px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `tuple` not found for this enum</tspan> + <tspan x="10px" y="6562px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="6580px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="6580px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::tuple(0);</tspan> </tspan> - <tspan x="10px" y="6598px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::tuple(0);</tspan> + <tspan x="10px" y="6598px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> </tspan> - <tspan x="10px" y="6616px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> + <tspan x="10px" y="6616px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="6634px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="6634px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="6652px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="6652px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="6670px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="6670px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">tuple</tspan><tspan>(0);</tspan> </tspan> - <tspan x="10px" y="6688px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">tuple</tspan><tspan>(0);</tspan> + <tspan x="10px" y="6688px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Tuple</tspan><tspan>(0);</tspan> </tspan> - <tspan x="10px" y="6706px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Tuple</tspan><tspan>(0);</tspan> + <tspan x="10px" y="6706px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="6724px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="6724px"> </tspan> - <tspan x="10px" y="6742px"> + <tspan x="10px" y="6742px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `r#struct` found for enum `Enum` in the current scope</tspan> </tspan> - <tspan x="10px" y="6760px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `r#struct` found for enum `Enum` in the current scope</tspan> + <tspan x="10px" y="6760px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:45:11</tspan> </tspan> - <tspan x="10px" y="6778px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:45:11</tspan> + <tspan x="10px" y="6778px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="6796px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="6796px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="6814px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="6814px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `r#struct` not found for this enum</tspan> </tspan> - <tspan x="10px" y="6832px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `r#struct` not found for this enum</tspan> + <tspan x="10px" y="6832px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="6850px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="6850px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::r#struct(0);</tspan> </tspan> - <tspan x="10px" y="6868px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::r#struct(0);</tspan> + <tspan x="10px" y="6868px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> </tspan> - <tspan x="10px" y="6886px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> + <tspan x="10px" y="6886px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="6904px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="6904px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="6922px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="6922px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="6940px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="6940px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">r#struct(0)</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="6958px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">r#struct(0)</tspan><tspan>;</tspan> + <tspan x="10px" y="6958px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Struct { x: /* value */ }</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="6976px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Struct { x: /* value */ }</tspan><tspan>;</tspan> + <tspan x="10px" y="6976px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="6994px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="6994px"> </tspan> - <tspan x="10px" y="7012px"> + <tspan x="10px" y="7012px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant named `unit` found for enum `Enum`</tspan> </tspan> - <tspan x="10px" y="7030px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant named `unit` found for enum `Enum`</tspan> + <tspan x="10px" y="7030px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:46:11</tspan> </tspan> - <tspan x="10px" y="7048px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:46:11</tspan> + <tspan x="10px" y="7048px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="7066px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="7066px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="7084px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="7084px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant `unit` not found here</tspan> </tspan> - <tspan x="10px" y="7102px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant `unit` not found here</tspan> + <tspan x="10px" y="7102px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="7120px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="7120px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::unit { x: 0 };</tspan> </tspan> - <tspan x="10px" y="7138px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::unit { x: 0 };</tspan> + <tspan x="10px" y="7138px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^</tspan> </tspan> - <tspan x="10px" y="7156px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^</tspan> + <tspan x="10px" y="7156px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="7174px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="7174px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="7192px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="7192px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="7210px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="7210px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">unit { x: 0 }</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="7228px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">unit { x: 0 }</tspan><tspan>;</tspan> + <tspan x="10px" y="7228px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Unit</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="7246px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Unit</tspan><tspan>;</tspan> + <tspan x="10px" y="7246px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="7264px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="7264px"> </tspan> - <tspan x="10px" y="7282px"> + <tspan x="10px" y="7282px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant named `tuple` found for enum `Enum`</tspan> </tspan> - <tspan x="10px" y="7300px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant named `tuple` found for enum `Enum`</tspan> + <tspan x="10px" y="7300px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:47:11</tspan> </tspan> - <tspan x="10px" y="7318px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:47:11</tspan> + <tspan x="10px" y="7318px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="7336px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="7336px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="7354px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="7354px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant `tuple` not found here</tspan> </tspan> - <tspan x="10px" y="7372px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant `tuple` not found here</tspan> + <tspan x="10px" y="7372px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="7390px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="7390px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::tuple { x: 0 };</tspan> </tspan> - <tspan x="10px" y="7408px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::tuple { x: 0 };</tspan> + <tspan x="10px" y="7408px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^</tspan> </tspan> - <tspan x="10px" y="7426px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^</tspan> + <tspan x="10px" y="7426px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="7444px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="7444px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="7462px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="7462px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="7480px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="7480px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">tuple { x: 0 }</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="7498px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">tuple { x: 0 }</tspan><tspan>;</tspan> + <tspan x="10px" y="7498px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Tuple(/* i32 */)</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="7516px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Tuple(/* i32 */)</tspan><tspan>;</tspan> + <tspan x="10px" y="7516px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="7534px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="7534px"> </tspan> - <tspan x="10px" y="7552px"> + <tspan x="10px" y="7552px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant named `r#struct` found for enum `Enum`</tspan> </tspan> - <tspan x="10px" y="7570px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant named `r#struct` found for enum `Enum`</tspan> + <tspan x="10px" y="7570px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:48:11</tspan> </tspan> - <tspan x="10px" y="7588px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:48:11</tspan> + <tspan x="10px" y="7588px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="7606px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="7606px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="7624px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="7624px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant `r#struct` not found here</tspan> </tspan> - <tspan x="10px" y="7642px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant `r#struct` not found here</tspan> + <tspan x="10px" y="7642px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="7660px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="7660px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::r#struct { x: 0 };</tspan> </tspan> - <tspan x="10px" y="7678px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::r#struct { x: 0 };</tspan> + <tspan x="10px" y="7678px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^</tspan> </tspan> - <tspan x="10px" y="7696px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^</tspan> + <tspan x="10px" y="7696px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="7714px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="7714px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="7732px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="7732px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="7750px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="7750px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">r#struct { x: 0 }</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="7768px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">r#struct { x: 0 }</tspan><tspan>;</tspan> + <tspan x="10px" y="7768px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Struct { x: /* value */ }</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="7786px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Struct { x: /* value */ }</tspan><tspan>;</tspan> + <tspan x="10px" y="7786px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="7804px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="7804px"> </tspan> - <tspan x="10px" y="7822px"> + <tspan x="10px" y="7822px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `unit` found for enum `Enum` in the current scope</tspan> </tspan> - <tspan x="10px" y="7840px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `unit` found for enum `Enum` in the current scope</tspan> + <tspan x="10px" y="7840px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:49:11</tspan> </tspan> - <tspan x="10px" y="7858px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:49:11</tspan> + <tspan x="10px" y="7858px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="7876px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="7876px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="7894px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="7894px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `unit` not found for this enum</tspan> </tspan> - <tspan x="10px" y="7912px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `unit` not found for this enum</tspan> + <tspan x="10px" y="7912px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="7930px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="7930px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::unit(0, 0);</tspan> </tspan> - <tspan x="10px" y="7948px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::unit(0, 0);</tspan> + <tspan x="10px" y="7948px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> </tspan> - <tspan x="10px" y="7966px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> + <tspan x="10px" y="7966px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="7984px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="7984px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="8002px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="8002px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="8020px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="8020px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">unit(0, 0)</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="8038px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">unit(0, 0)</tspan><tspan>;</tspan> + <tspan x="10px" y="8038px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Unit</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="8056px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Unit</tspan><tspan>;</tspan> + <tspan x="10px" y="8056px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="8074px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="8074px"> </tspan> - <tspan x="10px" y="8092px"> + <tspan x="10px" y="8092px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `tuple` found for enum `Enum` in the current scope</tspan> </tspan> - <tspan x="10px" y="8110px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `tuple` found for enum `Enum` in the current scope</tspan> + <tspan x="10px" y="8110px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:50:11</tspan> </tspan> - <tspan x="10px" y="8128px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:50:11</tspan> + <tspan x="10px" y="8128px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="8146px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="8146px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="8164px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="8164px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `tuple` not found for this enum</tspan> </tspan> - <tspan x="10px" y="8182px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `tuple` not found for this enum</tspan> + <tspan x="10px" y="8182px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="8200px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="8200px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::tuple(0, 0);</tspan> </tspan> - <tspan x="10px" y="8218px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::tuple(0, 0);</tspan> + <tspan x="10px" y="8218px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> </tspan> - <tspan x="10px" y="8236px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> + <tspan x="10px" y="8236px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="8254px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="8254px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="8272px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="8272px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="8290px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="8290px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">tuple</tspan><tspan>(</tspan><tspan class="fg-ansi256-009">0, 0</tspan><tspan>);</tspan> </tspan> - <tspan x="10px" y="8308px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">tuple</tspan><tspan>(</tspan><tspan class="fg-ansi256-009">0, 0</tspan><tspan>);</tspan> + <tspan x="10px" y="8308px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Tuple</tspan><tspan>(</tspan><tspan class="fg-ansi256-010">/* i32 */</tspan><tspan>);</tspan> </tspan> - <tspan x="10px" y="8326px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Tuple</tspan><tspan>(</tspan><tspan class="fg-ansi256-010">/* i32 */</tspan><tspan>);</tspan> + <tspan x="10px" y="8326px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="8344px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="8344px"> </tspan> - <tspan x="10px" y="8362px"> + <tspan x="10px" y="8362px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `r#struct` found for enum `Enum` in the current scope</tspan> </tspan> - <tspan x="10px" y="8380px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant or associated item named `r#struct` found for enum `Enum` in the current scope</tspan> + <tspan x="10px" y="8380px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:51:11</tspan> </tspan> - <tspan x="10px" y="8398px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:51:11</tspan> + <tspan x="10px" y="8398px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="8416px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="8416px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="8434px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="8434px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `r#struct` not found for this enum</tspan> </tspan> - <tspan x="10px" y="8452px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant or associated item `r#struct` not found for this enum</tspan> + <tspan x="10px" y="8452px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="8470px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="8470px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::r#struct(0, 0);</tspan> </tspan> - <tspan x="10px" y="8488px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::r#struct(0, 0);</tspan> + <tspan x="10px" y="8488px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> </tspan> - <tspan x="10px" y="8506px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">variant or associated item not found in `Enum`</tspan> + <tspan x="10px" y="8506px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="8524px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="8524px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="8542px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="8542px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="8560px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="8560px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">r#struct(0, 0)</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="8578px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">r#struct(0, 0)</tspan><tspan>;</tspan> + <tspan x="10px" y="8578px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Struct { x: /* value */ }</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="8596px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Struct { x: /* value */ }</tspan><tspan>;</tspan> + <tspan x="10px" y="8596px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="8614px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="8614px"> </tspan> - <tspan x="10px" y="8632px"> + <tspan x="10px" y="8632px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant named `unit` found for enum `Enum`</tspan> </tspan> - <tspan x="10px" y="8650px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant named `unit` found for enum `Enum`</tspan> + <tspan x="10px" y="8650px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:52:11</tspan> </tspan> - <tspan x="10px" y="8668px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:52:11</tspan> + <tspan x="10px" y="8668px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="8686px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="8686px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="8704px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="8704px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant `unit` not found here</tspan> </tspan> - <tspan x="10px" y="8722px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant `unit` not found here</tspan> + <tspan x="10px" y="8722px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="8740px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="8740px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::unit { x: 0, y: 0 };</tspan> </tspan> - <tspan x="10px" y="8758px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::unit { x: 0, y: 0 };</tspan> + <tspan x="10px" y="8758px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^</tspan> </tspan> - <tspan x="10px" y="8776px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^</tspan> + <tspan x="10px" y="8776px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="8794px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="8794px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="8812px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="8812px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="8830px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="8830px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">unit { x: 0, y: 0 }</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="8848px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">unit { x: 0, y: 0 }</tspan><tspan>;</tspan> + <tspan x="10px" y="8848px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Unit</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="8866px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Unit</tspan><tspan>;</tspan> + <tspan x="10px" y="8866px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="8884px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="8884px"> </tspan> - <tspan x="10px" y="8902px"> + <tspan x="10px" y="8902px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant named `tuple` found for enum `Enum`</tspan> </tspan> - <tspan x="10px" y="8920px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant named `tuple` found for enum `Enum`</tspan> + <tspan x="10px" y="8920px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:53:11</tspan> </tspan> - <tspan x="10px" y="8938px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:53:11</tspan> + <tspan x="10px" y="8938px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="8956px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="8956px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="8974px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="8974px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant `tuple` not found here</tspan> </tspan> - <tspan x="10px" y="8992px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant `tuple` not found here</tspan> + <tspan x="10px" y="8992px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="9010px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="9010px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::tuple { x: 0, y: 0 };</tspan> </tspan> - <tspan x="10px" y="9028px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::tuple { x: 0, y: 0 };</tspan> + <tspan x="10px" y="9028px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^</tspan> </tspan> - <tspan x="10px" y="9046px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^</tspan> + <tspan x="10px" y="9046px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="9064px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="9064px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="9082px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="9082px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="9100px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="9100px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">tuple { x: 0, y: 0 }</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="9118px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">tuple { x: 0, y: 0 }</tspan><tspan>;</tspan> + <tspan x="10px" y="9118px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Tuple(/* i32 */)</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="9136px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Tuple(/* i32 */)</tspan><tspan>;</tspan> + <tspan x="10px" y="9136px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="9154px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="9154px"> </tspan> - <tspan x="10px" y="9172px"> + <tspan x="10px" y="9172px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant named `r#struct` found for enum `Enum`</tspan> </tspan> - <tspan x="10px" y="9190px"><tspan class="fg-ansi256-009 bold">error[E0599]</tspan><tspan class="bold">: no variant named `r#struct` found for enum `Enum`</tspan> + <tspan x="10px" y="9190px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:54:11</tspan> </tspan> - <tspan x="10px" y="9208px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">--> </tspan><tspan>$DIR/incorrect-variant-literal.rs:54:11</tspan> + <tspan x="10px" y="9208px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="9226px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="9226px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> </tspan> - <tspan x="10px" y="9244px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> enum Enum {</tspan> + <tspan x="10px" y="9244px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant `r#struct` not found here</tspan> </tspan> - <tspan x="10px" y="9262px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">---------</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">variant `r#struct` not found here</tspan> + <tspan x="10px" y="9262px"><tspan class="fg-ansi256-012 bold">...</tspan> </tspan> - <tspan x="10px" y="9280px"><tspan class="fg-ansi256-012 bold">...</tspan> + <tspan x="10px" y="9280px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::r#struct { x: 0, y: 0 };</tspan> </tspan> - <tspan x="10px" y="9298px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> Enum::r#struct { x: 0, y: 0 };</tspan> + <tspan x="10px" y="9298px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^</tspan> </tspan> - <tspan x="10px" y="9316px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan><tspan> </tspan><tspan class="fg-ansi256-009 bold">^^^^^^^^</tspan> + <tspan x="10px" y="9316px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="9334px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="9334px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> </tspan> - <tspan x="10px" y="9352px"><tspan class="fg-ansi256-014 bold">help</tspan><tspan>: there is a variant with a similar name</tspan> + <tspan x="10px" y="9352px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="9370px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="9370px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">r#struct { x: 0, y: 0 }</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="9388px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-009">- </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-009">r#struct { x: 0, y: 0 }</tspan><tspan>;</tspan> + <tspan x="10px" y="9388px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Struct { x: /* value */ }</tspan><tspan>;</tspan> </tspan> - <tspan x="10px" y="9406px"><tspan class="fg-ansi256-012 bold">LL</tspan><tspan> </tspan><tspan class="fg-ansi256-010">+ </tspan><tspan> Enum::</tspan><tspan class="fg-ansi256-010">Struct { x: /* value */ }</tspan><tspan>;</tspan> + <tspan x="10px" y="9406px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> </tspan> - <tspan x="10px" y="9424px"><tspan> </tspan><tspan class="fg-ansi256-012 bold">|</tspan> + <tspan x="10px" y="9424px"> </tspan> - <tspan x="10px" y="9442px"> + <tspan x="10px" y="9442px"><tspan class="fg-ansi256-009 bold">error</tspan><tspan class="bold">: aborting due to 39 previous errors</tspan> </tspan> - <tspan x="10px" y="9460px"><tspan class="fg-ansi256-009 bold">error</tspan><tspan class="bold">: aborting due to 39 previous errors</tspan> + <tspan x="10px" y="9460px"> </tspan> - <tspan x="10px" y="9478px"> + <tspan x="10px" y="9478px"><tspan class="bold">Some errors have detailed explanations: E0061, E0063, E0533, E0559, E0599, E0618.</tspan> </tspan> - <tspan x="10px" y="9496px"><tspan class="bold">Some errors have detailed explanations: E0061, E0063, E0533, E0559, E0599, E0618.</tspan> + <tspan x="10px" y="9496px"><tspan class="bold">For more information about an error, try `rustc --explain E0061`.</tspan> </tspan> - <tspan x="10px" y="9514px"><tspan class="bold">For more information about an error, try `rustc --explain E0061`.</tspan> -</tspan> - <tspan x="10px" y="9532px"> + <tspan x="10px" y="9514px"> </tspan> </text> diff --git a/tests/ui/suggestions/return-bindings.stderr b/tests/ui/suggestions/return-bindings.stderr index 6f906c27ba9..8e396d17dc0 100644 --- a/tests/ui/suggestions/return-bindings.stderr +++ b/tests/ui/suggestions/return-bindings.stderr @@ -22,8 +22,8 @@ LL | | } else { | help: consider returning the local binding `s` | -LL ~ let s: String = if let Some(s) = opt_str { -LL + s +LL | let s: String = if let Some(s) = opt_str { +LL ~ s LL ~ | @@ -54,8 +54,8 @@ LL | | } else { | help: consider returning the local binding `s` | -LL ~ let s: String = if let Some(s) = opt_str { -LL + s +LL | let s: String = if let Some(s) = opt_str { +LL ~ s LL ~ | @@ -71,8 +71,8 @@ LL | String::new() | help: consider returning the local binding `s` | -LL ~ let s = if let Some(s) = opt_str { -LL + s +LL | let s = if let Some(s) = opt_str { +LL ~ s LL ~ } else { | diff --git a/tests/ui/suggestions/suggest-deref-in-match-issue-132784.stderr b/tests/ui/suggestions/suggest-deref-in-match-issue-132784.stderr index 2061b3f122a..6092272aa8c 100644 --- a/tests/ui/suggestions/suggest-deref-in-match-issue-132784.stderr +++ b/tests/ui/suggestions/suggest-deref-in-match-issue-132784.stderr @@ -43,9 +43,8 @@ LL | Some(_) => {} found enum `Option<_>` help: consider dereferencing to access the inner value using the Deref trait | -LL - match &x { -LL + match &*x { - | +LL | match &*x { + | + error[E0308]: mismatched types --> $DIR/suggest-deref-in-match-issue-132784.rs:18:9 @@ -60,9 +59,8 @@ LL | None => {} found enum `Option<_>` help: consider dereferencing to access the inner value using the Deref trait | -LL - match &x { -LL + match &*x { - | +LL | match &*x { + | + error[E0308]: mismatched types --> $DIR/suggest-deref-in-match-issue-132784.rs:26:9 diff --git a/tests/ui/suggestions/suggest-field-through-deref.stderr b/tests/ui/suggestions/suggest-field-through-deref.stderr index e3889781884..a742745f6a5 100644 --- a/tests/ui/suggestions/suggest-field-through-deref.stderr +++ b/tests/ui/suggestions/suggest-field-through-deref.stderr @@ -6,9 +6,8 @@ LL | let _ = x.longname; | help: a field with a similar name exists | -LL - let _ = x.longname; -LL + let _ = x.long_name; - | +LL | let _ = x.long_name; + | + error[E0609]: no field `longname` on type `S` --> $DIR/suggest-field-through-deref.rs:12:15 @@ -18,9 +17,8 @@ LL | let _ = y.longname; | help: a field with a similar name exists | -LL - let _ = y.longname; -LL + let _ = y.long_name; - | +LL | let _ = y.long_name; + | + error[E0609]: no field `longname` on type `Option<Arc<S>>` --> $DIR/suggest-field-through-deref.rs:14:15 diff --git a/tests/ui/suggestions/suggest-let-for-assignment.stderr b/tests/ui/suggestions/suggest-let-for-assignment.stderr index 9dc859dbe0e..eb4bfc9a783 100644 --- a/tests/ui/suggestions/suggest-let-for-assignment.stderr +++ b/tests/ui/suggestions/suggest-let-for-assignment.stderr @@ -58,9 +58,8 @@ LL | letother_variable = 6; | help: you might have meant to introduce a new binding | -LL - letother_variable = 6; -LL + let other_variable = 6; - | +LL | let other_variable = 6; + | + error[E0425]: cannot find value `other_variable` in this scope --> $DIR/suggest-let-for-assignment.rs:14:36 diff --git a/tests/ui/suggestions/suggest-trait-in-ufcs-in-hrtb.stderr b/tests/ui/suggestions/suggest-trait-in-ufcs-in-hrtb.stderr index fac93da9829..aa6f8cebe2a 100644 --- a/tests/ui/suggestions/suggest-trait-in-ufcs-in-hrtb.stderr +++ b/tests/ui/suggestions/suggest-trait-in-ufcs-in-hrtb.stderr @@ -6,12 +6,10 @@ LL | impl<S> Foo for Bar<S> where for<'a> <&'a S>::Item: Foo {} | help: use fully-qualified syntax | -LL - impl<S> Foo for Bar<S> where for<'a> <&'a S>::Item: Foo {} -LL + impl<S> Foo for Bar<S> where for<'a> <&'a S as IntoAsyncIterator>::Item: Foo {} - | -LL - impl<S> Foo for Bar<S> where for<'a> <&'a S>::Item: Foo {} -LL + impl<S> Foo for Bar<S> where for<'a> <&'a S as IntoIterator>::Item: Foo {} - | +LL | impl<S> Foo for Bar<S> where for<'a> <&'a S as IntoAsyncIterator>::Item: Foo {} + | ++++++++++++++++++++ +LL | impl<S> Foo for Bar<S> where for<'a> <&'a S as IntoIterator>::Item: Foo {} + | +++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/test-attrs/inaccessible-test-modules.stderr b/tests/ui/test-attrs/inaccessible-test-modules.stderr index dfb6985730a..c66dc0d0fc2 100644 --- a/tests/ui/test-attrs/inaccessible-test-modules.stderr +++ b/tests/ui/test-attrs/inaccessible-test-modules.stderr @@ -13,7 +13,7 @@ LL | use test as y; help: consider importing this module instead | LL | use test::test as y; - | ++++++ + | ++++++ error: aborting due to 2 previous errors diff --git a/tests/crashes/126944.rs b/tests/ui/traits/object/crash-due-to-projections-modulo-norm.rs index c0c5622e260..b1f7c4a6000 100644 --- a/tests/crashes/126944.rs +++ b/tests/ui/traits/object/crash-due-to-projections-modulo-norm.rs @@ -1,9 +1,12 @@ -//@ known-bug: rust-lang/rust#126944 +//@ check-pass + +// Regression test for #126944. + // Step 1: Create two names for a single type: `Thing` and `AlsoThing` struct Thing; struct Dummy; -pub trait DummyTrait { +trait DummyTrait { type DummyType; } impl DummyTrait for Dummy { @@ -13,7 +16,7 @@ type AlsoThing = <Dummy as DummyTrait>::DummyType; // Step 2: Create names for a single trait object type: `TraitObject` and `AlsoTraitObject` -pub trait SomeTrait { +trait SomeTrait { type Item; } type TraitObject = dyn SomeTrait<Item = AlsoThing>; @@ -21,12 +24,12 @@ type AlsoTraitObject = dyn SomeTrait<Item = Thing>; // Step 3: Force the compiler to check whether the two names are the same type -pub trait Supertrait { +trait Supertrait { type Foo; } -pub trait Subtrait: Supertrait<Foo = TraitObject> {} +trait Subtrait: Supertrait<Foo = TraitObject> {} -pub trait HasOutput<A: ?Sized> { +trait HasOutput<A: ?Sized> { type Output; } @@ -36,3 +39,5 @@ where { todo!() } + +fn main() {} diff --git a/tests/ui/traits/object/incomplete-multiple-super-projection.rs b/tests/ui/traits/object/incomplete-multiple-super-projection.rs new file mode 100644 index 00000000000..c7294eca4bd --- /dev/null +++ b/tests/ui/traits/object/incomplete-multiple-super-projection.rs @@ -0,0 +1,32 @@ +// Regression test for #133361. + +trait Sup<T> { + type Assoc; +} + +impl<T> Sup<T> for () { + type Assoc = T; +} +impl<T, U> Dyn<T, U> for () {} + +trait Dyn<A, B>: Sup<A, Assoc = A> + Sup<B, Assoc = B> {} + +trait Trait { + type Assoc; +} +impl Trait for dyn Dyn<(), ()> { + type Assoc = &'static str; +} +impl<A, B> Trait for dyn Dyn<A, B> { +//~^ ERROR conflicting implementations of trait `Trait` for type `(dyn Dyn<(), ()> + 'static)` + type Assoc = usize; +} + +fn call<A, B>(x: usize) -> <dyn Dyn<A, B> as Trait>::Assoc { + x +} + +fn main() { + let x: &'static str = call::<(), ()>(0xDEADBEEF); + println!("{x}"); +} diff --git a/tests/ui/traits/object/incomplete-multiple-super-projection.stderr b/tests/ui/traits/object/incomplete-multiple-super-projection.stderr new file mode 100644 index 00000000000..b4271f70ed0 --- /dev/null +++ b/tests/ui/traits/object/incomplete-multiple-super-projection.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `Trait` for type `(dyn Dyn<(), ()> + 'static)` + --> $DIR/incomplete-multiple-super-projection.rs:20:1 + | +LL | impl Trait for dyn Dyn<(), ()> { + | ------------------------------ first implementation here +... +LL | impl<A, B> Trait for dyn Dyn<A, B> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(dyn Dyn<(), ()> + 'static)` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/crashes/79590.rs b/tests/ui/traits/object/infer-shadows-implied-projection.rs index b73864cce23..628912c54fa 100644 --- a/tests/crashes/79590.rs +++ b/tests/ui/traits/object/infer-shadows-implied-projection.rs @@ -1,4 +1,4 @@ -//@ known-bug: #79590 +//@ check-pass trait Database: Restriction<Inner = u32> {} diff --git a/tests/ui/traits/object/outlives-super-proj.rs b/tests/ui/traits/object/outlives-super-proj.rs new file mode 100644 index 00000000000..15b67d9ab68 --- /dev/null +++ b/tests/ui/traits/object/outlives-super-proj.rs @@ -0,0 +1,24 @@ +//@ check-pass + +// Make sure that we still deduce outlives bounds from supertrait projections +// and require them for well-formedness. + +trait Trait { + type Assoc; +} + +trait Bar { + type Assoc; +} + +trait Foo<'a, T: 'a>: Bar<Assoc = &'a T> { + +} + +fn outlives<'a, T: 'a>() {} + +fn implied_outlives<'a, T: Trait>(x: &dyn Foo<'a, T::Assoc>) { + outlives::<'a, T::Assoc>(); +} + +fn main() {} diff --git a/tests/ui/traits/object/pretty.stderr b/tests/ui/traits/object/pretty.stderr index 2f9fdf151f0..37fe142951d 100644 --- a/tests/ui/traits/object/pretty.stderr +++ b/tests/ui/traits/object/pretty.stderr @@ -154,12 +154,12 @@ error[E0308]: mismatched types --> $DIR/pretty.rs:41:56 | LL | fn dyn_has_gat(x: &dyn HasGat<u8, Assoc<bool> = ()>) { x } - | - ^ expected `()`, found `&dyn HasGat<u8, Assoc<bool> = ()>` + | - ^ expected `()`, found `&dyn HasGat<u8>` | | - | help: try adding a return type: `-> &dyn HasGat<u8, Assoc<bool> = ()>` + | help: try adding a return type: `-> &dyn HasGat<u8>` | = note: expected unit type `()` - found reference `&dyn HasGat<u8, Assoc<bool> = ()>` + found reference `&dyn HasGat<u8>` error: aborting due to 14 previous errors; 1 warning emitted diff --git a/tests/ui/traits/object/redundant.rs b/tests/ui/traits/object/redundant.rs new file mode 100644 index 00000000000..be07b157138 --- /dev/null +++ b/tests/ui/traits/object/redundant.rs @@ -0,0 +1,12 @@ +//@ check-pass + +trait Foo: Bar<Out = ()> {} +trait Bar { + type Out; +} + +fn w(x: &dyn Foo<Out = ()>) { + let x: &dyn Foo = x; +} + +fn main() {} diff --git a/tests/ui/try-trait/bad-interconversion.stderr b/tests/ui/try-trait/bad-interconversion.stderr index 45422be946e..6df05747f32 100644 --- a/tests/ui/try-trait/bad-interconversion.stderr +++ b/tests/ui/try-trait/bad-interconversion.stderr @@ -20,9 +20,6 @@ LL | fn option_to_result() -> Result<u64, String> { | -------------------------------------------- this function returns a `Result` LL | Some(3)?; | ^ use `.ok_or(...)?` to provide an error compatible with `Result<u64, String>` - | - = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<u64, String>` - = help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>` error[E0277]: the `?` operator can only be used on `Result`s in a function that returns `Result` --> $DIR/bad-interconversion.rs:15:31 @@ -31,9 +28,6 @@ LL | fn control_flow_to_result() -> Result<u64, String> { | -------------------------------------------------- this function returns a `Result` LL | Ok(ControlFlow::Break(123)?) | ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Result<u64, String>` - | - = help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Result<u64, String>` - = help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>` error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option` --> $DIR/bad-interconversion.rs:20:22 @@ -42,9 +36,6 @@ LL | fn result_to_option() -> Option<u16> { | ------------------------------------ this function returns an `Option` LL | Some(Err("hello")?) | ^ use `.ok()?` if you want to discard the `Result<Infallible, &str>` error information - | - = help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `Option<u16>` - = help: the trait `FromResidual<Option<Infallible>>` is implemented for `Option<T>` error[E0277]: the `?` operator can only be used on `Option`s in a function that returns `Option` --> $DIR/bad-interconversion.rs:25:33 @@ -53,9 +44,6 @@ LL | fn control_flow_to_option() -> Option<u64> { | ------------------------------------------ this function returns an `Option` LL | Some(ControlFlow::Break(123)?) | ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Option<u64>` - | - = help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Option<u64>` - = help: the trait `FromResidual<Option<Infallible>>` is implemented for `Option<T>` error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow` --> $DIR/bad-interconversion.rs:30:39 diff --git a/tests/ui/try-trait/bad-question-mark-on-trait-object.rs b/tests/ui/try-trait/bad-question-mark-on-trait-object.rs new file mode 100644 index 00000000000..2a0d14b1750 --- /dev/null +++ b/tests/ui/try-trait/bad-question-mark-on-trait-object.rs @@ -0,0 +1,29 @@ +struct E; +//~^ NOTE `E` needs to implement `std::error::Error` +//~| NOTE alternatively, `E` needs to implement `Into<X>` +struct X; //~ NOTE `X` needs to implement `From<E>` + +fn foo() -> Result<(), Box<dyn std::error::Error>> { //~ NOTE required `E: std::error::Error` because of this + Ok(bar()?) + //~^ ERROR `?` couldn't convert the error: `E: std::error::Error` is not satisfied + //~| NOTE the trait `std::error::Error` is not implemented for `E` + //~| NOTE the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait + //~| NOTE required for `Box<dyn std::error::Error>` to implement `From<E>` + //~| NOTE this has type `Result<_, E>` + //~| NOTE in this expansion + //~| NOTE in this expansion + //~| NOTE in this expansion +} +fn bat() -> Result<(), X> { //~ NOTE expected `X` because of this + Ok(bar()?) + //~^ ERROR `?` couldn't convert the error to `X` + //~| NOTE the trait `From<E>` is not implemented for `X` + //~| NOTE this can't be annotated with `?` because it has type `Result<_, E>` + //~| NOTE the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait + //~| NOTE in this expansion + //~| NOTE in this expansion +} +fn bar() -> Result<(), E> { + Err(E) +} +fn main() {} diff --git a/tests/ui/try-trait/bad-question-mark-on-trait-object.stderr b/tests/ui/try-trait/bad-question-mark-on-trait-object.stderr new file mode 100644 index 00000000000..dd380850c9e --- /dev/null +++ b/tests/ui/try-trait/bad-question-mark-on-trait-object.stderr @@ -0,0 +1,43 @@ +error[E0277]: `?` couldn't convert the error: `E: std::error::Error` is not satisfied + --> $DIR/bad-question-mark-on-trait-object.rs:7:13 + | +LL | fn foo() -> Result<(), Box<dyn std::error::Error>> { + | -------------------------------------- required `E: std::error::Error` because of this +LL | Ok(bar()?) + | -----^ the trait `std::error::Error` is not implemented for `E` + | | + | this has type `Result<_, E>` + | +note: `E` needs to implement `std::error::Error` + --> $DIR/bad-question-mark-on-trait-object.rs:1:1 + | +LL | struct E; + | ^^^^^^^^ + = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait + = note: required for `Box<dyn std::error::Error>` to implement `From<E>` + +error[E0277]: `?` couldn't convert the error to `X` + --> $DIR/bad-question-mark-on-trait-object.rs:18:13 + | +LL | fn bat() -> Result<(), X> { + | ------------- expected `X` because of this +LL | Ok(bar()?) + | -----^ the trait `From<E>` is not implemented for `X` + | | + | this can't be annotated with `?` because it has type `Result<_, E>` + | +note: `X` needs to implement `From<E>` + --> $DIR/bad-question-mark-on-trait-object.rs:4:1 + | +LL | struct X; + | ^^^^^^^^ +note: alternatively, `E` needs to implement `Into<X>` + --> $DIR/bad-question-mark-on-trait-object.rs:1:1 + | +LL | struct E; + | ^^^^^^^^ + = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/try-trait/option-to-result.stderr b/tests/ui/try-trait/option-to-result.stderr index 1a5a925f92f..8a4c4707942 100644 --- a/tests/ui/try-trait/option-to-result.stderr +++ b/tests/ui/try-trait/option-to-result.stderr @@ -6,9 +6,6 @@ LL | fn test_result() -> Result<(),()> { LL | let a:Option<()> = Some(()); LL | a?; | ^ use `.ok_or(...)?` to provide an error compatible with `Result<(), ()>` - | - = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<(), ()>` - = help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>` error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option` --> $DIR/option-to-result.rs:11:6 @@ -18,9 +15,6 @@ LL | fn test_option() -> Option<i32>{ LL | let a:Result<i32, i32> = Ok(5); LL | a?; | ^ use `.ok()?` if you want to discard the `Result<Infallible, i32>` error information - | - = help: the trait `FromResidual<Result<Infallible, i32>>` is not implemented for `Option<i32>` - = help: the trait `FromResidual<Option<Infallible>>` is implemented for `Option<T>` error: aborting due to 2 previous errors diff --git a/tests/ui/try-trait/try-on-option-diagnostics.stderr b/tests/ui/try-trait/try-on-option-diagnostics.stderr index 9ee540c79fd..08675e242a3 100644 --- a/tests/ui/try-trait/try-on-option-diagnostics.stderr +++ b/tests/ui/try-trait/try-on-option-diagnostics.stderr @@ -6,8 +6,6 @@ LL | fn a_function() -> u32 { LL | let x: Option<u32> = None; LL | x?; | ^ cannot use the `?` operator in a function that returns `u32` - | - = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32` error[E0277]: the `?` operator can only be used in a closure that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-on-option-diagnostics.rs:14:10 @@ -17,8 +15,6 @@ LL | let a_closure = || { LL | let x: Option<u32> = None; LL | x?; | ^ cannot use the `?` operator in a closure that returns `{integer}` - | - = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `{integer}` error[E0277]: the `?` operator can only be used in a method that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-on-option-diagnostics.rs:26:14 @@ -28,8 +24,6 @@ LL | fn a_method() { LL | let x: Option<u32> = None; LL | x?; | ^ cannot use the `?` operator in a method that returns `()` - | - = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `()` error[E0277]: the `?` operator can only be used in a trait method that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-on-option-diagnostics.rs:39:14 @@ -39,8 +33,6 @@ LL | fn a_trait_method() { LL | let x: Option<u32> = None; LL | x?; | ^ cannot use the `?` operator in a trait method that returns `()` - | - = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `()` error: aborting due to 4 previous errors diff --git a/tests/ui/try-trait/try-on-option.stderr b/tests/ui/try-trait/try-on-option.stderr index 15d0b28ddc1..aeb519086d8 100644 --- a/tests/ui/try-trait/try-on-option.stderr +++ b/tests/ui/try-trait/try-on-option.stderr @@ -6,9 +6,6 @@ LL | fn foo() -> Result<u32, ()> { LL | let x: Option<u32> = None; LL | x?; | ^ use `.ok_or(...)?` to provide an error compatible with `Result<u32, ()>` - | - = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<u32, ()>` - = help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>` error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-on-option.rs:11:6 @@ -18,8 +15,6 @@ LL | fn bar() -> u32 { LL | let x: Option<u32> = None; LL | x?; | ^ cannot use the `?` operator in a function that returns `u32` - | - = help: the trait `FromResidual<Option<Infallible>>` is not implemented for `u32` error: aborting due to 2 previous errors diff --git a/tests/ui/try-trait/try-operator-on-main.stderr b/tests/ui/try-trait/try-operator-on-main.stderr index 311e8076ed4..9c2526442ab 100644 --- a/tests/ui/try-trait/try-operator-on-main.stderr +++ b/tests/ui/try-trait/try-operator-on-main.stderr @@ -7,7 +7,6 @@ LL | // error for a `Try` type on a non-`Try` fn LL | std::fs::File::open("foo")?; | ^ cannot use the `?` operator in a function that returns `()` | - = help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()` help: consider adding return type | LL ~ fn main() -> Result<(), Box<dyn std::error::Error>> { @@ -33,8 +32,6 @@ LL | fn main() { ... LL | ()?; | ^ cannot use the `?` operator in a function that returns `()` - | - = help: the trait `FromResidual<_>` is not implemented for `()` error[E0277]: the trait bound `(): Try` is not satisfied --> $DIR/try-operator-on-main.rs:14:25 diff --git a/tests/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.stderr b/tests/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.stderr index c4deafd4f6b..03fd43d43a9 100644 --- a/tests/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.stderr +++ b/tests/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.stderr @@ -11,9 +11,8 @@ LL | V(u8) | ^ help: provide the argument | -LL - <E>::V(); -LL + <E>::V(/* u8 */); - | +LL | <E>::V(/* u8 */); + | ++++++++ error[E0308]: mismatched types --> $DIR/enum-variant-priority-higher-than-other-inherent.rs:22:17 diff --git a/tests/ui/type-alias-impl-trait/bad-tait-no-substs.stderr b/tests/ui/type-alias-impl-trait/bad-tait-no-substs.stderr index 55df117d066..38fbff9d59d 100644 --- a/tests/ui/type-alias-impl-trait/bad-tait-no-substs.stderr +++ b/tests/ui/type-alias-impl-trait/bad-tait-no-substs.stderr @@ -69,7 +69,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match x { LL + UninhabitedVariants::Tuple(_) => todo!(), -LL + } +LL ~ } | error: aborting due to 5 previous errors diff --git a/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.stderr b/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.stderr index 6d9c8eabfad..5c9a4688105 100644 --- a/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.stderr +++ b/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.stderr @@ -9,7 +9,7 @@ help: ensure that all possible cases are being handled by adding a match arm wit | LL ~ match empty_opaque() { LL + _ => todo!(), -LL + } +LL ~ } | error: aborting due to 1 previous error diff --git a/tests/ui/type/pattern_types/range_patterns.stderr b/tests/ui/type/pattern_types/range_patterns.stderr index 7da8cfd4dbc..690592ba0b8 100644 --- a/tests/ui/type/pattern_types/range_patterns.stderr +++ b/tests/ui/type/pattern_types/range_patterns.stderr @@ -31,6 +31,7 @@ error: layout_of(NonZero<u32>) = Layout { valid_range: 1..=4294967295, }, ), + uninhabited: false, variants: Single { index: 0, }, @@ -69,6 +70,7 @@ error: layout_of((u32) is 1..=) = Layout { valid_range: 1..=4294967295, }, ), + uninhabited: false, variants: Single { index: 0, }, @@ -105,6 +107,7 @@ error: layout_of(Option<(u32) is 1..=>) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -134,6 +137,7 @@ error: layout_of(Option<(u32) is 1..=>) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -174,6 +178,7 @@ error: layout_of(Option<(u32) is 1..=>) = Layout { valid_range: 1..=4294967295, }, ), + uninhabited: false, variants: Single { index: 1, }, @@ -216,6 +221,7 @@ error: layout_of(Option<NonZero<u32>>) = Layout { ], }, largest_niche: None, + uninhabited: false, variants: Multiple { tag: Initialized { value: Int( @@ -245,6 +251,7 @@ error: layout_of(Option<NonZero<u32>>) = Layout { memory_index: [], }, largest_niche: None, + uninhabited: false, variants: Single { index: 0, }, @@ -285,6 +292,7 @@ error: layout_of(Option<NonZero<u32>>) = Layout { valid_range: 1..=4294967295, }, ), + uninhabited: false, variants: Single { index: 1, }, @@ -336,6 +344,7 @@ error: layout_of(NonZeroU32New) = Layout { valid_range: 1..=4294967295, }, ), + uninhabited: false, variants: Single { index: 0, }, diff --git a/tests/ui/type/type-check/point-at-inference-4.stderr b/tests/ui/type/type-check/point-at-inference-4.stderr index 52d603c5980..adfb0cebf26 100644 --- a/tests/ui/type/type-check/point-at-inference-4.stderr +++ b/tests/ui/type/type-check/point-at-inference-4.stderr @@ -11,9 +11,8 @@ LL | fn infer(&self, a: A, b: B) {} | ^^^^^ ---- help: provide the argument | -LL - s.infer(0i32); -LL + s.infer(0i32, /* b */); - | +LL | s.infer(0i32, /* b */); + | +++++++++ error[E0308]: mismatched types --> $DIR/point-at-inference-4.rs:18:24 diff --git a/tests/ui/typeck/issue-110052.stderr b/tests/ui/typeck/issue-110052.stderr index 649fc8429b9..832cdf6f710 100644 --- a/tests/ui/typeck/issue-110052.stderr +++ b/tests/ui/typeck/issue-110052.stderr @@ -6,12 +6,10 @@ LL | for<'iter> dyn Validator<<&'iter I>::Item>:, | help: use fully-qualified syntax | -LL - for<'iter> dyn Validator<<&'iter I>::Item>:, -LL + for<'iter> dyn Validator<<&'iter I as IntoAsyncIterator>::Item>:, - | -LL - for<'iter> dyn Validator<<&'iter I>::Item>:, -LL + for<'iter> dyn Validator<<&'iter I as IntoIterator>::Item>:, - | +LL | for<'iter> dyn Validator<<&'iter I as IntoAsyncIterator>::Item>:, + | ++++++++++++++++++++ +LL | for<'iter> dyn Validator<<&'iter I as IntoIterator>::Item>:, + | +++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/typeck/issue-13853-5.stderr b/tests/ui/typeck/issue-13853-5.stderr index 388d5ec746c..4e483a0a58e 100644 --- a/tests/ui/typeck/issue-13853-5.stderr +++ b/tests/ui/typeck/issue-13853-5.stderr @@ -14,8 +14,8 @@ LL | fn deserialize_token<D: Deserializer<'a>>(_x: D, _y: &'a str) -> &'a st | help: consider returning the local binding `_y` | -LL ~ fn deserialize_token<D: Deserializer<'a>>(_x: D, _y: &'a str) -> &'a str { -LL + _y +LL | fn deserialize_token<D: Deserializer<'a>>(_x: D, _y: &'a str) -> &'a str { +LL ~ _y LL ~ | diff --git a/tests/ui/typeck/issue-87872-missing-inaccessible-field-pattern.stderr b/tests/ui/typeck/issue-87872-missing-inaccessible-field-pattern.stderr index ed0e4eb9ece..da9caebb2d6 100644 --- a/tests/ui/typeck/issue-87872-missing-inaccessible-field-pattern.stderr +++ b/tests/ui/typeck/issue-87872-missing-inaccessible-field-pattern.stderr @@ -6,19 +6,16 @@ LL | let foo::Foo {} = foo::Foo::default(); | help: include the missing field in the pattern and ignore the inaccessible fields | -LL - let foo::Foo {} = foo::Foo::default(); -LL + let foo::Foo { visible, .. } = foo::Foo::default(); - | +LL | let foo::Foo { visible, .. } = foo::Foo::default(); + | +++++++++++ help: if you don't care about this missing field, you can explicitly ignore it | -LL - let foo::Foo {} = foo::Foo::default(); -LL + let foo::Foo { visible: _, .. } = foo::Foo::default(); - | +LL | let foo::Foo { visible: _, .. } = foo::Foo::default(); + | ++++++++++++++ help: or always ignore missing fields here | -LL - let foo::Foo {} = foo::Foo::default(); -LL + let foo::Foo { .. } = foo::Foo::default(); - | +LL | let foo::Foo { .. } = foo::Foo::default(); + | ++ error: aborting due to 1 previous error diff --git a/tests/ui/typeck/struct-enum-wrong-args.stderr b/tests/ui/typeck/struct-enum-wrong-args.stderr index d1003fbb6b3..690851ad19a 100644 --- a/tests/ui/typeck/struct-enum-wrong-args.stderr +++ b/tests/ui/typeck/struct-enum-wrong-args.stderr @@ -38,9 +38,8 @@ note: tuple variant defined here --> $SRC_DIR/core/src/result.rs:LL:COL help: provide the argument | -LL - let _ = Ok(); -LL + let _ = Ok(/* value */); - | +LL | let _ = Ok(/* value */); + | +++++++++++ error[E0061]: this struct takes 1 argument but 0 arguments were supplied --> $DIR/struct-enum-wrong-args.rs:9:13 @@ -55,9 +54,8 @@ LL | struct Wrapper(i32); | ^^^^^^^ help: provide the argument | -LL - let _ = Wrapper(); -LL + let _ = Wrapper(/* i32 */); - | +LL | let _ = Wrapper(/* i32 */); + | +++++++++ error[E0061]: this struct takes 1 argument but 2 arguments were supplied --> $DIR/struct-enum-wrong-args.rs:10:13 @@ -89,9 +87,8 @@ LL | struct DoubleWrapper(i32, i32); | ^^^^^^^^^^^^^ help: provide the arguments | -LL - let _ = DoubleWrapper(); -LL + let _ = DoubleWrapper(/* i32 */, /* i32 */); - | +LL | let _ = DoubleWrapper(/* i32 */, /* i32 */); + | ++++++++++++++++++++ error[E0061]: this struct takes 2 arguments but 1 argument was supplied --> $DIR/struct-enum-wrong-args.rs:12:13 @@ -106,9 +103,8 @@ LL | struct DoubleWrapper(i32, i32); | ^^^^^^^^^^^^^ help: provide the argument | -LL - let _ = DoubleWrapper(5); -LL + let _ = DoubleWrapper(5, /* i32 */); - | +LL | let _ = DoubleWrapper(5, /* i32 */); + | +++++++++++ error[E0061]: this struct takes 2 arguments but 3 arguments were supplied --> $DIR/struct-enum-wrong-args.rs:13:13 diff --git a/tests/ui/uninhabited/uninhabited-transparent-return-abi.rs b/tests/ui/uninhabited/uninhabited-transparent-return-abi.rs new file mode 100644 index 00000000000..2c2788a3e56 --- /dev/null +++ b/tests/ui/uninhabited/uninhabited-transparent-return-abi.rs @@ -0,0 +1,33 @@ +//@ run-pass +//@ needs-unwind +// See https://github.com/rust-lang/rust/issues/135802 + +enum Void {} + +// Should be ABI-compatible with T, but wasn't prior to the PR adding this test. +#[repr(transparent)] +struct NoReturn<T>(T, Void); + +// Returned by invisible reference (in most ABIs) +#[allow(dead_code)] +struct Large(u64, u64, u64); + +// Prior to the PR adding this test, this function had a different ABI than +// `fn() -> Large` (on `x86_64-unknown-linux-gnu` at least), so calling it as `fn() -> Large` +// would pass the return place pointer in rdi and `correct` in rsi, but the function +// would expect `correct` in rdi. +fn never(correct: &mut bool) -> NoReturn<Large> { + *correct = true; + panic!("catch this") +} + +fn main() { + let mut correct = false; + let never: fn(&mut bool) -> NoReturn<Large> = never; + // Safety: `NoReturn<Large>` is a `repr(transparent)` wrapper around `Large`, + // so they should be ABI-compatible. + let never: fn(&mut bool) -> Large = unsafe { std::mem::transmute(never) }; + let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| never(&mut correct))); + assert!(result.is_err(), "function should have panicked"); + assert!(correct, "function should have stored `true` into `correct`"); +} |
