diff options
339 files changed, 3195 insertions, 2376 deletions
diff --git a/Cargo.lock b/Cargo.lock index cf5425a5a89..00351c12410 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6332,9 +6332,9 @@ dependencies = [ [[package]] name = "windows-bindgen" -version = "0.55.0" +version = "0.56.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "073ff8a486ebad239d557809d2cd5fe5e04ee1de29e09c6cd83fb0bae19b8a4c" +checksum = "a28e3ea6330cf17fdcdce8bf08d0549ce93769dca9bedc6c39c36c8c0e17db46" dependencies = [ "proc-macro2", "rayon", @@ -6355,9 +6355,9 @@ dependencies = [ [[package]] name = "windows-metadata" -version = "0.55.0" +version = "0.56.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b602635050172a1fc57a35040d4d225baefc6098fefd97094919921d95961a7d" +checksum = "3993f7827fff10c454e3a24847075598c7c08108304b8b07943c2c73d78f3b34" [[package]] name = "windows-sys" diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 519eeeded9a..bddb50568d4 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -568,7 +568,7 @@ impl Pat { // In a type expression `_` is an inference variable. PatKind::Wild => TyKind::Infer, // An IDENT pattern with no binding mode would be valid as path to a type. E.g. `u32`. - PatKind::Ident(BindingAnnotation::NONE, ident, None) => { + PatKind::Ident(BindingMode::NONE, ident, None) => { TyKind::Path(None, Path::from_ident(*ident)) } PatKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()), @@ -675,7 +675,7 @@ impl Pat { pub fn descr(&self) -> Option<String> { match &self.kind { PatKind::Wild => Some("_".to_string()), - PatKind::Ident(BindingAnnotation::NONE, ident, None) => Some(format!("{ident}")), + PatKind::Ident(BindingMode::NONE, ident, None) => Some(format!("{ident}")), PatKind::Ref(pat, mutbl) => pat.descr().map(|d| format!("&{}{d}", mutbl.prefix_str())), _ => None, } @@ -707,14 +707,25 @@ pub enum ByRef { No, } -/// Explicit binding annotations given in the HIR for a binding. Note -/// that this is not the final binding *mode* that we infer after type -/// inference. +impl ByRef { + pub fn cap_ref_mutability(mut self, mutbl: Mutability) -> Self { + if let ByRef::Yes(old_mutbl) = &mut self { + *old_mutbl = cmp::min(*old_mutbl, mutbl); + } + self + } +} + +/// The mode of a binding (`mut`, `ref mut`, etc). +/// Used for both the explicit binding annotations given in the HIR for a binding +/// and the final binding mode that we infer after type inference/match ergonomics. +/// `.0` is the by-reference mode (`ref`, `ref mut`, or by value), +/// `.1` is the mutability of the binding. #[derive(Clone, Copy, Debug, Eq, PartialEq)] #[derive(Encodable, Decodable, HashStable_Generic)] -pub struct BindingAnnotation(pub ByRef, pub Mutability); +pub struct BindingMode(pub ByRef, pub Mutability); -impl BindingAnnotation { +impl BindingMode { pub const NONE: Self = Self(ByRef::No, Mutability::Not); pub const REF: Self = Self(ByRef::Yes(Mutability::Not), Mutability::Not); pub const MUT: Self = Self(ByRef::No, Mutability::Mut); @@ -732,13 +743,6 @@ impl BindingAnnotation { Self::MUT_REF_MUT => "mut ref mut ", } } - - pub fn cap_ref_mutability(mut self, mutbl: Mutability) -> Self { - if let ByRef::Yes(old_mutbl) = &mut self.0 { - *old_mutbl = cmp::min(*old_mutbl, mutbl); - } - self - } } #[derive(Clone, Encodable, Decodable, Debug)] @@ -769,7 +773,7 @@ pub enum PatKind { /// or a unit struct/variant pattern, or a const pattern (in the last two cases the third /// field must be `None`). Disambiguation cannot be done with parser alone, so it happens /// during name resolution. - Ident(BindingAnnotation, Ident, Option<P<Pat>>), + Ident(BindingMode, Ident, Option<P<Pat>>), /// A struct or struct variant pattern (e.g., `Variant {x, y, ..}`). Struct(Option<P<QSelf>>, Path, ThinVec<PatField>, PatFieldsRest), @@ -2382,7 +2386,7 @@ pub type ExplicitSelf = Spanned<SelfKind>; impl Param { /// Attempts to cast parameter to `ExplicitSelf`. pub fn to_self(&self) -> Option<ExplicitSelf> { - if let PatKind::Ident(BindingAnnotation(ByRef::No, mutbl), ident, _) = self.pat.kind { + if let PatKind::Ident(BindingMode(ByRef::No, mutbl), ident, _) = self.pat.kind { if ident.name == kw::SelfLower { return match self.ty.kind { TyKind::ImplicitSelf => Some(respan(self.pat.span, SelfKind::Value(mutbl))), @@ -2434,7 +2438,7 @@ impl Param { attrs, pat: P(Pat { id: DUMMY_NODE_ID, - kind: PatKind::Ident(BindingAnnotation(ByRef::No, mutbl), eself_ident, None), + kind: PatKind::Ident(BindingMode(ByRef::No, mutbl), eself_ident, None), span, tokens: None, }), @@ -3363,7 +3367,7 @@ impl TryFrom<ItemKind> for ForeignItemKind { pub type ForeignItem = Item<ForeignItemKind>; // Some nodes are used a lot. Make sure they don't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] mod size_asserts { use super::*; use rustc_data_structures::static_assert_size; diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 5b41ac8a69e..dcdd44c6041 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -1023,7 +1023,7 @@ where } // Some types are used a lot. Make sure they don't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] mod size_asserts { use super::*; use rustc_data_structures::static_assert_size; diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index f3249f3e5a8..880f92bbe7b 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -768,7 +768,7 @@ impl DelimSpacing { } // Some types are used a lot. Make sure they don't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] mod size_asserts { use super::*; use rustc_data_structures::static_assert_size; diff --git a/compiler/rustc_ast_lowering/src/delegation.rs b/compiler/rustc_ast_lowering/src/delegation.rs index e26a65c1f29..f4d5e71bade 100644 --- a/compiler/rustc_ast_lowering/src/delegation.rs +++ b/compiler/rustc_ast_lowering/src/delegation.rs @@ -178,7 +178,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let pat_id = self.lower_node_id(pat_node_id); let pat = self.arena.alloc(hir::Pat { hir_id: pat_id, - kind: hir::PatKind::Binding(hir::BindingAnnotation::NONE, pat_id, Ident::empty(), None), + kind: hir::PatKind::Binding(hir::BindingMode::NONE, pat_id, Ident::empty(), None), span: ty.span, default_binding_modes: false, }); diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 66841c094ce..2305cc07795 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -643,7 +643,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let (pat, task_context_hid) = self.pat_ident_binding_mode( span, Ident::with_dummy_span(sym::_task_context), - hir::BindingAnnotation::MUT, + hir::BindingMode::MUT, ); let param = hir::Param { hir_id: self.next_id(), @@ -805,11 +805,8 @@ impl<'hir> LoweringContext<'_, 'hir> { // debuggers and debugger extensions expect it to be called `__awaitee`. They use // this name to identify what is being awaited by a suspended async functions. let awaitee_ident = Ident::with_dummy_span(sym::__awaitee); - let (awaitee_pat, awaitee_pat_hid) = self.pat_ident_binding_mode( - gen_future_span, - awaitee_ident, - hir::BindingAnnotation::MUT, - ); + let (awaitee_pat, awaitee_pat_hid) = + self.pat_ident_binding_mode(gen_future_span, awaitee_ident, hir::BindingMode::MUT); let task_context_ident = Ident::with_dummy_span(sym::_task_context); @@ -1648,7 +1645,7 @@ impl<'hir> LoweringContext<'_, 'hir> { // `mut iter` let iter = Ident::with_dummy_span(sym::iter); let (iter_pat, iter_pat_nid) = - self.pat_ident_binding_mode(head_span, iter, hir::BindingAnnotation::MUT); + self.pat_ident_binding_mode(head_span, iter, hir::BindingMode::MUT); let match_expr = { let iter = self.expr_ident(head_span, iter, iter_pat_nid); diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index abfea6078f2..e4c633aa324 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1179,9 +1179,7 @@ impl<'hir> LoweringContext<'_, 'hir> { // Check if this is a binding pattern, if so, we can optimize and avoid adding a // `let <pat> = __argN;` statement. In this case, we do not rename the parameter. let (ident, is_simple_parameter) = match parameter.pat.kind { - hir::PatKind::Binding(hir::BindingAnnotation(ByRef::No, _), _, ident, _) => { - (ident, true) - } + hir::PatKind::Binding(hir::BindingMode(ByRef::No, _), _, ident, _) => (ident, true), // For `ref mut` or wildcard arguments, we can't reuse the binding, but // we can keep the same name for the parameter. // This lets rustdoc render it correctly in documentation. @@ -1244,7 +1242,7 @@ impl<'hir> LoweringContext<'_, 'hir> { // because the user may have specified a `ref mut` binding in the next // statement. let (move_pat, move_id) = - self.pat_ident_binding_mode(desugared_span, ident, hir::BindingAnnotation::MUT); + self.pat_ident_binding_mode(desugared_span, ident, hir::BindingMode::MUT); let move_expr = self.expr_ident(desugared_span, ident, new_parameter_id); let move_stmt = self.stmt_let_pat( None, diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index d6e62462b98..c5b5acf7f32 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1895,7 +1895,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { implicit_self: decl.inputs.get(0).map_or(hir::ImplicitSelfKind::None, |arg| { let is_mutable_pat = matches!( arg.pat.kind, - PatKind::Ident(hir::BindingAnnotation(_, Mutability::Mut), ..) + PatKind::Ident(hir::BindingMode(_, Mutability::Mut), ..) ); match &arg.ty.kind { @@ -2478,18 +2478,18 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { } fn pat_ident(&mut self, span: Span, ident: Ident) -> (&'hir hir::Pat<'hir>, HirId) { - self.pat_ident_binding_mode(span, ident, hir::BindingAnnotation::NONE) + self.pat_ident_binding_mode(span, ident, hir::BindingMode::NONE) } fn pat_ident_mut(&mut self, span: Span, ident: Ident) -> (hir::Pat<'hir>, HirId) { - self.pat_ident_binding_mode_mut(span, ident, hir::BindingAnnotation::NONE) + self.pat_ident_binding_mode_mut(span, ident, hir::BindingMode::NONE) } fn pat_ident_binding_mode( &mut self, span: Span, ident: Ident, - bm: hir::BindingAnnotation, + bm: hir::BindingMode, ) -> (&'hir hir::Pat<'hir>, HirId) { let (pat, hir_id) = self.pat_ident_binding_mode_mut(span, ident, bm); (self.arena.alloc(pat), hir_id) @@ -2499,7 +2499,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { &mut self, span: Span, ident: Ident, - bm: hir::BindingAnnotation, + bm: hir::BindingMode, ) -> (hir::Pat<'hir>, HirId) { let hir_id = self.next_id(); diff --git a/compiler/rustc_ast_lowering/src/pat.rs b/compiler/rustc_ast_lowering/src/pat.rs index 8631d90be81..118a7322fbd 100644 --- a/compiler/rustc_ast_lowering/src/pat.rs +++ b/compiler/rustc_ast_lowering/src/pat.rs @@ -243,7 +243,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { fn lower_pat_ident( &mut self, p: &Pat, - annotation: BindingAnnotation, + annotation: BindingMode, ident: Ident, lower_sub: impl FnOnce(&mut Self) -> Option<&'hir hir::Pat<'hir>>, ) -> hir::PatKind<'hir> { diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 495e90e967b..4e3d560ce89 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -276,8 +276,8 @@ impl<'a> AstValidator<'a> { fn check_decl_no_pat(decl: &FnDecl, mut report_err: impl FnMut(Span, Option<Ident>, bool)) { for Param { pat, .. } in &decl.inputs { match pat.kind { - PatKind::Ident(BindingAnnotation::NONE, _, None) | PatKind::Wild => {} - PatKind::Ident(BindingAnnotation::MUT, ident, None) => { + PatKind::Ident(BindingMode::NONE, _, None) | PatKind::Wild => {} + PatKind::Ident(BindingMode::MUT, ident, None) => { report_err(pat.span, Some(ident), true) } _ => report_err(pat.span, None, false), diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 242335f769c..293e65ce872 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -17,7 +17,7 @@ use rustc_ast::util::classify; use rustc_ast::util::comments::{Comment, CommentStyle}; use rustc_ast::util::parser; use rustc_ast::{self as ast, AttrArgs, AttrArgsEq, BlockCheckMode, PatKind}; -use rustc_ast::{attr, BindingAnnotation, ByRef, DelimArgs, RangeEnd, RangeSyntax, Term}; +use rustc_ast::{attr, BindingMode, ByRef, DelimArgs, RangeEnd, RangeSyntax, Term}; use rustc_ast::{GenericArg, GenericBound, SelfKind}; use rustc_ast::{InlineAsmOperand, InlineAsmRegOrRegClass}; use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; @@ -1558,7 +1558,7 @@ impl<'a> State<'a> { match &pat.kind { PatKind::Wild => self.word("_"), PatKind::Never => self.word("!"), - PatKind::Ident(BindingAnnotation(by_ref, mutbl), ident, sub) => { + PatKind::Ident(BindingMode(by_ref, mutbl), ident, sub) => { if mutbl.is_mut() { self.word_nbsp("mut"); } @@ -1654,7 +1654,7 @@ impl<'a> State<'a> { if mutbl.is_mut() { self.word("mut "); } - if let PatKind::Ident(ast::BindingAnnotation::MUT, ..) = inner.kind { + if let PatKind::Ident(ast::BindingMode::MUT, ..) = inner.kind { self.popen(); self.print_pat(inner); self.pclose(); diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 8ccf88ec59c..ec0d4af599e 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -377,7 +377,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { if p.span == self.expr_span { self.pat = Some(p); } - if let hir::PatKind::Binding(hir::BindingAnnotation::NONE, _, i, sub) = p.kind { + if let hir::PatKind::Binding(hir::BindingMode::NONE, _, i, sub) = p.kind { if i.span == self.expr_span || p.span == self.expr_span { self.pat = Some(p); } diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index 602a84ce4dd..8b314217190 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -5,7 +5,7 @@ use core::ops::ControlFlow; use hir::{ExprKind, Param}; use rustc_errors::{Applicability, Diag}; use rustc_hir::intravisit::Visitor; -use rustc_hir::{self as hir, BindingAnnotation, ByRef, Node}; +use rustc_hir::{self as hir, BindingMode, ByRef, Node}; use rustc_infer::traits; use rustc_middle::mir::{Mutability, Place, PlaceRef, ProjectionElem}; use rustc_middle::ty::{self, InstanceDef, ToPredicate, Ty, TyCtxt}; @@ -303,7 +303,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { { match *decl.local_info() { LocalInfo::User(BindingForm::Var(mir::VarBindingForm { - binding_mode: BindingAnnotation(ByRef::No, Mutability::Not), + binding_mode: BindingMode(ByRef::No, Mutability::Not), opt_ty_info: Some(sp), opt_match_place: _, pat_span: _, @@ -398,7 +398,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { let upvar_hir_id = captured_place.get_root_variable(); if let Node::Pat(pat) = self.infcx.tcx.hir_node(upvar_hir_id) - && let hir::PatKind::Binding(hir::BindingAnnotation::NONE, _, upvar_ident, _) = + && let hir::PatKind::Binding(hir::BindingMode::NONE, _, upvar_ident, _) = pat.kind { if upvar_ident.name == kw::SelfLower { @@ -729,7 +729,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { debug!("local_decl: {:?}", local_decl); let pat_span = match *local_decl.local_info() { LocalInfo::User(BindingForm::Var(mir::VarBindingForm { - binding_mode: BindingAnnotation(ByRef::No, Mutability::Not), + binding_mode: BindingMode(ByRef::No, Mutability::Not), opt_ty_info: _, opt_match_place: _, pat_span, @@ -1086,7 +1086,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } LocalInfo::User(mir::BindingForm::Var(mir::VarBindingForm { - binding_mode: BindingAnnotation(ByRef::No, _), + binding_mode: BindingMode(ByRef::No, _), opt_ty_info, .. })) => { @@ -1154,7 +1154,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { } LocalInfo::User(mir::BindingForm::Var(mir::VarBindingForm { - binding_mode: BindingAnnotation(ByRef::Yes(_), _), + binding_mode: BindingMode(ByRef::Yes(_), _), .. })) => { let pattern_span: Span = local_decl.source_info.span; @@ -1356,7 +1356,7 @@ pub fn mut_borrow_of_mutable_ref(local_decl: &LocalDecl<'_>, local_name: Option< match *local_decl.local_info() { // Check if mutably borrowing a mutable reference. LocalInfo::User(mir::BindingForm::Var(mir::VarBindingForm { - binding_mode: BindingAnnotation(ByRef::No, Mutability::Not), + binding_mode: BindingMode(ByRef::No, Mutability::Not), .. })) => matches!(local_decl.ty.kind(), ty::Ref(_, _, hir::Mutability::Mut)), LocalInfo::User(mir::BindingForm::ImplicitSelf(kind)) => { diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index f73106c1835..85d54e9257d 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -180,7 +180,7 @@ pub use SubstructureFields::*; use crate::{deriving, errors}; use rustc_ast::ptr::P; use rustc_ast::{ - self as ast, BindingAnnotation, ByRef, EnumDef, Expr, GenericArg, GenericParamKind, Generics, + self as ast, BindingMode, ByRef, EnumDef, Expr, GenericArg, GenericParamKind, Generics, Mutability, PatKind, TyKind, VariantData, }; use rustc_attr as attr; @@ -1479,11 +1479,7 @@ impl<'a> TraitDef<'a> { struct_field.ident, cx.pat( path.span, - PatKind::Ident( - BindingAnnotation(by_ref, Mutability::Not), - path, - None, - ), + PatKind::Ident(BindingMode(by_ref, Mutability::Not), path, None), ), ) }); diff --git a/compiler/rustc_codegen_llvm/src/back/archive.rs b/compiler/rustc_codegen_llvm/src/back/archive.rs index 0619000364b..d4a3e39cef7 100644 --- a/compiler/rustc_codegen_llvm/src/back/archive.rs +++ b/compiler/rustc_codegen_llvm/src/back/archive.rs @@ -415,6 +415,7 @@ impl<'a> LlvmArchiveBuilder<'a> { members.as_ptr() as *const &_, true, kind, + self.sess.target.arch == "arm64ec", ); let ret = if r.into_result().is_err() { let err = llvm::LLVMRustGetLastError(); diff --git a/compiler/rustc_codegen_llvm/src/common.rs b/compiler/rustc_codegen_llvm/src/common.rs index 568fcc3f3cf..ec33ce6292a 100644 --- a/compiler/rustc_codegen_llvm/src/common.rs +++ b/compiler/rustc_codegen_llvm/src/common.rs @@ -255,21 +255,38 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> { let (prov, offset) = ptr.into_parts(); let (base_addr, base_addr_space) = match self.tcx.global_alloc(prov.alloc_id()) { GlobalAlloc::Memory(alloc) => { - let init = const_alloc_to_llvm(self, alloc); - let alloc = alloc.inner(); - let value = match alloc.mutability { - Mutability::Mut => self.static_addr_of_mut(init, alloc.align, None), - _ => self.static_addr_of(init, alloc.align, None), - }; - if !self.sess().fewer_names() && llvm::get_value_name(value).is_empty() { - let hash = self.tcx.with_stable_hashing_context(|mut hcx| { - let mut hasher = StableHasher::new(); - alloc.hash_stable(&mut hcx, &mut hasher); - hasher.finish::<Hash128>() - }); - llvm::set_value_name(value, format!("alloc_{hash:032x}").as_bytes()); + // For ZSTs directly codegen an aligned pointer. + // This avoids generating a zero-sized constant value and actually needing a + // real address at runtime. + if alloc.inner().len() == 0 { + assert_eq!(offset.bytes(), 0); + let llval = self.const_usize(alloc.inner().align.bytes()); + return if matches!(layout.primitive(), Pointer(_)) { + unsafe { llvm::LLVMConstIntToPtr(llval, llty) } + } else { + self.const_bitcast(llval, llty) + }; + } else { + let init = const_alloc_to_llvm(self, alloc, /*static*/ false); + let alloc = alloc.inner(); + let value = match alloc.mutability { + Mutability::Mut => self.static_addr_of_mut(init, alloc.align, None), + _ => self.static_addr_of(init, alloc.align, None), + }; + if !self.sess().fewer_names() && llvm::get_value_name(value).is_empty() + { + let hash = self.tcx.with_stable_hashing_context(|mut hcx| { + let mut hasher = StableHasher::new(); + alloc.hash_stable(&mut hcx, &mut hasher); + hasher.finish::<Hash128>() + }); + llvm::set_value_name( + value, + format!("alloc_{hash:032x}").as_bytes(), + ); + } + (value, AddressSpace::DATA) } - (value, AddressSpace::DATA) } GlobalAlloc::Function(fn_instance) => ( self.get_fn_addr(fn_instance.polymorphize(self.tcx)), @@ -280,7 +297,7 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> { .tcx .global_alloc(self.tcx.vtable_allocation((ty, trait_ref))) .unwrap_memory(); - let init = const_alloc_to_llvm(self, alloc); + let init = const_alloc_to_llvm(self, alloc, /*static*/ false); let value = self.static_addr_of(init, alloc.inner().align, None); (value, AddressSpace::DATA) } @@ -308,7 +325,7 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> { } fn const_data_from_alloc(&self, alloc: ConstAllocation<'tcx>) -> Self::Value { - const_alloc_to_llvm(self, alloc) + const_alloc_to_llvm(self, alloc, /*static*/ false) } fn const_bitcast(&self, val: &'ll Value, ty: &'ll Type) -> &'ll Value { diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index 4afa230e598..a62dfe13204 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -26,8 +26,22 @@ use rustc_target::abi::{ }; use std::ops::Range; -pub fn const_alloc_to_llvm<'ll>(cx: &CodegenCx<'ll, '_>, alloc: ConstAllocation<'_>) -> &'ll Value { +pub fn const_alloc_to_llvm<'ll>( + cx: &CodegenCx<'ll, '_>, + alloc: ConstAllocation<'_>, + is_static: bool, +) -> &'ll Value { let alloc = alloc.inner(); + // We expect that callers of const_alloc_to_llvm will instead directly codegen a pointer or + // integer for any &ZST where the ZST is a constant (i.e. not a static). We should never be + // producing empty LLVM allocations as they're just adding noise to binaries and forcing less + // optimal codegen. + // + // Statics have a guaranteed meaningful address so it's less clear that we want to do + // something like this; it's also harder. + if !is_static { + assert!(alloc.len() != 0); + } let mut llvals = Vec::with_capacity(alloc.provenance().ptrs().len() + 1); let dl = cx.data_layout(); let pointer_size = dl.pointer_size.bytes() as usize; @@ -120,7 +134,7 @@ fn codegen_static_initializer<'ll, 'tcx>( def_id: DefId, ) -> Result<(&'ll Value, ConstAllocation<'tcx>), ErrorHandled> { let alloc = cx.tcx.eval_static_initializer(def_id)?; - Ok((const_alloc_to_llvm(cx, alloc), alloc)) + Ok((const_alloc_to_llvm(cx, alloc, /*static*/ true), alloc)) } fn set_global_alignment<'ll>(cx: &CodegenCx<'ll, '_>, gv: &'ll Value, mut align: Align) { diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 5509baaa3e9..83158f6f1d5 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -2303,6 +2303,7 @@ extern "C" { Members: *const &RustArchiveMember<'_>, WriteSymbtab: bool, Kind: ArchiveKind, + isEC: bool, ) -> LLVMRustResult; pub fn LLVMRustArchiveMemberNew<'a>( Filename: *const c_char, diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index c9e62e504ae..5552b381025 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -270,9 +270,10 @@ pub fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> LLVMFeature<'a> { "sve2-bitperm", TargetFeatureFoldStrength::EnableOnly("neon"), ), - // The unaligned-scalar-mem feature was renamed to fast-unaligned-access. - ("riscv32" | "riscv64", "fast-unaligned-access") if get_version().0 <= 17 => { - LLVMFeature::new("unaligned-scalar-mem") + // In LLVM 18, `unaligned-scalar-mem` was merged with `unaligned-vector-mem` into a single feature called + // `fast-unaligned-access`. In LLVM 19, it was split back out. + ("riscv32" | "riscv64", "unaligned-scalar-mem") if get_version().0 == 18 => { + LLVMFeature::new("fast-unaligned-access") } // For LLVM 18, enable the evex512 target feature if a avx512 target feature is enabled. ("x86", s) if get_version().0 >= 18 && s.starts_with("avx512") => { diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs index 4283ebc99d2..40afd9f162f 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -10,20 +10,21 @@ use rustc_middle::traits::Reveal; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::{self, Ty, TyCtxt}; +use rustc_session::lint; use rustc_span::def_id::LocalDefId; use rustc_span::Span; use rustc_target::abi::{self, Abi}; use super::{CanAccessMutGlobal, CompileTimeEvalContext, CompileTimeInterpreter}; use crate::const_eval::CheckAlignment; -use crate::errors; use crate::errors::ConstEvalError; -use crate::interpret::eval_nullary_intrinsic; +use crate::errors::{self, DanglingPtrInFinal}; use crate::interpret::{ create_static_alloc, intern_const_alloc_recursive, CtfeValidationMode, GlobalId, Immediate, InternKind, InterpCx, InterpError, InterpResult, MPlaceTy, MemoryKind, OpTy, RefTracking, StackPopCleanup, }; +use crate::interpret::{eval_nullary_intrinsic, InternResult}; use crate::CTRL_C_RECEIVED; // Returns a pointer to where the result lives @@ -89,11 +90,35 @@ fn eval_body_using_ecx<'mir, 'tcx, R: InterpretationResult<'tcx>>( } // Intern the result - intern_const_alloc_recursive(ecx, intern_kind, &ret)?; + let intern_result = intern_const_alloc_recursive(ecx, intern_kind, &ret); // Since evaluation had no errors, validate the resulting constant. const_validate_mplace(&ecx, &ret, cid)?; + // Only report this after validation, as validaiton produces much better diagnostics. + // FIXME: ensure validation always reports this and stop making interning care about it. + + match intern_result { + Ok(()) => {} + Err(InternResult::FoundDanglingPointer) => { + return Err(ecx + .tcx + .dcx() + .emit_err(DanglingPtrInFinal { span: ecx.tcx.span, kind: intern_kind }) + .into()); + } + Err(InternResult::FoundBadMutablePointer) => { + // only report mutable pointers if there were no dangling pointers + let err_diag = errors::MutablePtrInFinal { span: ecx.tcx.span, kind: intern_kind }; + ecx.tcx.emit_node_span_lint( + lint::builtin::CONST_EVAL_MUTABLE_PTR_IN_FINAL_VALUE, + ecx.best_lint_scope(), + err_diag.span, + err_diag, + ) + } + } + Ok(R::make_result(ret, ecx)) } diff --git a/compiler/rustc_const_eval/src/interpret/intern.rs b/compiler/rustc_const_eval/src/interpret/intern.rs index d0f0190fea7..d4168273f29 100644 --- a/compiler/rustc_const_eval/src/interpret/intern.rs +++ b/compiler/rustc_const_eval/src/interpret/intern.rs @@ -16,19 +16,17 @@ use hir::def::DefKind; use rustc_ast::Mutability; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; -use rustc_errors::ErrorGuaranteed; use rustc_hir as hir; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; use rustc_middle::mir::interpret::{ConstAllocation, CtfeProvenance, InterpResult}; use rustc_middle::query::TyCtxtAt; use rustc_middle::ty::layout::TyAndLayout; -use rustc_session::lint; use rustc_span::def_id::LocalDefId; use rustc_span::sym; use super::{AllocId, Allocation, InterpCx, MPlaceTy, Machine, MemoryKind, PlaceTy}; use crate::const_eval; -use crate::errors::{DanglingPtrInFinal, MutablePtrInFinal, NestedStaticInThreadLocal}; +use crate::errors::NestedStaticInThreadLocal; pub trait CompileTimeMachine<'mir, 'tcx: 'mir, T> = Machine< 'mir, @@ -134,6 +132,12 @@ pub enum InternKind { Promoted, } +#[derive(Debug)] +pub enum InternResult { + FoundBadMutablePointer, + FoundDanglingPointer, +} + /// Intern `ret` and everything it references. /// /// This *cannot raise an interpreter error*. Doing so is left to validation, which @@ -149,7 +153,7 @@ pub fn intern_const_alloc_recursive< ecx: &mut InterpCx<'mir, 'tcx, M>, intern_kind: InternKind, ret: &MPlaceTy<'tcx>, -) -> Result<(), ErrorGuaranteed> { +) -> Result<(), InternResult> { // We are interning recursively, and for mutability we are distinguishing the "root" allocation // that we are starting in, and all other allocations that we are encountering recursively. let (base_mutability, inner_mutability, is_static) = match intern_kind { @@ -201,7 +205,7 @@ pub fn intern_const_alloc_recursive< // Whether we encountered a bad mutable pointer. // We want to first report "dangling" and then "mutable", so we need to delay reporting these // errors. - let mut found_bad_mutable_pointer = false; + let mut result = Ok(()); // Keep interning as long as there are things to intern. // We show errors if there are dangling pointers, or mutable pointers in immutable contexts @@ -251,7 +255,10 @@ pub fn intern_const_alloc_recursive< // on the promotion analysis not screwing up to ensure that it is sound to intern // promoteds as immutable. trace!("found bad mutable pointer"); - found_bad_mutable_pointer = true; + // Prefer dangling pointer errors over mutable pointer errors + if result.is_ok() { + result = Err(InternResult::FoundBadMutablePointer); + } } if ecx.tcx.try_get_global_alloc(alloc_id).is_some() { // Already interned. @@ -269,21 +276,15 @@ pub fn intern_const_alloc_recursive< // pointers before deciding which allocations can be made immutable; but for now we are // okay with losing some potential for immutability here. This can anyway only affect // `static mut`. - todo.extend(intern_shallow(ecx, alloc_id, inner_mutability).map_err(|()| { - ecx.tcx.dcx().emit_err(DanglingPtrInFinal { span: ecx.tcx.span, kind: intern_kind }) - })?); - } - if found_bad_mutable_pointer { - let err_diag = MutablePtrInFinal { span: ecx.tcx.span, kind: intern_kind }; - ecx.tcx.emit_node_span_lint( - lint::builtin::CONST_EVAL_MUTABLE_PTR_IN_FINAL_VALUE, - ecx.best_lint_scope(), - err_diag.span, - err_diag, - ) + match intern_shallow(ecx, alloc_id, inner_mutability) { + Ok(nested) => todo.extend(nested), + Err(()) => { + ecx.tcx.dcx().delayed_bug("found dangling pointer during const interning"); + result = Err(InternResult::FoundDanglingPointer); + } + } } - - Ok(()) + result } /// Intern `ret`. This function assumes that `ret` references no other allocation. diff --git a/compiler/rustc_const_eval/src/interpret/mod.rs b/compiler/rustc_const_eval/src/interpret/mod.rs index 474d35b2aa3..7ede90ad13f 100644 --- a/compiler/rustc_const_eval/src/interpret/mod.rs +++ b/compiler/rustc_const_eval/src/interpret/mod.rs @@ -23,6 +23,7 @@ pub use rustc_middle::mir::interpret::*; // have all the `interpret` symbols in pub use self::eval_context::{format_interp_error, Frame, FrameInfo, InterpCx, StackPopCleanup}; pub use self::intern::{ intern_const_alloc_for_constprop, intern_const_alloc_recursive, HasStaticRootDefId, InternKind, + InternResult, }; pub use self::machine::{compile_time_machine, AllocMap, Machine, MayLeak, StackPopJump}; pub use self::memory::{AllocKind, AllocRef, AllocRefMut, FnVal, Memory, MemoryKind}; diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs index c120154ce2a..75a672785ea 100644 --- a/compiler/rustc_const_eval/src/interpret/operand.rs +++ b/compiler/rustc_const_eval/src/interpret/operand.rs @@ -792,7 +792,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } // Some nodes are used a lot. Make sure they don't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] mod size_asserts { use super::*; use rustc_data_structures::static_assert_size; diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs index 1549eddabbc..8364a5a8d18 100644 --- a/compiler/rustc_const_eval/src/interpret/place.rs +++ b/compiler/rustc_const_eval/src/interpret/place.rs @@ -1058,7 +1058,7 @@ where } // Some nodes are used a lot. Make sure they don't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] mod size_asserts { use super::*; use rustc_data_structures::static_assert_size; diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index 9911c59d4b8..b8a1733e45a 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -449,67 +449,41 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' // `!` is a ZST and we want to validate it. if let Ok((alloc_id, _offset, _prov)) = self.ecx.ptr_try_get_alloc_id(place.ptr()) { let mut skip_recursive_check = false; - // Let's see what kind of memory this points to. - // `unwrap` since dangling pointers have already been handled. - let alloc_kind = self.ecx.tcx.try_get_global_alloc(alloc_id).unwrap(); - let alloc_actual_mutbl = match alloc_kind { - GlobalAlloc::Static(did) => { - // Special handling for pointers to statics (irrespective of their type). - assert!(!self.ecx.tcx.is_thread_local_static(did)); - assert!(self.ecx.tcx.is_static(did)); - // Mode-specific checks - match self.ctfe_mode { - Some( - CtfeValidationMode::Static { .. } - | CtfeValidationMode::Promoted { .. }, - ) => { - // We skip recursively checking other statics. These statics must be sound by - // themselves, and the only way to get broken statics here is by using - // unsafe code. - // The reasons we don't check other statics is twofold. For one, in all - // sound cases, the static was already validated on its own, and second, we - // trigger cycle errors if we try to compute the value of the other static - // and that static refers back to us (potentially through a promoted). - // This could miss some UB, but that's fine. - skip_recursive_check = true; - } - Some(CtfeValidationMode::Const { .. }) => { - // We can't recursively validate `extern static`, so we better reject them. - if self.ecx.tcx.is_foreign_item(did) { - throw_validation_failure!(self.path, ConstRefToExtern); - } - } - None => {} + let alloc_actual_mutbl = mutability(self.ecx, alloc_id); + if let GlobalAlloc::Static(did) = self.ecx.tcx.global_alloc(alloc_id) { + let DefKind::Static { nested, .. } = self.ecx.tcx.def_kind(did) else { bug!() }; + // Special handling for pointers to statics (irrespective of their type). + assert!(!self.ecx.tcx.is_thread_local_static(did)); + assert!(self.ecx.tcx.is_static(did)); + // Mode-specific checks + match self.ctfe_mode { + Some( + CtfeValidationMode::Static { .. } | CtfeValidationMode::Promoted { .. }, + ) => { + // We skip recursively checking other statics. These statics must be sound by + // themselves, and the only way to get broken statics here is by using + // unsafe code. + // The reasons we don't check other statics is twofold. For one, in all + // sound cases, the static was already validated on its own, and second, we + // trigger cycle errors if we try to compute the value of the other static + // and that static refers back to us (potentially through a promoted). + // This could miss some UB, but that's fine. + // We still walk nested allocations, as they are fundamentally part of this validation run. + // This means we will also recurse into nested statics of *other* + // statics, even though we do not recurse into other statics directly. + // That's somewhat inconsistent but harmless. + skip_recursive_check = !nested; } - // Return alloc mutability. For "root" statics we look at the type to account for interior - // mutability; for nested statics we have no type and directly use the annotated mutability. - let DefKind::Static { mutability, nested } = self.ecx.tcx.def_kind(did) - else { - bug!() - }; - match (mutability, nested) { - (Mutability::Mut, _) => Mutability::Mut, - (Mutability::Not, true) => Mutability::Not, - (Mutability::Not, false) - if !self - .ecx - .tcx - .type_of(did) - .no_bound_vars() - .expect("statics should not have generic parameters") - .is_freeze(*self.ecx.tcx, ty::ParamEnv::reveal_all()) => - { - Mutability::Mut + Some(CtfeValidationMode::Const { .. }) => { + // We can't recursively validate `extern static`, so we better reject them. + if self.ecx.tcx.is_foreign_item(did) { + throw_validation_failure!(self.path, ConstRefToExtern); } - (Mutability::Not, false) => Mutability::Not, } + None => {} } - GlobalAlloc::Memory(alloc) => alloc.inner().mutability, - GlobalAlloc::Function(..) | GlobalAlloc::VTable(..) => { - // These are immutable, we better don't allow mutable pointers here. - Mutability::Not - } - }; + } + // Mutability check. // If this allocation has size zero, there is no actual mutability here. let (size, _align, _alloc_kind) = self.ecx.get_alloc_info(alloc_id); @@ -708,17 +682,58 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' fn in_mutable_memory(&self, op: &OpTy<'tcx, M::Provenance>) -> bool { if let Some(mplace) = op.as_mplace_or_imm().left() { if let Some(alloc_id) = mplace.ptr().provenance.and_then(|p| p.get_alloc_id()) { - let mutability = match self.ecx.tcx.global_alloc(alloc_id) { - GlobalAlloc::Static(_) => { - self.ecx.memory.alloc_map.get(alloc_id).unwrap().1.mutability + return mutability(self.ecx, alloc_id).is_mut(); + } + } + false + } +} + +/// Returns whether the allocation is mutable, and whether it's actually a static. +/// For "root" statics we look at the type to account for interior +/// mutability; for nested statics we have no type and directly use the annotated mutability. +fn mutability<'mir, 'tcx: 'mir>( + ecx: &InterpCx<'mir, 'tcx, impl Machine<'mir, 'tcx>>, + alloc_id: AllocId, +) -> Mutability { + // Let's see what kind of memory this points to. + // We're not using `try_global_alloc` since dangling pointers have already been handled. + match ecx.tcx.global_alloc(alloc_id) { + GlobalAlloc::Static(did) => { + let DefKind::Static { mutability, nested } = ecx.tcx.def_kind(did) else { bug!() }; + if nested { + assert!( + ecx.memory.alloc_map.get(alloc_id).is_none(), + "allocations of nested statics are already interned: {alloc_id:?}, {did:?}" + ); + // Nested statics in a `static` are never interior mutable, + // so just use the declared mutability. + mutability + } else { + let mutability = match mutability { + Mutability::Not + if !ecx + .tcx + .type_of(did) + .no_bound_vars() + .expect("statics should not have generic parameters") + .is_freeze(*ecx.tcx, ty::ParamEnv::reveal_all()) => + { + Mutability::Mut } - GlobalAlloc::Memory(alloc) => alloc.inner().mutability, - _ => span_bug!(self.ecx.tcx.span, "not a memory allocation"), + _ => mutability, }; - return mutability == Mutability::Mut; + if let Some((_, alloc)) = ecx.memory.alloc_map.get(alloc_id) { + assert_eq!(alloc.mutability, mutability); + } + mutability } } - false + GlobalAlloc::Memory(alloc) => alloc.inner().mutability, + GlobalAlloc::Function(..) | GlobalAlloc::VTable(..) => { + // These are immutable, we better don't allow mutable pointers here. + Mutability::Not + } } } diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index b4107bd4a2b..8d6b22a9fa9 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -102,9 +102,9 @@ pub type PResult<'a, T> = Result<T, PErr<'a>>; rustc_fluent_macro::fluent_messages! { "../messages.ftl" } // `PResult` is used a lot. Make sure it doesn't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] rustc_data_structures::static_assert_size!(PResult<'_, ()>, 16); -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] rustc_data_structures::static_assert_size!(PResult<'_, bool>, 16); #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, Encodable, Decodable)] diff --git a/compiler/rustc_expand/src/build.rs b/compiler/rustc_expand/src/build.rs index cdcf67b26f8..83f120525bc 100644 --- a/compiler/rustc_expand/src/build.rs +++ b/compiler/rustc_expand/src/build.rs @@ -202,7 +202,7 @@ impl<'a> ExtCtxt<'a> { ex: P<ast::Expr>, ) -> ast::Stmt { let pat = if mutbl { - self.pat_ident_binding_mode(sp, ident, ast::BindingAnnotation::MUT) + self.pat_ident_binding_mode(sp, ident, ast::BindingMode::MUT) } else { self.pat_ident(sp, ident) }; @@ -490,14 +490,14 @@ impl<'a> ExtCtxt<'a> { self.pat(span, PatKind::Lit(expr)) } pub fn pat_ident(&self, span: Span, ident: Ident) -> P<ast::Pat> { - self.pat_ident_binding_mode(span, ident, ast::BindingAnnotation::NONE) + self.pat_ident_binding_mode(span, ident, ast::BindingMode::NONE) } pub fn pat_ident_binding_mode( &self, span: Span, ident: Ident, - ann: ast::BindingAnnotation, + ann: ast::BindingMode, ) -> P<ast::Pat> { let pat = PatKind::Ident(ann, ident.with_span_pos(span), None); self.pat(span, pat) diff --git a/compiler/rustc_expand/src/mbe/macro_parser.rs b/compiler/rustc_expand/src/mbe/macro_parser.rs index 9fff00ffeae..ffb50f4c92e 100644 --- a/compiler/rustc_expand/src/mbe/macro_parser.rs +++ b/compiler/rustc_expand/src/mbe/macro_parser.rs @@ -266,7 +266,7 @@ struct MatcherPos { } // This type is used a lot. Make sure it doesn't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] rustc_data_structures::static_assert_size!(MatcherPos, 16); impl MatcherPos { diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index b39056d8690..e4f8d77dbc2 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -7,7 +7,7 @@ use crate::LangItem; use rustc_ast as ast; use rustc_ast::util::parser::ExprPrecedence; use rustc_ast::{Attribute, FloatTy, IntTy, Label, LitKind, TraitObjectSyntax, UintTy}; -pub use rustc_ast::{BinOp, BinOpKind, BindingAnnotation, BorrowKind, ByRef, CaptureBy}; +pub use rustc_ast::{BinOp, BinOpKind, BindingMode, BorrowKind, ByRef, CaptureBy}; pub use rustc_ast::{ImplPolarity, IsAuto, Movability, Mutability, UnOp}; use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; use rustc_data_structures::fingerprint::Fingerprint; @@ -1151,7 +1151,7 @@ pub enum PatKind<'hir> { /// The `HirId` is the canonical ID for the variable being bound, /// (e.g., in `Ok(x) | Err(x)`, both `x` use the same canonical ID), /// which is the pattern ID of the first `x`. - Binding(BindingAnnotation, HirId, Ident, Option<&'hir Pat<'hir>>), + Binding(BindingMode, HirId, Ident, Option<&'hir Pat<'hir>>), /// A struct or struct variant pattern (e.g., `Variant {x, y, ..}`). /// The `bool` is `true` in the presence of a `..`. @@ -3786,7 +3786,7 @@ impl<'hir> Node<'hir> { } // Some nodes are used a lot. Make sure they don't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] mod size_asserts { use super::*; // tidy-alphabetical-start diff --git a/compiler/rustc_hir/src/pat_util.rs b/compiler/rustc_hir/src/pat_util.rs index 1eaab3d2aca..9991b02b1e1 100644 --- a/compiler/rustc_hir/src/pat_util.rs +++ b/compiler/rustc_hir/src/pat_util.rs @@ -1,6 +1,6 @@ use crate::def::{CtorOf, DefKind, Res}; use crate::def_id::{DefId, DefIdSet}; -use crate::hir::{self, BindingAnnotation, ByRef, HirId, PatKind}; +use crate::hir::{self, BindingMode, ByRef, HirId, PatKind}; use rustc_span::symbol::Ident; use rustc_span::Span; @@ -60,7 +60,7 @@ impl<T: ExactSizeIterator> EnumerateAndAdjustIterator for T { impl hir::Pat<'_> { /// Call `f` on every "binding" in a pattern, e.g., on `a` in /// `match foo() { Some(a) => (), None => () }` - pub fn each_binding(&self, mut f: impl FnMut(hir::BindingAnnotation, HirId, Span, Ident)) { + pub fn each_binding(&self, mut f: impl FnMut(hir::BindingMode, HirId, Span, Ident)) { self.walk_always(|p| { if let PatKind::Binding(binding_mode, _, ident, _) = p.kind { f(binding_mode, p.hir_id, p.span, ident); @@ -74,10 +74,7 @@ impl hir::Pat<'_> { /// When encountering an or-pattern `p_0 | ... | p_n` only the first non-never pattern will be /// visited. If they're all never patterns we visit nothing, which is ok since a never pattern /// cannot have bindings. - pub fn each_binding_or_first( - &self, - f: &mut impl FnMut(hir::BindingAnnotation, HirId, Span, Ident), - ) { + pub fn each_binding_or_first(&self, f: &mut impl FnMut(hir::BindingMode, HirId, Span, Ident)) { self.walk(|p| match &p.kind { PatKind::Or(ps) => { for p in *ps { @@ -98,7 +95,7 @@ impl hir::Pat<'_> { pub fn simple_ident(&self) -> Option<Ident> { match self.kind { - PatKind::Binding(BindingAnnotation(ByRef::No, _), _, ident, None) => Some(ident), + PatKind::Binding(BindingMode(ByRef::No, _), _, ident, None) => Some(ident), _ => None, } } @@ -135,8 +132,8 @@ impl hir::Pat<'_> { pub fn contains_explicit_ref_binding(&self) -> Option<hir::Mutability> { let mut result = None; self.each_binding(|annotation, _, _, _| match annotation { - hir::BindingAnnotation::REF if result.is_none() => result = Some(hir::Mutability::Not), - hir::BindingAnnotation::REF_MUT => result = Some(hir::Mutability::Mut), + hir::BindingMode::REF if result.is_none() => result = Some(hir::Mutability::Not), + hir::BindingMode::REF_MUT => result = Some(hir::Mutability::Mut), _ => {} }); result diff --git a/compiler/rustc_hir_analysis/src/check/region.rs b/compiler/rustc_hir_analysis/src/check/region.rs index 397893491a3..d2ea51f65f9 100644 --- a/compiler/rustc_hir_analysis/src/check/region.rs +++ b/compiler/rustc_hir_analysis/src/check/region.rs @@ -654,7 +654,7 @@ fn resolve_local<'tcx>( // & expression, and its lifetime would be extended to the end of the block (due // to a different rule, not the below code). match pat.kind { - PatKind::Binding(hir::BindingAnnotation(hir::ByRef::Yes(_), _), ..) => true, + PatKind::Binding(hir::BindingMode(hir::ByRef::Yes(_), _), ..) => true, PatKind::Struct(_, field_pats, _) => field_pats.iter().any(|fp| is_binding_pat(fp.pat)), @@ -671,7 +671,7 @@ fn resolve_local<'tcx>( PatKind::Box(subpat) | PatKind::Deref(subpat) => is_binding_pat(subpat), PatKind::Ref(_, _) - | PatKind::Binding(hir::BindingAnnotation(hir::ByRef::No, _), ..) + | PatKind::Binding(hir::BindingMode(hir::ByRef::No, _), ..) | PatKind::Wild | PatKind::Never | PatKind::Path(_) diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 0f4d8df7293..285b99c2c69 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -10,7 +10,7 @@ use rustc_ast_pretty::pp::{self, Breaks}; use rustc_ast_pretty::pprust::{Comments, PrintState}; use rustc_hir as hir; use rustc_hir::{ - BindingAnnotation, ByRef, GenericArg, GenericBound, GenericParam, GenericParamKind, HirId, + BindingMode, ByRef, GenericArg, GenericBound, GenericParam, GenericParamKind, HirId, LifetimeParamKind, Node, PatKind, RangeEnd, Term, TraitBoundModifier, }; use rustc_span::source_map::SourceMap; @@ -1723,7 +1723,7 @@ impl<'a> State<'a> { match pat.kind { PatKind::Wild => self.word("_"), PatKind::Never => self.word("!"), - PatKind::Binding(BindingAnnotation(by_ref, mutbl), _, ident, sub) => { + PatKind::Binding(BindingMode(by_ref, mutbl), _, ident, sub) => { if mutbl.is_mut() { self.word_nbsp("mut"); } diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 3c1e01cfb53..6040b689f49 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -7,7 +7,7 @@ use rustc_errors::{ }; use rustc_hir::def::{CtorKind, DefKind, Res}; use rustc_hir::pat_util::EnumerateAndAdjustIterator; -use rustc_hir::{self as hir, BindingAnnotation, ByRef, HirId, Mutability, Pat, PatKind}; +use rustc_hir::{self as hir, BindingMode, ByRef, HirId, Mutability, Pat, PatKind}; use rustc_infer::infer; use rustc_infer::infer::type_variable::TypeVariableOrigin; use rustc_lint as lint; @@ -79,7 +79,7 @@ struct TopInfo<'tcx> { #[derive(Copy, Clone)] struct PatInfo<'tcx, 'a> { - binding_mode: BindingAnnotation, + binding_mode: ByRef, max_ref_mutbl: Mutability, top_info: TopInfo<'tcx>, decl_origin: Option<DeclOrigin<'a>>, @@ -125,8 +125,6 @@ impl<'tcx> FnCtxt<'_, 'tcx> { } } -const INITIAL_BM: BindingAnnotation = BindingAnnotation(ByRef::No, Mutability::Not); - /// Mode for adjusting the expected type and binding mode. enum AdjustMode { /// Peel off all immediate reference types. @@ -163,7 +161,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) { let info = TopInfo { expected, origin_expr, span }; let pat_info = PatInfo { - binding_mode: INITIAL_BM, + binding_mode: ByRef::No, max_ref_mutbl: Mutability::Mut, top_info: info, decl_origin, @@ -296,43 +294,43 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, pat: &'tcx Pat<'tcx>, expected: Ty<'tcx>, - def_bm: BindingAnnotation, + def_br: ByRef, adjust_mode: AdjustMode, max_ref_mutbl: Mutability, - ) -> (Ty<'tcx>, BindingAnnotation, Mutability, bool) { - if let ByRef::Yes(mutbl) = def_bm.0 { + ) -> (Ty<'tcx>, ByRef, Mutability, bool) { + if let ByRef::Yes(mutbl) = def_br { debug_assert!(mutbl <= max_ref_mutbl); } match adjust_mode { - AdjustMode::Pass => (expected, def_bm, max_ref_mutbl, false), - AdjustMode::Reset => (expected, INITIAL_BM, Mutability::Mut, false), + AdjustMode::Pass => (expected, def_br, max_ref_mutbl, false), + AdjustMode::Reset => (expected, ByRef::No, Mutability::Mut, false), AdjustMode::ResetAndConsumeRef(ref_pat_mutbl) => { - let mutbls_match = def_bm.0 == ByRef::Yes(ref_pat_mutbl); + let mutbls_match = def_br == ByRef::Yes(ref_pat_mutbl); if pat.span.at_least_rust_2024() && self.tcx.features().ref_pat_eat_one_layer_2024 { if mutbls_match { debug!("consuming inherited reference"); - (expected, INITIAL_BM, cmp::min(max_ref_mutbl, ref_pat_mutbl), true) + (expected, ByRef::No, cmp::min(max_ref_mutbl, ref_pat_mutbl), true) } else { let (new_ty, new_bm, max_ref_mutbl) = if ref_pat_mutbl == Mutability::Mut { self.peel_off_references( pat, expected, - def_bm, + def_br, Mutability::Not, max_ref_mutbl, ) } else { - (expected, def_bm.cap_ref_mutability(Mutability::Not), Mutability::Not) + (expected, def_br.cap_ref_mutability(Mutability::Not), Mutability::Not) }; (new_ty, new_bm, max_ref_mutbl, false) } } else { - (expected, INITIAL_BM, max_ref_mutbl, mutbls_match) + (expected, ByRef::No, max_ref_mutbl, mutbls_match) } } AdjustMode::Peel => { let peeled = - self.peel_off_references(pat, expected, def_bm, Mutability::Mut, max_ref_mutbl); + self.peel_off_references(pat, expected, def_br, Mutability::Mut, max_ref_mutbl); (peeled.0, peeled.1, peeled.2, false) } } @@ -413,10 +411,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, pat: &'tcx Pat<'tcx>, expected: Ty<'tcx>, - mut def_bm: BindingAnnotation, + mut def_br: ByRef, max_peelable_mutability: Mutability, mut max_ref_mutability: Mutability, - ) -> (Ty<'tcx>, BindingAnnotation, Mutability) { + ) -> (Ty<'tcx>, ByRef, Mutability) { let mut expected = self.try_structurally_resolve_type(pat.span, expected); // Peel off as many `&` or `&mut` from the scrutinee type as possible. For example, // for `match &&&mut Some(5)` the loop runs three times, aborting when it reaches @@ -437,7 +435,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pat_adjustments.push(expected); expected = self.try_structurally_resolve_type(pat.span, inner_ty); - def_bm.0 = ByRef::Yes(match def_bm.0 { + def_br = ByRef::Yes(match def_br { // If default binding mode is by value, make it `ref` or `ref mut` // (depending on whether we observe `&` or `&mut`). ByRef::No | @@ -450,21 +448,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } if pat.span.at_least_rust_2024() && self.tcx.features().ref_pat_eat_one_layer_2024 { - def_bm = def_bm.cap_ref_mutability(max_ref_mutability); - if def_bm.0 == ByRef::Yes(Mutability::Not) { + def_br = def_br.cap_ref_mutability(max_ref_mutability); + if def_br == ByRef::Yes(Mutability::Not) { max_ref_mutability = Mutability::Not; } } if !pat_adjustments.is_empty() { - debug!("default binding mode is now {:?}", def_bm); + debug!("default binding mode is now {:?}", def_br); self.typeck_results .borrow_mut() .pat_adjustments_mut() .insert(pat.hir_id, pat_adjustments); } - (expected, def_bm, max_ref_mutability) + (expected, def_br, max_ref_mutability) } fn check_pat_lit( @@ -669,17 +667,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn check_pat_ident( &self, pat: &'tcx Pat<'tcx>, - ba: BindingAnnotation, + ba: BindingMode, var_id: HirId, sub: Option<&'tcx Pat<'tcx>>, expected: Ty<'tcx>, pat_info: PatInfo<'tcx, '_>, ) -> Ty<'tcx> { - let PatInfo { binding_mode: BindingAnnotation(def_br, _), top_info: ti, .. } = pat_info; + let PatInfo { binding_mode: def_br, top_info: ti, .. } = pat_info; // Determine the binding mode... let bm = match ba { - BindingAnnotation(ByRef::No, Mutability::Mut) + BindingMode(ByRef::No, Mutability::Mut) if !(pat.span.at_least_rust_2024() && self.tcx.features().mut_preserve_binding_mode_2024) && matches!(def_br, ByRef::Yes(_)) => @@ -691,10 +689,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pat.span, errors::DereferencingMutBinding { span: pat.span }, ); - BindingAnnotation(ByRef::No, Mutability::Mut) + BindingMode(ByRef::No, Mutability::Mut) } - BindingAnnotation(ByRef::No, mutbl) => BindingAnnotation(def_br, mutbl), - BindingAnnotation(ByRef::Yes(_), _) => ba, + BindingMode(ByRef::No, mutbl) => BindingMode(def_br, mutbl), + BindingMode(ByRef::Yes(_), _) => ba, }; // ...and store it in a side table: self.typeck_results.borrow_mut().pat_binding_modes_mut().insert(pat.hir_id, bm); @@ -736,7 +734,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// bindings have the same type by comparing them all against the type of that first pat. fn check_binding_alt_eq_ty( &self, - ba: BindingAnnotation, + ba: BindingMode, span: Span, var_id: HirId, ty: Ty<'tcx>, @@ -776,10 +774,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { span: Span, expected: Ty<'tcx>, actual: Ty<'tcx>, - ba: BindingAnnotation, + ba: BindingMode, ) { match (expected.kind(), actual.kind(), ba) { - (ty::Ref(_, inner_ty, _), _, BindingAnnotation::NONE) + (ty::Ref(_, inner_ty, _), _, BindingMode::NONE) if self.can_eq(self.param_env, *inner_ty, actual) => { err.span_suggestion_verbose( @@ -789,7 +787,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Applicability::MaybeIncorrect, ); } - (_, ty::Ref(_, inner_ty, _), BindingAnnotation::REF) + (_, ty::Ref(_, inner_ty, _), BindingMode::REF) if self.can_eq(self.param_env, expected, *inner_ty) => { err.span_suggestion_verbose( @@ -881,7 +879,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let PatKind::Ref(the_ref, _) = i.kind && let PatKind::Binding(mt, _, ident, _) = the_ref.kind { - let BindingAnnotation(_, mtblty) = mt; + let BindingMode(_, mtblty) = mt; err.span_suggestion_verbose( i.span, format!("consider removing `&{mutability}` from the pattern"), diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index 60a5838cafc..2bf4f51a803 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -229,8 +229,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { else { bug!(); }; - let hir::PatKind::Binding(hir::BindingAnnotation(hir::ByRef::No, _), _, _, _) = - pat.kind + let hir::PatKind::Binding(hir::BindingMode(hir::ByRef::No, _), _, _, _) = pat.kind else { // Complex pattern, skip the non-upvar local. continue; diff --git a/compiler/rustc_index/src/bit_set.rs b/compiler/rustc_index/src/bit_set.rs index c7e563035fc..e37af6610dd 100644 --- a/compiler/rustc_index/src/bit_set.rs +++ b/compiler/rustc_index/src/bit_set.rs @@ -400,7 +400,7 @@ enum Chunk { } // This type is used a lot. Make sure it doesn't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] crate::static_assert_size!(Chunk, 16); impl<T> ChunkedBitSet<T> { diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 255e688fbc1..355fcf59495 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -477,7 +477,7 @@ pub enum SubregionOrigin<'tcx> { } // `SubregionOrigin` is used a lot. Make sure it doesn't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] static_assert_size!(SubregionOrigin<'_>, 32); impl<'tcx> SubregionOrigin<'tcx> { diff --git a/compiler/rustc_infer/src/lib.rs b/compiler/rustc_infer/src/lib.rs index 0444cbe2ee4..a5f52420a84 100644 --- a/compiler/rustc_infer/src/lib.rs +++ b/compiler/rustc_infer/src/lib.rs @@ -32,7 +32,7 @@ #[macro_use] extern crate rustc_macros; -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] #[macro_use] extern crate rustc_data_structures; #[macro_use] diff --git a/compiler/rustc_infer/src/traits/mod.rs b/compiler/rustc_infer/src/traits/mod.rs index 94ad0f5b1c8..7b4e085293c 100644 --- a/compiler/rustc_infer/src/traits/mod.rs +++ b/compiler/rustc_infer/src/traits/mod.rs @@ -112,7 +112,7 @@ impl<'tcx> PolyTraitObligation<'tcx> { } // `PredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] static_assert_size!(PredicateObligation<'_>, 48); pub type PredicateObligations<'tcx> = Vec<PredicateObligation<'tcx>>; diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index 3fe1f21d56a..0b0949e4dd8 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -1056,7 +1056,7 @@ impl UnusedParens { avoid_mut: bool, keep_space: (bool, bool), ) { - use ast::{BindingAnnotation, PatKind}; + use ast::{BindingMode, PatKind}; if let PatKind::Paren(inner) = &value.kind { match inner.kind { @@ -1068,7 +1068,7 @@ impl UnusedParens { // Avoid `p0 | .. | pn` if we should. PatKind::Or(..) if avoid_or => return, // Avoid `mut x` and `mut x @ p` if we should: - PatKind::Ident(BindingAnnotation::MUT, ..) if avoid_mut => { + PatKind::Ident(BindingMode::MUT, ..) if avoid_mut => { return; } // Otherwise proceed with linting. diff --git a/compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp index 64e6c18092f..8871f410e36 100644 --- a/compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/ArchiveWrapper.cpp @@ -175,7 +175,7 @@ extern "C" void LLVMRustArchiveMemberFree(LLVMRustArchiveMemberRef Member) { extern "C" LLVMRustResult LLVMRustWriteArchive(char *Dst, size_t NumMembers, const LLVMRustArchiveMemberRef *NewMembers, - bool WriteSymbtab, LLVMRustArchiveKind RustKind) { + bool WriteSymbtab, LLVMRustArchiveKind RustKind, bool isEC) { std::vector<NewArchiveMember> Members; auto Kind = fromRust(RustKind); @@ -207,7 +207,7 @@ LLVMRustWriteArchive(char *Dst, size_t NumMembers, auto Result = writeArchive(Dst, Members, WriteSymbtab, Kind, true, false); #else auto SymtabMode = WriteSymbtab ? SymtabWritingMode::NormalSymtab : SymtabWritingMode::NoSymtab; - auto Result = writeArchive(Dst, Members, SymtabMode, Kind, true, false); + auto Result = writeArchive(Dst, Members, SymtabMode, Kind, true, false, nullptr, isEC); #endif if (!Result) return LLVMRustResult::Success; diff --git a/compiler/rustc_middle/src/mir/consts.rs b/compiler/rustc_middle/src/mir/consts.rs index 155af062012..adf6801b032 100644 --- a/compiler/rustc_middle/src/mir/consts.rs +++ b/compiler/rustc_middle/src/mir/consts.rs @@ -70,7 +70,7 @@ pub enum ConstValue<'tcx> { }, } -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] static_assert_size!(ConstValue<'_>, 24); impl<'tcx> ConstValue<'tcx> { diff --git a/compiler/rustc_middle/src/mir/interpret/error.rs b/compiler/rustc_middle/src/mir/interpret/error.rs index e9be26d058b..65ce1cd8f50 100644 --- a/compiler/rustc_middle/src/mir/interpret/error.rs +++ b/compiler/rustc_middle/src/mir/interpret/error.rs @@ -88,7 +88,7 @@ pub type EvalToConstValueResult<'tcx> = Result<ConstValue<'tcx>, ErrorHandled>; /// This is needed in `thir::pattern::lower_inline_const`. pub type EvalToValTreeResult<'tcx> = Result<Option<ValTree<'tcx>>, ErrorHandled>; -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] static_assert_size!(InterpErrorInfo<'_>, 8); /// Packages the kind of error we got from the const code interpreter diff --git a/compiler/rustc_middle/src/mir/interpret/value.rs b/compiler/rustc_middle/src/mir/interpret/value.rs index 9f9433e483b..64e7bbdcd99 100644 --- a/compiler/rustc_middle/src/mir/interpret/value.rs +++ b/compiler/rustc_middle/src/mir/interpret/value.rs @@ -37,7 +37,7 @@ pub enum Scalar<Prov = CtfeProvenance> { Ptr(Pointer<Prov>, u8), } -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] static_assert_size!(Scalar, 24); // We want the `Debug` output to be readable as it is used by `derive(Debug)` for diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index df013effcb0..43e4e8216e1 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -18,8 +18,7 @@ use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, ErrorGuaranteed, Into use rustc_hir::def::{CtorKind, Namespace}; use rustc_hir::def_id::{DefId, CRATE_DEF_ID}; use rustc_hir::{ - self as hir, BindingAnnotation, ByRef, CoroutineDesugaring, CoroutineKind, HirId, - ImplicitSelfKind, + self as hir, BindingMode, ByRef, CoroutineDesugaring, CoroutineKind, HirId, ImplicitSelfKind, }; use rustc_session::Session; use rustc_span::source_map::Spanned; @@ -930,7 +929,7 @@ pub enum LocalKind { #[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable)] pub struct VarBindingForm<'tcx> { /// Is variable bound via `x`, `mut x`, `ref x`, `ref mut x`, `mut ref x`, or `mut ref mut x`? - pub binding_mode: BindingAnnotation, + pub binding_mode: BindingMode, /// If an explicit type was provided for this variable binding, /// this holds the source Span of that type. /// @@ -1155,7 +1154,7 @@ impl<'tcx> LocalDecl<'tcx> { self.local_info(), LocalInfo::User( BindingForm::Var(VarBindingForm { - binding_mode: BindingAnnotation(ByRef::No, _), + binding_mode: BindingMode(ByRef::No, _), opt_ty_info: _, opt_match_place: _, pat_span: _, @@ -1172,7 +1171,7 @@ impl<'tcx> LocalDecl<'tcx> { self.local_info(), LocalInfo::User( BindingForm::Var(VarBindingForm { - binding_mode: BindingAnnotation(ByRef::No, _), + binding_mode: BindingMode(ByRef::No, _), opt_ty_info: _, opt_match_place: _, pat_span: _, @@ -1814,7 +1813,7 @@ impl DefLocation { } // Some nodes are used a lot. Make sure they don't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] mod size_asserts { use super::*; use rustc_data_structures::static_assert_size; diff --git a/compiler/rustc_middle/src/mir/query.rs b/compiler/rustc_middle/src/mir/query.rs index 0f622127430..105f30f1db8 100644 --- a/compiler/rustc_middle/src/mir/query.rs +++ b/compiler/rustc_middle/src/mir/query.rs @@ -213,7 +213,7 @@ pub struct ClosureOutlivesRequirement<'tcx> { } // Make sure this enum doesn't unintentionally grow -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] rustc_data_structures::static_assert_size!(ConstraintCategory<'_>, 16); /// Outlives-constraints can be categorized to determine whether and why they diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index 9b409574026..97c3eb55638 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -1453,7 +1453,7 @@ pub enum BinOp { } // Some nodes are used a lot. Make sure they don't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] mod size_asserts { use super::*; // tidy-alphabetical-start diff --git a/compiler/rustc_middle/src/mir/tcx.rs b/compiler/rustc_middle/src/mir/tcx.rs index b86aa601ce8..506003ff7c0 100644 --- a/compiler/rustc_middle/src/mir/tcx.rs +++ b/compiler/rustc_middle/src/mir/tcx.rs @@ -14,7 +14,7 @@ pub struct PlaceTy<'tcx> { } // At least on 64 bit systems, `PlaceTy` should not be larger than two or three pointers. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] static_assert_size!(PlaceTy<'_>, 16); impl<'tcx> PlaceTy<'tcx> { diff --git a/compiler/rustc_middle/src/query/plumbing.rs b/compiler/rustc_middle/src/query/plumbing.rs index 643861972c4..038d3fe93c4 100644 --- a/compiler/rustc_middle/src/query/plumbing.rs +++ b/compiler/rustc_middle/src/query/plumbing.rs @@ -322,7 +322,7 @@ macro_rules! define_callbacks { // Ensure that keys grow no larger than 72 bytes by accident. // Increase this limit if necessary, but do try to keep the size low if possible - #[cfg(all(any(target_arch = "x86_64", target_arch="aarch64"), target_pointer_width = "64"))] + #[cfg(target_pointer_width = "64")] const _: () = { if mem::size_of::<Key<'static>>() > 72 { panic!("{}", concat!( @@ -337,7 +337,7 @@ macro_rules! define_callbacks { // Ensure that values grow no larger than 64 bytes by accident. // Increase this limit if necessary, but do try to keep the size low if possible - #[cfg(all(any(target_arch = "x86_64", target_arch="aarch64"), target_pointer_width = "64"))] + #[cfg(target_pointer_width = "64")] const _: () = { if mem::size_of::<Value<'static>>() > 64 { panic!("{}", concat!( diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index 8763e94c8b0..9821b57b4a2 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -12,7 +12,7 @@ use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; use rustc_errors::{DiagArgValue, IntoDiagArg}; use rustc_hir as hir; use rustc_hir::def_id::DefId; -use rustc_hir::{BindingAnnotation, ByRef, HirId, MatchSource, RangeEnd}; +use rustc_hir::{BindingMode, ByRef, HirId, MatchSource, RangeEnd}; use rustc_index::newtype_index; use rustc_index::IndexVec; use rustc_middle::middle::region; @@ -603,10 +603,7 @@ impl<'tcx> Pat<'tcx> { pub fn simple_ident(&self) -> Option<Symbol> { match self.kind { PatKind::Binding { - name, - mode: BindingAnnotation(ByRef::No, _), - subpattern: None, - .. + name, mode: BindingMode(ByRef::No, _), subpattern: None, .. } => Some(name), _ => None, } @@ -730,7 +727,7 @@ pub enum PatKind<'tcx> { Binding { name: Symbol, #[type_visitable(ignore)] - mode: BindingAnnotation, + mode: BindingMode, #[type_visitable(ignore)] var: LocalVarId, ty: Ty<'tcx>, @@ -1206,7 +1203,7 @@ impl<'tcx> fmt::Display for Pat<'tcx> { } // Some nodes are used a lot. Make sure they don't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] mod size_asserts { use super::*; // tidy-alphabetical-start diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index 28f6184a34e..ceee3ea48e3 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -551,7 +551,7 @@ impl<'tcx> ObligationCauseCode<'tcx> { } // `ObligationCauseCode` is used a lot. Make sure it doesn't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] static_assert_size!(ObligationCauseCode<'_>, 48); #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] diff --git a/compiler/rustc_middle/src/ty/consts.rs b/compiler/rustc_middle/src/ty/consts.rs index 49b806b8369..e03b6fbb1b8 100644 --- a/compiler/rustc_middle/src/ty/consts.rs +++ b/compiler/rustc_middle/src/ty/consts.rs @@ -22,6 +22,9 @@ pub use valtree::*; pub type ConstKind<'tcx> = IrConstKind<TyCtxt<'tcx>>; +#[cfg(target_pointer_width = "64")] +static_assert_size!(ConstKind<'_>, 32); + /// Use this rather than `ConstData`, whenever possible. #[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)] #[rustc_pass_by_value] @@ -59,7 +62,7 @@ pub struct ConstData<'tcx> { pub kind: ConstKind<'tcx>, } -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] static_assert_size!(ConstData<'_>, 40); impl<'tcx> Const<'tcx> { diff --git a/compiler/rustc_middle/src/ty/consts/kind.rs b/compiler/rustc_middle/src/ty/consts/kind.rs index 94e41709f5d..a7e0a0402ce 100644 --- a/compiler/rustc_middle/src/ty/consts/kind.rs +++ b/compiler/rustc_middle/src/ty/consts/kind.rs @@ -71,8 +71,5 @@ pub enum Expr<'tcx> { Cast(CastKind, Const<'tcx>, Ty<'tcx>), } -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] static_assert_size!(Expr<'_>, 24); - -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] -static_assert_size!(super::ConstKind<'_>, 32); diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index e6b773ae512..d0a69c6fd2c 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -2183,7 +2183,7 @@ pub struct DestructuredConst<'tcx> { } // Some types are used a lot. Make sure they don't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] mod size_asserts { use super::*; use rustc_data_structures::static_assert_size; diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index ad64745d579..6084e8d7cab 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -2697,7 +2697,7 @@ impl<'tcx> VarianceDiagInfo<'tcx> { } // Some types are used a lot. Make sure they don't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] mod size_asserts { use super::*; use rustc_data_structures::static_assert_size; diff --git a/compiler/rustc_middle/src/ty/typeck_results.rs b/compiler/rustc_middle/src/ty/typeck_results.rs index 818fb78793e..a28afcc4fb8 100644 --- a/compiler/rustc_middle/src/ty/typeck_results.rs +++ b/compiler/rustc_middle/src/ty/typeck_results.rs @@ -17,7 +17,7 @@ use rustc_hir::{ def::{DefKind, Res}, def_id::{DefId, LocalDefId, LocalDefIdMap}, hir_id::OwnerId, - BindingAnnotation, ByRef, HirId, ItemLocalId, ItemLocalMap, ItemLocalSet, Mutability, + BindingMode, ByRef, HirId, ItemLocalId, ItemLocalMap, ItemLocalSet, Mutability, }; use rustc_index::IndexVec; use rustc_macros::HashStable; @@ -78,8 +78,8 @@ pub struct TypeckResults<'tcx> { adjustments: ItemLocalMap<Vec<ty::adjustment::Adjustment<'tcx>>>, - /// Stores the actual binding mode for all instances of [`BindingAnnotation`]. - pat_binding_modes: ItemLocalMap<BindingAnnotation>, + /// Stores the actual binding mode for all instances of [`BindingMode`]. + pat_binding_modes: ItemLocalMap<BindingMode>, /// Stores the types which were implicitly dereferenced in pattern binding modes /// for later usage in THIR lowering. For example, @@ -413,22 +413,17 @@ impl<'tcx> TypeckResults<'tcx> { matches!(self.type_dependent_defs().get(expr.hir_id), Some(Ok((DefKind::AssocFn, _)))) } - pub fn extract_binding_mode( - &self, - s: &Session, - id: HirId, - sp: Span, - ) -> Option<BindingAnnotation> { + pub fn extract_binding_mode(&self, s: &Session, id: HirId, sp: Span) -> Option<BindingMode> { self.pat_binding_modes().get(id).copied().or_else(|| { s.dcx().span_bug(sp, "missing binding mode"); }) } - pub fn pat_binding_modes(&self) -> LocalTableInContext<'_, BindingAnnotation> { + pub fn pat_binding_modes(&self) -> LocalTableInContext<'_, BindingMode> { LocalTableInContext { hir_owner: self.hir_owner, data: &self.pat_binding_modes } } - pub fn pat_binding_modes_mut(&mut self) -> LocalTableInContextMut<'_, BindingAnnotation> { + pub fn pat_binding_modes_mut(&mut self) -> LocalTableInContextMut<'_, BindingMode> { LocalTableInContextMut { hir_owner: self.hir_owner, data: &mut self.pat_binding_modes } } @@ -460,7 +455,7 @@ impl<'tcx> TypeckResults<'tcx> { let mut has_ref_mut = false; pat.walk(|pat| { if let hir::PatKind::Binding(_, id, _, _) = pat.kind - && let Some(BindingAnnotation(ByRef::Yes(Mutability::Mut), _)) = + && let Some(BindingMode(ByRef::Yes(Mutability::Mut), _)) = self.pat_binding_modes().get(id) { has_ref_mut = true; diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index 367c391b45a..9730473c428 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/build/matches/mod.rs @@ -14,7 +14,7 @@ use rustc_data_structures::{ fx::{FxHashSet, FxIndexMap, FxIndexSet}, stack::ensure_sufficient_stack, }; -use rustc_hir::{BindingAnnotation, ByRef}; +use rustc_hir::{BindingMode, ByRef}; use rustc_middle::middle::region; use rustc_middle::mir::{self, *}; use rustc_middle::thir::{self, *}; @@ -385,15 +385,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let fake_borrows = match_has_guard .then(|| util::FakeBorrowCollector::collect_fake_borrows(self, candidates)); + // See the doc comment on `match_candidates` for why we have an + // otherwise block. Match checking will ensure this is actually + // unreachable. let otherwise_block = self.cfg.start_new_block(); // This will generate code to test scrutinee_place and // branch to the appropriate arm block self.match_candidates(match_start_span, scrutinee_span, block, otherwise_block, candidates); - // See the doc comment on `match_candidates` for why we may have an - // otherwise block. Match checking will ensure this is actually - // unreachable. let source_info = self.source_info(scrutinee_span); // Matching on a `scrutinee_place` with an uninhabited type doesn't @@ -621,12 +621,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ) -> BlockAnd<()> { match irrefutable_pat.kind { // Optimize the case of `let x = ...` to write directly into `x` - PatKind::Binding { - mode: BindingAnnotation(ByRef::No, _), - var, - subpattern: None, - .. - } => { + PatKind::Binding { mode: BindingMode(ByRef::No, _), var, subpattern: None, .. } => { let place = self.storage_live_binding(block, var, irrefutable_pat.span, OutsideGuard, true); unpack!(block = self.expr_into_dest(place, block, initializer_id)); @@ -652,7 +647,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { box Pat { kind: PatKind::Binding { - mode: BindingAnnotation(ByRef::No, _), + mode: BindingMode(ByRef::No, _), var, subpattern: None, .. @@ -893,7 +888,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { f: &mut impl FnMut( &mut Self, Symbol, - BindingAnnotation, + BindingMode, LocalVarId, Span, Ty<'tcx>, @@ -1148,7 +1143,7 @@ struct Binding<'tcx> { span: Span, source: Place<'tcx>, var_id: LocalVarId, - binding_mode: BindingAnnotation, + binding_mode: BindingMode, } /// Indicates that the type of `source` must be a subtype of the @@ -2412,7 +2407,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { source_info: SourceInfo, visibility_scope: SourceScope, name: Symbol, - mode: BindingAnnotation, + mode: BindingMode, var_id: LocalVarId, var_ty: Ty<'tcx>, user_ty: UserTypeProjections, diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index b5d72619a38..cc525f2ac2f 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -9,7 +9,7 @@ use rustc_data_structures::sorted_map::SortedIndexMultiMap; use rustc_errors::ErrorGuaranteed; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_hir::{self as hir, BindingAnnotation, ByRef, HirId, Node}; +use rustc_hir::{self as hir, BindingMode, ByRef, HirId, Node}; use rustc_index::bit_set::GrowableBitSet; use rustc_index::{Idx, IndexSlice, IndexVec}; use rustc_infer::infer::{InferCtxt, TyCtxtInferExt}; @@ -931,7 +931,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // Don't introduce extra copies for simple bindings PatKind::Binding { var, - mode: BindingAnnotation(ByRef::No, mutability), + mode: BindingMode(ByRef::No, mutability), subpattern: None, .. } => { @@ -941,7 +941,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { if let Some(kind) = param.self_kind { LocalInfo::User(BindingForm::ImplicitSelf(kind)) } else { - let binding_mode = BindingAnnotation(ByRef::No, mutability); + let binding_mode = BindingMode(ByRef::No, mutability); LocalInfo::User(BindingForm::Var(VarBindingForm { binding_mode, opt_ty_info: param.ty_span, diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index 9ee0fb79bf4..0c1e1d59c4f 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -2,7 +2,7 @@ use crate::build::ExprCategory; use crate::errors::*; use rustc_errors::DiagArgValue; -use rustc_hir::{self as hir, BindingAnnotation, ByRef, HirId, Mutability}; +use rustc_hir::{self as hir, BindingMode, ByRef, HirId, Mutability}; use rustc_middle::mir::BorrowKind; use rustc_middle::thir::visit::Visitor; use rustc_middle::thir::*; @@ -288,7 +288,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> { visit::walk_pat(self, pat); } } - PatKind::Binding { mode: BindingAnnotation(ByRef::Yes(rm), _), ty, .. } => { + PatKind::Binding { mode: BindingMode(ByRef::Yes(rm), _), ty, .. } => { if self.inside_adt { let ty::Ref(_, ty, _) = ty.kind() else { span_bug!( 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 03195a122b4..241d38f90d2 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -15,7 +15,7 @@ use rustc_errors::{ }; use rustc_hir::def::*; use rustc_hir::def_id::LocalDefId; -use rustc_hir::{self as hir, BindingAnnotation, ByRef, HirId}; +use rustc_hir::{self as hir, BindingMode, ByRef, HirId}; use rustc_middle::middle::limits::get_limit_size; use rustc_middle::thir::visit::Visitor; use rustc_middle::thir::*; @@ -839,7 +839,7 @@ fn check_for_bindings_named_same_as_variants( ) { if let PatKind::Binding { name, - mode: BindingAnnotation(ByRef::No, Mutability::Not), + mode: BindingMode(ByRef::No, Mutability::Not), subpattern: None, ty, .. diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index 60513a674af..625d8f53939 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -11,7 +11,7 @@ use rustc_middle::mir::visit::*; use rustc_middle::mir::*; use rustc_middle::ty::TypeVisitableExt; use rustc_middle::ty::{self, Instance, InstanceDef, ParamEnv, Ty, TyCtxt}; -use rustc_session::config::OptLevel; +use rustc_session::config::{DebugInfo, OptLevel}; use rustc_span::source_map::Spanned; use rustc_span::sym; use rustc_target::abi::FieldIdx; @@ -699,7 +699,19 @@ impl<'tcx> Inliner<'tcx> { // Insert all of the (mapped) parts of the callee body into the caller. caller_body.local_decls.extend(callee_body.drain_vars_and_temps()); caller_body.source_scopes.extend(&mut callee_body.source_scopes.drain(..)); - caller_body.var_debug_info.append(&mut callee_body.var_debug_info); + if self + .tcx + .sess + .opts + .unstable_opts + .inline_mir_preserve_debug + .unwrap_or(self.tcx.sess.opts.debuginfo != DebugInfo::None) + { + // Note that we need to preserve these in the standard library so that + // people working on rust can build with or without debuginfo while + // still getting consistent results from the mir-opt tests. + caller_body.var_debug_info.append(&mut callee_body.var_debug_info); + } caller_body.basic_blocks_mut().extend(callee_body.basic_blocks_mut().drain(..)); caller_body[callsite.block].terminator = Some(Terminator { diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index 1c1ca0bac81..058539e1717 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -30,7 +30,7 @@ use unescape_error_reporting::{emit_unescape_error, escaped_char}; // // This assertion is in this crate, rather than in `rustc_lexer`, because that // crate cannot depend on `rustc_data_structures`. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] rustc_data_structures::static_assert_size!(rustc_lexer::Token, 12); #[derive(Clone, Debug)] diff --git a/compiler/rustc_parse/src/parser/attr_wrapper.rs b/compiler/rustc_parse/src/parser/attr_wrapper.rs index baaed5ec37b..62c8f9f5dac 100644 --- a/compiler/rustc_parse/src/parser/attr_wrapper.rs +++ b/compiler/rustc_parse/src/parser/attr_wrapper.rs @@ -454,7 +454,7 @@ fn make_token_stream( } // Some types are used a lot. Make sure they don't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] mod size_asserts { use super::*; use rustc_data_structures::static_assert_size; diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 64f766543a7..f256dbf4360 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -29,7 +29,7 @@ use rustc_ast::token::{self, Delimiter, Lit, LitKind, Token, TokenKind}; use rustc_ast::tokenstream::AttrTokenTree; use rustc_ast::util::parser::AssocOp; use rustc_ast::{ - AngleBracketedArg, AngleBracketedArgs, AnonConst, AttrVec, BinOpKind, BindingAnnotation, Block, + AngleBracketedArg, AngleBracketedArgs, AnonConst, AttrVec, BinOpKind, BindingMode, Block, BlockCheckMode, Expr, ExprKind, GenericArg, Generics, HasTokens, Item, ItemKind, Param, Pat, PatKind, Path, PathSegment, QSelf, Ty, TyKind, }; @@ -51,7 +51,7 @@ use thin_vec::{thin_vec, ThinVec}; pub(super) fn dummy_arg(ident: Ident, guar: ErrorGuaranteed) -> Param { let pat = P(Pat { id: ast::DUMMY_NODE_ID, - kind: PatKind::Ident(BindingAnnotation::NONE, ident, None), + kind: PatKind::Ident(BindingMode::NONE, ident, None), span: ident.span, tokens: None, }); @@ -2787,7 +2787,7 @@ impl<'a> Parser<'a> { } _ => {} }, - PatKind::Ident(BindingAnnotation::NONE, ident, None) => { + PatKind::Ident(BindingMode::NONE, ident, None) => { match &first_pat.kind { PatKind::Ident(_, old_ident, _) => { let path = PatKind::Path( diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 8ae809f566b..84ecd0a0de5 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -2712,7 +2712,7 @@ impl<'a> Parser<'a> { match ty { Ok(ty) => { let ident = Ident::new(kw::Empty, this.prev_token.span); - let bm = BindingAnnotation::NONE; + let bm = BindingMode::NONE; let pat = this.mk_pat_ident(ty.span, bm, ident); (pat, ty) } diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index a4a9ba9d229..4a996f89a9a 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -179,7 +179,7 @@ pub struct Parser<'a> { // This type is used a lot, e.g. it's cloned when matching many declarative macro rules with nonterminals. Make sure // it doesn't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] rustc_data_structures::static_assert_size!(Parser<'_>, 264); /// Stores span information about a closure. diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index dd1ecf9b7c1..78d3d019bf4 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -16,8 +16,8 @@ use rustc_ast::mut_visit::{noop_visit_pat, MutVisitor}; use rustc_ast::ptr::P; use rustc_ast::token::{self, BinOpToken, Delimiter, Token}; use rustc_ast::{ - self as ast, AttrVec, BindingAnnotation, ByRef, Expr, ExprKind, MacCall, Mutability, Pat, - PatField, PatFieldsRest, PatKind, Path, QSelf, RangeEnd, RangeSyntax, + self as ast, AttrVec, BindingMode, ByRef, Expr, ExprKind, MacCall, Mutability, Pat, PatField, + PatFieldsRest, PatKind, Path, QSelf, RangeEnd, RangeSyntax, }; use rustc_ast_pretty::pprust; use rustc_errors::{Applicability, Diag, PResult}; @@ -486,7 +486,7 @@ impl<'a> Parser<'a> { } // Parse ref ident @ pat / ref mut ident @ pat let mutbl = self.parse_mutability(); - self.parse_pat_ident(BindingAnnotation(ByRef::Yes(mutbl), Mutability::Not), syntax_loc)? + self.parse_pat_ident(BindingMode(ByRef::Yes(mutbl), Mutability::Not), syntax_loc)? } else if self.eat_keyword(kw::Box) { self.parse_pat_box()? } else if self.check_inline_const(0) { @@ -511,7 +511,7 @@ impl<'a> Parser<'a> { // Parse `ident @ pat` // This can give false positives and parse nullary enums, // they are dealt with later in resolve. - self.parse_pat_ident(BindingAnnotation::NONE, syntax_loc)? + self.parse_pat_ident(BindingMode::NONE, syntax_loc)? } else if self.is_start_of_pat_with_path() { // Parse pattern starting with a path let (qself, path) = if self.eat_lt() { @@ -766,8 +766,7 @@ impl<'a> Parser<'a> { let mut pat = self.parse_pat_no_top_alt(Some(Expected::Identifier), None)?; // If we don't have `mut $ident (@ pat)?`, error. - if let PatKind::Ident(BindingAnnotation(br @ ByRef::No, m @ Mutability::Not), ..) = - &mut pat.kind + if let PatKind::Ident(BindingMode(br @ ByRef::No, m @ Mutability::Not), ..) = &mut pat.kind { // Don't recurse into the subpattern. // `mut` on the outer binding doesn't affect the inner bindings. @@ -779,8 +778,7 @@ impl<'a> Parser<'a> { self.ban_mut_general_pat(mut_span, &pat, changed_any_binding); } - if matches!(pat.kind, PatKind::Ident(BindingAnnotation(ByRef::Yes(_), Mutability::Mut), ..)) - { + if matches!(pat.kind, PatKind::Ident(BindingMode(ByRef::Yes(_), Mutability::Mut), ..)) { self.psess.gated_spans.gate(sym::mut_ref, pat.span); } Ok(pat.into_inner().kind) @@ -792,7 +790,7 @@ impl<'a> Parser<'a> { struct AddMut(bool); impl MutVisitor for AddMut { fn visit_pat(&mut self, pat: &mut P<Pat>) { - if let PatKind::Ident(BindingAnnotation(ByRef::No, m @ Mutability::Not), ..) = + if let PatKind::Ident(BindingMode(ByRef::No, m @ Mutability::Not), ..) = &mut pat.kind { self.0 = true; @@ -1025,7 +1023,7 @@ impl<'a> Parser<'a> { /// error message when parsing mistakes like `ref foo(a, b)`. fn parse_pat_ident( &mut self, - binding_annotation: BindingAnnotation, + binding_annotation: BindingMode, syntax_loc: Option<PatternLocation>, ) -> PResult<'a, PatKind> { let ident = self.parse_ident_common(false)?; @@ -1163,7 +1161,7 @@ impl<'a> Parser<'a> { None }; - Ok(PatKind::Ident(BindingAnnotation::NONE, Ident::new(kw::Box, box_span), sub)) + Ok(PatKind::Ident(BindingMode::NONE, Ident::new(kw::Box, box_span), sub)) } else { let pat = self.parse_pat_with_range_pat(false, None, None)?; self.psess.gated_spans.gate(sym::box_patterns, box_span.to(self.prev_token.span)); @@ -1344,7 +1342,7 @@ impl<'a> Parser<'a> { if let Some(last) = fields.iter().last() && last.is_shorthand && let PatKind::Ident(binding, ident, None) = last.pat.kind - && binding != BindingAnnotation::NONE + && binding != BindingMode::NONE && self.token == token::Colon // We found `ref mut? ident:`, try to parse a `name,` or `name }`. && let Some(name_span) = self.look_ahead(1, |t| t.is_ident().then(|| t.span)) @@ -1400,7 +1398,7 @@ impl<'a> Parser<'a> { let fieldname = self.parse_field_name()?; hi = self.prev_token.span; - let ann = BindingAnnotation(by_ref, mutability); + let ann = BindingMode(by_ref, mutability); let fieldpat = self.mk_pat_ident(boxed_span.to(hi), ann, fieldname); let subpat = if is_box { self.mk_pat(lo.to(hi), PatKind::Box(fieldpat)) } else { fieldpat }; @@ -1418,7 +1416,7 @@ impl<'a> Parser<'a> { }) } - pub(super) fn mk_pat_ident(&self, span: Span, ann: BindingAnnotation, ident: Ident) -> P<Pat> { + pub(super) fn mk_pat_ident(&self, span: Span, ann: BindingMode, ident: Ident) -> P<Pat> { self.mk_pat(span, PatKind::Ident(ann, ident, None)) } diff --git a/compiler/rustc_parse_format/src/lib.rs b/compiler/rustc_parse_format/src/lib.rs index ccda43c827c..faf6ca78467 100644 --- a/compiler/rustc_parse_format/src/lib.rs +++ b/compiler/rustc_parse_format/src/lib.rs @@ -1087,7 +1087,7 @@ fn unescape_string(string: &str) -> Option<string::String> { } // Assert a reasonable size for `Piece` -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] rustc_index::static_assert_size!(Piece<'_>, 16); #[cfg(test)] diff --git a/compiler/rustc_passes/src/naked_functions.rs b/compiler/rustc_passes/src/naked_functions.rs index a1f37ee3b83..d45ee32a624 100644 --- a/compiler/rustc_passes/src/naked_functions.rs +++ b/compiler/rustc_passes/src/naked_functions.rs @@ -83,8 +83,7 @@ fn check_abi(tcx: TyCtxt<'_>, def_id: LocalDefId, abi: Abi) { fn check_no_patterns(tcx: TyCtxt<'_>, params: &[hir::Param<'_>]) { for param in params { match param.pat.kind { - hir::PatKind::Wild - | hir::PatKind::Binding(hir::BindingAnnotation::NONE, _, _, None) => {} + hir::PatKind::Wild | hir::PatKind::Binding(hir::BindingMode::NONE, _, _, None) => {} _ => { tcx.dcx().emit_err(NoPatterns { span: param.pat.span }); } diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index ba1391bc378..753ba09d886 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -46,7 +46,7 @@ use diagnostics::{ElisionFnParameter, LifetimeElisionCandidate, MissingLifetime} #[derive(Copy, Clone, Debug)] struct BindingInfo { span: Span, - annotation: BindingAnnotation, + annotation: BindingMode, } #[derive(Copy, Clone, PartialEq, Eq, Debug)] @@ -3655,14 +3655,14 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> { fn try_resolve_as_non_binding( &mut self, pat_src: PatternSource, - ann: BindingAnnotation, + ann: BindingMode, ident: Ident, has_sub: bool, ) -> Option<Res> { // An immutable (no `mut`) by-value (no `ref`) binding pattern without // a sub pattern (no `@ $pat`) is syntactically ambiguous as it could // also be interpreted as a path to e.g. a constant, variant, etc. - let is_syntactic_ambiguity = !has_sub && ann == BindingAnnotation::NONE; + let is_syntactic_ambiguity = !has_sub && ann == BindingMode::NONE; let ls_binding = self.maybe_resolve_ident_in_lexical_scope(ident, ValueNS)?; let (res, binding) = match ls_binding { diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index c4d802a222b..6a2975263cf 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1717,6 +1717,9 @@ options! { "enable MIR inlining (default: no)"), inline_mir_hint_threshold: Option<usize> = (None, parse_opt_number, [TRACKED], "inlining threshold for functions with inline hint (default: 100)"), + inline_mir_preserve_debug: Option<bool> = (None, parse_opt_bool, [TRACKED], + "when MIR inlining, whether to preserve debug info for callee variables \ + (default: preserve for debuginfo != None, otherwise remove)"), inline_mir_threshold: Option<usize> = (None, parse_opt_number, [TRACKED], "a default MIR inlining threshold (default: 50)"), input_stats: bool = (false, parse_bool, [UNTRACKED], diff --git a/compiler/rustc_target/src/abi/call/mod.rs b/compiler/rustc_target/src/abi/call/mod.rs index 4502df339d1..c29a5960aa8 100644 --- a/compiler/rustc_target/src/abi/call/mod.rs +++ b/compiler/rustc_target/src/abi/call/mod.rs @@ -947,7 +947,7 @@ impl FromStr for Conv { } // Some types are used a lot. Make sure they don't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] mod size_asserts { use super::*; use rustc_data_structures::static_assert_size; diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index c003982278e..6b171af47de 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -279,9 +279,9 @@ const RISCV_ALLOWED_FEATURES: &[(&str, Stability)] = &[ ("d", Unstable(sym::riscv_target_feature)), ("e", Unstable(sym::riscv_target_feature)), ("f", Unstable(sym::riscv_target_feature)), - ("fast-unaligned-access", Unstable(sym::riscv_target_feature)), ("m", Stable), ("relax", Unstable(sym::riscv_target_feature)), + ("unaligned-scalar-mem", Unstable(sym::riscv_target_feature)), ("v", Unstable(sym::riscv_target_feature)), ("zba", Stable), ("zbb", Stable), diff --git a/compiler/rustc_trait_selection/src/lib.rs b/compiler/rustc_trait_selection/src/lib.rs index 057d00aeae8..d54f714b22c 100644 --- a/compiler/rustc_trait_selection/src/lib.rs +++ b/compiler/rustc_trait_selection/src/lib.rs @@ -31,7 +31,7 @@ #[macro_use] extern crate rustc_macros; -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] #[macro_use] extern crate rustc_data_structures; #[macro_use] diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 4c1784a18e5..db3794c1c40 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -751,9 +751,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { // Get the local name of this closure. This can be inaccurate because // of the possibility of reassignment, but this should be good enough. match &kind { - hir::PatKind::Binding(hir::BindingAnnotation::NONE, _, ident, None) => { - Some(ident.name) - } + hir::PatKind::Binding(hir::BindingMode::NONE, _, ident, None) => Some(ident.name), _ => { err.note(msg); None diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index a04a3bc6ebe..fbff78304ac 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -72,7 +72,7 @@ pub struct PendingPredicateObligation<'tcx> { } // `PendingPredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger. -#[cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] static_assert_size!(PendingPredicateObligation<'_>, 72); impl<'tcx> FulfillmentContext<'tcx> { diff --git a/library/core/src/hint.rs b/library/core/src/hint.rs index b27d0db4619..6e2d88c6b83 100644 --- a/library/core/src/hint.rs +++ b/library/core/src/hint.rs @@ -237,7 +237,7 @@ pub fn spin_loop() { crate::arch::riscv64::pause(); } - #[cfg(target_arch = "aarch64")] + #[cfg(any(target_arch = "aarch64", target_arch = "arm64ec"))] { // SAFETY: the `cfg` attr ensures that we only execute this on aarch64 targets. unsafe { crate::arch::aarch64::__isb(crate::arch::aarch64::SY) }; diff --git a/library/core/src/str/converts.rs b/library/core/src/str/converts.rs index ba282f09d20..b6ffb0a608d 100644 --- a/library/core/src/str/converts.rs +++ b/library/core/src/str/converts.rs @@ -239,7 +239,7 @@ pub const unsafe fn from_raw_parts<'a>(ptr: *const u8, len: usize) -> &'a str { #[must_use] #[unstable(feature = "str_from_raw_parts", issue = "119206")] #[rustc_const_unstable(feature = "const_str_from_raw_parts_mut", issue = "119206")] -pub const unsafe fn from_raw_parts_mut<'a>(ptr: *mut u8, len: usize) -> &'a str { +pub const unsafe fn from_raw_parts_mut<'a>(ptr: *mut u8, len: usize) -> &'a mut str { // SAFETY: the caller must uphold the safety contract for `from_raw_parts_mut`. unsafe { &mut *ptr::from_raw_parts_mut(ptr.cast(), len) } } diff --git a/library/panic_abort/src/lib.rs b/library/panic_abort/src/lib.rs index a6d07fd1984..353de8c5c57 100644 --- a/library/panic_abort/src/lib.rs +++ b/library/panic_abort/src/lib.rs @@ -8,6 +8,7 @@ #![doc(issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")] #![panic_runtime] #![allow(unused_features)] +#![feature(asm_experimental_arch)] #![feature(core_intrinsics)] #![feature(panic_runtime)] #![feature(std_internals)] @@ -78,7 +79,7 @@ pub unsafe fn __rust_start_panic(_payload: &mut dyn PanicPayload) -> u32 { core::arch::asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); } else if #[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))] { core::arch::asm!(".inst 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); - } else if #[cfg(target_arch = "aarch64")] { + } else if #[cfg(any(target_arch = "aarch64", target_arch = "arm64ec"))] { core::arch::asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); } else { core::intrinsics::abort(); diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index d152626d86a..241a443fab9 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -277,6 +277,7 @@ #![feature(allocator_internals)] #![feature(allow_internal_unsafe)] #![feature(allow_internal_unstable)] +#![feature(asm_experimental_arch)] #![feature(c_unwind)] #![feature(cfg_sanitizer_cfi)] #![feature(cfg_target_thread_local)] diff --git a/library/std/src/sys/pal/common/alloc.rs b/library/std/src/sys/pal/common/alloc.rs index 8cf9ef68047..598b6db71f5 100644 --- a/library/std/src/sys/pal/common/alloc.rs +++ b/library/std/src/sys/pal/common/alloc.rs @@ -23,6 +23,7 @@ pub const MIN_ALIGN: usize = 8; #[cfg(any( target_arch = "x86_64", target_arch = "aarch64", + target_arch = "arm64ec", target_arch = "loongarch64", target_arch = "mips64", target_arch = "mips64r6", diff --git a/library/std/src/sys/pal/windows/c/windows_sys.rs b/library/std/src/sys/pal/windows/c/windows_sys.rs index d180122d735..1da8871ae44 100644 --- a/library/std/src/sys/pal/windows/c/windows_sys.rs +++ b/library/std/src/sys/pal/windows/c/windows_sys.rs @@ -1,4 +1,4 @@ -// Bindings generated by `windows-bindgen` 0.55.0 +// Bindings generated by `windows-bindgen` 0.56.0 #![allow(non_snake_case, non_upper_case_globals, non_camel_case_types, dead_code, clippy::all)] #[link(name = "advapi32")] @@ -345,7 +345,7 @@ extern "system" { } #[link(name = "kernel32")] extern "system" { - pub fn GetSystemTimePreciseAsFileTime(lpsystemtimeasfiletime: *mut FILETIME) -> (); + pub fn GetSystemTimePreciseAsFileTime(lpsystemtimeasfiletime: *mut FILETIME); } #[link(name = "kernel32")] extern "system" { @@ -1018,7 +1018,7 @@ impl Clone for CONTEXT_0_0 { } } #[repr(C)] -#[cfg(target_arch = "x86_64")] +#[cfg(any(target_arch = "arm64ec", target_arch = "x86_64"))] pub struct CONTEXT { pub P1Home: u64, pub P2Home: u64, @@ -1067,30 +1067,30 @@ pub struct CONTEXT { pub LastExceptionToRip: u64, pub LastExceptionFromRip: u64, } -#[cfg(target_arch = "x86_64")] +#[cfg(any(target_arch = "arm64ec", target_arch = "x86_64"))] impl Copy for CONTEXT {} -#[cfg(target_arch = "x86_64")] +#[cfg(any(target_arch = "arm64ec", target_arch = "x86_64"))] impl Clone for CONTEXT { fn clone(&self) -> Self { *self } } #[repr(C)] -#[cfg(target_arch = "x86_64")] +#[cfg(any(target_arch = "arm64ec", target_arch = "x86_64"))] pub union CONTEXT_0 { pub FltSave: XSAVE_FORMAT, pub Anonymous: CONTEXT_0_0, } -#[cfg(target_arch = "x86_64")] +#[cfg(any(target_arch = "arm64ec", target_arch = "x86_64"))] impl Copy for CONTEXT_0 {} -#[cfg(target_arch = "x86_64")] +#[cfg(any(target_arch = "arm64ec", target_arch = "x86_64"))] impl Clone for CONTEXT_0 { fn clone(&self) -> Self { *self } } #[repr(C)] -#[cfg(target_arch = "x86_64")] +#[cfg(any(target_arch = "arm64ec", target_arch = "x86_64"))] pub struct CONTEXT_0_0 { pub Header: [M128A; 2], pub Legacy: [M128A; 8], @@ -1111,9 +1111,9 @@ pub struct CONTEXT_0_0 { pub Xmm14: M128A, pub Xmm15: M128A, } -#[cfg(target_arch = "x86_64")] +#[cfg(any(target_arch = "arm64ec", target_arch = "x86_64"))] impl Copy for CONTEXT_0_0 {} -#[cfg(target_arch = "x86_64")] +#[cfg(any(target_arch = "arm64ec", target_arch = "x86_64"))] impl Clone for CONTEXT_0_0 { fn clone(&self) -> Self { *self @@ -3339,7 +3339,7 @@ pub const FILE_WRITE_EA: FILE_ACCESS_RIGHTS = 16u32; pub const FILE_WRITE_THROUGH: NTCREATEFILE_CREATE_OPTIONS = 2u32; pub const FIONBIO: i32 = -2147195266i32; #[repr(C)] -#[cfg(any(target_arch = "aarch64", target_arch = "x86_64"))] +#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] pub struct FLOATING_SAVE_AREA { pub ControlWord: u32, pub StatusWord: u32, @@ -3351,9 +3351,9 @@ pub struct FLOATING_SAVE_AREA { pub RegisterArea: [u8; 80], pub Cr0NpxState: u32, } -#[cfg(any(target_arch = "aarch64", target_arch = "x86_64"))] +#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] impl Copy for FLOATING_SAVE_AREA {} -#[cfg(any(target_arch = "aarch64", target_arch = "x86_64"))] +#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] impl Clone for FLOATING_SAVE_AREA { fn clone(&self) -> Self { *self @@ -4106,7 +4106,7 @@ impl Clone for WSABUF { } } #[repr(C)] -#[cfg(any(target_arch = "aarch64", target_arch = "x86_64"))] +#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] pub struct WSADATA { pub wVersion: u16, pub wHighVersion: u16, @@ -4116,9 +4116,9 @@ pub struct WSADATA { pub szDescription: [i8; 257], pub szSystemStatus: [i8; 129], } -#[cfg(any(target_arch = "aarch64", target_arch = "x86_64"))] +#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] impl Copy for WSADATA {} -#[cfg(any(target_arch = "aarch64", target_arch = "x86_64"))] +#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] impl Clone for WSADATA { fn clone(&self) -> Self { *self @@ -4286,7 +4286,7 @@ pub const WSA_SECURE_HOST_NOT_FOUND: WSA_ERROR = 11032i32; pub const WSA_WAIT_EVENT_0: WSA_ERROR = 0i32; pub const WSA_WAIT_IO_COMPLETION: WSA_ERROR = 192i32; #[repr(C)] -#[cfg(any(target_arch = "aarch64", target_arch = "x86_64"))] +#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] pub struct XSAVE_FORMAT { pub ControlWord: u16, pub StatusWord: u16, @@ -4305,9 +4305,9 @@ pub struct XSAVE_FORMAT { pub XmmRegisters: [M128A; 16], pub Reserved4: [u8; 96], } -#[cfg(any(target_arch = "aarch64", target_arch = "x86_64"))] +#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] impl Copy for XSAVE_FORMAT {} -#[cfg(any(target_arch = "aarch64", target_arch = "x86_64"))] +#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] impl Clone for XSAVE_FORMAT { fn clone(&self) -> Self { *self diff --git a/library/std/src/sys/pal/windows/mod.rs b/library/std/src/sys/pal/windows/mod.rs index a734c2bd4c7..b49585599cb 100644 --- a/library/std/src/sys/pal/windows/mod.rs +++ b/library/std/src/sys/pal/windows/mod.rs @@ -332,7 +332,7 @@ pub fn abort_internal() -> ! { core::arch::asm!("int $$0x29", in("ecx") c::FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); } else if #[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))] { core::arch::asm!(".inst 0xDEFB", in("r0") c::FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); - } else if #[cfg(target_arch = "aarch64")] { + } else if #[cfg(any(target_arch = "aarch64", target_arch = "arm64ec"))] { core::arch::asm!("brk 0xF003", in("x0") c::FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); } else { core::intrinsics::abort(); diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 9420e40d6c2..50149d370d5 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -394,16 +394,13 @@ fn copy_self_contained_objects( target_deps.push((libunwind_path, DependencyType::TargetSelfContained)); } } else if target.contains("-wasi") { - let srcdir = builder - .wasi_root(target) - .unwrap_or_else(|| { - panic!( - "Target {:?} does not have a \"wasi-root\" key in Config.toml", - target.triple - ) - }) - .join("lib") - .join(target.to_string().replace("-preview1", "").replace("p2", "").replace("p1", "")); + let srcdir = builder.wasi_libdir(target).unwrap_or_else(|| { + panic!( + "Target {:?} does not have a \"wasi-root\" key in Config.toml \ + or `$WASI_SDK_PATH` set", + target.triple + ) + }); for &obj in &["libc.a", "crt1-command.o", "crt1-reactor.o"] { copy_and_stamp( builder, @@ -514,12 +511,8 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car } if target.contains("-wasi") { - if let Some(p) = builder.wasi_root(target) { - let root = format!( - "native={}/lib/{}", - p.to_str().unwrap(), - target.to_string().replace("-preview1", "") - ); + if let Some(dir) = builder.wasi_libdir(target) { + let root = format!("native={}", dir.to_str().unwrap()); cargo.rustflag("-L").rustflag(&root); } } diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index 499a74be6b1..27ab6eac03a 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -2102,6 +2102,14 @@ impl<'a> Builder<'a> { // break when incremental compilation is enabled. So this overrides the "no inlining // during incremental builds" heuristic for the standard library. rustflags.arg("-Zinline-mir"); + + // FIXME: always pass this after the next `#[cfg(bootstrap)]` update. + if compiler.stage != 0 { + // Similarly, we need to keep debug info for functions inlined into other std functions, + // even if we're not going to output debuginfo for the crate we're currently building, + // so that it'll be available when downstream consumers of std try to use it. + rustflags.arg("-Zinline-mir-preserve-debug"); + } } if self.config.rustc_parallel diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index f37b0f10437..0b6d987f87d 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -1373,9 +1373,24 @@ impl Build { self.musl_root(target).map(|root| root.join("lib")) } - /// Returns the sysroot for the wasi target, if defined - fn wasi_root(&self, target: TargetSelection) -> Option<&Path> { - self.config.target_config.get(&target).and_then(|t| t.wasi_root.as_ref()).map(|p| &**p) + /// Returns the `lib` directory for the WASI target specified, if + /// configured. + /// + /// This first consults `wasi-root` as configured in per-target + /// configuration, and failing that it assumes that `$WASI_SDK_PATH` is + /// set in the environment, and failing that `None` is returned. + fn wasi_libdir(&self, target: TargetSelection) -> Option<PathBuf> { + let configured = + self.config.target_config.get(&target).and_then(|t| t.wasi_root.as_ref()).map(|p| &**p); + if let Some(path) = configured { + return Some(path.join("lib").join(target.to_string())); + } + let mut env_root = PathBuf::from(std::env::var_os("WASI_SDK_PATH")?); + env_root.push("share"); + env_root.push("wasi-sysroot"); + env_root.push("lib"); + env_root.push(target.to_string()); + Some(env_root) } /// Returns `true` if this is a no-std `target`, if defined diff --git a/src/bootstrap/src/utils/cc_detect.rs b/src/bootstrap/src/utils/cc_detect.rs index 3ba4e0cb686..7e59b7f6f57 100644 --- a/src/bootstrap/src/utils/cc_detect.rs +++ b/src/bootstrap/src/utils/cc_detect.rs @@ -47,7 +47,7 @@ fn cc2ar(cc: &Path, target: TargetSelection) -> Option<PathBuf> { Some(PathBuf::from("ar")) } else if target.contains("vxworks") { Some(PathBuf::from("wr-ar")) - } else if target.contains("android") { + } else if target.contains("android") || target.contains("-wasi") { Some(cc.parent().unwrap().join(PathBuf::from("llvm-ar"))) } else { let parent = cc.parent().unwrap(); @@ -223,6 +223,16 @@ fn default_compiler( } } + t if t.contains("-wasi") => { + let root = PathBuf::from(std::env::var_os("WASI_SDK_PATH")?); + let compiler = match compiler { + Language::C => format!("{t}-clang"), + Language::CPlusPlus => format!("{t}-clang++"), + }; + let compiler = root.join("bin").join(compiler); + Some(compiler) + } + _ => None, } } diff --git a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile index 9b15bb3530b..bb6254942cb 100644 --- a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile @@ -85,11 +85,9 @@ RUN /tmp/build-solaris-toolchain.sh sparcv9 sparcv9 solaris-sparc sun COPY host-x86_64/dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh /tmp/ RUN /tmp/build-x86_64-fortanix-unknown-sgx-toolchain.sh -COPY host-x86_64/dist-various-2/build-wasi-toolchain.sh /tmp/ -RUN /tmp/build-wasi-toolchain.sh - -COPY host-x86_64/dist-various-2/build-wasi-threads-toolchain.sh /tmp/ -RUN /tmp/build-wasi-threads-toolchain.sh +RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0-linux.tar.gz | \ + tar -xz +ENV WASI_SDK_PATH=/tmp/wasi-sdk-22.0 COPY scripts/freebsd-toolchain.sh /tmp/ RUN /tmp/freebsd-toolchain.sh i686 @@ -136,9 +134,6 @@ ENV TARGETS=$TARGETS,x86_64-unknown-uefi RUN ln -s /usr/include/x86_64-linux-gnu/asm /usr/local/include/asm ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --enable-llvm-bitcode-linker --disable-docs \ - --set target.wasm32-wasi.wasi-root=/wasm32-wasip1 \ - --set target.wasm32-wasip1.wasi-root=/wasm32-wasip1 \ - --set target.wasm32-wasip1-threads.wasi-root=/wasm32-wasip1-threads \ --musl-root-armv7=/musl-armv7 ENV SCRIPT python3 ../x.py dist --host='' --target $TARGETS diff --git a/src/ci/docker/host-x86_64/dist-various-2/build-wasi-threads-toolchain.sh b/src/ci/docker/host-x86_64/dist-various-2/build-wasi-threads-toolchain.sh deleted file mode 100755 index 8f802eeaa8c..00000000000 --- a/src/ci/docker/host-x86_64/dist-various-2/build-wasi-threads-toolchain.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -set -ex - -# Originally from https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.4/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04.tar.xz -curl https://ci-mirrors.rust-lang.org/rustc/2023-05-17-clang%2Bllvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04.tar.xz | \ - tar xJf - -bin="$PWD/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin" - -git clone https://github.com/WebAssembly/wasi-libc - -cd wasi-libc -git reset --hard ec4566beae84e54952637f0bf61bee4b4cacc087 -make -j$(nproc) \ - CC="$bin/clang" \ - NM="$bin/llvm-nm" \ - AR="$bin/llvm-ar" \ - THREAD_MODEL=posix \ - INSTALL_DIR=/wasm32-wasip1-threads \ - install - -cd .. -rm -rf wasi-libc -rm -rf clang+llvm* diff --git a/src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh b/src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh deleted file mode 100755 index a2447494078..00000000000 --- a/src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -set -ex - -# Originally from https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.4/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04.tar.xz -curl https://ci-mirrors.rust-lang.org/rustc/2023-05-17-clang%2Bllvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04.tar.xz | \ - tar xJf - -bin="$PWD/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin" - -git clone https://github.com/WebAssembly/wasi-libc - -cd wasi-libc -git reset --hard ec4566beae84e54952637f0bf61bee4b4cacc087 -make -j$(nproc) \ - CC="$bin/clang" \ - NM="$bin/llvm-nm" \ - AR="$bin/llvm-ar" \ - INSTALL_DIR=/wasm32-wasip1 \ - install - -cd .. -rm -rf wasi-libc -rm -rf clang+llvm* diff --git a/src/ci/docker/host-x86_64/test-various/Dockerfile b/src/ci/docker/host-x86_64/test-various/Dockerfile index 4de9afdb171..8875e226fd8 100644 --- a/src/ci/docker/host-x86_64/test-various/Dockerfile +++ b/src/ci/docker/host-x86_64/test-various/Dockerfile @@ -39,14 +39,14 @@ WORKDIR / COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh -COPY host-x86_64/dist-various-2/build-wasi-toolchain.sh /tmp/ -RUN /tmp/build-wasi-toolchain.sh +RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0-linux.tar.gz | \ + tar -xz +ENV WASI_SDK_PATH=/wasi-sdk-22.0 ENV RUST_CONFIGURE_ARGS \ --musl-root-x86_64=/usr/local/x86_64-linux-musl \ --set build.nodejs=/node-v18.12.0-linux-x64/bin/node \ - --set rust.lld \ - --set target.wasm32-wasip1.wasi-root=/wasm32-wasip1 + --set rust.lld # Some run-make tests have assertions about code size, and enabling debug # assertions in libstd causes the binary to be much bigger than it would @@ -68,9 +68,6 @@ ENV WASM_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $WASM_T tests/codegen \ tests/assembly \ library/core -ENV CC_wasm32_wasip1=clang-11 \ - CFLAGS_wasm32_wasip1="--sysroot /wasm32-wasip1" \ - AR_wasm32_wasip1=llvm-ar-11 ENV NVPTX_TARGETS=nvptx64-nvidia-cuda ENV NVPTX_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $NVPTX_TARGETS \ diff --git a/src/doc/rustc/src/platform-support/arm64ec-pc-windows-msvc.md b/src/doc/rustc/src/platform-support/arm64ec-pc-windows-msvc.md index 1bb2c677b08..9fd0ac49881 100644 --- a/src/doc/rustc/src/platform-support/arm64ec-pc-windows-msvc.md +++ b/src/doc/rustc/src/platform-support/arm64ec-pc-windows-msvc.md @@ -11,48 +11,69 @@ applications on AArch64 Windows 11. See <https://learn.microsoft.com/en-us/windo ## Requirements -Target only supports cross-compilation, `core` and `alloc` are supported but -`std` is not. - Builds Arm64EC static and dynamic libraries and executables which can be run on AArch64 Windows 11 devices. Arm64EC static libraries can also be linked into Arm64X dynamic libraries and executables. -Uses `arm64ec` as its `target_arch` - code built for Arm64EC must be compatible -with x86_64 code (e.g., same structure layouts, function signatures, etc.) but -use AArch64 intrinsics. - -Only supported backend is LLVM 18 (or above). +Only supported backend is LLVM 18 or above: +* 18.1.0 added initial support for Arm64EC. +* 18.1.2 fixed import library generation (required for `raw-dylib` support). +* 18.1.4 fixed linking issue for some intrinsics implemented in + `compiler_builtins`. + +### Reusing code from other architectures - x86_64 or AArch64? + +Arm64EC uses `arm64ec` as its `target_arch`, but it is possible to reuse +existing architecture-specific code in most cases. The best mental model for +deciding which architecture to reuse is to is to think of Arm64EC as an x86_64 +process that happens to use the AArch64 instruction set (with some caveats) and +has a completely custom ABI. + +To put this in practice: +* Arm64EC interacts with the operating system, other processes and other DLLs as + x86_64. + - For example, [in `backtrace`](https://github.com/rust-lang/backtrace-rs/commit/ef39a7d7da58b4cae8c8f3fc67a8300fd8d2d0d9) + we use the x86_64 versions of `CONTEXT` and `RtlVirtualUnwind`. + - If you are configuring a search path to find DLLs (e.g., to load plugins or + addons into your application), you should use the same path as the x86_64 + version of your application, not the AArch64 path (since Arm64EC (i.e., + x86_64) processes cannot load native AArch64 DLLs). +* Arm64EC uses AArch64 intrinsics. + - For example, <https://github.com/rust-lang/portable-simd/commit/ca4033f49b1f6019561b8b161b4097b4a07f2e1b> + and <https://github.com/rust-lang/stdarch/commit/166ef7ba22b6a1d908d4b29a36e68ceca324808a>. +* Assembly for AArch64 might be reusable for Arm64EC, but there are many + caveats. For full details see [Microsoft's documentation on the Arm64EC ABI](https://learn.microsoft.com/en-us/windows/arm/arm64ec-abi) + but in brief: + - Arm64EC uses a subset of AArch64 registers. + - Arm64EC uses a different name mangling scheme than AArch64. + - Arm64EC requires entry and exit thunks be generated for some functions. + - Indirect calls must be done via a call checker. + - Control Flow Guard and stack checks use different functions than AArch64. ## Building the target You can build Rust with support for the targets by adding it to the `target` -list in `config.toml` and disabling `std`: +list in `config.toml`: ```toml [build] target = [ "arm64ec-pc-windows-msvc" ] - -[target.arm64ec-pc-windows-msvc] -no-std = true ``` ## Building Rust programs Rust does not yet ship pre-compiled artifacts for this target. To compile for this target, you will either need to build Rust with the target enabled (see -"Building the target" above), or build your own copy of `core` by using -`build-std` or similar. +"Building the target" above), or build your own copy using `build-std` or +similar. ## Testing Tests can be run on AArch64 Windows 11 devices. -Since this is a `no_std` target, the Rust test suite is not supported. - ## Cross-compilation toolchains and C code -C code can be built using the Arm64-targetting MSVC toolchain. +C code can be built using the Arm64-targetting MSVC or Clang toolchain. To compile: diff --git a/src/doc/rustc/src/platform-support/wasm32-wasip1.md b/src/doc/rustc/src/platform-support/wasm32-wasip1.md index a1ca81d1fec..77efa9c3282 100644 --- a/src/doc/rustc/src/platform-support/wasm32-wasip1.md +++ b/src/doc/rustc/src/platform-support/wasm32-wasip1.md @@ -73,19 +73,21 @@ be used instead. ## Building the target -To build this target a compiled version of [`wasi-libc`] is required to be -present at build time. This can be installed through -[`wasi-sdk`](https://github.com/WebAssembly/wasi-sdk) as well. This is the -configured with: - -```toml -[target.wasm32-wasip1] -wasi-root = ".../wasi-libc/sysroot" +To build this target first acquire a copy of +[`wasi-sdk`](https://github.com/WebAssembly/wasi-sdk/). At this time version 22 +is the minimum needed. + +Next configure the `WASI_SDK_PATH` environment variable to point to where this +is installed. For example: + +```text +export WASI_SDK_PATH=/path/to/wasi-sdk-22.0 ``` -Additionally users will need to enable LLD when building Rust from source as -LLVM's `wasm-ld` driver for LLD is required when linking WebAssembly code -together. +Next be sure to enable LLD when building Rust from source as LLVM's `wasm-ld` +driver for LLD is required when linking WebAssembly code together. Rust's build +system will automatically pick up any necessary binaries and programs from +`WASI_SDK_PATH`. ## Building Rust programs @@ -112,8 +114,10 @@ This target can be cross-compiled from any hosts. ## Testing -Currently the WASI target is not tested in rust-lang/rust CI. This means that -tests in the repository are not guaranteed to pass. This is theoretically -possibly by installing a standalone WebAssembly runtime and using it as a -"runner" for all tests, but there are various failures that will need to be -waded through to adjust tests to work on the WASI target. +This target is tested in rust-lang/rust CI on all merges. A subset of tests are +run in the `test-various` builder such as the UI tests and libcore tests. This +can be tested locally, for example, with: + +```text +./x.py test --target wasm32-wasip1 tests/ui +``` diff --git a/src/doc/rustc/src/platform-support/wasm32-wasip2.md b/src/doc/rustc/src/platform-support/wasm32-wasip2.md index 4466d2c0840..a385600cc22 100644 --- a/src/doc/rustc/src/platform-support/wasm32-wasip2.md +++ b/src/doc/rustc/src/platform-support/wasm32-wasip2.md @@ -22,9 +22,34 @@ This target is cross-compiled. The target supports `std` fully. ## Platform requirements -The WebAssembly runtime should support the wasi preview 2 API set. +The WebAssembly runtime should support the wasi preview 2 API set. Runtimes also +are required to support components since this target outputs a component as +opposed to a core wasm module. As of the time of this writing Wasmtime 17 and +above is able to run this target natively with no extra flags. -This target is not a stable target. This means that there are only a few engines -which implement wasi preview 2, for example: +## Building the target -* Wasmtime - `-W component-model` +To build this target first acquire a copy of +[`wasi-sdk`](https://github.com/WebAssembly/wasi-sdk/). At this time version 22 +is the minimum needed. + +Next configure the `WASI_SDK_PATH` environment variable to point to where this +is installed. For example: + +```text +export WASI_SDK_PATH=/path/to/wasi-sdk-22.0 +``` + +Next be sure to enable LLD when building Rust from source as LLVM's `wasm-ld` +driver for LLD is required when linking WebAssembly code together. Rust's build +system will automatically pick up any necessary binaries and programs from +`WASI_SDK_PATH`. + +## Testing + +This target is not tested in CI at this time. Locally it can be tested with a +`wasmtime` binary in `PATH` like so: + +```text +./x.py test --target wasm32-wasip2 tests/ui +``` diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index aeb7137b722..550221adaa8 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -2567,7 +2567,7 @@ pub(crate) enum TypeBindingKind { } // Some nodes are used a lot. Make sure they don't unintentionally get bigger. -#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] mod size_asserts { use super::*; use rustc_data_structures::static_assert_size; diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index 11fc99eb511..a3b88a880f2 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -346,16 +346,28 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { { let desc = short_markdown_summary(&item.doc_value(), &item.link_names(self.cache)); + // For searching purposes, a re-export is a duplicate if: + // + // - It's either an inline, or a true re-export + // - It's got the same name + // - Both of them have the same exact path + let defid = (match &*item.kind { + &clean::ItemKind::ImportItem(ref import) => import.source.did, + _ => None, + }) + .or_else(|| item.item_id.as_def_id()); // In case this is a field from a tuple struct, we don't add it into // the search index because its name is something like "0", which is // not useful for rustdoc search. self.cache.search_index.push(IndexItem { ty, + defid, name: s, path: join_with_double_colon(path), desc, parent, parent_idx: None, + exact_path: None, impl_id: if let Some(ParentStackItem::Impl { item_id, .. }) = self.cache.parent_stack.last() { diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 4cab2d64257..db1119eca1d 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -78,8 +78,10 @@ pub(crate) struct Context<'tcx> { } // `Context` is cloned a lot, so we don't want the size to grow unexpectedly. -#[cfg(all(not(windows), target_arch = "x86_64", target_pointer_width = "64"))] +#[cfg(all(not(windows), target_pointer_width = "64"))] rustc_data_structures::static_assert_size!(Context<'_>, 160); +#[cfg(all(windows, target_pointer_width = "64"))] +rustc_data_structures::static_assert_size!(Context<'_>, 168); /// Shared mutable state used in [`Context`] and elsewhere. pub(crate) struct SharedContext<'tcx> { diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index a949f795753..95e35b665f1 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -111,11 +111,13 @@ pub(crate) enum RenderMode { #[derive(Debug)] pub(crate) struct IndexItem { pub(crate) ty: ItemType, + pub(crate) defid: Option<DefId>, pub(crate) name: Symbol, pub(crate) path: String, pub(crate) desc: String, pub(crate) parent: Option<DefId>, pub(crate) parent_idx: Option<isize>, + pub(crate) exact_path: Option<String>, pub(crate) impl_id: Option<DefId>, pub(crate) search_type: Option<IndexItemFunctionType>, pub(crate) aliases: Box<[Symbol]>, diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs index 7083999de68..6d2bb31ee13 100644 --- a/src/librustdoc/html/render/search_index.rs +++ b/src/librustdoc/html/render/search_index.rs @@ -59,10 +59,13 @@ pub(crate) fn build_index<'tcx>( cache: &mut Cache, tcx: TyCtxt<'tcx>, ) -> SerializedSearchIndex { + // Maps from ID to position in the `crate_paths` array. let mut itemid_to_pathid = FxHashMap::default(); let mut primitives = FxHashMap::default(); let mut associated_types = FxHashMap::default(); - let mut crate_paths = vec![]; + + // item type, display path, re-exported internal path + let mut crate_paths: Vec<(ItemType, Vec<Symbol>, Option<Vec<Symbol>>)> = vec![]; // Attach all orphan items to the type's definition if the type // has since been learned. @@ -72,11 +75,13 @@ pub(crate) fn build_index<'tcx>( let desc = short_markdown_summary(&item.doc_value(), &item.link_names(cache)); cache.search_index.push(IndexItem { ty: item.type_(), + defid: item.item_id.as_def_id(), name: item.name.unwrap(), path: join_with_double_colon(&fqp[..fqp.len() - 1]), desc, parent: Some(parent), parent_idx: None, + exact_path: None, impl_id, search_type: get_function_type_for_search( item, @@ -126,9 +131,10 @@ pub(crate) fn build_index<'tcx>( map: &mut FxHashMap<F, isize>, itemid: F, lastpathid: &mut isize, - crate_paths: &mut Vec<(ItemType, Vec<Symbol>)>, + crate_paths: &mut Vec<(ItemType, Vec<Symbol>, Option<Vec<Symbol>>)>, item_type: ItemType, path: &[Symbol], + exact_path: Option<&[Symbol]>, ) -> RenderTypeId { match map.entry(itemid) { Entry::Occupied(entry) => RenderTypeId::Index(*entry.get()), @@ -136,7 +142,11 @@ pub(crate) fn build_index<'tcx>( let pathid = *lastpathid; entry.insert(pathid); *lastpathid += 1; - crate_paths.push((item_type, path.to_vec())); + crate_paths.push(( + item_type, + path.to_vec(), + exact_path.map(|path| path.to_vec()), + )); RenderTypeId::Index(pathid) } } @@ -149,14 +159,24 @@ pub(crate) fn build_index<'tcx>( primitives: &mut FxHashMap<Symbol, isize>, associated_types: &mut FxHashMap<Symbol, isize>, lastpathid: &mut isize, - crate_paths: &mut Vec<(ItemType, Vec<Symbol>)>, + crate_paths: &mut Vec<(ItemType, Vec<Symbol>, Option<Vec<Symbol>>)>, ) -> Option<RenderTypeId> { - let Cache { ref paths, ref external_paths, .. } = *cache; + let Cache { ref paths, ref external_paths, ref exact_paths, .. } = *cache; match id { RenderTypeId::DefId(defid) => { if let Some(&(ref fqp, item_type)) = paths.get(&defid).or_else(|| external_paths.get(&defid)) { + let exact_fqp = exact_paths + .get(&defid) + .or_else(|| external_paths.get(&defid).map(|&(ref fqp, _)| fqp)) + // Re-exports only count if the name is exactly the same. + // This is a size optimization, since it means we only need + // to store the name once (and the path is re-used for everything + // exported from this same module). It's also likely to Do + // What I Mean, since if a re-export changes the name, it might + // also be a change in semantic meaning. + .filter(|fqp| fqp.last() == fqp.last()); Some(insert_into_map( itemid_to_pathid, ItemId::DefId(defid), @@ -164,6 +184,7 @@ pub(crate) fn build_index<'tcx>( crate_paths, item_type, fqp, + exact_fqp.map(|x| &x[..]).filter(|exact_fqp| exact_fqp != fqp), )) } else { None @@ -178,6 +199,7 @@ pub(crate) fn build_index<'tcx>( crate_paths, ItemType::Primitive, &[sym], + None, )) } RenderTypeId::Index(_) => Some(id), @@ -188,6 +210,7 @@ pub(crate) fn build_index<'tcx>( crate_paths, ItemType::AssocType, &[sym], + None, )), } } @@ -199,7 +222,7 @@ pub(crate) fn build_index<'tcx>( primitives: &mut FxHashMap<Symbol, isize>, associated_types: &mut FxHashMap<Symbol, isize>, lastpathid: &mut isize, - crate_paths: &mut Vec<(ItemType, Vec<Symbol>)>, + crate_paths: &mut Vec<(ItemType, Vec<Symbol>, Option<Vec<Symbol>>)>, ) { if let Some(generics) = &mut ty.generics { for item in generics { @@ -296,7 +319,7 @@ pub(crate) fn build_index<'tcx>( } } - let Cache { ref paths, .. } = *cache; + let Cache { ref paths, ref exact_paths, ref external_paths, .. } = *cache; // Then, on parent modules let crate_items: Vec<&IndexItem> = search_index @@ -311,7 +334,13 @@ pub(crate) fn build_index<'tcx>( lastpathid += 1; if let Some(&(ref fqp, short)) = paths.get(&defid) { - crate_paths.push((short, fqp.clone())); + let exact_fqp = exact_paths + .get(&defid) + .or_else(|| external_paths.get(&defid).map(|&(ref fqp, _)| fqp)) + .filter(|exact_fqp| { + exact_fqp.last() == Some(&item.name) && *exact_fqp != fqp + }); + crate_paths.push((short, fqp.clone(), exact_fqp.cloned())); Some(pathid) } else { None @@ -319,6 +348,42 @@ pub(crate) fn build_index<'tcx>( } }); + if let Some(defid) = item.defid + && item.parent_idx.is_none() + { + // If this is a re-export, retain the original path. + // Associated items don't use this. + // Their parent carries the exact fqp instead. + let exact_fqp = exact_paths + .get(&defid) + .or_else(|| external_paths.get(&defid).map(|&(ref fqp, _)| fqp)); + item.exact_path = exact_fqp.and_then(|fqp| { + // Re-exports only count if the name is exactly the same. + // This is a size optimization, since it means we only need + // to store the name once (and the path is re-used for everything + // exported from this same module). It's also likely to Do + // What I Mean, since if a re-export changes the name, it might + // also be a change in semantic meaning. + if fqp.last() != Some(&item.name) { + return None; + } + let path = + if item.ty == ItemType::Macro && tcx.has_attr(defid, sym::macro_export) { + // `#[macro_export]` always exports to the crate root. + tcx.crate_name(defid.krate).to_string() + } else { + if fqp.len() < 2 { + return None; + } + join_with_double_colon(&fqp[..fqp.len() - 1]) + }; + if path == item.path { + return None; + } + Some(path) + }); + } + // Omit the parent path if it is same to that of the prior item. if lastpath == &item.path { item.path.clear(); @@ -356,7 +421,7 @@ pub(crate) fn build_index<'tcx>( struct CrateData<'a> { items: Vec<&'a IndexItem>, - paths: Vec<(ItemType, Vec<Symbol>)>, + paths: Vec<(ItemType, Vec<Symbol>, Option<Vec<Symbol>>)>, // The String is alias name and the vec is the list of the elements with this alias. // // To be noted: the `usize` elements are indexes to `items`. @@ -374,6 +439,7 @@ pub(crate) fn build_index<'tcx>( ty: ItemType, name: Symbol, path: Option<usize>, + exact_path: Option<usize>, } impl Serialize for Paths { @@ -387,6 +453,10 @@ pub(crate) fn build_index<'tcx>( if let Some(ref path) = self.path { seq.serialize_element(path)?; } + if let Some(ref path) = self.exact_path { + assert!(self.path.is_some()); + seq.serialize_element(path)?; + } seq.end() } } @@ -409,14 +479,39 @@ pub(crate) fn build_index<'tcx>( mod_paths.insert(&item.path, index); } let mut paths = Vec::with_capacity(self.paths.len()); - for (ty, path) in &self.paths { + for (ty, path, exact) in &self.paths { if path.len() < 2 { - paths.push(Paths { ty: *ty, name: path[0], path: None }); + paths.push(Paths { ty: *ty, name: path[0], path: None, exact_path: None }); continue; } let full_path = join_with_double_colon(&path[..path.len() - 1]); + let full_exact_path = exact + .as_ref() + .filter(|exact| exact.last() == path.last() && exact.len() >= 2) + .map(|exact| join_with_double_colon(&exact[..exact.len() - 1])); + let exact_path = extra_paths.len() + self.items.len(); + let exact_path = full_exact_path.as_ref().map(|full_exact_path| match extra_paths + .entry(full_exact_path.clone()) + { + Entry::Occupied(entry) => *entry.get(), + Entry::Vacant(entry) => { + if let Some(index) = mod_paths.get(&full_exact_path) { + return *index; + } + entry.insert(exact_path); + if !revert_extra_paths.contains_key(&exact_path) { + revert_extra_paths.insert(exact_path, full_exact_path.clone()); + } + exact_path + } + }); if let Some(index) = mod_paths.get(&full_path) { - paths.push(Paths { ty: *ty, name: *path.last().unwrap(), path: Some(*index) }); + paths.push(Paths { + ty: *ty, + name: *path.last().unwrap(), + path: Some(*index), + exact_path, + }); continue; } // It means it comes from an external crate so the item and its path will be @@ -424,28 +519,54 @@ pub(crate) fn build_index<'tcx>( // // `index` is put after the last `mod_paths` let index = extra_paths.len() + self.items.len(); - if !revert_extra_paths.contains_key(&index) { - revert_extra_paths.insert(index, full_path.clone()); - } - match extra_paths.entry(full_path) { + match extra_paths.entry(full_path.clone()) { Entry::Occupied(entry) => { paths.push(Paths { ty: *ty, name: *path.last().unwrap(), path: Some(*entry.get()), + exact_path, }); } Entry::Vacant(entry) => { entry.insert(index); + if !revert_extra_paths.contains_key(&index) { + revert_extra_paths.insert(index, full_path); + } paths.push(Paths { ty: *ty, name: *path.last().unwrap(), path: Some(index), + exact_path, }); } } } + // Direct exports use adjacent arrays for the current crate's items, + // but re-exported exact paths don't. + let mut re_exports = Vec::new(); + for (item_index, item) in self.items.iter().enumerate() { + if let Some(exact_path) = item.exact_path.as_ref() { + if let Some(path_index) = mod_paths.get(&exact_path) { + re_exports.push((item_index, *path_index)); + } else { + let path_index = extra_paths.len() + self.items.len(); + let path_index = match extra_paths.entry(exact_path.clone()) { + Entry::Occupied(entry) => *entry.get(), + Entry::Vacant(entry) => { + entry.insert(path_index); + if !revert_extra_paths.contains_key(&path_index) { + revert_extra_paths.insert(path_index, exact_path.clone()); + } + path_index + } + }; + re_exports.push((item_index, path_index)); + } + } + } + let mut names = Vec::with_capacity(self.items.len()); let mut types = String::with_capacity(self.items.len()); let mut full_paths = Vec::with_capacity(self.items.len()); @@ -501,6 +622,7 @@ pub(crate) fn build_index<'tcx>( crate_data.serialize_field("f", &functions)?; crate_data.serialize_field("D", &self.desc_index)?; crate_data.serialize_field("p", &paths)?; + crate_data.serialize_field("r", &re_exports)?; crate_data.serialize_field("b", &self.associated_item_disambiguators)?; crate_data.serialize_field("c", &bitmap_to_string(&deprecated))?; crate_data.serialize_field("e", &bitmap_to_string(&self.empty_desc))?; diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index e9c687b42fa..74c9130fd77 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1627,24 +1627,27 @@ a.tooltip:hover::after { color: var(--copy-path-button-color); background: var(--main-background-color); height: 34px; + width: 33px; margin-left: 10px; padding: 0; padding-left: 2px; border: 0; - width: 33px; - line-height: 0; font-size: 0; } - -#copy-path:before { +#copy-path::before { filter: var(--copy-path-img-filter); content: url('clipboard-24048e6d87f63d07.svg'); - width: 19px; - height: 18px; } -#copy-path:hover:before { +#copy-path:hover::before { filter: var(--copy-path-img-hover-filter); } +#copy-path.clicked::before { + /* Checkmark <https://www.svgrepo.com/svg/335033/checkmark> */ + content: url('data:image/svg+xml,<svg viewBox="-1 -1 23 23" xmlns="http://www.w3.org/2000/svg" \ + fill="black" height="18px">\ + <g><path d="M9 19.414l-6.707-6.707 1.414-1.414L9 16.586 20.293 5.293l1.414 1.414"></path>\ + </g></svg>'); +} @keyframes rotating { from { diff --git a/src/librustdoc/html/static/js/externs.js b/src/librustdoc/html/static/js/externs.js index d24148b9556..8cebce7ae86 100644 --- a/src/librustdoc/html/static/js/externs.js +++ b/src/librustdoc/html/static/js/externs.js @@ -239,20 +239,27 @@ let FunctionType; * `doc` contains the description of the crate. * * `p` is a list of path/type pairs. It is used for parents and function parameters. + * The first item is the type, the second is the name, the third is the visible path (if any) and + * the fourth is the canonical path used for deduplication (if any). + * + * `r` is the canonical path used for deduplication of re-exported items. + * It is not used for associated items like methods (that's the fourth element + * of `p`) but is used for modules items like free functions. * * `c` is an array of item indices that are deprecated. * @typedef {{ * doc: string, * a: Object, * n: Array<string>, - * t: String, + * t: string, * d: Array<string>, - * q: Array<[Number, string]>, - * i: Array<Number>, + * q: Array<[number, string]>, + * i: Array<number>, * f: string, - * p: Array<Object>, - * b: Array<[Number, String]>, - * c: Array<Number> + * p: Array<[number, string] | [number, string, number] | [number, string, number, number]>, + * b: Array<[number, String]>, + * c: Array<number>, + * r: Array<[number, number]>, * }} */ let RawSearchIndexCrate; diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index ee7d19634b4..64c35660778 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -1798,31 +1798,15 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm document.execCommand("copy"); document.body.removeChild(el); - // There is always one children, but multiple childNodes. - but.children[0].style.display = "none"; - - let tmp; - if (but.childNodes.length < 2) { - tmp = document.createTextNode("✓"); - but.appendChild(tmp); - } else { - onEachLazy(but.childNodes, e => { - if (e.nodeType === Node.TEXT_NODE) { - tmp = e; - return true; - } - }); - tmp.textContent = "✓"; - } + but.classList.add("clicked"); if (reset_button_timeout !== null) { window.clearTimeout(reset_button_timeout); } function reset_button() { - tmp.textContent = ""; reset_button_timeout = null; - but.children[0].style.display = ""; + but.classList.remove("clicked"); } reset_button_timeout = window.setTimeout(reset_button, 1000); diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 3daf1ad22de..41a9897de6d 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -79,6 +79,7 @@ const longItemTypes = [ // used for special search precedence const TY_GENERIC = itemTypes.indexOf("generic"); +const TY_IMPORT = itemTypes.indexOf("import"); const ROOT_PATH = typeof window !== "undefined" ? window.rootPath : "../"; // Hard limit on how deep to recurse into generics when doing type-driven search. @@ -1324,14 +1325,23 @@ function initSearch(rawSearchIndex) { obj.dist = result.dist; const res = buildHrefAndPath(obj); obj.displayPath = pathSplitter(res[0]); - obj.fullPath = obj.displayPath + obj.name; - // To be sure than it some items aren't considered as duplicate. - obj.fullPath += "|" + obj.ty; + // To be sure than it some items aren't considered as duplicate. + obj.fullPath = res[2] + "|" + obj.ty; if (duplicates.has(obj.fullPath)) { continue; } + + // Exports are specifically not shown if the items they point at + // are already in the results. + if (obj.ty === TY_IMPORT && duplicates.has(res[2])) { + continue; + } + if (duplicates.has(res[2] + "|" + TY_IMPORT)) { + continue; + } duplicates.add(obj.fullPath); + duplicates.add(res[2]); obj.href = res[1]; out.push(obj); @@ -1454,16 +1464,7 @@ function initSearch(rawSearchIndex) { return 0; }); - const transformed = transformResults(result_list); - const descs = await Promise.all(transformed.map(result => { - return searchIndexEmptyDesc.get(result.crate).contains(result.bitIndex) ? - "" : - searchState.loadDesc(result); - })); - for (const [i, result] of transformed.entries()) { - result.desc = descs[i]; - } - return transformed; + return transformResults(result_list); } /** @@ -2085,6 +2086,7 @@ function initSearch(rawSearchIndex) { path: item.path, descShard: item.descShard, descIndex: item.descIndex, + exactPath: item.exactPath, ty: item.ty, parent: item.parent, type: item.type, @@ -2506,6 +2508,16 @@ function initSearch(rawSearchIndex) { sorted_others, parsedQuery); handleAliases(ret, parsedQuery.original.replace(/"/g, ""), filterCrates, currentCrate); + await Promise.all([ret.others, ret.returned, ret.in_args].map(async list => { + const descs = await Promise.all(list.map(result => { + return searchIndexEmptyDesc.get(result.crate).contains(result.bitIndex) ? + "" : + searchState.loadDesc(result); + })); + for (const [i, result] of list.entries()) { + result.desc = descs[i]; + } + })); if (parsedQuery.error !== null && ret.others.length !== 0) { // It means some doc aliases were found so let's "remove" the error! ret.query.error = null; @@ -2538,6 +2550,7 @@ function initSearch(rawSearchIndex) { const type = itemTypes[item.ty]; const name = item.name; let path = item.path; + let exactPath = item.exactPath; if (type === "mod") { displayPath = path + "::"; @@ -2559,6 +2572,7 @@ function initSearch(rawSearchIndex) { const parentType = itemTypes[myparent.ty]; let pageType = parentType; let pageName = myparent.name; + exactPath = `${myparent.exactPath}::${myparent.name}`; if (parentType === "primitive") { displayPath = myparent.name + "::"; @@ -2587,7 +2601,7 @@ function initSearch(rawSearchIndex) { href = ROOT_PATH + item.path.replace(/::/g, "/") + "/" + type + "." + name + ".html"; } - return [displayPath, href]; + return [displayPath, href, `${exactPath}::${name}`]; } function pathSplitter(path) { @@ -2980,6 +2994,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\ id: pathIndex, ty: TY_GENERIC, path: null, + exactPath: null, generics, bindings, }; @@ -2989,6 +3004,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\ id: null, ty: null, path: null, + exactPath: null, generics, bindings, }; @@ -2998,6 +3014,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\ id: buildTypeMapIndex(item.name, isAssocType), ty: item.ty, path: item.path, + exactPath: item.exactPath, generics, bindings, }; @@ -3453,6 +3470,8 @@ ${item.displayPath}<span class="${type}">${name}</span>\ path: "", descShard, descIndex, + exactPath: "", + desc: crateCorpus.doc, parent: undefined, type: null, id, @@ -3478,6 +3497,9 @@ ${item.displayPath}<span class="${type}">${name}</span>\ // i.e. if indices 4 and 11 are present, but 5-10 and 12-13 are not present, // 5-10 will fall back to the path for 4 and 12-13 will fall back to the path for 11 const itemPaths = new Map(crateCorpus.q); + // An array of [(Number) item index, (Number) path index] + // Used to de-duplicate inlined and re-exported stuff + const itemReexports = new Map(crateCorpus.r); // an array of (Number) the parent path index + 1 to `paths`, or 0 if none const itemParentIdxs = crateCorpus.i; // a map Number, string for impl disambiguators @@ -3511,9 +3533,10 @@ ${item.displayPath}<span class="${type}">${name}</span>\ path = itemPaths.has(elem[2]) ? itemPaths.get(elem[2]) : lastPath; lastPath = path; } + const exactPath = elem.length > 3 ? itemPaths.get(elem[3]) : path; - lowercasePaths.push({ty: ty, name: name.toLowerCase(), path: path}); - paths[i] = {ty: ty, name: name, path: path}; + lowercasePaths.push({ty, name: name.toLowerCase(), path, exactPath}); + paths[i] = {ty, name, path, exactPath}; } // convert `item*` into an object form, and construct word indices. @@ -3572,6 +3595,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\ path, descShard, descIndex, + exactPath: itemReexports.has(i) ? itemPaths.get(itemReexports.get(i)) : path, parent: itemParentIdxs[i] > 0 ? paths[itemParentIdxs[i] - 1] : undefined, type, id, diff --git a/src/llvm-project b/src/llvm-project -Subproject af8f9eb61a2ad4ee1f2d3f46d157b93a47c6a4b +Subproject 5399a24c66cb6164cf32280e7d300488c90d576 diff --git a/src/tools/clippy/clippy_lints/src/dereference.rs b/src/tools/clippy/clippy_lints/src/dereference.rs index f83fb1b9019..bff40c2ae75 100644 --- a/src/tools/clippy/clippy_lints/src/dereference.rs +++ b/src/tools/clippy/clippy_lints/src/dereference.rs @@ -9,7 +9,7 @@ use rustc_data_structures::fx::FxIndexMap; use rustc_errors::Applicability; use rustc_hir::intravisit::{walk_ty, Visitor}; use rustc_hir::{ - self as hir, BindingAnnotation, Body, BodyId, BorrowKind, Expr, ExprKind, HirId, MatchSource, Mutability, Node, + self as hir, BindingMode, Body, BodyId, BorrowKind, Expr, ExprKind, HirId, MatchSource, Mutability, Node, Pat, PatKind, Path, QPath, TyKind, UnOp, }; use rustc_lint::{LateContext, LateLintPass}; @@ -599,7 +599,7 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> { } fn check_pat(&mut self, cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>) { - if let PatKind::Binding(BindingAnnotation::REF, id, name, _) = pat.kind { + if let PatKind::Binding(BindingMode::REF, id, name, _) = pat.kind { if let Some(opt_prev_pat) = self.ref_locals.get_mut(&id) { // This binding id has been seen before. Add this pattern to the list of changes. if let Some(prev_pat) = opt_prev_pat { diff --git a/src/tools/clippy/clippy_lints/src/eta_reduction.rs b/src/tools/clippy/clippy_lints/src/eta_reduction.rs index 850a4f0eec8..306a4a9e55c 100644 --- a/src/tools/clippy/clippy_lints/src/eta_reduction.rs +++ b/src/tools/clippy/clippy_lints/src/eta_reduction.rs @@ -5,7 +5,7 @@ use clippy_utils::ty::type_diagnostic_name; use clippy_utils::usage::{local_used_after_expr, local_used_in}; use clippy_utils::{get_path_from_caller_to_method_type, is_adjusted, path_to_local, path_to_local_id}; use rustc_errors::Applicability; -use rustc_hir::{BindingAnnotation, Expr, ExprKind, FnRetTy, Param, PatKind, QPath, TyKind, Unsafety}; +use rustc_hir::{BindingMode, Expr, ExprKind, FnRetTy, Param, PatKind, QPath, TyKind, Unsafety}; use rustc_infer::infer::TyCtxtInferExt; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{ @@ -229,7 +229,7 @@ fn check_inputs( && params.iter().zip(self_arg.into_iter().chain(args)).all(|(p, arg)| { matches!( p.pat.kind, - PatKind::Binding(BindingAnnotation::NONE, id, _, None) + PatKind::Binding(BindingMode::NONE, id, _, None) if path_to_local_id(arg, id) ) // Only allow adjustments which change regions (i.e. re-borrowing). diff --git a/src/tools/clippy/clippy_lints/src/explicit_write.rs b/src/tools/clippy/clippy_lints/src/explicit_write.rs index 33bd5a5a9d3..724e1843359 100644 --- a/src/tools/clippy/clippy_lints/src/explicit_write.rs +++ b/src/tools/clippy/clippy_lints/src/explicit_write.rs @@ -4,7 +4,7 @@ use clippy_utils::source::snippet_with_applicability; use clippy_utils::{is_expn_of, path_def_id}; use rustc_errors::Applicability; use rustc_hir::def::Res; -use rustc_hir::{BindingAnnotation, Block, BlockCheckMode, Expr, ExprKind, Node, PatKind, QPath, Stmt, StmtKind}; +use rustc_hir::{BindingMode, Block, BlockCheckMode, Expr, ExprKind, Node, PatKind, QPath, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; use rustc_span::{sym, ExpnId}; @@ -114,7 +114,7 @@ fn look_in_block<'tcx, 'hir>(cx: &LateContext<'tcx>, kind: &'tcx ExprKind<'hir>) && let Node::Pat(res_pat) = cx.tcx.hir_node(expr_res) // Find id of the local we found in the block - && let PatKind::Binding(BindingAnnotation::NONE, local_hir_id, _ident, None) = local.pat.kind + && let PatKind::Binding(BindingMode::NONE, local_hir_id, _ident, None) = local.pat.kind // If those two are the same hir id && res_pat.hir_id == local_hir_id diff --git a/src/tools/clippy/clippy_lints/src/index_refutable_slice.rs b/src/tools/clippy/clippy_lints/src/index_refutable_slice.rs index 6ddc8346511..799ec9d553d 100644 --- a/src/tools/clippy/clippy_lints/src/index_refutable_slice.rs +++ b/src/tools/clippy/clippy_lints/src/index_refutable_slice.rs @@ -94,7 +94,7 @@ fn find_slice_values(cx: &LateContext<'_>, pat: &hir::Pat<'_>) -> FxIndexMap<Hir pat.walk_always(|pat| { // We'll just ignore mut and ref mut for simplicity sake right now if let hir::PatKind::Binding( - hir::BindingAnnotation(by_ref, hir::Mutability::Not), + hir::BindingMode(by_ref, hir::Mutability::Not), value_hir_id, ident, sub_pat, diff --git a/src/tools/clippy/clippy_lints/src/let_if_seq.rs b/src/tools/clippy/clippy_lints/src/let_if_seq.rs index d4ddf76fb8a..a65cb3f4dfb 100644 --- a/src/tools/clippy/clippy_lints/src/let_if_seq.rs +++ b/src/tools/clippy/clippy_lints/src/let_if_seq.rs @@ -4,7 +4,7 @@ use clippy_utils::source::snippet; use clippy_utils::visitors::is_local_used; use rustc_errors::Applicability; use rustc_hir as hir; -use rustc_hir::{BindingAnnotation, Mutability}; +use rustc_hir::{BindingMode, Mutability}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; @@ -106,7 +106,7 @@ impl<'tcx> LateLintPass<'tcx> for LetIfSeq { }; let mutability = match mode { - BindingAnnotation(_, Mutability::Mut) => "<mut> ", + BindingMode(_, Mutability::Mut) => "<mut> ", _ => "", }; 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 d484ce40d78..b27528c11d4 100644 --- a/src/tools/clippy/clippy_lints/src/loops/manual_find.rs +++ b/src/tools/clippy/clippy_lints/src/loops/manual_find.rs @@ -7,7 +7,7 @@ use clippy_utils::{higher, is_res_lang_ctor, path_res, peel_blocks_with_stmt}; use rustc_errors::Applicability; use rustc_hir::def::Res; use rustc_hir::lang_items::LangItem; -use rustc_hir::{BindingAnnotation, Block, Expr, ExprKind, HirId, Node, Pat, PatKind, Stmt, StmtKind}; +use rustc_hir::{BindingMode, Block, Expr, ExprKind, HirId, Node, Pat, PatKind, Stmt, StmtKind}; use rustc_lint::LateContext; use rustc_span::Span; @@ -107,7 +107,7 @@ fn get_binding(pat: &Pat<'_>) -> Option<HirId> { hir_id = None; return; } - if let BindingAnnotation::NONE = annotation { + if let BindingMode::NONE = annotation { hir_id = Some(id); } }); diff --git a/src/tools/clippy/clippy_lints/src/loops/mut_range_bound.rs b/src/tools/clippy/clippy_lints/src/loops/mut_range_bound.rs index 94330001e4f..5047092192f 100644 --- a/src/tools/clippy/clippy_lints/src/loops/mut_range_bound.rs +++ b/src/tools/clippy/clippy_lints/src/loops/mut_range_bound.rs @@ -2,7 +2,7 @@ use super::MUT_RANGE_BOUND; use clippy_utils::diagnostics::span_lint_and_note; use clippy_utils::{get_enclosing_block, higher, path_to_local}; use rustc_hir::intravisit::{self, Visitor}; -use rustc_hir::{BindingAnnotation, Expr, ExprKind, HirId, Node, PatKind}; +use rustc_hir::{BindingMode, Expr, ExprKind, HirId, Node, PatKind}; use rustc_hir_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId}; use rustc_infer::infer::TyCtxtInferExt; use rustc_lint::LateContext; @@ -41,7 +41,7 @@ fn mut_warn_with_span(cx: &LateContext<'_>, span: Option<Span>) { fn check_for_mutability(cx: &LateContext<'_>, bound: &Expr<'_>) -> Option<HirId> { if let Some(hir_id) = path_to_local(bound) && let Node::Pat(pat) = cx.tcx.hir_node(hir_id) - && let PatKind::Binding(BindingAnnotation::MUT, ..) = pat.kind + && let PatKind::Binding(BindingMode::MUT, ..) = pat.kind { return Some(hir_id); } diff --git a/src/tools/clippy/clippy_lints/src/loops/same_item_push.rs b/src/tools/clippy/clippy_lints/src/loops/same_item_push.rs index 1d90d4a58f5..9185cf1f8b2 100644 --- a/src/tools/clippy/clippy_lints/src/loops/same_item_push.rs +++ b/src/tools/clippy/clippy_lints/src/loops/same_item_push.rs @@ -7,7 +7,7 @@ use rustc_data_structures::fx::FxHashSet; use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; use rustc_hir::intravisit::{walk_expr, Visitor}; -use rustc_hir::{BindingAnnotation, Block, Expr, ExprKind, HirId, Mutability, Node, Pat, PatKind, Stmt, StmtKind}; +use rustc_hir::{BindingMode, Block, Expr, ExprKind, HirId, Mutability, Node, Pat, PatKind, Stmt, StmtKind}; use rustc_lint::LateContext; use rustc_span::symbol::sym; use rustc_span::SyntaxContext; @@ -61,7 +61,7 @@ pub(super) fn check<'tcx>( let node = cx.tcx.hir_node(hir_id); if let Node::Pat(pat) = node && let PatKind::Binding(bind_ann, ..) = pat.kind - && !matches!(bind_ann, BindingAnnotation(_, Mutability::Mut)) + && !matches!(bind_ann, BindingMode(_, Mutability::Mut)) && let Node::LetStmt(parent_let_expr) = cx.tcx.parent_hir_node(hir_id) && let Some(init) = parent_let_expr.init { diff --git a/src/tools/clippy/clippy_lints/src/manual_hash_one.rs b/src/tools/clippy/clippy_lints/src/manual_hash_one.rs index f8f33cfc82e..daa8101aa5f 100644 --- a/src/tools/clippy/clippy_lints/src/manual_hash_one.rs +++ b/src/tools/clippy/clippy_lints/src/manual_hash_one.rs @@ -4,7 +4,7 @@ use clippy_utils::source::snippet_opt; use clippy_utils::visitors::{is_local_used, local_used_once}; use clippy_utils::{is_trait_method, path_to_local_id}; use rustc_errors::Applicability; -use rustc_hir::{BindingAnnotation, ExprKind, LetStmt, Node, PatKind, StmtKind}; +use rustc_hir::{BindingMode, ExprKind, LetStmt, Node, PatKind, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; use rustc_span::sym; @@ -62,7 +62,7 @@ impl_lint_pass!(ManualHashOne => [MANUAL_HASH_ONE]); impl LateLintPass<'_> for ManualHashOne { fn check_local(&mut self, cx: &LateContext<'_>, local: &LetStmt<'_>) { // `let mut hasher = seg.build_hasher();` - if let PatKind::Binding(BindingAnnotation::MUT, hasher, _, None) = local.pat.kind + if let PatKind::Binding(BindingMode::MUT, hasher, _, None) = local.pat.kind && let Some(init) = local.init && !init.span.from_expansion() && let ExprKind::MethodCall(seg, build_hasher, [], _) = init.kind diff --git a/src/tools/clippy/clippy_lints/src/matches/manual_utils.rs b/src/tools/clippy/clippy_lints/src/matches/manual_utils.rs index 152aba99ce9..183caab56c5 100644 --- a/src/tools/clippy/clippy_lints/src/matches/manual_utils.rs +++ b/src/tools/clippy/clippy_lints/src/matches/manual_utils.rs @@ -11,7 +11,7 @@ use rustc_ast::util::parser::PREC_POSTFIX; use rustc_errors::Applicability; use rustc_hir::def::Res; use rustc_hir::LangItem::{OptionNone, OptionSome}; -use rustc_hir::{BindingAnnotation, Expr, ExprKind, HirId, Mutability, Pat, PatKind, Path, QPath}; +use rustc_hir::{BindingMode, Expr, ExprKind, HirId, Mutability, Pat, PatKind, Path, QPath}; use rustc_lint::LateContext; use rustc_span::{sym, SyntaxContext}; @@ -139,7 +139,7 @@ where } // `ref` and `ref mut` annotations were handled earlier. - let annotation = if matches!(annotation, BindingAnnotation::MUT) { + let annotation = if matches!(annotation, BindingMode::MUT) { "mut " } else { "" diff --git a/src/tools/clippy/clippy_lints/src/matches/match_as_ref.rs b/src/tools/clippy/clippy_lints/src/matches/match_as_ref.rs index f5da8ec6187..6c123649afc 100644 --- a/src/tools/clippy/clippy_lints/src/matches/match_as_ref.rs +++ b/src/tools/clippy/clippy_lints/src/matches/match_as_ref.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_applicability; use clippy_utils::{is_res_lang_ctor, path_res, peel_blocks}; use rustc_errors::Applicability; -use rustc_hir::{Arm, BindingAnnotation, ByRef, Expr, ExprKind, LangItem, Mutability, PatKind, QPath}; +use rustc_hir::{Arm, BindingMode, ByRef, Expr, ExprKind, LangItem, Mutability, PatKind, QPath}; use rustc_lint::LateContext; use rustc_middle::ty; @@ -67,7 +67,7 @@ fn is_none_arm(cx: &LateContext<'_>, arm: &Arm<'_>) -> bool { fn is_ref_some_arm(cx: &LateContext<'_>, arm: &Arm<'_>) -> Option<Mutability> { if let PatKind::TupleStruct(ref qpath, [first_pat, ..], _) = arm.pat.kind && is_res_lang_ctor(cx, cx.qpath_res(qpath, arm.pat.hir_id), LangItem::OptionSome) - && let PatKind::Binding(BindingAnnotation(ByRef::Yes(mutabl), _), .., ident, _) = first_pat.kind + && let PatKind::Binding(BindingMode(ByRef::Yes(mutabl), _), .., ident, _) = first_pat.kind && let ExprKind::Call(e, [arg]) = peel_blocks(arm.body).kind && is_res_lang_ctor(cx, path_res(cx, e), LangItem::OptionSome) && let ExprKind::Path(QPath::Resolved(_, path2)) = arg.kind diff --git a/src/tools/clippy/clippy_lints/src/matches/needless_match.rs b/src/tools/clippy/clippy_lints/src/matches/needless_match.rs index fe83e784c3c..6f7d6902640 100644 --- a/src/tools/clippy/clippy_lints/src/matches/needless_match.rs +++ b/src/tools/clippy/clippy_lints/src/matches/needless_match.rs @@ -8,7 +8,7 @@ use clippy_utils::{ }; use rustc_errors::Applicability; use rustc_hir::LangItem::OptionNone; -use rustc_hir::{Arm, BindingAnnotation, ByRef, Expr, ExprKind, ItemKind, Node, Pat, PatKind, Path, QPath}; +use rustc_hir::{Arm, BindingMode, ByRef, Expr, ExprKind, ItemKind, Node, Pat, PatKind, Path, QPath}; use rustc_lint::LateContext; use rustc_span::sym; @@ -178,7 +178,7 @@ fn pat_same_as_expr(pat: &Pat<'_>, expr: &Expr<'_>) -> bool { }, )), ) => { - return !matches!(annot, BindingAnnotation(ByRef::Yes(_), _)) && pat_ident.name == first_seg.ident.name; + return !matches!(annot, BindingMode(ByRef::Yes(_), _)) && pat_ident.name == first_seg.ident.name; }, // Example: `Custom::TypeA => Custom::TypeB`, or `None => None` (PatKind::Path(QPath::Resolved(_, p_path)), ExprKind::Path(QPath::Resolved(_, e_path))) => { diff --git a/src/tools/clippy/clippy_lints/src/matches/single_match.rs b/src/tools/clippy/clippy_lints/src/matches/single_match.rs index a0db8e2db1f..37f72528140 100644 --- a/src/tools/clippy/clippy_lints/src/matches/single_match.rs +++ b/src/tools/clippy/clippy_lints/src/matches/single_match.rs @@ -4,7 +4,7 @@ use clippy_utils::ty::{implements_trait, is_type_diagnostic_item, peel_mid_ty_re use clippy_utils::{is_lint_allowed, is_unit_expr, is_wild, peel_blocks, peel_hir_pat_refs, peel_n_hir_expr_refs}; use core::cmp::max; use rustc_errors::Applicability; -use rustc_hir::{Arm, BindingAnnotation, Block, Expr, ExprKind, Pat, PatKind}; +use rustc_hir::{Arm, BindingMode, Block, Expr, ExprKind, Pat, PatKind}; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; use rustc_span::{sym, Span}; @@ -166,7 +166,7 @@ fn collect_pat_paths<'a>(acc: &mut Vec<Ty<'a>>, cx: &LateContext<'a>, pat: &Pat< let p_ty = cx.typeck_results().pat_ty(p); collect_pat_paths(acc, cx, p, p_ty); }), - PatKind::TupleStruct(..) | PatKind::Binding(BindingAnnotation::NONE, .., None) | PatKind::Path(_) => { + PatKind::TupleStruct(..) | PatKind::Binding(BindingMode::NONE, .., None) | PatKind::Path(_) => { acc.push(ty); }, _ => {}, diff --git a/src/tools/clippy/clippy_lints/src/methods/clone_on_copy.rs b/src/tools/clippy/clippy_lints/src/methods/clone_on_copy.rs index 4e6823e8220..e7a2060be04 100644 --- a/src/tools/clippy/clippy_lints/src/methods/clone_on_copy.rs +++ b/src/tools/clippy/clippy_lints/src/methods/clone_on_copy.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_context; use clippy_utils::ty::is_copy; use rustc_errors::Applicability; -use rustc_hir::{BindingAnnotation, ByRef, Expr, ExprKind, MatchSource, Node, PatKind, QPath}; +use rustc_hir::{BindingMode, ByRef, Expr, ExprKind, MatchSource, Node, PatKind, QPath}; use rustc_lint::LateContext; use rustc_middle::ty::adjustment::Adjust; use rustc_middle::ty::print::with_forced_trimmed_paths; @@ -69,7 +69,7 @@ pub(super) fn check( _ => false, }, // local binding capturing a reference - Node::LetStmt(l) if matches!(l.pat.kind, PatKind::Binding(BindingAnnotation(ByRef::Yes(_), _), ..)) => { + Node::LetStmt(l) if matches!(l.pat.kind, PatKind::Binding(BindingMode(ByRef::Yes(_), _), ..)) => { return; }, _ => false, diff --git a/src/tools/clippy/clippy_lints/src/methods/filter_next.rs b/src/tools/clippy/clippy_lints/src/methods/filter_next.rs index 7339362193e..e697ba656f5 100644 --- a/src/tools/clippy/clippy_lints/src/methods/filter_next.rs +++ b/src/tools/clippy/clippy_lints/src/methods/filter_next.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_then}; use clippy_utils::source::snippet; use clippy_utils::ty::implements_trait; -use rustc_ast::{BindingAnnotation, Mutability}; +use rustc_ast::{BindingMode, Mutability}; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; @@ -45,7 +45,7 @@ pub(super) fn check<'tcx>( span_lint_and_then(cx, FILTER_NEXT, expr.span, msg, |diag| { let (applicability, pat) = if let Some(id) = path_to_local(recv) && let hir::Node::Pat(pat) = cx.tcx.hir_node(id) - && let hir::PatKind::Binding(BindingAnnotation(_, Mutability::Not), _, ident, _) = pat.kind + && let hir::PatKind::Binding(BindingMode(_, Mutability::Not), _, ident, _) = pat.kind { (Applicability::Unspecified, Some((pat.span, ident))) } else { diff --git a/src/tools/clippy/clippy_lints/src/methods/iter_kv_map.rs b/src/tools/clippy/clippy_lints/src/methods/iter_kv_map.rs index b9fec0c4f80..7c852a3768d 100644 --- a/src/tools/clippy/clippy_lints/src/methods/iter_kv_map.rs +++ b/src/tools/clippy/clippy_lints/src/methods/iter_kv_map.rs @@ -6,7 +6,7 @@ use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_sugg, span_lint_an use clippy_utils::source::{snippet, snippet_with_applicability}; use clippy_utils::ty::is_type_diagnostic_item; use clippy_utils::{pat_is_wild, sugg}; -use rustc_hir::{BindingAnnotation, Body, BorrowKind, ByRef, Expr, ExprKind, Mutability, Pat, PatKind}; +use rustc_hir::{BindingMode, Body, BorrowKind, ByRef, Expr, ExprKind, Mutability, Pat, PatKind}; use rustc_lint::{LateContext, LintContext}; use rustc_middle::ty; use rustc_span::{sym, Span}; diff --git a/src/tools/clippy/clippy_lints/src/methods/iter_overeager_cloned.rs b/src/tools/clippy/clippy_lints/src/methods/iter_overeager_cloned.rs index 4729481320e..6d70989546a 100644 --- a/src/tools/clippy/clippy_lints/src/methods/iter_overeager_cloned.rs +++ b/src/tools/clippy/clippy_lints/src/methods/iter_overeager_cloned.rs @@ -1,7 +1,7 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::snippet_opt; use clippy_utils::ty::{implements_trait, is_copy}; -use rustc_ast::BindingAnnotation; +use rustc_ast::BindingMode; use rustc_errors::Applicability; use rustc_hir::{Body, Expr, ExprKind, HirId, HirIdSet, PatKind}; use rustc_hir_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId}; @@ -89,7 +89,7 @@ pub(super) fn check<'tcx>( } match it.kind { - PatKind::Binding(BindingAnnotation(_, Mutability::Mut), _, _, _) + PatKind::Binding(BindingMode(_, Mutability::Mut), _, _, _) | PatKind::Ref(_, Mutability::Mut) => { to_be_discarded = true; false diff --git a/src/tools/clippy/clippy_lints/src/methods/iter_skip_next.rs b/src/tools/clippy/clippy_lints/src/methods/iter_skip_next.rs index d1215290dad..fedb7c22ede 100644 --- a/src/tools/clippy/clippy_lints/src/methods/iter_skip_next.rs +++ b/src/tools/clippy/clippy_lints/src/methods/iter_skip_next.rs @@ -3,7 +3,7 @@ use clippy_utils::source::snippet; use clippy_utils::{is_trait_method, path_to_local}; use rustc_errors::Applicability; use rustc_hir as hir; -use rustc_hir::{BindingAnnotation, Node, PatKind}; +use rustc_hir::{BindingMode, Node, PatKind}; use rustc_lint::LateContext; use rustc_span::sym; @@ -22,7 +22,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr if let Some(id) = path_to_local(recv) && let Node::Pat(pat) = cx.tcx.hir_node(id) && let PatKind::Binding(ann, _, _, _) = pat.kind - && ann != BindingAnnotation::MUT + && ann != BindingMode::MUT { application = Applicability::Unspecified; diag.span_help( diff --git a/src/tools/clippy/clippy_lints/src/methods/map_clone.rs b/src/tools/clippy/clippy_lints/src/methods/map_clone.rs index 0901268e9bd..a5ba5e5d891 100644 --- a/src/tools/clippy/clippy_lints/src/methods/map_clone.rs +++ b/src/tools/clippy/clippy_lints/src/methods/map_clone.rs @@ -51,13 +51,13 @@ pub(super) fn check(cx: &LateContext<'_>, e: &hir::Expr<'_>, recv: &hir::Expr<'_ let closure_expr = peel_blocks(closure_body.value); match closure_body.params[0].pat.kind { hir::PatKind::Ref(inner, Mutability::Not) => { - if let hir::PatKind::Binding(hir::BindingAnnotation::NONE, .., name, None) = inner.kind { + if let hir::PatKind::Binding(hir::BindingMode::NONE, .., name, None) = inner.kind { if ident_eq(name, closure_expr) { lint_explicit_closure(cx, e.span, recv.span, true, msrv); } } }, - hir::PatKind::Binding(hir::BindingAnnotation::NONE, .., name, None) => { + hir::PatKind::Binding(hir::BindingMode::NONE, .., name, None) => { match closure_expr.kind { hir::ExprKind::Unary(hir::UnOp::Deref, inner) => { if ident_eq(name, inner) { diff --git a/src/tools/clippy/clippy_lints/src/methods/needless_collect.rs b/src/tools/clippy/clippy_lints/src/methods/needless_collect.rs index 662e7746496..1c695655536 100644 --- a/src/tools/clippy/clippy_lints/src/methods/needless_collect.rs +++ b/src/tools/clippy/clippy_lints/src/methods/needless_collect.rs @@ -11,7 +11,7 @@ use rustc_data_structures::fx::FxHashMap; use rustc_errors::{Applicability, MultiSpan}; use rustc_hir::intravisit::{walk_block, walk_expr, Visitor}; use rustc_hir::{ - BindingAnnotation, Block, Expr, ExprKind, HirId, HirIdSet, LetStmt, Mutability, Node, PatKind, Stmt, StmtKind, + BindingMode, Block, Expr, ExprKind, HirId, HirIdSet, LetStmt, Mutability, Node, PatKind, Stmt, StmtKind, }; use rustc_lint::LateContext; use rustc_middle::hir::nested_filter; @@ -86,7 +86,7 @@ pub(super) fn check<'tcx>( } }, Node::LetStmt(l) => { - if let PatKind::Binding(BindingAnnotation::NONE | BindingAnnotation::MUT, id, _, None) = l.pat.kind + if let PatKind::Binding(BindingMode::NONE | BindingMode::MUT, id, _, None) = l.pat.kind && let ty = cx.typeck_results().expr_ty(collect_expr) && [sym::Vec, sym::VecDeque, sym::BinaryHeap, sym::LinkedList] .into_iter() 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 55ae9746298..e8c12bbeea0 100644 --- a/src/tools/clippy/clippy_lints/src/methods/str_splitn.rs +++ b/src/tools/clippy/clippy_lints/src/methods/str_splitn.rs @@ -8,7 +8,7 @@ use clippy_utils::{is_diag_item_method, match_def_path, path_to_local_id, paths} use core::ops::ControlFlow; use rustc_errors::Applicability; use rustc_hir::{ - BindingAnnotation, Expr, ExprKind, HirId, LangItem, LetStmt, MatchSource, Node, Pat, PatKind, QPath, Stmt, StmtKind, + BindingMode, Expr, ExprKind, HirId, LangItem, LetStmt, MatchSource, Node, Pat, PatKind, QPath, Stmt, StmtKind, }; use rustc_lint::LateContext; use rustc_middle::ty; @@ -129,7 +129,7 @@ fn check_manual_split_once_indirect( let ctxt = expr.span.ctxt(); let mut parents = cx.tcx.hir().parent_iter(expr.hir_id); if let (_, Node::LetStmt(local)) = parents.next()? - && let PatKind::Binding(BindingAnnotation::MUT, iter_binding_id, iter_ident, None) = local.pat.kind + && let PatKind::Binding(BindingMode::MUT, iter_binding_id, iter_ident, None) = local.pat.kind && let (iter_stmt_id, Node::Stmt(_)) = parents.next()? && let (_, Node::Block(enclosing_block)) = parents.next()? && let mut stmts = enclosing_block @@ -200,7 +200,7 @@ fn indirect_usage<'tcx>( ) -> Option<IndirectUsage<'tcx>> { if let StmtKind::Let(&LetStmt { pat: Pat { - kind: PatKind::Binding(BindingAnnotation::NONE, _, ident, None), + kind: PatKind::Binding(BindingMode::NONE, _, ident, None), .. }, init: Some(init_expr), diff --git a/src/tools/clippy/clippy_lints/src/misc.rs b/src/tools/clippy/clippy_lints/src/misc.rs index 3cf054e7207..f3f9bf11a61 100644 --- a/src/tools/clippy/clippy_lints/src/misc.rs +++ b/src/tools/clippy/clippy_lints/src/misc.rs @@ -9,7 +9,7 @@ use rustc_errors::Applicability; use rustc_hir::def::Res; use rustc_hir::intravisit::FnKind; use rustc_hir::{ - BinOpKind, BindingAnnotation, Body, ByRef, Expr, ExprKind, FnDecl, Mutability, PatKind, QPath, Stmt, StmtKind, + BinOpKind, BindingMode, Body, ByRef, Expr, ExprKind, FnDecl, Mutability, PatKind, QPath, Stmt, StmtKind, }; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; @@ -129,7 +129,7 @@ impl<'tcx> LateLintPass<'tcx> for LintPass { if !is_lint_allowed(cx, REF_PATTERNS, arg.pat.hir_id) { return; } - if let PatKind::Binding(BindingAnnotation(ByRef::Yes(_), _), ..) = arg.pat.kind { + if let PatKind::Binding(BindingMode(ByRef::Yes(_), _), ..) = arg.pat.kind { span_lint( cx, TOPLEVEL_REF_ARG, @@ -144,7 +144,7 @@ impl<'tcx> LateLintPass<'tcx> for LintPass { fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) { if !in_external_macro(cx.tcx.sess, stmt.span) && let StmtKind::Let(local) = stmt.kind - && let PatKind::Binding(BindingAnnotation(ByRef::Yes(mutabl), _), .., name, None) = local.pat.kind + && let PatKind::Binding(BindingMode(ByRef::Yes(mutabl), _), .., name, None) = local.pat.kind && let Some(init) = local.init // Do not emit if clippy::ref_patterns is not allowed to avoid having two lints for the same issue. && is_lint_allowed(cx, REF_PATTERNS, local.pat.hir_id) diff --git a/src/tools/clippy/clippy_lints/src/needless_arbitrary_self_type.rs b/src/tools/clippy/clippy_lints/src/needless_arbitrary_self_type.rs index 2ab83f733cb..60c44382059 100644 --- a/src/tools/clippy/clippy_lints/src/needless_arbitrary_self_type.rs +++ b/src/tools/clippy/clippy_lints/src/needless_arbitrary_self_type.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_sugg; -use rustc_ast::ast::{BindingAnnotation, ByRef, Lifetime, Mutability, Param, PatKind, Path, TyKind}; +use rustc_ast::ast::{BindingMode, ByRef, Lifetime, Mutability, Param, PatKind, Path, TyKind}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::declare_lint_pass; @@ -117,13 +117,13 @@ impl EarlyLintPass for NeedlessArbitrarySelfType { match &p.ty.kind { TyKind::Path(None, path) => { - if let PatKind::Ident(BindingAnnotation(ByRef::No, mutbl), _, _) = p.pat.kind { + if let PatKind::Ident(BindingMode(ByRef::No, mutbl), _, _) = p.pat.kind { check_param_inner(cx, path, p.span.to(p.ty.span), &Mode::Value, mutbl); } }, TyKind::Ref(lifetime, mut_ty) => { if let TyKind::Path(None, path) = &mut_ty.ty.kind - && let PatKind::Ident(BindingAnnotation::NONE, _, _) = p.pat.kind + && let PatKind::Ident(BindingMode::NONE, _, _) = p.pat.kind { check_param_inner(cx, path, p.span.to(p.ty.span), &Mode::Ref(*lifetime), mut_ty.mutbl); } 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 d91329eadcb..fb02f24c9dc 100644 --- a/src/tools/clippy/clippy_lints/src/needless_borrowed_ref.rs +++ b/src/tools/clippy/clippy_lints/src/needless_borrowed_ref.rs @@ -1,6 +1,6 @@ use clippy_utils::diagnostics::span_lint_and_then; use rustc_errors::Applicability; -use rustc_hir::{BindingAnnotation, Mutability, Node, Pat, PatKind}; +use rustc_hir::{BindingMode, Mutability, Node, Pat, PatKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; @@ -58,7 +58,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBorrowedRef { match pat.kind { // Check sub_pat got a `ref` keyword (excluding `ref mut`). - PatKind::Binding(BindingAnnotation::REF, _, ident, None) => { + PatKind::Binding(BindingMode::REF, _, ident, None) => { span_lint_and_then( cx, NEEDLESS_BORROWED_REFERENCE, @@ -128,7 +128,7 @@ fn check_subpatterns<'tcx>( for subpattern in subpatterns { match subpattern.kind { - PatKind::Binding(BindingAnnotation::REF, _, ident, None) => { + PatKind::Binding(BindingMode::REF, _, ident, None) => { // `ref ident` // ^^^^ let span = subpattern.span.until(ident.span); 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 810799acb2e..0c0b1a73351 100644 --- a/src/tools/clippy/clippy_lints/src/needless_late_init.rs +++ b/src/tools/clippy/clippy_lints/src/needless_late_init.rs @@ -6,7 +6,7 @@ use clippy_utils::visitors::{for_each_expr, for_each_expr_with_closures, is_loca use core::ops::ControlFlow; use rustc_errors::{Applicability, MultiSpan}; use rustc_hir::{ - BindingAnnotation, Block, Expr, ExprKind, HirId, LetStmt, LocalSource, MatchSource, Node, Pat, PatKind, Stmt, + BindingMode, Block, Expr, ExprKind, HirId, LetStmt, LocalSource, MatchSource, Node, Pat, PatKind, Stmt, StmtKind, }; use rustc_lint::{LateContext, LateLintPass}; @@ -369,7 +369,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessLateInit { init: None, pat: &Pat { - kind: PatKind::Binding(BindingAnnotation::NONE, binding_id, _, None), + kind: PatKind::Binding(BindingMode::NONE, binding_id, _, None), .. }, source: LocalSource::Normal, diff --git a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs index f33e2e0ed71..53bcde68087 100644 --- a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs +++ b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs @@ -9,7 +9,7 @@ use rustc_ast::ast::Attribute; use rustc_errors::{Applicability, Diag}; use rustc_hir::intravisit::FnKind; use rustc_hir::{ - BindingAnnotation, Body, FnDecl, GenericArg, HirId, HirIdSet, Impl, ItemKind, LangItem, Mutability, Node, PatKind, + BindingMode, Body, FnDecl, GenericArg, HirId, HirIdSet, Impl, ItemKind, LangItem, Mutability, Node, PatKind, QPath, TyKind, }; use rustc_hir_typeck::expr_use_visitor as euv; @@ -192,7 +192,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue { }) && !implements_borrow_trait && !all_borrowable_trait - && let PatKind::Binding(BindingAnnotation(_, Mutability::Not), canonical_id, ..) = arg.pat.kind + && let PatKind::Binding(BindingMode(_, Mutability::Not), canonical_id, ..) = arg.pat.kind && !moved_vars.contains(&canonical_id) { // Dereference suggestion diff --git a/src/tools/clippy/clippy_lints/src/option_if_let_else.rs b/src/tools/clippy/clippy_lints/src/option_if_let_else.rs index 3cbd03a58c5..d4906328ccb 100644 --- a/src/tools/clippy/clippy_lints/src/option_if_let_else.rs +++ b/src/tools/clippy/clippy_lints/src/option_if_let_else.rs @@ -7,7 +7,7 @@ use clippy_utils::{ use rustc_errors::Applicability; use rustc_hir::def::Res; use rustc_hir::LangItem::{OptionNone, OptionSome, ResultErr, ResultOk}; -use rustc_hir::{Arm, BindingAnnotation, Expr, ExprKind, MatchSource, Mutability, Pat, PatKind, Path, QPath, UnOp}; +use rustc_hir::{Arm, BindingMode, Expr, ExprKind, MatchSource, Mutability, Pat, PatKind, Path, QPath, UnOp}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; use rustc_span::SyntaxContext; @@ -129,7 +129,7 @@ fn try_get_option_occurrence<'tcx>( .filter_map(|(id, &c)| none_captures.get(id).map(|&c2| (c, c2))) .all(|(x, y)| x.is_imm_ref() && y.is_imm_ref()) { - let capture_mut = if bind_annotation == BindingAnnotation::MUT { + let capture_mut = if bind_annotation == BindingMode::MUT { "mut " } else { "" @@ -149,8 +149,8 @@ fn try_get_option_occurrence<'tcx>( (mutb == Mutability::Not, mutb == Mutability::Mut) }, _ => ( - bind_annotation == BindingAnnotation::REF, - bind_annotation == BindingAnnotation::REF_MUT, + bind_annotation == BindingMode::REF, + bind_annotation == BindingMode::REF_MUT, ), }; diff --git a/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs b/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs index bb4a1de9f77..128bfd49d9e 100644 --- a/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs +++ b/src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs @@ -10,7 +10,7 @@ use rustc_data_structures::fx::FxHashSet; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_hir::intravisit::FnKind; -use rustc_hir::{BindingAnnotation, Body, FnDecl, Impl, ItemKind, MutTy, Mutability, Node, PatKind}; +use rustc_hir::{BindingMode, Body, FnDecl, Impl, ItemKind, MutTy, Mutability, Node, PatKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::adjustment::{Adjust, PointerCoercion}; use rustc_middle::ty::layout::LayoutOf; @@ -221,7 +221,7 @@ impl<'tcx> PassByRefOrValue { // if function has a body and parameter is annotated with mut, ignore if let Some(param) = fn_body.and_then(|body| body.params.get(index)) { match param.pat.kind { - PatKind::Binding(BindingAnnotation::NONE, _, _, _) => {}, + PatKind::Binding(BindingMode::NONE, _, _, _) => {}, _ => continue, } } diff --git a/src/tools/clippy/clippy_lints/src/ptr.rs b/src/tools/clippy/clippy_lints/src/ptr.rs index d6592622f0b..cc61ef9184c 100644 --- a/src/tools/clippy/clippy_lints/src/ptr.rs +++ b/src/tools/clippy/clippy_lints/src/ptr.rs @@ -11,7 +11,7 @@ use rustc_hir::def_id::DefId; use rustc_hir::hir_id::{HirId, HirIdMap}; use rustc_hir::intravisit::{walk_expr, Visitor}; use rustc_hir::{ - self as hir, AnonConst, BinOpKind, BindingAnnotation, Body, Expr, ExprKind, FnRetTy, FnSig, GenericArg, + self as hir, AnonConst, BinOpKind, BindingMode, Body, Expr, ExprKind, FnRetTy, FnSig, GenericArg, ImplItemKind, ItemKind, Lifetime, Mutability, Node, Param, PatKind, QPath, TraitFn, TraitItem, TraitItemKind, TyKind, Unsafety, }; @@ -606,7 +606,7 @@ fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &'tcx Body<'_>, args: Some((Node::Stmt(_), _)) => (), Some((Node::LetStmt(l), _)) => { // Only trace simple bindings. e.g `let x = y;` - if let PatKind::Binding(BindingAnnotation::NONE, id, _, None) = l.pat.kind { + if let PatKind::Binding(BindingMode::NONE, id, _, None) = l.pat.kind { self.bindings.insert(id, args_idx); } else { set_skip_flag(); @@ -687,7 +687,7 @@ fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &'tcx Body<'_>, args: .filter_map(|(i, arg)| { let param = &body.params[arg.idx]; match param.pat.kind { - PatKind::Binding(BindingAnnotation::NONE, id, _, None) + PatKind::Binding(BindingMode::NONE, id, _, None) if !is_lint_allowed(cx, PTR_ARG, param.hir_id) => { Some((id, i)) diff --git a/src/tools/clippy/clippy_lints/src/question_mark.rs b/src/tools/clippy/clippy_lints/src/question_mark.rs index 927c6f1d519..4ad967589a5 100644 --- a/src/tools/clippy/clippy_lints/src/question_mark.rs +++ b/src/tools/clippy/clippy_lints/src/question_mark.rs @@ -14,7 +14,7 @@ use rustc_errors::Applicability; use rustc_hir::def::Res; use rustc_hir::LangItem::{self, OptionNone, OptionSome, ResultErr, ResultOk}; use rustc_hir::{ - BindingAnnotation, Block, Body, ByRef, Expr, ExprKind, LetStmt, Mutability, Node, PatKind, PathSegment, QPath, + BindingMode, Block, Body, ByRef, Expr, ExprKind, LetStmt, Mutability, Node, PatKind, PathSegment, QPath, Stmt, StmtKind, }; use rustc_lint::{LateContext, LateLintPass}; @@ -283,7 +283,7 @@ fn check_if_let_some_or_err_and_early_return<'tcx>(cx: &LateContext<'tcx>, expr: && !is_else_clause(cx.tcx, expr) && let PatKind::TupleStruct(ref path1, [field], ddpos) = let_pat.kind && ddpos.as_opt_usize().is_none() - && let PatKind::Binding(BindingAnnotation(by_ref, _), bind_id, ident, None) = field.kind + && let PatKind::Binding(BindingMode(by_ref, _), bind_id, ident, None) = field.kind && let caller_ty = cx.typeck_results().expr_ty(let_expr) && let if_block = IfBlockType::IfLet( cx.qpath_res(path1, let_pat.hir_id), diff --git a/src/tools/clippy/clippy_lints/src/redundant_locals.rs b/src/tools/clippy/clippy_lints/src/redundant_locals.rs index 7202266deeb..d94ca5bc7ec 100644 --- a/src/tools/clippy/clippy_lints/src/redundant_locals.rs +++ b/src/tools/clippy/clippy_lints/src/redundant_locals.rs @@ -3,7 +3,7 @@ use clippy_utils::is_from_proc_macro; use clippy_utils::ty::needs_ordered_drop; use rustc_ast::Mutability; use rustc_hir::def::Res; -use rustc_hir::{BindingAnnotation, ByRef, ExprKind, HirId, LetStmt, Node, Pat, PatKind, QPath}; +use rustc_hir::{BindingMode, ByRef, ExprKind, HirId, LetStmt, Node, Pat, PatKind, QPath}; use rustc_hir_typeck::expr_use_visitor::PlaceBase; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; @@ -50,7 +50,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantLocals { fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx LetStmt<'tcx>) { if !local.span.is_desugaring(DesugaringKind::Async) // the pattern is a single by-value binding - && let PatKind::Binding(BindingAnnotation(ByRef::No, mutability), _, ident, None) = local.pat.kind + && let PatKind::Binding(BindingMode(ByRef::No, mutability), _, ident, None) = local.pat.kind // the binding is not type-ascribed && local.ty.is_none() // the expression is a resolved path @@ -109,7 +109,7 @@ fn is_by_value_closure_capture(cx: &LateContext<'_>, redefinition: HirId, root_v } /// Find the annotation of a binding introduced by a pattern, or `None` if it's not introduced. -fn find_binding(pat: &Pat<'_>, name: Ident) -> Option<BindingAnnotation> { +fn find_binding(pat: &Pat<'_>, name: Ident) -> Option<BindingMode> { let mut ret = None; pat.each_binding_or_first(&mut |annotation, _, _, ident| { diff --git a/src/tools/clippy/clippy_lints/src/ref_patterns.rs b/src/tools/clippy/clippy_lints/src/ref_patterns.rs index a4be78b310b..607a0740b84 100644 --- a/src/tools/clippy/clippy_lints/src/ref_patterns.rs +++ b/src/tools/clippy/clippy_lints/src/ref_patterns.rs @@ -1,5 +1,5 @@ use clippy_utils::diagnostics::span_lint_and_help; -use rustc_ast::ast::{BindingAnnotation, Pat, PatKind}; +use rustc_ast::ast::{BindingMode, Pat, PatKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::declare_lint_pass; @@ -28,7 +28,7 @@ declare_lint_pass!(RefPatterns => [REF_PATTERNS]); impl EarlyLintPass for RefPatterns { fn check_pat(&mut self, cx: &EarlyContext<'_>, pat: &Pat) { - if let PatKind::Ident(BindingAnnotation::REF, _, _) = pat.kind + if let PatKind::Ident(BindingMode::REF, _, _) = pat.kind && !pat.span.from_expansion() { span_lint_and_help( diff --git a/src/tools/clippy/clippy_lints/src/reserve_after_initialization.rs b/src/tools/clippy/clippy_lints/src/reserve_after_initialization.rs index c227b5b22f4..caf3fb8707d 100644 --- a/src/tools/clippy/clippy_lints/src/reserve_after_initialization.rs +++ b/src/tools/clippy/clippy_lints/src/reserve_after_initialization.rs @@ -4,7 +4,7 @@ use clippy_utils::source::snippet; use clippy_utils::{is_from_proc_macro, path_to_local_id}; use rustc_errors::Applicability; use rustc_hir::def::Res; -use rustc_hir::{BindingAnnotation, Block, Expr, ExprKind, HirId, LetStmt, PatKind, QPath, Stmt, StmtKind}; +use rustc_hir::{BindingMode, Block, Expr, ExprKind, HirId, LetStmt, PatKind, QPath, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::impl_lint_pass; @@ -71,7 +71,7 @@ impl<'tcx> LateLintPass<'tcx> for ReserveAfterInitialization { fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx LetStmt<'tcx>) { if let Some(init_expr) = local.init - && let PatKind::Binding(BindingAnnotation::MUT, id, _, None) = local.pat.kind + && let PatKind::Binding(BindingMode::MUT, id, _, None) = local.pat.kind && !in_external_macro(cx.sess(), local.span) && let Some(init) = get_vec_init_kind(cx, init_expr) && !matches!( diff --git a/src/tools/clippy/clippy_lints/src/slow_vector_initialization.rs b/src/tools/clippy/clippy_lints/src/slow_vector_initialization.rs index 8a9f02b6dcb..28c254537ab 100644 --- a/src/tools/clippy/clippy_lints/src/slow_vector_initialization.rs +++ b/src/tools/clippy/clippy_lints/src/slow_vector_initialization.rs @@ -7,7 +7,7 @@ use clippy_utils::{ }; use rustc_errors::Applicability; use rustc_hir::intravisit::{walk_block, walk_expr, walk_stmt, Visitor}; -use rustc_hir::{BindingAnnotation, Block, Expr, ExprKind, HirId, PatKind, Stmt, StmtKind}; +use rustc_hir::{BindingMode, Block, Expr, ExprKind, HirId, PatKind, Stmt, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; use rustc_span::symbol::sym; @@ -120,7 +120,7 @@ impl<'tcx> LateLintPass<'tcx> for SlowVectorInit { // Matches statements which initializes vectors. For example: `let mut vec = Vec::with_capacity(10)` // or `Vec::new()` if let StmtKind::Let(local) = stmt.kind - && let PatKind::Binding(BindingAnnotation::MUT, local_id, _, None) = local.pat.kind + && let PatKind::Binding(BindingMode::MUT, local_id, _, None) = local.pat.kind && let Some(init) = local.init && let Some(size_expr) = Self::as_vec_initializer(cx, init) { diff --git a/src/tools/clippy/clippy_lints/src/unnecessary_struct_initialization.rs b/src/tools/clippy/clippy_lints/src/unnecessary_struct_initialization.rs index 333ea0c82df..2da75334344 100644 --- a/src/tools/clippy/clippy_lints/src/unnecessary_struct_initialization.rs +++ b/src/tools/clippy/clippy_lints/src/unnecessary_struct_initialization.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use clippy_utils::ty::is_copy; use clippy_utils::{get_parent_expr, path_to_local}; -use rustc_hir::{BindingAnnotation, Expr, ExprKind, Node, PatKind, UnOp}; +use rustc_hir::{BindingMode, Expr, ExprKind, Node, PatKind, UnOp}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; @@ -84,7 +84,7 @@ fn is_mutable(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { if let Some(hir_id) = path_to_local(expr) && let Node::Pat(pat) = cx.tcx.hir_node(hir_id) { - matches!(pat.kind, PatKind::Binding(BindingAnnotation::MUT, ..)) + matches!(pat.kind, PatKind::Binding(BindingMode::MUT, ..)) } else { true } diff --git a/src/tools/clippy/clippy_lints/src/unnested_or_patterns.rs b/src/tools/clippy/clippy_lints/src/unnested_or_patterns.rs index 0049de931f4..fcc41b51542 100644 --- a/src/tools/clippy/clippy_lints/src/unnested_or_patterns.rs +++ b/src/tools/clippy/clippy_lints/src/unnested_or_patterns.rs @@ -137,12 +137,12 @@ fn insert_necessary_parens(pat: &mut P<Pat>) { struct Visitor; impl MutVisitor for Visitor { fn visit_pat(&mut self, pat: &mut P<Pat>) { - use ast::BindingAnnotation; + use ast::BindingMode; noop_visit_pat(pat, self); let target = match &mut pat.kind { // `i @ a | b`, `box a | b`, and `& mut? a | b`. Ident(.., Some(p)) | Box(p) | Ref(p, _) if matches!(&p.kind, Or(ps) if ps.len() > 1) => p, - Ref(p, Mutability::Not) if matches!(p.kind, Ident(BindingAnnotation::MUT, ..)) => p, // `&(mut x)` + Ref(p, Mutability::Not) if matches!(p.kind, Ident(BindingMode::MUT, ..)) => p, // `&(mut x)` _ => return, }; target.kind = Paren(P(take_pat(target))); diff --git a/src/tools/clippy/clippy_lints/src/useless_conversion.rs b/src/tools/clippy/clippy_lints/src/useless_conversion.rs index 75541766156..2f7d54e73ed 100644 --- a/src/tools/clippy/clippy_lints/src/useless_conversion.rs +++ b/src/tools/clippy/clippy_lints/src/useless_conversion.rs @@ -5,7 +5,7 @@ use clippy_utils::ty::{is_copy, is_type_diagnostic_item, same_type_and_consts}; use clippy_utils::{get_parent_expr, is_trait_method, is_ty_alias, path_to_local}; use rustc_errors::Applicability; use rustc_hir::def_id::DefId; -use rustc_hir::{BindingAnnotation, Expr, ExprKind, HirId, MatchSource, Node, PatKind}; +use rustc_hir::{BindingMode, Expr, ExprKind, HirId, MatchSource, Node, PatKind}; use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::traits::Obligation; use rustc_lint::{LateContext, LateLintPass}; @@ -282,7 +282,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { if let Some(id) = path_to_local(recv) && let Node::Pat(pat) = cx.tcx.hir_node(id) && let PatKind::Binding(ann, ..) = pat.kind - && ann != BindingAnnotation::MUT + && ann != BindingMode::MUT { // Do not remove .into_iter() applied to a non-mutable local variable used in // a larger expression context as it would differ in mutability. diff --git a/src/tools/clippy/clippy_lints/src/utils/author.rs b/src/tools/clippy/clippy_lints/src/utils/author.rs index 7b43abeef67..7f0769452c7 100644 --- a/src/tools/clippy/clippy_lints/src/utils/author.rs +++ b/src/tools/clippy/clippy_lints/src/utils/author.rs @@ -7,7 +7,7 @@ use rustc_ast::LitIntType; use rustc_data_structures::fx::FxHashMap; use rustc_hir as hir; use rustc_hir::{ - ArrayLen, BindingAnnotation, CaptureBy, Closure, ClosureKind, CoroutineKind, ExprKind, FnRetTy, HirId, Lit, + ArrayLen, BindingMode, CaptureBy, Closure, ClosureKind, CoroutineKind, ExprKind, FnRetTy, HirId, Lit, PatKind, QPath, StmtKind, TyKind, }; use rustc_lint::{LateContext, LateLintPass, LintContext}; @@ -645,14 +645,14 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> { bind!(self, name); opt_bind!(self, sub); let ann = match ann { - BindingAnnotation::NONE => "NONE", - BindingAnnotation::REF => "REF", - BindingAnnotation::MUT => "MUT", - BindingAnnotation::REF_MUT => "REF_MUT", - BindingAnnotation::MUT_REF => "MUT_REF", - BindingAnnotation::MUT_REF_MUT => "MUT_REF_MUT", + BindingMode::NONE => "NONE", + BindingMode::REF => "REF", + BindingMode::MUT => "MUT", + BindingMode::REF_MUT => "REF_MUT", + BindingMode::MUT_REF => "MUT_REF", + BindingMode::MUT_REF_MUT => "MUT_REF_MUT", }; - kind!("Binding(BindingAnnotation::{ann}, _, {name}, {sub})"); + kind!("Binding(BindingMode::{ann}, _, {name}, {sub})"); self.ident(name); sub.if_some(|p| self.pat(p)); }, diff --git a/src/tools/clippy/clippy_lints/src/vec_init_then_push.rs b/src/tools/clippy/clippy_lints/src/vec_init_then_push.rs index b58a4fb8474..c46f0298cc8 100644 --- a/src/tools/clippy/clippy_lints/src/vec_init_then_push.rs +++ b/src/tools/clippy/clippy_lints/src/vec_init_then_push.rs @@ -7,7 +7,7 @@ use core::ops::ControlFlow; use rustc_errors::Applicability; use rustc_hir::def::Res; use rustc_hir::{ - BindingAnnotation, Block, Expr, ExprKind, HirId, LetStmt, Mutability, PatKind, QPath, Stmt, StmtKind, UnOp, + BindingMode, Block, Expr, ExprKind, HirId, LetStmt, Mutability, PatKind, QPath, Stmt, StmtKind, UnOp, }; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; @@ -159,7 +159,7 @@ impl<'tcx> LateLintPass<'tcx> for VecInitThenPush { fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx LetStmt<'tcx>) { if let Some(init_expr) = local.init - && let PatKind::Binding(BindingAnnotation::MUT, id, name, None) = local.pat.kind + && let PatKind::Binding(BindingMode::MUT, id, name, None) = local.pat.kind && !in_external_macro(cx.sess(), local.span) && let Some(init) = get_vec_init_kind(cx, init_expr) && !matches!(init, VecInitKind::WithExprCapacity(_)) diff --git a/src/tools/clippy/clippy_utils/src/hir_utils.rs b/src/tools/clippy/clippy_utils/src/hir_utils.rs index 6c3d9329932..07c443acb05 100644 --- a/src/tools/clippy/clippy_utils/src/hir_utils.rs +++ b/src/tools/clippy/clippy_utils/src/hir_utils.rs @@ -7,7 +7,7 @@ use rustc_data_structures::fx::FxHasher; use rustc_hir::def::Res; use rustc_hir::MatchSource::TryDesugar; use rustc_hir::{ - ArrayLen, BinOpKind, BindingAnnotation, Block, BodyId, Closure, Expr, ExprField, ExprKind, FnRetTy, GenericArg, + ArrayLen, BinOpKind, BindingMode, Block, BodyId, Closure, Expr, ExprField, ExprKind, FnRetTy, GenericArg, GenericArgs, HirId, HirIdMap, InlineAsmOperand, LetExpr, Lifetime, LifetimeName, Pat, PatField, PatKind, Path, PathSegment, PrimTy, QPath, Stmt, StmtKind, Ty, TyKind, TypeBinding, }; @@ -947,7 +947,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> { pub fn hash_pat(&mut self, pat: &Pat<'_>) { std::mem::discriminant(&pat.kind).hash(&mut self.s); match pat.kind { - PatKind::Binding(BindingAnnotation(by_ref, mutability), _, _, pat) => { + PatKind::Binding(BindingMode(by_ref, mutability), _, _, pat) => { std::mem::discriminant(&by_ref).hash(&mut self.s); std::mem::discriminant(&mutability).hash(&mut self.s); if let Some(pat) = pat { diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index 37c12dd850c..aac699eed23 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -99,7 +99,7 @@ use rustc_hir::hir_id::{HirIdMap, HirIdSet}; use rustc_hir::intravisit::{walk_expr, FnKind, Visitor}; use rustc_hir::LangItem::{OptionNone, OptionSome, ResultErr, ResultOk}; use rustc_hir::{ - self as hir, def, Arm, ArrayLen, BindingAnnotation, Block, BlockCheckMode, Body, ByRef, Closure, Destination, Expr, + self as hir, def, Arm, ArrayLen, BindingMode, Block, BlockCheckMode, Body, ByRef, Closure, Destination, Expr, ExprField, ExprKind, FnDecl, FnRetTy, GenericArgs, HirId, Impl, ImplItem, ImplItemKind, ImplItemRef, Item, ItemKind, LangItem, LetStmt, MatchSource, Mutability, Node, OwnerId, Param, Pat, PatKind, Path, PathSegment, PrimTy, QPath, Stmt, StmtKind, TraitItem, TraitItemKind, TraitItemRef, TraitRef, TyKind, UnOp, @@ -184,7 +184,7 @@ pub fn expr_or_init<'a, 'b, 'tcx: 'b>(cx: &LateContext<'tcx>, mut expr: &'a Expr /// canonical binding `HirId`. pub fn find_binding_init<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<&'tcx Expr<'tcx>> { if let Node::Pat(pat) = cx.tcx.hir_node(hir_id) - && matches!(pat.kind, PatKind::Binding(BindingAnnotation::NONE, ..)) + && matches!(pat.kind, PatKind::Binding(BindingMode::NONE, ..)) && let Node::LetStmt(local) = cx.tcx.parent_hir_node(hir_id) { return local.init; diff --git a/src/tools/clippy/tests/ui/author.stdout b/src/tools/clippy/tests/ui/author.stdout index 27ad538f24d..d448db097a7 100644 --- a/src/tools/clippy/tests/ui/author.stdout +++ b/src/tools/clippy/tests/ui/author.stdout @@ -5,7 +5,7 @@ if let StmtKind::Local(local) = stmt.kind && match_qpath(qpath, &["char"]) && let ExprKind::Lit(ref lit) = expr.kind && let LitKind::Int(69, LitIntType::Unsuffixed) = lit.node - && let PatKind::Binding(BindingAnnotation::NONE, _, name, None) = local.pat.kind + && let PatKind::Binding(BindingMode::NONE, _, name, None) = local.pat.kind && name.as_str() == "x" { // report your lint here diff --git a/src/tools/clippy/tests/ui/author/blocks.stdout b/src/tools/clippy/tests/ui/author/blocks.stdout index 579f137f861..80b928dd6cb 100644 --- a/src/tools/clippy/tests/ui/author/blocks.stdout +++ b/src/tools/clippy/tests/ui/author/blocks.stdout @@ -4,13 +4,13 @@ if let ExprKind::Block(block, None) = expr.kind && let Some(init) = local.init && let ExprKind::Lit(ref lit) = init.kind && let LitKind::Int(42, LitIntType::Signed(IntTy::I32)) = lit.node - && let PatKind::Binding(BindingAnnotation::NONE, _, name, None) = local.pat.kind + && let PatKind::Binding(BindingMode::NONE, _, name, None) = local.pat.kind && name.as_str() == "x" && let StmtKind::Local(local1) = block.stmts[1].kind && let Some(init1) = local1.init && let ExprKind::Lit(ref lit1) = init1.kind && let LitKind::Float(_, LitFloatType::Suffixed(FloatTy::F32)) = lit1.node - && let PatKind::Binding(BindingAnnotation::NONE, _, name1, None) = local1.pat.kind + && let PatKind::Binding(BindingMode::NONE, _, name1, None) = local1.pat.kind && name1.as_str() == "_t" && let StmtKind::Semi(e) = block.stmts[2].kind && let ExprKind::Unary(UnOp::Neg, inner) = e.kind @@ -28,7 +28,7 @@ if let ExprKind::Block(block, None) = expr.kind && let ExprKind::Path(ref qpath) = func.kind && match_qpath(qpath, &["String", "new"]) && args.is_empty() - && let PatKind::Binding(BindingAnnotation::NONE, _, name, None) = local.pat.kind + && let PatKind::Binding(BindingMode::NONE, _, name, None) = local.pat.kind && name.as_str() == "expr" && let Some(trailing_expr) = block.expr && let ExprKind::Call(func1, args1) = trailing_expr.kind diff --git a/src/tools/clippy/tests/ui/author/loop.stdout b/src/tools/clippy/tests/ui/author/loop.stdout index 94a6436ed54..631105a2238 100644 --- a/src/tools/clippy/tests/ui/author/loop.stdout +++ b/src/tools/clippy/tests/ui/author/loop.stdout @@ -1,5 +1,5 @@ if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::ForLoop::hir(expr) - && let PatKind::Binding(BindingAnnotation::NONE, _, name, None) = pat.kind + && let PatKind::Binding(BindingMode::NONE, _, name, None) = pat.kind && name.as_str() == "y" && let ExprKind::Struct(qpath, fields, None) = arg.kind && matches!(qpath, QPath::LangItem(LangItem::Range, _)) @@ -16,7 +16,7 @@ if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::Fo && let Some(init) = local.init && let ExprKind::Path(ref qpath1) = init.kind && match_qpath(qpath1, &["y"]) - && let PatKind::Binding(BindingAnnotation::NONE, _, name1, None) = local.pat.kind + && let PatKind::Binding(BindingMode::NONE, _, name1, None) = local.pat.kind && name1.as_str() == "z" && block.expr.is_none() { diff --git a/src/tools/clippy/tests/ui/author/macro_in_closure.stdout b/src/tools/clippy/tests/ui/author/macro_in_closure.stdout index f2e54c2c1c8..b90c830e030 100644 --- a/src/tools/clippy/tests/ui/author/macro_in_closure.stdout +++ b/src/tools/clippy/tests/ui/author/macro_in_closure.stdout @@ -34,7 +34,7 @@ if let StmtKind::Local(local) = stmt.kind && let ExprKind::Path(ref qpath3) = inner2.kind && match_qpath(qpath3, &["x"]) && block.expr.is_none() - && let PatKind::Binding(BindingAnnotation::NONE, _, name, None) = local.pat.kind + && let PatKind::Binding(BindingMode::NONE, _, name, None) = local.pat.kind && name.as_str() == "print_text" { // report your lint here diff --git a/src/tools/clippy/tests/ui/author/macro_in_loop.stdout b/src/tools/clippy/tests/ui/author/macro_in_loop.stdout index a719e3af7e7..3f9be297c33 100644 --- a/src/tools/clippy/tests/ui/author/macro_in_loop.stdout +++ b/src/tools/clippy/tests/ui/author/macro_in_loop.stdout @@ -1,5 +1,5 @@ if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::ForLoop::hir(expr) - && let PatKind::Binding(BindingAnnotation::NONE, _, name, None) = pat.kind + && let PatKind::Binding(BindingMode::NONE, _, name, None) = pat.kind && name.as_str() == "i" && let ExprKind::Struct(qpath, fields, None) = arg.kind && matches!(qpath, QPath::LangItem(LangItem::Range, _)) diff --git a/src/tools/clippy/tests/ui/author/matches.stdout b/src/tools/clippy/tests/ui/author/matches.stdout index 88e2ca656a4..30e4a9b2560 100644 --- a/src/tools/clippy/tests/ui/author/matches.stdout +++ b/src/tools/clippy/tests/ui/author/matches.stdout @@ -20,7 +20,7 @@ if let StmtKind::Local(local) = stmt.kind && let Some(init1) = local1.init && let ExprKind::Lit(ref lit4) = init1.kind && let LitKind::Int(3, LitIntType::Unsuffixed) = lit4.node - && let PatKind::Binding(BindingAnnotation::NONE, _, name, None) = local1.pat.kind + && let PatKind::Binding(BindingMode::NONE, _, name, None) = local1.pat.kind && name.as_str() == "x" && let Some(trailing_expr) = block.expr && let ExprKind::Path(ref qpath) = trailing_expr.kind @@ -29,7 +29,7 @@ if let StmtKind::Local(local) = stmt.kind && arms[2].guard.is_none() && let ExprKind::Lit(ref lit5) = arms[2].body.kind && let LitKind::Int(1, LitIntType::Unsuffixed) = lit5.node - && let PatKind::Binding(BindingAnnotation::NONE, _, name1, None) = local.pat.kind + && let PatKind::Binding(BindingMode::NONE, _, name1, None) = local.pat.kind && name1.as_str() == "a" { // report your lint here diff --git a/src/tools/generate-windows-sys/Cargo.toml b/src/tools/generate-windows-sys/Cargo.toml index 9ea26defdc4..8b971d6efe7 100644 --- a/src/tools/generate-windows-sys/Cargo.toml +++ b/src/tools/generate-windows-sys/Cargo.toml @@ -4,4 +4,4 @@ version = "0.1.0" edition = "2021" [dependencies.windows-bindgen] -version = "0.55.0" +version = "0.56.0" diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs index 0bfc59e67db..26f8c0a3bab 100644 --- a/src/tools/miri/src/machine.rs +++ b/src/tools/miri/src/machine.rs @@ -241,12 +241,12 @@ pub enum ProvenanceExtra { Wildcard, } -#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] static_assert_size!(Pointer<Provenance>, 24); // FIXME: this would with in 24bytes but layout optimizations are not smart enough -// #[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] +// #[cfg(target_pointer_width = "64")] //static_assert_size!(Pointer<Option<Provenance>>, 24); -#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))] +#[cfg(target_pointer_width = "64")] static_assert_size!(Scalar<Provenance>, 32); impl fmt::Debug for Provenance { diff --git a/src/tools/rustfmt/src/patterns.rs b/src/tools/rustfmt/src/patterns.rs index 820eccb2dc2..d8cb26a20f1 100644 --- a/src/tools/rustfmt/src/patterns.rs +++ b/src/tools/rustfmt/src/patterns.rs @@ -1,6 +1,4 @@ -use rustc_ast::ast::{ - self, BindingAnnotation, ByRef, Pat, PatField, PatKind, RangeEnd, RangeSyntax, -}; +use rustc_ast::ast::{self, BindingMode, ByRef, Pat, PatField, PatKind, RangeEnd, RangeSyntax}; use rustc_ast::ptr; use rustc_span::{BytePos, Span}; @@ -106,7 +104,7 @@ impl Rewrite for Pat { write_list(&items, &fmt) } PatKind::Box(ref pat) => rewrite_unary_prefix(context, "box ", &**pat, shape), - PatKind::Ident(BindingAnnotation(by_ref, mutability), ident, ref sub_pat) => { + PatKind::Ident(BindingMode(by_ref, mutability), ident, ref sub_pat) => { let mut_prefix = format_mutability(mutability).trim(); let (ref_kw, mut_infix) = match by_ref { diff --git a/tests/codegen/mem-replace-simple-type.rs b/tests/codegen/mem-replace-simple-type.rs index 50b43f5854a..7209fa21925 100644 --- a/tests/codegen/mem-replace-simple-type.rs +++ b/tests/codegen/mem-replace-simple-type.rs @@ -34,18 +34,20 @@ pub fn replace_ref_str<'a>(r: &mut &'a str, v: &'a str) -> &'a str { #[no_mangle] // CHECK-LABEL: @replace_short_array_3( +// CHECK-SAME: ptr{{.+}}sret{{.+}}%[[RET:.+]], ptr{{.+}}%r, ptr{{.+}}%v pub fn replace_short_array_3(r: &mut [u32; 3], v: [u32; 3]) -> [u32; 3] { // CHECK-NOT: alloca - // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %result, ptr align 4 %r, i64 12, i1 false) + // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[RET]], ptr align 4 %r, i64 12, i1 false) // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %r, ptr align 4 %v, i64 12, i1 false) std::mem::replace(r, v) } #[no_mangle] // CHECK-LABEL: @replace_short_array_4( +// CHECK-SAME: ptr{{.+}}sret{{.+}}%[[RET:.+]], ptr{{.+}}%r, ptr{{.+}}%v pub fn replace_short_array_4(r: &mut [u32; 4], v: [u32; 4]) -> [u32; 4] { // CHECK-NOT: alloca - // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %result, ptr align 4 %r, i64 16, i1 false) + // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[RET]], ptr align 4 %r, i64 16, i1 false) // CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %r, ptr align 4 %v, i64 16, i1 false) std::mem::replace(r, v) } diff --git a/tests/codegen/slice-ref-equality.rs b/tests/codegen/slice-ref-equality.rs index 85d9c34a30b..7ab70108fe0 100644 --- a/tests/codegen/slice-ref-equality.rs +++ b/tests/codegen/slice-ref-equality.rs @@ -43,48 +43,48 @@ pub fn is_zero_array(data: &[u8; 4]) -> bool { // equality for non-byte types also just emit a `bcmp`, not a loop. // CHECK-LABEL: @eq_slice_of_nested_u8( -// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1 -// CHECK-SAME: [[USIZE]] noundef %3 +// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1 +// CHECK-SAME: [[USIZE]] noundef %y.1 #[no_mangle] fn eq_slice_of_nested_u8(x: &[[u8; 3]], y: &[[u8; 3]]) -> bool { - // CHECK: icmp eq [[USIZE]] %1, %3 - // CHECK: %[[BYTES:.+]] = mul nsw [[USIZE]] %1, 3 + // CHECK: icmp eq [[USIZE]] %x.1, %y.1 + // CHECK: %[[BYTES:.+]] = mul nsw [[USIZE]] {{%x.1|%y.1}}, 3 // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y } // CHECK-LABEL: @eq_slice_of_i32( -// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1 -// CHECK-SAME: [[USIZE]] noundef %3 +// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1 +// CHECK-SAME: [[USIZE]] noundef %y.1 #[no_mangle] fn eq_slice_of_i32(x: &[i32], y: &[i32]) -> bool { - // CHECK: icmp eq [[USIZE]] %1, %3 - // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 2 + // CHECK: icmp eq [[USIZE]] %x.1, %y.1 + // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] {{%x.1|%y.1}}, 2 // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y } // CHECK-LABEL: @eq_slice_of_nonzero( -// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1 -// CHECK-SAME: [[USIZE]] noundef %3 +// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1 +// CHECK-SAME: [[USIZE]] noundef %y.1 #[no_mangle] fn eq_slice_of_nonzero(x: &[NonZero<i32>], y: &[NonZero<i32>]) -> bool { - // CHECK: icmp eq [[USIZE]] %1, %3 - // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 2 + // CHECK: icmp eq [[USIZE]] %x.1, %y.1 + // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] {{%x.1|%y.1}}, 2 // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y } // CHECK-LABEL: @eq_slice_of_option_of_nonzero( -// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %1 -// CHECK-SAME: [[USIZE]] noundef %3 +// CHECK-SAME: [[USIZE:i16|i32|i64]] noundef %x.1 +// CHECK-SAME: [[USIZE]] noundef %y.1 #[no_mangle] fn eq_slice_of_option_of_nonzero(x: &[Option<NonZero<i16>>], y: &[Option<NonZero<i16>>]) -> bool { - // CHECK: icmp eq [[USIZE]] %1, %3 - // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] %1, 1 + // CHECK: icmp eq [[USIZE]] %x.1, %y.1 + // CHECK: %[[BYTES:.+]] = shl nsw [[USIZE]] {{%x.1|%y.1}}, 1 // CHECK: tail call{{( noundef)?}} i32 @{{bcmp|memcmp}}(ptr // CHECK-SAME: , [[USIZE]]{{( noundef)?}} %[[BYTES]]) x == y diff --git a/tests/crashes/100618.rs b/tests/crashes/100618.rs new file mode 100644 index 00000000000..911c4098bad --- /dev/null +++ b/tests/crashes/100618.rs @@ -0,0 +1,12 @@ +//@ known-bug: #100618 +//@ compile-flags: -Cdebuginfo=2 + +//@ only-x86_64 +enum Foo<T: 'static> { + Value(T), + Recursive(&'static Foo<Option<T>>), +} + +fn main() { + let _x = Foo::Value(()); +} diff --git a/tests/crashes/105299.rs b/tests/crashes/105299.rs new file mode 100644 index 00000000000..8e3aafa47bc --- /dev/null +++ b/tests/crashes/105299.rs @@ -0,0 +1,19 @@ +//@ known-bug: #105299 + +pub trait Foo: Clone {} + +pub struct Bar<'a, T: Clone> { + pub cow: std::borrow::Cow<'a, [T]>, + + pub THIS_CAUSES_ICE: (), // #1 +} + +impl<T> Bar<'_, T> +where + T: Clone, + [T]: Foo, +{ + pub fn MOVES_SELF(self) {} // #2 +} + +pub fn main() {} diff --git a/tests/crashes/107362.rs b/tests/crashes/107362.rs new file mode 100644 index 00000000000..8d55d611eb1 --- /dev/null +++ b/tests/crashes/107362.rs @@ -0,0 +1,43 @@ +//@ known-bug: #107362 +//@ compile-flags: -Cdebuginfo=2 + +pub trait Functor +{ + type With<T>: Functor; +} + +pub struct IdFunctor<T>(T); +impl<T> Functor for IdFunctor<T> { + type With<T2> = IdFunctor<T2>; +} + +impl<T> Functor for Vec<T> { + type With<T2> = Vec<T2> ; +} + + +pub struct Compose<F1, F2, T>(F1::With<F2::With<T>>) +where + F1: Functor + ?Sized, + F2: Functor + ?Sized; + +impl<F1, F2, T> Functor for Compose<F1, F2, T> +where + F1: Functor + ?Sized, + F2: Functor + ?Sized +{ + type With<T2> = F1::With<F2::With<T2>> ; +} + +pub enum Value<F> +where + F: Functor + ?Sized, +{ + SignedInt(*mut F::With<i64>), + Array(*mut Value<Compose<F, Vec<()>, ()>>), + +} + +fn main() { + let x: Value<IdFunctor<()>> = Value::SignedInt(&mut IdFunctor(1)); +} diff --git a/tests/crashes/108499.rs b/tests/crashes/108499.rs new file mode 100644 index 00000000000..4a0638cd59a --- /dev/null +++ b/tests/crashes/108499.rs @@ -0,0 +1,44 @@ +//@ known-bug: #108499 + +// at lower recursion limits the recursion limit is reached before the bug happens +#![recursion_limit = "2000"] + +// this will try to calculate 3↑↑3=3^(3^3) +type Test = <() as Op<((), ()), [[[(); 0]; 0]; 0], [[[(); 0]; 0]; 0], + [[[[(); 0]; 0]; 0]; 0]>>::Result; + +use std::default::Default; + +fn main() { + // force the compiler to actually evaluate `Test` + println!("{}", Test::default()); +} + +trait Op<X, A, B, C> { + type Result; +} + +// this recursive function defines the hyperoperation sequence, +// a canonical example of the type of recursion which produces the issue +// the problem seems to be caused by having two recursive calls, the second +// of which depending on the first +impl< + X: Op<(X, Y), A, [B; 0], [C; 0]>, + Y: Op<(X, Y), A, X::Result, C>, + A, B, C, +> Op<(X, Y), A, [[B; 0]; 0], [C; 0]> for () { + type Result = Y::Result; +} + +// base cases +impl<X, A, B> Op<X, A, B, ()> for () { + type Result = [B; 0]; +} + +impl<X, A> Op<X, A, [(); 0], [(); 0]> for () { + type Result = [A; 0]; +} + +impl<X, A, C> Op<X, A, [(); 0], [[C; 0]; 0]> for () { + type Result = A; +} diff --git a/tests/crashes/112623.rs b/tests/crashes/112623.rs new file mode 100644 index 00000000000..fc7361bfcb2 --- /dev/null +++ b/tests/crashes/112623.rs @@ -0,0 +1,26 @@ +//@ known-bug: #112623 + +#![feature(const_trait_impl, effects)] + +#[const_trait] +trait Value { + fn value() -> u32; +} + +const fn get_value<T: ~const Value>() -> u32 { + T::value() +} + +struct FortyTwo; + +impl const Value for FortyTwo { + fn value() -> i64 { + 42 + } +} + +const FORTY_TWO: u32 = get_value::<FortyTwo>(); + +fn main() { + assert_eq!(FORTY_TWO, 42); +} diff --git a/tests/crashes/114198-2.rs b/tests/crashes/114198-2.rs new file mode 100644 index 00000000000..de9d61ae1b9 --- /dev/null +++ b/tests/crashes/114198-2.rs @@ -0,0 +1,15 @@ +//@ known-bug: #114198 +//@ compile-flags: -Zprint-mono-items=eager + +impl Trait for <Ty as Owner>::Struct {} +trait Trait { + fn test(&self) {} +} + +enum Ty {} +trait Owner { type Struct: ?Sized; } +impl Owner for Ty { + type Struct = dyn Trait + Send; +} + +fn main() {} diff --git a/tests/crashes/114198.rs b/tests/crashes/114198.rs new file mode 100644 index 00000000000..1ec8cdd424e --- /dev/null +++ b/tests/crashes/114198.rs @@ -0,0 +1,13 @@ +//@ known-bug: #114198 +//@ compile-flags: -Zprint-mono-items=eager + +#![feature(lazy_type_alias)] + +impl Trait for Struct {} +trait Trait { + fn test(&self) {} +} + +type Struct = dyn Trait + Send; + +fn main() {} diff --git a/tests/crashes/114920.rs b/tests/crashes/114920.rs new file mode 100644 index 00000000000..9aa7598e10f --- /dev/null +++ b/tests/crashes/114920.rs @@ -0,0 +1,2 @@ +//@ known-bug: #114920 +#![core::prelude::v1::test] diff --git a/tests/crashes/118185-2.rs b/tests/crashes/118185-2.rs new file mode 100644 index 00000000000..c3a29c3a3f5 --- /dev/null +++ b/tests/crashes/118185-2.rs @@ -0,0 +1,26 @@ +//@ known-bug: #118185 + +fn main() { + let target: Target = create_target(); + target.get(0); // correct arguments work + target.get(10.0); // CRASH HERE +} + +// must be generic +fn create_target<T>() -> T { + unimplemented!() +} + +// unimplemented trait, but contains function with the same name +pub trait RandomTrait { + fn get(&mut self); // but less arguments +} + +struct Target; + +impl Target { + // correct function with arguments + pub fn get(&self, data: i32) { + unimplemented!() + } +} diff --git a/tests/crashes/118185.rs b/tests/crashes/118185.rs new file mode 100644 index 00000000000..c3a29c3a3f5 --- /dev/null +++ b/tests/crashes/118185.rs @@ -0,0 +1,26 @@ +//@ known-bug: #118185 + +fn main() { + let target: Target = create_target(); + target.get(0); // correct arguments work + target.get(10.0); // CRASH HERE +} + +// must be generic +fn create_target<T>() -> T { + unimplemented!() +} + +// unimplemented trait, but contains function with the same name +pub trait RandomTrait { + fn get(&mut self); // but less arguments +} + +struct Target; + +impl Target { + // correct function with arguments + pub fn get(&self, data: i32) { + unimplemented!() + } +} diff --git a/tests/crashes/118545.rs b/tests/crashes/118545.rs new file mode 100644 index 00000000000..1d4bb848bf0 --- /dev/null +++ b/tests/crashes/118545.rs @@ -0,0 +1,8 @@ +//@ known-bug: #118545 +#![feature(generic_const_exprs)] + +struct Checked<const F: fn()>; + +fn foo() {} +const _: Checked<foo> = Checked::<foo>; +pub fn main() {} diff --git a/tests/crashes/118590.rs b/tests/crashes/118590.rs new file mode 100644 index 00000000000..829c16582dc --- /dev/null +++ b/tests/crashes/118590.rs @@ -0,0 +1,11 @@ +//@ known-bug: #118590 + +fn main() { + recurse(std::iter::empty::<()>()) +} + +fn recurse(nums: impl Iterator) { + if true { return } + + recurse(nums.skip(42).peekable()) +} diff --git a/tests/crashes/119381.rs b/tests/crashes/119381.rs new file mode 100644 index 00000000000..51d1d084ba2 --- /dev/null +++ b/tests/crashes/119381.rs @@ -0,0 +1,6 @@ +//@ known-bug: #119381 + +#![feature(with_negative_coherence)] +trait Trait {} +impl<const N: u8> Trait for [(); N] {} +impl<const N: i8> Trait for [(); N] {} diff --git a/tests/crashes/120033.rs b/tests/crashes/120033.rs new file mode 100644 index 00000000000..f1502978dc5 --- /dev/null +++ b/tests/crashes/120033.rs @@ -0,0 +1,14 @@ +//@ known-bug: #120033 +#![feature(non_lifetime_binders)] + +pub trait Foo<T: ?Sized> { + type Bar<K: ?Sized>; +} + +pub struct Bar<T: ?AutoTrait> {} + +pub fn f<T1, T2>() +where + T1: for<T> Foo<usize, Bar = Bar<T>>, + T2: for<L, T> Foo<usize, Bar<T> = T1::Bar<T>>, +{} diff --git a/tests/crashes/120254.rs b/tests/crashes/120254.rs new file mode 100644 index 00000000000..ea68523820e --- /dev/null +++ b/tests/crashes/120254.rs @@ -0,0 +1,24 @@ +//@ known-bug: #120254 + +trait Dbg {} + +struct Foo<I, E> { + input: I, + errors: E, +} + +trait Bar: Offset<<Self as Bar>::Checkpoint> { + type Checkpoint; +} + +impl<I: Bar, E: Dbg> Bar for Foo<I, E> { + type Checkpoint = I::Checkpoint; +} + +trait Offset<Start = Self> {} + +impl<I: Bar, E: Dbg> Offset<<Foo<I, E> as Bar>::Checkpoint> for Foo<I, E> {} + +impl<I: Bar, E> Foo<I, E> { + fn record_err(self, _: <Self as Bar>::Checkpoint) -> () {} +} diff --git a/tests/crashes/120421.rs b/tests/crashes/120421.rs new file mode 100644 index 00000000000..b6059f3ace4 --- /dev/null +++ b/tests/crashes/120421.rs @@ -0,0 +1,12 @@ +//@ known-bug: #120421 +//@ compile-flags: -Zlint-mir + +#![feature(never_patterns)] + +enum Void {} + +fn main() { + let res_void: Result<bool, Void> = Ok(true); + + for (Ok(mut _x) | Err(!)) in [res_void] {} +} diff --git a/tests/crashes/120792.rs b/tests/crashes/120792.rs new file mode 100644 index 00000000000..51889251787 --- /dev/null +++ b/tests/crashes/120792.rs @@ -0,0 +1,25 @@ +//@ known-bug: #120792 +//@ compile-flags: -Zpolymorphize=on -Zinline-mir=yes + +impl Trait<()> for () { + fn foo<'a, K>(self, _: (), _: K) { + todo!(); + } +} + +trait Foo<T> {} + +impl<F, T> Foo<T> for F { + fn main() { + ().foo((), ()); + } +} + +trait Trait<T> { + fn foo<'a, K>(self, _: T, _: K) + where + T: 'a, + K: 'a; +} + +pub fn main() {} diff --git a/tests/crashes/120811.rs b/tests/crashes/120811.rs new file mode 100644 index 00000000000..6b368fe681a --- /dev/null +++ b/tests/crashes/120811.rs @@ -0,0 +1,27 @@ +//@ known-bug: #120811 + +trait Container { + type Item<'a>; +} +impl Container for () { + type Item<'a> = (); +} +struct Exchange<C, F> { + _marker: std::marker::PhantomData<(C, F)>, +} +fn exchange<C, F>(_: F) -> Exchange<C, F> +where + C: Container, + for<'a> F: FnMut(&C::Item<'a>), +{ + unimplemented!() +} +trait Parallelization<C> {} +impl<C, F> Parallelization<C> for Exchange<C, F> {} +fn unary_frontier<P: Parallelization<()>>(_: P) {} +fn main() { + let exchange = exchange(|_| ()); + let _ = || { + unary_frontier(exchange); + }; +} diff --git a/tests/crashes/121063.rs b/tests/crashes/121063.rs new file mode 100644 index 00000000000..cb9db2853c2 --- /dev/null +++ b/tests/crashes/121063.rs @@ -0,0 +1,20 @@ +//@ known-bug: #121063 +//@ compile-flags: -Zpolymorphize=on --edition=2021 -Zinline-mir=yes + +use std::{ + fmt, ops, + path::{Component, Path, PathBuf}, +}; + +pub struct AbsPathBuf(PathBuf); + +impl TryFrom<PathBuf> for AbsPathBuf { + type Error = PathBuf; + fn try_from(path: impl AsRef<Path>) -> Result<AbsPathBuf, PathBuf> {} +} + +impl TryFrom<&str> for AbsPathBuf { + fn try_from(path: &str) -> Result<AbsPathBuf, PathBuf> { + AbsPathBuf::try_from(PathBuf::from(path)) + } +} diff --git a/tests/crashes/121127.rs b/tests/crashes/121127.rs new file mode 100644 index 00000000000..2e64bf68b82 --- /dev/null +++ b/tests/crashes/121127.rs @@ -0,0 +1,23 @@ +//@ known-bug: #121127 +//@ compile-flags: -Zpolymorphize=on -Zinline-mir=yes -C debuginfo=2 +// Note that as of PR#123949 this only crashes with debuginfo enabled + +#![feature(specialization)] + +pub trait Foo { + fn abc() -> u32; +} + +pub trait Marker {} + +impl<T> Foo for T { + default fn abc(f: fn(&T), t: &T) -> u32 { + 16 + } +} + +impl<T: Marker> Foo for T { + fn def() -> u32 { + Self::abc() + } +} diff --git a/tests/crashes/121363.rs b/tests/crashes/121363.rs new file mode 100644 index 00000000000..2a5b6274496 --- /dev/null +++ b/tests/crashes/121363.rs @@ -0,0 +1,9 @@ +//@ known-bug: #121363 +//@ compile-flags: -Zmir-opt-level=5 --crate-type lib + +#![feature(trivial_bounds)] + +#[derive(Debug)] +struct TwoStrs(str, str) +where + str: Sized; diff --git a/tests/crashes/121538.rs b/tests/crashes/121538.rs new file mode 100644 index 00000000000..f18bad84b57 --- /dev/null +++ b/tests/crashes/121538.rs @@ -0,0 +1,30 @@ +//@ known-bug: #121538 +//@ compile-flags: -Cdebuginfo=2 + +use std::marker::PhantomData; + +struct Digit<T> { + elem: T +} + +struct Node<T:'static> { m: PhantomData<&'static T> } + +enum FingerTree<T:'static> { + Single(T), + + Deep( + Digit<T>, + Node<FingerTree<Node<T>>>, + ) +} + +enum Wrapper<T:'static> { + Simple, + Other(FingerTree<T>), +} + +fn main() { + let w = + Some(Wrapper::Simple::<u32>); + +} diff --git a/tests/crashes/122259.rs b/tests/crashes/122259.rs new file mode 100644 index 00000000000..5ac8063f0f3 --- /dev/null +++ b/tests/crashes/122259.rs @@ -0,0 +1,12 @@ +//@ known-bug: #122259 + +#![feature(unsized_fn_params)] + +#[derive(Copy, Clone)] +struct Target(str); + +fn w(t: &Target) { + x(*t); +} + +fn x(t: Target) {} diff --git a/tests/crashes/122548.rs b/tests/crashes/122548.rs deleted file mode 100644 index 232ce5d4413..00000000000 --- a/tests/crashes/122548.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ known-bug: #122548 -#![feature(const_mut_refs)] -#![feature(const_refs_to_static)] - -use std::cell::UnsafeCell; - -struct Meh { - x: &'static UnsafeCell<i32>, -} - -const MUH: Meh = Meh { - x: &mut *(&READONLY as *const _ as *mut _), -}; - -static READONLY: i32 = 0; - -pub fn main() {} diff --git a/tests/crashes/122630.rs b/tests/crashes/122630.rs new file mode 100644 index 00000000000..e66624431c5 --- /dev/null +++ b/tests/crashes/122630.rs @@ -0,0 +1,22 @@ +//@ known-bug: #122630 +//@ compile-flags: -Zvalidate-mir + +use std::ops::Coroutine; + +const FOO_SIZE: usize = 1024; +struct Foo([u8; FOO_SIZE]); + +impl Drop for Foo { + fn move_before_yield_with_noop() -> impl Coroutine<Yield = ()> {} +} + +fn overlap_move_points() -> impl Coroutine<Yield = ()> { + static || { + let first = Foo([0; FOO_SIZE]); + yield; + let second = first; + yield; + let second = first; + yield; + } +} diff --git a/tests/crashes/123456.rs b/tests/crashes/123456.rs new file mode 100644 index 00000000000..ed7cbada3f8 --- /dev/null +++ b/tests/crashes/123456.rs @@ -0,0 +1,16 @@ +//@ known-bug: #123456 + +trait Project { + const SELF: Self; +} + +fn take1( + _: Project< + SELF = { + j2.join().unwrap(); + }, + >, +) { +} + +pub fn main() {} diff --git a/tests/crashes/123461.rs b/tests/crashes/123461.rs new file mode 100644 index 00000000000..6dbfb5c8092 --- /dev/null +++ b/tests/crashes/123461.rs @@ -0,0 +1,5 @@ +//@ known-bug: #123461 + +fn main() { + let _: [_; unsafe { std::mem::transmute(|o_b: Option<_>| {}) }]; +} diff --git a/tests/crashes/123690.rs b/tests/crashes/123690.rs new file mode 100644 index 00000000000..3af70e20aee --- /dev/null +++ b/tests/crashes/123690.rs @@ -0,0 +1,278 @@ +//@ known-bug: #123690 + +fn more_discriminant_overflow() { + pub enum Infallible {} + + pub enum E1 { + V2 {}, + V3, + V4, + } + + #[repr(u8)] + + pub enum E2<X> { + V1 { f: bool }, + + /*_00*/ _01(X), + _02(X), + _03(X), + _04(X), + _05(X), + _06(X), + _07(X), + _08(X), + _09(X), + _0A(X), + _0B(X), + _0C(X), + _0D(X), + _0E(X), + _0F(X), + _10(X), + _11(X), + _12(X), + _13(X), + _14(X), + _15(X), + _16(X), + _17(X), + _18(X), + _19(X), + _1A(X), + _1B(X), + _1C(X), + _1D(X), + _1E(X), + _1F(X), + _20(X), + _21(X), + _22(X), + _23(X), + _24(X), + _25(X), + _26(X), + _27(X), + _28(X), + _29(X), + _2A(X), + _2B(X), + _2C(X), + _2D(X), + _2E(X), + _2F(X), + _30(X), + _31(X), + _32(X), + _33(X), + _34(X), + _35(X), + _36(X), + _37(X), + _38(X), + _39(X), + _3A(X), + _3B(X), + _3C(X), + _3D(X), + _3E(X), + _3F(X), + _40(X), + _41(X), + _42(X), + _43(X), + _44(X), + _45(X), + _46(X), + _47(X), + _48(X), + _49(X), + _4A(X), + _4B(X), + _4C(X), + _4D(X), + _4E(X), + _4F(X), + _50(X), + _51(X), + _52(X), + _53(X), + _54(X), + _55(X), + _56(X), + _57(X), + _58(X), + _59(X), + _5A(X), + _5B(X), + _5C(X), + _5D(X), + _5E(X), + _5F(X), + _60(X), + _61(X), + _62(X), + _63(X), + _64(X), + _65(X), + _66(X), + _67(X), + _68(X), + _69(X), + _6A(X), + _6B(X), + _6C(X), + _6D(X), + _6E(X), + _6F(X), + _70(X), + _71(X), + _72(X), + _73(X), + _74(E1), + _75(X), + _76(X), + _77(X), + _78(X), + _79(X), + _7A(X), + _7B(X), + _7C(X), + _7D(X), + _7E(X), + _7F(X), + _80(X), + _81(X), + _82(X), + _83(X), + _84(X), + _85(X), + _86(X), + _87(X), + _88(X), + _89(X), + _8A(X), + _8B(X), + _8C(X), + _8D(X), + _8E(X), + _8F(X), + _90(X), + _91(X), + _92(X), + _93(X), + _94(X), + _95(X), + _96(X), + _97(X), + _98(X), + _99(X), + _9A(X), + _9B(X), + _9C(X), + _9D(X), + _9E(X), + _9F(X), + _A0(X), + _A1(X), + _A2(X), + _A3(X), + _A4(X), + _A5(X), + _A6(X), + _A7(X), + _A8(X), + _A9(X), + _AA(X), + _AB(X), + _AC(X), + _AD(X), + _AE(X), + _AF(X), + _B0(X), + _B1(X), + _B2(X), + _B3(X), + _B4(X), + _B5(X), + _B6(X), + _B7(X), + _B8(X), + _B9(X), + _BA(X), + _BB(X), + _BC(X), + _BD(X), + _BE(X), + _BF(X), + _C0(X), + _C1(X), + _C2(X), + _C3(X), + _C4(X), + _C5(X), + _C6(X), + _D8(X), + _C8(X), + _C9(X), + _CA(X), + _CB(X), + _CC(X), + _CD(X), + _CE(X), + _CF(X), + _D0(X), + _D1(X), + _D2(X), + _D3(X), + _D4(X), + _D5(X), + _D6(X), + _D7(X), + _D8(X), + _D9(X), + _DA(X), + _DB(X), + _DC(X), + _DD(X), + _DE(X), + _DF(X), + _E0(X), + _E1(X), + _E2(X), + _E3(X), + _E4(X), + _E5(X), + _E6(X), + _E7(X), + _E8(X), + _E9(X), + _EA(X), + _EB(X), + _EC(X), + _ED(X), + _EE(X), + _EF(i32, i32), + _F0(X), + _F1(X), + _F2(X), + _F3(X), + _F4(X), + _F5(X), + _F6(X), + _F7(X), + _F8(X), + _F9(X), + _FA(X), + _FB(X), + _FC(X), + _FD(X), + _FE(X), + _FF(X), + + V3, + V4, + } + + if let E2::V1 { .. } = E2::V3::<Infallible> {} +} diff --git a/tests/crashes/123693.rs b/tests/crashes/123693.rs new file mode 100644 index 00000000000..c2e192092be --- /dev/null +++ b/tests/crashes/123693.rs @@ -0,0 +1,22 @@ +//@ known-bug: #123693 + +#![feature(transmutability)] + +mod assert { + use std::mem::{Assume, BikeshedIntrinsicFrom}; + + pub fn is_transmutable<Src, Dst>() + where + Dst: BikeshedIntrinsicFrom<Src, { Assume::NOTHING }>, + { + } +} + +enum Lopsided { + Smol(()), + Lorg(bool), +} + +fn should_pad_variants() { + assert::is_transmutable::<Lopsided, ()>(); +} diff --git a/tests/crashes/123710.rs b/tests/crashes/123710.rs new file mode 100644 index 00000000000..f171fa7cebb --- /dev/null +++ b/tests/crashes/123710.rs @@ -0,0 +1,17 @@ +//@ known-bug: #123710 + +#[repr(packed)] +#[repr(u32)] +enum E { + A, + B, + C, +} + +fn main() { + union InvalidTag { + int: u32, + e: E, + } + let _invalid_tag = InvalidTag { int: 4 }; +} diff --git a/tests/crashes/123809.rs b/tests/crashes/123809.rs new file mode 100644 index 00000000000..c7a633aed01 --- /dev/null +++ b/tests/crashes/123809.rs @@ -0,0 +1,4 @@ +//@ known-bug: #123809 +type Positive = std::pat::pattern_type!(std::pat:: is 0..); + +pub fn main() {} diff --git a/tests/crashes/123810.rs b/tests/crashes/123810.rs new file mode 100644 index 00000000000..57de3bc7f34 --- /dev/null +++ b/tests/crashes/123810.rs @@ -0,0 +1,10 @@ +//@ known-bug: #123810 +//@ compile-flags: -Zlint-mir + +fn temp() -> (String, i32) { + (String::from("Hello"), 1) +} + +fn main() { + let f = if true { &temp() } else { &temp() }; +} diff --git a/tests/crashes/123863.rs b/tests/crashes/123863.rs new file mode 100644 index 00000000000..e0f3ac9dcd7 --- /dev/null +++ b/tests/crashes/123863.rs @@ -0,0 +1,6 @@ +//@ known-bug: #123863 +const fn concat_strs<const A: &'static str>() -> &'static str { + struct Inner<const A: &'static str>; + Inner::concat_strs::<"a">::A +} +pub fn main() {} diff --git a/tests/crashes/123893.rs b/tests/crashes/123893.rs new file mode 100644 index 00000000000..137ae783511 --- /dev/null +++ b/tests/crashes/123893.rs @@ -0,0 +1,20 @@ +//@ known-bug: #123893 +//@ compile-flags: -Zpolymorphize=on -Zinline-mir=yes -Zinline-mir-threshold=20 +pub fn main() { + generic_impl::<bool>(); +} + +fn generic_impl<T>() { + trait MagicTrait { + const IS_BIG: bool; + } + impl<T> MagicTrait for T { + const IS_BIG: bool = true; + } + if T::IS_BIG { + big_impl::<i32>(); + } +} + +#[inline(never)] +fn big_impl<T>() {} diff --git a/tests/crashes/123901.rs b/tests/crashes/123901.rs new file mode 100644 index 00000000000..06722f0bf29 --- /dev/null +++ b/tests/crashes/123901.rs @@ -0,0 +1,8 @@ +//@ known-bug: #123901 +//@ edition:2021 + +pub fn test(test: &u64, temp: &u64) { + async |check, a, b| { + temp.abs_diff(12); + }; +} diff --git a/tests/crashes/123911.rs b/tests/crashes/123911.rs new file mode 100644 index 00000000000..1a4d6a79512 --- /dev/null +++ b/tests/crashes/123911.rs @@ -0,0 +1,16 @@ +//@ known-bug: #123911 + +macro_rules! m { + ($attr_path: path) => { + #[$attr_path] + fn f() {} + } +} + +m!(inline<{ + let a = CharCharFloat { a: 1 }; + let b = rustrt::rust_dbg_abi_4(a); + println!("a: {}", b.a); +}>); + +fn main() {} diff --git a/tests/crashes/123912.rs b/tests/crashes/123912.rs new file mode 100644 index 00000000000..35216caabcd --- /dev/null +++ b/tests/crashes/123912.rs @@ -0,0 +1,15 @@ +//@ known-bug: #123912 + +macro_rules! m { + ($attr_path: path) => { + #[$attr_path] + fn f() {} + } +} + +m!(inline<{ + let a = CharCharFloat { a: 1 }; + println!("a: {}", a); +}>); + +fn main() {} diff --git a/tests/crashes/123917.rs b/tests/crashes/123917.rs new file mode 100644 index 00000000000..66e75460662 --- /dev/null +++ b/tests/crashes/123917.rs @@ -0,0 +1,41 @@ +//@ known-bug: #123917 +//@ compile-flags: -Zmir-opt-level=5 -Zpolymorphize=on + +use std::marker::PhantomData; + +pub struct Id<'id>(); + +pub struct Item<'life, T> { + data: T, +} + +pub struct Token<'life, 'borrow, 'compact, 'reborrow, T> +where + 'life: 'reborrow, + T: Tokenize, +{ + ptr: *mut <T as Tokenize>::Tokenized, + ptr: core::ptr::NonNull<T::Tokenized>, + _phantom: PhantomData<Id<'life>>, +} + +impl<'life> Arena<'life> { + pub fn tokenize<'before, 'compact, 'borrow, 'reborrow, T, U>( + item: Item<'life, &'before mut T>, + ) -> Token<'life, 'borrow, 'compact, 'reborrow, U> + where + T: Tokenize<'life, 'borrow, 'compact, 'reborrow, Untokenized = U>, + T::Untokenized: Tokenize<'life, 'borrow, 'compact, 'reborrow>, + { + let dst = item.data as *mut T as *mut T::Tokenized; + Token { + ptr: core::ptr::NonNull::new(dst as *mut _).unwrap(), + _phantom: PhantomData, + } + } +} + +pub trait Tokenize { + type Tokenized; + type Untokenized; +} diff --git a/tests/crashes/123959.rs b/tests/crashes/123959.rs new file mode 100644 index 00000000000..fe22c0225ed --- /dev/null +++ b/tests/crashes/123959.rs @@ -0,0 +1,5 @@ +//@ known-bug: #123959 +#![feature(generic_const_exprs)] +fn foo<T>(_: [(); std::mem::offset_of!((T,), 0)]) {} + +pub fn main() {} diff --git a/tests/crashes/124004.rs b/tests/crashes/124004.rs new file mode 100644 index 00000000000..1fcf0785945 --- /dev/null +++ b/tests/crashes/124004.rs @@ -0,0 +1,18 @@ +//@ known-bug: #124004 + +#![feature(box_patterns)] + +use std::ops::{ Deref }; + +struct X(dyn Iterator<Item = &'a ()>); + +impl Deref for X { + type Target = isize; + + fn deref(&self) -> &isize { + let &X(box ref x) = self; + x + } +} + +fn main() {} diff --git a/tests/crashes/124020.rs b/tests/crashes/124020.rs new file mode 100644 index 00000000000..f461f32f59d --- /dev/null +++ b/tests/crashes/124020.rs @@ -0,0 +1,33 @@ +//@ known-bug: #124020 +//@ compile-flags: -Zpolymorphize=on --edition=2018 --crate-type=lib + +#![feature(async_closure, noop_waker, async_fn_traits)] + +use std::future::Future; +use std::pin::pin; +use std::task::*; + +pub fn block_on<T>(fut: impl Future<Output = T>) -> T { + let mut fut = pin!(fut); + let ctx = &mut Context::from_waker(Waker::noop()); + + loop { + match fut.as_mut().poll(ctx) { + Poll::Pending => {} + Poll::Ready(t) => break t, + } + } +} + +async fn call_once(f: impl async FnOnce(DropMe)) { + f(DropMe("world")).await; +} + +struct DropMe(&'static str); + +pub fn future() { + block_on(async { + let async_closure = async move |a: DropMe| {}; + call_once(async_closure).await; + }); +} diff --git a/tests/crashes/124021.rs b/tests/crashes/124021.rs new file mode 100644 index 00000000000..a2b6b7f9a66 --- /dev/null +++ b/tests/crashes/124021.rs @@ -0,0 +1,6 @@ +//@ known-bug: #124021 +type Opaque2<'a> = impl Sized + 'a; + +fn test2() -> impl for<'a, 'b> Fn((&'a str, &'b str)) -> (Opaque2<'a>, Opaque2<'a>) { + |x| x +} diff --git a/tests/crashes/124031.rs b/tests/crashes/124031.rs new file mode 100644 index 00000000000..bdc66fbafe4 --- /dev/null +++ b/tests/crashes/124031.rs @@ -0,0 +1,17 @@ +//@ known-bug: #124031 + +trait Trait { + type RefTarget; +} + +impl Trait for () {} + +struct Other { + data: <() as Trait>::RefTarget, +} + +fn main() { + unsafe { + std::mem::transmute::<Option<()>, Option<&Other>>(None); + } +} diff --git a/tests/crashes/97006.rs b/tests/crashes/97006.rs new file mode 100644 index 00000000000..c8dfa52ebee --- /dev/null +++ b/tests/crashes/97006.rs @@ -0,0 +1,15 @@ +//@ known-bug: #97006 +//@ compile-flags: -Zunpretty=hir + +#![allow(unused)] + +macro_rules! m { + ($attr_path: path) => { + #[$attr_path] + fn f() {} + } +} + +m!(inline<u8>); //~ ERROR: unexpected generic arguments in path + +fn main() {} diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-abort.diff index 4c2df228eb8..8c5a0df94f4 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-abort.diff @@ -9,8 +9,6 @@ scope 1 { } scope 2 (inlined #[track_caller] <u8 as Add>::add) { - debug self => _2; - debug other => _3; let mut _4: (u8, bool); } diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-unwind.diff index c4e666b489e..7887a8a9072 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-unwind.diff @@ -9,8 +9,6 @@ scope 1 { } scope 2 (inlined #[track_caller] <u8 as Add>::add) { - debug self => _2; - debug other => _3; let mut _4: (u8, bool); } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff index 44e73b56098..8005bc23cf6 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff @@ -12,16 +12,13 @@ let _3: std::ptr::Unique<[bool]>; let mut _4: std::ptr::Unique<[bool; 0]>; scope 3 { - debug ptr => _3; } scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { let _6: *mut [bool; 0]; scope 6 { - debug ptr => _6; scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { - debug ptr => _6; let mut _8: bool; let _9: (); let mut _10: *mut (); @@ -37,7 +34,6 @@ scope 8 (inlined align_of::<[bool; 0]>) { } scope 9 (inlined without_provenance_mut::<[bool; 0]>) { - debug addr => _7; } } } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff index 6cef8b692ba..42b1be32387 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff @@ -12,16 +12,13 @@ let _3: std::ptr::Unique<[bool]>; let mut _4: std::ptr::Unique<[bool; 0]>; scope 3 { - debug ptr => _3; } scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { let _6: *mut [bool; 0]; scope 6 { - debug ptr => _6; scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { - debug ptr => _6; let mut _8: bool; let _9: (); let mut _10: *mut (); @@ -37,7 +34,6 @@ scope 8 (inlined align_of::<[bool; 0]>) { } scope 9 (inlined without_provenance_mut::<[bool; 0]>) { - debug addr => _7; } } } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff index 6efccded993..7b57b0db50c 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff @@ -12,16 +12,13 @@ let _3: std::ptr::Unique<[bool]>; let mut _4: std::ptr::Unique<[bool; 0]>; scope 3 { - debug ptr => _3; } scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { let _6: *mut [bool; 0]; scope 6 { - debug ptr => _6; scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { - debug ptr => _6; let mut _8: bool; let _9: (); let mut _10: *mut (); @@ -37,7 +34,6 @@ scope 8 (inlined align_of::<[bool; 0]>) { } scope 9 (inlined without_provenance_mut::<[bool; 0]>) { - debug addr => _7; } } } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff index a705d0064cb..2e75a63e290 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff @@ -12,16 +12,13 @@ let _3: std::ptr::Unique<[bool]>; let mut _4: std::ptr::Unique<[bool; 0]>; scope 3 { - debug ptr => _3; } scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { let _6: *mut [bool; 0]; scope 6 { - debug ptr => _6; scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { - debug ptr => _6; let mut _8: bool; let _9: (); let mut _10: *mut (); @@ -37,7 +34,6 @@ scope 8 (inlined align_of::<[bool; 0]>) { } scope 9 (inlined without_provenance_mut::<[bool; 0]>) { - debug addr => _7; } } } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff index f9c854ca3f4..ca445046279 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff @@ -12,16 +12,13 @@ let _3: std::ptr::Unique<[bool]>; let mut _4: std::ptr::Unique<[bool; 0]>; scope 3 { - debug ptr => _3; } scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { let _6: *mut [bool; 0]; scope 6 { - debug ptr => _6; scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { - debug ptr => _6; let mut _8: bool; let _9: (); let mut _10: *mut (); @@ -37,7 +34,6 @@ scope 8 (inlined align_of::<[bool; 0]>) { } scope 9 (inlined without_provenance_mut::<[bool; 0]>) { - debug addr => _7; } } } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff index 333726689d7..1f498c65fa7 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff @@ -12,16 +12,13 @@ let _3: std::ptr::Unique<[bool]>; let mut _4: std::ptr::Unique<[bool; 0]>; scope 3 { - debug ptr => _3; } scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { let _6: *mut [bool; 0]; scope 6 { - debug ptr => _6; scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { - debug ptr => _6; let mut _8: bool; let _9: (); let mut _10: *mut (); @@ -37,7 +34,6 @@ scope 8 (inlined align_of::<[bool; 0]>) { } scope 9 (inlined without_provenance_mut::<[bool; 0]>) { - debug addr => _7; } } } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff index e1841760077..da72e581496 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff @@ -12,16 +12,13 @@ let _3: std::ptr::Unique<[bool]>; let mut _4: std::ptr::Unique<[bool; 0]>; scope 3 { - debug ptr => _3; } scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { let _6: *mut [bool; 0]; scope 6 { - debug ptr => _6; scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { - debug ptr => _6; let mut _8: bool; let _9: (); let mut _10: *mut (); @@ -37,7 +34,6 @@ scope 8 (inlined align_of::<[bool; 0]>) { } scope 9 (inlined without_provenance_mut::<[bool; 0]>) { - debug addr => _7; } } } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff index 7aa02556ec5..920e66452e3 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff @@ -12,16 +12,13 @@ let _3: std::ptr::Unique<[bool]>; let mut _4: std::ptr::Unique<[bool; 0]>; scope 3 { - debug ptr => _3; } scope 4 (inlined Unique::<[bool; 0]>::dangling) { let mut _5: std::ptr::NonNull<[bool; 0]>; scope 5 (inlined NonNull::<[bool; 0]>::dangling) { let _6: *mut [bool; 0]; scope 6 { - debug ptr => _6; scope 10 (inlined NonNull::<[bool; 0]>::new_unchecked) { - debug ptr => _6; let mut _8: bool; let _9: (); let mut _10: *mut (); @@ -37,7 +34,6 @@ scope 8 (inlined align_of::<[bool; 0]>) { } scope 9 (inlined without_provenance_mut::<[bool; 0]>) { - debug addr => _7; } } } diff --git a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff index 09fc48043b9..ca1bd737caf 100644 --- a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-abort.diff @@ -9,8 +9,6 @@ scope 1 { } scope 2 (inlined #[track_caller] <u8 as Add>::add) { - debug self => _2; - debug other => _3; let mut _4: (u8, bool); } diff --git a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff index c0b26080f56..0d7fe9360c1 100644 --- a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff @@ -9,8 +9,6 @@ scope 1 { } scope 2 (inlined #[track_caller] <u8 as Add>::add) { - debug self => _2; - debug other => _3; let mut _4: (u8, bool); } diff --git a/tests/mir-opt/dest-prop/union.rs b/tests/mir-opt/dest-prop/union.rs index abd1f1b2c93..66fadd84712 100644 --- a/tests/mir-opt/dest-prop/union.rs +++ b/tests/mir-opt/dest-prop/union.rs @@ -1,7 +1,7 @@ // skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY //! Tests that we can propagate into places that are projections into unions -//@ compile-flags: -Zunsound-mir-opts +//@ compile-flags: -Zunsound-mir-opts -C debuginfo=full fn val() -> u32 { 1 } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff index bd346af6d16..8a701641ff9 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff @@ -29,13 +29,11 @@ debug precision => _8; let _8: usize; scope 5 (inlined Formatter::<'_>::precision) { - debug self => _1; } } } } scope 4 (inlined Formatter::<'_>::sign_plus) { - debug self => _1; let mut _20: u32; let mut _21: u32; } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff index 422cbeaa224..5e65700ee4a 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff @@ -29,13 +29,11 @@ debug precision => _8; let _8: usize; scope 5 (inlined Formatter::<'_>::precision) { - debug self => _1; } } } } scope 4 (inlined Formatter::<'_>::sign_plus) { - debug self => _1; let mut _20: u32; let mut _21: u32; } diff --git a/tests/mir-opt/inline/asm_unwind.rs b/tests/mir-opt/inline/asm_unwind.rs index 7708f567c71..8a102b2f561 100644 --- a/tests/mir-opt/inline/asm_unwind.rs +++ b/tests/mir-opt/inline/asm_unwind.rs @@ -3,7 +3,7 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY //@ needs-asm-support //@ needs-unwind -//@ compile-flags: -Zinline-mir-hint-threshold=1000 +//@ compile-flags: -Zinline-mir-hint-threshold=1000 -C debuginfo=full #![feature(asm_unwind)] struct D; diff --git a/tests/mir-opt/inline/cycle.rs b/tests/mir-opt/inline/cycle.rs index b2eacfe33b1..cb50638473f 100644 --- a/tests/mir-opt/inline/cycle.rs +++ b/tests/mir-opt/inline/cycle.rs @@ -1,5 +1,5 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -//@ compile-flags: -Zinline-mir-hint-threshold=1000 +//@ compile-flags: -Zinline-mir-hint-threshold=1000 -C debuginfo=full // EMIT_MIR cycle.f.Inline.diff #[inline(always)] diff --git a/tests/mir-opt/inline/dyn_trait.rs b/tests/mir-opt/inline/dyn_trait.rs index ecf220a85e6..d991403a5ac 100644 --- a/tests/mir-opt/inline/dyn_trait.rs +++ b/tests/mir-opt/inline/dyn_trait.rs @@ -1,4 +1,5 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY +//@ compile-flags: -C debuginfo=full #![crate_type = "lib"] use std::fmt::Debug; diff --git a/tests/mir-opt/inline/inline_any_operand.rs b/tests/mir-opt/inline/inline_any_operand.rs index 8151949214b..b34f71a6979 100644 --- a/tests/mir-opt/inline/inline_any_operand.rs +++ b/tests/mir-opt/inline/inline_any_operand.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Z span_free_formats +//@ compile-flags: -Z span_free_formats -C debuginfo=full // Tests that MIR inliner works for any operand diff --git a/tests/mir-opt/inline/inline_closure.rs b/tests/mir-opt/inline/inline_closure.rs index 9a3cf54ef07..a5954955c0f 100644 --- a/tests/mir-opt/inline/inline_closure.rs +++ b/tests/mir-opt/inline/inline_closure.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Z span_free_formats +//@ compile-flags: -Z span_free_formats -C debuginfo=full // Tests that MIR inliner can handle closure arguments. (#45894) diff --git a/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir b/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir index 6e77a9bc575..a6198ca053b 100644 --- a/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir +++ b/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir @@ -14,10 +14,7 @@ fn foo(_1: T, _2: &i32) -> i32 { scope 1 { debug x => _3; scope 2 (inlined foo::<T>::{closure#0}) { - debug r => _8; - debug _s => _9; scope 3 { - debug variable => _8; } } } diff --git a/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir b/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir index 10b81e59b5f..2f9d28ea093 100644 --- a/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir +++ b/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir @@ -14,9 +14,6 @@ fn foo(_1: T, _2: i32) -> (i32, T) { scope 1 { debug x => _3; scope 2 (inlined foo::<T>::{closure#0}) { - debug _q => _9; - debug q => (*((*_6).0: &i32)); - debug t => (*((*_6).1: &T)); let mut _10: &i32; let mut _11: i32; let mut _12: &T; diff --git a/tests/mir-opt/inline/inline_coroutine.rs b/tests/mir-opt/inline/inline_coroutine.rs index 9500c2261cc..180f9d4a6fd 100644 --- a/tests/mir-opt/inline/inline_coroutine.rs +++ b/tests/mir-opt/inline/inline_coroutine.rs @@ -1,5 +1,5 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -//@ compile-flags: -Zinline-mir-hint-threshold=1000 +//@ compile-flags: -Zinline-mir-hint-threshold=1000 -C debuginfo=full #![feature(coroutines, coroutine_trait)] use std::ops::Coroutine; diff --git a/tests/mir-opt/inline/inline_cycle.rs b/tests/mir-opt/inline/inline_cycle.rs index e3dd082556b..1826e38f894 100644 --- a/tests/mir-opt/inline/inline_cycle.rs +++ b/tests/mir-opt/inline/inline_cycle.rs @@ -1,4 +1,5 @@ // skip-filecheck +//@ compile-flags: -C debuginfo=full // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Check that inliner handles various forms of recursion and doesn't fall into // an infinite inlining cycle. The particular outcome of inlining is not diff --git a/tests/mir-opt/inline/inline_diverging.rs b/tests/mir-opt/inline/inline_diverging.rs index 89ef0fc4a61..e1cea3618f1 100644 --- a/tests/mir-opt/inline/inline_diverging.rs +++ b/tests/mir-opt/inline/inline_diverging.rs @@ -1,7 +1,7 @@ // Tests inlining of diverging calls. // // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -//@ compile-flags: -Zinline-mir-hint-threshold=1000 +//@ compile-flags: -Zinline-mir-hint-threshold=1000 -C debuginfo=full #![crate_type = "lib"] // EMIT_MIR inline_diverging.f.Inline.diff diff --git a/tests/mir-opt/inline/inline_retag.rs b/tests/mir-opt/inline/inline_retag.rs index 5cf7f768f91..81e63637887 100644 --- a/tests/mir-opt/inline/inline_retag.rs +++ b/tests/mir-opt/inline/inline_retag.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Z span_free_formats -Z mir-emit-retag +//@ compile-flags: -Z span_free_formats -Z mir-emit-retag -C debuginfo=full // Tests that MIR inliner fixes up `Retag`'s `fn_entry` flag diff --git a/tests/mir-opt/inline/inline_trait_method_2.rs b/tests/mir-opt/inline/inline_trait_method_2.rs index c3a71e63783..2ca71afad4c 100644 --- a/tests/mir-opt/inline/inline_trait_method_2.rs +++ b/tests/mir-opt/inline/inline_trait_method_2.rs @@ -1,5 +1,5 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -//@ compile-flags: -Z span_free_formats -Z mir-opt-level=4 +//@ compile-flags: -Z span_free_formats -Z mir-opt-level=4 -C debuginfo=full // EMIT_MIR inline_trait_method_2.test2.Inline.after.mir fn test2(x: &dyn X) -> bool { diff --git a/tests/mir-opt/inline/issue_106141.rs b/tests/mir-opt/inline/issue_106141.rs index 592b4d9b723..1cca7d76b25 100644 --- a/tests/mir-opt/inline/issue_106141.rs +++ b/tests/mir-opt/inline/issue_106141.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -C debuginfo=full // Verify that we do not ICE inlining a function which uses _0 as an index. // EMIT_MIR_FOR_EACH_PANIC_STRATEGY diff --git a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs index 4517c88d713..d8a5c47850d 100644 --- a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs +++ b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs @@ -1,3 +1,5 @@ +//@ compile-flags: -C debuginfo=full + // EMIT_MIR issue_58867_inline_as_ref_as_mut.a.Inline.after.mir pub fn a<T>(x: &mut [T]) -> &mut [T] { // CHECK-LABEL: fn a( diff --git a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir index ba4f91b28d5..63d3ae2a869 100644 --- a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir +++ b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir @@ -2,8 +2,8 @@ fn main() -> () { let mut _0: (); - let _1: {closure@$DIR/issue_76997_inline_scopes_parenting.rs:15:13: 15:16}; - let mut _2: &{closure@$DIR/issue_76997_inline_scopes_parenting.rs:15:13: 15:16}; + let _1: {closure@$DIR/issue_76997_inline_scopes_parenting.rs:16:13: 16:16}; + let mut _2: &{closure@$DIR/issue_76997_inline_scopes_parenting.rs:16:13: 16:16}; let mut _3: ((),); let mut _4: (); let mut _5: (); @@ -19,7 +19,7 @@ fn main() -> () { bb0: { StorageLive(_1); - _1 = {closure@$DIR/issue_76997_inline_scopes_parenting.rs:15:13: 15:16}; + _1 = {closure@$DIR/issue_76997_inline_scopes_parenting.rs:16:13: 16:16}; StorageLive(_2); _2 = &_1; StorageLive(_3); diff --git a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs index 2fb363c1904..75772c16127 100644 --- a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs +++ b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -C debuginfo=full // Tests that MIR inliner can handle `SourceScopeData` parenting correctly. (#76997) // EMIT_MIR issue_76997_inline_scopes_parenting.main.Inline.after.mir diff --git a/tests/mir-opt/inline/issue_78442.rs b/tests/mir-opt/inline/issue_78442.rs index 2fbe0c6c64c..6dc875f9a40 100644 --- a/tests/mir-opt/inline/issue_78442.rs +++ b/tests/mir-opt/inline/issue_78442.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Z mir-opt-level=3 -Z inline-mir +//@ compile-flags: -Z mir-opt-level=3 -Z inline-mir -C debuginfo=full // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![crate_type = "lib"] diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff index cc1b8b9b70f..a624ab78dad 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff @@ -8,8 +8,6 @@ let mut _3: u16; let mut _4: u32; + scope 1 (inlined core::num::<impl u16>::unchecked_shl) { -+ debug self => _3; -+ debug rhs => _4; + } bb0: { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff index f244f378bce..81a0a5b39f7 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff @@ -8,8 +8,6 @@ let mut _3: u16; let mut _4: u32; + scope 1 (inlined core::num::<impl u16>::unchecked_shl) { -+ debug self => _3; -+ debug rhs => _4; + } bb0: { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir index c96983c18cb..9e3802b7501 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir @@ -5,8 +5,6 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { debug b => _2; let mut _0: u16; scope 1 (inlined core::num::<impl u16>::unchecked_shl) { - debug self => _1; - debug rhs => _2; } bb0: { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir index c96983c18cb..9e3802b7501 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir @@ -5,8 +5,6 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { debug b => _2; let mut _0: u16; scope 1 (inlined core::num::<impl u16>::unchecked_shl) { - debug self => _1; - debug rhs => _2; } bb0: { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff index 74518db370f..a2b3ad4b3ba 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff @@ -8,8 +8,6 @@ let mut _3: i64; let mut _4: u32; + scope 1 (inlined core::num::<impl i64>::unchecked_shr) { -+ debug self => _3; -+ debug rhs => _4; + } bb0: { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff index aab04624f6c..2ff6b532d61 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff @@ -8,8 +8,6 @@ let mut _3: i64; let mut _4: u32; + scope 1 (inlined core::num::<impl i64>::unchecked_shr) { -+ debug self => _3; -+ debug rhs => _4; + } bb0: { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-abort.mir index 1dd8cb27314..f3961982648 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-abort.mir @@ -5,8 +5,6 @@ fn unchecked_shr_signed_bigger(_1: i64, _2: u32) -> i64 { debug b => _2; let mut _0: i64; scope 1 (inlined core::num::<impl i64>::unchecked_shr) { - debug self => _1; - debug rhs => _2; } bb0: { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-unwind.mir index 1dd8cb27314..f3961982648 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-unwind.mir @@ -5,8 +5,6 @@ fn unchecked_shr_signed_bigger(_1: i64, _2: u32) -> i64 { debug b => _2; let mut _0: i64; scope 1 (inlined core::num::<impl i64>::unchecked_shr) { - debug self => _1; - debug rhs => _2; } bb0: { diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff index 814eda10459..c1f7879cf0e 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff @@ -6,10 +6,8 @@ let mut _0: T; let mut _2: std::option::Option<T>; + scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) { -+ debug self => _2; + let mut _3: isize; + scope 2 { -+ debug val => _0; + } + scope 3 (inlined unreachable_unchecked) { + let mut _4: bool; diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff index d5d69074382..5271e538daf 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff @@ -6,10 +6,8 @@ let mut _0: T; let mut _2: std::option::Option<T>; + scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) { -+ debug self => _2; + let mut _3: isize; + scope 2 { -+ debug val => _0; + } + scope 3 (inlined unreachable_unchecked) { + let mut _4: bool; diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir index 7c24a97166c..dcab8a679a8 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir @@ -4,10 +4,8 @@ fn unwrap_unchecked(_1: Option<T>) -> T { debug slf => _1; let mut _0: T; scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) { - debug self => _1; let mut _2: isize; scope 2 { - debug val => _0; } scope 3 (inlined unreachable_unchecked) { scope 4 (inlined core::ub_checks::check_language_ub) { diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir index 7c24a97166c..dcab8a679a8 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir @@ -4,10 +4,8 @@ fn unwrap_unchecked(_1: Option<T>) -> T { debug slf => _1; let mut _0: T; scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) { - debug self => _1; let mut _2: isize; scope 2 { - debug val => _0; } scope 3 (inlined unreachable_unchecked) { scope 4 (inlined core::ub_checks::check_language_ub) { diff --git a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff index f8cceacd7e6..f8715789cec 100644 --- a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff +++ b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff @@ -21,8 +21,6 @@ scope 3 { } + scope 6 (inlined ActionPermit::<'_, T>::perform::{closure#0}) { -+ debug _task_context => _31; -+ debug self => ((*(_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()})).0: ActionPermit<'_, T>); + let _11: ActionPermit<'_, T>; + let mut _12: std::future::Ready<()>; + let mut _13: std::future::Ready<()>; @@ -52,28 +50,22 @@ + let mut _39: &mut {async fn body of ActionPermit<'_, T>::perform()}; + let mut _40: &mut {async fn body of ActionPermit<'_, T>::perform()}; + scope 7 { -+ debug self => (((*(_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()})) as variant#3).0: ActionPermit<'_, T>); + let mut _15: std::future::Ready<()>; + scope 8 { -+ debug __awaitee => (((*(_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()})) as variant#3).1: std::future::Ready<()>); + let _26: (); + scope 9 { -+ debug result => _26; + } + } + scope 10 (inlined ready::<()>) { -+ debug t => _14; + let mut _41: std::option::Option<()>; + } + } + } } + scope 5 (inlined Pin::<&mut {async fn body of ActionPermit<'_, T>::perform()}>::new_unchecked) { -+ debug pointer => _5; + } } + scope 4 (inlined ActionPermit::<'_, T>::perform) { -+ debug self => _3; + } bb0: { diff --git a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff index fd080d22d3a..494f5591e32 100644 --- a/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff @@ -21,8 +21,6 @@ scope 3 { } + scope 6 (inlined ActionPermit::<'_, T>::perform::{closure#0}) { -+ debug _task_context => _31; -+ debug self => ((*(_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()})).0: ActionPermit<'_, T>); + let _11: ActionPermit<'_, T>; + let mut _12: std::future::Ready<()>; + let mut _13: std::future::Ready<()>; @@ -54,28 +52,22 @@ + let mut _41: &mut {async fn body of ActionPermit<'_, T>::perform()}; + let mut _42: &mut {async fn body of ActionPermit<'_, T>::perform()}; + scope 7 { -+ debug self => (((*(_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()})) as variant#3).0: ActionPermit<'_, T>); + let mut _15: std::future::Ready<()>; + scope 8 { -+ debug __awaitee => (((*(_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()})) as variant#3).1: std::future::Ready<()>); + let _26: (); + scope 9 { -+ debug result => _26; + } + } + scope 10 (inlined ready::<()>) { -+ debug t => _14; + let mut _43: std::option::Option<()>; + } + } + } } + scope 5 (inlined Pin::<&mut {async fn body of ActionPermit<'_, T>::perform()}>::new_unchecked) { -+ debug pointer => _5; + } } + scope 4 (inlined ActionPermit::<'_, T>::perform) { -+ debug self => _3; + } bb0: { diff --git a/tests/mir-opt/inline_generically_if_sized.call.Inline.diff b/tests/mir-opt/inline_generically_if_sized.call.Inline.diff index 0cf4565dc99..fc5833f54ec 100644 --- a/tests/mir-opt/inline_generically_if_sized.call.Inline.diff +++ b/tests/mir-opt/inline_generically_if_sized.call.Inline.diff @@ -6,7 +6,6 @@ let mut _0: i32; let mut _2: &T; + scope 1 (inlined <T as Foo>::bar) { -+ debug self => _2; + } bb0: { diff --git a/tests/mir-opt/instsimplify/casts.redundant.InstSimplify.diff b/tests/mir-opt/instsimplify/casts.redundant.InstSimplify.diff index 9e1bce1ee20..e7451d55777 100644 --- a/tests/mir-opt/instsimplify/casts.redundant.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/casts.redundant.InstSimplify.diff @@ -8,7 +8,6 @@ let mut _3: *const &u8; let mut _4: *const &u8; scope 1 (inlined generic_cast::<&u8, &u8>) { - debug x => _4; let mut _5: *const &u8; } diff --git a/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify.diff b/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify.diff index 6d6c9c9a7a1..4d8d6589842 100644 --- a/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/ub_check.unwrap_unchecked.InstSimplify.diff @@ -6,10 +6,8 @@ let mut _0: i32; let mut _2: std::option::Option<i32>; scope 1 (inlined #[track_caller] Option::<i32>::unwrap_unchecked) { - debug self => _2; let mut _3: isize; scope 2 { - debug val => _0; } scope 3 (inlined unreachable_unchecked) { let mut _4: bool; diff --git a/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff b/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff index 187290785c0..311de9e1c93 100644 --- a/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff +++ b/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff @@ -17,15 +17,11 @@ let mut _12: u32; let mut _13: bool; scope 1 (inlined imm8) { - debug x => _5; let mut _14: u32; scope 2 { - debug out => _4; } } scope 3 (inlined core::num::<impl u32>::rotate_right) { - debug self => _4; - debug n => _6; } bb0: { @@ -34,7 +30,7 @@ StorageLive(_4); StorageLive(_5); _5 = _1; - _4 = const 0_u32; + nop; - StorageLive(_14); - _14 = BitAnd(_5, const 255_u32); - _4 = BitOr(const 0_u32, move _14); @@ -74,7 +70,8 @@ bb2: { _6 = Shl(move _7, const 1_i32); StorageDead(_7); - _3 = rotate_right::<u32>(move _4, move _6) -> [return: bb3, unwind unreachable]; +- _3 = rotate_right::<u32>(move _4, move _6) -> [return: bb3, unwind unreachable]; ++ _3 = rotate_right::<u32>(_14, move _6) -> [return: bb3, unwind unreachable]; } bb3: { diff --git a/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff b/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff index 99350bac478..c5fd042161d 100644 --- a/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff +++ b/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff @@ -17,15 +17,11 @@ let mut _12: u32; let mut _13: bool; scope 1 (inlined imm8) { - debug x => _5; let mut _14: u32; scope 2 { - debug out => _4; } } scope 3 (inlined core::num::<impl u32>::rotate_right) { - debug self => _4; - debug n => _6; } bb0: { @@ -34,7 +30,7 @@ StorageLive(_4); StorageLive(_5); _5 = _1; - _4 = const 0_u32; + nop; - StorageLive(_14); - _14 = BitAnd(_5, const 255_u32); - _4 = BitOr(const 0_u32, move _14); @@ -74,7 +70,8 @@ bb2: { _6 = Shl(move _7, const 1_i32); StorageDead(_7); - _3 = rotate_right::<u32>(move _4, move _6) -> [return: bb3, unwind unreachable]; +- _3 = rotate_right::<u32>(move _4, move _6) -> [return: bb3, unwind unreachable]; ++ _3 = rotate_right::<u32>(_14, move _6) -> [return: bb3, unwind unreachable]; } bb3: { diff --git a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-abort.mir b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-abort.mir index bc12002490a..8da56d59aaa 100644 --- a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-abort.mir @@ -3,66 +3,56 @@ fn num_to_digit(_1: char) -> u32 { debug num => _1; let mut _0: u32; - let mut _5: std::option::Option<u32>; + let mut _4: std::option::Option<u32>; scope 1 (inlined char::methods::<impl char>::is_digit) { - debug self => _1; - debug radix => const 8_u32; let _2: std::option::Option<u32>; - let mut _3: &std::option::Option<u32>; scope 2 (inlined Option::<u32>::is_some) { - debug self => _3; - let mut _4: isize; + let mut _3: isize; } } scope 3 (inlined #[track_caller] Option::<u32>::unwrap) { - debug self => _5; - let mut _6: isize; - let mut _7: !; + let mut _5: isize; + let mut _6: !; scope 4 { - debug val => _0; } } bb0: { - StorageLive(_3); StorageLive(_2); _2 = char::methods::<impl char>::to_digit(_1, const 8_u32) -> [return: bb1, unwind unreachable]; } bb1: { - _3 = &_2; - StorageLive(_4); - _4 = discriminant(_2); - switchInt(move _4) -> [1: bb2, 0: bb6, otherwise: bb8]; + StorageLive(_3); + _3 = discriminant(_2); + switchInt(move _3) -> [1: bb2, 0: bb6, otherwise: bb8]; } bb2: { - StorageDead(_4); StorageDead(_3); StorageDead(_2); - StorageLive(_5); - _5 = char::methods::<impl char>::to_digit(move _1, const 8_u32) -> [return: bb3, unwind unreachable]; + StorageLive(_4); + _4 = char::methods::<impl char>::to_digit(move _1, const 8_u32) -> [return: bb3, unwind unreachable]; } bb3: { - StorageLive(_6); - _6 = discriminant(_5); - switchInt(move _6) -> [0: bb4, 1: bb5, otherwise: bb8]; + StorageLive(_5); + _5 = discriminant(_4); + switchInt(move _5) -> [0: bb4, 1: bb5, otherwise: bb8]; } bb4: { - _7 = option::unwrap_failed() -> unwind unreachable; + _6 = option::unwrap_failed() -> unwind unreachable; } bb5: { - _0 = move ((_5 as Some).0: u32); - StorageDead(_6); + _0 = move ((_4 as Some).0: u32); StorageDead(_5); + StorageDead(_4); goto -> bb7; } bb6: { - StorageDead(_4); StorageDead(_3); StorageDead(_2); _0 = const 0_u32; diff --git a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir index 6c7e10a4525..61bc09d901c 100644 --- a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir @@ -3,66 +3,56 @@ fn num_to_digit(_1: char) -> u32 { debug num => _1; let mut _0: u32; - let mut _5: std::option::Option<u32>; + let mut _4: std::option::Option<u32>; scope 1 (inlined char::methods::<impl char>::is_digit) { - debug self => _1; - debug radix => const 8_u32; let _2: std::option::Option<u32>; - let mut _3: &std::option::Option<u32>; scope 2 (inlined Option::<u32>::is_some) { - debug self => _3; - let mut _4: isize; + let mut _3: isize; } } scope 3 (inlined #[track_caller] Option::<u32>::unwrap) { - debug self => _5; - let mut _6: isize; - let mut _7: !; + let mut _5: isize; + let mut _6: !; scope 4 { - debug val => _0; } } bb0: { - StorageLive(_3); StorageLive(_2); _2 = char::methods::<impl char>::to_digit(_1, const 8_u32) -> [return: bb1, unwind continue]; } bb1: { - _3 = &_2; - StorageLive(_4); - _4 = discriminant(_2); - switchInt(move _4) -> [1: bb2, 0: bb6, otherwise: bb8]; + StorageLive(_3); + _3 = discriminant(_2); + switchInt(move _3) -> [1: bb2, 0: bb6, otherwise: bb8]; } bb2: { - StorageDead(_4); StorageDead(_3); StorageDead(_2); - StorageLive(_5); - _5 = char::methods::<impl char>::to_digit(move _1, const 8_u32) -> [return: bb3, unwind continue]; + StorageLive(_4); + _4 = char::methods::<impl char>::to_digit(move _1, const 8_u32) -> [return: bb3, unwind continue]; } bb3: { - StorageLive(_6); - _6 = discriminant(_5); - switchInt(move _6) -> [0: bb4, 1: bb5, otherwise: bb8]; + StorageLive(_5); + _5 = discriminant(_4); + switchInt(move _5) -> [0: bb4, 1: bb5, otherwise: bb8]; } bb4: { - _7 = option::unwrap_failed() -> unwind continue; + _6 = option::unwrap_failed() -> unwind continue; } bb5: { - _0 = move ((_5 as Some).0: u32); - StorageDead(_6); + _0 = move ((_4 as Some).0: u32); StorageDead(_5); + StorageDead(_4); goto -> bb7; } bb6: { - StorageDead(_4); StorageDead(_3); StorageDead(_2); _0 = const 0_u32; diff --git a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff index d67477ab1b9..65379ae8b89 100644 --- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff +++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff @@ -16,13 +16,10 @@ debug residual => _6; scope 2 { scope 8 (inlined #[track_caller] <Result<i32, i32> as FromResidual<Result<Infallible, i32>>>::from_residual) { - debug residual => _8; let _14: i32; let mut _15: i32; scope 9 { - debug e => _14; scope 10 (inlined <i32 as From<i32>>::from) { - debug t => _14; } } } @@ -34,16 +31,13 @@ } } scope 5 (inlined <Result<i32, i32> as Try>::branch) { - debug self => _4; let mut _10: isize; let _11: i32; let _12: i32; let mut _13: std::result::Result<std::convert::Infallible, i32>; scope 6 { - debug v => _11; } scope 7 { - debug e => _12; } } diff --git a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff index d67477ab1b9..65379ae8b89 100644 --- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff +++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff @@ -16,13 +16,10 @@ debug residual => _6; scope 2 { scope 8 (inlined #[track_caller] <Result<i32, i32> as FromResidual<Result<Infallible, i32>>>::from_residual) { - debug residual => _8; let _14: i32; let mut _15: i32; scope 9 { - debug e => _14; scope 10 (inlined <i32 as From<i32>>::from) { - debug t => _14; } } } @@ -34,16 +31,13 @@ } } scope 5 (inlined <Result<i32, i32> as Try>::branch) { - debug self => _4; let mut _10: isize; let _11: i32; let _12: i32; let mut _13: std::result::Result<std::convert::Infallible, i32>; scope 6 { - debug v => _11; } scope 7 { - debug e => _12; } } diff --git a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir index 845673601b2..845673601b2 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-abort.mir diff --git a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir new file mode 100644 index 00000000000..845673601b2 --- /dev/null +++ b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.panic-unwind.mir @@ -0,0 +1,68 @@ +// MIR for `checked_shl` after PreCodegen + +fn checked_shl(_1: u32, _2: u32) -> Option<u32> { + debug x => _1; + debug rhs => _2; + let mut _0: std::option::Option<u32>; + scope 1 (inlined core::num::<impl u32>::checked_shl) { + debug self => _1; + debug rhs => _2; + let mut _6: bool; + scope 2 { + debug a => _4; + debug b => _5; + } + scope 3 (inlined core::num::<impl u32>::overflowing_shl) { + debug self => _1; + debug rhs => _2; + let mut _4: u32; + let mut _5: bool; + scope 4 (inlined core::num::<impl u32>::wrapping_shl) { + debug self => _1; + debug rhs => _2; + let mut _3: u32; + scope 5 (inlined core::num::<impl u32>::unchecked_shl) { + debug self => _1; + debug rhs => _3; + } + } + } + } + + bb0: { + StorageLive(_4); + StorageLive(_5); + StorageLive(_3); + _3 = BitAnd(_2, const 31_u32); + _4 = ShlUnchecked(_1, _3); + StorageDead(_3); + _5 = Ge(_2, const core::num::<impl u32>::BITS); + StorageLive(_6); + _6 = unlikely(move _5) -> [return: bb1, unwind unreachable]; + } + + bb1: { + switchInt(move _6) -> [0: bb2, otherwise: bb3]; + } + + bb2: { + _0 = Option::<u32>::Some(_4); + goto -> bb4; + } + + bb3: { + _0 = const Option::<u32>::None; + goto -> bb4; + } + + bb4: { + StorageDead(_6); + StorageDead(_5); + StorageDead(_4); + return; + } +} + +ALLOC0 (size: 8, align: 4) { + 00 00 00 00 __ __ __ __ │ ....░░░░ +} diff --git a/tests/mir-opt/pre-codegen/checked_ops.rs b/tests/mir-opt/pre-codegen/checked_ops.rs index 3ff1123d0b1..8dd5c4b495e 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.rs +++ b/tests/mir-opt/pre-codegen/checked_ops.rs @@ -1,12 +1,13 @@ // skip-filecheck //@ compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=2 -//@ needs-unwind +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![crate_type = "lib"] #![feature(step_trait)] // EMIT_MIR checked_ops.step_forward.PreCodegen.after.mir -pub fn step_forward(x: u32, n: usize) -> u32 { +pub fn step_forward(x: u16, n: usize) -> u16 { + // This uses `u16` so that the conversion to usize is always widening. std::iter::Step::forward(x, n) } diff --git a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir new file mode 100644 index 00000000000..cfb9134a1f1 --- /dev/null +++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-abort.mir @@ -0,0 +1,15 @@ +// MIR for `step_forward` after PreCodegen + +fn step_forward(_1: u16, _2: usize) -> u16 { + debug x => _1; + debug n => _2; + let mut _0: u16; + + bb0: { + _0 = <u16 as Step>::forward(move _1, move _2) -> [return: bb1, unwind unreachable]; + } + + bb1: { + return; + } +} diff --git a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir index f1d0da28b4e..cacc1224aba 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.panic-unwind.mir @@ -1,12 +1,12 @@ // MIR for `step_forward` after PreCodegen -fn step_forward(_1: u32, _2: usize) -> u32 { +fn step_forward(_1: u16, _2: usize) -> u16 { debug x => _1; debug n => _2; - let mut _0: u32; + let mut _0: u16; bb0: { - _0 = <u32 as Step>::forward(move _1, move _2) -> [return: bb1, unwind continue]; + _0 = <u16 as Step>::forward(move _1, move _2) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir index a6c64425912..47f10451b05 100644 --- a/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir @@ -4,71 +4,51 @@ fn <impl at $DIR/derived_ord.rs:6:10: 6:20>::partial_cmp(_1: &MultiField, _2: &M debug self => _1; debug other => _2; let mut _0: std::option::Option<std::cmp::Ordering>; - let mut _3: &char; - let mut _4: &char; - let mut _8: std::option::Option<std::cmp::Ordering>; - let mut _9: i8; - let mut _10: &i16; - let mut _11: &i16; + let mut _6: std::option::Option<std::cmp::Ordering>; + let mut _7: i8; scope 1 { - debug cmp => _8; + debug cmp => _6; } scope 2 (inlined std::cmp::impls::<impl PartialOrd for char>::partial_cmp) { - debug self => _3; - debug other => _4; - let mut _5: char; - let mut _6: char; - let mut _7: std::cmp::Ordering; + let mut _3: char; + let mut _4: char; + let mut _5: std::cmp::Ordering; } scope 3 (inlined std::cmp::impls::<impl PartialOrd for i16>::partial_cmp) { - debug self => _10; - debug other => _11; - let mut _12: i16; - let mut _13: i16; - let mut _14: std::cmp::Ordering; + let mut _8: i16; + let mut _9: i16; + let mut _10: std::cmp::Ordering; } bb0: { StorageLive(_3); - _3 = &((*_1).0: char); + _3 = ((*_1).0: char); StorageLive(_4); - _4 = &((*_2).0: char); - StorageLive(_5); - _5 = ((*_1).0: char); - StorageLive(_6); - _6 = ((*_2).0: char); - _7 = Cmp(move _5, move _6); - StorageDead(_6); - StorageDead(_5); - _8 = Option::<std::cmp::Ordering>::Some(_7); + _4 = ((*_2).0: char); + _5 = Cmp(move _3, move _4); StorageDead(_4); StorageDead(_3); - _9 = discriminant(_7); - switchInt(move _9) -> [0: bb1, otherwise: bb2]; + _6 = Option::<std::cmp::Ordering>::Some(_5); + _7 = discriminant(_5); + switchInt(move _7) -> [0: bb1, otherwise: bb2]; } bb1: { StorageLive(_10); - _10 = &((*_1).1: i16); - StorageLive(_11); - _11 = &((*_2).1: i16); - StorageLive(_14); - StorageLive(_12); - _12 = ((*_1).1: i16); - StorageLive(_13); - _13 = ((*_2).1: i16); - _14 = Cmp(move _12, move _13); - StorageDead(_13); - StorageDead(_12); - _0 = Option::<std::cmp::Ordering>::Some(move _14); - StorageDead(_14); - StorageDead(_11); + StorageLive(_8); + _8 = ((*_1).1: i16); + StorageLive(_9); + _9 = ((*_2).1: i16); + _10 = Cmp(move _8, move _9); + StorageDead(_9); + StorageDead(_8); + _0 = Option::<std::cmp::Ordering>::Some(move _10); StorageDead(_10); goto -> bb3; } bb2: { - _0 = _8; + _0 = _6; goto -> bb3; } diff --git a/tests/mir-opt/pre-codegen/intrinsics.f_u64.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/intrinsics.f_u64.PreCodegen.after.mir index 174fb2c0c3c..1109da31d95 100644 --- a/tests/mir-opt/pre-codegen/intrinsics.f_u64.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/intrinsics.f_u64.PreCodegen.after.mir @@ -3,7 +3,6 @@ fn f_u64() -> () { let mut _0: (); scope 1 (inlined f_dispatch::<u64>) { - debug t => const 0_u64; let _1: (); scope 2 (inlined std::mem::size_of::<u64>) { } diff --git a/tests/mir-opt/pre-codegen/intrinsics.f_unit.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/intrinsics.f_unit.PreCodegen.after.mir index 578cb2d7069..2768c2bb2d7 100644 --- a/tests/mir-opt/pre-codegen/intrinsics.f_unit.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/intrinsics.f_unit.PreCodegen.after.mir @@ -3,7 +3,6 @@ fn f_unit() -> () { let mut _0: (); scope 1 (inlined f_dispatch::<()>) { - debug t => const (); let _1: (); scope 2 (inlined std::mem::size_of::<()>) { } diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff index 2865b829e3e..17d83752fc1 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff @@ -18,11 +18,8 @@ debug ptr => _3; } scope 5 (inlined <std::alloc::Global as Allocator>::allocate) { - debug self => _9; - debug layout => _8; } scope 6 (inlined #[track_caller] Result::<NonNull<[u8]>, std::alloc::AllocError>::unwrap) { - debug self => _6; let mut _12: isize; let _13: std::alloc::AllocError; let mut _14: !; @@ -30,23 +27,18 @@ let mut _16: &dyn std::fmt::Debug; let mut _17: &std::alloc::AllocError; scope 7 { - debug t => _5; } scope 8 { - debug e => const std::alloc::AllocError; } } scope 9 (inlined NonNull::<[u8]>::as_ptr) { - debug self => _5; let mut _18: *const [u8]; } } scope 3 (inlined #[track_caller] Option::<Layout>::unwrap) { - debug self => _2; let mut _10: isize; let mut _11: !; scope 4 { - debug val => _1; } } diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff index 603b1405562..4a37c860320 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff @@ -18,20 +18,15 @@ debug ptr => _3; } scope 5 (inlined <std::alloc::Global as Allocator>::allocate) { - debug self => _9; - debug layout => _8; } scope 6 (inlined NonNull::<[u8]>::as_ptr) { - debug self => _5; let mut _12: *const [u8]; } } scope 3 (inlined #[track_caller] Option::<Layout>::unwrap) { - debug self => _2; let mut _10: isize; let mut _11: !; scope 4 { - debug val => _1; } } diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff index 44964392dd6..1cf950402c3 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff @@ -18,11 +18,8 @@ debug ptr => _3; } scope 5 (inlined <std::alloc::Global as Allocator>::allocate) { - debug self => _9; - debug layout => _8; } scope 6 (inlined #[track_caller] Result::<NonNull<[u8]>, std::alloc::AllocError>::unwrap) { - debug self => _6; let mut _12: isize; let _13: std::alloc::AllocError; let mut _14: !; @@ -30,23 +27,18 @@ let mut _16: &dyn std::fmt::Debug; let mut _17: &std::alloc::AllocError; scope 7 { - debug t => _5; } scope 8 { - debug e => const std::alloc::AllocError; } } scope 9 (inlined NonNull::<[u8]>::as_ptr) { - debug self => _5; let mut _18: *const [u8]; } } scope 3 (inlined #[track_caller] Option::<Layout>::unwrap) { - debug self => _2; let mut _10: isize; let mut _11: !; scope 4 { - debug val => _1; } } diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff index 5fd4af21a11..ec2e95fecb6 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff @@ -18,20 +18,15 @@ debug ptr => _3; } scope 5 (inlined <std::alloc::Global as Allocator>::allocate) { - debug self => _9; - debug layout => _8; } scope 6 (inlined NonNull::<[u8]>::as_ptr) { - debug self => _5; let mut _12: *const [u8]; } } scope 3 (inlined #[track_caller] Option::<Layout>::unwrap) { - debug self => _2; let mut _10: isize; let mut _11: !; scope 4 { - debug val => _1; } } diff --git a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-abort.mir index c744787fce2..a3dc54f73c8 100644 --- a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-abort.mir @@ -5,17 +5,11 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 { debug v => _2; let mut _0: u32; scope 1 (inlined std::mem::replace::<u32>) { - debug dest => _1; - debug src => _2; scope 2 { - debug result => _0; scope 4 (inlined std::ptr::write::<u32>) { - debug dst => _1; - debug src => _2; } } scope 3 (inlined std::ptr::read::<u32>) { - debug src => _1; } } diff --git a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-unwind.mir index c744787fce2..a3dc54f73c8 100644 --- a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.panic-unwind.mir @@ -5,17 +5,11 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 { debug v => _2; let mut _0: u32; scope 1 (inlined std::mem::replace::<u32>) { - debug dest => _1; - debug src => _2; scope 2 { - debug result => _0; scope 4 (inlined std::ptr::write::<u32>) { - debug dst => _1; - debug src => _2; } } scope 3 (inlined std::ptr::read::<u32>) { - debug src => _1; } } diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir index 002d55ad9d9..96b4962854d 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -5,77 +5,56 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { debug end => _2; debug f => _3; let mut _0: (); - let mut _4: std::ops::Range<u32>; - let mut _5: std::ops::Range<u32>; - let mut _6: &mut std::ops::Range<u32>; - let mut _14: std::option::Option<u32>; - let mut _16: &impl Fn(u32); - let mut _17: (u32,); - let _18: (); + let mut _4: u32; + let mut _9: std::option::Option<u32>; + let mut _11: &impl Fn(u32); + let mut _12: (u32,); + let _13: (); scope 1 { - debug iter => _5; - let _15: u32; + debug ((iter: std::ops::Range<u32>).0: u32) => _4; + debug ((iter: std::ops::Range<u32>).1: u32) => _2; + let _10: u32; scope 2 { - debug x => _15; + debug x => _10; } scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) { - debug self => _6; scope 5 (inlined <std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next) { - debug self => _6; - let mut _7: &u32; - let mut _8: &u32; - let mut _11: bool; - let _12: u32; - let mut _13: u32; + let mut _6: bool; + let _7: u32; + let mut _8: u32; scope 6 { - debug old => _12; } scope 7 (inlined std::cmp::impls::<impl PartialOrd for u32>::lt) { - debug self => _7; - debug other => _8; - let mut _9: u32; - let mut _10: u32; + let mut _5: u32; } } } } scope 3 (inlined <std::ops::Range<u32> as IntoIterator>::into_iter) { - debug self => _4; } bb0: { - _4 = std::ops::Range::<u32> { start: _1, end: _2 }; - StorageLive(_5); - _5 = _4; + StorageLive(_4); + _4 = _1; goto -> bb1; } bb1: { - StorageLive(_14); - _6 = &mut _5; - StorageLive(_12); - StorageLive(_11); - StorageLive(_7); - _7 = &(_5.0: u32); - StorageLive(_8); - _8 = &(_5.1: u32); StorageLive(_9); - _9 = (_5.0: u32); - StorageLive(_10); - _10 = (_5.1: u32); - _11 = Lt(move _9, move _10); - StorageDead(_10); - StorageDead(_9); - switchInt(move _11) -> [0: bb2, otherwise: bb4]; + StorageLive(_7); + StorageLive(_6); + StorageLive(_5); + _5 = _4; + _6 = Lt(move _5, _2); + StorageDead(_5); + switchInt(move _6) -> [0: bb2, otherwise: bb4]; } bb2: { - StorageDead(_8); + StorageDead(_6); StorageDead(_7); - StorageDead(_11); - StorageDead(_12); - StorageDead(_14); - StorageDead(_5); + StorageDead(_9); + StorageDead(_4); drop(_3) -> [return: bb3, unwind unreachable]; } @@ -84,31 +63,29 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb4: { - StorageDead(_8); - StorageDead(_7); - _12 = (_5.0: u32); - StorageLive(_13); - _13 = <u32 as Step>::forward_unchecked(_12, const 1_usize) -> [return: bb5, unwind unreachable]; + _7 = _4; + StorageLive(_8); + _8 = <u32 as Step>::forward_unchecked(_7, const 1_usize) -> [return: bb5, unwind unreachable]; } bb5: { - (_5.0: u32) = move _13; - StorageDead(_13); - _14 = Option::<u32>::Some(_12); - StorageDead(_11); - StorageDead(_12); - _15 = ((_14 as Some).0: u32); - StorageLive(_16); - _16 = &_3; - StorageLive(_17); - _17 = (_15,); - _18 = <impl Fn(u32) as Fn<(u32,)>>::call(move _16, move _17) -> [return: bb6, unwind unreachable]; + _4 = move _8; + StorageDead(_8); + _9 = Option::<u32>::Some(_7); + StorageDead(_6); + StorageDead(_7); + _10 = ((_9 as Some).0: u32); + StorageLive(_11); + _11 = &_3; + StorageLive(_12); + _12 = (_10,); + _13 = <impl Fn(u32) as Fn<(u32,)>>::call(move _11, move _12) -> [return: bb6, unwind unreachable]; } bb6: { - StorageDead(_17); - StorageDead(_16); - StorageDead(_14); + StorageDead(_12); + StorageDead(_11); + StorageDead(_9); goto -> bb1; } } diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir index d5021ac84d2..ce8e2bd083e 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -5,77 +5,56 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { debug end => _2; debug f => _3; let mut _0: (); - let mut _4: std::ops::Range<u32>; - let mut _5: std::ops::Range<u32>; - let mut _6: &mut std::ops::Range<u32>; - let mut _14: std::option::Option<u32>; - let mut _16: &impl Fn(u32); - let mut _17: (u32,); - let _18: (); + let mut _4: u32; + let mut _9: std::option::Option<u32>; + let mut _11: &impl Fn(u32); + let mut _12: (u32,); + let _13: (); scope 1 { - debug iter => _5; - let _15: u32; + debug ((iter: std::ops::Range<u32>).0: u32) => _4; + debug ((iter: std::ops::Range<u32>).1: u32) => _2; + let _10: u32; scope 2 { - debug x => _15; + debug x => _10; } scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) { - debug self => _6; scope 5 (inlined <std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next) { - debug self => _6; - let mut _7: &u32; - let mut _8: &u32; - let mut _11: bool; - let _12: u32; - let mut _13: u32; + let mut _6: bool; + let _7: u32; + let mut _8: u32; scope 6 { - debug old => _12; } scope 7 (inlined std::cmp::impls::<impl PartialOrd for u32>::lt) { - debug self => _7; - debug other => _8; - let mut _9: u32; - let mut _10: u32; + let mut _5: u32; } } } } scope 3 (inlined <std::ops::Range<u32> as IntoIterator>::into_iter) { - debug self => _4; } bb0: { - _4 = std::ops::Range::<u32> { start: _1, end: _2 }; - StorageLive(_5); - _5 = _4; + StorageLive(_4); + _4 = _1; goto -> bb1; } bb1: { - StorageLive(_14); - _6 = &mut _5; - StorageLive(_12); - StorageLive(_11); - StorageLive(_7); - _7 = &(_5.0: u32); - StorageLive(_8); - _8 = &(_5.1: u32); StorageLive(_9); - _9 = (_5.0: u32); - StorageLive(_10); - _10 = (_5.1: u32); - _11 = Lt(move _9, move _10); - StorageDead(_10); - StorageDead(_9); - switchInt(move _11) -> [0: bb2, otherwise: bb4]; + StorageLive(_7); + StorageLive(_6); + StorageLive(_5); + _5 = _4; + _6 = Lt(move _5, _2); + StorageDead(_5); + switchInt(move _6) -> [0: bb2, otherwise: bb4]; } bb2: { - StorageDead(_8); + StorageDead(_6); StorageDead(_7); - StorageDead(_11); - StorageDead(_12); - StorageDead(_14); - StorageDead(_5); + StorageDead(_9); + StorageDead(_4); drop(_3) -> [return: bb3, unwind continue]; } @@ -84,31 +63,29 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb4: { - StorageDead(_8); - StorageDead(_7); - _12 = (_5.0: u32); - StorageLive(_13); - _13 = <u32 as Step>::forward_unchecked(_12, const 1_usize) -> [return: bb5, unwind: bb7]; + _7 = _4; + StorageLive(_8); + _8 = <u32 as Step>::forward_unchecked(_7, const 1_usize) -> [return: bb5, unwind: bb7]; } bb5: { - (_5.0: u32) = move _13; - StorageDead(_13); - _14 = Option::<u32>::Some(_12); - StorageDead(_11); - StorageDead(_12); - _15 = ((_14 as Some).0: u32); - StorageLive(_16); - _16 = &_3; - StorageLive(_17); - _17 = (_15,); - _18 = <impl Fn(u32) as Fn<(u32,)>>::call(move _16, move _17) -> [return: bb6, unwind: bb7]; + _4 = move _8; + StorageDead(_8); + _9 = Option::<u32>::Some(_7); + StorageDead(_6); + StorageDead(_7); + _10 = ((_9 as Some).0: u32); + StorageLive(_11); + _11 = &_3; + StorageLive(_12); + _12 = (_10,); + _13 = <impl Fn(u32) as Fn<(u32,)>>::call(move _11, move _12) -> [return: bb6, unwind: bb7]; } bb6: { - StorageDead(_17); - StorageDead(_16); - StorageDead(_14); + StorageDead(_12); + StorageDead(_11); + StorageDead(_9); goto -> bb1; } diff --git a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir index 0836600cb6e..ce79a33013d 100644 --- a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir @@ -20,15 +20,11 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { debug x => _9; } scope 5 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) { - debug self => _6; } } scope 3 (inlined RangeInclusive::<u32>::new) { - debug start => _1; - debug end => _2; } scope 4 (inlined <RangeInclusive<u32> as IntoIterator>::into_iter) { - debug self => _4; } bb0: { diff --git a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir index 8c1794de524..602ecb7c9b8 100644 --- a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir @@ -20,15 +20,11 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { debug x => _9; } scope 5 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) { - debug self => _6; } } scope 3 (inlined RangeInclusive::<u32>::new) { - debug start => _1; - debug end => _2; } scope 4 (inlined <RangeInclusive<u32> as IntoIterator>::into_iter) { - debug self => _4; } bb0: { diff --git a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-abort.mir index b0f475b4db7..8e038246fa2 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-abort.mir @@ -4,7 +4,6 @@ fn range_inclusive_iter_next(_1: &mut RangeInclusive<u32>) -> Option<u32> { debug it => _1; let mut _0: std::option::Option<u32>; scope 1 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) { - debug self => _1; } bb0: { diff --git a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir index 663ec229f72..f54d003c662 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir @@ -4,7 +4,6 @@ fn range_inclusive_iter_next(_1: &mut RangeInclusive<u32>) -> Option<u32> { debug it => _1; let mut _0: std::option::Option<u32>; scope 1 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) { - debug self => _1; } bb0: { diff --git a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir index 7faae1d863c..2ac7e880ccb 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-abort.mir @@ -4,68 +4,53 @@ fn range_iter_next(_1: &mut std::ops::Range<u32>) -> Option<u32> { debug it => _1; let mut _0: std::option::Option<u32>; scope 1 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) { - debug self => _1; scope 2 (inlined <std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next) { - debug self => _1; - let mut _2: &u32; - let mut _3: &u32; - let mut _6: bool; - let _7: u32; - let mut _8: u32; + let mut _4: bool; + let _5: u32; + let mut _6: u32; scope 3 { - debug old => _7; } scope 4 (inlined std::cmp::impls::<impl PartialOrd for u32>::lt) { - debug self => _2; - debug other => _3; - let mut _4: u32; - let mut _5: u32; + let mut _2: u32; + let mut _3: u32; } } } bb0: { - StorageLive(_7); - StorageLive(_6); + StorageLive(_5); + StorageLive(_4); StorageLive(_2); - _2 = &((*_1).0: u32); + _2 = ((*_1).0: u32); StorageLive(_3); - _3 = &((*_1).1: u32); - StorageLive(_4); - _4 = ((*_1).0: u32); - StorageLive(_5); - _5 = ((*_1).1: u32); - _6 = Lt(move _4, move _5); - StorageDead(_5); - StorageDead(_4); - switchInt(move _6) -> [0: bb1, otherwise: bb2]; + _3 = ((*_1).1: u32); + _4 = Lt(move _2, move _3); + StorageDead(_3); + StorageDead(_2); + switchInt(move _4) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageDead(_3); - StorageDead(_2); _0 = const Option::<u32>::None; goto -> bb4; } bb2: { - StorageDead(_3); - StorageDead(_2); - _7 = ((*_1).0: u32); - StorageLive(_8); - _8 = <u32 as Step>::forward_unchecked(_7, const 1_usize) -> [return: bb3, unwind unreachable]; + _5 = ((*_1).0: u32); + StorageLive(_6); + _6 = <u32 as Step>::forward_unchecked(_5, const 1_usize) -> [return: bb3, unwind unreachable]; } bb3: { - ((*_1).0: u32) = move _8; - StorageDead(_8); - _0 = Option::<u32>::Some(_7); + ((*_1).0: u32) = move _6; + StorageDead(_6); + _0 = Option::<u32>::Some(_5); goto -> bb4; } bb4: { - StorageDead(_6); - StorageDead(_7); + StorageDead(_4); + StorageDead(_5); return; } } diff --git a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir index 37f00533b60..60bf644fce6 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir @@ -4,68 +4,53 @@ fn range_iter_next(_1: &mut std::ops::Range<u32>) -> Option<u32> { debug it => _1; let mut _0: std::option::Option<u32>; scope 1 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) { - debug self => _1; scope 2 (inlined <std::ops::Range<u32> as iter::range::RangeIteratorImpl>::spec_next) { - debug self => _1; - let mut _2: &u32; - let mut _3: &u32; - let mut _6: bool; - let _7: u32; - let mut _8: u32; + let mut _4: bool; + let _5: u32; + let mut _6: u32; scope 3 { - debug old => _7; } scope 4 (inlined std::cmp::impls::<impl PartialOrd for u32>::lt) { - debug self => _2; - debug other => _3; - let mut _4: u32; - let mut _5: u32; + let mut _2: u32; + let mut _3: u32; } } } bb0: { - StorageLive(_7); - StorageLive(_6); + StorageLive(_5); + StorageLive(_4); StorageLive(_2); - _2 = &((*_1).0: u32); + _2 = ((*_1).0: u32); StorageLive(_3); - _3 = &((*_1).1: u32); - StorageLive(_4); - _4 = ((*_1).0: u32); - StorageLive(_5); - _5 = ((*_1).1: u32); - _6 = Lt(move _4, move _5); - StorageDead(_5); - StorageDead(_4); - switchInt(move _6) -> [0: bb1, otherwise: bb2]; + _3 = ((*_1).1: u32); + _4 = Lt(move _2, move _3); + StorageDead(_3); + StorageDead(_2); + switchInt(move _4) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageDead(_3); - StorageDead(_2); _0 = const Option::<u32>::None; goto -> bb4; } bb2: { - StorageDead(_3); - StorageDead(_2); - _7 = ((*_1).0: u32); - StorageLive(_8); - _8 = <u32 as Step>::forward_unchecked(_7, const 1_usize) -> [return: bb3, unwind continue]; + _5 = ((*_1).0: u32); + StorageLive(_6); + _6 = <u32 as Step>::forward_unchecked(_5, const 1_usize) -> [return: bb3, unwind continue]; } bb3: { - ((*_1).0: u32) = move _8; - StorageDead(_8); - _0 = Option::<u32>::Some(_7); + ((*_1).0: u32) = move _6; + StorageDead(_6); + _0 = Option::<u32>::Some(_5); goto -> bb4; } bb4: { - StorageDead(_6); - StorageDead(_7); + StorageDead(_4); + StorageDead(_5); return; } } diff --git a/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir index 7265a4fc942..030f9c3b93e 100644 --- a/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir @@ -4,15 +4,11 @@ fn ezmap(_1: Option<i32>) -> Option<i32> { debug x => _1; let mut _0: std::option::Option<i32>; scope 1 (inlined map::<i32, i32, {closure@$DIR/simple_option_map.rs:17:12: 17:15}>) { - debug slf => _1; - debug f => const ZeroSized: {closure@$DIR/simple_option_map.rs:17:12: 17:15}; let mut _2: isize; let _3: i32; let mut _4: i32; scope 2 { - debug x => _3; scope 3 (inlined ezmap::{closure#0}) { - debug n => _3; } } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir index 153505b1bbb..7e20817cf23 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir @@ -5,8 +5,6 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { debug index => _2; let mut _0: std::option::Option<&mut u32>; scope 1 (inlined core::slice::<impl [u32]>::get_mut::<usize>) { - debug self => _1; - debug index => _2; } bb0: { diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir index d37ee783117..2f65b8c6401 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir @@ -5,8 +5,6 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { debug index => _2; let mut _0: std::option::Option<&mut u32>; scope 1 (inlined core::slice::<impl [u32]>::get_mut::<usize>) { - debug self => _1; - debug index => _2; } bb0: { diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir index e5490955a36..ef3f4a21720 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir @@ -5,8 +5,6 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> debug index => _2; let mut _0: &mut [u32]; scope 1 (inlined core::slice::<impl [u32]>::get_unchecked_mut::<std::ops::Range<usize>>) { - debug self => _1; - debug index => _2; let mut _3: *mut [u32]; let mut _4: *mut [u32]; } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir index 810fee9a149..9e93a43ac72 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir @@ -5,8 +5,6 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> debug index => _2; let mut _0: &mut [u32]; scope 1 (inlined core::slice::<impl [u32]>::get_unchecked_mut::<std::ops::Range<usize>>) { - debug self => _1; - debug index => _2; let mut _3: *mut [u32]; let mut _4: *mut [u32]; } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-abort.mir index d97c96ac8a0..731f6438a6e 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-abort.mir @@ -5,8 +5,6 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range<usize>) -> &[u32] { debug index => _2; let mut _0: &[u32]; scope 1 (inlined #[track_caller] core::slice::index::<impl Index<std::ops::Range<usize>> for [u32]>::index) { - debug self => _1; - debug index => _2; } bb0: { diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir index 4a976002fa5..d879d06bb4e 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir @@ -5,8 +5,6 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range<usize>) -> &[u32] { debug index => _2; let mut _0: &[u32]; scope 1 (inlined #[track_caller] core::slice::index::<impl Index<std::ops::Range<usize>> for [u32]>::index) { - debug self => _1; - debug index => _2; } bb0: { 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 1ec85906385..d979c5ec1d5 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,147 +4,128 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _13: std::slice::Iter<'_, T>; + let mut _12: std::slice::Iter<'_, T>; + let mut _13: std::iter::Enumerate<std::slice::Iter<'_, T>>; let mut _14: std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _15: std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _16: &mut std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _17: std::option::Option<(usize, &T)>; - let mut _18: isize; - let mut _21: &impl Fn(usize, &T); - let mut _22: (usize, &T); - let _23: (); + let mut _15: &mut std::iter::Enumerate<std::slice::Iter<'_, T>>; + let mut _16: std::option::Option<(usize, &T)>; + let mut _17: isize; + let mut _20: &impl Fn(usize, &T); + let mut _21: (usize, &T); + let _22: (); scope 1 { - debug iter => _15; - let _19: usize; - let _20: &T; + debug iter => _14; + let _18: usize; + let _19: &T; scope 2 { - debug i => _19; - debug x => _20; + debug i => _18; + debug x => _19; } } scope 3 (inlined core::slice::<impl [T]>::iter) { - debug self => _1; scope 4 (inlined std::slice::Iter::<'_, T>::new) { - debug slice => _1; let _3: usize; - let mut _5: std::ptr::NonNull<[T]>; - let mut _8: bool; + let mut _7: bool; + let mut _8: *mut T; let mut _9: *mut T; - let mut _10: *mut T; - let mut _12: *const T; + let mut _11: *const T; scope 5 { - debug len => _3; - let _7: std::ptr::NonNull<T>; + let _6: std::ptr::NonNull<T>; scope 6 { - debug ptr => _7; - let _11: *const T; + let _10: *const T; scope 7 { - debug end_or_len => _11; } scope 11 (inlined without_provenance::<T>) { - debug addr => _3; } scope 12 (inlined NonNull::<T>::as_ptr) { - debug self => _7; } scope 13 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { - debug self => _9; - debug count => _3; } } scope 8 (inlined <NonNull<[T]> as From<&[T]>>::from) { - debug reference => _1; let mut _4: *const [T]; } scope 9 (inlined NonNull::<[T]>::cast::<T>) { - debug self => _5; - let mut _6: *const T; + let mut _5: *const T; scope 10 (inlined NonNull::<[T]>::as_ptr) { - debug self => _5; } } } } } scope 14 (inlined <std::slice::Iter<'_, T> as Iterator>::enumerate) { - debug self => _13; scope 15 (inlined Enumerate::<std::slice::Iter<'_, T>>::new) { - debug iter => _13; } } scope 16 (inlined <Enumerate<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) { - debug self => _14; } bb0: { - StorageLive(_13); + StorageLive(_12); StorageLive(_3); - StorageLive(_7); - StorageLive(_4); StorageLive(_6); - _3 = Len((*_1)); + StorageLive(_4); StorageLive(_5); + _3 = Len((*_1)); _4 = &raw const (*_1); - _5 = NonNull::<[T]> { pointer: _4 }; - _6 = _4 as *const T (PtrToPtr); - _7 = NonNull::<T> { pointer: _6 }; - StorageDead(_5); - StorageLive(_11); - StorageLive(_8); - _8 = const <T as std::mem::SizedTypeProperties>::IS_ZST; - switchInt(move _8) -> [0: bb1, otherwise: bb2]; + _5 = _4 as *const T (PtrToPtr); + _6 = NonNull::<T> { pointer: _5 }; + StorageLive(_10); + StorageLive(_7); + _7 = const <T as std::mem::SizedTypeProperties>::IS_ZST; + switchInt(move _7) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_10); StorageLive(_9); - _9 = _4 as *mut T (PtrToPtr); - _10 = Offset(_9, _3); + StorageLive(_8); + _8 = _4 as *mut T (PtrToPtr); + _9 = Offset(_8, _3); + StorageDead(_8); + _10 = move _9 as *const T (PointerCoercion(MutToConstPointer)); StorageDead(_9); - _11 = move _10 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_10); goto -> bb3; } bb2: { - _11 = _3 as *const T (Transmute); + _10 = _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_8); - StorageLive(_12); - _12 = _11; - _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_12); + StorageDead(_7); + StorageLive(_11); + _11 = _10; + _12 = std::slice::Iter::<'_, T> { ptr: _6, end_or_len: move _11, _marker: const ZeroSized: PhantomData<&T> }; StorageDead(_11); - StorageDead(_6); + StorageDead(_10); + StorageDead(_5); StorageDead(_4); - StorageDead(_7); + StorageDead(_6); StorageDead(_3); - _14 = Enumerate::<std::slice::Iter<'_, T>> { iter: _13, count: const 0_usize }; - StorageDead(_13); - StorageLive(_15); - _15 = _14; + _13 = Enumerate::<std::slice::Iter<'_, T>> { iter: _12, count: const 0_usize }; + StorageDead(_12); + StorageLive(_14); + _14 = _13; goto -> bb4; } bb4: { - StorageLive(_17); StorageLive(_16); - _16 = &mut _15; - _17 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _16) -> [return: bb5, unwind unreachable]; + StorageLive(_15); + _15 = &mut _14; + _16 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _15) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_16); - _18 = discriminant(_17); - switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_15); + _17 = discriminant(_16); + switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_17); - StorageDead(_15); + StorageDead(_16); + StorageDead(_14); drop(_2) -> [return: bb7, unwind unreachable]; } @@ -153,19 +134,19 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb8: { - _19 = (((_17 as Some).0: (usize, &T)).0: usize); - _20 = (((_17 as Some).0: (usize, &T)).1: &T); + _18 = (((_16 as Some).0: (usize, &T)).0: usize); + _19 = (((_16 as Some).0: (usize, &T)).1: &T); + StorageLive(_20); + _20 = &_2; StorageLive(_21); - _21 = &_2; - StorageLive(_22); - _22 = (_19, _20); - _23 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _21, move _22) -> [return: bb9, unwind unreachable]; + _21 = (_18, _19); + _22 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _20, move _21) -> [return: bb9, unwind unreachable]; } bb9: { - StorageDead(_22); StorageDead(_21); - StorageDead(_17); + StorageDead(_20); + StorageDead(_16); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir index 70cdf3f41c2..8491c49f767 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir @@ -4,147 +4,128 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _13: std::slice::Iter<'_, T>; + let mut _12: std::slice::Iter<'_, T>; + let mut _13: std::iter::Enumerate<std::slice::Iter<'_, T>>; let mut _14: std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _15: std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _16: &mut std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _17: std::option::Option<(usize, &T)>; - let mut _18: isize; - let mut _21: &impl Fn(usize, &T); - let mut _22: (usize, &T); - let _23: (); + let mut _15: &mut std::iter::Enumerate<std::slice::Iter<'_, T>>; + let mut _16: std::option::Option<(usize, &T)>; + let mut _17: isize; + let mut _20: &impl Fn(usize, &T); + let mut _21: (usize, &T); + let _22: (); scope 1 { - debug iter => _15; - let _19: usize; - let _20: &T; + debug iter => _14; + let _18: usize; + let _19: &T; scope 2 { - debug i => _19; - debug x => _20; + debug i => _18; + debug x => _19; } } scope 3 (inlined core::slice::<impl [T]>::iter) { - debug self => _1; scope 4 (inlined std::slice::Iter::<'_, T>::new) { - debug slice => _1; let _3: usize; - let mut _5: std::ptr::NonNull<[T]>; - let mut _8: bool; + let mut _7: bool; + let mut _8: *mut T; let mut _9: *mut T; - let mut _10: *mut T; - let mut _12: *const T; + let mut _11: *const T; scope 5 { - debug len => _3; - let _7: std::ptr::NonNull<T>; + let _6: std::ptr::NonNull<T>; scope 6 { - debug ptr => _7; - let _11: *const T; + let _10: *const T; scope 7 { - debug end_or_len => _11; } scope 11 (inlined without_provenance::<T>) { - debug addr => _3; } scope 12 (inlined NonNull::<T>::as_ptr) { - debug self => _7; } scope 13 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { - debug self => _9; - debug count => _3; } } scope 8 (inlined <NonNull<[T]> as From<&[T]>>::from) { - debug reference => _1; let mut _4: *const [T]; } scope 9 (inlined NonNull::<[T]>::cast::<T>) { - debug self => _5; - let mut _6: *const T; + let mut _5: *const T; scope 10 (inlined NonNull::<[T]>::as_ptr) { - debug self => _5; } } } } } scope 14 (inlined <std::slice::Iter<'_, T> as Iterator>::enumerate) { - debug self => _13; scope 15 (inlined Enumerate::<std::slice::Iter<'_, T>>::new) { - debug iter => _13; } } scope 16 (inlined <Enumerate<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) { - debug self => _14; } bb0: { - StorageLive(_13); + StorageLive(_12); StorageLive(_3); - StorageLive(_7); - StorageLive(_4); StorageLive(_6); - _3 = Len((*_1)); + StorageLive(_4); StorageLive(_5); + _3 = Len((*_1)); _4 = &raw const (*_1); - _5 = NonNull::<[T]> { pointer: _4 }; - _6 = _4 as *const T (PtrToPtr); - _7 = NonNull::<T> { pointer: _6 }; - StorageDead(_5); - StorageLive(_11); - StorageLive(_8); - _8 = const <T as std::mem::SizedTypeProperties>::IS_ZST; - switchInt(move _8) -> [0: bb1, otherwise: bb2]; + _5 = _4 as *const T (PtrToPtr); + _6 = NonNull::<T> { pointer: _5 }; + StorageLive(_10); + StorageLive(_7); + _7 = const <T as std::mem::SizedTypeProperties>::IS_ZST; + switchInt(move _7) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_10); StorageLive(_9); - _9 = _4 as *mut T (PtrToPtr); - _10 = Offset(_9, _3); + StorageLive(_8); + _8 = _4 as *mut T (PtrToPtr); + _9 = Offset(_8, _3); + StorageDead(_8); + _10 = move _9 as *const T (PointerCoercion(MutToConstPointer)); StorageDead(_9); - _11 = move _10 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_10); goto -> bb3; } bb2: { - _11 = _3 as *const T (Transmute); + _10 = _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_8); - StorageLive(_12); - _12 = _11; - _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_12); + StorageDead(_7); + StorageLive(_11); + _11 = _10; + _12 = std::slice::Iter::<'_, T> { ptr: _6, end_or_len: move _11, _marker: const ZeroSized: PhantomData<&T> }; StorageDead(_11); - StorageDead(_6); + StorageDead(_10); + StorageDead(_5); StorageDead(_4); - StorageDead(_7); + StorageDead(_6); StorageDead(_3); - _14 = Enumerate::<std::slice::Iter<'_, T>> { iter: _13, count: const 0_usize }; - StorageDead(_13); - StorageLive(_15); - _15 = _14; + _13 = Enumerate::<std::slice::Iter<'_, T>> { iter: _12, count: const 0_usize }; + StorageDead(_12); + StorageLive(_14); + _14 = _13; goto -> bb4; } bb4: { - StorageLive(_17); StorageLive(_16); - _16 = &mut _15; - _17 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _16) -> [return: bb5, unwind: bb11]; + StorageLive(_15); + _15 = &mut _14; + _16 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _15) -> [return: bb5, unwind: bb11]; } bb5: { - StorageDead(_16); - _18 = discriminant(_17); - switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_15); + _17 = discriminant(_16); + switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_17); - StorageDead(_15); + StorageDead(_16); + StorageDead(_14); drop(_2) -> [return: bb7, unwind continue]; } @@ -153,19 +134,19 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb8: { - _19 = (((_17 as Some).0: (usize, &T)).0: usize); - _20 = (((_17 as Some).0: (usize, &T)).1: &T); + _18 = (((_16 as Some).0: (usize, &T)).0: usize); + _19 = (((_16 as Some).0: (usize, &T)).1: &T); + StorageLive(_20); + _20 = &_2; StorageLive(_21); - _21 = &_2; - StorageLive(_22); - _22 = (_19, _20); - _23 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _21, move _22) -> [return: bb9, unwind: bb11]; + _21 = (_18, _19); + _22 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _20, move _21) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_22); StorageDead(_21); - StorageDead(_17); + StorageDead(_20); + StorageDead(_16); 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 d8252e7267a..67dd0c85ea1 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,135 +4,118 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); + let mut _12: std::slice::Iter<'_, T>; let mut _13: std::slice::Iter<'_, T>; - let mut _14: std::slice::Iter<'_, T>; - let mut _15: &mut std::slice::Iter<'_, T>; - let mut _16: std::option::Option<&T>; - let mut _17: isize; - let mut _19: &impl Fn(&T); - let mut _20: (&T,); - let _21: (); + let mut _14: &mut std::slice::Iter<'_, T>; + let mut _15: std::option::Option<&T>; + let mut _16: isize; + let mut _18: &impl Fn(&T); + let mut _19: (&T,); + let _20: (); scope 1 { - debug iter => _14; - let _18: &T; + debug iter => _13; + let _17: &T; scope 2 { - debug x => _18; + debug x => _17; } } scope 3 (inlined core::slice::<impl [T]>::iter) { - debug self => _1; scope 4 (inlined std::slice::Iter::<'_, T>::new) { - debug slice => _1; let _3: usize; - let mut _5: std::ptr::NonNull<[T]>; - let mut _8: bool; + let mut _7: bool; + let mut _8: *mut T; let mut _9: *mut T; - let mut _10: *mut T; - let mut _12: *const T; + let mut _11: *const T; scope 5 { - debug len => _3; - let _7: std::ptr::NonNull<T>; + let _6: std::ptr::NonNull<T>; scope 6 { - debug ptr => _7; - let _11: *const T; + let _10: *const T; scope 7 { - debug end_or_len => _11; } scope 11 (inlined without_provenance::<T>) { - debug addr => _3; } scope 12 (inlined NonNull::<T>::as_ptr) { - debug self => _7; } scope 13 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { - debug self => _9; - debug count => _3; } } scope 8 (inlined <NonNull<[T]> as From<&[T]>>::from) { - debug reference => _1; let mut _4: *const [T]; } scope 9 (inlined NonNull::<[T]>::cast::<T>) { - debug self => _5; - let mut _6: *const T; + let mut _5: *const T; scope 10 (inlined NonNull::<[T]>::as_ptr) { - debug self => _5; } } } } } scope 14 (inlined <std::slice::Iter<'_, T> as IntoIterator>::into_iter) { - debug self => _13; } bb0: { StorageLive(_3); - StorageLive(_7); - StorageLive(_4); StorageLive(_6); - _3 = Len((*_1)); + StorageLive(_4); StorageLive(_5); + _3 = Len((*_1)); _4 = &raw const (*_1); - _5 = NonNull::<[T]> { pointer: _4 }; - _6 = _4 as *const T (PtrToPtr); - _7 = NonNull::<T> { pointer: _6 }; - StorageDead(_5); - StorageLive(_11); - StorageLive(_8); - _8 = const <T as std::mem::SizedTypeProperties>::IS_ZST; - switchInt(move _8) -> [0: bb1, otherwise: bb2]; + _5 = _4 as *const T (PtrToPtr); + _6 = NonNull::<T> { pointer: _5 }; + StorageLive(_10); + StorageLive(_7); + _7 = const <T as std::mem::SizedTypeProperties>::IS_ZST; + switchInt(move _7) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_10); StorageLive(_9); - _9 = _4 as *mut T (PtrToPtr); - _10 = Offset(_9, _3); + StorageLive(_8); + _8 = _4 as *mut T (PtrToPtr); + _9 = Offset(_8, _3); + StorageDead(_8); + _10 = move _9 as *const T (PointerCoercion(MutToConstPointer)); StorageDead(_9); - _11 = move _10 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_10); goto -> bb3; } bb2: { - _11 = _3 as *const T (Transmute); + _10 = _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_8); - StorageLive(_12); - _12 = _11; - _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_12); + StorageDead(_7); + StorageLive(_11); + _11 = _10; + _12 = std::slice::Iter::<'_, T> { ptr: _6, end_or_len: move _11, _marker: const ZeroSized: PhantomData<&T> }; StorageDead(_11); - StorageDead(_6); + StorageDead(_10); + StorageDead(_5); StorageDead(_4); - StorageDead(_7); + StorageDead(_6); StorageDead(_3); - StorageLive(_14); - _14 = _13; + StorageLive(_13); + _13 = _12; goto -> bb4; } bb4: { - StorageLive(_16); StorageLive(_15); - _15 = &mut _14; - _16 = <std::slice::Iter<'_, T> as Iterator>::next(move _15) -> [return: bb5, unwind unreachable]; + StorageLive(_14); + _14 = &mut _13; + _15 = <std::slice::Iter<'_, T> as Iterator>::next(move _14) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_15); - _17 = discriminant(_16); - switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_14); + _16 = discriminant(_15); + switchInt(move _16) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_16); - StorageDead(_14); + StorageDead(_15); + StorageDead(_13); drop(_2) -> [return: bb7, unwind unreachable]; } @@ -141,18 +124,18 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _18 = ((_16 as Some).0: &T); + _17 = ((_15 as Some).0: &T); + StorageLive(_18); + _18 = &_2; StorageLive(_19); - _19 = &_2; - StorageLive(_20); - _20 = (_18,); - _21 = <impl Fn(&T) as Fn<(&T,)>>::call(move _19, move _20) -> [return: bb9, unwind unreachable]; + _19 = (_17,); + _20 = <impl Fn(&T) as Fn<(&T,)>>::call(move _18, move _19) -> [return: bb9, unwind unreachable]; } bb9: { - StorageDead(_20); StorageDead(_19); - StorageDead(_16); + StorageDead(_18); + StorageDead(_15); 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 b3904dc70a6..7c41e9e1f1b 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,135 +4,118 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); + let mut _12: std::slice::Iter<'_, T>; let mut _13: std::slice::Iter<'_, T>; - let mut _14: std::slice::Iter<'_, T>; - let mut _15: &mut std::slice::Iter<'_, T>; - let mut _16: std::option::Option<&T>; - let mut _17: isize; - let mut _19: &impl Fn(&T); - let mut _20: (&T,); - let _21: (); + let mut _14: &mut std::slice::Iter<'_, T>; + let mut _15: std::option::Option<&T>; + let mut _16: isize; + let mut _18: &impl Fn(&T); + let mut _19: (&T,); + let _20: (); scope 1 { - debug iter => _14; - let _18: &T; + debug iter => _13; + let _17: &T; scope 2 { - debug x => _18; + debug x => _17; } } scope 3 (inlined core::slice::<impl [T]>::iter) { - debug self => _1; scope 4 (inlined std::slice::Iter::<'_, T>::new) { - debug slice => _1; let _3: usize; - let mut _5: std::ptr::NonNull<[T]>; - let mut _8: bool; + let mut _7: bool; + let mut _8: *mut T; let mut _9: *mut T; - let mut _10: *mut T; - let mut _12: *const T; + let mut _11: *const T; scope 5 { - debug len => _3; - let _7: std::ptr::NonNull<T>; + let _6: std::ptr::NonNull<T>; scope 6 { - debug ptr => _7; - let _11: *const T; + let _10: *const T; scope 7 { - debug end_or_len => _11; } scope 11 (inlined without_provenance::<T>) { - debug addr => _3; } scope 12 (inlined NonNull::<T>::as_ptr) { - debug self => _7; } scope 13 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { - debug self => _9; - debug count => _3; } } scope 8 (inlined <NonNull<[T]> as From<&[T]>>::from) { - debug reference => _1; let mut _4: *const [T]; } scope 9 (inlined NonNull::<[T]>::cast::<T>) { - debug self => _5; - let mut _6: *const T; + let mut _5: *const T; scope 10 (inlined NonNull::<[T]>::as_ptr) { - debug self => _5; } } } } } scope 14 (inlined <std::slice::Iter<'_, T> as IntoIterator>::into_iter) { - debug self => _13; } bb0: { StorageLive(_3); - StorageLive(_7); - StorageLive(_4); StorageLive(_6); - _3 = Len((*_1)); + StorageLive(_4); StorageLive(_5); + _3 = Len((*_1)); _4 = &raw const (*_1); - _5 = NonNull::<[T]> { pointer: _4 }; - _6 = _4 as *const T (PtrToPtr); - _7 = NonNull::<T> { pointer: _6 }; - StorageDead(_5); - StorageLive(_11); - StorageLive(_8); - _8 = const <T as std::mem::SizedTypeProperties>::IS_ZST; - switchInt(move _8) -> [0: bb1, otherwise: bb2]; + _5 = _4 as *const T (PtrToPtr); + _6 = NonNull::<T> { pointer: _5 }; + StorageLive(_10); + StorageLive(_7); + _7 = const <T as std::mem::SizedTypeProperties>::IS_ZST; + switchInt(move _7) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_10); StorageLive(_9); - _9 = _4 as *mut T (PtrToPtr); - _10 = Offset(_9, _3); + StorageLive(_8); + _8 = _4 as *mut T (PtrToPtr); + _9 = Offset(_8, _3); + StorageDead(_8); + _10 = move _9 as *const T (PointerCoercion(MutToConstPointer)); StorageDead(_9); - _11 = move _10 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_10); goto -> bb3; } bb2: { - _11 = _3 as *const T (Transmute); + _10 = _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_8); - StorageLive(_12); - _12 = _11; - _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_12); + StorageDead(_7); + StorageLive(_11); + _11 = _10; + _12 = std::slice::Iter::<'_, T> { ptr: _6, end_or_len: move _11, _marker: const ZeroSized: PhantomData<&T> }; StorageDead(_11); - StorageDead(_6); + StorageDead(_10); + StorageDead(_5); StorageDead(_4); - StorageDead(_7); + StorageDead(_6); StorageDead(_3); - StorageLive(_14); - _14 = _13; + StorageLive(_13); + _13 = _12; goto -> bb4; } bb4: { - StorageLive(_16); StorageLive(_15); - _15 = &mut _14; - _16 = <std::slice::Iter<'_, T> as Iterator>::next(move _15) -> [return: bb5, unwind: bb11]; + StorageLive(_14); + _14 = &mut _13; + _15 = <std::slice::Iter<'_, T> as Iterator>::next(move _14) -> [return: bb5, unwind: bb11]; } bb5: { - StorageDead(_15); - _17 = discriminant(_16); - switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_14); + _16 = discriminant(_15); + switchInt(move _16) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_16); - StorageDead(_14); + StorageDead(_15); + StorageDead(_13); drop(_2) -> [return: bb7, unwind continue]; } @@ -141,18 +124,18 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _18 = ((_16 as Some).0: &T); + _17 = ((_15 as Some).0: &T); + StorageLive(_18); + _18 = &_2; StorageLive(_19); - _19 = &_2; - StorageLive(_20); - _20 = (_18,); - _21 = <impl Fn(&T) as Fn<(&T,)>>::call(move _19, move _20) -> [return: bb9, unwind: bb11]; + _19 = (_17,); + _20 = <impl Fn(&T) as Fn<(&T,)>>::call(move _18, move _19) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_20); StorageDead(_19); - StorageDead(_16); + StorageDead(_18); + StorageDead(_15); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir index 5ab88c9b855..dbe6f39548c 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir @@ -5,86 +5,63 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug f => _2; let mut _0: (); let mut _3: usize; - let mut _4: std::ops::Range<usize>; - let mut _5: std::ops::Range<usize>; - let mut _6: &mut std::ops::Range<usize>; - let mut _14: std::option::Option<usize>; - let mut _16: usize; - let mut _17: bool; - let mut _19: &impl Fn(usize, &T); - let mut _20: (usize, &T); - let _21: (); + let mut _4: usize; + let mut _9: std::option::Option<usize>; + let mut _11: usize; + let mut _12: bool; + let mut _14: &impl Fn(usize, &T); + let mut _15: (usize, &T); + let _16: (); scope 1 { - debug iter => _5; - let _15: usize; + debug ((iter: std::ops::Range<usize>).0: usize) => _4; + debug ((iter: std::ops::Range<usize>).1: usize) => _3; + let _10: usize; scope 2 { - debug i => _15; - let _18: &T; + debug i => _10; + let _13: &T; scope 3 { - debug x => _18; + debug x => _13; } } scope 5 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) { - debug self => _6; scope 6 (inlined <std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next) { - debug self => _6; - let mut _7: &usize; - let mut _8: &usize; - let mut _11: bool; - let _12: usize; - let mut _13: usize; + let mut _6: bool; + let _7: usize; + let mut _8: usize; scope 7 { - debug old => _12; } scope 8 (inlined std::cmp::impls::<impl PartialOrd for usize>::lt) { - debug self => _7; - debug other => _8; - let mut _9: usize; - let mut _10: usize; + let mut _5: usize; } } } } scope 4 (inlined <std::ops::Range<usize> as IntoIterator>::into_iter) { - debug self => _4; } bb0: { - StorageLive(_3); _3 = Len((*_1)); - _4 = std::ops::Range::<usize> { start: const 0_usize, end: move _3 }; - StorageDead(_3); - StorageLive(_5); - _5 = _4; + StorageLive(_4); + _4 = const 0_usize; goto -> bb1; } bb1: { - StorageLive(_14); - _6 = &mut _5; - StorageLive(_12); - StorageLive(_11); - StorageLive(_7); - _7 = &(_5.0: usize); - StorageLive(_8); - _8 = &(_5.1: usize); StorageLive(_9); - _9 = (_5.0: usize); - StorageLive(_10); - _10 = (_5.1: usize); - _11 = Lt(move _9, move _10); - StorageDead(_10); - StorageDead(_9); - switchInt(move _11) -> [0: bb2, otherwise: bb4]; + StorageLive(_7); + StorageLive(_6); + StorageLive(_5); + _5 = _4; + _6 = Lt(move _5, _3); + StorageDead(_5); + switchInt(move _6) -> [0: bb2, otherwise: bb4]; } bb2: { - StorageDead(_8); + StorageDead(_6); StorageDead(_7); - StorageDead(_11); - StorageDead(_12); - StorageDead(_14); - StorageDead(_5); + StorageDead(_9); + StorageDead(_4); drop(_2) -> [return: bb3, unwind unreachable]; } @@ -93,38 +70,36 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb4: { - StorageDead(_8); - StorageDead(_7); - _12 = (_5.0: usize); - StorageLive(_13); - _13 = <usize as Step>::forward_unchecked(_12, const 1_usize) -> [return: bb5, unwind unreachable]; + _7 = _4; + StorageLive(_8); + _8 = <usize as Step>::forward_unchecked(_7, const 1_usize) -> [return: bb5, unwind unreachable]; } bb5: { - (_5.0: usize) = move _13; - StorageDead(_13); - _14 = Option::<usize>::Some(_12); - StorageDead(_11); - StorageDead(_12); - _15 = ((_14 as Some).0: usize); - _16 = Len((*_1)); - _17 = Lt(_15, _16); - assert(move _17, "index out of bounds: the length is {} but the index is {}", move _16, _15) -> [success: bb6, unwind unreachable]; + _4 = move _8; + StorageDead(_8); + _9 = Option::<usize>::Some(_7); + StorageDead(_6); + StorageDead(_7); + _10 = ((_9 as Some).0: usize); + _11 = Len((*_1)); + _12 = Lt(_10, _11); + assert(move _12, "index out of bounds: the length is {} but the index is {}", move _11, _10) -> [success: bb6, unwind unreachable]; } bb6: { - _18 = &(*_1)[_15]; - StorageLive(_19); - _19 = &_2; - StorageLive(_20); - _20 = (_15, _18); - _21 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _19, move _20) -> [return: bb7, unwind unreachable]; + _13 = &(*_1)[_10]; + StorageLive(_14); + _14 = &_2; + StorageLive(_15); + _15 = (_10, _13); + _16 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _14, move _15) -> [return: bb7, unwind unreachable]; } bb7: { - StorageDead(_20); - StorageDead(_19); + StorageDead(_15); StorageDead(_14); + StorageDead(_9); goto -> bb1; } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir index 513651090a8..5b6441cfb3b 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir @@ -5,86 +5,63 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug f => _2; let mut _0: (); let mut _3: usize; - let mut _4: std::ops::Range<usize>; - let mut _5: std::ops::Range<usize>; - let mut _6: &mut std::ops::Range<usize>; - let mut _14: std::option::Option<usize>; - let mut _16: usize; - let mut _17: bool; - let mut _19: &impl Fn(usize, &T); - let mut _20: (usize, &T); - let _21: (); + let mut _4: usize; + let mut _9: std::option::Option<usize>; + let mut _11: usize; + let mut _12: bool; + let mut _14: &impl Fn(usize, &T); + let mut _15: (usize, &T); + let _16: (); scope 1 { - debug iter => _5; - let _15: usize; + debug ((iter: std::ops::Range<usize>).0: usize) => _4; + debug ((iter: std::ops::Range<usize>).1: usize) => _3; + let _10: usize; scope 2 { - debug i => _15; - let _18: &T; + debug i => _10; + let _13: &T; scope 3 { - debug x => _18; + debug x => _13; } } scope 5 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) { - debug self => _6; scope 6 (inlined <std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next) { - debug self => _6; - let mut _7: &usize; - let mut _8: &usize; - let mut _11: bool; - let _12: usize; - let mut _13: usize; + let mut _6: bool; + let _7: usize; + let mut _8: usize; scope 7 { - debug old => _12; } scope 8 (inlined std::cmp::impls::<impl PartialOrd for usize>::lt) { - debug self => _7; - debug other => _8; - let mut _9: usize; - let mut _10: usize; + let mut _5: usize; } } } } scope 4 (inlined <std::ops::Range<usize> as IntoIterator>::into_iter) { - debug self => _4; } bb0: { - StorageLive(_3); _3 = Len((*_1)); - _4 = std::ops::Range::<usize> { start: const 0_usize, end: move _3 }; - StorageDead(_3); - StorageLive(_5); - _5 = _4; + StorageLive(_4); + _4 = const 0_usize; goto -> bb1; } bb1: { - StorageLive(_14); - _6 = &mut _5; - StorageLive(_12); - StorageLive(_11); - StorageLive(_7); - _7 = &(_5.0: usize); - StorageLive(_8); - _8 = &(_5.1: usize); StorageLive(_9); - _9 = (_5.0: usize); - StorageLive(_10); - _10 = (_5.1: usize); - _11 = Lt(move _9, move _10); - StorageDead(_10); - StorageDead(_9); - switchInt(move _11) -> [0: bb2, otherwise: bb4]; + StorageLive(_7); + StorageLive(_6); + StorageLive(_5); + _5 = _4; + _6 = Lt(move _5, _3); + StorageDead(_5); + switchInt(move _6) -> [0: bb2, otherwise: bb4]; } bb2: { - StorageDead(_8); + StorageDead(_6); StorageDead(_7); - StorageDead(_11); - StorageDead(_12); - StorageDead(_14); - StorageDead(_5); + StorageDead(_9); + StorageDead(_4); drop(_2) -> [return: bb3, unwind continue]; } @@ -93,38 +70,36 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb4: { - StorageDead(_8); - StorageDead(_7); - _12 = (_5.0: usize); - StorageLive(_13); - _13 = <usize as Step>::forward_unchecked(_12, const 1_usize) -> [return: bb5, unwind: bb8]; + _7 = _4; + StorageLive(_8); + _8 = <usize as Step>::forward_unchecked(_7, const 1_usize) -> [return: bb5, unwind: bb8]; } bb5: { - (_5.0: usize) = move _13; - StorageDead(_13); - _14 = Option::<usize>::Some(_12); - StorageDead(_11); - StorageDead(_12); - _15 = ((_14 as Some).0: usize); - _16 = Len((*_1)); - _17 = Lt(_15, _16); - assert(move _17, "index out of bounds: the length is {} but the index is {}", move _16, _15) -> [success: bb6, unwind: bb8]; + _4 = move _8; + StorageDead(_8); + _9 = Option::<usize>::Some(_7); + StorageDead(_6); + StorageDead(_7); + _10 = ((_9 as Some).0: usize); + _11 = Len((*_1)); + _12 = Lt(_10, _11); + assert(move _12, "index out of bounds: the length is {} but the index is {}", move _11, _10) -> [success: bb6, unwind: bb8]; } bb6: { - _18 = &(*_1)[_15]; - StorageLive(_19); - _19 = &_2; - StorageLive(_20); - _20 = (_15, _18); - _21 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _19, move _20) -> [return: bb7, unwind: bb8]; + _13 = &(*_1)[_10]; + StorageLive(_14); + _14 = &_2; + StorageLive(_15); + _15 = (_10, _13); + _16 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _14, move _15) -> [return: bb7, unwind: bb8]; } bb7: { - StorageDead(_20); - StorageDead(_19); + StorageDead(_15); StorageDead(_14); + StorageDead(_9); goto -> bb1; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir index 091c8a0e968..ffeef1e04a1 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir @@ -4,150 +4,128 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _13: std::slice::Iter<'_, T>; + let mut _12: std::slice::Iter<'_, T>; + let mut _13: std::iter::Rev<std::slice::Iter<'_, T>>; let mut _14: std::iter::Rev<std::slice::Iter<'_, T>>; - let mut _15: std::iter::Rev<std::slice::Iter<'_, T>>; - let mut _16: &mut std::iter::Rev<std::slice::Iter<'_, T>>; - let mut _18: std::option::Option<&T>; - let mut _19: isize; - let mut _21: &impl Fn(&T); - let mut _22: (&T,); - let _23: (); + let mut _16: std::option::Option<&T>; + let mut _17: isize; + let mut _19: &impl Fn(&T); + let mut _20: (&T,); + let _21: (); scope 1 { - debug iter => _15; - let _20: &T; + debug iter => _14; + let _18: &T; scope 2 { - debug x => _20; + debug x => _18; } scope 17 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) { - debug self => _16; - let mut _17: &mut std::slice::Iter<'_, T>; + let mut _15: &mut std::slice::Iter<'_, T>; } } scope 3 (inlined core::slice::<impl [T]>::iter) { - debug self => _1; scope 4 (inlined std::slice::Iter::<'_, T>::new) { - debug slice => _1; let _3: usize; - let mut _5: std::ptr::NonNull<[T]>; - let mut _8: bool; + let mut _7: bool; + let mut _8: *mut T; let mut _9: *mut T; - let mut _10: *mut T; - let mut _12: *const T; + let mut _11: *const T; scope 5 { - debug len => _3; - let _7: std::ptr::NonNull<T>; + let _6: std::ptr::NonNull<T>; scope 6 { - debug ptr => _7; - let _11: *const T; + let _10: *const T; scope 7 { - debug end_or_len => _11; } scope 11 (inlined without_provenance::<T>) { - debug addr => _3; } scope 12 (inlined NonNull::<T>::as_ptr) { - debug self => _7; } scope 13 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { - debug self => _9; - debug count => _3; } } scope 8 (inlined <NonNull<[T]> as From<&[T]>>::from) { - debug reference => _1; let mut _4: *const [T]; } scope 9 (inlined NonNull::<[T]>::cast::<T>) { - debug self => _5; - let mut _6: *const T; + let mut _5: *const T; scope 10 (inlined NonNull::<[T]>::as_ptr) { - debug self => _5; } } } } } scope 14 (inlined <std::slice::Iter<'_, T> as Iterator>::rev) { - debug self => _13; scope 15 (inlined Rev::<std::slice::Iter<'_, T>>::new) { - debug iter => _13; } } scope 16 (inlined <Rev<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) { - debug self => _14; } bb0: { - StorageLive(_13); + StorageLive(_12); StorageLive(_3); - StorageLive(_7); - StorageLive(_4); StorageLive(_6); - _3 = Len((*_1)); + StorageLive(_4); StorageLive(_5); + _3 = Len((*_1)); _4 = &raw const (*_1); - _5 = NonNull::<[T]> { pointer: _4 }; - _6 = _4 as *const T (PtrToPtr); - _7 = NonNull::<T> { pointer: _6 }; - StorageDead(_5); - StorageLive(_11); - StorageLive(_8); - _8 = const <T as std::mem::SizedTypeProperties>::IS_ZST; - switchInt(move _8) -> [0: bb1, otherwise: bb2]; + _5 = _4 as *const T (PtrToPtr); + _6 = NonNull::<T> { pointer: _5 }; + StorageLive(_10); + StorageLive(_7); + _7 = const <T as std::mem::SizedTypeProperties>::IS_ZST; + switchInt(move _7) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_10); StorageLive(_9); - _9 = _4 as *mut T (PtrToPtr); - _10 = Offset(_9, _3); + StorageLive(_8); + _8 = _4 as *mut T (PtrToPtr); + _9 = Offset(_8, _3); + StorageDead(_8); + _10 = move _9 as *const T (PointerCoercion(MutToConstPointer)); StorageDead(_9); - _11 = move _10 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_10); goto -> bb3; } bb2: { - _11 = _3 as *const T (Transmute); + _10 = _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_8); - StorageLive(_12); - _12 = _11; - _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_12); + StorageDead(_7); + StorageLive(_11); + _11 = _10; + _12 = std::slice::Iter::<'_, T> { ptr: _6, end_or_len: move _11, _marker: const ZeroSized: PhantomData<&T> }; StorageDead(_11); - StorageDead(_6); + StorageDead(_10); + StorageDead(_5); StorageDead(_4); - StorageDead(_7); + StorageDead(_6); StorageDead(_3); - _14 = Rev::<std::slice::Iter<'_, T>> { iter: _13 }; - StorageDead(_13); - StorageLive(_15); - _15 = _14; + _13 = Rev::<std::slice::Iter<'_, T>> { iter: _12 }; + StorageDead(_12); + StorageLive(_14); + _14 = _13; goto -> bb4; } bb4: { - StorageLive(_18); - _16 = &mut _15; - StorageLive(_17); - _17 = &mut (_15.0: std::slice::Iter<'_, T>); - _18 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _17) -> [return: bb5, unwind unreachable]; + StorageLive(_16); + StorageLive(_15); + _15 = &mut (_14.0: std::slice::Iter<'_, T>); + _16 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _15) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_17); - _19 = discriminant(_18); - switchInt(move _19) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_15); + _17 = discriminant(_16); + switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_18); - StorageDead(_15); + StorageDead(_16); + StorageDead(_14); drop(_2) -> [return: bb7, unwind unreachable]; } @@ -156,18 +134,18 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _20 = ((_18 as Some).0: &T); - StorageLive(_21); - _21 = &_2; - StorageLive(_22); - _22 = (_20,); - _23 = <impl Fn(&T) as Fn<(&T,)>>::call(move _21, move _22) -> [return: bb9, unwind unreachable]; + _18 = ((_16 as Some).0: &T); + StorageLive(_19); + _19 = &_2; + StorageLive(_20); + _20 = (_18,); + _21 = <impl Fn(&T) as Fn<(&T,)>>::call(move _19, move _20) -> [return: bb9, unwind unreachable]; } bb9: { - StorageDead(_22); - StorageDead(_21); - StorageDead(_18); + StorageDead(_20); + StorageDead(_19); + StorageDead(_16); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir index 1873d452f34..c7cd37afd86 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir @@ -4,150 +4,128 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _13: std::slice::Iter<'_, T>; + let mut _12: std::slice::Iter<'_, T>; + let mut _13: std::iter::Rev<std::slice::Iter<'_, T>>; let mut _14: std::iter::Rev<std::slice::Iter<'_, T>>; - let mut _15: std::iter::Rev<std::slice::Iter<'_, T>>; - let mut _16: &mut std::iter::Rev<std::slice::Iter<'_, T>>; - let mut _18: std::option::Option<&T>; - let mut _19: isize; - let mut _21: &impl Fn(&T); - let mut _22: (&T,); - let _23: (); + let mut _16: std::option::Option<&T>; + let mut _17: isize; + let mut _19: &impl Fn(&T); + let mut _20: (&T,); + let _21: (); scope 1 { - debug iter => _15; - let _20: &T; + debug iter => _14; + let _18: &T; scope 2 { - debug x => _20; + debug x => _18; } scope 17 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) { - debug self => _16; - let mut _17: &mut std::slice::Iter<'_, T>; + let mut _15: &mut std::slice::Iter<'_, T>; } } scope 3 (inlined core::slice::<impl [T]>::iter) { - debug self => _1; scope 4 (inlined std::slice::Iter::<'_, T>::new) { - debug slice => _1; let _3: usize; - let mut _5: std::ptr::NonNull<[T]>; - let mut _8: bool; + let mut _7: bool; + let mut _8: *mut T; let mut _9: *mut T; - let mut _10: *mut T; - let mut _12: *const T; + let mut _11: *const T; scope 5 { - debug len => _3; - let _7: std::ptr::NonNull<T>; + let _6: std::ptr::NonNull<T>; scope 6 { - debug ptr => _7; - let _11: *const T; + let _10: *const T; scope 7 { - debug end_or_len => _11; } scope 11 (inlined without_provenance::<T>) { - debug addr => _3; } scope 12 (inlined NonNull::<T>::as_ptr) { - debug self => _7; } scope 13 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { - debug self => _9; - debug count => _3; } } scope 8 (inlined <NonNull<[T]> as From<&[T]>>::from) { - debug reference => _1; let mut _4: *const [T]; } scope 9 (inlined NonNull::<[T]>::cast::<T>) { - debug self => _5; - let mut _6: *const T; + let mut _5: *const T; scope 10 (inlined NonNull::<[T]>::as_ptr) { - debug self => _5; } } } } } scope 14 (inlined <std::slice::Iter<'_, T> as Iterator>::rev) { - debug self => _13; scope 15 (inlined Rev::<std::slice::Iter<'_, T>>::new) { - debug iter => _13; } } scope 16 (inlined <Rev<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) { - debug self => _14; } bb0: { - StorageLive(_13); + StorageLive(_12); StorageLive(_3); - StorageLive(_7); - StorageLive(_4); StorageLive(_6); - _3 = Len((*_1)); + StorageLive(_4); StorageLive(_5); + _3 = Len((*_1)); _4 = &raw const (*_1); - _5 = NonNull::<[T]> { pointer: _4 }; - _6 = _4 as *const T (PtrToPtr); - _7 = NonNull::<T> { pointer: _6 }; - StorageDead(_5); - StorageLive(_11); - StorageLive(_8); - _8 = const <T as std::mem::SizedTypeProperties>::IS_ZST; - switchInt(move _8) -> [0: bb1, otherwise: bb2]; + _5 = _4 as *const T (PtrToPtr); + _6 = NonNull::<T> { pointer: _5 }; + StorageLive(_10); + StorageLive(_7); + _7 = const <T as std::mem::SizedTypeProperties>::IS_ZST; + switchInt(move _7) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_10); StorageLive(_9); - _9 = _4 as *mut T (PtrToPtr); - _10 = Offset(_9, _3); + StorageLive(_8); + _8 = _4 as *mut T (PtrToPtr); + _9 = Offset(_8, _3); + StorageDead(_8); + _10 = move _9 as *const T (PointerCoercion(MutToConstPointer)); StorageDead(_9); - _11 = move _10 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_10); goto -> bb3; } bb2: { - _11 = _3 as *const T (Transmute); + _10 = _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_8); - StorageLive(_12); - _12 = _11; - _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_12); + StorageDead(_7); + StorageLive(_11); + _11 = _10; + _12 = std::slice::Iter::<'_, T> { ptr: _6, end_or_len: move _11, _marker: const ZeroSized: PhantomData<&T> }; StorageDead(_11); - StorageDead(_6); + StorageDead(_10); + StorageDead(_5); StorageDead(_4); - StorageDead(_7); + StorageDead(_6); StorageDead(_3); - _14 = Rev::<std::slice::Iter<'_, T>> { iter: _13 }; - StorageDead(_13); - StorageLive(_15); - _15 = _14; + _13 = Rev::<std::slice::Iter<'_, T>> { iter: _12 }; + StorageDead(_12); + StorageLive(_14); + _14 = _13; goto -> bb4; } bb4: { - StorageLive(_18); - _16 = &mut _15; - StorageLive(_17); - _17 = &mut (_15.0: std::slice::Iter<'_, T>); - _18 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _17) -> [return: bb5, unwind: bb11]; + StorageLive(_16); + StorageLive(_15); + _15 = &mut (_14.0: std::slice::Iter<'_, T>); + _16 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _15) -> [return: bb5, unwind: bb11]; } bb5: { - StorageDead(_17); - _19 = discriminant(_18); - switchInt(move _19) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_15); + _17 = discriminant(_16); + switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_18); - StorageDead(_15); + StorageDead(_16); + StorageDead(_14); drop(_2) -> [return: bb7, unwind continue]; } @@ -156,18 +134,18 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _20 = ((_18 as Some).0: &T); - StorageLive(_21); - _21 = &_2; - StorageLive(_22); - _22 = (_20,); - _23 = <impl Fn(&T) as Fn<(&T,)>>::call(move _21, move _22) -> [return: bb9, unwind: bb11]; + _18 = ((_16 as Some).0: &T); + StorageLive(_19); + _19 = &_2; + StorageLive(_20); + _20 = (_18,); + _21 = <impl Fn(&T) as Fn<(&T,)>>::call(move _19, move _20) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_22); - StorageDead(_21); - StorageDead(_18); + StorageDead(_20); + StorageDead(_19); + StorageDead(_16); goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/spans.rs b/tests/mir-opt/pre-codegen/spans.rs index 4d3dc7ec3e5..940089d2d49 100644 --- a/tests/mir-opt/pre-codegen/spans.rs +++ b/tests/mir-opt/pre-codegen/spans.rs @@ -2,7 +2,7 @@ // Test that the comments we emit in MIR opts are accurate. // // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -//@ compile-flags: -Zmir-include-spans +//@ compile-flags: -Zmir-include-spans -C debuginfo=full #![crate_type = "lib"] diff --git a/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-abort.diff b/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-abort.diff index 22a1a882b41..0c73602bec8 100644 --- a/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-abort.diff +++ b/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-abort.diff @@ -7,7 +7,6 @@ let _2: (); let mut _3: T; scope 1 (inlined std::mem::drop::<T>) { - debug _x => _3; } bb0: { diff --git a/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-unwind.diff b/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-unwind.diff index 56070e6102f..59cce9fbcdd 100644 --- a/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-unwind.diff +++ b/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-unwind.diff @@ -7,7 +7,6 @@ let _2: (); let mut _3: T; scope 1 (inlined std::mem::drop::<T>) { - debug _x => _3; } bb0: { diff --git a/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-abort.diff b/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-abort.diff index 105bedd0ac8..428b366b5a6 100644 --- a/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-abort.diff +++ b/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-abort.diff @@ -7,7 +7,6 @@ let _2: (); let mut _3: std::vec::Vec<bool>; scope 1 (inlined std::mem::drop::<Vec<bool>>) { - debug _x => _3; } bb0: { diff --git a/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-unwind.diff b/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-unwind.diff index c9790dc071d..445c1f82a96 100644 --- a/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-unwind.diff +++ b/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-unwind.diff @@ -7,7 +7,6 @@ let _2: (); let mut _3: std::vec::Vec<bool>; scope 1 (inlined std::mem::drop::<Vec<bool>>) { - debug _x => _3; } bb0: { diff --git a/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-abort.diff b/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-abort.diff index a48ac82ea7d..5afeb8620a1 100644 --- a/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-abort.diff +++ b/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-abort.diff @@ -7,7 +7,6 @@ let _2: (); let mut _3: bool; scope 1 (inlined std::mem::drop::<bool>) { - debug _x => _3; } bb0: { diff --git a/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-unwind.diff b/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-unwind.diff index a335e8853f3..b9919ddea56 100644 --- a/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-unwind.diff +++ b/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-unwind.diff @@ -7,7 +7,6 @@ let _2: (); let mut _3: bool; scope 1 (inlined std::mem::drop::<bool>) { - debug _x => _3; } bb0: { diff --git a/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-abort.diff b/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-abort.diff index 049b32f284d..b89432dd6d6 100644 --- a/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-abort.diff +++ b/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-abort.diff @@ -7,7 +7,6 @@ let _2: (); let mut _3: T; scope 1 (inlined std::mem::drop::<T>) { - debug _x => _3; } bb0: { diff --git a/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-unwind.diff b/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-unwind.diff index 1f7a6f9ad59..48d02605332 100644 --- a/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-unwind.diff +++ b/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-unwind.diff @@ -7,7 +7,6 @@ let _2: (); let mut _3: T; scope 1 (inlined std::mem::drop::<T>) { - debug _x => _3; } bb0: { diff --git a/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff b/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff index d0abebff214..8dd904c7d7b 100644 --- a/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff +++ b/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff @@ -5,54 +5,44 @@ debug x => _1; let mut _0: std::result::Result<i32, i32>; let mut _2: std::ops::ControlFlow<std::result::Result<std::convert::Infallible, i32>, i32>; - let mut _3: std::result::Result<i32, i32>; - let mut _4: isize; - let _5: std::result::Result<std::convert::Infallible, i32>; - let mut _6: std::result::Result<std::convert::Infallible, i32>; - let _7: i32; + let mut _3: isize; + let _4: std::result::Result<std::convert::Infallible, i32>; + let _5: i32; scope 1 { - debug residual => _5; + debug residual => _4; scope 2 { scope 8 (inlined #[track_caller] <Result<i32, i32> as FromResidual<Result<Infallible, i32>>>::from_residual) { - debug residual => _6; - let _12: i32; + let _10: i32; scope 9 { - debug e => _12; scope 10 (inlined <i32 as From<i32>>::from) { - debug t => _12; } } } } } scope 3 { - debug val => _7; + debug val => _5; scope 4 { } } scope 5 (inlined <Result<i32, i32> as Try>::branch) { - debug self => _3; - let mut _8: isize; - let _9: i32; - let _10: i32; - let mut _11: std::result::Result<std::convert::Infallible, i32>; + let mut _6: isize; + let _7: i32; + let _8: i32; + let mut _9: std::result::Result<std::convert::Infallible, i32>; scope 6 { - debug v => _9; } scope 7 { - debug e => _10; } } bb0: { StorageLive(_2); - StorageLive(_3); - _3 = _1; + StorageLive(_6); + StorageLive(_7); StorageLive(_8); - StorageLive(_9); - StorageLive(_10); - _8 = discriminant(_1); - switchInt(move _8) -> [0: bb6, 1: bb5, otherwise: bb1]; + _6 = discriminant(_1); + switchInt(move _6) -> [0: bb6, 1: bb5, otherwise: bb1]; } bb1: { @@ -60,55 +50,50 @@ } bb2: { - _7 = ((_2 as Continue).0: i32); - _0 = Result::<i32, i32>::Ok(_7); + _5 = ((_2 as Continue).0: i32); + _0 = Result::<i32, i32>::Ok(_5); StorageDead(_2); return; } bb3: { - _5 = ((_2 as Break).0: std::result::Result<std::convert::Infallible, i32>); - StorageLive(_6); - _6 = _5; - _12 = ((_5 as Err).0: i32); - _0 = Result::<i32, i32>::Err(_12); - StorageDead(_6); + _4 = ((_2 as Break).0: std::result::Result<std::convert::Infallible, i32>); + _10 = ((_4 as Err).0: i32); + _0 = Result::<i32, i32>::Err(_10); StorageDead(_2); return; } bb4: { - StorageDead(_10); - StorageDead(_9); StorageDead(_8); - StorageDead(_3); - _4 = discriminant(_2); -- switchInt(move _4) -> [0: bb2, 1: bb3, otherwise: bb1]; + StorageDead(_7); + StorageDead(_6); + _3 = discriminant(_2); +- switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; + goto -> bb2; } bb5: { - _10 = ((_1 as Err).0: i32); - StorageLive(_11); - _11 = Result::<Infallible, i32>::Err(_10); - _2 = ControlFlow::<Result<Infallible, i32>, i32>::Break(move _11); - StorageDead(_11); + _8 = ((_1 as Err).0: i32); + StorageLive(_9); + _9 = Result::<Infallible, i32>::Err(_8); + _2 = ControlFlow::<Result<Infallible, i32>, i32>::Break(move _9); + StorageDead(_9); - goto -> bb4; + goto -> bb7; } bb6: { - _9 = ((_1 as Ok).0: i32); - _2 = ControlFlow::<Result<Infallible, i32>, i32>::Continue(_9); + _7 = ((_1 as Ok).0: i32); + _2 = ControlFlow::<Result<Infallible, i32>, i32>::Continue(_7); goto -> bb4; + } + + bb7: { -+ StorageDead(_10); -+ StorageDead(_9); + StorageDead(_8); -+ StorageDead(_3); -+ _4 = discriminant(_2); ++ StorageDead(_7); ++ StorageDead(_6); ++ _3 = discriminant(_2); + goto -> bb3; } } diff --git a/tests/run-make/static-pie/test-aslr.rs b/tests/run-make/static-pie/test-aslr.rs index 96b17af46df..8d8e7586323 100644 --- a/tests/run-make/static-pie/test-aslr.rs +++ b/tests/run-make/static-pie/test-aslr.rs @@ -17,7 +17,7 @@ fn main() { let arg0 = args.next().unwrap(); match args.next() { Some(s) if s.eq("--report") => { - println!("main = {:#?}", &main as *const _); + println!("main = {:#?}", main as fn() as usize); } Some(s) if s.eq("--test-no-aslr") => { let cnt = run_self(&arg0); diff --git a/tests/rustdoc-gui/copy-path.goml b/tests/rustdoc-gui/copy-path.goml new file mode 100644 index 00000000000..dc05b96f7ae --- /dev/null +++ b/tests/rustdoc-gui/copy-path.goml @@ -0,0 +1,15 @@ +// Checks that the "copy path" button is not triggering JS error and its display +// isn't broken. +go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" + +// First we store the size of the button before we click on it. +store-size: ("#copy-path", {"width": width, "height": height}) +click: "#copy-path" +// We wait for the new text to appear. +wait-for: "#copy-path.clicked" +// We check that the size didn't change. +assert-size: ("#copy-path.clicked", {"width": |width|, "height": |height|}) +// We wait for the button to turn back to its original state. +wait-for: "#copy-path:not(.clicked)" +// We check that the size is still the same. +assert-size: ("#copy-path:not(.clicked)", {"width": |width|, "height": |height|}) diff --git a/tests/rustdoc-js-std/alias-1.js b/tests/rustdoc-js-std/alias-1.js index b27b3da2179..c31d1a3b1ad 100644 --- a/tests/rustdoc-js-std/alias-1.js +++ b/tests/rustdoc-js-std/alias-1.js @@ -1,6 +1,10 @@ const EXPECTED = { 'query': '&', 'others': [ - { 'path': 'std', 'name': 'reference' }, + { + 'path': 'std', + 'name': 'reference', + 'desc': "References, <code>&T</code> and <code>&mut T</code>.", + }, ], }; diff --git a/tests/rustdoc-js-std/vec-new.js b/tests/rustdoc-js-std/vec-new.js index 9823a417a5d..bb122ff4398 100644 --- a/tests/rustdoc-js-std/vec-new.js +++ b/tests/rustdoc-js-std/vec-new.js @@ -3,17 +3,47 @@ const EXPECTED = [ 'query': 'Vec::new', 'others': [ { 'path': 'std::vec::Vec', 'name': 'new' }, - { 'path': 'alloc::vec::Vec', 'name': 'new' }, { 'path': 'std::vec::Vec', 'name': 'new_in' }, - { 'path': 'alloc::vec::Vec', 'name': 'new_in' }, + ], + }, + { + 'query': 'prelude::vec', + 'others': [ + { 'path': 'std::prelude::rust_2024', 'name': 'Vec' }, ], }, { 'query': 'Vec new', 'others': [ { 'path': 'std::vec::Vec', 'name': 'new' }, - { 'path': 'alloc::vec::Vec', 'name': 'new' }, { 'path': 'std::vec::Vec', 'name': 'new_in' }, + ], + }, + { + 'query': 'std::Vec::new', + 'others': [ + { 'path': 'std::vec::Vec', 'name': 'new' }, + { 'path': 'std::vec::Vec', 'name': 'new_in' }, + ], + }, + { + 'query': 'std Vec new', + 'others': [ + { 'path': 'std::vec::Vec', 'name': 'new' }, + { 'path': 'std::vec::Vec', 'name': 'new_in' }, + ], + }, + { + 'query': 'alloc::Vec::new', + 'others': [ + { 'path': 'alloc::vec::Vec', 'name': 'new' }, + { 'path': 'alloc::vec::Vec', 'name': 'new_in' }, + ], + }, + { + 'query': 'alloc Vec new', + 'others': [ + { 'path': 'alloc::vec::Vec', 'name': 'new' }, { 'path': 'alloc::vec::Vec', 'name': 'new_in' }, ], }, diff --git a/tests/rustdoc-js/auxiliary/macro-in-module.rs b/tests/rustdoc-js/auxiliary/macro-in-module.rs new file mode 100644 index 00000000000..b3fbccaf3f5 --- /dev/null +++ b/tests/rustdoc-js/auxiliary/macro-in-module.rs @@ -0,0 +1,7 @@ +#[macro_use] +mod hidden_macro_module { + #[macro_export] + macro_rules! vec { + () => {}; + } +} diff --git a/tests/rustdoc-js/reexport-dedup-macro.js b/tests/rustdoc-js/reexport-dedup-macro.js new file mode 100644 index 00000000000..bc42fc3a8d5 --- /dev/null +++ b/tests/rustdoc-js/reexport-dedup-macro.js @@ -0,0 +1,11 @@ +// exact-check + +const EXPECTED = [ + { + 'query': 'vec', + 'others': [ + { 'path': 'foo', 'name': 'vec', 'exactPath': 'macro_in_module' }, + { 'path': 'foo', 'name': 'myspecialvec', 'exactPath': 'foo' }, + ], + }, +]; diff --git a/tests/rustdoc-js/reexport-dedup-macro.rs b/tests/rustdoc-js/reexport-dedup-macro.rs new file mode 100644 index 00000000000..3d18da3951c --- /dev/null +++ b/tests/rustdoc-js/reexport-dedup-macro.rs @@ -0,0 +1,15 @@ +//@ aux-crate: macro_in_module=macro-in-module.rs +#![crate_name="foo"] +extern crate macro_in_module; + +// Test case based on the relationship between alloc and std. +#[doc(inline)] +pub use macro_in_module::vec; + +#[macro_use] +mod hidden_macro_module { + #[macro_export] + macro_rules! myspecialvec { + () => {}; + } +} diff --git a/tests/rustdoc-js/reexport-dedup-method.js b/tests/rustdoc-js/reexport-dedup-method.js new file mode 100644 index 00000000000..5d1497df4d5 --- /dev/null +++ b/tests/rustdoc-js/reexport-dedup-method.js @@ -0,0 +1,16 @@ +// exact-check + +const EXPECTED = [ + { + 'query': 'Subscriber dostuff', + 'others': [ + { 'path': 'foo::fmt::Subscriber', 'name': 'dostuff' }, + ], + }, + { + 'query': 'AnotherOne dostuff', + 'others': [ + { 'path': 'foo::AnotherOne', 'name': 'dostuff' }, + ], + }, +]; diff --git a/tests/rustdoc-js/reexport-dedup-method.rs b/tests/rustdoc-js/reexport-dedup-method.rs new file mode 100644 index 00000000000..5dbd66e9c8e --- /dev/null +++ b/tests/rustdoc-js/reexport-dedup-method.rs @@ -0,0 +1,18 @@ +// This test enforces that the (renamed) reexports are present in the search results. +#![crate_name="foo"] + +pub mod fmt { + pub struct Subscriber; + impl Subscriber { + pub fn dostuff(&self) {} + } +} +mod foo { + pub struct AnotherOne; + impl AnotherOne { + pub fn dostuff(&self) {} + } +} + +pub use foo::AnotherOne; +pub use fmt::Subscriber; diff --git a/tests/rustdoc-js/reexport-dedup.js b/tests/rustdoc-js/reexport-dedup.js new file mode 100644 index 00000000000..979619c50cd --- /dev/null +++ b/tests/rustdoc-js/reexport-dedup.js @@ -0,0 +1,22 @@ +// exact-check + +const EXPECTED = [ + { + 'query': 'Subscriber', + 'others': [ + { 'path': 'foo', 'name': 'Subscriber' }, + ], + }, + { + 'query': 'fmt Subscriber', + 'others': [ + { 'path': 'foo::fmt', 'name': 'Subscriber' }, + ], + }, + { + 'query': 'AnotherOne', + 'others': [ + { 'path': 'foo', 'name': 'AnotherOne' }, + ], + }, +]; diff --git a/tests/rustdoc-js/reexport-dedup.rs b/tests/rustdoc-js/reexport-dedup.rs new file mode 100644 index 00000000000..40aea963303 --- /dev/null +++ b/tests/rustdoc-js/reexport-dedup.rs @@ -0,0 +1,12 @@ +// This test enforces that the (renamed) reexports are present in the search results. +#![crate_name="foo"] + +pub mod fmt { + pub struct Subscriber; +} +mod foo { + pub struct AnotherOne; +} + +pub use foo::AnotherOne; +pub use fmt::Subscriber; diff --git a/tests/rustdoc-js/reexport.rs b/tests/rustdoc-js/reexport.rs index d69b2901edd..d51b7fb369c 100644 --- a/tests/rustdoc-js/reexport.rs +++ b/tests/rustdoc-js/reexport.rs @@ -1,4 +1,6 @@ // This test enforces that the (renamed) reexports are present in the search results. +// This is a DWIM case, since renaming the export probably means the intent is also different. +// For the de-duplication case of exactly the same name, see reexport-dedup pub mod fmt { pub struct Subscriber; diff --git a/tests/ui/abi/riscv-discoverability-guidance.rs b/tests/ui/abi/riscv-discoverability-guidance.rs index a09a0edba85..1b189d907ba 100644 --- a/tests/ui/abi/riscv-discoverability-guidance.rs +++ b/tests/ui/abi/riscv-discoverability-guidance.rs @@ -2,9 +2,9 @@ //@ revisions: riscv32 riscv64 // //@ [riscv32] needs-llvm-components: riscv -//@ [riscv32] compile-flags: --target=riscv32i-unknown-none-elf -C target-feature=-fast-unaligned-access --crate-type=rlib +//@ [riscv32] compile-flags: --target=riscv32i-unknown-none-elf -C target-feature=-unaligned-scalar-mem --crate-type=rlib //@ [riscv64] needs-llvm-components: riscv -//@ [riscv64] compile-flags: --target=riscv64gc-unknown-none-elf -C target-feature=-fast-unaligned-access --crate-type=rlib +//@ [riscv64] compile-flags: --target=riscv64gc-unknown-none-elf -C target-feature=-unaligned-scalar-mem --crate-type=rlib #![no_core] #![feature( no_core, diff --git a/tests/ui/abi/segfault-no-out-of-stack.rs b/tests/ui/abi/segfault-no-out-of-stack.rs index fb1f8303f9f..113c82c30e9 100644 --- a/tests/ui/abi/segfault-no-out-of-stack.rs +++ b/tests/ui/abi/segfault-no-out-of-stack.rs @@ -1,31 +1,29 @@ //@ run-pass - -#![allow(unused_imports)] //@ ignore-wasm32 can't run commands //@ ignore-sgx no processes //@ ignore-fuchsia must translate zircon signal to SIGSEGV/SIGBUS, FIXME (#58590) -#![feature(rustc_private)] -extern crate libc; +#![feature(rustc_private)] use std::env; +use std::ffi::c_char; use std::process::{Command, ExitStatus}; #[link(name = "rust_test_helpers", kind = "static")] extern "C" { - fn rust_get_null_ptr() -> *mut ::libc::c_char; + fn rust_get_null_ptr() -> *mut c_char; } #[cfg(unix)] -fn check_status(status: std::process::ExitStatus) { - use libc; +fn check_status(status: ExitStatus) { + extern crate libc; use std::os::unix::process::ExitStatusExt; assert!(status.signal() == Some(libc::SIGSEGV) || status.signal() == Some(libc::SIGBUS)); } #[cfg(not(unix))] -fn check_status(status: std::process::ExitStatus) { +fn check_status(status: ExitStatus) { assert!(!status.success()); } diff --git a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-and-child-processes.rs b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-and-child-processes.rs index f96bd634876..9d1bd9f9607 100644 --- a/tests/ui/attributes/unix_sigpipe/unix_sigpipe-and-child-processes.rs +++ b/tests/ui/attributes/unix_sigpipe/unix_sigpipe-and-child-processes.rs @@ -11,10 +11,8 @@ // processes with and without the attribute. Search for // `unix_sigpipe_attr_specified()` in the code base to learn more. -#![feature(rustc_private)] #![cfg_attr(any(sig_dfl, sig_ign, inherit), feature(unix_sigpipe))] -extern crate libc; extern crate sigpipe_utils; use sigpipe_utils::*; diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index af3ef92fdd5..dceb6f4c030 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -154,7 +154,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_feature = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512er`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512pf`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `bf16`, `bmi1`, `bmi2`, `bti`, `bulk-memory`, `c`, `cache`, `cmpxchg16b`, `crc`, `crt-static`, `d`, `d32`, `dit`, `doloop`, `dotprod`, `dpb`, `dpb2`, `dsp`, `dsp1e2`, `dspe60`, `e`, `e1`, `e2`, `edsp`, `elrw`, `ermsb`, `exception-handling`, `f`, `f16c`, `f32mm`, `f64mm`, `fast-unaligned-access`, `fcma`, `fdivdu`, `fhm`, `flagm`, `float1e2`, `float1e3`, `float3e4`, `float7e60`, `floate1`, `fma`, `fp-armv8`, `fp16`, `fp64`, `fpuv2_df`, `fpuv2_sf`, `fpuv3_df`, `fpuv3_hf`, `fpuv3_hi`, `fpuv3_sf`, `frecipe`, `frintts`, `fxsr`, `gfni`, `hard-float`, `hard-float-abi`, `hard-tp`, `high-registers`, `hvx`, `hvx-length128b`, `hwdiv`, `i8mm`, `jsconv`, `lahfsahf`, `lasx`, `lbt`, `lor`, `lse`, `lsx`, `lvz`, `lzcnt`, `m`, `mclass`, `movbe`, `mp`, `mp1e2`, `msa`, `mte`, `multivalue`, `mutable-globals`, `neon`, `nontrapping-fptoint`, `nvic`, `paca`, `pacg`, `pan`, `pclmulqdq`, `pmuv3`, `popcnt`, `power10-vector`, `power8-altivec`, `power8-vector`, `power9-altivec`, `power9-vector`, `prfchw`, `rand`, `ras`, `rclass`, `rcpc`, `rcpc2`, `rdm`, `rdrand`, `rdseed`, `reference-types`, `relax`, `relaxed-simd`, `rtm`, `sb`, `sha`, `sha2`, `sha3`, `sign-ext`, `simd128`, `sm4`, `spe`, `ssbs`, `sse`, `sse2`, `sse3`, `sse4.1`, `sse4.2`, `sse4a`, `ssse3`, `sve`, `sve2`, `sve2-aes`, `sve2-bitperm`, `sve2-sha3`, `sve2-sm4`, `tbm`, `thumb-mode`, `thumb2`, `tme`, `trust`, `trustzone`, `ual`, `v`, `v5te`, `v6`, `v6k`, `v6t2`, `v7`, `v8`, `v8.1a`, `v8.2a`, `v8.3a`, `v8.4a`, `v8.5a`, `v8.6a`, `v8.7a`, `vaes`, `vdsp2e60f`, `vdspv1`, `vdspv2`, `vfp2`, `vfp3`, `vfp4`, `vh`, `virt`, `virtualization`, `vpclmulqdq`, `vsx`, `xsave`, `xsavec`, `xsaveopt`, `xsaves`, `zba`, `zbb`, `zbc`, `zbkb`, `zbkc`, `zbkx`, `zbs`, `zdinx`, `zfh`, `zfhmin`, `zfinx`, `zhinx`, `zhinxmin`, `zk`, `zkn`, `zknd`, `zkne`, `zknh`, `zkr`, `zks`, `zksed`, `zksh`, `zkt` + = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512er`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512pf`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `bf16`, `bmi1`, `bmi2`, `bti`, `bulk-memory`, `c`, `cache`, `cmpxchg16b`, `crc`, `crt-static`, `d`, `d32`, `dit`, `doloop`, `dotprod`, `dpb`, `dpb2`, `dsp`, `dsp1e2`, `dspe60`, `e`, `e1`, `e2`, `edsp`, `elrw`, `ermsb`, `exception-handling`, `f`, `f16c`, `f32mm`, `f64mm`, `fcma`, `fdivdu`, `fhm`, `flagm`, `float1e2`, `float1e3`, `float3e4`, `float7e60`, `floate1`, `fma`, `fp-armv8`, `fp16`, `fp64`, `fpuv2_df`, `fpuv2_sf`, `fpuv3_df`, `fpuv3_hf`, `fpuv3_hi`, `fpuv3_sf`, `frecipe`, `frintts`, `fxsr`, `gfni`, `hard-float`, `hard-float-abi`, `hard-tp`, `high-registers`, `hvx`, `hvx-length128b`, `hwdiv`, `i8mm`, `jsconv`, `lahfsahf`, `lasx`, `lbt`, `lor`, `lse`, `lsx`, `lvz`, `lzcnt`, `m`, `mclass`, `movbe`, `mp`, `mp1e2`, `msa`, `mte`, `multivalue`, `mutable-globals`, `neon`, `nontrapping-fptoint`, `nvic`, `paca`, `pacg`, `pan`, `pclmulqdq`, `pmuv3`, `popcnt`, `power10-vector`, `power8-altivec`, `power8-vector`, `power9-altivec`, `power9-vector`, `prfchw`, `rand`, `ras`, `rclass`, `rcpc`, `rcpc2`, `rdm`, `rdrand`, `rdseed`, `reference-types`, `relax`, `relaxed-simd`, `rtm`, `sb`, `sha`, `sha2`, `sha3`, `sign-ext`, `simd128`, `sm4`, `spe`, `ssbs`, `sse`, `sse2`, `sse3`, `sse4.1`, `sse4.2`, `sse4a`, `ssse3`, `sve`, `sve2`, `sve2-aes`, `sve2-bitperm`, `sve2-sha3`, `sve2-sm4`, `tbm`, `thumb-mode`, `thumb2`, `tme`, `trust`, `trustzone`, `ual`, `unaligned-scalar-mem`, `v`, `v5te`, `v6`, `v6k`, `v6t2`, `v7`, `v8`, `v8.1a`, `v8.2a`, `v8.3a`, `v8.4a`, `v8.5a`, `v8.6a`, `v8.7a`, `vaes`, `vdsp2e60f`, `vdspv1`, `vdspv2`, `vfp2`, `vfp3`, `vfp4`, `vh`, `virt`, `virtualization`, `vpclmulqdq`, `vsx`, `xsave`, `xsavec`, `xsaveopt`, `xsaves`, `zba`, `zbb`, `zbc`, `zbkb`, `zbkc`, `zbkx`, `zbs`, `zdinx`, `zfh`, `zfhmin`, `zfinx`, `zhinx`, `zhinxmin`, `zk`, `zkn`, `zknd`, `zkne`, `zknh`, `zkr`, `zks`, `zksed`, `zksh`, `zkt` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs index 6ede6f5339c..0f70862b5d9 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs @@ -2,10 +2,15 @@ #![feature(const_heap)] #![feature(const_mut_refs)] +// Strip out raw byte dumps to make comparison platform-independent: +//@ normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" +//@ normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" +//@ normalize-stderr-test "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP" + use std::intrinsics; const _X: &'static u8 = unsafe { - //~^ error: dangling pointer in final value of constant + //~^ error: it is undefined behavior to use this value let ptr = intrinsics::const_allocate(4, 4); intrinsics::const_deallocate(ptr, 4, 4); &*ptr diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr index 59f5f79a95f..a42c26c0a8d 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr @@ -1,14 +1,19 @@ -error: encountered dangling pointer in final value of constant - --> $DIR/dealloc_intrinsic_dangling.rs:7:1 +error[E0080]: it is undefined behavior to use this value + --> $DIR/dealloc_intrinsic_dangling.rs:12:1 | LL | const _X: &'static u8 = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (use-after-free) + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } error[E0080]: evaluation of constant value failed - --> $DIR/dealloc_intrinsic_dangling.rs:18:5 + --> $DIR/dealloc_intrinsic_dangling.rs:23:5 | LL | *reference - | ^^^^^^^^^^ memory access failed: ALLOC0 has been freed, so this pointer is dangling + | ^^^^^^^^^^ memory access failed: ALLOC1 has been freed, so this pointer is dangling error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs index f3f0e1446fc..b86846af988 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs @@ -33,8 +33,8 @@ const fn helper_dangling() -> Option<&'static mut i32> { unsafe { // Undefined behaviour (dangling pointer), who doesn't love tests like this. Some(&mut *(&mut 42 as *mut i32)) } } -const DANGLING: Option<&mut i32> = helper_dangling(); //~ ERROR encountered dangling pointer -static DANGLING_STATIC: Option<&mut i32> = helper_dangling(); //~ ERROR encountered dangling pointer +const DANGLING: Option<&mut i32> = helper_dangling(); //~ ERROR it is undefined behavior to use this value +static DANGLING_STATIC: Option<&mut i32> = helper_dangling(); //~ ERROR it is undefined behavior to use this value // These are fine! Just statics pointing to mutable statics, nothing fundamentally wrong with this. static MUT_STATIC: Option<&mut i32> = helper(); diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr index 5923683a1c9..ea9dccf0173 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr @@ -31,17 +31,27 @@ LL | static INT2PTR_STATIC: Option<&mut i32> = helper_int2ptr(); HEX_DUMP } -error: encountered dangling pointer in final value of constant +error[E0080]: it is undefined behavior to use this value --> $DIR/mut_ref_in_final_dynamic_check.rs:36:1 | LL | const DANGLING: Option<&mut i32> = helper_dangling(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0: encountered a dangling reference (use-after-free) + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } -error: encountered dangling pointer in final value of static +error[E0080]: it is undefined behavior to use this value --> $DIR/mut_ref_in_final_dynamic_check.rs:37:1 | LL | static DANGLING_STATIC: Option<&mut i32> = helper_dangling(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Some)>.0: encountered a dangling reference (use-after-free) + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } error: aborting due to 5 previous errors diff --git a/tests/ui/consts/dangling-alloc-id-ice.rs b/tests/ui/consts/dangling-alloc-id-ice.rs index d9f458f3770..76d6f33baf3 100644 --- a/tests/ui/consts/dangling-alloc-id-ice.rs +++ b/tests/ui/consts/dangling-alloc-id-ice.rs @@ -1,4 +1,8 @@ // https://github.com/rust-lang/rust/issues/55223 +// Strip out raw byte dumps to make comparison platform-independent: +//@ normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" +//@ normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" +//@ normalize-stderr-test "HEX_DUMP\s*\n\s*HEX_DUMP" -> "HEX_DUMP" union Foo<'a> { y: &'a (), @@ -6,7 +10,7 @@ union Foo<'a> { } const FOO: &() = { -//~^ ERROR encountered dangling pointer in final value of constant + //~^ ERROR it is undefined behavior to use this value let y = (); unsafe { Foo { y: &y }.long_live_the_unit } }; diff --git a/tests/ui/consts/dangling-alloc-id-ice.stderr b/tests/ui/consts/dangling-alloc-id-ice.stderr index 8322b18d692..881c0b162ed 100644 --- a/tests/ui/consts/dangling-alloc-id-ice.stderr +++ b/tests/ui/consts/dangling-alloc-id-ice.stderr @@ -1,8 +1,14 @@ -error: encountered dangling pointer in final value of constant - --> $DIR/dangling-alloc-id-ice.rs:8:1 +error[E0080]: it is undefined behavior to use this value + --> $DIR/dangling-alloc-id-ice.rs:12:1 | LL | const FOO: &() = { - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (use-after-free) + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/dangling_raw_ptr.rs b/tests/ui/consts/dangling_raw_ptr.rs index 0ab3643f121..e68a7c9dfe1 100644 --- a/tests/ui/consts/dangling_raw_ptr.rs +++ b/tests/ui/consts/dangling_raw_ptr.rs @@ -1,8 +1,29 @@ -const FOO: *const u32 = { //~ ERROR encountered dangling pointer in final value of constant +const FOO: *const u32 = { + //~^ ERROR encountered dangling pointer in final value of constant let x = 42; &x }; -fn main() { - let x = FOO; +union Union { + ptr: *const u32, } + +const BAR: Union = { + //~^ ERROR encountered dangling pointer in final value of constant + let x = 42; + Union { ptr: &x } +}; + +const BAZ: Union = { + //~^ ERROR encountered dangling pointer in final value of constant + let x = 42_u32; + Union { ptr: &(&x as *const u32) as *const *const u32 as _ } +}; + +const FOOMP: *const u32 = { + //~^ ERROR encountered dangling pointer in final value of constant + let x = 42_u32; + &(&x as *const u32) as *const *const u32 as _ +}; + +fn main() {} diff --git a/tests/ui/consts/dangling_raw_ptr.stderr b/tests/ui/consts/dangling_raw_ptr.stderr index 28a58ae7be2..5cabbbd9f58 100644 --- a/tests/ui/consts/dangling_raw_ptr.stderr +++ b/tests/ui/consts/dangling_raw_ptr.stderr @@ -4,5 +4,23 @@ error: encountered dangling pointer in final value of constant LL | const FOO: *const u32 = { | ^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 1 previous error +error: encountered dangling pointer in final value of constant + --> $DIR/dangling_raw_ptr.rs:11:1 + | +LL | const BAR: Union = { + | ^^^^^^^^^^^^^^^^ + +error: encountered dangling pointer in final value of constant + --> $DIR/dangling_raw_ptr.rs:17:1 + | +LL | const BAZ: Union = { + | ^^^^^^^^^^^^^^^^ + +error: encountered dangling pointer in final value of constant + --> $DIR/dangling_raw_ptr.rs:23:1 + | +LL | const FOOMP: *const u32 = { + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors diff --git a/tests/ui/consts/miri_unleashed/mutable_references.rs b/tests/ui/consts/miri_unleashed/mutable_references.rs index 8878e8eccf1..07f1d70259f 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references.rs +++ b/tests/ui/consts/miri_unleashed/mutable_references.rs @@ -5,11 +5,9 @@ #![deny(const_eval_mutable_ptr_in_final_value)] use std::cell::UnsafeCell; -// a test demonstrating what things we could allow with a smarter const qualification - +// This requires walking nested statics. static FOO: &&mut u32 = &&mut 42; -//~^ ERROR encountered mutable pointer in final value of static -//~| WARNING this was previously accepted by the compiler +//~^ ERROR it is undefined behavior to use this value static BAR: &mut () = &mut (); //~^ ERROR encountered mutable pointer in final value of static @@ -26,13 +24,10 @@ struct Meh { } unsafe impl Sync for Meh {} static MEH: Meh = Meh { x: &UnsafeCell::new(42) }; -//~^ ERROR encountered mutable pointer in final value of static -//~| WARNING this was previously accepted by the compiler +//~^ ERROR it is undefined behavior to use this value static OH_YES: &mut i32 = &mut 42; -//~^ ERROR encountered mutable pointer in final value of static -//~| WARNING this was previously accepted by the compiler -//~| ERROR it is undefined behavior to use this value +//~^ ERROR it is undefined behavior to use this value fn main() { unsafe { diff --git a/tests/ui/consts/miri_unleashed/mutable_references.stderr b/tests/ui/consts/miri_unleashed/mutable_references.stderr index 7122eb609f1..b207e3869ac 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references.stderr +++ b/tests/ui/consts/miri_unleashed/mutable_references.stderr @@ -1,28 +1,30 @@ -error: encountered mutable pointer in final value of static - --> $DIR/mutable_references.rs:10:1 +error[E0080]: it is undefined behavior to use this value + --> $DIR/mutable_references.rs:9:1 | LL | static FOO: &&mut u32 = &&mut 42; - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered mutable reference or box pointing to read-only memory | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> -note: the lint level is defined here - --> $DIR/mutable_references.rs:5:9 - | -LL | #![deny(const_eval_mutable_ptr_in_final_value)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } error: encountered mutable pointer in final value of static - --> $DIR/mutable_references.rs:14:1 + --> $DIR/mutable_references.rs:12:1 | LL | static BAR: &mut () = &mut (); | ^^^^^^^^^^^^^^^^^^^ | = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> +note: the lint level is defined here + --> $DIR/mutable_references.rs:5:9 + | +LL | #![deny(const_eval_mutable_ptr_in_final_value)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of static - --> $DIR/mutable_references.rs:20:1 + --> $DIR/mutable_references.rs:18:1 | LL | static BOO: &mut Foo<()> = &mut Foo(()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -30,26 +32,19 @@ LL | static BOO: &mut Foo<()> = &mut Foo(()); = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> -error: encountered mutable pointer in final value of static - --> $DIR/mutable_references.rs:28:1 +error[E0080]: it is undefined behavior to use this value + --> $DIR/mutable_references.rs:26:1 | LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) }; - | ^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> - -error: encountered mutable pointer in final value of static - --> $DIR/mutable_references.rs:32:1 - | -LL | static OH_YES: &mut i32 = &mut 42; - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ constructing invalid value at .x.<deref>: encountered `UnsafeCell` in read-only memory | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references.rs:32:1 + --> $DIR/mutable_references.rs:29:1 | LL | static OH_YES: &mut i32 = &mut 42; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory @@ -60,7 +55,7 @@ LL | static OH_YES: &mut i32 = &mut 42; } error[E0594]: cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item - --> $DIR/mutable_references.rs:41:5 + --> $DIR/mutable_references.rs:36:5 | LL | *OH_YES = 99; | ^^^^^^^^^^^^ cannot assign @@ -68,53 +63,38 @@ LL | *OH_YES = 99; warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:10:26 + --> $DIR/mutable_references.rs:9:26 | LL | static FOO: &&mut u32 = &&mut 42; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:14:23 + --> $DIR/mutable_references.rs:12:23 | LL | static BAR: &mut () = &mut (); | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:20:28 + --> $DIR/mutable_references.rs:18:28 | LL | static BOO: &mut Foo<()> = &mut Foo(()); | ^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:28:28 + --> $DIR/mutable_references.rs:26:28 | LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:32:27 + --> $DIR/mutable_references.rs:29:27 | LL | static OH_YES: &mut i32 = &mut 42; | ^^^^^^^ -error: aborting due to 7 previous errors; 1 warning emitted +error: aborting due to 6 previous errors; 1 warning emitted Some errors have detailed explanations: E0080, E0594. For more information about an error, try `rustc --explain E0080`. Future incompatibility report: Future breakage diagnostic: error: encountered mutable pointer in final value of static - --> $DIR/mutable_references.rs:10:1 - | -LL | static FOO: &&mut u32 = &&mut 42; - | ^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> -note: the lint level is defined here - --> $DIR/mutable_references.rs:5:9 - | -LL | #![deny(const_eval_mutable_ptr_in_final_value)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: encountered mutable pointer in final value of static - --> $DIR/mutable_references.rs:14:1 + --> $DIR/mutable_references.rs:12:1 | LL | static BAR: &mut () = &mut (); | ^^^^^^^^^^^^^^^^^^^ @@ -129,7 +109,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)] Future breakage diagnostic: error: encountered mutable pointer in final value of static - --> $DIR/mutable_references.rs:20:1 + --> $DIR/mutable_references.rs:18:1 | LL | static BOO: &mut Foo<()> = &mut Foo(()); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -142,33 +122,3 @@ note: the lint level is defined here LL | #![deny(const_eval_mutable_ptr_in_final_value)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Future breakage diagnostic: -error: encountered mutable pointer in final value of static - --> $DIR/mutable_references.rs:28:1 - | -LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) }; - | ^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> -note: the lint level is defined here - --> $DIR/mutable_references.rs:5:9 - | -LL | #![deny(const_eval_mutable_ptr_in_final_value)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: encountered mutable pointer in final value of static - --> $DIR/mutable_references.rs:32:1 - | -LL | static OH_YES: &mut i32 = &mut 42; - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> -note: the lint level is defined here - --> $DIR/mutable_references.rs:5:9 - | -LL | #![deny(const_eval_mutable_ptr_in_final_value)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - diff --git a/tests/ui/consts/miri_unleashed/mutable_references_err.rs b/tests/ui/consts/miri_unleashed/mutable_references_err.rs index 97b8a71cafa..a3da545846e 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references_err.rs +++ b/tests/ui/consts/miri_unleashed/mutable_references_err.rs @@ -16,9 +16,7 @@ unsafe impl Sync for Meh {} // the following will never be ok! no interior mut behind consts, because // all allocs interned here will be marked immutable. const MUH: Meh = Meh { - //~^ ERROR encountered mutable pointer in final value of constant - //~| WARNING this was previously accepted by the compiler - //~| ERROR: it is undefined behavior to use this value + //~^ ERROR it is undefined behavior to use this value x: &UnsafeCell::new(42), }; @@ -29,9 +27,7 @@ unsafe impl Sync for Synced {} // Make sure we also catch this behind a type-erased `dyn Trait` reference. const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; -//~^ ERROR: mutable pointer in final value -//~| WARNING this was previously accepted by the compiler -//~| ERROR it is undefined behavior to use this value +//~^ ERROR: it is undefined behavior to use this value // Make sure we also catch mutable references in values that shouldn't have them. static mut FOO: i32 = 0; @@ -40,9 +36,7 @@ const SUBTLE: &mut i32 = unsafe { &mut FOO }; //~| static const BLUNT: &mut i32 = &mut 42; -//~^ ERROR: mutable pointer in final value -//~| WARNING this was previously accepted by the compiler -//~| ERROR it is undefined behavior to use this value +//~^ ERROR: it is undefined behavior to use this value // Check for mutable references to read-only memory. static READONLY: i32 = 0; diff --git a/tests/ui/consts/miri_unleashed/mutable_references_err.stderr b/tests/ui/consts/miri_unleashed/mutable_references_err.stderr index 45615f523a6..d385b45a3df 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references_err.stderr +++ b/tests/ui/consts/miri_unleashed/mutable_references_err.stderr @@ -1,17 +1,3 @@ -error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:18:1 - | -LL | const MUH: Meh = Meh { - | ^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> -note: the lint level is defined here - --> $DIR/mutable_references_err.rs:5:9 - | -LL | #![deny(const_eval_mutable_ptr_in_final_value)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0080]: it is undefined behavior to use this value --> $DIR/mutable_references_err.rs:18:1 | @@ -23,17 +9,8 @@ LL | const MUH: Meh = Meh { HEX_DUMP } -error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:31:1 - | -LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> - error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references_err.rs:31:1 + --> $DIR/mutable_references_err.rs:29:1 | LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.<dyn-downcast>.x: encountered `UnsafeCell` in read-only memory @@ -44,7 +21,7 @@ LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; } error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references_err.rs:38:1 + --> $DIR/mutable_references_err.rs:34:1 | LL | const SUBTLE: &mut i32 = unsafe { &mut FOO }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` @@ -54,17 +31,8 @@ LL | const SUBTLE: &mut i32 = unsafe { &mut FOO }; HEX_DUMP } -error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:42:1 - | -LL | const BLUNT: &mut i32 = &mut 42; - | ^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> - error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references_err.rs:42:1 + --> $DIR/mutable_references_err.rs:38:1 | LL | const BLUNT: &mut i32 = &mut 42; | ^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory @@ -75,7 +43,7 @@ LL | const BLUNT: &mut i32 = &mut 42; } error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references_err.rs:49:1 + --> $DIR/mutable_references_err.rs:43:1 | LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory @@ -86,7 +54,7 @@ LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const } error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references_err.rs:56:1 + --> $DIR/mutable_references_err.rs:50:1 | LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` @@ -97,28 +65,33 @@ LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE }; } note: erroneous constant encountered - --> $DIR/mutable_references_err.rs:58:34 + --> $DIR/mutable_references_err.rs:52:34 | LL | const READS_FROM_MUTABLE: i32 = *POINTS_TO_MUTABLE1; | ^^^^^^^^^^^^^^^^^^ error[E0080]: evaluation of constant value failed - --> $DIR/mutable_references_err.rs:60:43 + --> $DIR/mutable_references_err.rs:54:43 | LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; | ^^^^^^^^^^^^^ constant accesses mutable global memory error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:64:1 + --> $DIR/mutable_references_err.rs:58:1 | LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> +note: the lint level is defined here + --> $DIR/mutable_references_err.rs:5:9 + | +LL | #![deny(const_eval_mutable_ptr_in_final_value)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:68:1 + --> $DIR/mutable_references_err.rs:62:1 | LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -127,7 +100,7 @@ LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _; = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153> error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:72:1 + --> $DIR/mutable_references_err.rs:66:1 | LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -136,7 +109,7 @@ LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *cons = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153> error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:85:1 + --> $DIR/mutable_references_err.rs:79:1 | LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -145,7 +118,7 @@ LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) }; = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153> error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:89:1 + --> $DIR/mutable_references_err.rs:83:1 | LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -154,7 +127,7 @@ LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153> error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:93:1 + --> $DIR/mutable_references_err.rs:87:1 | LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -165,132 +138,87 @@ LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 }; warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:22:8 + --> $DIR/mutable_references_err.rs:20:8 | LL | x: &UnsafeCell::new(42), | ^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:31:27 + --> $DIR/mutable_references_err.rs:29:27 | LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check for `const_refs_to_static` feature - --> $DIR/mutable_references_err.rs:38:40 + --> $DIR/mutable_references_err.rs:34:40 | LL | const SUBTLE: &mut i32 = unsafe { &mut FOO }; | ^^^ help: skipping check for `const_mut_refs` feature - --> $DIR/mutable_references_err.rs:38:35 + --> $DIR/mutable_references_err.rs:34:35 | LL | const SUBTLE: &mut i32 = unsafe { &mut FOO }; | ^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:42:25 + --> $DIR/mutable_references_err.rs:38:25 | LL | const BLUNT: &mut i32 = &mut 42; | ^^^^^^^ help: skipping check for `const_mut_refs` feature - --> $DIR/mutable_references_err.rs:49:49 + --> $DIR/mutable_references_err.rs:43:49 | LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check for `const_mut_refs` feature - --> $DIR/mutable_references_err.rs:49:49 + --> $DIR/mutable_references_err.rs:43:49 | LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check for `const_refs_to_static` feature - --> $DIR/mutable_references_err.rs:56:44 + --> $DIR/mutable_references_err.rs:50:44 | LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE }; | ^^^^^^^ help: skipping check for `const_refs_to_static` feature - --> $DIR/mutable_references_err.rs:60:45 + --> $DIR/mutable_references_err.rs:54:45 | LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; | ^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:64:45 + --> $DIR/mutable_references_err.rs:58:45 | LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:68:46 + --> $DIR/mutable_references_err.rs:62:46 | LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:72:47 + --> $DIR/mutable_references_err.rs:66:47 | LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; | ^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:85:51 + --> $DIR/mutable_references_err.rs:79:51 | LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) }; | ^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:89:49 + --> $DIR/mutable_references_err.rs:83:49 | LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ }; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:93:51 + --> $DIR/mutable_references_err.rs:87:51 | LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 }; | ^^^^^^ -error: aborting due to 16 previous errors; 1 warning emitted +error: aborting due to 13 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0080`. Future incompatibility report: Future breakage diagnostic: error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:18:1 - | -LL | const MUH: Meh = Meh { - | ^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> -note: the lint level is defined here - --> $DIR/mutable_references_err.rs:5:9 - | -LL | #![deny(const_eval_mutable_ptr_in_final_value)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:31:1 - | -LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> -note: the lint level is defined here - --> $DIR/mutable_references_err.rs:5:9 - | -LL | #![deny(const_eval_mutable_ptr_in_final_value)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:42:1 - | -LL | const BLUNT: &mut i32 = &mut 42; - | ^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> -note: the lint level is defined here - --> $DIR/mutable_references_err.rs:5:9 - | -LL | #![deny(const_eval_mutable_ptr_in_final_value)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:64:1 + --> $DIR/mutable_references_err.rs:58:1 | LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -305,7 +233,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)] Future breakage diagnostic: error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:68:1 + --> $DIR/mutable_references_err.rs:62:1 | LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -320,7 +248,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)] Future breakage diagnostic: error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:72:1 + --> $DIR/mutable_references_err.rs:66:1 | LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -335,7 +263,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)] Future breakage diagnostic: error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:85:1 + --> $DIR/mutable_references_err.rs:79:1 | LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -350,7 +278,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)] Future breakage diagnostic: error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:89:1 + --> $DIR/mutable_references_err.rs:83:1 | LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -365,7 +293,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)] Future breakage diagnostic: error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:93:1 + --> $DIR/mutable_references_err.rs:87:1 | LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr b/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr index 85ed6cbd538..1e554f6bac3 100644 --- a/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr +++ b/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr @@ -1,77 +1,63 @@ -error: encountered mutable pointer in final value of static +error[E0080]: it is undefined behavior to use this value --> $DIR/static-no-inner-mut.rs:9:1 | LL | static REF: &AtomicI32 = &AtomicI32::new(42); - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> -note: the lint level is defined here - --> $DIR/static-no-inner-mut.rs:6:9 - | -LL | #![deny(const_eval_mutable_ptr_in_final_value)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:13:1 + | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.v: encountered `UnsafeCell` in read-only memory | -LL | static REFMUT: &mut i32 = &mut 0; - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 4, align: 4) { + ╾ALLOC0╼ │ ╾──╼ + } error[E0080]: it is undefined behavior to use this value - --> $DIR/static-no-inner-mut.rs:13:1 + --> $DIR/static-no-inner-mut.rs:12:1 | LL | static REFMUT: &mut i32 = &mut 0; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { - ╾ALLOC0╼ │ ╾──╼ + ╾ALLOC1╼ │ ╾──╼ } -error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:19:1 +error[E0080]: it is undefined behavior to use this value + --> $DIR/static-no-inner-mut.rs:16:1 | LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}}; - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.v: encountered `UnsafeCell` in read-only memory | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> - -error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:23:1 - | -LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 4, align: 4) { + ╾ALLOC2╼ │ ╾──╼ + } error[E0080]: it is undefined behavior to use this value - --> $DIR/static-no-inner-mut.rs:23:1 + --> $DIR/static-no-inner-mut.rs:18:1 | LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { - ╾ALLOC1╼ │ ╾──╼ + ╾ALLOC3╼ │ ╾──╼ } error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:41:1 + --> $DIR/static-no-inner-mut.rs:34:1 | LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> +note: the lint level is defined here + --> $DIR/static-no-inner-mut.rs:6:9 + | +LL | #![deny(const_eval_mutable_ptr_in_final_value)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:45:1 + --> $DIR/static-no-inner-mut.rs:38:1 | LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -80,7 +66,7 @@ LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *con = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153> error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:49:1 + --> $DIR/static-no-inner-mut.rs:42:1 | LL | static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -96,102 +82,42 @@ help: skipping check that does not even have a feature gate LL | static REF: &AtomicI32 = &AtomicI32::new(42); | ^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/static-no-inner-mut.rs:13:27 + --> $DIR/static-no-inner-mut.rs:12:27 | LL | static REFMUT: &mut i32 = &mut 0; | ^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/static-no-inner-mut.rs:19:56 + --> $DIR/static-no-inner-mut.rs:16:56 | LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}}; | ^^^^ help: skipping check that does not even have a feature gate - --> $DIR/static-no-inner-mut.rs:23:44 + --> $DIR/static-no-inner-mut.rs:18:44 | LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; | ^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/static-no-inner-mut.rs:41:52 + --> $DIR/static-no-inner-mut.rs:34:52 | LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) }; | ^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/static-no-inner-mut.rs:45:51 + --> $DIR/static-no-inner-mut.rs:38:51 | LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/static-no-inner-mut.rs:49:52 + --> $DIR/static-no-inner-mut.rs:42:52 | LL | static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 }; | ^^^^^^ -error: aborting due to 9 previous errors; 1 warning emitted +error: aborting due to 7 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0080`. Future incompatibility report: Future breakage diagnostic: error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:9:1 - | -LL | static REF: &AtomicI32 = &AtomicI32::new(42); - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> -note: the lint level is defined here - --> $DIR/static-no-inner-mut.rs:6:9 - | -LL | #![deny(const_eval_mutable_ptr_in_final_value)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:13:1 - | -LL | static REFMUT: &mut i32 = &mut 0; - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> -note: the lint level is defined here - --> $DIR/static-no-inner-mut.rs:6:9 - | -LL | #![deny(const_eval_mutable_ptr_in_final_value)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:19:1 - | -LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}}; - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> -note: the lint level is defined here - --> $DIR/static-no-inner-mut.rs:6:9 - | -LL | #![deny(const_eval_mutable_ptr_in_final_value)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:23:1 - | -LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> -note: the lint level is defined here - --> $DIR/static-no-inner-mut.rs:6:9 - | -LL | #![deny(const_eval_mutable_ptr_in_final_value)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:41:1 + --> $DIR/static-no-inner-mut.rs:34:1 | LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -206,7 +132,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)] Future breakage diagnostic: error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:45:1 + --> $DIR/static-no-inner-mut.rs:38:1 | LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -221,7 +147,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)] Future breakage diagnostic: error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:49:1 + --> $DIR/static-no-inner-mut.rs:42:1 | LL | static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr b/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr index 5aa1cd0b15f..84ed631fcda 100644 --- a/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr +++ b/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr @@ -1,77 +1,63 @@ -error: encountered mutable pointer in final value of static +error[E0080]: it is undefined behavior to use this value --> $DIR/static-no-inner-mut.rs:9:1 | LL | static REF: &AtomicI32 = &AtomicI32::new(42); - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> -note: the lint level is defined here - --> $DIR/static-no-inner-mut.rs:6:9 - | -LL | #![deny(const_eval_mutable_ptr_in_final_value)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:13:1 + | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.v: encountered `UnsafeCell` in read-only memory | -LL | static REFMUT: &mut i32 = &mut 0; - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 8, align: 8) { + ╾ALLOC0╼ │ ╾──────╼ + } error[E0080]: it is undefined behavior to use this value - --> $DIR/static-no-inner-mut.rs:13:1 + --> $DIR/static-no-inner-mut.rs:12:1 | LL | static REFMUT: &mut i32 = &mut 0; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { - ╾ALLOC0╼ │ ╾──────╼ + ╾ALLOC1╼ │ ╾──────╼ } -error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:19:1 +error[E0080]: it is undefined behavior to use this value + --> $DIR/static-no-inner-mut.rs:16:1 | LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}}; - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<deref>.v: encountered `UnsafeCell` in read-only memory | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> - -error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:23:1 - | -LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 8, align: 8) { + ╾ALLOC2╼ │ ╾──────╼ + } error[E0080]: it is undefined behavior to use this value - --> $DIR/static-no-inner-mut.rs:23:1 + --> $DIR/static-no-inner-mut.rs:18:1 | LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { - ╾ALLOC1╼ │ ╾──────╼ + ╾ALLOC3╼ │ ╾──────╼ } error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:41:1 + --> $DIR/static-no-inner-mut.rs:34:1 | LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> +note: the lint level is defined here + --> $DIR/static-no-inner-mut.rs:6:9 + | +LL | #![deny(const_eval_mutable_ptr_in_final_value)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:45:1 + --> $DIR/static-no-inner-mut.rs:38:1 | LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -80,7 +66,7 @@ LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *con = note: for more information, see issue #122153 <https://github.com/rust-lang/rust/issues/122153> error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:49:1 + --> $DIR/static-no-inner-mut.rs:42:1 | LL | static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -96,102 +82,42 @@ help: skipping check that does not even have a feature gate LL | static REF: &AtomicI32 = &AtomicI32::new(42); | ^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/static-no-inner-mut.rs:13:27 + --> $DIR/static-no-inner-mut.rs:12:27 | LL | static REFMUT: &mut i32 = &mut 0; | ^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/static-no-inner-mut.rs:19:56 + --> $DIR/static-no-inner-mut.rs:16:56 | LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}}; | ^^^^ help: skipping check that does not even have a feature gate - --> $DIR/static-no-inner-mut.rs:23:44 + --> $DIR/static-no-inner-mut.rs:18:44 | LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; | ^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/static-no-inner-mut.rs:41:52 + --> $DIR/static-no-inner-mut.rs:34:52 | LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) }; | ^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/static-no-inner-mut.rs:45:51 + --> $DIR/static-no-inner-mut.rs:38:51 | LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/static-no-inner-mut.rs:49:52 + --> $DIR/static-no-inner-mut.rs:42:52 | LL | static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 }; | ^^^^^^ -error: aborting due to 9 previous errors; 1 warning emitted +error: aborting due to 7 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0080`. Future incompatibility report: Future breakage diagnostic: error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:9:1 - | -LL | static REF: &AtomicI32 = &AtomicI32::new(42); - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> -note: the lint level is defined here - --> $DIR/static-no-inner-mut.rs:6:9 - | -LL | #![deny(const_eval_mutable_ptr_in_final_value)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:13:1 - | -LL | static REFMUT: &mut i32 = &mut 0; - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> -note: the lint level is defined here - --> $DIR/static-no-inner-mut.rs:6:9 - | -LL | #![deny(const_eval_mutable_ptr_in_final_value)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:19:1 - | -LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}}; - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> -note: the lint level is defined here - --> $DIR/static-no-inner-mut.rs:6:9 - | -LL | #![deny(const_eval_mutable_ptr_in_final_value)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:23:1 - | -LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 #122153 <https://github.com/rust-lang/rust/issues/122153> -note: the lint level is defined here - --> $DIR/static-no-inner-mut.rs:6:9 - | -LL | #![deny(const_eval_mutable_ptr_in_final_value)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Future breakage diagnostic: -error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:41:1 + --> $DIR/static-no-inner-mut.rs:34:1 | LL | static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -206,7 +132,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)] Future breakage diagnostic: error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:45:1 + --> $DIR/static-no-inner-mut.rs:38:1 | LL | static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -221,7 +147,7 @@ LL | #![deny(const_eval_mutable_ptr_in_final_value)] Future breakage diagnostic: error: encountered mutable pointer in final value of static - --> $DIR/static-no-inner-mut.rs:49:1 + --> $DIR/static-no-inner-mut.rs:42:1 | LL | static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs b/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs index e82ca50d882..810760319c1 100644 --- a/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs +++ b/tests/ui/consts/miri_unleashed/static-no-inner-mut.rs @@ -7,23 +7,16 @@ use std::sync::atomic::*; static REF: &AtomicI32 = &AtomicI32::new(42); -//~^ ERROR mutable pointer in final value -//~| WARNING this was previously accepted by the compiler +//~^ ERROR it is undefined behavior to use this value static REFMUT: &mut i32 = &mut 0; -//~^ ERROR mutable pointer in final value -//~| WARNING this was previously accepted by the compiler -//~| ERROR it is undefined behavior to use this value +//~^ ERROR it is undefined behavior to use this value // Different way of writing this that avoids promotion. static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}}; -//~^ ERROR mutable pointer in final value -//~| WARNING this was previously accepted by the compiler - +//~^ ERROR it is undefined behavior to use this value static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; -//~^ ERROR mutable pointer in final value -//~| WARNING this was previously accepted by the compiler -//~| ERROR it is undefined behavior to use this value +//~^ ERROR it is undefined behavior to use this value // This one is obvious, since it is non-Sync. (It also suppresses the other errors, so it is // commented out.) diff --git a/tests/ui/consts/zst_no_llvm_alloc.rs b/tests/ui/consts/zst_no_llvm_alloc.rs index 1622a199a7a..48ef11e2b58 100644 --- a/tests/ui/consts/zst_no_llvm_alloc.rs +++ b/tests/ui/consts/zst_no_llvm_alloc.rs @@ -6,16 +6,21 @@ struct Foo; static FOO: Foo = Foo; fn main() { + // There's no stable guarantee that these are true. + // However, we want them to be true so that our LLVM IR and runtime are a bit faster: + // a constant address is cheap and doesn't result in relocations in comparison to a "real" + // global somewhere in the data section. let x: &'static () = &(); - assert_ne!(x as *const () as usize, 1); + assert_eq!(x as *const () as usize, 1); let x: &'static Foo = &Foo; - assert_ne!(x as *const Foo as usize, 4); + assert_eq!(x as *const Foo as usize, 4); - // statics must have a unique address - assert_ne!(&FOO as *const Foo as usize, 4); + // The exact addresses returned by these library functions are not necessarily stable guarantees + // but for now we assert that we're still matching. + assert_eq!(<Vec<i32>>::new().as_ptr(), <&[i32]>::default().as_ptr()); + assert_eq!(<Box<[i32]>>::default().as_ptr(), (&[]).as_ptr()); - // FIXME this two tests should be assert_eq! - // this stopped working since we are promoting to constants instead of statics - assert_ne!(<Vec<i32>>::new().as_ptr(), <&[i32]>::default().as_ptr()); - assert_ne!(<Box<[i32]>>::default().as_ptr(), (&[]).as_ptr()); + // statics must have a unique address (see https://github.com/rust-lang/rust/issues/18297, not + // clear whether this is a stable guarantee) + assert_ne!(&FOO as *const Foo as usize, 4); } diff --git a/tests/ui/extern-flag/auxiliary/panic_handler.rs b/tests/ui/extern-flag/auxiliary/panic_handler.rs index a625761a838..5ca32fa992b 100644 --- a/tests/ui/extern-flag/auxiliary/panic_handler.rs +++ b/tests/ui/extern-flag/auxiliary/panic_handler.rs @@ -5,7 +5,9 @@ // Rust programs link necessary system libraries via `#[link()]` // attributes in the `libc` crate. `libc` is a dependency of `std`, // but as we are `#![no_std]`, we need to include it manually. +// Except on windows-msvc. #![feature(rustc_private)] +#[cfg(not(all(windows, target_env = "msvc")))] extern crate libc; #[panic_handler] diff --git a/tests/ui/rfcs/rfc-1014-stdout-existential-crisis/rfc-1014-2.rs b/tests/ui/rfcs/rfc-1014-stdout-existential-crisis/rfc-1014-2.rs index 4944de0b82f..eb512bb40aa 100644 --- a/tests/ui/rfcs/rfc-1014-stdout-existential-crisis/rfc-1014-2.rs +++ b/tests/ui/rfcs/rfc-1014-stdout-existential-crisis/rfc-1014-2.rs @@ -1,31 +1,28 @@ +// Test that println! to a closed stdout does not panic. +// On Windows, close via SetStdHandle to 0. //@ run-pass -#![allow(dead_code)] #![feature(rustc_private)] -extern crate libc; - -type DWORD = u32; -type HANDLE = *mut u8; -type BOOL = i32; - -#[cfg(windows)] -extern "system" { - fn SetStdHandle(nStdHandle: DWORD, nHandle: HANDLE) -> BOOL; -} - #[cfg(windows)] fn close_stdout() { + type DWORD = u32; + type HANDLE = *mut u8; + type BOOL = i32; + + extern "system" { + fn SetStdHandle(nStdHandle: DWORD, nHandle: HANDLE) -> BOOL; + } + const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD; unsafe { SetStdHandle(STD_OUTPUT_HANDLE, 0 as HANDLE); } } -#[cfg(windows)] +#[cfg(not(windows))] +fn close_stdout() {} + fn main() { close_stdout(); println!("hello"); println!("world"); } - -#[cfg(not(windows))] -fn main() {} diff --git a/tests/ui/rfcs/rfc-1014-stdout-existential-crisis/rfc-1014.rs b/tests/ui/rfcs/rfc-1014-stdout-existential-crisis/rfc-1014.rs index cc2d9bad029..950c4dee329 100644 --- a/tests/ui/rfcs/rfc-1014-stdout-existential-crisis/rfc-1014.rs +++ b/tests/ui/rfcs/rfc-1014-stdout-existential-crisis/rfc-1014.rs @@ -1,28 +1,27 @@ +// Test that println! to a closed stdout does not panic. +// On Windows, close via CloseHandle. //@ run-pass -#![allow(dead_code)] //@ ignore-sgx no libc #![feature(rustc_private)] -extern crate libc; - -type DWORD = u32; -type HANDLE = *mut u8; - -#[cfg(windows)] -extern "system" { - fn GetStdHandle(which: DWORD) -> HANDLE; - fn CloseHandle(handle: HANDLE) -> i32; -} - #[cfg(windows)] fn close_stdout() { + type DWORD = u32; + type HANDLE = *mut u8; + + extern "system" { + fn GetStdHandle(which: DWORD) -> HANDLE; + fn CloseHandle(handle: HANDLE) -> i32; + } + const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD; unsafe { CloseHandle(GetStdHandle(STD_OUTPUT_HANDLE)); } } #[cfg(not(windows))] fn close_stdout() { + extern crate libc; unsafe { libc::close(1); } } diff --git a/tests/ui/statics/mutable_memory_validation.rs b/tests/ui/statics/mutable_memory_validation.rs new file mode 100644 index 00000000000..fcf6ad16277 --- /dev/null +++ b/tests/ui/statics/mutable_memory_validation.rs @@ -0,0 +1,21 @@ +//issue: rust-lang/rust#122548 + +// Strip out raw byte dumps to make comparison platform-independent: +//@ normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" +//@ normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" + +#![feature(const_mut_refs)] +#![feature(const_refs_to_static)] + +use std::cell::UnsafeCell; + +struct Meh { + x: &'static UnsafeCell<i32>, +} + +const MUH: Meh = Meh { x: unsafe { &mut *(&READONLY as *const _ as *mut _) } }; +//~^ ERROR: it is undefined behavior to use this value + +static READONLY: i32 = 0; + +pub fn main() {} diff --git a/tests/ui/statics/mutable_memory_validation.stderr b/tests/ui/statics/mutable_memory_validation.stderr new file mode 100644 index 00000000000..f21269235e9 --- /dev/null +++ b/tests/ui/statics/mutable_memory_validation.stderr @@ -0,0 +1,14 @@ +error[E0080]: it is undefined behavior to use this value + --> $DIR/mutable_memory_validation.rs:16:1 + | +LL | const MUH: Meh = Meh { x: unsafe { &mut *(&READONLY as *const _ as *mut _) } }; + | ^^^^^^^^^^^^^^ constructing invalid value at .x.<deref>: encountered `UnsafeCell` in read-only memory + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/thir-print/thir-tree-match.stdout b/tests/ui/thir-print/thir-tree-match.stdout index b248d2a8268..31c46716a00 100644 --- a/tests/ui/thir-print/thir-tree-match.stdout +++ b/tests/ui/thir-print/thir-tree-match.stdout @@ -12,7 +12,7 @@ params: [ kind: PatKind { Binding { name: "foo" - mode: BindingAnnotation(No, Not) + mode: BindingMode(No, Not) var: LocalVarId(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).2)) ty: Foo is_primary: true |
