diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 373604adb0541..aad495fa3fae6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,5 +4,5 @@ Thank you for your interest in contributing to Rust! To get started, read the [Getting Started] guide in the [rustc-dev-guide]. -[Getting Started]: https://rustc-dev-guide.rust-lang.org/getting-started.md +[Getting Started]: https://rustc-dev-guide.rust-lang.org/getting-started.html [rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org/ diff --git a/README.md b/README.md index 70d3d51ce9b23..639789123d832 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ The Rust build system uses a Python script called `x.py` to build the compiler, which manages the bootstrapping process. More information about it can be found by running `./x.py --help` or reading the [rustc dev guide][rustcguidebuild]. -[gettingstarted]: https://rustc-dev-guide.rust-lang.org/getting-started.md +[gettingstarted]: https://rustc-dev-guide.rust-lang.org/getting-started.html [rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html ### Building on a Unix-like system diff --git a/src/ci/docker/host-x86_64/mingw-check/Dockerfile b/src/ci/docker/host-x86_64/mingw-check/Dockerfile index e9570e8425e98..e0607d298f4f4 100644 --- a/src/ci/docker/host-x86_64/mingw-check/Dockerfile +++ b/src/ci/docker/host-x86_64/mingw-check/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:16.04 +FROM ubuntu:18.04 RUN apt-get update && apt-get install -y --no-install-recommends \ g++ \ diff --git a/src/doc/unstable-book/src/library-features/format-args-capture.md b/src/doc/unstable-book/src/library-features/format-args-capture.md new file mode 100644 index 0000000000000..64b1b3d81bd83 --- /dev/null +++ b/src/doc/unstable-book/src/library-features/format-args-capture.md @@ -0,0 +1,47 @@ +# `format_args_capture` + +The tracking issue for this feature is: [#67984] + +[#67984]: https://github.com/rust-lang/rust/issues/67984 + +------------------------ + +Enables `format_args!` (and macros which use `format_args!` in their implementation, such +as `format!`, `print!` and `panic!`) to capture variables from the surrounding scope. +This avoids the need to pass named parameters when the binding in question +already exists in scope. + +```rust +#![feature(format_args_capture)] + +let (person, species, name) = ("Charlie Brown", "dog", "Snoopy"); + +// captures named argument `person` +print!("Hello {person}"); + +// captures named arguments `species` and `name` +format!("The {species}'s name is {name}."); +``` + +This also works for formatting parameters such as width and precision: + +```rust +#![feature(format_args_capture)] + +let precision = 2; +let s = format!("{:.precision$}", 1.324223); + +assert_eq!(&s, "1.32"); +``` + +A non-exhaustive list of macros which benefit from this functionality include: +- `format!` +- `print!` and `println!` +- `eprint!` and `eprintln!` +- `write!` and `writeln!` +- `panic!` +- `unreachable!` +- `unimplemented!` +- `todo!` +- `assert!` and similar +- macros in many thirdparty crates, such as `log` diff --git a/src/etc/htmldocck.py b/src/etc/htmldocck.py index 7789b24b62c83..2e7958325cd61 100644 --- a/src/etc/htmldocck.py +++ b/src/etc/htmldocck.py @@ -114,7 +114,10 @@ from html.parser import HTMLParser except ImportError: from HTMLParser import HTMLParser -from xml.etree import cElementTree as ET +try: + from xml.etree import cElementTree as ET +except ImportError: + from xml.etree import ElementTree as ET try: from html.entities import name2codepoint diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 5f18fe8bfab84..79bfd57a00fa9 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -100,6 +100,7 @@ #![feature(fundamental)] #![feature(internal_uninit_const)] #![feature(lang_items)] +#![feature(layout_for_ptr)] #![feature(libc)] #![feature(negative_impls)] #![feature(new_uninit)] @@ -109,6 +110,7 @@ #![feature(pattern)] #![feature(ptr_internals)] #![feature(ptr_offset_from)] +#![feature(raw_ref_op)] #![feature(rustc_attrs)] #![feature(receiver_trait)] #![feature(min_specialization)] diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 4d50ae9efca95..fccdfa0dca92a 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -245,7 +245,7 @@ use core::hash::{Hash, Hasher}; use core::intrinsics::abort; use core::iter; use core::marker::{self, PhantomData, Unpin, Unsize}; -use core::mem::{self, align_of, align_of_val, forget, size_of_val}; +use core::mem::{self, align_of_val_raw, forget, size_of_val}; use core::ops::{CoerceUnsized, Deref, DispatchFromDyn, Receiver}; use core::pin::Pin; use core::ptr::{self, NonNull}; @@ -591,17 +591,11 @@ impl Rc { #[stable(feature = "weak_into_raw", since = "1.45.0")] pub fn as_ptr(this: &Self) -> *const T { let ptr: *mut RcBox = NonNull::as_ptr(this.ptr); - let fake_ptr = ptr as *mut T; - // SAFETY: This cannot go through Deref::deref. - // Instead, we manually offset the pointer rather than manifesting a reference. - // This is so that the returned pointer retains the same provenance as our pointer. - // This is required so that e.g. `get_mut` can write through the pointer - // after the Rc is recovered through `from_raw`. - unsafe { - let offset = data_offset(&(*ptr).value); - set_data_ptr(fake_ptr, (ptr as *mut u8).offset(offset)) - } + // SAFETY: This cannot go through Deref::deref or Rc::inner because + // this is required to retain raw/mut provenance such that e.g. `get_mut` can + // write through the pointer after the Rc is recovered through `from_raw`. + unsafe { &raw const (*ptr).value } } /// Constructs an `Rc` from a raw pointer. @@ -1647,6 +1641,7 @@ pub struct Weak { // `Weak::new` sets this to `usize::MAX` so that it doesn’t need // to allocate space on the heap. That's not a value a real pointer // will ever have because RcBox has alignment at least 2. + // This is only possible when `T: Sized`; unsized `T` never dangle. ptr: NonNull>, } @@ -1708,9 +1703,18 @@ impl Weak { /// [`null`]: ../../std/ptr/fn.null.html #[stable(feature = "weak_into_raw", since = "1.45.0")] pub fn as_ptr(&self) -> *const T { - let offset = data_offset_sized::(); - let ptr = self.ptr.cast::().as_ptr().wrapping_offset(offset); - ptr as *const T + let ptr: *mut RcBox = NonNull::as_ptr(self.ptr); + + // SAFETY: we must offset the pointer manually, and said pointer may be + // a dangling weak (usize::MAX) if T is sized. data_offset is safe to call, + // because we know that a pointer to unsized T was derived from a real + // unsized T, as dangling weaks are only created for sized T. wrapping_offset + // is used so that we can use the same code path for the non-dangling + // unsized case and the potentially dangling sized case. + unsafe { + let offset = data_offset(ptr as *mut T); + set_data_ptr(ptr as *mut T, (ptr as *mut u8).wrapping_offset(offset)) + } } /// Consumes the `Weak` and turns it into a raw pointer. @@ -2113,19 +2117,22 @@ impl AsRef for Rc { #[stable(feature = "pin", since = "1.33.0")] impl Unpin for Rc {} +/// Get the offset within an `ArcInner` for +/// a payload of type described by a pointer. +/// +/// # Safety +/// +/// This has the same safety requirements as `align_of_val_raw`. In effect: +/// +/// - This function is safe for any argument if `T` is sized, and +/// - if `T` is unsized, the pointer must have appropriate pointer metadata +/// aquired from the real instance that you are getting this offset for. unsafe fn data_offset(ptr: *const T) -> isize { // Align the unsized value to the end of the `RcBox`. // Because it is ?Sized, it will always be the last field in memory. // Note: This is a detail of the current implementation of the compiler, // and is not a guaranteed language detail. Do not rely on it outside of std. - unsafe { data_offset_align(align_of_val(&*ptr)) } -} - -/// Computes the offset of the data field within `RcBox`. -/// -/// Unlike [`data_offset`], this doesn't need the pointer, but it works only on `T: Sized`. -fn data_offset_sized() -> isize { - data_offset_align(align_of::()) + unsafe { data_offset_align(align_of_val_raw(ptr)) } } #[inline] diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 826f0c8fa833f..ac3ce2255c89b 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -16,7 +16,7 @@ use core::hash::{Hash, Hasher}; use core::intrinsics::abort; use core::iter; use core::marker::{PhantomData, Unpin, Unsize}; -use core::mem::{self, align_of, align_of_val, size_of_val}; +use core::mem::{self, align_of_val, size_of_val}; use core::ops::{CoerceUnsized, Deref, DispatchFromDyn, Receiver}; use core::pin::Pin; use core::ptr::{self, NonNull}; @@ -267,6 +267,7 @@ pub struct Weak { // `Weak::new` sets this to `usize::MAX` so that it doesn’t need // to allocate space on the heap. That's not a value a real pointer // will ever have because RcBox has alignment at least 2. + // This is only possible when `T: Sized`; unsized `T` never dangle. ptr: NonNull>, } @@ -590,17 +591,11 @@ impl Arc { #[stable(feature = "weak_into_raw", since = "1.45.0")] pub fn as_ptr(this: &Self) -> *const T { let ptr: *mut ArcInner = NonNull::as_ptr(this.ptr); - let fake_ptr = ptr as *mut T; - // SAFETY: This cannot go through Deref::deref. - // Instead, we manually offset the pointer rather than manifesting a reference. - // This is so that the returned pointer retains the same provenance as our pointer. - // This is required so that e.g. `get_mut` can write through the pointer - // after the Arc is recovered through `from_raw`. - unsafe { - let offset = data_offset(&(*ptr).data); - set_data_ptr(fake_ptr, (ptr as *mut u8).offset(offset)) - } + // SAFETY: This cannot go through Deref::deref or RcBoxPtr::inner because + // this is required to retain raw/mut provenance such that e.g. `get_mut` can + // write through the pointer after the Rc is recovered through `from_raw`. + unsafe { &raw const (*ptr).data } } /// Constructs an `Arc` from a raw pointer. @@ -1476,9 +1471,18 @@ impl Weak { /// [`null`]: ../../std/ptr/fn.null.html #[stable(feature = "weak_into_raw", since = "1.45.0")] pub fn as_ptr(&self) -> *const T { - let offset = data_offset_sized::(); - let ptr = self.ptr.cast::().as_ptr().wrapping_offset(offset); - ptr as *const T + let ptr: *mut ArcInner = NonNull::as_ptr(self.ptr); + + // SAFETY: we must offset the pointer manually, and said pointer may be + // a dangling weak (usize::MAX) if T is sized. data_offset is safe to call, + // because we know that a pointer to unsized T was derived from a real + // unsized T, as dangling weaks are only created for sized T. wrapping_offset + // is used so that we can use the same code path for the non-dangling + // unsized case and the potentially dangling sized case. + unsafe { + let offset = data_offset(ptr as *mut T); + set_data_ptr(ptr as *mut T, (ptr as *mut u8).wrapping_offset(offset)) + } } /// Consumes the `Weak` and turns it into a raw pointer. @@ -2270,7 +2274,16 @@ impl AsRef for Arc { #[stable(feature = "pin", since = "1.33.0")] impl Unpin for Arc {} -/// Computes the offset of the data field within `ArcInner`. +/// Get the offset within an `ArcInner` for +/// a payload of type described by a pointer. +/// +/// # Safety +/// +/// This has the same safety requirements as `align_of_val_raw`. In effect: +/// +/// - This function is safe for any argument if `T` is sized, and +/// - if `T` is unsized, the pointer must have appropriate pointer metadata +/// aquired from the real instance that you are getting this offset for. unsafe fn data_offset(ptr: *const T) -> isize { // Align the unsized value to the end of the `ArcInner`. // Because it is `?Sized`, it will always be the last field in memory. @@ -2279,13 +2292,6 @@ unsafe fn data_offset(ptr: *const T) -> isize { unsafe { data_offset_align(align_of_val(&*ptr)) } } -/// Computes the offset of the data field within `ArcInner`. -/// -/// Unlike [`data_offset`], this doesn't need the pointer, but it works only on `T: Sized`. -fn data_offset_sized() -> isize { - data_offset_align(align_of::()) -} - #[inline] fn data_offset_align(align: usize) -> isize { let layout = Layout::new::>(); diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 6040dd31847a9..fdcfae8530a3b 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -694,7 +694,7 @@ mod impls { )] #[lang = "discriminant_kind"] pub trait DiscriminantKind { - /// The type of the dicriminant, which must satisfy the trait + /// The type of the discriminant, which must satisfy the trait /// bounds required by `mem::Discriminant`. type Discriminant: Clone + Copy + Debug + Eq + PartialEq + Hash + Send + Sync + Unpin; } diff --git a/src/librustc_ast_pretty/pp.rs b/src/librustc_ast_pretty/pp.rs index e6090db3284a7..4bb806a923e6c 100644 --- a/src/librustc_ast_pretty/pp.rs +++ b/src/librustc_ast_pretty/pp.rs @@ -1,10 +1,8 @@ //! This pretty-printer is a direct reimplementation of Philip Karlton's -//! Mesa pretty-printer, as described in appendix A of -//! -//! ```text -//! STAN-CS-79-770: "Pretty Printing", by Derek C. Oppen. -//! Stanford Department of Computer Science, 1979. -//! ``` +//! Mesa pretty-printer, as described in the appendix to +//! Derek C. Oppen, "Pretty Printing" (1979), +//! Stanford Computer Science Department STAN-CS-79-770, +//! . //! //! The algorithm's aim is to break a stream into as few lines as possible //! while respecting the indentation-consistency requirements of the enclosing diff --git a/src/librustc_builtin_macros/format.rs b/src/librustc_builtin_macros/format.rs index e574b076bf84c..4cc83f8e31c20 100644 --- a/src/librustc_builtin_macros/format.rs +++ b/src/librustc_builtin_macros/format.rs @@ -107,6 +107,9 @@ struct Context<'a, 'b> { arg_spans: Vec, /// All the formatting arguments that have formatting flags set, in order for diagnostics. arg_with_formatting: Vec>, + + /// Whether this format string came from a string literal, as opposed to a macro. + is_literal: bool, } /// Parses the arguments from the given list of tokens, returning the diagnostic @@ -498,10 +501,55 @@ impl<'a, 'b> Context<'a, 'b> { self.verify_arg_type(Exact(idx), ty) } None => { - let msg = format!("there is no argument named `{}`", name); - let sp = *self.arg_spans.get(self.curpiece).unwrap_or(&self.fmtsp); - let mut err = self.ecx.struct_span_err(sp, &msg[..]); - err.emit(); + let capture_feature_enabled = self + .ecx + .ecfg + .features + .map_or(false, |features| features.format_args_capture); + + // For the moment capturing variables from format strings expanded from macros is + // disabled (see RFC #2795) + let can_capture = capture_feature_enabled && self.is_literal; + + if can_capture { + // Treat this name as a variable to capture from the surrounding scope + let idx = self.args.len(); + self.arg_types.push(Vec::new()); + self.arg_unique_types.push(Vec::new()); + self.args.push( + self.ecx.expr_ident(self.fmtsp, Ident::new(name, self.fmtsp)), + ); + self.names.insert(name, idx); + self.verify_arg_type(Exact(idx), ty) + } else { + let msg = format!("there is no argument named `{}`", name); + let sp = if self.is_literal { + *self.arg_spans.get(self.curpiece).unwrap_or(&self.fmtsp) + } else { + self.fmtsp + }; + let mut err = self.ecx.struct_span_err(sp, &msg[..]); + + if capture_feature_enabled && !self.is_literal { + err.note(&format!( + "did you intend to capture a variable `{}` from \ + the surrounding scope?", + name + )); + err.note( + "to avoid ambiguity, `format_args!` cannot capture variables \ + when the format string is expanded from a macro", + ); + } else if self.ecx.parse_sess().unstable_features.is_nightly_build() { + err.help(&format!( + "if you intended to capture `{}` from the surrounding scope, add \ + `#![feature(format_args_capture)]` to the crate attributes", + name + )); + } + + err.emit(); + } } } } @@ -951,6 +999,7 @@ pub fn expand_preparsed_format_args( invalid_refs: Vec::new(), arg_spans, arg_with_formatting: Vec::new(), + is_literal: parser.is_literal, }; // This needs to happen *after* the Parser has consumed all pieces to create all the spans diff --git a/src/librustc_data_structures/graph/dominators/mod.rs b/src/librustc_data_structures/graph/dominators/mod.rs index a7f9340dead88..438a0d0c6ff97 100644 --- a/src/librustc_data_structures/graph/dominators/mod.rs +++ b/src/librustc_data_structures/graph/dominators/mod.rs @@ -1,8 +1,9 @@ -//! Algorithm citation: -//! A Simple, Fast Dominance Algorithm. -//! Keith D. Cooper, Timothy J. Harvey, and Ken Kennedy -//! Rice Computer Science TS-06-33870 -//! +//! Finding the dominators in a control-flow graph. +//! +//! Algorithm based on Keith D. Cooper, Timothy J. Harvey, and Ken Kennedy, +//! "A Simple, Fast Dominance Algorithm", +//! Rice Computer Science TS-06-33870, +//! . use super::iterate::reverse_post_order; use super::ControlFlowGraph; diff --git a/src/librustc_data_structures/graph/scc/mod.rs b/src/librustc_data_structures/graph/scc/mod.rs index 57eaf56f268f8..2db8e466e1144 100644 --- a/src/librustc_data_structures/graph/scc/mod.rs +++ b/src/librustc_data_structures/graph/scc/mod.rs @@ -1,7 +1,9 @@ -//! Routine to compute the strongly connected components (SCCs) of a -//! graph, as well as the resulting DAG if each SCC is replaced with a -//! node in the graph. This uses Tarjan's algorithm that completes in -//! O(n) time. +//! Routine to compute the strongly connected components (SCCs) of a graph. +//! +//! Also computes as the resulting DAG if each SCC is replaced with a +//! node in the graph. This uses [Tarjan's algorithm]( +//! https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm) +//! that completes in *O(n)* time. use crate::fx::FxHashSet; use crate::graph::vec_graph::VecGraph; diff --git a/src/librustc_error_codes/error_codes.rs b/src/librustc_error_codes/error_codes.rs index 00c072e1b04a1..f687221d78e03 100644 --- a/src/librustc_error_codes/error_codes.rs +++ b/src/librustc_error_codes/error_codes.rs @@ -449,6 +449,7 @@ E0764: include_str!("./error_codes/E0764.md"), E0765: include_str!("./error_codes/E0765.md"), E0766: include_str!("./error_codes/E0766.md"), E0767: include_str!("./error_codes/E0767.md"), +E0768: include_str!("./error_codes/E0768.md"), ; // E0006, // merged with E0005 // E0008, // cannot bind by-move into a pattern guard diff --git a/src/librustc_error_codes/error_codes/E0768.md b/src/librustc_error_codes/error_codes/E0768.md new file mode 100644 index 0000000000000..24169ef512efb --- /dev/null +++ b/src/librustc_error_codes/error_codes/E0768.md @@ -0,0 +1,13 @@ +A number in a non-decimal base has no digits. + +Erroneous code example: + +```compile_fail,E0768 +let s: i32 = 0b; // error! +``` + +To fix this error, add the missing digits: + +``` +let s: i32 = 0b1; // ok! +``` diff --git a/src/librustc_feature/active.rs b/src/librustc_feature/active.rs index b9a55377949f2..313744efb3fce 100644 --- a/src/librustc_feature/active.rs +++ b/src/librustc_feature/active.rs @@ -567,6 +567,9 @@ declare_features! ( /// Be more precise when looking for live drops in a const context. (active, const_precise_live_drops, "1.46.0", Some(73255), None), + /// Allows capturing variables in scope using format_args! + (active, format_args_capture, "1.46.0", Some(67984), None), + // ------------------------------------------------------------------------- // feature-group-end: actual feature gates // ------------------------------------------------------------------------- diff --git a/src/librustc_middle/mir/mod.rs b/src/librustc_middle/mir/mod.rs index ad4e8b55b75e1..31b8de500e030 100644 --- a/src/librustc_middle/mir/mod.rs +++ b/src/librustc_middle/mir/mod.rs @@ -257,6 +257,18 @@ impl<'tcx> Body<'tcx> { (&mut self.basic_blocks, &mut self.local_decls) } + #[inline] + pub fn basic_blocks_local_decls_mut_and_var_debug_info( + &mut self, + ) -> ( + &mut IndexVec>, + &mut LocalDecls<'tcx>, + &mut Vec>, + ) { + self.predecessor_cache.invalidate(); + (&mut self.basic_blocks, &mut self.local_decls, &mut self.var_debug_info) + } + /// Returns `true` if a cycle exists in the control-flow graph that is reachable from the /// `START_BLOCK`. pub fn is_cfg_cyclic(&self) -> bool { diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index 2c1565b54261c..e4c1ca4e851b0 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -638,8 +638,20 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { return None; } + Rvalue::ThreadLocalRef(def_id) => { + trace!("skipping ThreadLocalRef({:?})", def_id); - _ => {} + return None; + } + + // There's no other checking to do at this time. + Rvalue::Aggregate(..) + | Rvalue::Use(..) + | Rvalue::Repeat(..) + | Rvalue::Len(..) + | Rvalue::Cast(..) + | Rvalue::Discriminant(..) + | Rvalue::NullaryOp(..) => {} } // FIXME we need to revisit this for #67176 diff --git a/src/librustc_mir/transform/simplify_try.rs b/src/librustc_mir/transform/simplify_try.rs index 50136ac3becca..97a01de867e1d 100644 --- a/src/librustc_mir/transform/simplify_try.rs +++ b/src/librustc_mir/transform/simplify_try.rs @@ -11,9 +11,10 @@ use crate::transform::{simplify, MirPass, MirSource}; use itertools::Itertools as _; -use rustc_index::vec::IndexVec; +use rustc_index::{bit_set::BitSet, vec::IndexVec}; +use rustc_middle::mir::visit::{NonUseContext, PlaceContext, Visitor}; use rustc_middle::mir::*; -use rustc_middle::ty::{Ty, TyCtxt}; +use rustc_middle::ty::{List, Ty, TyCtxt}; use rustc_target::abi::VariantIdx; use std::iter::{Enumerate, Peekable}; use std::slice::Iter; @@ -73,9 +74,20 @@ struct ArmIdentityInfo<'tcx> { /// The statements that should be removed (turned into nops) stmts_to_remove: Vec, + + /// Indices of debug variables that need to be adjusted to point to + // `{local_0}.{dbg_projection}`. + dbg_info_to_adjust: Vec, + + /// The projection used to rewrite debug info. + dbg_projection: &'tcx List>, } -fn get_arm_identity_info<'a, 'tcx>(stmts: &'a [Statement<'tcx>]) -> Option> { +fn get_arm_identity_info<'a, 'tcx>( + stmts: &'a [Statement<'tcx>], + locals_count: usize, + debug_info: &'a [VarDebugInfo<'tcx>], +) -> Option> { // This can't possibly match unless there are at least 3 statements in the block // so fail fast on tiny blocks. if stmts.len() < 3 { @@ -187,7 +199,7 @@ fn get_arm_identity_info<'a, 'tcx>(stmts: &'a [Statement<'tcx>]) -> Option(stmts: &'a [Statement<'tcx>]) -> Option(stmts: &'a [Statement<'tcx>]) -> Option( opt_info: &ArmIdentityInfo<'tcx>, local_decls: &IndexVec>, + local_uses: &IndexVec, + var_debug_info: &[VarDebugInfo<'tcx>], ) -> bool { trace!("testing if optimization applies..."); @@ -273,6 +302,7 @@ fn optimization_applies<'tcx>( // Verify the assigment chain consists of the form b = a; c = b; d = c; etc... if opt_info.field_tmp_assignments.is_empty() { trace!("NO: no assignments found"); + return false; } let mut last_assigned_to = opt_info.field_tmp_assignments[0].1; let source_local = last_assigned_to; @@ -285,6 +315,35 @@ fn optimization_applies<'tcx>( last_assigned_to = *l; } + // Check that the first and last used locals are only used twice + // since they are of the form: + // + // ``` + // _first = ((_x as Variant).n: ty); + // _n = _first; + // ... + // ((_y as Variant).n: ty) = _n; + // discriminant(_y) = z; + // ``` + for (l, r) in &opt_info.field_tmp_assignments { + if local_uses[*l] != 2 { + warn!("NO: FAILED assignment chain local {:?} was used more than twice", l); + return false; + } else if local_uses[*r] != 2 { + warn!("NO: FAILED assignment chain local {:?} was used more than twice", r); + return false; + } + } + + // Check that debug info only points to full Locals and not projections. + for dbg_idx in &opt_info.dbg_info_to_adjust { + let dbg_info = &var_debug_info[*dbg_idx]; + if !dbg_info.place.projection.is_empty() { + trace!("NO: debug info for {:?} had a projection {:?}", dbg_info.name, dbg_info.place); + return false; + } + } + if source_local != opt_info.local_temp_0 { trace!( "NO: start of assignment chain does not match enum variant temp: {:?} != {:?}", @@ -312,11 +371,15 @@ impl<'tcx> MirPass<'tcx> for SimplifyArmIdentity { } trace!("running SimplifyArmIdentity on {:?}", source); - let (basic_blocks, local_decls) = body.basic_blocks_and_local_decls_mut(); + let local_uses = LocalUseCounter::get_local_uses(body); + let (basic_blocks, local_decls, debug_info) = + body.basic_blocks_local_decls_mut_and_var_debug_info(); for bb in basic_blocks { - if let Some(opt_info) = get_arm_identity_info(&bb.statements) { + if let Some(opt_info) = + get_arm_identity_info(&bb.statements, local_decls.len(), debug_info) + { trace!("got opt_info = {:#?}", opt_info); - if !optimization_applies(&opt_info, local_decls) { + if !optimization_applies(&opt_info, local_decls, &local_uses, &debug_info) { debug!("optimization skipped for {:?}", source); continue; } @@ -352,23 +415,57 @@ impl<'tcx> MirPass<'tcx> for SimplifyArmIdentity { bb.statements.retain(|stmt| stmt.kind != StatementKind::Nop); + // Fix the debug info to point to the right local + for dbg_index in opt_info.dbg_info_to_adjust { + let dbg_info = &mut debug_info[dbg_index]; + assert!(dbg_info.place.projection.is_empty()); + dbg_info.place.local = opt_info.local_0; + dbg_info.place.projection = opt_info.dbg_projection; + } + trace!("block is now {:?}", bb.statements); } } } } +struct LocalUseCounter { + local_uses: IndexVec, +} + +impl LocalUseCounter { + fn get_local_uses<'tcx>(body: &Body<'tcx>) -> IndexVec { + let mut counter = LocalUseCounter { local_uses: IndexVec::from_elem(0, &body.local_decls) }; + counter.visit_body(body); + counter.local_uses + } +} + +impl<'tcx> Visitor<'tcx> for LocalUseCounter { + fn visit_local(&mut self, local: &Local, context: PlaceContext, _location: Location) { + if context.is_storage_marker() + || context == PlaceContext::NonUse(NonUseContext::VarDebugInfo) + { + return; + } + + self.local_uses[*local] += 1; + } +} + /// Match on: /// ```rust /// _LOCAL_INTO = ((_LOCAL_FROM as Variant).FIELD: TY); /// ``` -fn match_get_variant_field<'tcx>(stmt: &Statement<'tcx>) -> Option<(Local, Local, VarField<'tcx>)> { +fn match_get_variant_field<'tcx>( + stmt: &Statement<'tcx>, +) -> Option<(Local, Local, VarField<'tcx>, &'tcx List>)> { match &stmt.kind { StatementKind::Assign(box (place_into, rvalue_from)) => match rvalue_from { Rvalue::Use(Operand::Copy(pf) | Operand::Move(pf)) => { let local_into = place_into.as_local()?; let (local_from, vf) = match_variant_field_place(*pf)?; - Some((local_into, local_from, vf)) + Some((local_into, local_from, vf, pf.projection)) } _ => None, }, diff --git a/src/librustc_parse/lexer/mod.rs b/src/librustc_parse/lexer/mod.rs index 5050f03bea9b2..2b0e637c74e5a 100644 --- a/src/librustc_parse/lexer/mod.rs +++ b/src/librustc_parse/lexer/mod.rs @@ -391,7 +391,14 @@ impl<'a> StringReader<'a> { } rustc_lexer::LiteralKind::Int { base, empty_int } => { return if empty_int { - self.err_span_(start, suffix_start, "no valid digits found for number"); + self.sess + .span_diagnostic + .struct_span_err_with_code( + self.mk_sp(start, suffix_start), + "no valid digits found for number", + error_code!(E0768), + ) + .emit(); (token::Integer, sym::integer(0)) } else { self.validate_int_literal(base, start, suffix_start); diff --git a/src/librustc_parse_format/lib.rs b/src/librustc_parse_format/lib.rs index a5b5a1090cbfd..7db62f3493ede 100644 --- a/src/librustc_parse_format/lib.rs +++ b/src/librustc_parse_format/lib.rs @@ -190,7 +190,7 @@ pub struct Parser<'a> { /// Whether the source string is comes from `println!` as opposed to `format!` or `print!` append_newline: bool, /// Whether this formatting string is a literal or it comes from a macro. - is_literal: bool, + pub is_literal: bool, /// Start position of the current line. cur_line_start: usize, /// Start and end byte offset of every line of the format string. Excludes diff --git a/src/librustc_span/hygiene.rs b/src/librustc_span/hygiene.rs index 90f4cc0966080..fef1e34a23ba3 100644 --- a/src/librustc_span/hygiene.rs +++ b/src/librustc_span/hygiene.rs @@ -1,9 +1,8 @@ -//! Machinery for hygienic macros, inspired by the `MTWT[1]` paper. +//! Machinery for hygienic macros. //! -//! `[1]` Matthew Flatt, Ryan Culpepper, David Darais, and Robert Bruce Findler. 2012. -//! *Macros that work together: Compile-time bindings, partial expansion, -//! and definition contexts*. J. Funct. Program. 22, 2 (March 2012), 181-216. -//! DOI=10.1017/S0956796812000093 +//! Inspired by Matthew Flatt et al., “Macros That Work Together: Compile-Time Bindings, Partial +//! Expansion, and Definition Contexts,” *Journal of Functional Programming* 22, no. 2 +//! (March 1, 2012): 181–216, . // Hygiene data is stored in a global variable and accessed via TLS, which // means that accesses are somewhat expensive. (`HygieneData::with` diff --git a/src/librustc_span/symbol.rs b/src/librustc_span/symbol.rs index 12ac2ed1c0b19..acc2a50abe88e 100644 --- a/src/librustc_span/symbol.rs +++ b/src/librustc_span/symbol.rs @@ -342,6 +342,7 @@ symbols! { forbid, format_args, format_args_nl, + format_args_capture, from, From, from_desugaring, diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index 97d62d958ca4f..9542e7209b4cf 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -229,10 +229,10 @@ pub mod panic_count { thread_local! { static LOCAL_PANIC_COUNT: Cell = Cell::new(0) } // Sum of panic counts from all threads. The purpose of this is to have - // a fast path in `is_zero` (which is used by `panicking`). Access to - // this variable can be always be done with relaxed ordering because - // it is always guaranteed that, if `GLOBAL_PANIC_COUNT` is zero, - // `LOCAL_PANIC_COUNT` will be zero. + // a fast path in `is_zero` (which is used by `panicking`). In any particular + // thread, if that thread currently views `GLOBAL_PANIC_COUNT` as being zero, + // then `LOCAL_PANIC_COUNT` in that thread is zero. This invariant holds before + // and after increase and decrease, but not necessarily during their execution. static GLOBAL_PANIC_COUNT: AtomicUsize = AtomicUsize::new(0); pub fn increase() -> usize { @@ -263,6 +263,12 @@ pub mod panic_count { // Fast path: if `GLOBAL_PANIC_COUNT` is zero, all threads // (including the current one) will have `LOCAL_PANIC_COUNT` // equal to zero, so TLS access can be avoided. + // + // In terms of performance, a relaxed atomic load is similar to a normal + // aligned memory read (e.g., a mov instruction in x86), but with some + // compiler optimization restrictions. On the other hand, a TLS access + // might require calling a non-inlinable function (such as `__tls_get_addr` + // when using the GD TLS model). true } else { is_zero_slow_path() diff --git a/src/test/mir-opt/issue-73223.rs b/src/test/mir-opt/issue-73223.rs new file mode 100644 index 0000000000000..d93805e6cd176 --- /dev/null +++ b/src/test/mir-opt/issue-73223.rs @@ -0,0 +1,13 @@ +fn main() { + let split = match Some(1) { + Some(v) => v, + None => return, + }; + + let _prev = Some(split); + assert_eq!(split, 1); +} + +// EMIT_MIR_FOR_EACH_BIT_WIDTH +// EMIT_MIR rustc.main.SimplifyArmIdentity.diff +// EMIT_MIR rustc.main.PreCodegen.diff diff --git a/src/test/mir-opt/issue-73223/32bit/rustc.main.PreCodegen.diff b/src/test/mir-opt/issue-73223/32bit/rustc.main.PreCodegen.diff new file mode 100644 index 0000000000000..59c00e1b96f96 --- /dev/null +++ b/src/test/mir-opt/issue-73223/32bit/rustc.main.PreCodegen.diff @@ -0,0 +1,252 @@ +- // MIR for `main` before PreCodegen ++ // MIR for `main` after PreCodegen + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue-73223.rs:1:11: 1:11 + let mut _1: std::option::Option; // in scope 0 at $DIR/issue-73223.rs:2:23: 2:30 + let _2: i32; // in scope 0 at $DIR/issue-73223.rs:3:14: 3:15 + let mut _4: i32; // in scope 0 at $DIR/issue-73223.rs:7:22: 7:27 + let mut _5: (&i32, &i32); // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _6: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _9: bool; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _10: bool; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _11: i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _12: i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _13: &std::fmt::Arguments; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let _14: std::fmt::Arguments; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _15: &[&str]; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _16: &[std::fmt::ArgumentV1]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let _17: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let _18: [std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _19: (&&i32, &&i32); // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _20: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _21: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _22: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _23: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _26: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _27: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _28: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _29: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + scope 1 { + debug split => _2; // in scope 1 at $DIR/issue-73223.rs:2:9: 2:14 + let _3: std::option::Option; // in scope 1 at $DIR/issue-73223.rs:7:9: 7:14 + scope 3 { + debug _prev => _3; // in scope 3 at $DIR/issue-73223.rs:7:9: 7:14 + let _7: &i32; // in scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _8: &i32; // in scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + scope 4 { + debug left_val => _7; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + debug right_val => _8; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _24: &&i32; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _25: &&i32; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + scope 5 { + debug arg0 => _24; // in scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + debug arg1 => _25; // in scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + scope 6 { + debug x => _24; // in scope 6 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + debug f => _27; // in scope 6 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + let mut _30: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _31: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + } + scope 8 { + debug x => _25; // in scope 8 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + debug f => _29; // in scope 8 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + let mut _32: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _33: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + } + } + scope 10 { + debug pieces => _15; // in scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + debug args => _16; // in scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + let mut _34: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL + } + } + } + } + scope 2 { + debug v => _2; // in scope 2 at $DIR/issue-73223.rs:3:14: 3:15 + } + scope 7 { + } + scope 9 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 + ((_1 as Some).0: i32) = const 1_i32; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/issue-73223.rs:2:28: 2:29 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + discriminant(_1) = 1; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 + _2 = ((_1 as Some).0: i32); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 + StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7 + StorageLive(_3); // scope 1 at $DIR/issue-73223.rs:7:9: 7:14 + StorageLive(_4); // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 + _4 = _2; // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 + ((_3 as Some).0: i32) = move _4; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 + discriminant(_3) = 1; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 + StorageDead(_4); // scope 1 at $DIR/issue-73223.rs:7:27: 7:28 + StorageLive(_5); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_6); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _6 = &_2; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + (_5.0: &i32) = move _6; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + (_5.1: &i32) = const main::promoted[1]; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + // ty::Const + // + ty: &i32 + // + val: Unevaluated(DefId(0:3 ~ issue_73223[317d]::main[0]), [], Some(promoted[1])) + // mir::Constant + // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL + // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:3 ~ issue_73223[317d]::main[0]), [], Some(promoted[1])) } + StorageDead(_6); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_7); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _7 = (_5.0: &i32); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_8); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _8 = (_5.1: &i32); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_9); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_10); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_11); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _11 = (*_7); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_12); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _12 = (*_8); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _10 = Eq(move _11, move _12); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_12); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_11); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _9 = Not(move _10); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_10); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + switchInt(_9) -> [false: bb1, otherwise: bb2]; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + } + + bb1: { + StorageDead(_9); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_8); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_7); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_5); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 + // ty::Const + // + ty: () + // + val: Value(Scalar()) + // mir::Constant + // + span: $DIR/issue-73223.rs:1:11: 9:2 + // + literal: Const { ty: (), val: Value(Scalar()) } + StorageDead(_3); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2 + return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 + } + + bb2: { + StorageLive(_14); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _15 = const main::promoted[0] as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + // ty::Const + // + ty: &[&str; 3] + // + val: Unevaluated(DefId(0:3 ~ issue_73223[317d]::main[0]), [], Some(promoted[0])) + // mir::Constant + // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL + // + literal: Const { ty: &[&str; 3], val: Unevaluated(DefId(0:3 ~ issue_73223[317d]::main[0]), [], Some(promoted[0])) } + StorageLive(_18); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_19); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_20); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_21); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _21 = _7; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _20 = &_21; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_22); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_23); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _23 = _8; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _22 = &_23; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + (_19.0: &&i32) = move _20; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + (_19.1: &&i32) = move _22; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_22); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_20); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _24 = (_19.0: &&i32); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _25 = (_19.1: &&i32); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_26); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + _27 = const <&i32 as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + // ty::Const + // + ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL + // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } + StorageLive(_30); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _30 = const std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _27) -> bb3; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // ty::Const + // + ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } + } + + bb3: { + StorageLive(_31); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _31 = const std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _24) -> bb4; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // ty::Const + // + ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } + } + + bb4: { + (_26.0: &core::fmt::Opaque) = move _31; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_26.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _30; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_31); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_30); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_28); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + _29 = const <&i32 as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + // ty::Const + // + ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL + // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } + StorageLive(_32); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _32 = const std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _29) -> bb5; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // ty::Const + // + ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } + } + + bb5: { + StorageLive(_33); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _33 = const std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _25) -> bb6; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // ty::Const + // + ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } + } + + bb6: { + (_28.0: &core::fmt::Opaque) = move _33; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_28.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _32; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_33); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_32); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _18 = [move _26, move _28]; // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_28); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_26); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + _17 = &_18; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_34); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + discriminant(_34) = 0; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_14.0: &[&str]) = move _15; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_14.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _34; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_14.2: &[std::fmt::ArgumentV1]) = move _16; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_34); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _13 = &_14; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + const std::rt::begin_panic_fmt(move _13); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + // ty::Const + // + ty: for<'r, 's> fn(&'r std::fmt::Arguments<'s>) -> ! {std::rt::begin_panic_fmt} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libstd/macros.rs:LL:COL + // + literal: Const { ty: for<'r, 's> fn(&'r std::fmt::Arguments<'s>) -> ! {std::rt::begin_panic_fmt}, val: Value(Scalar()) } + } + } + diff --git a/src/test/mir-opt/issue-73223/32bit/rustc.main.SimplifyArmIdentity.diff b/src/test/mir-opt/issue-73223/32bit/rustc.main.SimplifyArmIdentity.diff new file mode 100644 index 0000000000000..e5b4a0328808f --- /dev/null +++ b/src/test/mir-opt/issue-73223/32bit/rustc.main.SimplifyArmIdentity.diff @@ -0,0 +1,376 @@ +- // MIR for `main` before SimplifyArmIdentity ++ // MIR for `main` after SimplifyArmIdentity + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue-73223.rs:1:11: 1:11 + let _1: i32; // in scope 0 at $DIR/issue-73223.rs:2:9: 2:14 + let mut _2: std::option::Option; // in scope 0 at $DIR/issue-73223.rs:2:23: 2:30 + let mut _3: isize; // in scope 0 at $DIR/issue-73223.rs:3:9: 3:16 + let _4: i32; // in scope 0 at $DIR/issue-73223.rs:3:14: 3:15 + let mut _5: !; // in scope 0 at $DIR/issue-73223.rs:4:17: 4:23 + let mut _7: i32; // in scope 0 at $DIR/issue-73223.rs:7:22: 7:27 + let _8: (); // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _9: (&i32, &i32); // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _10: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _11: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _12: i32; // in scope 0 at $DIR/issue-73223.rs:8:23: 8:24 + let mut _15: bool; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _16: bool; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _17: i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _18: i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _19: !; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _20: &std::fmt::Arguments; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let _21: &std::fmt::Arguments; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let _22: std::fmt::Arguments; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _23: &[&str]; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _24: &[&str; 3]; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _25: &[&str; 3]; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _26: [&str; 3]; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _27: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _28: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _29: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _30: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _31: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _32: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _33: &[std::fmt::ArgumentV1]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _34: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let _35: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let _36: [std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _37: (&&i32, &&i32); // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _38: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _39: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _40: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _41: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _44: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _45: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _46: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _47: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _48: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _49: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + scope 1 { + debug split => _1; // in scope 1 at $DIR/issue-73223.rs:2:9: 2:14 + let _6: std::option::Option; // in scope 1 at $DIR/issue-73223.rs:7:9: 7:14 + scope 3 { + debug _prev => _6; // in scope 3 at $DIR/issue-73223.rs:7:9: 7:14 + let _13: &i32; // in scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _14: &i32; // in scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _51: &i32; // in scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + scope 4 { + debug left_val => _13; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + debug right_val => _14; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _42: &&i32; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _43: &&i32; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _50: &[&str; 3]; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + scope 5 { + debug arg0 => _42; // in scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + debug arg1 => _43; // in scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + scope 6 { + debug x => _45; // in scope 6 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + debug f => _46; // in scope 6 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + let mut _52: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _53: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _54: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _55: &&i32; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + } + scope 8 { + debug x => _48; // in scope 8 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + debug f => _49; // in scope 8 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + let mut _56: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _57: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _58: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _59: &&i32; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + } + } + scope 10 { + debug pieces => _23; // in scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + debug args => _33; // in scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + let mut _60: &[&str]; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _61: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _62: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL + } + } + } + } + scope 2 { + debug v => _4; // in scope 2 at $DIR/issue-73223.rs:3:14: 3:15 + } + scope 7 { + } + scope 9 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/issue-73223.rs:2:9: 2:14 + StorageLive(_2); // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 + ((_2 as Some).0: i32) = const 1_i32; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/issue-73223.rs:2:28: 2:29 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + discriminant(_2) = 1; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 + _3 = const 1_isize; // scope 0 at $DIR/issue-73223.rs:3:9: 3:16 + // ty::Const + // + ty: isize + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/issue-73223.rs:3:9: 3:16 + // + literal: Const { ty: isize, val: Value(Scalar(0x00000001)) } + goto -> bb2; // scope 0 at $DIR/issue-73223.rs:3:9: 3:16 + } + + bb1: { + _0 = const (); // scope 0 at $DIR/issue-73223.rs:4:17: 4:23 + // ty::Const + // + ty: () + // + val: Value(Scalar()) + // mir::Constant + // + span: $DIR/issue-73223.rs:4:17: 4:23 + // + literal: Const { ty: (), val: Value(Scalar()) } + StorageDead(_2); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7 + StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 + goto -> bb3; // scope 0 at $DIR/issue-73223.rs:4:17: 4:23 + } + + bb2: { + StorageLive(_4); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 + _4 = ((_2 as Some).0: i32); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 + _1 = _4; // scope 2 at $DIR/issue-73223.rs:3:20: 3:21 + StorageDead(_4); // scope 0 at $DIR/issue-73223.rs:3:21: 3:22 + StorageDead(_2); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7 + StorageLive(_6); // scope 1 at $DIR/issue-73223.rs:7:9: 7:14 + StorageLive(_7); // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 + _7 = _1; // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 + ((_6 as Some).0: i32) = move _7; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 + discriminant(_6) = 1; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 + StorageDead(_7); // scope 1 at $DIR/issue-73223.rs:7:27: 7:28 + StorageLive(_8); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_9); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_10); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _10 = &_1; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_11); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _51 = const main::promoted[1]; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + // ty::Const + // + ty: &i32 + // + val: Unevaluated(DefId(0:3 ~ issue_73223[317d]::main[0]), [], Some(promoted[1])) + // mir::Constant + // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL + // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:3 ~ issue_73223[317d]::main[0]), [], Some(promoted[1])) } + _11 = _51; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + (_9.0: &i32) = move _10; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + (_9.1: &i32) = move _11; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_11); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_10); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_13); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _13 = (_9.0: &i32); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_14); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _14 = (_9.1: &i32); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_15); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_16); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_17); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _17 = (*_13); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_18); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _18 = (*_14); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _16 = Eq(move _17, move _18); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_18); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_17); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _15 = Not(move _16); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_16); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + switchInt(_15) -> [false: bb4, otherwise: bb5]; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + } + + bb3: { + return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 + } + + bb4: { + _8 = const (); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + // ty::Const + // + ty: () + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL + // + literal: Const { ty: (), val: Value(Scalar()) } + StorageDead(_15); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_14); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_13); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_9); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_8); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 + // ty::Const + // + ty: () + // + val: Value(Scalar()) + // mir::Constant + // + span: $DIR/issue-73223.rs:1:11: 9:2 + // + literal: Const { ty: (), val: Value(Scalar()) } + StorageDead(_6); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2 + StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 + goto -> bb3; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 + } + + bb5: { + StorageLive(_19); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_20); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_21); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_22); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_23); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_24); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_25); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _50 = const main::promoted[0]; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + // ty::Const + // + ty: &[&str; 3] + // + val: Unevaluated(DefId(0:3 ~ issue_73223[317d]::main[0]), [], Some(promoted[0])) + // mir::Constant + // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL + // + literal: Const { ty: &[&str; 3], val: Unevaluated(DefId(0:3 ~ issue_73223[317d]::main[0]), [], Some(promoted[0])) } + _25 = _50; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _24 = _25; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _23 = move _24 as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_24); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_33); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_34); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_35); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_36); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_37); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_38); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_39); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _39 = _13; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _38 = &_39; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_40); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_41); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _41 = _14; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _40 = &_41; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + (_37.0: &&i32) = move _38; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + (_37.1: &&i32) = move _40; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_40); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_38); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_42); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _42 = (_37.0: &&i32); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_43); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _43 = (_37.1: &&i32); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_44); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_45); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _45 = _42; // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_46); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _46 = const <&i32 as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + // ty::Const + // + ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL + // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } + StorageLive(_52); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_53); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _53 = _46; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _52 = const std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _53) -> bb6; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // ty::Const + // + ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } + } + + bb6: { + StorageDead(_53); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_54); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_55); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _55 = _45; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _54 = const std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _55) -> bb7; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // ty::Const + // + ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } + } + + bb7: { + StorageDead(_55); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_44.0: &core::fmt::Opaque) = move _54; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_44.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _52; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_54); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_52); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_46); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_45); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_47); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_48); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _48 = _43; // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_49); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _49 = const <&i32 as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + // ty::Const + // + ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL + // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } + StorageLive(_56); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_57); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _57 = _49; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _56 = const std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _57) -> bb8; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // ty::Const + // + ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } + } + + bb8: { + StorageDead(_57); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_58); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_59); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _59 = _48; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _58 = const std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _59) -> bb9; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // ty::Const + // + ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } + } + + bb9: { + StorageDead(_59); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_47.0: &core::fmt::Opaque) = move _58; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_47.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _56; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_58); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_56); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_49); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_48); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + _36 = [move _44, move _47]; // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_47); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_44); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_43); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_42); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _35 = &_36; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _34 = _35; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _33 = move _34 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_34); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_60); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _60 = _23; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_61); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + discriminant(_61) = 0; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_62); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _62 = _33; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_22.0: &[&str]) = move _60; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_22.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _61; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_22.2: &[std::fmt::ArgumentV1]) = move _62; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_62); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_61); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_60); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_33); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_23); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _21 = &_22; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _20 = _21; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + const std::rt::begin_panic_fmt(move _20); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + // ty::Const + // + ty: for<'r, 's> fn(&'r std::fmt::Arguments<'s>) -> ! {std::rt::begin_panic_fmt} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libstd/macros.rs:LL:COL + // + literal: Const { ty: for<'r, 's> fn(&'r std::fmt::Arguments<'s>) -> ! {std::rt::begin_panic_fmt}, val: Value(Scalar()) } + } + } + diff --git a/src/test/mir-opt/issue-73223/64bit/rustc.main.PreCodegen.diff b/src/test/mir-opt/issue-73223/64bit/rustc.main.PreCodegen.diff new file mode 100644 index 0000000000000..59c00e1b96f96 --- /dev/null +++ b/src/test/mir-opt/issue-73223/64bit/rustc.main.PreCodegen.diff @@ -0,0 +1,252 @@ +- // MIR for `main` before PreCodegen ++ // MIR for `main` after PreCodegen + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue-73223.rs:1:11: 1:11 + let mut _1: std::option::Option; // in scope 0 at $DIR/issue-73223.rs:2:23: 2:30 + let _2: i32; // in scope 0 at $DIR/issue-73223.rs:3:14: 3:15 + let mut _4: i32; // in scope 0 at $DIR/issue-73223.rs:7:22: 7:27 + let mut _5: (&i32, &i32); // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _6: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _9: bool; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _10: bool; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _11: i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _12: i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _13: &std::fmt::Arguments; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let _14: std::fmt::Arguments; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _15: &[&str]; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _16: &[std::fmt::ArgumentV1]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let _17: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let _18: [std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _19: (&&i32, &&i32); // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _20: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _21: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _22: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _23: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _26: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _27: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _28: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _29: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + scope 1 { + debug split => _2; // in scope 1 at $DIR/issue-73223.rs:2:9: 2:14 + let _3: std::option::Option; // in scope 1 at $DIR/issue-73223.rs:7:9: 7:14 + scope 3 { + debug _prev => _3; // in scope 3 at $DIR/issue-73223.rs:7:9: 7:14 + let _7: &i32; // in scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _8: &i32; // in scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + scope 4 { + debug left_val => _7; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + debug right_val => _8; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _24: &&i32; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _25: &&i32; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + scope 5 { + debug arg0 => _24; // in scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + debug arg1 => _25; // in scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + scope 6 { + debug x => _24; // in scope 6 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + debug f => _27; // in scope 6 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + let mut _30: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _31: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + } + scope 8 { + debug x => _25; // in scope 8 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + debug f => _29; // in scope 8 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + let mut _32: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _33: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + } + } + scope 10 { + debug pieces => _15; // in scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + debug args => _16; // in scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + let mut _34: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL + } + } + } + } + scope 2 { + debug v => _2; // in scope 2 at $DIR/issue-73223.rs:3:14: 3:15 + } + scope 7 { + } + scope 9 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 + ((_1 as Some).0: i32) = const 1_i32; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/issue-73223.rs:2:28: 2:29 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + discriminant(_1) = 1; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 + _2 = ((_1 as Some).0: i32); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 + StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7 + StorageLive(_3); // scope 1 at $DIR/issue-73223.rs:7:9: 7:14 + StorageLive(_4); // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 + _4 = _2; // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 + ((_3 as Some).0: i32) = move _4; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 + discriminant(_3) = 1; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 + StorageDead(_4); // scope 1 at $DIR/issue-73223.rs:7:27: 7:28 + StorageLive(_5); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_6); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _6 = &_2; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + (_5.0: &i32) = move _6; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + (_5.1: &i32) = const main::promoted[1]; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + // ty::Const + // + ty: &i32 + // + val: Unevaluated(DefId(0:3 ~ issue_73223[317d]::main[0]), [], Some(promoted[1])) + // mir::Constant + // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL + // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:3 ~ issue_73223[317d]::main[0]), [], Some(promoted[1])) } + StorageDead(_6); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_7); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _7 = (_5.0: &i32); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_8); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _8 = (_5.1: &i32); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_9); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_10); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_11); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _11 = (*_7); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_12); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _12 = (*_8); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _10 = Eq(move _11, move _12); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_12); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_11); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _9 = Not(move _10); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_10); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + switchInt(_9) -> [false: bb1, otherwise: bb2]; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + } + + bb1: { + StorageDead(_9); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_8); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_7); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_5); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 + // ty::Const + // + ty: () + // + val: Value(Scalar()) + // mir::Constant + // + span: $DIR/issue-73223.rs:1:11: 9:2 + // + literal: Const { ty: (), val: Value(Scalar()) } + StorageDead(_3); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2 + return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 + } + + bb2: { + StorageLive(_14); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _15 = const main::promoted[0] as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + // ty::Const + // + ty: &[&str; 3] + // + val: Unevaluated(DefId(0:3 ~ issue_73223[317d]::main[0]), [], Some(promoted[0])) + // mir::Constant + // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL + // + literal: Const { ty: &[&str; 3], val: Unevaluated(DefId(0:3 ~ issue_73223[317d]::main[0]), [], Some(promoted[0])) } + StorageLive(_18); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_19); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_20); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_21); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _21 = _7; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _20 = &_21; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_22); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_23); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _23 = _8; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _22 = &_23; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + (_19.0: &&i32) = move _20; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + (_19.1: &&i32) = move _22; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_22); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_20); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _24 = (_19.0: &&i32); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _25 = (_19.1: &&i32); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_26); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + _27 = const <&i32 as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + // ty::Const + // + ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL + // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } + StorageLive(_30); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _30 = const std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _27) -> bb3; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // ty::Const + // + ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } + } + + bb3: { + StorageLive(_31); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _31 = const std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _24) -> bb4; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // ty::Const + // + ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } + } + + bb4: { + (_26.0: &core::fmt::Opaque) = move _31; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_26.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _30; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_31); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_30); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_28); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + _29 = const <&i32 as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + // ty::Const + // + ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL + // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } + StorageLive(_32); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _32 = const std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _29) -> bb5; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // ty::Const + // + ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } + } + + bb5: { + StorageLive(_33); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _33 = const std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _25) -> bb6; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // ty::Const + // + ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } + } + + bb6: { + (_28.0: &core::fmt::Opaque) = move _33; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_28.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _32; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_33); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_32); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _18 = [move _26, move _28]; // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_28); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_26); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + _17 = &_18; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_34); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + discriminant(_34) = 0; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_14.0: &[&str]) = move _15; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_14.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _34; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_14.2: &[std::fmt::ArgumentV1]) = move _16; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_34); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _13 = &_14; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + const std::rt::begin_panic_fmt(move _13); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + // ty::Const + // + ty: for<'r, 's> fn(&'r std::fmt::Arguments<'s>) -> ! {std::rt::begin_panic_fmt} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libstd/macros.rs:LL:COL + // + literal: Const { ty: for<'r, 's> fn(&'r std::fmt::Arguments<'s>) -> ! {std::rt::begin_panic_fmt}, val: Value(Scalar()) } + } + } + diff --git a/src/test/mir-opt/issue-73223/64bit/rustc.main.SimplifyArmIdentity.diff b/src/test/mir-opt/issue-73223/64bit/rustc.main.SimplifyArmIdentity.diff new file mode 100644 index 0000000000000..0c2651dc3c68d --- /dev/null +++ b/src/test/mir-opt/issue-73223/64bit/rustc.main.SimplifyArmIdentity.diff @@ -0,0 +1,376 @@ +- // MIR for `main` before SimplifyArmIdentity ++ // MIR for `main` after SimplifyArmIdentity + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue-73223.rs:1:11: 1:11 + let _1: i32; // in scope 0 at $DIR/issue-73223.rs:2:9: 2:14 + let mut _2: std::option::Option; // in scope 0 at $DIR/issue-73223.rs:2:23: 2:30 + let mut _3: isize; // in scope 0 at $DIR/issue-73223.rs:3:9: 3:16 + let _4: i32; // in scope 0 at $DIR/issue-73223.rs:3:14: 3:15 + let mut _5: !; // in scope 0 at $DIR/issue-73223.rs:4:17: 4:23 + let mut _7: i32; // in scope 0 at $DIR/issue-73223.rs:7:22: 7:27 + let _8: (); // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _9: (&i32, &i32); // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _10: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _11: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _12: i32; // in scope 0 at $DIR/issue-73223.rs:8:23: 8:24 + let mut _15: bool; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _16: bool; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _17: i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _18: i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _19: !; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _20: &std::fmt::Arguments; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let _21: &std::fmt::Arguments; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let _22: std::fmt::Arguments; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _23: &[&str]; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _24: &[&str; 3]; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _25: &[&str; 3]; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _26: [&str; 3]; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _27: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _28: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _29: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _30: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _31: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _32: &str; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _33: &[std::fmt::ArgumentV1]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _34: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let _35: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let _36: [std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _37: (&&i32, &&i32); // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _38: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _39: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _40: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _41: &i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _44: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _45: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _46: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _47: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _48: &&i32; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _49: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 0 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + scope 1 { + debug split => _1; // in scope 1 at $DIR/issue-73223.rs:2:9: 2:14 + let _6: std::option::Option; // in scope 1 at $DIR/issue-73223.rs:7:9: 7:14 + scope 3 { + debug _prev => _6; // in scope 3 at $DIR/issue-73223.rs:7:9: 7:14 + let _13: &i32; // in scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _14: &i32; // in scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _51: &i32; // in scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + scope 4 { + debug left_val => _13; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + debug right_val => _14; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _42: &&i32; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let _43: &&i32; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + let mut _50: &[&str; 3]; // in scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + scope 5 { + debug arg0 => _42; // in scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + debug arg1 => _43; // in scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + scope 6 { + debug x => _45; // in scope 6 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + debug f => _46; // in scope 6 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + let mut _52: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _53: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _54: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _55: &&i32; // in scope 6 at $SRC_DIR/libstd/macros.rs:LL:COL + } + scope 8 { + debug x => _48; // in scope 8 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + debug f => _49; // in scope 8 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + let mut _56: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _57: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _58: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _59: &&i32; // in scope 8 at $SRC_DIR/libstd/macros.rs:LL:COL + } + } + scope 10 { + debug pieces => _23; // in scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + debug args => _33; // in scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + let mut _60: &[&str]; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _61: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _62: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/libstd/macros.rs:LL:COL + } + } + } + } + scope 2 { + debug v => _4; // in scope 2 at $DIR/issue-73223.rs:3:14: 3:15 + } + scope 7 { + } + scope 9 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/issue-73223.rs:2:9: 2:14 + StorageLive(_2); // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 + ((_2 as Some).0: i32) = const 1_i32; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/issue-73223.rs:2:28: 2:29 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + discriminant(_2) = 1; // scope 0 at $DIR/issue-73223.rs:2:23: 2:30 + _3 = const 1_isize; // scope 0 at $DIR/issue-73223.rs:3:9: 3:16 + // ty::Const + // + ty: isize + // + val: Value(Scalar(0x0000000000000001)) + // mir::Constant + // + span: $DIR/issue-73223.rs:3:9: 3:16 + // + literal: Const { ty: isize, val: Value(Scalar(0x0000000000000001)) } + goto -> bb2; // scope 0 at $DIR/issue-73223.rs:3:9: 3:16 + } + + bb1: { + _0 = const (); // scope 0 at $DIR/issue-73223.rs:4:17: 4:23 + // ty::Const + // + ty: () + // + val: Value(Scalar()) + // mir::Constant + // + span: $DIR/issue-73223.rs:4:17: 4:23 + // + literal: Const { ty: (), val: Value(Scalar()) } + StorageDead(_2); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7 + StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 + goto -> bb3; // scope 0 at $DIR/issue-73223.rs:4:17: 4:23 + } + + bb2: { + StorageLive(_4); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 + _4 = ((_2 as Some).0: i32); // scope 0 at $DIR/issue-73223.rs:3:14: 3:15 + _1 = _4; // scope 2 at $DIR/issue-73223.rs:3:20: 3:21 + StorageDead(_4); // scope 0 at $DIR/issue-73223.rs:3:21: 3:22 + StorageDead(_2); // scope 0 at $DIR/issue-73223.rs:5:6: 5:7 + StorageLive(_6); // scope 1 at $DIR/issue-73223.rs:7:9: 7:14 + StorageLive(_7); // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 + _7 = _1; // scope 1 at $DIR/issue-73223.rs:7:22: 7:27 + ((_6 as Some).0: i32) = move _7; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 + discriminant(_6) = 1; // scope 1 at $DIR/issue-73223.rs:7:17: 7:28 + StorageDead(_7); // scope 1 at $DIR/issue-73223.rs:7:27: 7:28 + StorageLive(_8); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_9); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_10); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _10 = &_1; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_11); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _51 = const main::promoted[1]; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + // ty::Const + // + ty: &i32 + // + val: Unevaluated(DefId(0:3 ~ issue_73223[317d]::main[0]), [], Some(promoted[1])) + // mir::Constant + // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL + // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:3 ~ issue_73223[317d]::main[0]), [], Some(promoted[1])) } + _11 = _51; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + (_9.0: &i32) = move _10; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + (_9.1: &i32) = move _11; // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_11); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_10); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_13); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _13 = (_9.0: &i32); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_14); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _14 = (_9.1: &i32); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_15); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_16); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_17); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _17 = (*_13); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_18); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _18 = (*_14); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _16 = Eq(move _17, move _18); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_18); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_17); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _15 = Not(move _16); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_16); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + switchInt(_15) -> [false: bb4, otherwise: bb5]; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + } + + bb3: { + return; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 + } + + bb4: { + _8 = const (); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + // ty::Const + // + ty: () + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL + // + literal: Const { ty: (), val: Value(Scalar()) } + StorageDead(_15); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_14); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_13); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_9); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_8); // scope 3 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _0 = const (); // scope 0 at $DIR/issue-73223.rs:1:11: 9:2 + // ty::Const + // + ty: () + // + val: Value(Scalar()) + // mir::Constant + // + span: $DIR/issue-73223.rs:1:11: 9:2 + // + literal: Const { ty: (), val: Value(Scalar()) } + StorageDead(_6); // scope 1 at $DIR/issue-73223.rs:9:1: 9:2 + StorageDead(_1); // scope 0 at $DIR/issue-73223.rs:9:1: 9:2 + goto -> bb3; // scope 0 at $DIR/issue-73223.rs:9:2: 9:2 + } + + bb5: { + StorageLive(_19); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_20); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_21); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_22); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_23); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_24); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_25); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _50 = const main::promoted[0]; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + // ty::Const + // + ty: &[&str; 3] + // + val: Unevaluated(DefId(0:3 ~ issue_73223[317d]::main[0]), [], Some(promoted[0])) + // mir::Constant + // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL + // + literal: Const { ty: &[&str; 3], val: Unevaluated(DefId(0:3 ~ issue_73223[317d]::main[0]), [], Some(promoted[0])) } + _25 = _50; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _24 = _25; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _23 = move _24 as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageDead(_24); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_33); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_34); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_35); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_36); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_37); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_38); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_39); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _39 = _13; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _38 = &_39; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_40); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_41); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _41 = _14; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _40 = &_41; // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + (_37.0: &&i32) = move _38; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + (_37.1: &&i32) = move _40; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_40); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_38); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_42); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _42 = (_37.0: &&i32); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_43); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _43 = (_37.1: &&i32); // scope 4 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_44); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_45); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _45 = _42; // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_46); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _46 = const <&i32 as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + // ty::Const + // + ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL + // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } + StorageLive(_52); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_53); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _53 = _46; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _52 = const std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _53) -> bb6; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // ty::Const + // + ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } + } + + bb6: { + StorageDead(_53); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_54); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_55); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _55 = _45; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _54 = const std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _55) -> bb7; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // ty::Const + // + ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } + } + + bb7: { + StorageDead(_55); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_44.0: &core::fmt::Opaque) = move _54; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_44.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _52; // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_54); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_52); // scope 7 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_46); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_45); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_47); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_48); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _48 = _43; // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + StorageLive(_49); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + _49 = const <&i32 as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)); // scope 5 at $SRC_DIR/libcore/macros/mod.rs:LL:COL + // ty::Const + // + ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/macros/mod.rs:LL:COL + // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } + StorageLive(_56); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_57); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _57 = _49; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _56 = const std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _57) -> bb8; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // ty::Const + // + ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } + } + + bb8: { + StorageDead(_57); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_58); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_59); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _59 = _48; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _58 = const std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>(move _59) -> bb9; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // ty::Const + // + ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libcore/fmt/mod.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&&i32) -> &core::fmt::Opaque {std::intrinsics::transmute::<&&i32, &core::fmt::Opaque>}, val: Value(Scalar()) } + } + + bb9: { + StorageDead(_59); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_47.0: &core::fmt::Opaque) = move _58; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_47.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _56; // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_58); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_56); // scope 9 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_49); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_48); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + _36 = [move _44, move _47]; // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_47); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_44); // scope 5 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_43); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_42); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _35 = &_36; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _34 = _35; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _33 = move _34 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_34); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageLive(_60); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _60 = _23; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_61); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + discriminant(_61) = 0; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageLive(_62); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + _62 = _33; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_22.0: &[&str]) = move _60; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_22.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _61; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + (_22.2: &[std::fmt::ArgumentV1]) = move _62; // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_62); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_61); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_60); // scope 10 at $SRC_DIR/libcore/fmt/mod.rs:LL:COL + StorageDead(_33); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + StorageDead(_23); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _21 = &_22; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + _20 = _21; // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + const std::rt::begin_panic_fmt(move _20); // scope 4 at $SRC_DIR/libstd/macros.rs:LL:COL + // ty::Const + // + ty: for<'r, 's> fn(&'r std::fmt::Arguments<'s>) -> ! {std::rt::begin_panic_fmt} + // + val: Value(Scalar()) + // mir::Constant + // + span: $SRC_DIR/libstd/macros.rs:LL:COL + // + literal: Const { ty: for<'r, 's> fn(&'r std::fmt::Arguments<'s>) -> ! {std::rt::begin_panic_fmt}, val: Value(Scalar()) } + } + } + diff --git a/src/test/mir-opt/simplify-locals-removes-unused-discriminant-reads/32bit/rustc.map.SimplifyLocals.diff b/src/test/mir-opt/simplify-locals-removes-unused-discriminant-reads/32bit/rustc.map.SimplifyLocals.diff index f0b696118e996..551f6db08a599 100644 --- a/src/test/mir-opt/simplify-locals-removes-unused-discriminant-reads/32bit/rustc.map.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify-locals-removes-unused-discriminant-reads/32bit/rustc.map.SimplifyLocals.diff @@ -5,12 +5,12 @@ debug x => _1; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:1:8: 1:9 let mut _0: std::option::Option>; // return place in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:1:31: 1:46 let mut _2: isize; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:3:9: 3:13 - let _3: std::boxed::Box<()>; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:14: 4:15 +- let _3: std::boxed::Box<()>; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:14: 4:15 - let mut _4: std::boxed::Box<()>; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:25: 4:26 - let mut _5: isize; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:6:1: 6:2 - let mut _6: isize; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:6:1: 6:2 scope 1 { - debug x => _3; // in scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:14: 4:15 + debug x => ((_0 as Some).0: std::boxed::Box<()>); // in scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:14: 4:15 } bb0: { diff --git a/src/test/mir-opt/simplify-locals-removes-unused-discriminant-reads/64bit/rustc.map.SimplifyLocals.diff b/src/test/mir-opt/simplify-locals-removes-unused-discriminant-reads/64bit/rustc.map.SimplifyLocals.diff index 1ac6eb85441f5..388b382b86daf 100644 --- a/src/test/mir-opt/simplify-locals-removes-unused-discriminant-reads/64bit/rustc.map.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify-locals-removes-unused-discriminant-reads/64bit/rustc.map.SimplifyLocals.diff @@ -5,12 +5,12 @@ debug x => _1; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:1:8: 1:9 let mut _0: std::option::Option>; // return place in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:1:31: 1:46 let mut _2: isize; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:3:9: 3:13 - let _3: std::boxed::Box<()>; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:14: 4:15 +- let _3: std::boxed::Box<()>; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:14: 4:15 - let mut _4: std::boxed::Box<()>; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:25: 4:26 - let mut _5: isize; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:6:1: 6:2 - let mut _6: isize; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:6:1: 6:2 scope 1 { - debug x => _3; // in scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:14: 4:15 + debug x => ((_0 as Some).0: std::boxed::Box<()>); // in scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:4:14: 4:15 } bb0: { diff --git a/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyArmIdentity.diff index 7f8366309c089..e6d794a71508c 100644 --- a/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyArmIdentity.diff @@ -15,22 +15,27 @@ let _10: u32; // in scope 0 at $DIR/simplify_try.rs:6:13: 6:15 let mut _11: u32; // in scope 0 at $DIR/simplify_try.rs:7:8: 7:9 scope 1 { - debug y => _2; // in scope 1 at $DIR/simplify_try.rs:6:9: 6:10 +- debug y => _2; // in scope 1 at $DIR/simplify_try.rs:6:9: 6:10 ++ debug y => ((_0 as Ok).0: u32); // in scope 1 at $DIR/simplify_try.rs:6:9: 6:10 } scope 2 { - debug err => _6; // in scope 2 at $DIR/simplify_try.rs:6:14: 6:15 +- debug err => _6; // in scope 2 at $DIR/simplify_try.rs:6:14: 6:15 ++ debug err => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify_try.rs:6:14: 6:15 scope 3 { scope 7 { - debug t => _9; // in scope 7 at $SRC_DIR/libcore/convert/mod.rs:LL:COL +- debug t => _9; // in scope 7 at $SRC_DIR/libcore/convert/mod.rs:LL:COL ++ debug t => ((_0 as Err).0: i32); // in scope 7 at $SRC_DIR/libcore/convert/mod.rs:LL:COL } scope 8 { - debug v => _8; // in scope 8 at $SRC_DIR/libcore/result.rs:LL:COL +- debug v => _8; // in scope 8 at $SRC_DIR/libcore/result.rs:LL:COL ++ debug v => ((_0 as Err).0: i32); // in scope 8 at $SRC_DIR/libcore/result.rs:LL:COL let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:6:14: 6:15 } } } scope 4 { - debug val => _10; // in scope 4 at $DIR/simplify_try.rs:6:13: 6:15 +- debug val => _10; // in scope 4 at $DIR/simplify_try.rs:6:13: 6:15 ++ debug val => ((_0 as Ok).0: u32); // in scope 4 at $DIR/simplify_try.rs:6:13: 6:15 scope 5 { } } diff --git a/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyBranchSame.after.mir b/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyBranchSame.after.mir index be61e5e2a9fff..24bde51c7d3bb 100644 --- a/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyBranchSame.after.mir +++ b/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyBranchSame.after.mir @@ -14,22 +14,22 @@ fn try_identity(_1: std::result::Result) -> std::result::Result _2; // in scope 1 at $DIR/simplify_try.rs:6:9: 6:10 + debug y => ((_0 as Ok).0: u32); // in scope 1 at $DIR/simplify_try.rs:6:9: 6:10 } scope 2 { - debug err => _6; // in scope 2 at $DIR/simplify_try.rs:6:14: 6:15 + debug err => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify_try.rs:6:14: 6:15 scope 3 { scope 7 { - debug t => _9; // in scope 7 at $SRC_DIR/libcore/convert/mod.rs:LL:COL + debug t => ((_0 as Err).0: i32); // in scope 7 at $SRC_DIR/libcore/convert/mod.rs:LL:COL } scope 8 { - debug v => _8; // in scope 8 at $SRC_DIR/libcore/result.rs:LL:COL + debug v => ((_0 as Err).0: i32); // in scope 8 at $SRC_DIR/libcore/result.rs:LL:COL let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:6:14: 6:15 } } } scope 4 { - debug val => _10; // in scope 4 at $DIR/simplify_try.rs:6:13: 6:15 + debug val => ((_0 as Ok).0: u32); // in scope 4 at $DIR/simplify_try.rs:6:13: 6:15 scope 5 { } } diff --git a/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyLocals.after.mir b/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyLocals.after.mir index b12036f6a03e4..929f04d4654ad 100644 --- a/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyLocals.after.mir +++ b/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyLocals.after.mir @@ -3,27 +3,22 @@ fn try_identity(_1: std::result::Result) -> std::result::Result { debug x => _1; // in scope 0 at $DIR/simplify_try.rs:5:17: 5:18 let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_try.rs:5:41: 5:57 - let _2: u32; // in scope 0 at $DIR/simplify_try.rs:6:9: 6:10 - let _3: i32; // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15 - let mut _4: i32; // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15 - let mut _5: i32; // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15 - let _6: u32; // in scope 0 at $DIR/simplify_try.rs:6:13: 6:15 scope 1 { - debug y => _2; // in scope 1 at $DIR/simplify_try.rs:6:9: 6:10 + debug y => ((_0 as Ok).0: u32); // in scope 1 at $DIR/simplify_try.rs:6:9: 6:10 } scope 2 { - debug err => _3; // in scope 2 at $DIR/simplify_try.rs:6:14: 6:15 + debug err => ((_0 as Err).0: i32); // in scope 2 at $DIR/simplify_try.rs:6:14: 6:15 scope 3 { scope 7 { - debug t => _5; // in scope 7 at $SRC_DIR/libcore/convert/mod.rs:LL:COL + debug t => ((_0 as Err).0: i32); // in scope 7 at $SRC_DIR/libcore/convert/mod.rs:LL:COL } scope 8 { - debug v => _4; // in scope 8 at $SRC_DIR/libcore/result.rs:LL:COL + debug v => ((_0 as Err).0: i32); // in scope 8 at $SRC_DIR/libcore/result.rs:LL:COL } } } scope 4 { - debug val => _6; // in scope 4 at $DIR/simplify_try.rs:6:13: 6:15 + debug val => ((_0 as Ok).0: u32); // in scope 4 at $DIR/simplify_try.rs:6:13: 6:15 scope 5 { } } @@ -32,9 +27,7 @@ fn try_identity(_1: std::result::Result) -> std::result::Result $DIR/feature-gate-format-args-capture.rs:2:14 + | +LL | format!("{foo}"); + | ^^^^^ + | + = help: if you intended to capture `foo` from the surrounding scope, add `#![feature(format_args_capture)]` to the crate attributes + +error: there is no argument named `foo` + --> $DIR/feature-gate-format-args-capture.rs:5:13 + | +LL | panic!("{foo} {bar}", bar=1); + | ^^^^^ + | + = help: if you intended to capture `foo` from the surrounding scope, add `#![feature(format_args_capture)]` to the crate attributes + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/fmt/format-args-capture-macro-hygiene.rs b/src/test/ui/fmt/format-args-capture-macro-hygiene.rs new file mode 100644 index 0000000000000..6ca7dcc216f3a --- /dev/null +++ b/src/test/ui/fmt/format-args-capture-macro-hygiene.rs @@ -0,0 +1,6 @@ +#![feature(format_args_capture)] + +fn main() { + format!(concat!("{foo}")); //~ ERROR: there is no argument named `foo` + format!(concat!("{ba", "r} {}"), 1); //~ ERROR: there is no argument named `bar` +} diff --git a/src/test/ui/fmt/format-args-capture-macro-hygiene.stderr b/src/test/ui/fmt/format-args-capture-macro-hygiene.stderr new file mode 100644 index 0000000000000..0c5915149cd60 --- /dev/null +++ b/src/test/ui/fmt/format-args-capture-macro-hygiene.stderr @@ -0,0 +1,22 @@ +error: there is no argument named `foo` + --> $DIR/format-args-capture-macro-hygiene.rs:4:13 + | +LL | format!(concat!("{foo}")); + | ^^^^^^^^^^^^^^^^ + | + = note: did you intend to capture a variable `foo` from the surrounding scope? + = note: to avoid ambiguity, `format_args!` cannot capture variables when the format string is expanded from a macro + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: there is no argument named `bar` + --> $DIR/format-args-capture-macro-hygiene.rs:5:13 + | +LL | format!(concat!("{ba", "r} {}"), 1); + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: did you intend to capture a variable `bar` from the surrounding scope? + = note: to avoid ambiguity, `format_args!` cannot capture variables when the format string is expanded from a macro + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/fmt/format-args-capture-missing-variables.rs b/src/test/ui/fmt/format-args-capture-missing-variables.rs new file mode 100644 index 0000000000000..3c596ae3bb899 --- /dev/null +++ b/src/test/ui/fmt/format-args-capture-missing-variables.rs @@ -0,0 +1,22 @@ +#![feature(format_args_capture)] + +fn main() { + format!("{} {foo} {} {bar} {}", 1, 2, 3); + //~^ ERROR: cannot find value `foo` in this scope + //~^^ ERROR: cannot find value `bar` in this scope + + format!("{foo}"); //~ ERROR: cannot find value `foo` in this scope + + format!("{valuea} {valueb}", valuea=5, valuec=7); + //~^ ERROR cannot find value `valueb` in this scope + //~^^ ERROR named argument never used + + format!(r##" + + {foo} + + "##); + //~^^^^^ ERROR: cannot find value `foo` in this scope + + panic!("{foo} {bar}", bar=1); //~ ERROR: cannot find value `foo` in this scope +} diff --git a/src/test/ui/fmt/format-args-capture-missing-variables.stderr b/src/test/ui/fmt/format-args-capture-missing-variables.stderr new file mode 100644 index 0000000000000..c3d740eef9d3c --- /dev/null +++ b/src/test/ui/fmt/format-args-capture-missing-variables.stderr @@ -0,0 +1,52 @@ +error: named argument never used + --> $DIR/format-args-capture-missing-variables.rs:10:51 + | +LL | format!("{valuea} {valueb}", valuea=5, valuec=7); + | ------------------- ^ named argument never used + | | + | formatting specifier missing + +error[E0425]: cannot find value `foo` in this scope + --> $DIR/format-args-capture-missing-variables.rs:4:13 + | +LL | format!("{} {foo} {} {bar} {}", 1, 2, 3); + | ^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find value `bar` in this scope + --> $DIR/format-args-capture-missing-variables.rs:4:13 + | +LL | format!("{} {foo} {} {bar} {}", 1, 2, 3); + | ^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find value `foo` in this scope + --> $DIR/format-args-capture-missing-variables.rs:8:13 + | +LL | format!("{foo}"); + | ^^^^^^^ not found in this scope + +error[E0425]: cannot find value `valueb` in this scope + --> $DIR/format-args-capture-missing-variables.rs:10:13 + | +LL | format!("{valuea} {valueb}", valuea=5, valuec=7); + | ^^^^^^^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find value `foo` in this scope + --> $DIR/format-args-capture-missing-variables.rs:14:13 + | +LL | format!(r##" + | _____________^ +LL | | +LL | | {foo} +LL | | +LL | | "##); + | |_______^ not found in this scope + +error[E0425]: cannot find value `foo` in this scope + --> $DIR/format-args-capture-missing-variables.rs:21:12 + | +LL | panic!("{foo} {bar}", bar=1); + | ^^^^^^^^^^^^^ not found in this scope + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/fmt/format-args-capture.rs b/src/test/ui/fmt/format-args-capture.rs new file mode 100644 index 0000000000000..7490632110c85 --- /dev/null +++ b/src/test/ui/fmt/format-args-capture.rs @@ -0,0 +1,64 @@ +// run-pass +// ignore-wasm32 +// ignore-wasm64 +#![feature(format_args_capture)] + +fn main() { + named_argument_takes_precedence_to_captured(); + panic_with_single_argument_does_not_get_formatted(); + panic_with_multiple_arguments_is_formatted(); + formatting_parameters_can_be_captured(); +} + +fn named_argument_takes_precedence_to_captured() { + let foo = "captured"; + let s = format!("{foo}", foo="named"); + assert_eq!(&s, "named"); + + let s = format!("{foo}-{foo}-{foo}", foo="named"); + assert_eq!(&s, "named-named-named"); + + let s = format!("{}-{bar}-{foo}", "positional", bar="named"); + assert_eq!(&s, "positional-named-captured"); +} + +fn panic_with_single_argument_does_not_get_formatted() { + // panic! with a single argument does not perform string formatting. + // RFC #2795 suggests that this may need to change so that captured arguments are formatted. + // For stability reasons this will need to part of an edition change. + + let msg = std::panic::catch_unwind(|| { + panic!("{foo}"); + }).unwrap_err(); + + assert_eq!(msg.downcast_ref::<&str>(), Some(&"{foo}")) +} + +fn panic_with_multiple_arguments_is_formatted() { + let foo = "captured"; + + let msg = std::panic::catch_unwind(|| { + panic!("{}-{bar}-{foo}", "positional", bar="named"); + }).unwrap_err(); + + assert_eq!(msg.downcast_ref::(), Some(&"positional-named-captured".to_string())) +} + +fn formatting_parameters_can_be_captured() { + let width = 9; + let precision = 3; + + let x = 7.0; + + let s = format!("{x:width$}"); + assert_eq!(&s, " 7"); + + let s = format!("{x: $DIR/ifmt-bad-arg.rs:27:26 | LL | format!("{} {foo} {} {bar} {}", 1, 2, 3); | ^^^^^ + | + = help: if you intended to capture `bar` from the surrounding scope, add `#![feature(format_args_capture)]` to the crate attributes error: there is no argument named `foo` --> $DIR/ifmt-bad-arg.rs:31:14 | LL | format!("{foo}"); | ^^^^^ + | + = help: if you intended to capture `foo` from the surrounding scope, add `#![feature(format_args_capture)]` to the crate attributes error: multiple unused formatting arguments --> $DIR/ifmt-bad-arg.rs:32:17 @@ -155,6 +161,8 @@ error: there is no argument named `valueb` | LL | format!("{valuea} {valueb}", valuea=5, valuec=7); | ^^^^^^^^ + | + = help: if you intended to capture `valueb` from the surrounding scope, add `#![feature(format_args_capture)]` to the crate attributes error: named argument never used --> $DIR/ifmt-bad-arg.rs:45:51 @@ -205,6 +213,8 @@ error: there is no argument named `foo` | LL | {foo} | ^^^^^ + | + = help: if you intended to capture `foo` from the surrounding scope, add `#![feature(format_args_capture)]` to the crate attributes error: invalid format string: expected `'}'`, found `'t'` --> $DIR/ifmt-bad-arg.rs:75:1 diff --git a/src/test/ui/parser/issue-1802-1.stderr b/src/test/ui/parser/issue-1802-1.stderr index b7d003df56b71..954cc0beeef3e 100644 --- a/src/test/ui/parser/issue-1802-1.stderr +++ b/src/test/ui/parser/issue-1802-1.stderr @@ -1,4 +1,4 @@ -error: no valid digits found for number +error[E0768]: no valid digits found for number --> $DIR/issue-1802-1.rs:5:16 | LL | log(error, 0b); @@ -6,3 +6,4 @@ LL | log(error, 0b); error: aborting due to previous error +For more information about this error, try `rustc --explain E0768`. diff --git a/src/test/ui/parser/issue-1802-2.stderr b/src/test/ui/parser/issue-1802-2.stderr index 8491dd07cb788..49043d07b35eb 100644 --- a/src/test/ui/parser/issue-1802-2.stderr +++ b/src/test/ui/parser/issue-1802-2.stderr @@ -1,4 +1,4 @@ -error: no valid digits found for number +error[E0768]: no valid digits found for number --> $DIR/issue-1802-2.rs:5:16 | LL | log(error, 0b); @@ -6,3 +6,4 @@ LL | log(error, 0b); error: aborting due to previous error +For more information about this error, try `rustc --explain E0768`. diff --git a/src/test/ui/parser/lex-bad-numeric-literals.stderr b/src/test/ui/parser/lex-bad-numeric-literals.stderr index 151480dd012a3..f05d61603023c 100644 --- a/src/test/ui/parser/lex-bad-numeric-literals.stderr +++ b/src/test/ui/parser/lex-bad-numeric-literals.stderr @@ -46,7 +46,7 @@ error: hexadecimal float literal is not supported LL | 0x9.0e-9; | ^^^^^^^^ -error: no valid digits found for number +error[E0768]: no valid digits found for number --> $DIR/lex-bad-numeric-literals.rs:11:5 | LL | 0o; @@ -64,31 +64,31 @@ error: hexadecimal float literal is not supported LL | 0x539.0; | ^^^^^^^ -error: no valid digits found for number +error[E0768]: no valid digits found for number --> $DIR/lex-bad-numeric-literals.rs:18:5 | LL | 0x; | ^^ -error: no valid digits found for number +error[E0768]: no valid digits found for number --> $DIR/lex-bad-numeric-literals.rs:19:5 | LL | 0xu32; | ^^ -error: no valid digits found for number +error[E0768]: no valid digits found for number --> $DIR/lex-bad-numeric-literals.rs:20:5 | LL | 0ou32; | ^^ -error: no valid digits found for number +error[E0768]: no valid digits found for number --> $DIR/lex-bad-numeric-literals.rs:21:5 | LL | 0bu32; | ^^ -error: no valid digits found for number +error[E0768]: no valid digits found for number --> $DIR/lex-bad-numeric-literals.rs:22:5 | LL | 0b; @@ -138,3 +138,4 @@ LL | 0b101f64; error: aborting due to 23 previous errors +For more information about this error, try `rustc --explain E0768`.