From 37ce212f1f0a009a181d3a0a27dbd52505d4ac07 Mon Sep 17 00:00:00 2001 From: Trevor Spiteri Date: Wed, 23 Sep 2020 12:01:25 +0200 Subject: [PATCH 01/25] make exp_m1 examples more representative of use With this commit, the examples for exp_m1 would fail if x.exp() - 1.0 is used instead of x.exp_m1(). --- library/std/src/f32.rs | 9 +++++---- library/std/src/f64.rs | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/library/std/src/f32.rs b/library/std/src/f32.rs index 59c2da5273bde..cd9065b3a2115 100644 --- a/library/std/src/f32.rs +++ b/library/std/src/f32.rs @@ -719,12 +719,13 @@ impl f32 { /// # Examples /// /// ``` - /// let x = 6.0f32; + /// let x = 1e-8_f32; /// - /// // e^(ln(6)) - 1 - /// let abs_difference = (x.ln().exp_m1() - 5.0).abs(); + /// // for very small x, e^x is approximately 1 + x + x^2 / 2 + /// let approx = x + x * x / 2.0; + /// let abs_difference = (x.exp_m1() - approx).abs(); /// - /// assert!(abs_difference <= f32::EPSILON); + /// assert!(abs_difference < 1e-10); /// ``` #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/std/src/f64.rs b/library/std/src/f64.rs index bd094bdb55dc3..e412f89432c76 100644 --- a/library/std/src/f64.rs +++ b/library/std/src/f64.rs @@ -721,12 +721,13 @@ impl f64 { /// # Examples /// /// ``` - /// let x = 7.0_f64; + /// let x = 1e-16_f64; /// - /// // e^(ln(7)) - 1 - /// let abs_difference = (x.ln().exp_m1() - 6.0).abs(); + /// // for very small x, e^x is approximately 1 + x + x^2 / 2 + /// let approx = x + x * x / 2.0; + /// let abs_difference = (x.exp_m1() - approx).abs(); /// - /// assert!(abs_difference < 1e-10); + /// assert!(abs_difference < 1e-20); /// ``` #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] From 50d3ddcb0cbc36f782fa5939d1ef24422f6902d4 Mon Sep 17 00:00:00 2001 From: Trevor Spiteri Date: Wed, 23 Sep 2020 12:02:49 +0200 Subject: [PATCH 02/25] make ln_1p examples more representative of use With this commit, the examples for ln_1p would fail if (x + 1.0).ln() is used instead of x.ln_1p(). --- library/std/src/f32.rs | 9 +++++---- library/std/src/f64.rs | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/library/std/src/f32.rs b/library/std/src/f32.rs index cd9065b3a2115..ed975c4287981 100644 --- a/library/std/src/f32.rs +++ b/library/std/src/f32.rs @@ -740,12 +740,13 @@ impl f32 { /// # Examples /// /// ``` - /// let x = std::f32::consts::E - 1.0; + /// let x = 1e-8_f32; /// - /// // ln(1 + (e - 1)) == ln(e) == 1 - /// let abs_difference = (x.ln_1p() - 1.0).abs(); + /// // for very small x, ln(1 + x) is approximately x - x^2 / 2 + /// let approx = x - x * x / 2.0; + /// let abs_difference = (x.ln_1p() - approx).abs(); /// - /// assert!(abs_difference <= f32::EPSILON); + /// assert!(abs_difference < 1e-10); /// ``` #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/std/src/f64.rs b/library/std/src/f64.rs index e412f89432c76..8d0a85e056f71 100644 --- a/library/std/src/f64.rs +++ b/library/std/src/f64.rs @@ -742,12 +742,13 @@ impl f64 { /// # Examples /// /// ``` - /// let x = std::f64::consts::E - 1.0; + /// let x = 1e-16_f64; /// - /// // ln(1 + (e - 1)) == ln(e) == 1 - /// let abs_difference = (x.ln_1p() - 1.0).abs(); + /// // for very small x, ln(1 + x) is approximately x - x^2 / 2 + /// let approx = x - x * x / 2.0; + /// let abs_difference = (x.ln_1p() - approx).abs(); /// - /// assert!(abs_difference < 1e-10); + /// assert!(abs_difference < 1e-20); /// ``` #[must_use = "method returns a new number and does not mutate the original value"] #[stable(feature = "rust1", since = "1.0.0")] From 01b0aff1df1dd5ee7c60e8fbeff15cc3edaa3208 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 22 Jul 2020 12:17:36 +0200 Subject: [PATCH 03/25] Add std::panic::panic_box. --- library/std/src/panic.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/library/std/src/panic.rs b/library/std/src/panic.rs index 4281867314cca..06ce66c10f7ea 100644 --- a/library/std/src/panic.rs +++ b/library/std/src/panic.rs @@ -23,6 +23,20 @@ pub use crate::panicking::{set_hook, take_hook}; #[stable(feature = "panic_hooks", since = "1.10.0")] pub use core::panic::{Location, PanicInfo}; +/// Panic the current thread, with the given payload as the panic message. +/// +/// This supports an arbitrary panic payload, instead of just (formatted) strings. +/// +/// The message is attached as a `Box<'static + Any + Send>`, which can be +/// accessed using [`PanicInfo::payload`]. +/// +/// See the [`panic!`] macro for more information about panicking. +#[unstable(feature = "panic_box", issue = "none")] +#[inline] +pub fn panic_box(msg: M) -> ! { + crate::panicking::begin_panic(msg); +} + /// A marker trait which represents "panic safe" types in Rust. /// /// This trait is implemented by default for many types and behaves similarly in From 16201da6a4ff613d00ca3680c43cbb1b52f60cf1 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sun, 18 Oct 2020 12:29:13 +0200 Subject: [PATCH 04/25] Rename panic_box to panic_any. --- library/std/src/panic.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/std/src/panic.rs b/library/std/src/panic.rs index 06ce66c10f7ea..9a756e4bbb4d4 100644 --- a/library/std/src/panic.rs +++ b/library/std/src/panic.rs @@ -23,17 +23,17 @@ pub use crate::panicking::{set_hook, take_hook}; #[stable(feature = "panic_hooks", since = "1.10.0")] pub use core::panic::{Location, PanicInfo}; -/// Panic the current thread, with the given payload as the panic message. +/// Panic the current thread with the given message as the panic payload. /// -/// This supports an arbitrary panic payload, instead of just (formatted) strings. +/// The message can be of any (`Any + Send`) type, not just strings. /// -/// The message is attached as a `Box<'static + Any + Send>`, which can be -/// accessed using [`PanicInfo::payload`]. +/// The message is wrapped in a `Box<'static + Any + Send>`, which can be +/// accessed later using [`PanicInfo::payload`]. /// /// See the [`panic!`] macro for more information about panicking. #[unstable(feature = "panic_box", issue = "none")] #[inline] -pub fn panic_box(msg: M) -> ! { +pub fn panic_any(msg: M) -> ! { crate::panicking::begin_panic(msg); } From 9e16213610f606de0e44ac2b26ab9666bf0e83bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 26 Oct 2020 16:28:56 -0700 Subject: [PATCH 05/25] Suggest calling associated `fn` inside `trait`s When calling a function that doesn't exist inside of a trait's associated `fn`, and another associated `fn` in that trait has that name, suggest calling it with the appropriate fully-qualified path. Expand the label to be more descriptive. Prompted by the following user experience: https://users.rust-lang.org/t/cannot-find-function/50663 --- compiler/rustc_resolve/src/late.rs | 24 +++----- .../rustc_resolve/src/late/diagnostics.rs | 58 +++++++++++++++---- .../ui/resolve/associated-fn-called-as-fn.rs | 32 ++++++++++ .../resolve/associated-fn-called-as-fn.stderr | 15 +++++ src/test/ui/resolve/issue-14254.stderr | 30 +++++----- src/test/ui/resolve/issue-2356.stderr | 6 +- .../resolve/resolve-assoc-suggestions.stderr | 4 +- .../resolve-speculative-adjustment.stderr | 2 +- .../assoc-type-in-method-return.stderr | 2 +- 9 files changed, 124 insertions(+), 49 deletions(-) create mode 100644 src/test/ui/resolve/associated-fn-called-as-fn.rs create mode 100644 src/test/ui/resolve/associated-fn-called-as-fn.stderr diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 7517ab66170a2..9fe42590d3eae 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -353,8 +353,8 @@ impl<'a> PathSource<'a> { #[derive(Default)] struct DiagnosticMetadata<'ast> { - /// The current trait's associated types' ident, used for diagnostic suggestions. - current_trait_assoc_types: Vec, + /// The current trait's associated items' ident, used for diagnostic suggestions. + current_trait_assoc_items: Option<&'ast [P]>, /// The current self type if inside an impl (used for better errors). current_self_type: Option, @@ -1148,26 +1148,18 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { result } - /// When evaluating a `trait` use its associated types' idents for suggestionsa in E0412. + /// When evaluating a `trait` use its associated types' idents for suggestions in E0412. fn with_trait_items( &mut self, - trait_items: &Vec>, + trait_items: &'ast Vec>, f: impl FnOnce(&mut Self) -> T, ) -> T { - let trait_assoc_types = replace( - &mut self.diagnostic_metadata.current_trait_assoc_types, - trait_items - .iter() - .filter_map(|item| match &item.kind { - AssocItemKind::TyAlias(_, _, bounds, _) if bounds.is_empty() => { - Some(item.ident) - } - _ => None, - }) - .collect(), + let trait_assoc_items = replace( + &mut self.diagnostic_metadata.current_trait_assoc_items, + Some(&trait_items[..]), ); let result = f(self); - self.diagnostic_metadata.current_trait_assoc_types = trait_assoc_types; + self.diagnostic_metadata.current_trait_assoc_items = trait_assoc_items; result } diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index c24b383f3b811..75dc54e4d6531 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -30,7 +30,21 @@ type Res = def::Res; enum AssocSuggestion { Field, MethodWithSelf, - AssocItem, + AssocFn, + AssocType, + AssocConst, +} + +impl AssocSuggestion { + fn action(&self) -> &'static str { + match self { + AssocSuggestion::Field => "use the available field", + AssocSuggestion::MethodWithSelf => "call the method with the fully-qualified path", + AssocSuggestion::AssocFn => "call the associated function", + AssocSuggestion::AssocConst => "use the associated `const`", + AssocSuggestion::AssocType => "use the associated type", + } + } } crate enum MissingLifetimeSpot<'tcx> { @@ -386,15 +400,18 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { AssocSuggestion::MethodWithSelf if self_is_available => { err.span_suggestion( span, - "try", + "you might have meant to call the method", format!("self.{}", path_str), Applicability::MachineApplicable, ); } - AssocSuggestion::MethodWithSelf | AssocSuggestion::AssocItem => { + AssocSuggestion::MethodWithSelf + | AssocSuggestion::AssocFn + | AssocSuggestion::AssocConst + | AssocSuggestion::AssocType => { err.span_suggestion( span, - "try", + &format!("you might have meant to {}", candidate.action()), format!("Self::{}", path_str), Applicability::MachineApplicable, ); @@ -1048,9 +1065,19 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { } } - for assoc_type_ident in &self.diagnostic_metadata.current_trait_assoc_types { - if *assoc_type_ident == ident { - return Some(AssocSuggestion::AssocItem); + if let Some(items) = self.diagnostic_metadata.current_trait_assoc_items { + for assoc_item in &items[..] { + if assoc_item.ident == ident { + return Some(match &assoc_item.kind { + ast::AssocItemKind::Const(..) => AssocSuggestion::AssocConst, + ast::AssocItemKind::Fn(_, sig, ..) if sig.decl.has_self() => { + AssocSuggestion::MethodWithSelf + } + ast::AssocItemKind::Fn(..) => AssocSuggestion::AssocFn, + ast::AssocItemKind::TyAlias(..) => AssocSuggestion::AssocType, + ast::AssocItemKind::MacCall(_) => continue, + }); + } } } @@ -1066,11 +1093,20 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { ) { let res = binding.res(); if filter_fn(res) { - return Some(if self.r.has_self.contains(&res.def_id()) { - AssocSuggestion::MethodWithSelf + if self.r.has_self.contains(&res.def_id()) { + return Some(AssocSuggestion::MethodWithSelf); } else { - AssocSuggestion::AssocItem - }); + match res { + Res::Def(DefKind::AssocFn, _) => return Some(AssocSuggestion::AssocFn), + Res::Def(DefKind::AssocConst, _) => { + return Some(AssocSuggestion::AssocConst); + } + Res::Def(DefKind::AssocTy, _) => { + return Some(AssocSuggestion::AssocType); + } + _ => {} + } + } } } } diff --git a/src/test/ui/resolve/associated-fn-called-as-fn.rs b/src/test/ui/resolve/associated-fn-called-as-fn.rs new file mode 100644 index 0000000000000..f31f3d67b5be5 --- /dev/null +++ b/src/test/ui/resolve/associated-fn-called-as-fn.rs @@ -0,0 +1,32 @@ +struct S; +impl Foo for S { + fn parse(s:&str) { + for c in s.chars() { + match c { + '0'..='9' => collect_primary(&c), //~ ERROR cannot find function `collect_primary` + //~^ HELP you might have meant to call the associated function + '+' | '-' => println!("We got a sign: {}", c), + _ => println!("Not a number!") + } + } + } +} +trait Foo { + fn collect_primary(ch:&char) { } + fn parse(s:&str); +} +trait Bar { + fn collect_primary(ch:&char) { } + fn parse(s:&str) { + for c in s.chars() { + match c { + '0'..='9' => collect_primary(&c), //~ ERROR cannot find function `collect_primary` + //~^ HELP you might have meant to call the associated function + '+' | '-' => println!("We got a sign: {}", c), + _ => println!("Not a number!") + } + } + } +} + +fn main() {} diff --git a/src/test/ui/resolve/associated-fn-called-as-fn.stderr b/src/test/ui/resolve/associated-fn-called-as-fn.stderr new file mode 100644 index 0000000000000..fbdea30d551fd --- /dev/null +++ b/src/test/ui/resolve/associated-fn-called-as-fn.stderr @@ -0,0 +1,15 @@ +error[E0425]: cannot find function `collect_primary` in this scope + --> $DIR/associated-fn-called-as-fn.rs:6:30 + | +LL | '0'..='9' => collect_primary(&c), + | ^^^^^^^^^^^^^^^ help: you might have meant to call the associated function: `Self::collect_primary` + +error[E0425]: cannot find function `collect_primary` in this scope + --> $DIR/associated-fn-called-as-fn.rs:23:30 + | +LL | '0'..='9' => collect_primary(&c), + | ^^^^^^^^^^^^^^^ help: you might have meant to call the associated function: `Self::collect_primary` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/resolve/issue-14254.stderr b/src/test/ui/resolve/issue-14254.stderr index 97d42aa8ef4a5..b1f45adb8b714 100644 --- a/src/test/ui/resolve/issue-14254.stderr +++ b/src/test/ui/resolve/issue-14254.stderr @@ -2,7 +2,7 @@ error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:19:9 | LL | baz(); - | ^^^ help: try: `self.baz` + | ^^^ help: you might have meant to call the method: `self.baz` error[E0425]: cannot find value `a` in this scope --> $DIR/issue-14254.rs:21:9 @@ -14,7 +14,7 @@ error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:28:9 | LL | baz(); - | ^^^ help: try: `self.baz` + | ^^^ help: you might have meant to call the method: `self.baz` error[E0425]: cannot find value `x` in this scope --> $DIR/issue-14254.rs:30:9 @@ -38,7 +38,7 @@ error[E0425]: cannot find value `bah` in this scope --> $DIR/issue-14254.rs:36:9 | LL | bah; - | ^^^ help: try: `Self::bah` + | ^^^ help: you might have meant to call the associated function: `Self::bah` error[E0425]: cannot find value `b` in this scope --> $DIR/issue-14254.rs:38:9 @@ -50,7 +50,7 @@ error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:45:9 | LL | baz(); - | ^^^ help: try: `self.baz` + | ^^^ help: you might have meant to call the method: `self.baz` error[E0425]: cannot find value `x` in this scope --> $DIR/issue-14254.rs:47:9 @@ -74,7 +74,7 @@ error[E0425]: cannot find value `bah` in this scope --> $DIR/issue-14254.rs:53:9 | LL | bah; - | ^^^ help: try: `Self::bah` + | ^^^ help: you might have meant to call the associated function: `Self::bah` error[E0425]: cannot find value `b` in this scope --> $DIR/issue-14254.rs:55:9 @@ -86,61 +86,61 @@ error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:62:9 | LL | baz(); - | ^^^ help: try: `self.baz` + | ^^^ help: you might have meant to call the method: `self.baz` error[E0425]: cannot find value `bah` in this scope --> $DIR/issue-14254.rs:64:9 | LL | bah; - | ^^^ help: try: `Self::bah` + | ^^^ help: you might have meant to call the associated function: `Self::bah` error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:71:9 | LL | baz(); - | ^^^ help: try: `self.baz` + | ^^^ help: you might have meant to call the method: `self.baz` error[E0425]: cannot find value `bah` in this scope --> $DIR/issue-14254.rs:73:9 | LL | bah; - | ^^^ help: try: `Self::bah` + | ^^^ help: you might have meant to call the associated function: `Self::bah` error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:80:9 | LL | baz(); - | ^^^ help: try: `self.baz` + | ^^^ help: you might have meant to call the method: `self.baz` error[E0425]: cannot find value `bah` in this scope --> $DIR/issue-14254.rs:82:9 | LL | bah; - | ^^^ help: try: `Self::bah` + | ^^^ help: you might have meant to call the associated function: `Self::bah` error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:89:9 | LL | baz(); - | ^^^ help: try: `self.baz` + | ^^^ help: you might have meant to call the method: `self.baz` error[E0425]: cannot find value `bah` in this scope --> $DIR/issue-14254.rs:91:9 | LL | bah; - | ^^^ help: try: `Self::bah` + | ^^^ help: you might have meant to call the associated function: `Self::bah` error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:98:9 | LL | baz(); - | ^^^ help: try: `self.baz` + | ^^^ help: you might have meant to call the method: `self.baz` error[E0425]: cannot find value `bah` in this scope --> $DIR/issue-14254.rs:100:9 | LL | bah; - | ^^^ help: try: `Self::bah` + | ^^^ help: you might have meant to call the associated function: `Self::bah` error: aborting due to 24 previous errors diff --git a/src/test/ui/resolve/issue-2356.stderr b/src/test/ui/resolve/issue-2356.stderr index 0339daa0d6a18..8083233c01b92 100644 --- a/src/test/ui/resolve/issue-2356.stderr +++ b/src/test/ui/resolve/issue-2356.stderr @@ -8,7 +8,7 @@ error[E0425]: cannot find function `clone` in this scope --> $DIR/issue-2356.rs:24:5 | LL | clone(); - | ^^^^^ help: try: `self.clone` + | ^^^^^ help: you might have meant to call the method: `self.clone` error[E0425]: cannot find function `default` in this scope --> $DIR/issue-2356.rs:31:5 @@ -16,7 +16,7 @@ error[E0425]: cannot find function `default` in this scope LL | default(); | ^^^^^^^ | -help: try +help: you might have meant to call the associated function | LL | Self::default(); | ^^^^^^^^^^^^^ @@ -35,7 +35,7 @@ error[E0425]: cannot find function `shave` in this scope --> $DIR/issue-2356.rs:41:5 | LL | shave(4); - | ^^^^^ help: try: `Self::shave` + | ^^^^^ help: you might have meant to call the associated function: `Self::shave` error[E0425]: cannot find function `purr` in this scope --> $DIR/issue-2356.rs:43:5 diff --git a/src/test/ui/resolve/resolve-assoc-suggestions.stderr b/src/test/ui/resolve/resolve-assoc-suggestions.stderr index a05ac0f854395..b6acaeb8cc232 100644 --- a/src/test/ui/resolve/resolve-assoc-suggestions.stderr +++ b/src/test/ui/resolve/resolve-assoc-suggestions.stderr @@ -20,7 +20,7 @@ error[E0412]: cannot find type `Type` in this scope --> $DIR/resolve-assoc-suggestions.rs:23:16 | LL | let _: Type; - | ^^^^ help: try: `Self::Type` + | ^^^^ help: you might have meant to use the associated type: `Self::Type` error[E0531]: cannot find tuple struct or tuple variant `Type` in this scope --> $DIR/resolve-assoc-suggestions.rs:25:13 @@ -50,7 +50,7 @@ error[E0425]: cannot find value `method` in this scope --> $DIR/resolve-assoc-suggestions.rs:34:9 | LL | method; - | ^^^^^^ help: try: `self.method` + | ^^^^^^ help: you might have meant to call the method: `self.method` error: aborting due to 9 previous errors diff --git a/src/test/ui/resolve/resolve-speculative-adjustment.stderr b/src/test/ui/resolve/resolve-speculative-adjustment.stderr index 892b50309a905..1c34af6d0ffe5 100644 --- a/src/test/ui/resolve/resolve-speculative-adjustment.stderr +++ b/src/test/ui/resolve/resolve-speculative-adjustment.stderr @@ -20,7 +20,7 @@ error[E0425]: cannot find function `method` in this scope --> $DIR/resolve-speculative-adjustment.rs:25:9 | LL | method(); - | ^^^^^^ help: try: `self.method` + | ^^^^^^ help: you might have meant to call the method: `self.method` error: aborting due to 4 previous errors diff --git a/src/test/ui/suggestions/assoc-type-in-method-return.stderr b/src/test/ui/suggestions/assoc-type-in-method-return.stderr index bf908d36d2e3f..202e4a16eada7 100644 --- a/src/test/ui/suggestions/assoc-type-in-method-return.stderr +++ b/src/test/ui/suggestions/assoc-type-in-method-return.stderr @@ -2,7 +2,7 @@ error[E0412]: cannot find type `Bla` in this scope --> $DIR/assoc-type-in-method-return.rs:3:25 | LL | fn to_bla(&self) -> Bla; - | ^^^ help: try: `Self::Bla` + | ^^^ help: you might have meant to use the associated type: `Self::Bla` error: aborting due to previous error From a9d334d386e5abf79d8ee60f94bf32147b755c4c Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 28 Oct 2020 21:21:41 +0100 Subject: [PATCH 06/25] Update panic_any feature name. Co-authored-by: Camelid --- library/std/src/panic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/panic.rs b/library/std/src/panic.rs index 9a756e4bbb4d4..ad91933d65102 100644 --- a/library/std/src/panic.rs +++ b/library/std/src/panic.rs @@ -31,7 +31,7 @@ pub use core::panic::{Location, PanicInfo}; /// accessed later using [`PanicInfo::payload`]. /// /// See the [`panic!`] macro for more information about panicking. -#[unstable(feature = "panic_box", issue = "none")] +#[unstable(feature = "panic_any", issue = "none")] #[inline] pub fn panic_any(msg: M) -> ! { crate::panicking::begin_panic(msg); From b48fee010c92dde304154ba45c0e41d396e60568 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 28 Oct 2020 21:23:45 +0100 Subject: [PATCH 07/25] Add tracking issue number for panic_any. --- library/std/src/panic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/panic.rs b/library/std/src/panic.rs index ad91933d65102..d18b94b6c1aef 100644 --- a/library/std/src/panic.rs +++ b/library/std/src/panic.rs @@ -31,7 +31,7 @@ pub use core::panic::{Location, PanicInfo}; /// accessed later using [`PanicInfo::payload`]. /// /// See the [`panic!`] macro for more information about panicking. -#[unstable(feature = "panic_any", issue = "none")] +#[unstable(feature = "panic_any", issue = "78500")] #[inline] pub fn panic_any(msg: M) -> ! { crate::panicking::begin_panic(msg); From 4ba57aa703397a34e92f055c9e07bc880b771226 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Thu, 29 Oct 2020 11:37:55 -0400 Subject: [PATCH 08/25] Strip tokens from trait and impl items before printing AST JSON Fixes #78510 --- compiler/rustc_interface/src/passes.rs | 11 +++++++++++ src/test/ui/ast-json/issue-78510-assoc-ice.rs | 18 ++++++++++++++++++ .../ui/ast-json/issue-78510-assoc-ice.stderr | 15 +++++++++++++++ .../ui/ast-json/issue-78510-assoc-ice.stdout | 1 + 4 files changed, 45 insertions(+) create mode 100644 src/test/ui/ast-json/issue-78510-assoc-ice.rs create mode 100644 src/test/ui/ast-json/issue-78510-assoc-ice.stderr create mode 100644 src/test/ui/ast-json/issue-78510-assoc-ice.stdout diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 9dbd59506b188..a1487aa0060d5 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -70,6 +70,17 @@ impl mut_visit::MutVisitor for TokenStripper { i.tokens = None; mut_visit::noop_flat_map_foreign_item(i, self) } + fn flat_map_trait_item( + &mut self, + mut i: P, + ) -> SmallVec<[P; 1]> { + i.tokens = None; + mut_visit::noop_flat_map_assoc_item(i, self) + } + fn flat_map_impl_item(&mut self, mut i: P) -> SmallVec<[P; 1]> { + i.tokens = None; + mut_visit::noop_flat_map_assoc_item(i, self) + } fn visit_block(&mut self, b: &mut P) { b.tokens = None; mut_visit::noop_visit_block(b, self); diff --git a/src/test/ui/ast-json/issue-78510-assoc-ice.rs b/src/test/ui/ast-json/issue-78510-assoc-ice.rs new file mode 100644 index 0000000000000..ef3117c49cad3 --- /dev/null +++ b/src/test/ui/ast-json/issue-78510-assoc-ice.rs @@ -0,0 +1,18 @@ +// compile-flags: -Zast-json +// +// Regression test for issue #78510 +// Tests that we don't ICE when we have tokens for an associated item + +struct S; + +impl S { + #[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions + fn f() {} +} + +trait Bar { + #[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions + fn foo() {} +} + +fn main() {} diff --git a/src/test/ui/ast-json/issue-78510-assoc-ice.stderr b/src/test/ui/ast-json/issue-78510-assoc-ice.stderr new file mode 100644 index 0000000000000..3573c203a7893 --- /dev/null +++ b/src/test/ui/ast-json/issue-78510-assoc-ice.stderr @@ -0,0 +1,15 @@ +error[E0774]: `derive` may only be applied to structs, enums and unions + --> $DIR/issue-78510-assoc-ice.rs:9:5 + | +LL | #[derive(Debug)] + | ^^^^^^^^^^^^^^^^ + +error[E0774]: `derive` may only be applied to structs, enums and unions + --> $DIR/issue-78510-assoc-ice.rs:14:5 + | +LL | #[derive(Debug)] + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0774`. diff --git a/src/test/ui/ast-json/issue-78510-assoc-ice.stdout b/src/test/ui/ast-json/issue-78510-assoc-ice.stdout new file mode 100644 index 0000000000000..fef9504285b53 --- /dev/null +++ b/src/test/ui/ast-json/issue-78510-assoc-ice.stdout @@ -0,0 +1 @@ +{"module":{"inner":{"lo":139,"hi":397},"unsafety":"No","items":[{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"prelude_import","span":{"lo":0,"hi":0}},"id":3,"args":null}],"tokens":null},"args":"Empty","tokens":null}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0},"tokens":null}],"id":4,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"","span":{"lo":0,"hi":0}},"kind":{"variant":"Use","fields":[{"prefix":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"{{root}}","span":{"lo":0,"hi":0}},"id":5,"args":null},{"ident":{"name":"std","span":{"lo":0,"hi":0}},"id":6,"args":null},{"ident":{"name":"prelude","span":{"lo":0,"hi":0}},"id":7,"args":null},{"ident":{"name":"v1","span":{"lo":0,"hi":0}},"id":8,"args":null}],"tokens":null},"kind":"Glob","span":{"lo":0,"hi":0}}]},"tokens":null},{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"macro_use","span":{"lo":0,"hi":0}},"id":9,"args":null}],"tokens":null},"args":"Empty","tokens":null}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0},"tokens":null}],"id":10,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"std","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null},{"attrs":[],"id":11,"span":{"lo":139,"hi":148},"vis":{"kind":"Inherited","span":{"lo":139,"hi":139},"tokens":null},"ident":{"name":"S","span":{"lo":146,"hi":147}},"kind":{"variant":"Struct","fields":[{"variant":"Unit","fields":[12]},{"params":[],"where_clause":{"has_where_token":false,"predicates":[],"span":{"lo":147,"hi":147}},"span":{"lo":147,"hi":147}}]},"tokens":null},{"attrs":[],"id":13,"span":{"lo":150,"hi":263},"vis":{"kind":"Inherited","span":{"lo":150,"hi":150},"tokens":null},"ident":{"name":"","span":{"lo":0,"hi":0}},"kind":{"variant":"Impl","fields":["No","Positive","Final","No",{"params":[],"where_clause":{"has_where_token":false,"predicates":[],"span":{"lo":156,"hi":156}},"span":{"lo":154,"hi":154}},null,{"id":14,"kind":{"variant":"Path","fields":[null,{"span":{"lo":155,"hi":156},"segments":[{"ident":{"name":"S","span":{"lo":155,"hi":156}},"id":15,"args":null}],"tokens":null}]},"span":{"lo":155,"hi":156},"tokens":null},[{"attrs":[],"id":19,"span":{"lo":252,"hi":261},"vis":{"kind":"Inherited","span":{"lo":252,"hi":252},"tokens":null},"ident":{"name":"f","span":{"lo":255,"hi":256}},"kind":{"variant":"Fn","fields":["Final",{"header":{"unsafety":"No","asyncness":"No","constness":"No","ext":"None"},"decl":{"inputs":[],"output":{"variant":"Default","fields":[{"lo":259,"hi":259}]}},"span":{"lo":252,"hi":258}},{"params":[],"where_clause":{"has_where_token":false,"predicates":[],"span":{"lo":258,"hi":258}},"span":{"lo":256,"hi":256}},{"stmts":[],"id":20,"rules":"Default","span":{"lo":259,"hi":261},"tokens":null}]},"tokens":null}]]},"tokens":null},{"attrs":[],"id":16,"span":{"lo":265,"hi":383},"vis":{"kind":"Inherited","span":{"lo":265,"hi":265},"tokens":null},"ident":{"name":"Bar","span":{"lo":271,"hi":274}},"kind":{"variant":"Trait","fields":["No","No",{"params":[],"where_clause":{"has_where_token":false,"predicates":[],"span":{"lo":274,"hi":274}},"span":{"lo":274,"hi":274}},[],[{"attrs":[],"id":21,"span":{"lo":370,"hi":381},"vis":{"kind":"Inherited","span":{"lo":370,"hi":370},"tokens":null},"ident":{"name":"foo","span":{"lo":373,"hi":376}},"kind":{"variant":"Fn","fields":["Final",{"header":{"unsafety":"No","asyncness":"No","constness":"No","ext":"None"},"decl":{"inputs":[],"output":{"variant":"Default","fields":[{"lo":379,"hi":379}]}},"span":{"lo":370,"hi":378}},{"params":[],"where_clause":{"has_where_token":false,"predicates":[],"span":{"lo":378,"hi":378}},"span":{"lo":376,"hi":376}},{"stmts":[],"id":22,"rules":"Default","span":{"lo":379,"hi":381},"tokens":null}]},"tokens":null}]]},"tokens":null},{"attrs":[],"id":17,"span":{"lo":385,"hi":397},"vis":{"kind":"Inherited","span":{"lo":385,"hi":385},"tokens":null},"ident":{"name":"main","span":{"lo":388,"hi":392}},"kind":{"variant":"Fn","fields":["Final",{"header":{"unsafety":"No","asyncness":"No","constness":"No","ext":"None"},"decl":{"inputs":[],"output":{"variant":"Default","fields":[{"lo":395,"hi":395}]}},"span":{"lo":385,"hi":394}},{"params":[],"where_clause":{"has_where_token":false,"predicates":[],"span":{"lo":394,"hi":394}},"span":{"lo":392,"hi":392}},{"stmts":[],"id":18,"rules":"Default","span":{"lo":395,"hi":397},"tokens":null}]},"tokens":null}],"inline":true},"attrs":[],"span":{"lo":139,"hi":397},"proc_macros":[]} From dcbf2f324f3e3c116b3a7f45b501e2382e89510d Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 29 Oct 2020 09:45:15 -0700 Subject: [PATCH 09/25] rustc_llvm: unwrap LLVMMetadataRef before casting Directly casting the opaque pointer was [reported] to cause an "incomplete type" error with GCC 9.3: ``` llvm-wrapper/RustWrapper.cpp:939:31: required from here /usr/include/c++/9.3/type_traits:1301:12: error: invalid use of incomplete type 'struct LLVMOpaqueMetadata' 1301 | struct is_base_of | ^~~~~~~~~~ In file included from [...]/rust/src/llvm-project/llvm/include/llvm-c/BitReader.h:23, from llvm-wrapper/LLVMWrapper.h:1, from llvm-wrapper/RustWrapper.cpp:1: [...]/rust/src/llvm-project/llvm/include/llvm-c/Types.h:89:16: note: forward declaration of 'struct LLVMOpaqueMetadata' 89 | typedef struct LLVMOpaqueMetadata *LLVMMetadataRef; | ^~~~~~~~~~~~~~~~~~ ``` [reported]: https://zulip-archive.rust-lang.org/182449tcompilerhelp/12215halprustcllvmbuildfail.html#214915124 A simple `unwrap` fixes the issue. --- compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 3beb328339e7a..c689ac9427abe 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -936,7 +936,7 @@ extern "C" LLVMValueRef LLVMRustDIBuilderInsertDeclareAtEnd( return wrap(Builder->insertDeclare( unwrap(V), unwrap(VarInfo), Builder->createExpression(llvm::ArrayRef(AddrOps, AddrOpsCount)), - DebugLoc(cast(DL)), + DebugLoc(cast(unwrap(DL))), unwrap(InsertAtEnd))); } From 93ca9aebb9183c7256db9b277cfe01d0beaf75a2 Mon Sep 17 00:00:00 2001 From: Camelid Date: Sat, 24 Oct 2020 18:35:46 -0700 Subject: [PATCH 10/25] Qualify `panic!` as `core::panic!` in non-built-in `core` macros Otherwise code like this #![no_implicit_prelude] fn main() { ::std::todo!(); ::std::unimplemented!(); } will fail to compile, which is unfortunate and presumably unintended. This changes many invocations of `panic!` in a `macro_rules!` definition to invocations of `$crate::panic!`, which makes the invocations hygienic. Note that this does not make the built-in macro `assert!` hygienic. --- library/core/src/macros/mod.rs | 22 +- .../issue_73223.main.PreCodegen.32bit.diff | 133 ++++----- .../issue_73223.main.PreCodegen.64bit.diff | 133 ++++----- ..._73223.main.SimplifyArmIdentity.32bit.diff | 278 +++++++++--------- ..._73223.main.SimplifyArmIdentity.64bit.diff | 278 +++++++++--------- ...76432.test.SimplifyComparisonIntegral.diff | 10 +- src/test/ui/hygiene/no_implicit_prelude.rs | 4 +- .../ui/hygiene/no_implicit_prelude.stderr | 4 +- src/test/ui/macros/issue-78333.rs | 11 + 9 files changed, 431 insertions(+), 442 deletions(-) create mode 100644 src/test/ui/macros/issue-78333.rs diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index bce8a70e92f31..f052c4c7de7fb 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -44,7 +44,7 @@ macro_rules! assert_eq { // The reborrows below are intentional. Without them, the stack slot for the // borrow is initialized even before the values are compared, leading to a // noticeable slow down. - panic!(r#"assertion failed: `(left == right)` + $crate::panic!(r#"assertion failed: `(left == right)` left: `{:?}`, right: `{:?}`"#, &*left_val, &*right_val) } @@ -58,7 +58,7 @@ macro_rules! assert_eq { // The reborrows below are intentional. Without them, the stack slot for the // borrow is initialized even before the values are compared, leading to a // noticeable slow down. - panic!(r#"assertion failed: `(left == right)` + $crate::panic!(r#"assertion failed: `(left == right)` left: `{:?}`, right: `{:?}`: {}"#, &*left_val, &*right_val, $crate::format_args!($($arg)+)) @@ -95,7 +95,7 @@ macro_rules! assert_ne { // The reborrows below are intentional. Without them, the stack slot for the // borrow is initialized even before the values are compared, leading to a // noticeable slow down. - panic!(r#"assertion failed: `(left != right)` + $crate::panic!(r#"assertion failed: `(left != right)` left: `{:?}`, right: `{:?}`"#, &*left_val, &*right_val) } @@ -109,7 +109,7 @@ macro_rules! assert_ne { // The reborrows below are intentional. Without them, the stack slot for the // borrow is initialized even before the values are compared, leading to a // noticeable slow down. - panic!(r#"assertion failed: `(left != right)` + $crate::panic!(r#"assertion failed: `(left != right)` left: `{:?}`, right: `{:?}`: {}"#, &*left_val, &*right_val, $crate::format_args!($($arg)+)) @@ -466,7 +466,7 @@ macro_rules! writeln { /// /// # Panics /// -/// This will always [`panic!`] +/// This will always [`panic!`]. /// /// # Examples /// @@ -500,13 +500,13 @@ macro_rules! writeln { #[stable(feature = "rust1", since = "1.0.0")] macro_rules! unreachable { () => ({ - panic!("internal error: entered unreachable code") + $crate::panic!("internal error: entered unreachable code") }); ($msg:expr $(,)?) => ({ $crate::unreachable!("{}", $msg) }); ($fmt:expr, $($arg:tt)*) => ({ - panic!($crate::concat!("internal error: entered unreachable code: ", $fmt), $($arg)*) + $crate::panic!($crate::concat!("internal error: entered unreachable code: ", $fmt), $($arg)*) }); } @@ -584,8 +584,8 @@ macro_rules! unreachable { #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] macro_rules! unimplemented { - () => (panic!("not implemented")); - ($($arg:tt)+) => (panic!("not implemented: {}", $crate::format_args!($($arg)+))); + () => ($crate::panic!("not implemented")); + ($($arg:tt)+) => ($crate::panic!("not implemented: {}", $crate::format_args!($($arg)+))); } /// Indicates unfinished code. @@ -645,8 +645,8 @@ macro_rules! unimplemented { #[macro_export] #[stable(feature = "todo_macro", since = "1.40.0")] macro_rules! todo { - () => (panic!("not yet implemented")); - ($($arg:tt)+) => (panic!("not yet implemented: {}", $crate::format_args!($($arg)+))); + () => ($crate::panic!("not yet implemented")); + ($($arg:tt)+) => ($crate::panic!("not yet implemented: {}", $crate::format_args!($($arg)+))); } /// Definitions of built-in macros. diff --git a/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff b/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff index 23aefe07892fd..e1032558de037 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff @@ -11,17 +11,16 @@ let mut _9: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _10: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _11: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _12: &std::fmt::Arguments; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let _13: std::fmt::Arguments; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _14: &[&str; 3]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _15: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let _16: [std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _17: (&&i32, &&i32); // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let _18: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _19: &&i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _20: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _21: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _22: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _12: std::fmt::Arguments; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _13: &[&str; 3]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _14: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _15: [std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _16: (&&i32, &&i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _17: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _18: &&i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _19: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _20: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _21: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 1 { debug split => _1; // in scope 1 at $DIR/issue-73223.rs:2:9: 2:14 let _4: std::option::Option; // in scope 1 at $DIR/issue-73223.rs:7:9: 7:14 @@ -33,33 +32,32 @@ debug left_val => _7; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL debug right_val => _8; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 5 { - debug arg0 => _25; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - debug arg1 => _28; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - scope 6 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _25; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _24; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _23: 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/core/src/fmt/mod.rs:LL:COL - let mut _24: 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/core/src/fmt/mod.rs:LL:COL - let mut _25: &&i32; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug arg0 => _24; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug arg1 => _27; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + scope 6 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug x => _24; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug f => _23; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _22: 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/core/src/fmt/mod.rs:LL:COL + let mut _23: 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/core/src/fmt/mod.rs:LL:COL + let mut _24: &&i32; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL scope 7 { } } - scope 8 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _28; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _27; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _26: 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/core/src/fmt/mod.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 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _28: &&i32; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + scope 8 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug x => _27; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug f => _26; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _25: 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/core/src/fmt/mod.rs:LL:COL + let mut _26: 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/core/src/fmt/mod.rs:LL:COL + let mut _27: &&i32; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL scope 9 { } } } - scope 10 (inlined Arguments::new_v1) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug pieces => _29; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug args => _31; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _29: &[&str]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _30: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _31: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + scope 10 (inlined Arguments::new_v1) { // at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug pieces => (_12.0: &[&str]); // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug args => _29; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _28: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _29: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL } } } @@ -114,83 +112,80 @@ } bb2: { - StorageLive(_13); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - _14 = const main::promoted[0]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _13 = const main::promoted[0]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // ty::Const // + ty: &[&str; 3] // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[0])) // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: &[&str; 3], val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[0])) } - _29 = move _14 as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_16); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + (_12.0: &[&str]) = move _13 as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _17 = _7; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + (_16.0: &&i32) = &_17; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _18 = _7; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - (_17.0: &&i32) = &_18; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_19); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _20 = _8; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _19 = &_20; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - (_17.1: &&i32) = move _19; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_19); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - _25 = (_17.0: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _28 = (_17.1: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _24 = <&i32 as 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/core/src/macros/mod.rs:LL:COL + _19 = _8; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _18 = &_19; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + (_16.1: &&i32) = move _18; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _24 = (_16.0: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _27 = (_16.1: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _23 = <&i32 as 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/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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(_23); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _23 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _24) -> bb3; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_22); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _22 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _23) -> bb3; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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: { - (_21.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _25) -> bb4; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_20.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _24) -> bb4; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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: { - (_21.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _23; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_23); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _27 = <&i32 as 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/core/src/macros/mod.rs:LL:COL + (_20.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _22; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_22); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _26 = <&i32 as 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/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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(_26); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _26 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _27) -> bb5; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_25); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _25 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _26) -> bb5; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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: { - (_22.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _28) -> bb6; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_21.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _27) -> bb6; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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: { - (_22.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _26; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_26); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _16 = [move _21, move _22]; // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - _15 = &_16; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - _31 = move _15 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_30); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - discriminant(_30) = 0; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_13.0: &[&str]) = move _29; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_13.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _30; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_13.2: &[std::fmt::ArgumentV1]) = move _31; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_30); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _12 = &_13; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - begin_panic_fmt(move _12); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + (_21.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _25; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_25); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _15 = [move _20, move _21]; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _14 = &_15; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _29 = move _14 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_28); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + discriminant(_28) = 0; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_12.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _28; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_12.2: &[std::fmt::ArgumentV1]) = move _29; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_28); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + core::panicking::panic_fmt(move _12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/std/src/macros.rs:LL:COL - // + literal: Const { ty: for<'r, 's> fn(&'r std::fmt::Arguments<'s>) -> ! {std::rt::begin_panic_fmt}, val: Value(Scalar()) } + // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL + // + literal: Const { ty: for<'r> fn(std::fmt::Arguments<'r>) -> ! {core::panicking::panic_fmt}, val: Value(Scalar()) } } } diff --git a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff index 23aefe07892fd..e1032558de037 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff @@ -11,17 +11,16 @@ let mut _9: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _10: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _11: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _12: &std::fmt::Arguments; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let _13: std::fmt::Arguments; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _14: &[&str; 3]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _15: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let _16: [std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _17: (&&i32, &&i32); // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let _18: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _19: &&i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _20: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _21: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _22: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _12: std::fmt::Arguments; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _13: &[&str; 3]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _14: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _15: [std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _16: (&&i32, &&i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _17: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _18: &&i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _19: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _20: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _21: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 1 { debug split => _1; // in scope 1 at $DIR/issue-73223.rs:2:9: 2:14 let _4: std::option::Option; // in scope 1 at $DIR/issue-73223.rs:7:9: 7:14 @@ -33,33 +32,32 @@ debug left_val => _7; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL debug right_val => _8; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 5 { - debug arg0 => _25; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - debug arg1 => _28; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - scope 6 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _25; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _24; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _23: 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/core/src/fmt/mod.rs:LL:COL - let mut _24: 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/core/src/fmt/mod.rs:LL:COL - let mut _25: &&i32; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug arg0 => _24; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug arg1 => _27; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + scope 6 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug x => _24; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug f => _23; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _22: 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/core/src/fmt/mod.rs:LL:COL + let mut _23: 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/core/src/fmt/mod.rs:LL:COL + let mut _24: &&i32; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL scope 7 { } } - scope 8 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _28; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _27; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _26: 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/core/src/fmt/mod.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 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _28: &&i32; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + scope 8 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug x => _27; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug f => _26; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _25: 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/core/src/fmt/mod.rs:LL:COL + let mut _26: 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/core/src/fmt/mod.rs:LL:COL + let mut _27: &&i32; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL scope 9 { } } } - scope 10 (inlined Arguments::new_v1) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug pieces => _29; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug args => _31; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _29: &[&str]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _30: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _31: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + scope 10 (inlined Arguments::new_v1) { // at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug pieces => (_12.0: &[&str]); // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug args => _29; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _28: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _29: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL } } } @@ -114,83 +112,80 @@ } bb2: { - StorageLive(_13); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - _14 = const main::promoted[0]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _13 = const main::promoted[0]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // ty::Const // + ty: &[&str; 3] // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[0])) // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: &[&str; 3], val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[0])) } - _29 = move _14 as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_16); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + (_12.0: &[&str]) = move _13 as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _17 = _7; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + (_16.0: &&i32) = &_17; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _18 = _7; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - (_17.0: &&i32) = &_18; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_19); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _20 = _8; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _19 = &_20; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - (_17.1: &&i32) = move _19; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_19); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - _25 = (_17.0: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _28 = (_17.1: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _24 = <&i32 as 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/core/src/macros/mod.rs:LL:COL + _19 = _8; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _18 = &_19; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + (_16.1: &&i32) = move _18; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_18); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _24 = (_16.0: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _27 = (_16.1: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _23 = <&i32 as 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/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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(_23); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _23 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _24) -> bb3; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_22); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _22 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _23) -> bb3; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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: { - (_21.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _25) -> bb4; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_20.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _24) -> bb4; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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: { - (_21.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _23; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_23); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _27 = <&i32 as 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/core/src/macros/mod.rs:LL:COL + (_20.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _22; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_22); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _26 = <&i32 as 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/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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(_26); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _26 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _27) -> bb5; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_25); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _25 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _26) -> bb5; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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: { - (_22.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _28) -> bb6; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_21.0: &core::fmt::Opaque) = transmute::<&&i32, &core::fmt::Opaque>(move _27) -> bb6; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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: { - (_22.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _26; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_26); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _16 = [move _21, move _22]; // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - _15 = &_16; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - _31 = move _15 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_30); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - discriminant(_30) = 0; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_13.0: &[&str]) = move _29; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_13.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _30; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_13.2: &[std::fmt::ArgumentV1]) = move _31; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_30); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _12 = &_13; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - begin_panic_fmt(move _12); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + (_21.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _25; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_25); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _15 = [move _20, move _21]; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _14 = &_15; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _29 = move _14 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_28); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + discriminant(_28) = 0; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_12.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _28; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_12.2: &[std::fmt::ArgumentV1]) = move _29; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_28); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + core::panicking::panic_fmt(move _12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/std/src/macros.rs:LL:COL - // + literal: Const { ty: for<'r, 's> fn(&'r std::fmt::Arguments<'s>) -> ! {std::rt::begin_panic_fmt}, val: Value(Scalar()) } + // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL + // + literal: Const { ty: for<'r> fn(std::fmt::Arguments<'r>) -> ! {core::panicking::panic_fmt}, val: Value(Scalar()) } } } diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff index b9cb58e14c45d..02ec5410bcd99 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff @@ -18,29 +18,27 @@ let mut _16: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _17: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _18: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _19: !; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _20: &std::fmt::Arguments; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let _21: &std::fmt::Arguments; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let _22: std::fmt::Arguments; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _23: &[&str]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _24: &[&str; 3]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _25: &[&str; 3]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _26: [&str; 3]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _27: &[std::fmt::ArgumentV1]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _28: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let _29: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let _30: [std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _31: (&&i32, &&i32); // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _19: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _20: std::fmt::Arguments; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _21: &[&str]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _22: &[&str; 3]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _23: &[&str; 3]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _24: [&str; 3]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _25: &[std::fmt::ArgumentV1]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _26: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _27: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _28: [std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _29: (&&i32, &&i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _30: &&i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _31: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _32: &&i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let _33: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _34: &&i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _35: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _38: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _39: &&i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _40: 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/core/src/macros/mod.rs:LL:COL - let mut _41: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _42: &&i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _43: 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/core/src/macros/mod.rs:LL:COL + let mut _36: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _37: &&i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _38: 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/core/src/macros/mod.rs:LL:COL + let mut _39: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _40: &&i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _41: 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/core/src/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 @@ -48,43 +46,43 @@ debug _prev => _6; // in scope 3 at $DIR/issue-73223.rs:7:9: 7:14 let _13: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let _14: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _45: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _43: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 4 { debug left_val => _13; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL debug right_val => _14; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _36: &&i32; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _37: &&i32; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _44: &[&str; 3]; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _34: &&i32; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _35: &&i32; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _42: &[&str; 3]; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 5 { - debug arg0 => _36; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - debug arg1 => _37; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - scope 6 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _39; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _40; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _46: 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/core/src/fmt/mod.rs:LL:COL - let mut _47: 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/core/src/fmt/mod.rs:LL:COL - let mut _48: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _49: &&i32; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug arg0 => _34; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug arg1 => _35; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + scope 6 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug x => _37; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug f => _38; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _44: 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/core/src/fmt/mod.rs:LL:COL + let mut _45: 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/core/src/fmt/mod.rs:LL:COL + let mut _46: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _47: &&i32; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL scope 7 { } } - scope 8 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _42; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _43; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _50: 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/core/src/fmt/mod.rs:LL:COL - let mut _51: 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/core/src/fmt/mod.rs:LL:COL - let mut _52: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _53: &&i32; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + scope 8 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug x => _40; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug f => _41; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _48: 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/core/src/fmt/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 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _50: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _51: &&i32; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL scope 9 { } } } - scope 10 (inlined Arguments::new_v1) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug pieces => _23; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug args => _27; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _54: &[&str]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _55: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _56: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + scope 10 (inlined Arguments::new_v1) { // at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug pieces => _21; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug args => _25; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _52: &[&str]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _53: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _54: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL } } } @@ -126,14 +124,14 @@ StorageLive(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _10 = &_1; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _45 = const main::promoted[1]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _43 = const main::promoted[1]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // ty::Const // + ty: &i32 // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[1])) // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[1])) } - _11 = _45; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _11 = _43; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL (_9.0: &i32) = move _10; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL (_9.1: &i32) = move _11; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -170,146 +168,142 @@ } bb4: { - StorageLive(_19); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_20); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_21); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_22); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_19); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_21); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_22); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_23); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_24); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_25); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _44 = const main::promoted[0]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _42 = const main::promoted[0]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // ty::Const // + ty: &[&str; 3] // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[0])) // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: &[&str; 3], val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[0])) } - _25 = _44; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _24 = _25; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _23 = move _24 as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_24); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_27); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_28); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_29); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_30); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_31); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + _23 = _42; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _22 = _23; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _21 = move _22 as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_22); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_25); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_26); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_27); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_28); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_29); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_30); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_31); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _31 = _13; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _30 = &_31; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_33); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _33 = _13; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _33 = _14; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _32 = &_33; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + (_29.0: &&i32) = move _30; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + (_29.1: &&i32) = move _32; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_30); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_34); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _34 = (_29.0: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_35); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _35 = _14; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _34 = &_35; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - (_31.0: &&i32) = move _32; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - (_31.1: &&i32) = move _34; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_34); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_32); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_36); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _36 = (_31.0: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_37); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _37 = (_31.1: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_38); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_39); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _39 = _36; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_40); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _40 = <&i32 as 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/core/src/macros/mod.rs:LL:COL + _35 = (_29.1: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_36); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_37); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _37 = _34; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_38); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _38 = <&i32 as 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/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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(_46); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _47 = _40; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _46 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _47) -> bb5; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_44); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_45); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _45 = _38; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _44 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _45) -> bb5; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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: { - StorageDead(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_48); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_49); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _49 = _39; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _48 = transmute::<&&i32, &core::fmt::Opaque>(move _49) -> bb6; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_45); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_46); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _47 = _37; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _46 = transmute::<&&i32, &core::fmt::Opaque>(move _47) -> bb6; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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: { - StorageDead(_49); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_38.0: &core::fmt::Opaque) = move _48; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_38.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _46; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_48); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_36.0: &core::fmt::Opaque) = move _46; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_36.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _44; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL StorageDead(_46); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_40); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_39); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_41); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_42); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _42 = _37; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_43); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _43 = <&i32 as 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/core/src/macros/mod.rs:LL:COL + StorageDead(_44); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_38); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_37); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_39); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_40); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _40 = _35; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_41); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _41 = <&i32 as 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/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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(_50); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _51 = _43; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _50 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _51) -> bb7; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_48); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_49); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _49 = _41; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _48 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _49) -> bb7; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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()) } } bb7: { - StorageDead(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_52); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_53); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _53 = _42; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _52 = transmute::<&&i32, &core::fmt::Opaque>(move _53) -> bb8; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_49); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_50); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _51 = _40; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _50 = transmute::<&&i32, &core::fmt::Opaque>(move _51) -> bb8; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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()) } } bb8: { - StorageDead(_53); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_41.0: &core::fmt::Opaque) = move _52; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_41.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _50; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_52); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_39.0: &core::fmt::Opaque) = move _50; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_39.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _48; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL StorageDead(_50); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_43); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_42); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - _30 = [move _38, move _41]; // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_41); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_38); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_37); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_36); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - _29 = &_30; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - _28 = _29; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - _27 = move _28 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_28); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_48); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_41); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_40); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _28 = [move _36, move _39]; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_39); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_36); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_35); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_34); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _27 = &_28; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _26 = _27; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _25 = move _26 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_26); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_52); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _52 = _21; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_53); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + discriminant(_53) = 0; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL StorageLive(_54); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _54 = _23; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_55); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - discriminant(_55) = 0; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_56); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _56 = _27; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_22.0: &[&str]) = move _54; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_22.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _55; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_22.2: &[std::fmt::ArgumentV1]) = move _56; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_56); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_55); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _54 = _25; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_20.0: &[&str]) = move _52; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_20.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _53; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_20.2: &[std::fmt::ArgumentV1]) = move _54; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL StorageDead(_54); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_27); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_23); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - _21 = &_22; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - _20 = _21; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - begin_panic_fmt(move _20); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_53); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_52); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_25); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_21); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + core::panicking::panic_fmt(move _20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/std/src/macros.rs:LL:COL - // + literal: Const { ty: for<'r, 's> fn(&'r std::fmt::Arguments<'s>) -> ! {std::rt::begin_panic_fmt}, val: Value(Scalar()) } + // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL + // + literal: Const { ty: for<'r> fn(std::fmt::Arguments<'r>) -> ! {core::panicking::panic_fmt}, val: Value(Scalar()) } } } diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff index b9cb58e14c45d..02ec5410bcd99 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff @@ -18,29 +18,27 @@ let mut _16: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _17: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _18: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _19: !; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _20: &std::fmt::Arguments; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let _21: &std::fmt::Arguments; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let _22: std::fmt::Arguments; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _23: &[&str]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _24: &[&str; 3]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _25: &[&str; 3]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _26: [&str; 3]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _27: &[std::fmt::ArgumentV1]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _28: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let _29: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let _30: [std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _31: (&&i32, &&i32); // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _19: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _20: std::fmt::Arguments; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _21: &[&str]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _22: &[&str; 3]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _23: &[&str; 3]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _24: [&str; 3]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _25: &[std::fmt::ArgumentV1]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _26: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _27: &[std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _28: [std::fmt::ArgumentV1; 2]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _29: (&&i32, &&i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _30: &&i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _31: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _32: &&i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let _33: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _34: &&i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _35: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _38: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _39: &&i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _40: 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/core/src/macros/mod.rs:LL:COL - let mut _41: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL - let mut _42: &&i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _43: 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/core/src/macros/mod.rs:LL:COL + let mut _36: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _37: &&i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _38: 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/core/src/macros/mod.rs:LL:COL + let mut _39: std::fmt::ArgumentV1; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _40: &&i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _41: 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/core/src/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 @@ -48,43 +46,43 @@ debug _prev => _6; // in scope 3 at $DIR/issue-73223.rs:7:9: 7:14 let _13: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let _14: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _45: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _43: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 4 { debug left_val => _13; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL debug right_val => _14; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _36: &&i32; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _37: &&i32; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _44: &[&str; 3]; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _34: &&i32; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _35: &&i32; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _42: &[&str; 3]; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 5 { - debug arg0 => _36; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - debug arg1 => _37; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - scope 6 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _39; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _40; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _46: 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/core/src/fmt/mod.rs:LL:COL - let mut _47: 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/core/src/fmt/mod.rs:LL:COL - let mut _48: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _49: &&i32; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug arg0 => _34; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug arg1 => _35; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + scope 6 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug x => _37; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug f => _38; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _44: 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/core/src/fmt/mod.rs:LL:COL + let mut _45: 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/core/src/fmt/mod.rs:LL:COL + let mut _46: &core::fmt::Opaque; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _47: &&i32; // in scope 6 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL scope 7 { } } - scope 8 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug x => _42; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug f => _43; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _50: 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/core/src/fmt/mod.rs:LL:COL - let mut _51: 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/core/src/fmt/mod.rs:LL:COL - let mut _52: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _53: &&i32; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + scope 8 (inlined ArgumentV1::new::<&i32>) { // at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug x => _40; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug f => _41; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _48: 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/core/src/fmt/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 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _50: &core::fmt::Opaque; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _51: &&i32; // in scope 8 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL scope 9 { } } } - scope 10 (inlined Arguments::new_v1) { // at $SRC_DIR/std/src/macros.rs:LL:COL - debug pieces => _23; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - debug args => _27; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _54: &[&str]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _55: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - let mut _56: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + scope 10 (inlined Arguments::new_v1) { // at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug pieces => _21; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + debug args => _25; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _52: &[&str]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _53: std::option::Option<&[std::fmt::rt::v1::Argument]>; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + let mut _54: &[std::fmt::ArgumentV1]; // in scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL } } } @@ -126,14 +124,14 @@ StorageLive(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _10 = &_1; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _45 = const main::promoted[1]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _43 = const main::promoted[1]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // ty::Const // + ty: &i32 // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[1])) // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: &i32, val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[1])) } - _11 = _45; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _11 = _43; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL (_9.0: &i32) = move _10; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL (_9.1: &i32) = move _11; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -170,146 +168,142 @@ } bb4: { - StorageLive(_19); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_20); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_21); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_22); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_19); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_21); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_22); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_23); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_24); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_25); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _44 = const main::promoted[0]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _42 = const main::promoted[0]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // ty::Const // + ty: &[&str; 3] // + val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[0])) // mir::Constant // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: &[&str; 3], val: Unevaluated(WithOptConstParam { did: DefId(0:3 ~ issue_73223[317d]::main), const_param_did: None }, [], Some(promoted[0])) } - _25 = _44; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _24 = _25; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _23 = move _24 as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_24); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_27); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_28); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_29); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_30); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_31); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + _23 = _42; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _22 = _23; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _21 = move _22 as &[&str] (Pointer(Unsize)); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_22); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_25); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_26); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_27); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_28); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_29); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_30); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_31); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _31 = _13; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _30 = &_31; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_33); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _33 = _13; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _33 = _14; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _32 = &_33; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + (_29.0: &&i32) = move _30; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + (_29.1: &&i32) = move _32; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_30); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_34); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _34 = (_29.0: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_35); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _35 = _14; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _34 = &_35; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - (_31.0: &&i32) = move _32; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - (_31.1: &&i32) = move _34; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_34); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_32); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_36); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _36 = (_31.0: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_37); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _37 = (_31.1: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_38); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_39); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _39 = _36; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_40); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _40 = <&i32 as 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/core/src/macros/mod.rs:LL:COL + _35 = (_29.1: &&i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_36); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_37); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _37 = _34; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_38); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _38 = <&i32 as 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/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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(_46); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _47 = _40; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _46 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _47) -> bb5; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_44); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_45); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _45 = _38; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _44 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _45) -> bb5; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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: { - StorageDead(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_48); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_49); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _49 = _39; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _48 = transmute::<&&i32, &core::fmt::Opaque>(move _49) -> bb6; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_45); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_46); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _47 = _37; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _46 = transmute::<&&i32, &core::fmt::Opaque>(move _47) -> bb6; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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: { - StorageDead(_49); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_38.0: &core::fmt::Opaque) = move _48; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_38.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _46; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_48); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_47); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_36.0: &core::fmt::Opaque) = move _46; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_36.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _44; // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL StorageDead(_46); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_40); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_39); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_41); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageLive(_42); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _42 = _37; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_43); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _43 = <&i32 as 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/core/src/macros/mod.rs:LL:COL + StorageDead(_44); // scope 7 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_38); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_37); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_39); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_40); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _40 = _35; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_41); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _41 = <&i32 as 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/core/src/macros/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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(_50); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _51 = _43; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _50 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _51) -> bb7; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_48); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_49); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _49 = _41; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _48 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _49) -> bb7; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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()) } } bb7: { - StorageDead(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_52); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_53); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _53 = _42; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _52 = transmute::<&&i32, &core::fmt::Opaque>(move _53) -> bb8; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_49); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_50); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _51 = _40; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _50 = transmute::<&&i32, &core::fmt::Opaque>(move _51) -> bb8; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/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()) } } bb8: { - StorageDead(_53); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_41.0: &core::fmt::Opaque) = move _52; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_41.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _50; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_52); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_51); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_39.0: &core::fmt::Opaque) = move _50; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_39.1: for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) = move _48; // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL StorageDead(_50); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_43); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_42); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - _30 = [move _38, move _41]; // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_41); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_38); // scope 5 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_37); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_36); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - _29 = &_30; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - _28 = _29; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - _27 = move _28 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_28); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_48); // scope 9 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_41); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_40); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _28 = [move _36, move _39]; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_39); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_36); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_35); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_34); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _27 = &_28; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _26 = _27; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _25 = move _26 as &[std::fmt::ArgumentV1] (Pointer(Unsize)); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_26); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_52); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _52 = _21; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageLive(_53); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + discriminant(_53) = 0; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL StorageLive(_54); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _54 = _23; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_55); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - discriminant(_55) = 0; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageLive(_56); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - _56 = _27; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_22.0: &[&str]) = move _54; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_22.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _55; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - (_22.2: &[std::fmt::ArgumentV1]) = move _56; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_56); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_55); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + _54 = _25; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_20.0: &[&str]) = move _52; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_20.1: std::option::Option<&[std::fmt::rt::v1::Argument]>) = move _53; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + (_20.2: &[std::fmt::ArgumentV1]) = move _54; // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL StorageDead(_54); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL - StorageDead(_27); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - StorageDead(_23); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - _21 = &_22; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - _20 = _21; // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL - begin_panic_fmt(move _20); // scope 4 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageDead(_53); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_52); // scope 10 at $SRC_DIR/core/src/fmt/mod.rs:LL:COL + StorageDead(_25); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_21); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + core::panicking::panic_fmt(move _20); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/std/src/macros.rs:LL:COL - // + literal: Const { ty: for<'r, 's> fn(&'r std::fmt::Arguments<'s>) -> ! {std::rt::begin_panic_fmt}, val: Value(Scalar()) } + // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL + // + literal: Const { ty: for<'r> fn(std::fmt::Arguments<'r>) -> ! {core::panicking::panic_fmt}, val: Value(Scalar()) } } } diff --git a/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff b/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff index 499134b69919f..6450a2a22c6ca 100644 --- a/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff @@ -21,7 +21,7 @@ let mut _19: *const T; // in scope 0 at $DIR/issue_76432.rs:9:54: 9:68 let mut _20: *const T; // in scope 0 at $DIR/issue_76432.rs:9:70: 9:84 let mut _21: *const T; // in scope 0 at $DIR/issue_76432.rs:9:70: 9:84 - let mut _22: !; // in scope 0 at $SRC_DIR/std/src/macros.rs:LL:COL + let mut _22: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 1 { debug v => _2; // in scope 1 at $DIR/issue_76432.rs:7:9: 7:10 let _13: &T; // in scope 1 at $DIR/issue_76432.rs:9:10: 9:16 @@ -64,11 +64,11 @@ } bb1: { - StorageLive(_22); // scope 1 at $SRC_DIR/std/src/macros.rs:LL:COL - begin_panic::<&str>(const "internal error: entered unreachable code"); // scope 1 at $SRC_DIR/std/src/macros.rs:LL:COL + StorageLive(_22); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + core::panicking::panic(const "internal error: entered unreachable code"); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant - // + span: $SRC_DIR/std/src/macros.rs:LL:COL - // + literal: Const { ty: fn(&str) -> ! {std::rt::begin_panic::<&str>}, val: Value(Scalar()) } + // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL + // + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value(Scalar()) } // ty::Const // + ty: &str // + val: Value(Slice { data: Allocation { bytes: [105, 110, 116, 101, 114, 110, 97, 108, 32, 101, 114, 114, 111, 114, 58, 32, 101, 110, 116, 101, 114, 101, 100, 32, 117, 110, 114, 101, 97, 99, 104, 97, 98, 108, 101, 32, 99, 111, 100, 101], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [1099511627775], len: Size { raw: 40 } }, size: Size { raw: 40 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 40 }) diff --git a/src/test/ui/hygiene/no_implicit_prelude.rs b/src/test/ui/hygiene/no_implicit_prelude.rs index 204e7b248797a..a6b9e22cc6520 100644 --- a/src/test/ui/hygiene/no_implicit_prelude.rs +++ b/src/test/ui/hygiene/no_implicit_prelude.rs @@ -1,7 +1,7 @@ #![feature(decl_macro)] mod foo { - pub macro m() { Vec::new(); ().clone() } + pub macro m() { Vec::::new(); ().clone() } fn f() { ::bar::m!(); } } @@ -13,7 +13,7 @@ mod bar { } fn f() { ::foo::m!(); - assert_eq!(0, 0); //~ ERROR cannot find macro `panic` in this scope + assert!(true); //~ ERROR cannot find macro `panic` in this scope } } diff --git a/src/test/ui/hygiene/no_implicit_prelude.stderr b/src/test/ui/hygiene/no_implicit_prelude.stderr index 843dee2478b3f..b35304a76b9c7 100644 --- a/src/test/ui/hygiene/no_implicit_prelude.stderr +++ b/src/test/ui/hygiene/no_implicit_prelude.stderr @@ -1,8 +1,8 @@ error: cannot find macro `panic` in this scope --> $DIR/no_implicit_prelude.rs:16:9 | -LL | assert_eq!(0, 0); - | ^^^^^^^^^^^^^^^^^ +LL | assert!(true); + | ^^^^^^^^^^^^^^ | = note: consider importing one of these items: core::panic diff --git a/src/test/ui/macros/issue-78333.rs b/src/test/ui/macros/issue-78333.rs new file mode 100644 index 0000000000000..9fc4bcb99302e --- /dev/null +++ b/src/test/ui/macros/issue-78333.rs @@ -0,0 +1,11 @@ +// build-pass + +#![no_implicit_prelude] + +fn main() { + ::std::panic!(); + ::std::todo!(); + ::std::unimplemented!(); + ::std::assert_eq!(0, 0); + ::std::dbg!(123); +} From 5c87941896c77e7347d31655c85e2a16279baff3 Mon Sep 17 00:00:00 2001 From: Camelid Date: Sat, 24 Oct 2020 18:38:25 -0700 Subject: [PATCH 11/25] Clean up `core` macros documentation * Switch a couple links over to intra-doc links * Clean up some formatting/typography --- library/core/src/macros/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index f052c4c7de7fb..3f92d8be41ad1 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -515,15 +515,15 @@ macro_rules! unreachable { /// This allows your code to type-check, which is useful if you are prototyping or /// implementing a trait that requires multiple methods which you don't plan of using all of. /// -/// The difference between `unimplemented!` and [`todo!`](macro.todo.html) is that while `todo!` +/// The difference between `unimplemented!` and [`todo!`] is that while `todo!` /// conveys an intent of implementing the functionality later and the message is "not yet /// implemented", `unimplemented!` makes no such claims. Its message is "not implemented". /// Also some IDEs will mark `todo!`s. /// /// # Panics /// -/// This will always [panic!](macro.panic.html) because `unimplemented!` is just a -/// shorthand for `panic!` with a fixed, specific message. +/// This will always [`panic!`] because `unimplemented!` is just a shorthand for `panic!` with a +/// fixed, specific message. /// /// Like `panic!`, this macro has a second form for displaying custom values. /// @@ -600,7 +600,7 @@ macro_rules! unimplemented { /// /// # Panics /// -/// This will always [panic!](macro.panic.html) +/// This will always [`panic!`]. /// /// # Examples /// From 7b3d8971bb60347d39a93608ec19069f58731430 Mon Sep 17 00:00:00 2001 From: Camelid Date: Thu, 29 Oct 2020 13:47:08 -0700 Subject: [PATCH 12/25] Add two more test cases --- src/test/ui/macros/issue-78333.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/ui/macros/issue-78333.rs b/src/test/ui/macros/issue-78333.rs index 9fc4bcb99302e..c376f2067045b 100644 --- a/src/test/ui/macros/issue-78333.rs +++ b/src/test/ui/macros/issue-78333.rs @@ -7,5 +7,7 @@ fn main() { ::std::todo!(); ::std::unimplemented!(); ::std::assert_eq!(0, 0); + ::std::assert_ne!(0, 1); ::std::dbg!(123); + ::std::unreachable!(); } From 8cf7d66d0a7e5405f55887ca008cca7fce7f7396 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Thu, 29 Oct 2020 21:23:55 -0400 Subject: [PATCH 13/25] Create config.toml in the current directory, not the top-level directory See https://github.com/rust-lang/rust/issues/78509 for discussion. --- src/bootstrap/setup.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/setup.rs b/src/bootstrap/setup.rs index c6e1c99564c09..f5ce45a5bd11b 100644 --- a/src/bootstrap/setup.rs +++ b/src/bootstrap/setup.rs @@ -89,7 +89,7 @@ pub fn setup(src_path: &Path, profile: Profile) { std::process::exit(1); } - let path = cfg_file.unwrap_or_else(|| src_path.join("config.toml")); + let path = cfg_file.unwrap_or("config.toml".into()); let settings = format!( "# Includes one of the default files in src/bootstrap/defaults\n\ profile = \"{}\"\n\ From 59c6ae615e5547610c3348b466a45ff2a5b3d935 Mon Sep 17 00:00:00 2001 From: Maarten de Vries Date: Fri, 30 Oct 2020 14:05:53 +0100 Subject: [PATCH 14/25] Use SOCK_CLOEXEC and accept4() on more platforms. --- library/std/src/sys/unix/net.rs | 38 +++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/library/std/src/sys/unix/net.rs b/library/std/src/sys/unix/net.rs index 74c7db27226ef..71c6aa5a0e7ea 100644 --- a/library/std/src/sys/unix/net.rs +++ b/library/std/src/sys/unix/net.rs @@ -55,9 +55,18 @@ impl Socket { pub fn new_raw(fam: c_int, ty: c_int) -> io::Result { unsafe { cfg_if::cfg_if! { - if #[cfg(target_os = "linux")] { - // On Linux we pass the SOCK_CLOEXEC flag to atomically create - // the socket and set it as CLOEXEC, added in 2.6.27. + if #[cfg(any( + target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "illumos", + target_os = "linux", + target_os = "netbsd", + target_os = "opensbd", + ))] { + // On platforms that support it we pass the SOCK_CLOEXEC + // flag to atomically create the socket and set it as + // CLOEXEC. On Linux this was added in 2.6.27. let fd = cvt(libc::socket(fam, ty | libc::SOCK_CLOEXEC, 0))?; Ok(Socket(FileDesc::new(fd))) } else { @@ -83,7 +92,15 @@ impl Socket { let mut fds = [0, 0]; cfg_if::cfg_if! { - if #[cfg(target_os = "linux")] { + if #[cfg(any( + target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "illumos", + target_os = "linux", + target_os = "netbsd", + target_os = "opensbd", + ))] { // Like above, set cloexec atomically cvt(libc::socketpair(fam, ty | libc::SOCK_CLOEXEC, 0, fds.as_mut_ptr()))?; Ok((Socket(FileDesc::new(fds[0])), Socket(FileDesc::new(fds[1])))) @@ -174,9 +191,18 @@ impl Socket { pub fn accept(&self, storage: *mut sockaddr, len: *mut socklen_t) -> io::Result { // Unfortunately the only known way right now to accept a socket and // atomically set the CLOEXEC flag is to use the `accept4` syscall on - // Linux. This was added in 2.6.28, glibc 2.10 and musl 0.9.5. + // platforms that support it. On Linux, this was added in 2.6.28, + // glibc 2.10 and musl 0.9.5. cfg_if::cfg_if! { - if #[cfg(target_os = "linux")] { + if #[cfg(any( + target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "illumos", + target_os = "linux", + target_os = "netbsd", + target_os = "opensbd", + ))] { let fd = cvt_r(|| unsafe { libc::accept4(self.0.raw(), storage, len, libc::SOCK_CLOEXEC) })?; From 922ebf4ec7e5bc70a30c068a8f63a433e91f8381 Mon Sep 17 00:00:00 2001 From: Camelid Date: Fri, 30 Oct 2020 15:55:52 -0700 Subject: [PATCH 15/25] Remove unused `use std::panic;`s --- src/test/ui/iterators/iter-count-overflow-ndebug.rs | 1 - src/test/ui/iterators/iter-position-overflow-ndebug.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/src/test/ui/iterators/iter-count-overflow-ndebug.rs b/src/test/ui/iterators/iter-count-overflow-ndebug.rs index b755bb554f441..c38755db87ebf 100644 --- a/src/test/ui/iterators/iter-count-overflow-ndebug.rs +++ b/src/test/ui/iterators/iter-count-overflow-ndebug.rs @@ -2,7 +2,6 @@ // only-32bit too impatient for 2⁶⁴ items // compile-flags: -C debug_assertions=no -C opt-level=3 -use std::panic; use std::usize::MAX; fn main() { diff --git a/src/test/ui/iterators/iter-position-overflow-ndebug.rs b/src/test/ui/iterators/iter-position-overflow-ndebug.rs index 368f9c0c02b07..3b0c245a5c2a1 100644 --- a/src/test/ui/iterators/iter-position-overflow-ndebug.rs +++ b/src/test/ui/iterators/iter-position-overflow-ndebug.rs @@ -2,7 +2,6 @@ // only-32bit too impatient for 2⁶⁴ items // compile-flags: -C debug_assertions=no -C opt-level=3 -use std::panic; use std::usize::MAX; fn main() { From 23018a55d9735afbefb19fcec91db4b53fe917d8 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Thu, 13 Aug 2020 15:41:52 -0400 Subject: [PATCH 16/25] Implement rustc side of report-future-incompat --- Cargo.lock | 14 +++ compiler/rustc_ast_lowering/src/path.rs | 4 +- compiler/rustc_errors/Cargo.toml | 1 + .../src/annotate_snippet_emitter_writer.rs | 4 +- compiler/rustc_errors/src/diagnostic.rs | 13 +- .../rustc_errors/src/diagnostic_builder.rs | 3 +- compiler/rustc_errors/src/emitter.rs | 9 +- compiler/rustc_errors/src/json.rs | 35 +++++- compiler/rustc_errors/src/lib.rs | 111 +++++++++++----- compiler/rustc_interface/src/passes.rs | 5 +- compiler/rustc_interface/src/tests.rs | 1 + compiler/rustc_lint/src/array_into_iter.rs | 5 +- compiler/rustc_lint/src/builtin.rs | 1 - compiler/rustc_lint/src/context.rs | 21 +++- compiler/rustc_lint_defs/Cargo.toml | 13 ++ .../lint => rustc_lint_defs/src}/builtin.rs | 1 - .../lint.rs => rustc_lint_defs/src/lib.rs} | 119 ++++++++++-------- compiler/rustc_middle/src/lint.rs | 25 ++-- compiler/rustc_session/Cargo.toml | 1 + compiler/rustc_session/src/lib.rs | 4 +- compiler/rustc_session/src/options.rs | 2 + compiler/rustc_session/src/session.rs | 54 +++++++- 22 files changed, 332 insertions(+), 114 deletions(-) create mode 100644 compiler/rustc_lint_defs/Cargo.toml rename compiler/{rustc_session/src/lint => rustc_lint_defs/src}/builtin.rs (99%) rename compiler/{rustc_session/src/lint.rs => rustc_lint_defs/src/lib.rs} (83%) diff --git a/Cargo.lock b/Cargo.lock index 65d20190c0db5..a8e4490aa1a45 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3638,6 +3638,7 @@ dependencies = [ "annotate-snippets 0.8.0", "atty", "rustc_data_structures", + "rustc_lint_defs", "rustc_macros", "rustc_serialize", "rustc_span", @@ -3830,6 +3831,18 @@ dependencies = [ "unicode-security", ] +[[package]] +name = "rustc_lint_defs" +version = "0.0.0" +dependencies = [ + "rustc_ast", + "rustc_data_structures", + "rustc_macros", + "rustc_serialize", + "rustc_span", + "tracing", +] + [[package]] name = "rustc_llvm" version = "0.0.0" @@ -4112,6 +4125,7 @@ dependencies = [ "rustc_errors", "rustc_feature", "rustc_fs_util", + "rustc_lint_defs", "rustc_macros", "rustc_serialize", "rustc_span", diff --git a/compiler/rustc_ast_lowering/src/path.rs b/compiler/rustc_ast_lowering/src/path.rs index e1eed168b31bb..6afed355dc338 100644 --- a/compiler/rustc_ast_lowering/src/path.rs +++ b/compiler/rustc_ast_lowering/src/path.rs @@ -308,8 +308,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { E0726, "implicit elided lifetime not allowed here" ); - rustc_session::lint::add_elided_lifetime_in_path_suggestion( - &self.sess, + rustc_errors::add_elided_lifetime_in_path_suggestion( + &self.sess.source_map(), &mut err, expected_lifetimes, path_span, diff --git a/compiler/rustc_errors/Cargo.toml b/compiler/rustc_errors/Cargo.toml index e4dbb8db38104..5d8ff601e7993 100644 --- a/compiler/rustc_errors/Cargo.toml +++ b/compiler/rustc_errors/Cargo.toml @@ -13,6 +13,7 @@ rustc_serialize = { path = "../rustc_serialize" } rustc_span = { path = "../rustc_span" } rustc_macros = { path = "../rustc_macros" } rustc_data_structures = { path = "../rustc_data_structures" } +rustc_lint_defs = { path = "../rustc_lint_defs" } unicode-width = "0.1.4" atty = "0.2" termcolor = "1.0" diff --git a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs index 265ba59cccb2a..6f365c07f6d30 100644 --- a/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs +++ b/compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs @@ -72,6 +72,7 @@ fn annotation_type_for_level(level: Level) -> AnnotationType { Level::Help => AnnotationType::Help, // FIXME(#59346): Not sure how to map these two levels Level::Cancelled | Level::FailureNote => AnnotationType::Error, + Level::Allow => panic!("Should not call with Allow"), } } @@ -143,7 +144,8 @@ impl AnnotateSnippetEmitterWriter { title: Some(Annotation { label: Some(&message), id: code.as_ref().map(|c| match c { - DiagnosticId::Error(val) | DiagnosticId::Lint(val) => val.as_str(), + DiagnosticId::Error(val) + | DiagnosticId::Lint { name: val, has_future_breakage: _ } => val.as_str(), }), annotation_type: annotation_type_for_level(*level), }), diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 91bfc6296b1c7..decbf03b9de85 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -1,10 +1,10 @@ use crate::snippet::Style; -use crate::Applicability; use crate::CodeSuggestion; use crate::Level; use crate::Substitution; use crate::SubstitutionPart; use crate::SuggestionStyle; +use rustc_lint_defs::Applicability; use rustc_span::{MultiSpan, Span, DUMMY_SP}; use std::fmt; @@ -27,7 +27,7 @@ pub struct Diagnostic { #[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)] pub enum DiagnosticId { Error(String), - Lint(String), + Lint { name: String, has_future_breakage: bool }, } /// For example a note attached to an error. @@ -107,7 +107,14 @@ impl Diagnostic { match self.level { Level::Bug | Level::Fatal | Level::Error | Level::FailureNote => true, - Level::Warning | Level::Note | Level::Help | Level::Cancelled => false, + Level::Warning | Level::Note | Level::Help | Level::Cancelled | Level::Allow => false, + } + } + + pub fn has_future_breakage(&self) -> bool { + match self.code { + Some(DiagnosticId::Lint { has_future_breakage, .. }) => has_future_breakage, + _ => false, } } diff --git a/compiler/rustc_errors/src/diagnostic_builder.rs b/compiler/rustc_errors/src/diagnostic_builder.rs index d1ff6f721c415..56acdf699ef45 100644 --- a/compiler/rustc_errors/src/diagnostic_builder.rs +++ b/compiler/rustc_errors/src/diagnostic_builder.rs @@ -1,5 +1,6 @@ -use crate::{Applicability, Handler, Level, StashKey}; use crate::{Diagnostic, DiagnosticId, DiagnosticStyledString}; +use crate::{Handler, Level, StashKey}; +use rustc_lint_defs::Applicability; use rustc_span::{MultiSpan, Span}; use std::fmt::{self, Debug}; diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 08e9bdf308798..2dc7b7e2da383 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -9,14 +9,15 @@ use Destination::*; +use rustc_lint_defs::FutureBreakage; use rustc_span::source_map::SourceMap; use rustc_span::{MultiSpan, SourceFile, Span}; use crate::snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, Style, StyledString}; use crate::styled_buffer::StyledBuffer; -use crate::{ - pluralize, CodeSuggestion, Diagnostic, DiagnosticId, Level, SubDiagnostic, SuggestionStyle, -}; +use crate::{CodeSuggestion, Diagnostic, DiagnosticId, Level, SubDiagnostic, SuggestionStyle}; + +use rustc_lint_defs::pluralize; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::Lrc; @@ -192,6 +193,8 @@ pub trait Emitter { /// other formats can, and will, simply ignore it. fn emit_artifact_notification(&mut self, _path: &Path, _artifact_type: &str) {} + fn emit_future_breakage_report(&mut self, _diags: Vec<(FutureBreakage, Diagnostic)>) {} + /// Checks if should show explanations about "rustc --explain" fn should_show_explain(&self) -> bool { true diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index fbe3588280ad1..ddffa64f2225d 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -13,8 +13,9 @@ use rustc_span::source_map::{FilePathMapping, SourceMap}; use crate::emitter::{Emitter, HumanReadableErrorType}; use crate::registry::Registry; -use crate::{Applicability, DiagnosticId}; +use crate::DiagnosticId; use crate::{CodeSuggestion, SubDiagnostic}; +use rustc_lint_defs::{Applicability, FutureBreakage}; use rustc_data_structures::sync::Lrc; use rustc_span::hygiene::ExpnData; @@ -131,6 +132,30 @@ impl Emitter for JsonEmitter { } } + fn emit_future_breakage_report(&mut self, diags: Vec<(FutureBreakage, crate::Diagnostic)>) { + let data: Vec = diags + .into_iter() + .map(|(breakage, mut diag)| { + if diag.level == crate::Level::Allow { + diag.level = crate::Level::Warning; + } + FutureBreakageItem { + future_breakage_date: breakage.date, + diagnostic: Diagnostic::from_errors_diagnostic(&diag, self), + } + }) + .collect(); + let result = if self.pretty { + writeln!(&mut self.dst, "{}", as_pretty_json(&data)) + } else { + writeln!(&mut self.dst, "{}", as_json(&data)) + } + .and_then(|_| self.dst.flush()); + if let Err(e) = result { + panic!("failed to print future breakage report: {:?}", e); + } + } + fn source_map(&self) -> Option<&Lrc> { Some(&self.sm) } @@ -223,6 +248,12 @@ struct ArtifactNotification<'a> { emit: &'a str, } +#[derive(Encodable)] +struct FutureBreakageItem { + future_breakage_date: Option<&'static str>, + diagnostic: Diagnostic, +} + impl Diagnostic { fn from_errors_diagnostic(diag: &crate::Diagnostic, je: &JsonEmitter) -> Diagnostic { let sugg = diag.suggestions.iter().map(|sugg| Diagnostic { @@ -432,7 +463,7 @@ impl DiagnosticCode { s.map(|s| { let s = match s { DiagnosticId::Error(s) => s, - DiagnosticId::Lint(s) => s, + DiagnosticId::Lint { name, has_future_breakage: _ } => name, }; let je_result = je.registry.as_ref().map(|registry| registry.try_find_description(&s)).unwrap(); diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 2ebc4a7e9d923..593e0d92031ff 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -21,6 +21,8 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_data_structures::stable_hasher::StableHasher; use rustc_data_structures::sync::{self, Lock, Lrc}; use rustc_data_structures::AtomicRef; +use rustc_lint_defs::FutureBreakage; +pub use rustc_lint_defs::{pluralize, Applicability}; use rustc_span::source_map::SourceMap; use rustc_span::{Loc, MultiSpan, Span}; @@ -49,30 +51,6 @@ pub type PResult<'a, T> = Result>; #[cfg(target_arch = "x86_64")] rustc_data_structures::static_assert_size!(PResult<'_, bool>, 16); -/// Indicates the confidence in the correctness of a suggestion. -/// -/// All suggestions are marked with an `Applicability`. Tools use the applicability of a suggestion -/// to determine whether it should be automatically applied or if the user should be consulted -/// before applying the suggestion. -#[derive(Copy, Clone, Debug, PartialEq, Hash, Encodable, Decodable)] -pub enum Applicability { - /// The suggestion is definitely what the user intended. This suggestion should be - /// automatically applied. - MachineApplicable, - - /// The suggestion may be what the user intended, but it is uncertain. The suggestion should - /// result in valid Rust code if it is applied. - MaybeIncorrect, - - /// The suggestion contains placeholders like `(...)` or `{ /* fields */ }`. The suggestion - /// cannot be applied automatically because it will not result in valid Rust code. The user - /// will need to fill in the placeholders. - HasPlaceholders, - - /// The applicability of the suggestion is unknown. - Unspecified, -} - #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, Encodable, Decodable)] pub enum SuggestionStyle { /// Hide the suggested code when displaying this suggestion inline. @@ -321,6 +299,8 @@ struct HandlerInner { /// The warning count, used for a recap upon finishing deduplicated_warn_count: usize, + + future_breakage_diagnostics: Vec, } /// A key denoting where from a diagnostic was stashed. @@ -434,6 +414,7 @@ impl Handler { emitted_diagnostic_codes: Default::default(), emitted_diagnostics: Default::default(), stashed_diagnostics: Default::default(), + future_breakage_diagnostics: Vec::new(), }), } } @@ -503,6 +484,17 @@ impl Handler { result } + /// Construct a builder at the `Allow` level at the given `span` and with the `msg`. + pub fn struct_span_allow( + &self, + span: impl Into, + msg: &str, + ) -> DiagnosticBuilder<'_> { + let mut result = self.struct_allow(msg); + result.set_span(span); + result + } + /// Construct a builder at the `Warning` level at the given `span` and with the `msg`. /// Also include a code. pub fn struct_span_warn_with_code( @@ -525,6 +517,11 @@ impl Handler { result } + /// Construct a builder at the `Allow` level with the `msg`. + pub fn struct_allow(&self, msg: &str) -> DiagnosticBuilder<'_> { + DiagnosticBuilder::new(self, Level::Allow, msg) + } + /// Construct a builder at the `Error` level at the given `span` and with the `msg`. pub fn struct_span_err(&self, span: impl Into, msg: &str) -> DiagnosticBuilder<'_> { let mut result = self.struct_err(msg); @@ -693,6 +690,10 @@ impl Handler { self.inner.borrow_mut().print_error_count(registry) } + pub fn take_future_breakage_diagnostics(&self) -> Vec { + std::mem::take(&mut self.inner.borrow_mut().future_breakage_diagnostics) + } + pub fn abort_if_errors(&self) { self.inner.borrow_mut().abort_if_errors() } @@ -723,6 +724,10 @@ impl Handler { self.inner.borrow_mut().emit_artifact_notification(path, artifact_type) } + pub fn emit_future_breakage_report(&self, diags: Vec<(FutureBreakage, Diagnostic)>) { + self.inner.borrow_mut().emitter.emit_future_breakage_report(diags) + } + pub fn delay_as_bug(&self, diagnostic: Diagnostic) { self.inner.borrow_mut().delay_as_bug(diagnostic) } @@ -748,12 +753,23 @@ impl HandlerInner { return; } + if diagnostic.has_future_breakage() { + self.future_breakage_diagnostics.push(diagnostic.clone()); + } + if diagnostic.level == Warning && !self.flags.can_emit_warnings { + if diagnostic.has_future_breakage() { + (*TRACK_DIAGNOSTICS)(diagnostic); + } return; } (*TRACK_DIAGNOSTICS)(diagnostic); + if diagnostic.level == Allow { + return; + } + if let Some(ref code) = diagnostic.code { self.emitted_diagnostic_codes.insert(code.clone()); } @@ -992,6 +1008,7 @@ pub enum Level { Help, Cancelled, FailureNote, + Allow, } impl fmt::Display for Level { @@ -1017,7 +1034,7 @@ impl Level { spec.set_fg(Some(Color::Cyan)).set_intense(true); } FailureNote => {} - Cancelled => unreachable!(), + Allow | Cancelled => unreachable!(), } spec } @@ -1031,6 +1048,7 @@ impl Level { Help => "help", FailureNote => "failure-note", Cancelled => panic!("Shouldn't call on cancelled error"), + Allow => panic!("Shouldn't call on allowed error"), } } @@ -1039,11 +1057,46 @@ impl Level { } } -#[macro_export] -macro_rules! pluralize { - ($x:expr) => { - if $x != 1 { "s" } else { "" } +pub fn add_elided_lifetime_in_path_suggestion( + source_map: &SourceMap, + db: &mut DiagnosticBuilder<'_>, + n: usize, + path_span: Span, + incl_angl_brckt: bool, + insertion_span: Span, + anon_lts: String, +) { + let (replace_span, suggestion) = if incl_angl_brckt { + (insertion_span, anon_lts) + } else { + // When possible, prefer a suggestion that replaces the whole + // `Path` expression with `Path<'_, T>`, rather than inserting `'_, ` + // at a point (which makes for an ugly/confusing label) + if let Ok(snippet) = source_map.span_to_snippet(path_span) { + // But our spans can get out of whack due to macros; if the place we think + // we want to insert `'_` isn't even within the path expression's span, we + // should bail out of making any suggestion rather than panicking on a + // subtract-with-overflow or string-slice-out-out-bounds (!) + // FIXME: can we do better? + if insertion_span.lo().0 < path_span.lo().0 { + return; + } + let insertion_index = (insertion_span.lo().0 - path_span.lo().0) as usize; + if insertion_index > snippet.len() { + return; + } + let (before, after) = snippet.split_at(insertion_index); + (path_span, format!("{}{}{}", before, anon_lts, after)) + } else { + (insertion_span, anon_lts) + } }; + db.span_suggestion( + replace_span, + &format!("indicate the anonymous lifetime{}", pluralize!(n)), + suggestion, + Applicability::MachineApplicable, + ); } // Useful type to use with `Result<>` indicate that an error has already diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 9dbd59506b188..5340cd6406295 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -275,7 +275,10 @@ pub fn register_plugins<'a>( } }); - Ok((krate, Lrc::new(lint_store))) + let lint_store = Lrc::new(lint_store); + sess.init_lint_store(lint_store.clone()); + + Ok((krate, lint_store)) } fn pre_expansion_lint(sess: &Session, lint_store: &LintStore, krate: &ast::Crate) { diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 235e049c3f566..ad4baaaa52f8a 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -477,6 +477,7 @@ fn test_debugging_options_tracking_hash() { untracked!(dump_mir_dir, String::from("abc")); untracked!(dump_mir_exclude_pass_number, true); untracked!(dump_mir_graphviz, true); + untracked!(emit_future_compat_report, true); untracked!(emit_stack_sizes, true); untracked!(hir_stats, true); untracked!(identify_regions, true); diff --git a/compiler/rustc_lint/src/array_into_iter.rs b/compiler/rustc_lint/src/array_into_iter.rs index e6be082da0e99..0b5bd39f7f984 100644 --- a/compiler/rustc_lint/src/array_into_iter.rs +++ b/compiler/rustc_lint/src/array_into_iter.rs @@ -3,7 +3,7 @@ use rustc_errors::Applicability; use rustc_hir as hir; use rustc_middle::ty; use rustc_middle::ty::adjustment::{Adjust, Adjustment}; -use rustc_session::lint::FutureIncompatibleInfo; +use rustc_session::lint::FutureBreakage; use rustc_span::symbol::sym; declare_lint! { @@ -38,6 +38,9 @@ declare_lint! { @future_incompatible = FutureIncompatibleInfo { reference: "issue #66145 ", edition: None, + future_breakage: Some(FutureBreakage { + date: None + }) }; } diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 7e029aa7a1928..c65cf65b1c777 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -44,7 +44,6 @@ use rustc_middle::lint::LintDiagnosticBuilder; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::subst::{GenericArgKind, Subst}; use rustc_middle::ty::{self, layout::LayoutError, Ty, TyCtxt}; -use rustc_session::lint::FutureIncompatibleInfo; use rustc_session::Session; use rustc_span::edition::Edition; use rustc_span::source_map::Spanned; diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 48270eb59a050..4cfeb0d968b95 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -22,7 +22,7 @@ use rustc_ast as ast; use rustc_ast::util::lev_distance::find_best_match_for_name; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync; -use rustc_errors::{struct_span_err, Applicability}; +use rustc_errors::{add_elided_lifetime_in_path_suggestion, struct_span_err, Applicability}; use rustc_hir as hir; use rustc_hir::def::Res; use rustc_hir::def_id::{CrateNum, DefId}; @@ -33,9 +33,10 @@ use rustc_middle::middle::stability; use rustc_middle::ty::layout::{LayoutError, TyAndLayout}; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::{self, print::Printer, subst::GenericArg, Ty, TyCtxt}; -use rustc_session::lint::{add_elided_lifetime_in_path_suggestion, BuiltinLintDiagnostics}; +use rustc_session::lint::BuiltinLintDiagnostics; use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintBuffer, LintId}; use rustc_session::Session; +use rustc_session::SessionLintStore; use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP}; use rustc_target::abi::LayoutOf; @@ -69,6 +70,20 @@ pub struct LintStore { lint_groups: FxHashMap<&'static str, LintGroup>, } +impl SessionLintStore for LintStore { + fn name_to_lint(&self, lint_name: &str) -> LintId { + let lints = self + .find_lints(lint_name) + .unwrap_or_else(|_| panic!("Failed to find lint with name `{}`", lint_name)); + + if let &[lint] = lints.as_slice() { + return lint; + } else { + panic!("Found mutliple lints with name `{}`: {:?}", lint_name, lints); + } + } +} + /// The target of the `by_name` map, which accounts for renaming/deprecation. enum TargetLint { /// A direct lint target @@ -543,7 +558,7 @@ pub trait LintContext: Sized { anon_lts, ) => { add_elided_lifetime_in_path_suggestion( - sess, + sess.source_map(), &mut db, n, path_span, diff --git a/compiler/rustc_lint_defs/Cargo.toml b/compiler/rustc_lint_defs/Cargo.toml new file mode 100644 index 0000000000000..7f908088cf5b0 --- /dev/null +++ b/compiler/rustc_lint_defs/Cargo.toml @@ -0,0 +1,13 @@ +[package] +authors = ["The Rust Project Developers"] +name = "rustc_lint_defs" +version = "0.0.0" +edition = "2018" + +[dependencies] +log = { package = "tracing", version = "0.1" } +rustc_ast = { path = "../rustc_ast" } +rustc_data_structures = { path = "../rustc_data_structures" } +rustc_span = { path = "../rustc_span" } +rustc_serialize = { path = "../rustc_serialize" } +rustc_macros = { path = "../rustc_macros" } diff --git a/compiler/rustc_session/src/lint/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs similarity index 99% rename from compiler/rustc_session/src/lint/builtin.rs rename to compiler/rustc_lint_defs/src/builtin.rs index b8826a548b8be..048f096aabe13 100644 --- a/compiler/rustc_session/src/lint/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -4,7 +4,6 @@ //! compiler code, rather than using their own custom pass. Those //! lints are all available in `rustc_lint::builtin`. -use crate::lint::FutureIncompatibleInfo; use crate::{declare_lint, declare_lint_pass, declare_tool_lint}; use rustc_span::edition::Edition; use rustc_span::symbol::sym; diff --git a/compiler/rustc_session/src/lint.rs b/compiler/rustc_lint_defs/src/lib.rs similarity index 83% rename from compiler/rustc_session/src/lint.rs rename to compiler/rustc_lint_defs/src/lib.rs index 62e021d5e45bd..25a7bfcabb728 100644 --- a/compiler/rustc_session/src/lint.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -1,12 +1,45 @@ +#[macro_use] +extern crate rustc_macros; + pub use self::Level::*; use rustc_ast::node_id::{NodeId, NodeMap}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey}; -use rustc_errors::{pluralize, Applicability, DiagnosticBuilder}; use rustc_span::edition::Edition; use rustc_span::{sym, symbol::Ident, MultiSpan, Span, Symbol}; pub mod builtin; +#[macro_export] +macro_rules! pluralize { + ($x:expr) => { + if $x != 1 { "s" } else { "" } + }; +} + +/// Indicates the confidence in the correctness of a suggestion. +/// +/// All suggestions are marked with an `Applicability`. Tools use the applicability of a suggestion +/// to determine whether it should be automatically applied or if the user should be consulted +/// before applying the suggestion. +#[derive(Copy, Clone, Debug, PartialEq, Hash, Encodable, Decodable)] +pub enum Applicability { + /// The suggestion is definitely what the user intended. This suggestion should be + /// automatically applied. + MachineApplicable, + + /// The suggestion may be what the user intended, but it is uncertain. The suggestion should + /// result in valid Rust code if it is applied. + MaybeIncorrect, + + /// The suggestion contains placeholders like `(...)` or `{ /* fields */ }`. The suggestion + /// cannot be applied automatically because it will not result in valid Rust code. The user + /// will need to fill in the placeholders. + HasPlaceholders, + + /// The applicability of the suggestion is unknown. + Unspecified, +} + /// Setting for how to handle a lint. #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)] pub enum Level { @@ -106,6 +139,21 @@ pub struct FutureIncompatibleInfo { /// If this is an edition fixing lint, the edition in which /// this lint becomes obsolete pub edition: Option, + /// Information about a future breakage, which will + /// be emitted in JSON messages to be displayed by Cargo + /// for upstream deps + pub future_breakage: Option, +} + +#[derive(Copy, Clone, Debug)] +pub struct FutureBreakage { + pub date: Option<&'static str>, +} + +impl FutureIncompatibleInfo { + pub const fn default_fields_for_macro() -> Self { + FutureIncompatibleInfo { reference: "", edition: None, future_breakage: None } + } } impl Lint { @@ -331,31 +379,34 @@ macro_rules! declare_lint { ); ); ($(#[$attr:meta])* $vis: vis $NAME: ident, $Level: ident, $desc: expr, - $(@future_incompatible = $fi:expr;)? $(@feature_gate = $gate:expr;)? + $(@future_incompatible = FutureIncompatibleInfo { $($field:ident : $val:expr),* $(,)* }; )? $($v:ident),*) => ( $(#[$attr])* - $vis static $NAME: &$crate::lint::Lint = &$crate::lint::Lint { + $vis static $NAME: &$crate::Lint = &$crate::Lint { name: stringify!($NAME), - default_level: $crate::lint::$Level, + default_level: $crate::$Level, desc: $desc, edition_lint_opts: None, is_plugin: false, $($v: true,)* - $(future_incompatible: Some($fi),)* $(feature_gate: Some($gate),)* - ..$crate::lint::Lint::default_fields_for_macro() + $(future_incompatible: Some($crate::FutureIncompatibleInfo { + $($field: $val,)* + ..$crate::FutureIncompatibleInfo::default_fields_for_macro() + }),)* + ..$crate::Lint::default_fields_for_macro() }; ); ($(#[$attr:meta])* $vis: vis $NAME: ident, $Level: ident, $desc: expr, $lint_edition: expr => $edition_level: ident ) => ( $(#[$attr])* - $vis static $NAME: &$crate::lint::Lint = &$crate::lint::Lint { + $vis static $NAME: &$crate::Lint = &$crate::Lint { name: stringify!($NAME), - default_level: $crate::lint::$Level, + default_level: $crate::$Level, desc: $desc, - edition_lint_opts: Some(($lint_edition, $crate::lint::Level::$edition_level)), + edition_lint_opts: Some(($lint_edition, $crate::Level::$edition_level)), report_in_external_macro: false, is_plugin: false, }; @@ -380,9 +431,9 @@ macro_rules! declare_tool_lint { $external:expr ) => ( $(#[$attr])* - $vis static $NAME: &$crate::lint::Lint = &$crate::lint::Lint { + $vis static $NAME: &$crate::Lint = &$crate::Lint { name: &concat!(stringify!($tool), "::", stringify!($NAME)), - default_level: $crate::lint::$Level, + default_level: $crate::$Level, desc: $desc, edition_lint_opts: None, report_in_external_macro: $external, @@ -413,11 +464,11 @@ pub trait LintPass { #[macro_export] macro_rules! impl_lint_pass { ($ty:ty => [$($lint:expr),* $(,)?]) => { - impl $crate::lint::LintPass for $ty { + impl $crate::LintPass for $ty { fn name(&self) -> &'static str { stringify!($ty) } } impl $ty { - pub fn get_lints() -> $crate::lint::LintArray { $crate::lint_array!($($lint),*) } + pub fn get_lints() -> $crate::LintArray { $crate::lint_array!($($lint),*) } } }; } @@ -431,45 +482,3 @@ macro_rules! declare_lint_pass { $crate::impl_lint_pass!($name => [$($lint),*]); }; } - -pub fn add_elided_lifetime_in_path_suggestion( - sess: &crate::Session, - db: &mut DiagnosticBuilder<'_>, - n: usize, - path_span: Span, - incl_angl_brckt: bool, - insertion_span: Span, - anon_lts: String, -) { - let (replace_span, suggestion) = if incl_angl_brckt { - (insertion_span, anon_lts) - } else { - // When possible, prefer a suggestion that replaces the whole - // `Path` expression with `Path<'_, T>`, rather than inserting `'_, ` - // at a point (which makes for an ugly/confusing label) - if let Ok(snippet) = sess.source_map().span_to_snippet(path_span) { - // But our spans can get out of whack due to macros; if the place we think - // we want to insert `'_` isn't even within the path expression's span, we - // should bail out of making any suggestion rather than panicking on a - // subtract-with-overflow or string-slice-out-out-bounds (!) - // FIXME: can we do better? - if insertion_span.lo().0 < path_span.lo().0 { - return; - } - let insertion_index = (insertion_span.lo().0 - path_span.lo().0) as usize; - if insertion_index > snippet.len() { - return; - } - let (before, after) = snippet.split_at(insertion_index); - (path_span, format!("{}{}{}", before, anon_lts, after)) - } else { - (insertion_span, anon_lts) - } - }; - db.span_suggestion( - replace_span, - &format!("indicate the anonymous lifetime{}", pluralize!(n)), - suggestion, - Applicability::MachineApplicable, - ); -} diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index 91e1d6e0b0b72..6e67f0d828c05 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -225,9 +225,24 @@ pub fn struct_lint_level<'s, 'd>( span: Option, decorate: Box FnOnce(LintDiagnosticBuilder<'b>) + 'd>, ) { + // Check for future incompatibility lints and issue a stronger warning. + let lint_id = LintId::of(lint); + let future_incompatible = lint.future_incompatible; + + let has_future_breakage = + future_incompatible.map_or(false, |incompat| incompat.future_breakage.is_some()); + let mut err = match (level, span) { - (Level::Allow, _) => { - return; + (Level::Allow, span) => { + if has_future_breakage { + if let Some(span) = span { + sess.struct_span_allow(span, "") + } else { + sess.struct_allow("") + } + } else { + return; + } } (Level::Warn, Some(span)) => sess.struct_span_warn(span, ""), (Level::Warn, None) => sess.struct_warn(""), @@ -235,10 +250,6 @@ pub fn struct_lint_level<'s, 'd>( (Level::Deny | Level::Forbid, None) => sess.struct_err(""), }; - // Check for future incompatibility lints and issue a stronger warning. - let lint_id = LintId::of(lint); - let future_incompatible = lint.future_incompatible; - // If this code originates in a foreign macro, aka something that this crate // did not itself author, then it's likely that there's nothing this crate // can do about it. We probably want to skip the lint entirely. @@ -321,7 +332,7 @@ pub fn struct_lint_level<'s, 'd>( } } - err.code(DiagnosticId::Lint(name)); + err.code(DiagnosticId::Lint { name, has_future_breakage }); if let Some(future_incompatible) = future_incompatible { const STANDARD_MESSAGE: &str = "this was previously accepted by the compiler but is being phased out; \ diff --git a/compiler/rustc_session/Cargo.toml b/compiler/rustc_session/Cargo.toml index cdff1662fdb0e..4c72920502f5f 100644 --- a/compiler/rustc_session/Cargo.toml +++ b/compiler/rustc_session/Cargo.toml @@ -18,3 +18,4 @@ rustc_span = { path = "../rustc_span" } rustc_fs_util = { path = "../rustc_fs_util" } num_cpus = "1.0" rustc_ast = { path = "../rustc_ast" } +rustc_lint_defs = { path = "../rustc_lint_defs" } diff --git a/compiler/rustc_session/src/lib.rs b/compiler/rustc_session/src/lib.rs index a808261798da7..d002f59739166 100644 --- a/compiler/rustc_session/src/lib.rs +++ b/compiler/rustc_session/src/lib.rs @@ -9,8 +9,8 @@ extern crate rustc_macros; pub mod cgu_reuse_tracker; pub mod utils; -#[macro_use] -pub mod lint; +pub use lint::{declare_lint, declare_lint_pass, declare_tool_lint, impl_lint_pass}; +pub use rustc_lint_defs as lint; pub mod parse; mod code_stats; diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 750f2e19ee257..aaed8488c9241 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -893,6 +893,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, all `statement`s (including terminators), only `terminator` spans, or \ computed `block` spans (one span encompassing a block's terminator and \ all statements)."), + emit_future_compat_report: bool = (false, parse_bool, [UNTRACKED], + "emits a future-compatibility report for lints (RFC 2834)"), emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED], "emit a section containing stack size metadata (default: no)"), fewer_names: bool = (false, parse_bool, [TRACKED], diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 8312f89b2714c..5ef4883c99ba3 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -3,7 +3,7 @@ use crate::code_stats::CodeStats; pub use crate::code_stats::{DataTypeKind, FieldInfo, SizeKind, VariantInfo}; use crate::config::{self, CrateType, OutputType, PrintRequest, SanitizerSet, SwitchWithOptPath}; use crate::filesearch; -use crate::lint; +use crate::lint::{self, LintId}; use crate::parse::ParseSess; use crate::search_paths::{PathKind, SearchPath}; @@ -21,7 +21,8 @@ use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitterWriter; use rustc_errors::emitter::{Emitter, EmitterWriter, HumanReadableErrorType}; use rustc_errors::json::JsonEmitter; use rustc_errors::registry::Registry; -use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticId, ErrorReported}; +use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, DiagnosticId, ErrorReported}; +use rustc_lint_defs::FutureBreakage; use rustc_span::edition::Edition; use rustc_span::source_map::{FileLoader, MultiSpan, RealFileLoader, SourceMap, Span}; use rustc_span::{sym, SourceFileHashAlgorithm, Symbol}; @@ -40,6 +41,10 @@ use std::str::FromStr; use std::sync::Arc; use std::time::Duration; +pub trait SessionLintStore: sync::Send + sync::Sync { + fn name_to_lint(&self, lint_name: &str) -> LintId; +} + pub struct OptimizationFuel { /// If `-zfuel=crate=n` is specified, initially set to `n`, otherwise `0`. remaining: u64, @@ -131,6 +136,8 @@ pub struct Session { features: OnceCell, + lint_store: OnceCell>, + /// The maximum recursion limit for potentially infinitely recursive /// operations such as auto-dereference and monomorphization. pub recursion_limit: OnceCell, @@ -297,6 +304,35 @@ impl Session { pub fn finish_diagnostics(&self, registry: &Registry) { self.check_miri_unleashed_features(); self.diagnostic().print_error_count(registry); + self.emit_future_breakage(); + } + + fn emit_future_breakage(&self) { + if !self.opts.debugging_opts.emit_future_compat_report { + return; + } + + let diags = self.diagnostic().take_future_breakage_diagnostics(); + if diags.is_empty() { + return; + } + // If any future-breakage lints were registered, this lint store + // should be available + let lint_store = self.lint_store.get().expect("`lint_store` not initialized!"); + let diags_and_breakage: Vec<(FutureBreakage, Diagnostic)> = diags + .into_iter() + .map(|diag| { + let lint_name = match &diag.code { + Some(DiagnosticId::Lint { name, has_future_breakage: true }) => name, + _ => panic!("Unexpected code in diagnostic {:?}", diag), + }; + let lint = lint_store.name_to_lint(&lint_name); + let future_breakage = + lint.lint.future_incompatible.unwrap().future_breakage.unwrap(); + (future_breakage, diag) + }) + .collect(); + self.parse_sess.span_diagnostic.emit_future_breakage_report(diags_and_breakage); } pub fn local_crate_disambiguator(&self) -> CrateDisambiguator { @@ -337,6 +373,12 @@ impl Session { pub fn struct_warn(&self, msg: &str) -> DiagnosticBuilder<'_> { self.diagnostic().struct_warn(msg) } + pub fn struct_span_allow>(&self, sp: S, msg: &str) -> DiagnosticBuilder<'_> { + self.diagnostic().struct_span_allow(sp, msg) + } + pub fn struct_allow(&self, msg: &str) -> DiagnosticBuilder<'_> { + self.diagnostic().struct_allow(msg) + } pub fn struct_span_err>(&self, sp: S, msg: &str) -> DiagnosticBuilder<'_> { self.diagnostic().struct_span_err(sp, msg) } @@ -611,6 +653,13 @@ impl Session { } } + pub fn init_lint_store(&self, lint_store: Lrc) { + self.lint_store + .set(lint_store) + .map_err(|_| ()) + .expect("`lint_store` was initialized twice"); + } + /// Calculates the flavor of LTO to use for this compilation. pub fn lto(&self) -> config::Lto { // If our target has codegen requirements ignore the command line @@ -1388,6 +1437,7 @@ pub fn build_session( crate_types: OnceCell::new(), crate_disambiguator: OnceCell::new(), features: OnceCell::new(), + lint_store: OnceCell::new(), recursion_limit: OnceCell::new(), type_length_limit: OnceCell::new(), const_eval_limit: OnceCell::new(), From 6bdb4e32067a37b339d77f7788a772356d486f72 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Sun, 18 Oct 2020 15:28:23 -0400 Subject: [PATCH 17/25] Some work --- compiler/rustc_errors/src/json.rs | 10 ++++++-- compiler/rustc_session/src/options.rs | 4 ++-- compiler/rustc_session/src/session.rs | 2 +- .../iterators/into-iter-on-arrays-lint.fixed | 1 + .../ui/iterators/into-iter-on-arrays-lint.rs | 1 + .../iterators/into-iter-on-arrays-lint.stderr | 24 +++++++++---------- src/tools/compiletest/src/json.rs | 19 +++++++++++++-- 7 files changed, 42 insertions(+), 19 deletions(-) diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index ddffa64f2225d..d57beb1148a25 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -145,10 +145,11 @@ impl Emitter for JsonEmitter { } }) .collect(); + let report = FutureIncompatReport { future_incompat_report: data }; let result = if self.pretty { - writeln!(&mut self.dst, "{}", as_pretty_json(&data)) + writeln!(&mut self.dst, "{}", as_pretty_json(&report)) } else { - writeln!(&mut self.dst, "{}", as_json(&data)) + writeln!(&mut self.dst, "{}", as_json(&report)) } .and_then(|_| self.dst.flush()); if let Err(e) = result { @@ -254,6 +255,11 @@ struct FutureBreakageItem { diagnostic: Diagnostic, } +#[derive(Encodable)] +struct FutureIncompatReport { + future_incompat_report: Vec, +} + impl Diagnostic { fn from_errors_diagnostic(diag: &crate::Diagnostic, je: &JsonEmitter) -> Diagnostic { let sugg = diag.suggestions.iter().map(|sugg| Diagnostic { diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index aaed8488c9241..578caf2192d5f 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -893,8 +893,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, all `statement`s (including terminators), only `terminator` spans, or \ computed `block` spans (one span encompassing a block's terminator and \ all statements)."), - emit_future_compat_report: bool = (false, parse_bool, [UNTRACKED], - "emits a future-compatibility report for lints (RFC 2834)"), + emit_future_incompat_report: bool = (false, parse_bool, [UNTRACKED], + "emits a future-incompatibility report for lints (RFC 2834)"), emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED], "emit a section containing stack size metadata (default: no)"), fewer_names: bool = (false, parse_bool, [TRACKED], diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 5ef4883c99ba3..0b7c35a8afd50 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -308,7 +308,7 @@ impl Session { } fn emit_future_breakage(&self) { - if !self.opts.debugging_opts.emit_future_compat_report { + if !self.opts.debugging_opts.emit_future_incompat_report { return; } diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.fixed b/src/test/ui/iterators/into-iter-on-arrays-lint.fixed index 561376c8f059d..1e473a2b720b3 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.fixed +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.fixed @@ -1,5 +1,6 @@ // run-pass // run-rustfix +// compiler-flags: -Z emit-future-compat-report fn main() { let small = [1, 2]; diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.rs b/src/test/ui/iterators/into-iter-on-arrays-lint.rs index cc310191f0caf..8e441ed56a123 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.rs +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.rs @@ -1,5 +1,6 @@ // run-pass // run-rustfix +// compile-flags: -Z emit-future-incompat-report fn main() { let small = [1, 2]; diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.stderr b/src/test/ui/iterators/into-iter-on-arrays-lint.stderr index b31f444b36e99..89e5881b9558f 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.stderr +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.stderr @@ -1,5 +1,5 @@ warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:9:11 + --> $DIR/into-iter-on-arrays-lint.rs:10:11 | LL | small.into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -9,7 +9,7 @@ LL | small.into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:12:12 + --> $DIR/into-iter-on-arrays-lint.rs:13:12 | LL | [1, 2].into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -18,7 +18,7 @@ LL | [1, 2].into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:15:9 + --> $DIR/into-iter-on-arrays-lint.rs:16:9 | LL | big.into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -27,7 +27,7 @@ LL | big.into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:18:15 + --> $DIR/into-iter-on-arrays-lint.rs:19:15 | LL | [0u8; 33].into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -36,7 +36,7 @@ LL | [0u8; 33].into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:22:21 + --> $DIR/into-iter-on-arrays-lint.rs:23:21 | LL | Box::new(small).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -45,7 +45,7 @@ LL | Box::new(small).into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:25:22 + --> $DIR/into-iter-on-arrays-lint.rs:26:22 | LL | Box::new([1, 2]).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -54,7 +54,7 @@ LL | Box::new([1, 2]).into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:28:19 + --> $DIR/into-iter-on-arrays-lint.rs:29:19 | LL | Box::new(big).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -63,7 +63,7 @@ LL | Box::new(big).into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:31:25 + --> $DIR/into-iter-on-arrays-lint.rs:32:25 | LL | Box::new([0u8; 33]).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -72,7 +72,7 @@ LL | Box::new([0u8; 33]).into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:35:31 + --> $DIR/into-iter-on-arrays-lint.rs:36:31 | LL | Box::new(Box::new(small)).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -81,7 +81,7 @@ LL | Box::new(Box::new(small)).into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:38:32 + --> $DIR/into-iter-on-arrays-lint.rs:39:32 | LL | Box::new(Box::new([1, 2])).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -90,7 +90,7 @@ LL | Box::new(Box::new([1, 2])).into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:41:29 + --> $DIR/into-iter-on-arrays-lint.rs:42:29 | LL | Box::new(Box::new(big)).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -99,7 +99,7 @@ LL | Box::new(Box::new(big)).into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:44:35 + --> $DIR/into-iter-on-arrays-lint.rs:45:35 | LL | Box::new(Box::new([0u8; 33])).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index 6a03a76c566ef..643475dc5399f 100644 --- a/src/tools/compiletest/src/json.rs +++ b/src/tools/compiletest/src/json.rs @@ -36,6 +36,17 @@ struct DiagnosticSpan { expansion: Option>, } +#[derive(Deserialize)] +struct FutureIncompatReport { + future_incompat_report: Vec +} + +#[derive(Deserialize)] +struct FutureBreakageItem { + future_breakage_date: Option, + diagnostic: Diagnostic +} + impl DiagnosticSpan { /// Returns the deepest source span in the macro call stack with a given file name. /// This is either the supplied span, or the span for some macro callsite that expanded to it. @@ -94,10 +105,14 @@ pub fn extract_rendered(output: &str) -> String { } pub fn parse_output(file_name: &str, output: &str, proc_res: &ProcRes) -> Vec { - output.lines().flat_map(|line| parse_line(file_name, line, output, proc_res)).collect() + let lines = output.lines(); + let last_line = lines.next_back(); + lines.flat_map(|line| parse_line(file_name, line, output, proc_res, false)).chain( + last_line.into_iter().flat_map(|line| parse_line(file_name, line, output, proc_res, true)) + ).collect() } -fn parse_line(file_name: &str, line: &str, output: &str, proc_res: &ProcRes) -> Vec { +fn parse_line(file_name: &str, line: &str, output: &str, proc_res: &ProcRes, last_line: bool) -> Vec { // The compiler sometimes intermingles non-JSON stuff into the // output. This hack just skips over such lines. Yuck. if line.starts_with('{') { From a77a65c029fc2543ec753982ff8d6da2bdb1d866 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Mon, 19 Oct 2020 11:19:37 -0400 Subject: [PATCH 18/25] Print future breakage report --- src/tools/compiletest/src/json.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index 643475dc5399f..1171a598d8bd8 100644 --- a/src/tools/compiletest/src/json.rs +++ b/src/tools/compiletest/src/json.rs @@ -86,6 +86,13 @@ pub fn extract_rendered(output: &str) -> String { if line.starts_with('{') { if let Ok(diagnostic) = serde_json::from_str::(line) { diagnostic.rendered + } else if let Ok(report) = serde_json::from_str::(line) { + Some(format!("Future incompatibility report: {}", + report.future_incompat_report.into_iter().map(|item| { + format!("Future breakage date: {}, diagnostic:\n{}", + item.future_breakage_date.unwrap_or_else(|| "None".to_string()), + item.diagnostic.rendered.unwrap_or_else(|| "Not rendered".to_string())) + }).collect::())) } else if serde_json::from_str::(line).is_ok() { // Ignore the notification. None @@ -105,14 +112,10 @@ pub fn extract_rendered(output: &str) -> String { } pub fn parse_output(file_name: &str, output: &str, proc_res: &ProcRes) -> Vec { - let lines = output.lines(); - let last_line = lines.next_back(); - lines.flat_map(|line| parse_line(file_name, line, output, proc_res, false)).chain( - last_line.into_iter().flat_map(|line| parse_line(file_name, line, output, proc_res, true)) - ).collect() + output.lines().flat_map(|line| parse_line(file_name, line, output, proc_res)).collect() } -fn parse_line(file_name: &str, line: &str, output: &str, proc_res: &ProcRes, last_line: bool) -> Vec { +fn parse_line(file_name: &str, line: &str, output: &str, proc_res: &ProcRes) -> Vec { // The compiler sometimes intermingles non-JSON stuff into the // output. This hack just skips over such lines. Yuck. if line.starts_with('{') { From 2d17597f849fce55aa730edaa8f1bf0e91d64147 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Mon, 19 Oct 2020 11:43:38 -0400 Subject: [PATCH 19/25] Strip out non-diagnostic lines from rustfix input --- src/tools/compiletest/src/json.rs | 22 +++++++++++++++++----- src/tools/compiletest/src/runtest.rs | 5 +++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index 1171a598d8bd8..8eeaf8b1bb50c 100644 --- a/src/tools/compiletest/src/json.rs +++ b/src/tools/compiletest/src/json.rs @@ -79,6 +79,12 @@ struct DiagnosticCode { explanation: Option, } +pub fn rustfix_diagnostics_only(output: &str) -> String { + output.lines().filter(|line| { + line.starts_with('{') && serde_json::from_str::(line).is_ok() + }).collect() +} + pub fn extract_rendered(output: &str) -> String { output .lines() @@ -126,11 +132,17 @@ fn parse_line(file_name: &str, line: &str, output: &str, proc_res: &ProcRes) -> expected_errors } Err(error) => { - proc_res.fatal(Some(&format!( - "failed to decode compiler output as json: \ - `{}`\nline: {}\noutput: {}", - error, line, output - ))); + // Ignore the future compat report message - this is handled + // by `extract_rendered` + if serde_json::from_str::(line).is_ok() { + vec![] + } else { + proc_res.fatal(Some(&format!( + "failed to decode compiler output as json: \ + `{}`\nline: {}\noutput: {}", + error, line, output + ))); + } } } } else { diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 666e5d402ef1e..0f2165edacb64 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2978,6 +2978,7 @@ impl<'test> TestCx<'test> { self.prune_duplicate_outputs(&modes_to_prune); let mut errors = self.load_compare_outputs(&proc_res, TestOutput::Compile, explicit); + let rustfix_input = json::rustfix_diagnostics_only(&proc_res.stderr); if self.config.compare_mode.is_some() { // don't test rustfix with nll right now @@ -2988,7 +2989,7 @@ impl<'test> TestCx<'test> { // This will return an empty `Vec` in case the executed test file has a // `compile-flags: --error-format=xxxx` header with a value other than `json`. let suggestions = get_suggestions_from_json( - &proc_res.stderr, + &rustfix_input, &HashSet::new(), Filter::MachineApplicableOnly, ) @@ -3015,7 +3016,7 @@ impl<'test> TestCx<'test> { // Apply suggestions from rustc to the code itself let unfixed_code = self.load_expected_output_from_path(&self.testpaths.file).unwrap(); let suggestions = get_suggestions_from_json( - &proc_res.stderr, + &rustfix_input, &HashSet::new(), if self.props.rustfix_only_machine_applicable { Filter::MachineApplicableOnly From 4b4f84f3274e2d5662c76f52769ac4b7e6826fcf Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Mon, 19 Oct 2020 11:49:07 -0400 Subject: [PATCH 20/25] Only error on unfixed diagnostics --- src/tools/compiletest/src/runtest.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 0f2165edacb64..f36bc662ea89c 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -3122,7 +3122,9 @@ impl<'test> TestCx<'test> { self.fatal_proc_rec("failed to compile fixed code", &res); } if !res.stderr.is_empty() && !self.props.rustfix_only_machine_applicable { - self.fatal_proc_rec("fixed code is still producing diagnostics", &res); + if !json::rustfix_diagnostics_only(&res.stderr).is_empty() { + self.fatal_proc_rec("fixed code is still producing diagnostics", &res); + } } } } From 4621ce9858856389c32f890725feac489bc94ac5 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Mon, 19 Oct 2020 11:50:36 -0400 Subject: [PATCH 21/25] Update into-iter-on-arrays test to check future-incompat-report --- .../iterators/into-iter-on-arrays-lint.fixed | 5 +- .../ui/iterators/into-iter-on-arrays-lint.rs | 3 + .../iterators/into-iter-on-arrays-lint.stderr | 136 ++++++++++++++++++ src/tools/compiletest/src/json.rs | 33 +++-- 4 files changed, 165 insertions(+), 12 deletions(-) diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.fixed b/src/test/ui/iterators/into-iter-on-arrays-lint.fixed index 1e473a2b720b3..08df0cbe9738a 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.fixed +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.fixed @@ -1,6 +1,6 @@ // run-pass // run-rustfix -// compiler-flags: -Z emit-future-compat-report +// compile-flags: -Z emit-future-incompat-report fn main() { let small = [1, 2]; @@ -56,4 +56,7 @@ fn main() { (&small as &[_]).into_iter(); small[..].into_iter(); std::iter::IntoIterator::into_iter(&[1, 2]); + + #[allow(array_into_iter)] + [0, 1].into_iter(); } diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.rs b/src/test/ui/iterators/into-iter-on-arrays-lint.rs index 8e441ed56a123..cd12698da7edf 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.rs +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.rs @@ -56,4 +56,7 @@ fn main() { (&small as &[_]).into_iter(); small[..].into_iter(); std::iter::IntoIterator::into_iter(&[1, 2]); + + #[allow(array_into_iter)] + [0, 1].into_iter(); } diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.stderr b/src/test/ui/iterators/into-iter-on-arrays-lint.stderr index 89e5881b9558f..87965bdda7a16 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.stderr +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.stderr @@ -109,3 +109,139 @@ LL | Box::new(Box::new([0u8; 33])).into_iter(); warning: 12 warnings emitted +Future incompatibility report: Future breakage date: None, diagnostic: +warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. + --> $DIR/into-iter-on-arrays-lint.rs:10:11 + | +LL | small.into_iter(); + | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` + | + = note: `#[warn(array_into_iter)]` on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #66145 + +Future breakage date: None, diagnostic: +warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. + --> $DIR/into-iter-on-arrays-lint.rs:13:12 + | +LL | [1, 2].into_iter(); + | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #66145 + +Future breakage date: None, diagnostic: +warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. + --> $DIR/into-iter-on-arrays-lint.rs:16:9 + | +LL | big.into_iter(); + | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #66145 + +Future breakage date: None, diagnostic: +warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. + --> $DIR/into-iter-on-arrays-lint.rs:19:15 + | +LL | [0u8; 33].into_iter(); + | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #66145 + +Future breakage date: None, diagnostic: +warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. + --> $DIR/into-iter-on-arrays-lint.rs:23:21 + | +LL | Box::new(small).into_iter(); + | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #66145 + +Future breakage date: None, diagnostic: +warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. + --> $DIR/into-iter-on-arrays-lint.rs:26:22 + | +LL | Box::new([1, 2]).into_iter(); + | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #66145 + +Future breakage date: None, diagnostic: +warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. + --> $DIR/into-iter-on-arrays-lint.rs:29:19 + | +LL | Box::new(big).into_iter(); + | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #66145 + +Future breakage date: None, diagnostic: +warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. + --> $DIR/into-iter-on-arrays-lint.rs:32:25 + | +LL | Box::new([0u8; 33]).into_iter(); + | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #66145 + +Future breakage date: None, diagnostic: +warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. + --> $DIR/into-iter-on-arrays-lint.rs:36:31 + | +LL | Box::new(Box::new(small)).into_iter(); + | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #66145 + +Future breakage date: None, diagnostic: +warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. + --> $DIR/into-iter-on-arrays-lint.rs:39:32 + | +LL | Box::new(Box::new([1, 2])).into_iter(); + | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #66145 + +Future breakage date: None, diagnostic: +warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. + --> $DIR/into-iter-on-arrays-lint.rs:42:29 + | +LL | Box::new(Box::new(big)).into_iter(); + | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #66145 + +Future breakage date: None, diagnostic: +warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. + --> $DIR/into-iter-on-arrays-lint.rs:45:35 + | +LL | Box::new(Box::new([0u8; 33])).into_iter(); + | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #66145 + +Future breakage date: None, diagnostic: +warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. + --> $DIR/into-iter-on-arrays-lint.rs:61:12 + | +LL | [0, 1].into_iter(); + | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` + | +note: the lint level is defined here + --> $DIR/into-iter-on-arrays-lint.rs:60:13 + | +LL | #[allow(array_into_iter)] + | ^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #66145 + diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index 8eeaf8b1bb50c..176c3219307ca 100644 --- a/src/tools/compiletest/src/json.rs +++ b/src/tools/compiletest/src/json.rs @@ -38,13 +38,13 @@ struct DiagnosticSpan { #[derive(Deserialize)] struct FutureIncompatReport { - future_incompat_report: Vec + future_incompat_report: Vec, } #[derive(Deserialize)] struct FutureBreakageItem { future_breakage_date: Option, - diagnostic: Diagnostic + diagnostic: Diagnostic, } impl DiagnosticSpan { @@ -80,9 +80,10 @@ struct DiagnosticCode { } pub fn rustfix_diagnostics_only(output: &str) -> String { - output.lines().filter(|line| { - line.starts_with('{') && serde_json::from_str::(line).is_ok() - }).collect() + output + .lines() + .filter(|line| line.starts_with('{') && serde_json::from_str::(line).is_ok()) + .collect() } pub fn extract_rendered(output: &str) -> String { @@ -93,12 +94,22 @@ pub fn extract_rendered(output: &str) -> String { if let Ok(diagnostic) = serde_json::from_str::(line) { diagnostic.rendered } else if let Ok(report) = serde_json::from_str::(line) { - Some(format!("Future incompatibility report: {}", - report.future_incompat_report.into_iter().map(|item| { - format!("Future breakage date: {}, diagnostic:\n{}", - item.future_breakage_date.unwrap_or_else(|| "None".to_string()), - item.diagnostic.rendered.unwrap_or_else(|| "Not rendered".to_string())) - }).collect::())) + Some(format!( + "Future incompatibility report: {}", + report + .future_incompat_report + .into_iter() + .map(|item| { + format!( + "Future breakage date: {}, diagnostic:\n{}", + item.future_breakage_date.unwrap_or_else(|| "None".to_string()), + item.diagnostic + .rendered + .unwrap_or_else(|| "Not rendered".to_string()) + ) + }) + .collect::() + )) } else if serde_json::from_str::(line).is_ok() { // Ignore the notification. None From 2f6e59d94126bf9d4d09fe92b18d329a1631448f Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Mon, 19 Oct 2020 11:54:09 -0400 Subject: [PATCH 22/25] Don't display empty future-compat report --- src/tools/compiletest/src/json.rs | 37 ++++++++++++++++++------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index 176c3219307ca..19aec0ea598f9 100644 --- a/src/tools/compiletest/src/json.rs +++ b/src/tools/compiletest/src/json.rs @@ -94,22 +94,27 @@ pub fn extract_rendered(output: &str) -> String { if let Ok(diagnostic) = serde_json::from_str::(line) { diagnostic.rendered } else if let Ok(report) = serde_json::from_str::(line) { - Some(format!( - "Future incompatibility report: {}", - report - .future_incompat_report - .into_iter() - .map(|item| { - format!( - "Future breakage date: {}, diagnostic:\n{}", - item.future_breakage_date.unwrap_or_else(|| "None".to_string()), - item.diagnostic - .rendered - .unwrap_or_else(|| "Not rendered".to_string()) - ) - }) - .collect::() - )) + if report.future_incompat_report.is_empty() { + None + } else { + Some(format!( + "Future incompatibility report: {}", + report + .future_incompat_report + .into_iter() + .map(|item| { + format!( + "Future breakage date: {}, diagnostic:\n{}", + item.future_breakage_date + .unwrap_or_else(|| "None".to_string()), + item.diagnostic + .rendered + .unwrap_or_else(|| "Not rendered".to_string()) + ) + }) + .collect::() + )) + } } else if serde_json::from_str::(line).is_ok() { // Ignore the notification. None From 7b7c22382759f283c7b203564911937aee270158 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Mon, 19 Oct 2020 11:55:35 -0400 Subject: [PATCH 23/25] Always pass `-Z future-incompat-report` to UI tests --- .../iterators/into-iter-on-arrays-lint.fixed | 1 - .../ui/iterators/into-iter-on-arrays-lint.rs | 1 - .../iterators/into-iter-on-arrays-lint.stderr | 52 +++++++++---------- src/tools/compiletest/src/runtest.rs | 1 + 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.fixed b/src/test/ui/iterators/into-iter-on-arrays-lint.fixed index 08df0cbe9738a..7f511bde3cbfc 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.fixed +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.fixed @@ -1,6 +1,5 @@ // run-pass // run-rustfix -// compile-flags: -Z emit-future-incompat-report fn main() { let small = [1, 2]; diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.rs b/src/test/ui/iterators/into-iter-on-arrays-lint.rs index cd12698da7edf..d5fe83a7834b6 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.rs +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.rs @@ -1,6 +1,5 @@ // run-pass // run-rustfix -// compile-flags: -Z emit-future-incompat-report fn main() { let small = [1, 2]; diff --git a/src/test/ui/iterators/into-iter-on-arrays-lint.stderr b/src/test/ui/iterators/into-iter-on-arrays-lint.stderr index 87965bdda7a16..211315c3fcf05 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-lint.stderr +++ b/src/test/ui/iterators/into-iter-on-arrays-lint.stderr @@ -1,5 +1,5 @@ warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:10:11 + --> $DIR/into-iter-on-arrays-lint.rs:9:11 | LL | small.into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -9,7 +9,7 @@ LL | small.into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:13:12 + --> $DIR/into-iter-on-arrays-lint.rs:12:12 | LL | [1, 2].into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -18,7 +18,7 @@ LL | [1, 2].into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:16:9 + --> $DIR/into-iter-on-arrays-lint.rs:15:9 | LL | big.into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -27,7 +27,7 @@ LL | big.into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:19:15 + --> $DIR/into-iter-on-arrays-lint.rs:18:15 | LL | [0u8; 33].into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -36,7 +36,7 @@ LL | [0u8; 33].into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:23:21 + --> $DIR/into-iter-on-arrays-lint.rs:22:21 | LL | Box::new(small).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -45,7 +45,7 @@ LL | Box::new(small).into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:26:22 + --> $DIR/into-iter-on-arrays-lint.rs:25:22 | LL | Box::new([1, 2]).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -54,7 +54,7 @@ LL | Box::new([1, 2]).into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:29:19 + --> $DIR/into-iter-on-arrays-lint.rs:28:19 | LL | Box::new(big).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -63,7 +63,7 @@ LL | Box::new(big).into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:32:25 + --> $DIR/into-iter-on-arrays-lint.rs:31:25 | LL | Box::new([0u8; 33]).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -72,7 +72,7 @@ LL | Box::new([0u8; 33]).into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:36:31 + --> $DIR/into-iter-on-arrays-lint.rs:35:31 | LL | Box::new(Box::new(small)).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -81,7 +81,7 @@ LL | Box::new(Box::new(small)).into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:39:32 + --> $DIR/into-iter-on-arrays-lint.rs:38:32 | LL | Box::new(Box::new([1, 2])).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -90,7 +90,7 @@ LL | Box::new(Box::new([1, 2])).into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:42:29 + --> $DIR/into-iter-on-arrays-lint.rs:41:29 | LL | Box::new(Box::new(big)).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -99,7 +99,7 @@ LL | Box::new(Box::new(big)).into_iter(); = note: for more information, see issue #66145 warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:45:35 + --> $DIR/into-iter-on-arrays-lint.rs:44:35 | LL | Box::new(Box::new([0u8; 33])).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -111,7 +111,7 @@ warning: 12 warnings emitted Future incompatibility report: Future breakage date: None, diagnostic: warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:10:11 + --> $DIR/into-iter-on-arrays-lint.rs:9:11 | LL | small.into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -122,7 +122,7 @@ LL | small.into_iter(); Future breakage date: None, diagnostic: warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:13:12 + --> $DIR/into-iter-on-arrays-lint.rs:12:12 | LL | [1, 2].into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -132,7 +132,7 @@ LL | [1, 2].into_iter(); Future breakage date: None, diagnostic: warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:16:9 + --> $DIR/into-iter-on-arrays-lint.rs:15:9 | LL | big.into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -142,7 +142,7 @@ LL | big.into_iter(); Future breakage date: None, diagnostic: warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:19:15 + --> $DIR/into-iter-on-arrays-lint.rs:18:15 | LL | [0u8; 33].into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -152,7 +152,7 @@ LL | [0u8; 33].into_iter(); Future breakage date: None, diagnostic: warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:23:21 + --> $DIR/into-iter-on-arrays-lint.rs:22:21 | LL | Box::new(small).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -162,7 +162,7 @@ LL | Box::new(small).into_iter(); Future breakage date: None, diagnostic: warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:26:22 + --> $DIR/into-iter-on-arrays-lint.rs:25:22 | LL | Box::new([1, 2]).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -172,7 +172,7 @@ LL | Box::new([1, 2]).into_iter(); Future breakage date: None, diagnostic: warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:29:19 + --> $DIR/into-iter-on-arrays-lint.rs:28:19 | LL | Box::new(big).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -182,7 +182,7 @@ LL | Box::new(big).into_iter(); Future breakage date: None, diagnostic: warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:32:25 + --> $DIR/into-iter-on-arrays-lint.rs:31:25 | LL | Box::new([0u8; 33]).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -192,7 +192,7 @@ LL | Box::new([0u8; 33]).into_iter(); Future breakage date: None, diagnostic: warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:36:31 + --> $DIR/into-iter-on-arrays-lint.rs:35:31 | LL | Box::new(Box::new(small)).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -202,7 +202,7 @@ LL | Box::new(Box::new(small)).into_iter(); Future breakage date: None, diagnostic: warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:39:32 + --> $DIR/into-iter-on-arrays-lint.rs:38:32 | LL | Box::new(Box::new([1, 2])).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -212,7 +212,7 @@ LL | Box::new(Box::new([1, 2])).into_iter(); Future breakage date: None, diagnostic: warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:42:29 + --> $DIR/into-iter-on-arrays-lint.rs:41:29 | LL | Box::new(Box::new(big)).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -222,7 +222,7 @@ LL | Box::new(Box::new(big)).into_iter(); Future breakage date: None, diagnostic: warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:45:35 + --> $DIR/into-iter-on-arrays-lint.rs:44:35 | LL | Box::new(Box::new([0u8; 33])).into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` @@ -232,13 +232,13 @@ LL | Box::new(Box::new([0u8; 33])).into_iter(); Future breakage date: None, diagnostic: warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added. - --> $DIR/into-iter-on-arrays-lint.rs:61:12 + --> $DIR/into-iter-on-arrays-lint.rs:60:12 | LL | [0, 1].into_iter(); | ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter` | note: the lint level is defined here - --> $DIR/into-iter-on-arrays-lint.rs:60:13 + --> $DIR/into-iter-on-arrays-lint.rs:59:13 | LL | #[allow(array_into_iter)] | ^^^^^^^^^^^^^^^ diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index f36bc662ea89c..19ddcf3a01091 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1942,6 +1942,7 @@ impl<'test> TestCx<'test> { } rustc.arg("-Zui-testing"); rustc.arg("-Zdeduplicate-diagnostics=no"); + rustc.arg("-Zemit-future-incompat-report"); } MirOpt => { rustc.args(&[ From ac12e6fd0ede4b7043851960e1e1749f708356d9 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Tue, 20 Oct 2020 07:57:24 -0400 Subject: [PATCH 24/25] Fix test --- compiler/rustc_interface/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index ad4baaaa52f8a..9332554eede33 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -477,7 +477,7 @@ fn test_debugging_options_tracking_hash() { untracked!(dump_mir_dir, String::from("abc")); untracked!(dump_mir_exclude_pass_number, true); untracked!(dump_mir_graphviz, true); - untracked!(emit_future_compat_report, true); + untracked!(emit_future_incompat_report, true); untracked!(emit_stack_sizes, true); untracked!(hir_stats, true); untracked!(identify_regions, true); From 6db00a213a6c8815aed7ae2d4e71d8a1b5b6338e Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Fri, 30 Oct 2020 21:41:16 -0400 Subject: [PATCH 25/25] Update Clippy path to `Lint` --- src/tools/clippy/clippy_lints/src/utils/paths.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/clippy/clippy_lints/src/utils/paths.rs b/src/tools/clippy/clippy_lints/src/utils/paths.rs index cd72fdd61fd3a..736a531eda657 100644 --- a/src/tools/clippy/clippy_lints/src/utils/paths.rs +++ b/src/tools/clippy/clippy_lints/src/utils/paths.rs @@ -59,7 +59,7 @@ pub const IO_WRITE: [&str; 3] = ["std", "io", "Write"]; pub const ITERATOR: [&str; 5] = ["core", "iter", "traits", "iterator", "Iterator"]; pub const LATE_CONTEXT: [&str; 2] = ["rustc_lint", "LateContext"]; pub const LINKED_LIST: [&str; 4] = ["alloc", "collections", "linked_list", "LinkedList"]; -pub const LINT: [&str; 3] = ["rustc_session", "lint", "Lint"]; +pub const LINT: [&str; 2] = ["rustc_lint_defs", "Lint"]; pub const MEM_DISCRIMINANT: [&str; 3] = ["core", "mem", "discriminant"]; pub const MEM_FORGET: [&str; 3] = ["core", "mem", "forget"]; pub const MEM_MANUALLY_DROP: [&str; 4] = ["core", "mem", "manually_drop", "ManuallyDrop"];