From 6ef377cc41dbc7ba9455d0b44f13c3c1a024b0cf Mon Sep 17 00:00:00 2001 From: Havard Eidnes Date: Sun, 7 May 2023 18:35:35 +0000 Subject: [PATCH 001/103] Add support for NetBSD/aarch64-be (big-endian arm64). --- .../src/spec/aarch64_be_unknown_netbsd.rs | 17 +++++++++++++++++ compiler/rustc_target/src/spec/mod.rs | 1 + src/bootstrap/bootstrap.py | 1 + 3 files changed, 19 insertions(+) create mode 100644 compiler/rustc_target/src/spec/aarch64_be_unknown_netbsd.rs diff --git a/compiler/rustc_target/src/spec/aarch64_be_unknown_netbsd.rs b/compiler/rustc_target/src/spec/aarch64_be_unknown_netbsd.rs new file mode 100644 index 000000000000..98ae05974aa8 --- /dev/null +++ b/compiler/rustc_target/src/spec/aarch64_be_unknown_netbsd.rs @@ -0,0 +1,17 @@ +use crate::abi::Endian; +use crate::spec::{Target, TargetOptions}; + +pub fn target() -> Target { + Target { + llvm_target: "aarch64_be-unknown-netbsd".into(), + pointer_width: 64, + data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), + arch: "aarch64".into(), + options: TargetOptions { + mcount: "__mcount".into(), + max_atomic_width: Some(128), + endian: Endian::Big, + ..super::netbsd_base::opts() + }, + } +} diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 10d38c34919c..e09f8c9ea917 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1100,6 +1100,7 @@ supported_targets! { ("x86_64-unknown-openbsd", x86_64_unknown_openbsd), ("aarch64-unknown-netbsd", aarch64_unknown_netbsd), + ("aarch64_be-unknown-netbsd", aarch64_be_unknown_netbsd), ("armv6-unknown-netbsd-eabihf", armv6_unknown_netbsd_eabihf), ("armv7-unknown-netbsd-eabihf", armv7_unknown_netbsd_eabihf), ("i686-unknown-netbsd", i686_unknown_netbsd), diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index f22cdad7df41..c79fe0431466 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -327,6 +327,7 @@ def default_build_triple(verbose): cputype_mapper = { 'BePC': 'i686', 'aarch64': 'aarch64', + 'aarch64eb': 'aarch64', 'amd64': 'x86_64', 'arm64': 'aarch64', 'i386': 'i686', From 9b5574f028c75d794b51c96ff6471ddf756f329b Mon Sep 17 00:00:00 2001 From: clubby789 Date: Fri, 5 May 2023 21:26:42 +0100 Subject: [PATCH 002/103] Validate fluent variable references with `debug_assertions` --- compiler/rustc_fluent_macro/src/fluent.rs | 45 +++++++++++- .../src/diagnostics/diagnostic.rs | 68 +++++++++++++++++-- 2 files changed, 106 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_fluent_macro/src/fluent.rs b/compiler/rustc_fluent_macro/src/fluent.rs index 9dffc9a76454..b1c83e0dedce 100644 --- a/compiler/rustc_fluent_macro/src/fluent.rs +++ b/compiler/rustc_fluent_macro/src/fluent.rs @@ -179,7 +179,8 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok let mut previous_defns = HashMap::new(); let mut message_refs = Vec::new(); for entry in resource.entries() { - if let Entry::Message(Message { id: Identifier { name }, attributes, value, .. }) = entry { + if let Entry::Message(msg) = entry { + let Message { id: Identifier { name }, attributes, value, .. } = msg; let _ = previous_defns.entry(name.to_string()).or_insert(resource_span); if name.contains('-') { Diagnostic::spanned( @@ -229,9 +230,10 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok continue; } - let msg = format!("Constant referring to Fluent message `{name}` from `{crate_name}`"); + let docstr = + format!("Constant referring to Fluent message `{name}` from `{crate_name}`"); constants.extend(quote! { - #[doc = #msg] + #[doc = #docstr] pub const #snake_name: crate::DiagnosticMessage = crate::DiagnosticMessage::FluentIdentifier( std::borrow::Cow::Borrowed(#name), @@ -269,6 +271,17 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok ); }); } + #[cfg(debug_assertions)] + { + // Record variables referenced by these messages so we can produce + // tests in the derive diagnostics to validate them. + let ident = quote::format_ident!("{snake_name}_refs"); + let vrefs = variable_references(msg); + constants.extend(quote! { + #[cfg(test)] + pub const #ident: &[&str] = &[#(#vrefs),*]; + }) + } } } @@ -334,3 +347,29 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok } .into() } + +#[cfg(debug_assertions)] +fn variable_references<'a>(msg: &Message<&'a str>) -> Vec<&'a str> { + let mut refs = vec![]; + if let Some(Pattern { elements }) = &msg.value { + for elt in elements { + if let PatternElement::Placeable { + expression: Expression::Inline(InlineExpression::VariableReference { id }), + } = elt + { + refs.push(id.name); + } + } + } + for attr in &msg.attributes { + for elt in &attr.value.elements { + if let PatternElement::Placeable { + expression: Expression::Inline(InlineExpression::VariableReference { id }), + } = elt + { + refs.push(id.name); + } + } + } + refs +} diff --git a/compiler/rustc_macros/src/diagnostics/diagnostic.rs b/compiler/rustc_macros/src/diagnostics/diagnostic.rs index 12a954258d1d..b9eba65f66a3 100644 --- a/compiler/rustc_macros/src/diagnostics/diagnostic.rs +++ b/compiler/rustc_macros/src/diagnostics/diagnostic.rs @@ -1,5 +1,7 @@ #![deny(unused_must_use)] +use std::cell::RefCell; + use crate::diagnostics::diagnostic_builder::{DiagnosticDeriveBuilder, DiagnosticDeriveKind}; use crate::diagnostics::error::{span_err, DiagnosticDeriveError}; use crate::diagnostics::utils::SetOnce; @@ -28,6 +30,7 @@ impl<'a> DiagnosticDerive<'a> { pub(crate) fn into_tokens(self) -> TokenStream { let DiagnosticDerive { mut structure, mut builder } = self; + let slugs = RefCell::new(Vec::new()); let implementation = builder.each_variant(&mut structure, |mut builder, variant| { let preamble = builder.preamble(variant); let body = builder.body(variant); @@ -56,6 +59,7 @@ impl<'a> DiagnosticDerive<'a> { return DiagnosticDeriveError::ErrorHandled.to_compile_error(); } Some(slug) => { + slugs.borrow_mut().push(slug.clone()); quote! { let mut #diag = #handler.struct_diagnostic(crate::fluent_generated::#slug); } @@ -73,7 +77,8 @@ impl<'a> DiagnosticDerive<'a> { }); let DiagnosticDeriveKind::Diagnostic { handler } = &builder.kind else { unreachable!() }; - structure.gen_impl(quote! { + #[allow(unused_mut)] + let mut imp = structure.gen_impl(quote! { gen impl<'__diagnostic_handler_sess, G> rustc_errors::IntoDiagnostic<'__diagnostic_handler_sess, G> for @Self @@ -89,7 +94,14 @@ impl<'a> DiagnosticDerive<'a> { #implementation } } - }) + }); + #[cfg(debug_assertions)] + { + for test in slugs.borrow().iter().map(|s| generate_test(s, &structure)) { + imp.extend(test); + } + } + imp } } @@ -124,6 +136,7 @@ impl<'a> LintDiagnosticDerive<'a> { } }); + let slugs = RefCell::new(Vec::new()); let msg = builder.each_variant(&mut structure, |mut builder, variant| { // Collect the slug by generating the preamble. let _ = builder.preamble(variant); @@ -148,6 +161,7 @@ impl<'a> LintDiagnosticDerive<'a> { DiagnosticDeriveError::ErrorHandled.to_compile_error() } Some(slug) => { + slugs.borrow_mut().push(slug.clone()); quote! { crate::fluent_generated::#slug.into() } @@ -156,7 +170,8 @@ impl<'a> LintDiagnosticDerive<'a> { }); let diag = &builder.diag; - structure.gen_impl(quote! { + #[allow(unused_mut)] + let mut imp = structure.gen_impl(quote! { gen impl<'__a> rustc_errors::DecorateLint<'__a, ()> for @Self { #[track_caller] fn decorate_lint<'__b>( @@ -171,7 +186,14 @@ impl<'a> LintDiagnosticDerive<'a> { #msg } } - }) + }); + #[cfg(debug_assertions)] + { + for test in slugs.borrow().iter().map(|s| generate_test(s, &structure)) { + imp.extend(test); + } + } + imp } } @@ -198,3 +220,41 @@ impl Mismatch { } } } + +/// Generates a `#[test]` that verifies that all referenced variables +/// exist on this structure. +#[cfg(debug_assertions)] +fn generate_test(slug: &syn::Path, structure: &Structure<'_>) -> TokenStream { + // FIXME: We can't identify variables in a subdiagnostic + for field in structure.variants().iter().flat_map(|v| v.ast().fields.iter()) { + for attr_name in field.attrs.iter().filter_map(|at| at.path().get_ident()) { + if attr_name == "subdiagnostic" { + return quote!(); + } + } + } + use std::sync::atomic::{AtomicUsize, Ordering}; + // We need to make sure that the same diagnostic slug can be used multiple times without causing an + // error, so just have a global counter here. + static COUNTER: AtomicUsize = AtomicUsize::new(0); + let slug = slug.get_ident().unwrap(); + let ident = quote::format_ident!("verify_{slug}_{}", COUNTER.fetch_add(1, Ordering::Relaxed)); + let ref_slug = quote::format_ident!("{slug}_refs"); + let struct_name = &structure.ast().ident; + let variables: Vec<_> = structure + .variants() + .iter() + .flat_map(|v| v.ast().fields.iter().filter_map(|f| f.ident.as_ref().map(|i| i.to_string()))) + .collect(); + // tidy errors on `#[test]` outside of test files, so we use `#[test ]` to work around this + quote! { + #[cfg(test)] + #[test ] + fn #ident() { + let variables = [#(#variables),*]; + for vref in crate::fluent_generated::#ref_slug { + assert!(variables.contains(vref), "{}: variable `{vref}` not found ({})", stringify!(#struct_name), stringify!(#slug)); + } + } + } +} From 220bb61b3317340d01d95aad4f4d30cca91943f2 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Sat, 6 May 2023 00:29:52 +0100 Subject: [PATCH 003/103] Fix diagnostics with errors --- compiler/rustc_fluent_macro/src/fluent.rs | 21 ++++++++----------- compiler/rustc_hir_analysis/messages.ftl | 2 +- .../src/diagnostics/diagnostic.rs | 19 ++++++----------- compiler/rustc_passes/src/errors.rs | 8 ------- .../auxiliary/default_body.rs | 4 ++++ .../default-body-stability-err.rs | 1 + .../default-body-stability-err.stderr | 14 +++++++++++-- .../default-body-stability-ok-impls.rs | 2 ++ 8 files changed, 35 insertions(+), 36 deletions(-) diff --git a/compiler/rustc_fluent_macro/src/fluent.rs b/compiler/rustc_fluent_macro/src/fluent.rs index b1c83e0dedce..56e23ac27752 100644 --- a/compiler/rustc_fluent_macro/src/fluent.rs +++ b/compiler/rustc_fluent_macro/src/fluent.rs @@ -271,17 +271,15 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok ); }); } - #[cfg(debug_assertions)] - { - // Record variables referenced by these messages so we can produce - // tests in the derive diagnostics to validate them. - let ident = quote::format_ident!("{snake_name}_refs"); - let vrefs = variable_references(msg); - constants.extend(quote! { - #[cfg(test)] - pub const #ident: &[&str] = &[#(#vrefs),*]; - }) - } + + // Record variables referenced by these messages so we can produce + // tests in the derive diagnostics to validate them. + let ident = quote::format_ident!("{snake_name}_refs"); + let vrefs = variable_references(msg); + constants.extend(quote! { + #[cfg(test)] + pub const #ident: &[&str] = &[#(#vrefs),*]; + }) } } @@ -348,7 +346,6 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok .into() } -#[cfg(debug_assertions)] fn variable_references<'a>(msg: &Message<&'a str>) -> Vec<&'a str> { let mut refs = vec![]; if let Some(Pattern { elements }) = &msg.value { diff --git a/compiler/rustc_hir_analysis/messages.ftl b/compiler/rustc_hir_analysis/messages.ftl index 02d1dfcd1134..5225fee4916a 100644 --- a/compiler/rustc_hir_analysis/messages.ftl +++ b/compiler/rustc_hir_analysis/messages.ftl @@ -137,7 +137,7 @@ hir_analysis_missing_trait_item_suggestion = implement the missing item: `{$snip hir_analysis_missing_trait_item_unstable = not all trait items implemented, missing: `{$missing_item_name}` .note = default implementation of `{$missing_item_name}` is unstable - .some_note = use of unstable library feature '{$feature}': {$r} + .some_note = use of unstable library feature '{$feature}': {$reason} .none_note = use of unstable library feature '{$feature}' hir_analysis_missing_type_params = diff --git a/compiler/rustc_macros/src/diagnostics/diagnostic.rs b/compiler/rustc_macros/src/diagnostics/diagnostic.rs index b9eba65f66a3..04b7c5feebe5 100644 --- a/compiler/rustc_macros/src/diagnostics/diagnostic.rs +++ b/compiler/rustc_macros/src/diagnostics/diagnostic.rs @@ -77,7 +77,7 @@ impl<'a> DiagnosticDerive<'a> { }); let DiagnosticDeriveKind::Diagnostic { handler } = &builder.kind else { unreachable!() }; - #[allow(unused_mut)] + let mut imp = structure.gen_impl(quote! { gen impl<'__diagnostic_handler_sess, G> rustc_errors::IntoDiagnostic<'__diagnostic_handler_sess, G> @@ -95,11 +95,8 @@ impl<'a> DiagnosticDerive<'a> { } } }); - #[cfg(debug_assertions)] - { - for test in slugs.borrow().iter().map(|s| generate_test(s, &structure)) { - imp.extend(test); - } + for test in slugs.borrow().iter().map(|s| generate_test(s, &structure)) { + imp.extend(test); } imp } @@ -170,7 +167,6 @@ impl<'a> LintDiagnosticDerive<'a> { }); let diag = &builder.diag; - #[allow(unused_mut)] let mut imp = structure.gen_impl(quote! { gen impl<'__a> rustc_errors::DecorateLint<'__a, ()> for @Self { #[track_caller] @@ -187,12 +183,10 @@ impl<'a> LintDiagnosticDerive<'a> { } } }); - #[cfg(debug_assertions)] - { - for test in slugs.borrow().iter().map(|s| generate_test(s, &structure)) { - imp.extend(test); - } + for test in slugs.borrow().iter().map(|s| generate_test(s, &structure)) { + imp.extend(test); } + imp } } @@ -223,7 +217,6 @@ impl Mismatch { /// Generates a `#[test]` that verifies that all referenced variables /// exist on this structure. -#[cfg(debug_assertions)] fn generate_test(slug: &syn::Path, structure: &Structure<'_>) -> TokenStream { // FIXME: We can't identify variables in a subdiagnostic for field in structure.variants().iter().flat_map(|v| v.ast().fields.iter()) { diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 99fc69d1bec7..4d9254a0a45d 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -1153,14 +1153,6 @@ pub struct UnixSigpipeValues { pub span: Span, } -#[derive(Diagnostic)] -#[diag(passes_no_main_function, code = "E0601")] -pub struct NoMainFunction { - #[primary_span] - pub span: Span, - pub crate_name: String, -} - pub struct NoMainErr { pub sp: Span, pub crate_name: Symbol, diff --git a/tests/ui/stability-attribute/auxiliary/default_body.rs b/tests/ui/stability-attribute/auxiliary/default_body.rs index 3a177419d666..2f315eb1bc8f 100644 --- a/tests/ui/stability-attribute/auxiliary/default_body.rs +++ b/tests/ui/stability-attribute/auxiliary/default_body.rs @@ -11,6 +11,10 @@ pub trait JustTrait { #[rustc_default_body_unstable(feature = "fun_default_body", issue = "none")] #[stable(feature = "stable_feature", since = "1.0.0")] fn fun() {} + + #[rustc_default_body_unstable(feature = "fun_default_body", issue = "none", reason = "reason")] + #[stable(feature = "stable_feature", since = "1.0.0")] + fn fun2() {} } #[rustc_must_implement_one_of(eq, neq)] diff --git a/tests/ui/stability-attribute/default-body-stability-err.rs b/tests/ui/stability-attribute/default-body-stability-err.rs index ecb281bccf60..d1a3597687d7 100644 --- a/tests/ui/stability-attribute/default-body-stability-err.rs +++ b/tests/ui/stability-attribute/default-body-stability-err.rs @@ -10,6 +10,7 @@ struct Type; impl JustTrait for Type {} //~^ ERROR not all trait items implemented, missing: `CONSTANT` [E0046] //~| ERROR not all trait items implemented, missing: `fun` [E0046] +//~| ERROR not all trait items implemented, missing: `fun2` [E0046] impl Equal for Type { //~^ ERROR not all trait items implemented, missing: `eq` [E0046] diff --git a/tests/ui/stability-attribute/default-body-stability-err.stderr b/tests/ui/stability-attribute/default-body-stability-err.stderr index ef666f30fc2a..12ec9ea3adb4 100644 --- a/tests/ui/stability-attribute/default-body-stability-err.stderr +++ b/tests/ui/stability-attribute/default-body-stability-err.stderr @@ -18,8 +18,18 @@ LL | impl JustTrait for Type {} = note: use of unstable library feature 'fun_default_body' = help: add `#![feature(fun_default_body)]` to the crate attributes to enable +error[E0046]: not all trait items implemented, missing: `fun2` + --> $DIR/default-body-stability-err.rs:10:1 + | +LL | impl JustTrait for Type {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: default implementation of `fun2` is unstable + = note: use of unstable library feature 'fun_default_body': reason + = help: add `#![feature(fun_default_body)]` to the crate attributes to enable + error[E0046]: not all trait items implemented, missing: `eq` - --> $DIR/default-body-stability-err.rs:14:1 + --> $DIR/default-body-stability-err.rs:15:1 | LL | / impl Equal for Type { LL | | @@ -33,6 +43,6 @@ LL | | } = note: use of unstable library feature 'eq_default_body' = help: add `#![feature(eq_default_body)]` to the crate attributes to enable -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/stability-attribute/default-body-stability-ok-impls.rs b/tests/ui/stability-attribute/default-body-stability-ok-impls.rs index e1f5c017096a..b29d45256bf3 100644 --- a/tests/ui/stability-attribute/default-body-stability-ok-impls.rs +++ b/tests/ui/stability-attribute/default-body-stability-ok-impls.rs @@ -12,6 +12,8 @@ impl JustTrait for Type { const CONSTANT: usize = 1; fn fun() {} + + fn fun2() {} } impl Equal for Type { From 0a1e42e0e27c46b245fbd025af353b9031217fae Mon Sep 17 00:00:00 2001 From: Havard Eidnes Date: Fri, 26 May 2023 20:14:48 +0000 Subject: [PATCH 004/103] platform-support.md: document the various NetBSD targets. This is slightly patterned after what OpenBSD has done. This is a step along the path to reduce the number and amount of diffs that pkgsrc carries around for rust, and this documents also some parts which have not yet been upstreamed (mipsel-*). --- src/doc/rustc/src/platform-support.md | 15 +-- src/doc/rustc/src/platform-support/netbsd.md | 108 +++++++++++++++++++ 2 files changed, 117 insertions(+), 6 deletions(-) create mode 100644 src/doc/rustc/src/platform-support/netbsd.md diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 75f97c1fc1ed..152c16abc722 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -223,13 +223,14 @@ target | std | host | notes `aarch64-unknown-freebsd` | ✓ | ✓ | ARM64 FreeBSD `aarch64-unknown-hermit` | ✓ | | ARM64 HermitCore `aarch64-unknown-linux-gnu_ilp32` | ✓ | ✓ | ARM64 Linux (ILP32 ABI) -`aarch64-unknown-netbsd` | ✓ | ✓ | +[`aarch64-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | ARM64 NetBSD [`aarch64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | ARM64 OpenBSD `aarch64-unknown-redox` | ? | | ARM64 Redox OS `aarch64-uwp-windows-msvc` | ? | | `aarch64-wrs-vxworks` | ? | | `aarch64_be-unknown-linux-gnu_ilp32` | ✓ | ✓ | ARM64 Linux (big-endian, ILP32 ABI) `aarch64_be-unknown-linux-gnu` | ✓ | ✓ | ARM64 Linux (big-endian) +[`aarch64_be-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | ARM64 NetBSD (big-endian) [`arm64_32-apple-watchos`](platform-support/apple-watchos.md) | ✓ | | ARM Apple WatchOS 64-bit with 32-bit pointers [`armeb-unknown-linux-gnueabi`](platform-support/armeb-unknown-linux-gnueabi.md) | ✓ | ? | ARM BE8 the default ARM big-endian architecture since [ARMv6](https://developer.arm.com/documentation/101754/0616/armlink-Reference/armlink-Command-line-Options/--be8?lang=en). `armv4t-none-eabi` | * | | ARMv4T A32 @@ -237,7 +238,7 @@ target | std | host | notes [`armv5te-none-eabi`](platform-support/armv5te-none-eabi.md) | * | | ARMv5TE A32 `armv5te-unknown-linux-uclibceabi` | ? | | ARMv5TE Linux with uClibc `armv6-unknown-freebsd` | ✓ | ✓ | ARMv6 FreeBSD -`armv6-unknown-netbsd-eabihf` | ? | | +[`armv6-unknown-netbsd-eabihf`](platform-support/netbsd.md) | ✓ | ✓ | ARMv6 NetBSD w/hard-float [`armv6k-nintendo-3ds`](platform-support/armv6k-nintendo-3ds.md) | ? | | ARMv6K Nintendo 3DS, Horizon (Requires devkitARM toolchain) `armv7-apple-ios` | ✓ | | ARMv7 iOS, Cortex-a8 [`armv7-sony-vita-newlibeabihf`](platform-support/armv7-sony-vita-newlibeabihf.md) | ? | | ARM Cortex-A9 Sony PlayStation Vita (requires VITASDK toolchain) @@ -245,7 +246,7 @@ target | std | host | notes [`armv7-unknown-linux-uclibceabi`](platform-support/armv7-unknown-linux-uclibceabi.md) | ✓ | ✓ | ARMv7 Linux with uClibc, softfloat [`armv7-unknown-linux-uclibceabihf`](platform-support/armv7-unknown-linux-uclibceabihf.md) | ✓ | ? | ARMv7 Linux with uClibc, hardfloat `armv7-unknown-freebsd` | ✓ | ✓ | ARMv7 FreeBSD -`armv7-unknown-netbsd-eabihf` | ✓ | ✓ | +[`armv7-unknown-netbsd-eabihf`](platform-support/netbsd.md) | ✓ | ✓ | ARMv7 NetBSD w/hard-float `armv7-wrs-vxworks-eabihf` | ? | | [`armv7a-kmc-solid_asp3-eabi`](platform-support/kmc-solid.md) | ✓ | | ARM SOLID with TOPPERS/ASP3 [`armv7a-kmc-solid_asp3-eabihf`](platform-support/kmc-solid.md) | ✓ | | ARM SOLID with TOPPERS/ASP3, hardfloat @@ -258,10 +259,11 @@ target | std | host | notes `hexagon-unknown-linux-musl` | ? | | `i386-apple-ios` | ✓ | | 32-bit x86 iOS [`i586-pc-nto-qnx700`](platform-support/nto-qnx.md) | * | | 32-bit x86 QNX Neutrino 7.0 RTOS | +[`i586-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | NetBSD/i386 restricted to Pentium insns `i686-apple-darwin` | ✓ | ✓ | 32-bit macOS (10.7+, Lion+) `i686-pc-windows-msvc` | * | | 32-bit Windows XP support `i686-unknown-haiku` | ✓ | ✓ | 32-bit Haiku -`i686-unknown-netbsd` | ✓ | ✓ | NetBSD/i386 with SSE2 +[`i686-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | NetBSD/i386 with SSE2 [`i686-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | 32-bit OpenBSD `i686-uwp-windows-gnu` | ? | | `i686-uwp-windows-msvc` | ? | | @@ -273,6 +275,7 @@ target | std | host | notes `mipsel-sony-psp` | * | | MIPS (LE) Sony PlayStation Portable (PSP) [`mipsel-sony-psx`](platform-support/mipsel-sony-psx.md) | * | | MIPS (LE) Sony PlayStation 1 (PSX) `mipsel-unknown-linux-uclibc` | ✓ | | MIPS (LE) Linux with uClibc +[`mipsel-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | MIPS (LE) on NetBSD, requires mips32 CPU `mipsel-unknown-none` | * | | Bare MIPS (LE) softfloat `mipsisa32r6-unknown-linux-gnu` | ? | | `mipsisa32r6el-unknown-linux-gnu` | ? | | @@ -281,7 +284,7 @@ target | std | host | notes `msp430-none-elf` | * | | 16-bit MSP430 microcontrollers `powerpc-unknown-linux-gnuspe` | ✓ | | PowerPC SPE Linux `powerpc-unknown-linux-musl` | ? | | -`powerpc-unknown-netbsd` | ✓ | ✓ | +[`powerpc-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | NetBSD 32-bit powerpc systems `powerpc-unknown-openbsd` | ? | | `powerpc-wrs-vxworks-spe` | ? | | `powerpc-wrs-vxworks` | ? | | @@ -304,7 +307,7 @@ target | std | host | notes [`riscv64gc-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/riscv64 `s390x-unknown-linux-musl` | | | S390x Linux (kernel 3.2, MUSL) `sparc-unknown-linux-gnu` | ✓ | | 32-bit SPARC Linux -`sparc64-unknown-netbsd` | ✓ | ✓ | NetBSD/sparc64 +[`sparc64-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | NetBSD/sparc64 [`sparc64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/sparc64 `thumbv4t-none-eabi` | * | | ARMv4T T32 [`thumbv5te-none-eabi`](platform-support/armv5te-none-eabi.md) | * | | ARMv5TE T32 diff --git a/src/doc/rustc/src/platform-support/netbsd.md b/src/doc/rustc/src/platform-support/netbsd.md new file mode 100644 index 000000000000..436a6d4226cf --- /dev/null +++ b/src/doc/rustc/src/platform-support/netbsd.md @@ -0,0 +1,108 @@ +# \*-unknown-netbsd + +**Tier: 3** + +[NetBSD] multi-platform 4.4BSD-based UNIX-like operating system. + +[NetBSD]: https://www.NetBSD.org/ + +The target names follow this format: `$ARCH-unknown-netbsd{-$SUFFIX}`, +where `$ARCH` specifies the target processor architecture and +`-$SUFFIX` (optional) might indicate the ABI. The following targets +are currently defined running NetBSD: + +| Target name | NetBSD Platform | +|--------------------------------|-----------------| +| `amd64-unknown-netbsd` | [amd64 / x86_64 systems](https://wiki.netbsd.org/ports/amd64/) | +| `armv7-unknown-netbsd-eabihf` | [32-bit ARMv7 systems with hard-float](https://wiki.netbsd.org/ports/evbarm/) | +| `armv6-unknown-netbsd-eabihf` | [32-bit ARMv6 systems with hard-float](https://wiki.netbsd.org/ports/evbarm/) | +| `aarch64-unknown-netbsd` | [64-bit ARM systems, little-endian](https://wiki.netbsd.org/ports/evbarm/) | +| `aarch64_be-unknown-netbsd` | [64-bit ARM systems, big-endian](https://wiki.netbsd.org/ports/evbarm/) | +| `i586-unknown-netbsd` | [32-bit i386, restricted to Pentium](https://wiki.netbsd.org/ports/i386/) | +| `i686-unknown-netbsd` | [32-bit i386 with SSE](https://wiki.netbsd.org/ports/i386/) | +| `mipsel-unknown-netbsd` | [32-bit mips, requires mips32 cpu support](https://wiki.netbsd.org/ports/evbmips/) | +| `powerpc-unknown-netbsd` | [Various 32-bit PowerPC systems, e.g. MacPPC](https://wiki.netbsd.org/ports/macppc/) | +| `sparc64-unknown-netbsd` | [Sun UltraSPARC systems](https://wiki.netbsd.org/ports/sparc64/) | + +All use the "native" `stdc++` library which goes along with the natively +supplied GNU C++ compiler for the given OS version. Many of the bootstraps +are built for NetBSD 9.x, although some exceptions exist (some +are built for NetBSD 8.x but also work on newer OS versions). + + +## Designated Developers + +- [@he32](https://github.com/he32), `he@NetBSD.org` +- [NetBSD/pkgsrc-wip's rust](https://github.com/NetBSD/pkgsrc-wip/blob/master/rust/Makefile) maintainer (see MAINTAINER variable). This package is part of "pkgsrc work-in-progress" and is used for deployment and testing of new versions of rust +- [NetBSD's pkgsrc lang/rust](https://github.com/NetBSD/pkgsrc/tree/trunk/lang/rust) for the "proper" package in pkgsrc. +- [NetBSD's pkgsrc lang/rust-bin](https://github.com/NetBSD/pkgsrc/tree/trunk/lang/rust-bin) which re-uses the bootstrap kit as a binary distribution and therefore avoids the rather protracted native build time of rust itself + +Fallback to pkgsrc-users@NetBSD.org, or fault reporting via NetBSD's +bug reporting system. + +## Requirements + +The `amd64-unknown-netbsd` artifacts is being distributed by the +rust project. + +The other targets are built by the designated developers (see above), +and the targets are initially cross-compiled, but many if not most +of them are also built natively as part of testing. + + +## Building + +The default build mode for the packages is a native build. + + +## Cross-compilation + +These targets can be cross-compiled, and we do that via the pkgsrc +package(s). + +Cross-compilation typically requires the "tools" and "dest" trees +resulting from a normal cross-build of NetBSD itself, ref. our main +build script, `build.sh`. + +See e.g. [do-cross.mk +Makefile](https://github.com/NetBSD/pkgsrc/tree/trunk/lang/rust/do-cross.mk) +for the Makefile used to cross-build all the above NetBSD targets +(except for the `amd64` target). + +The major option for the rust build is whether to build rust with +the LLVM rust carries in its distribution, or use the LLVM package +installed from pkgsrc. The `PKG_OPTIONS.rust` option is +`rust-internal-llvm`, ref. [the rust package's options.mk make +fragment](https://github.com/NetBSD/pkgsrc/blob/trunk/lang/rust/options.mk). +It defaults to being set for a few of the above platforms, for +various reasons (see comments), but is otherwise unset and therefore +indicates use of the pkgsrc LLVM. + + +## Testing + +The Rust testsuite could presumably be run natively. + +For the systems where the maintainer can build natively, the rust +compiler itself is re-built natively. This involves the rust compiler +being re-built with the newly self-built rust compiler, so excercises +the result quite extensively. + +Additionally, for some systems we build `librsvg`, and for the more +capable systems we build and test `firefox` (amd64, i386, aarch64). + + +## Building Rust programs + +Rust ships pre-compiled artifacts for the `amd64-unknown-netbsd` +target. + +For the other systems mentioned above, using the `pkgsrc` route is +probably the easiest, possibly via the `rust-bin` package to save +time, see the `RUST_TYPE` variable from the `rust.mk` Makefile +fragment. + +The pkgsrc rust package has a few files to assist with building +pkgsrc packages written in rust, ref. the `rust.mk` and `cargo.mk` +Makefile fragments in the `lang/rust` package. + From 7269972f7336a27980ea19353a29bad0d2a1faa9 Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Fri, 2 Jun 2023 13:50:18 +0100 Subject: [PATCH 005/103] Add trustzone and virtualization target features for aarch32. These are LLVM target features which allow the `smc` and `hvc` instructions respectively to be used in inline assembly. --- compiler/rustc_codegen_ssa/src/target_features.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/rustc_codegen_ssa/src/target_features.rs b/compiler/rustc_codegen_ssa/src/target_features.rs index c5976a65411f..6a3a31a0d60a 100644 --- a/compiler/rustc_codegen_ssa/src/target_features.rs +++ b/compiler/rustc_codegen_ssa/src/target_features.rs @@ -44,6 +44,7 @@ const ARM_ALLOWED_FEATURES: &[(&str, Option)] = &[ // #[target_feature]. ("thumb-mode", Some(sym::arm_target_feature)), ("thumb2", Some(sym::arm_target_feature)), + ("trustzone", Some(sym::arm_target_feature)), ("v5te", Some(sym::arm_target_feature)), ("v6", Some(sym::arm_target_feature)), ("v6k", Some(sym::arm_target_feature)), @@ -53,6 +54,7 @@ const ARM_ALLOWED_FEATURES: &[(&str, Option)] = &[ ("vfp2", Some(sym::arm_target_feature)), ("vfp3", Some(sym::arm_target_feature)), ("vfp4", Some(sym::arm_target_feature)), + ("virtualization", Some(sym::arm_target_feature)), // tidy-alphabetical-end ]; From bd0aae92dc76d9336cf09c097ac5a49fd619da44 Mon Sep 17 00:00:00 2001 From: Erik Desjardins Date: Sun, 11 Jun 2023 00:04:53 -0400 Subject: [PATCH 006/103] cg_llvm: use index-based loop in write_operand_repeatedly This is easier for LLVM to analyze. --- compiler/rustc_codegen_llvm/src/builder.rs | 20 ++++++-------------- tests/codegen/issues/issue-111603.rs | 12 ++++++++++++ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index b4aa001547c4..43258078bd77 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -572,8 +572,6 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { ) { let zero = self.const_usize(0); let count = self.const_usize(count); - let start = dest.project_index(self, zero).llval; - let end = dest.project_index(self, count).llval; let header_bb = self.append_sibling_block("repeat_loop_header"); let body_bb = self.append_sibling_block("repeat_loop_body"); @@ -582,24 +580,18 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { self.br(header_bb); let mut header_bx = Self::build(self.cx, header_bb); - let current = header_bx.phi(self.val_ty(start), &[start], &[self.llbb()]); + let i = header_bx.phi(self.val_ty(zero), &[zero], &[self.llbb()]); - let keep_going = header_bx.icmp(IntPredicate::IntNE, current, end); + let keep_going = header_bx.icmp(IntPredicate::IntULT, i, count); header_bx.cond_br(keep_going, body_bb, next_bb); let mut body_bx = Self::build(self.cx, body_bb); - let align = dest.align.restrict_for_offset(dest.layout.field(self.cx(), 0).size); - cg_elem - .val - .store(&mut body_bx, PlaceRef::new_sized_aligned(current, cg_elem.layout, align)); + let dest_elem = dest.project_index(&mut body_bx, i); + cg_elem.val.store(&mut body_bx, dest_elem); - let next = body_bx.inbounds_gep( - self.backend_type(cg_elem.layout), - current, - &[self.const_usize(1)], - ); + let next = body_bx.unchecked_uadd(i, self.const_usize(1)); body_bx.br(header_bb); - header_bx.add_incoming_to_phi(current, next, body_bb); + header_bx.add_incoming_to_phi(i, next, body_bb); *self = Self::build(self.cx, next_bb); } diff --git a/tests/codegen/issues/issue-111603.rs b/tests/codegen/issues/issue-111603.rs index 90b3c314d2f4..06429ed3fa9b 100644 --- a/tests/codegen/issues/issue-111603.rs +++ b/tests/codegen/issues/issue-111603.rs @@ -5,6 +5,18 @@ use std::sync::Arc; +// CHECK-LABEL: @new_from_array +#[no_mangle] +pub fn new_from_array(x: u64) -> Arc<[u64]> { + // Ensure that we only generate one alloca for the array. + + // CHECK: alloca + // CHECK-SAME: [1000 x i64] + // CHECK-NOT: alloca + let array = [x; 1000]; + Arc::new(array) +} + // CHECK-LABEL: @new_uninit #[no_mangle] pub fn new_uninit(x: u64) -> Arc<[u64; 1000]> { From c0aed703be1c8c6db6dbbf8edecba0108506a43c Mon Sep 17 00:00:00 2001 From: Sergio Gasquez Date: Mon, 12 Jun 2023 17:12:14 +0200 Subject: [PATCH 007/103] =?UTF-8?q?docs:=20=F0=9F=93=9D=20Add=20missing=20?= =?UTF-8?q?targets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/doc/rustc/src/platform-support/esp-idf.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/doc/rustc/src/platform-support/esp-idf.md b/src/doc/rustc/src/platform-support/esp-idf.md index 4bbe35709b08..8f630fa152c4 100644 --- a/src/doc/rustc/src/platform-support/esp-idf.md +++ b/src/doc/rustc/src/platform-support/esp-idf.md @@ -13,10 +13,12 @@ Targets for the [ESP-IDF](https://github.com/espressif/esp-idf) development fram The target names follow this format: `$ARCH-esp-espidf`, where `$ARCH` specifies the target processor architecture. The following targets are currently defined: -| Target name | Target CPU(s) | Minimum ESP-IDF version | -|--------------------------------|-----------------------|-------------------------| -| `riscv32imc-esp-espidf` | [ESP32-C3](https://www.espressif.com/en/products/socs/esp32-c3) | `v4.3` | -| `riscv32imac-esp-espidf` | [ESP32-C6](https://www.espressif.com/en/products/socs/esp32-c6) | `v5.1` | +| Target name | Target CPU(s) | Minimum ESP-IDF version | +| ------------------------ | --------------------------------------------------------------- | ----------------------- | +| `riscv32imc-esp-espidf` | [ESP32-C2](https://www.espressif.com/en/products/socs/esp32-c2) | `v5.0` | +| `riscv32imc-esp-espidf` | [ESP32-C3](https://www.espressif.com/en/products/socs/esp32-c3) | `v4.3` | +| `riscv32imac-esp-espidf` | [ESP32-C6](https://www.espressif.com/en/products/socs/esp32-c6) | `v5.1` | +| `riscv32imac-esp-espidf` | [ESP32-H2](https://www.espressif.com/en/products/socs/esp32-h2) | `v5.1` | It is recommended to use the latest ESP-IDF stable release if possible. From 64ee0f74eb4d724e87601fea4bd6b18377289fa2 Mon Sep 17 00:00:00 2001 From: The 8472 Date: Thu, 15 Jun 2023 21:14:40 +0200 Subject: [PATCH 008/103] remove unused field since DrainFilter no longer continues draining when it's dropped the panic tracking is no longer needed. --- library/alloc/src/vec/extract_if.rs | 8 -------- library/alloc/src/vec/mod.rs | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/library/alloc/src/vec/extract_if.rs b/library/alloc/src/vec/extract_if.rs index e8e6bd56d21b..118cfdb36b9c 100644 --- a/library/alloc/src/vec/extract_if.rs +++ b/library/alloc/src/vec/extract_if.rs @@ -37,12 +37,6 @@ pub struct ExtractIf< pub(super) old_len: usize, /// The filter test predicate. pub(super) pred: F, - /// A flag that indicates a panic has occurred in the filter test predicate. - /// This is used as a hint in the drop implementation to prevent consumption - /// of the remainder of the `ExtractIf`. Any unprocessed items will be - /// backshifted in the `vec`, but no further items will be dropped or - /// tested by the filter predicate. - pub(super) panic_flag: bool, } impl ExtractIf<'_, T, F, A> @@ -69,9 +63,7 @@ where while self.idx < self.old_len { let i = self.idx; let v = slice::from_raw_parts_mut(self.vec.as_mut_ptr(), self.old_len); - self.panic_flag = true; let drained = (self.pred)(&mut v[i]); - self.panic_flag = false; // Update the index *after* the predicate is called. If the index // is updated prior and the predicate panics, the element at this // index would be leaked. diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 289bbc7d2eff..259c659c7ebb 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -2948,7 +2948,7 @@ impl Vec { self.set_len(0); } - ExtractIf { vec: self, idx: 0, del: 0, old_len, pred: filter, panic_flag: false } + ExtractIf { vec: self, idx: 0, del: 0, old_len, pred: filter } } } From 001b081cc1bfd24657e2dccbd9c8289f9a9d67a5 Mon Sep 17 00:00:00 2001 From: Igor Gutorov Date: Wed, 14 Jun 2023 19:50:32 +0300 Subject: [PATCH 009/103] alloc: Allow comparing `Box`s over different allocators --- library/alloc/src/boxed.rs | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index 1768687e8cd0..ce0d19f1a3cf 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -1311,39 +1311,56 @@ impl Clone for Box { } #[stable(feature = "rust1", since = "1.0.0")] -impl PartialEq for Box { +impl PartialEq> for Box +where + T: ?Sized + PartialEq, + A1: Allocator, + A2: Allocator, +{ #[inline] - fn eq(&self, other: &Self) -> bool { + fn eq(&self, other: &Box) -> bool { PartialEq::eq(&**self, &**other) } + #[inline] - fn ne(&self, other: &Self) -> bool { + fn ne(&self, other: &Box) -> bool { PartialEq::ne(&**self, &**other) } } + #[stable(feature = "rust1", since = "1.0.0")] -impl PartialOrd for Box { +impl PartialOrd> for Box +where + T: ?Sized + PartialOrd, + A1: Allocator, + A2: Allocator, +{ #[inline] - fn partial_cmp(&self, other: &Self) -> Option { + fn partial_cmp(&self, other: &Box) -> Option { PartialOrd::partial_cmp(&**self, &**other) } + #[inline] - fn lt(&self, other: &Self) -> bool { + fn lt(&self, other: &Box) -> bool { PartialOrd::lt(&**self, &**other) } + #[inline] - fn le(&self, other: &Self) -> bool { + fn le(&self, other: &Box) -> bool { PartialOrd::le(&**self, &**other) } + #[inline] - fn ge(&self, other: &Self) -> bool { + fn ge(&self, other: &Box) -> bool { PartialOrd::ge(&**self, &**other) } + #[inline] - fn gt(&self, other: &Self) -> bool { + fn gt(&self, other: &Box) -> bool { PartialOrd::gt(&**self, &**other) } } + #[stable(feature = "rust1", since = "1.0.0")] impl Ord for Box { #[inline] From c5943307ec68e82bcfcb7604a4ebb2bbab6a0272 Mon Sep 17 00:00:00 2001 From: lcnr Date: Fri, 9 Jun 2023 13:12:45 +0200 Subject: [PATCH 010/103] add tests for unsound subtype handling --- .../codegen/subtyping-impacts-selection-1.rs | 44 +++++++++++++++++++ .../codegen/subtyping-impacts-selection-2.rs | 12 +++++ 2 files changed, 56 insertions(+) create mode 100644 tests/ui/codegen/subtyping-impacts-selection-1.rs create mode 100644 tests/ui/codegen/subtyping-impacts-selection-2.rs diff --git a/tests/ui/codegen/subtyping-impacts-selection-1.rs b/tests/ui/codegen/subtyping-impacts-selection-1.rs new file mode 100644 index 000000000000..09e06f6d6843 --- /dev/null +++ b/tests/ui/codegen/subtyping-impacts-selection-1.rs @@ -0,0 +1,44 @@ +// run-pass +// revisions: mir codegen +//[mir] compile-flags: -Zmir-opt-level=3 +//[codegen] compile-flags: -Zmir-opt-level=0 + +// A regression test for #107205 +#![allow(coherence_leak_check)] +struct Foo(T); + +fn useful<'a>(_: &'a u8) {} + +trait GetInner { + type Assoc; + fn muahaha(&mut self) -> Self::Assoc; +} + +impl GetInner for Foo { + type Assoc = String; + fn muahaha(&mut self) -> String { + String::from("I am a string") + } +} + +impl GetInner for Foo fn(&'a u8)> { + type Assoc = [usize; 3]; + fn muahaha(&mut self) -> [usize; 3] { + [100; 3] + } +} + +fn break_me(hr_fnptr: Box fn(&'a u8)>>) -> Box> { + let lr_fnptr = hr_fnptr as Box>; + lr_fnptr as Box> +} + +fn main() { + drop(Box::new(Foo(useful as fn(&'static u8))) as Box>); + drop(Box::new(Foo(useful as fn(&u8))) as Box>); + + let mut any = break_me(Box::new(Foo(useful))); + + let evil_string = any.muahaha(); + assert_eq!(evil_string, "I am a string"); +} diff --git a/tests/ui/codegen/subtyping-impacts-selection-2.rs b/tests/ui/codegen/subtyping-impacts-selection-2.rs new file mode 100644 index 000000000000..921136775b7f --- /dev/null +++ b/tests/ui/codegen/subtyping-impacts-selection-2.rs @@ -0,0 +1,12 @@ +// run-pass +// revisions: mir codegen +//[mir] compile-flags: -Zmir-opt-level=3 +//[codegen] compile-flags: -Zmir-opt-level=0 + +// A regression test for #107205 + +const X: for<'b> fn(&'b ()) = |&()| (); +fn main() { + let dyn_debug = Box::new(X) as Box as Box; + drop(dyn_debug) +} From be33ad88480781e6dc3e036a40a5c490beac957a Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 19 Jun 2023 09:06:32 +0200 Subject: [PATCH 011/103] fix types in shim building --- compiler/rustc_mir_transform/src/shim.rs | 30 ++++++++++++++----- ...-Fn-call.AddMovesForPackedDrops.before.mir | 2 +- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs index 5f12f1937c06..3d9dccfc7006 100644 --- a/compiler/rustc_mir_transform/src/shim.rs +++ b/compiler/rustc_mir_transform/src/shim.rs @@ -32,13 +32,15 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<' let mut result = match instance { ty::InstanceDef::Item(..) => bug!("item {:?} passed to make_shim", instance), ty::InstanceDef::VTableShim(def_id) => { - build_call_shim(tcx, instance, Some(Adjustment::Deref), CallKind::Direct(def_id)) + let adjustment = Adjustment::Deref { source: DerefSource::MutPtr }; + build_call_shim(tcx, instance, Some(adjustment), CallKind::Direct(def_id)) } ty::InstanceDef::FnPtrShim(def_id, ty) => { let trait_ = tcx.trait_of_item(def_id).unwrap(); let adjustment = match tcx.fn_trait_kind_from_def_id(trait_) { Some(ty::ClosureKind::FnOnce) => Adjustment::Identity, - Some(ty::ClosureKind::FnMut | ty::ClosureKind::Fn) => Adjustment::Deref, + Some(ty::ClosureKind::Fn) => Adjustment::Deref { source: DerefSource::ImmRef }, + Some(ty::ClosureKind::FnMut) => Adjustment::Deref { source: DerefSource::MutRef }, None => bug!("fn pointer {:?} is not an fn", ty), }; @@ -107,16 +109,26 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<' result } +#[derive(Copy, Clone, Debug, PartialEq)] +enum DerefSource { + /// `fn shim(&self) { inner(*self )}`. + ImmRef, + /// `fn shim(&mut self) { inner(*self )}`. + MutRef, + /// `fn shim(*mut self) { inner(*self )}`. + MutPtr, +} + #[derive(Copy, Clone, Debug, PartialEq)] enum Adjustment { /// Pass the receiver as-is. Identity, - /// We get passed `&[mut] self` and call the target with `*self`. + /// We get passed a reference or a raw pointer to `self` and call the target with `*self`. /// /// This either copies `self` (if `Self: Copy`, eg. for function items), or moves out of it /// (for `VTableShim`, which effectively is passed `&own Self`). - Deref, + Deref { source: DerefSource }, /// We get passed `self: Self` and call the target with `&mut self`. /// @@ -667,8 +679,12 @@ fn build_call_shim<'tcx>( let self_arg = &mut inputs_and_output[0]; *self_arg = match rcvr_adjustment.unwrap() { Adjustment::Identity => fnty, - Adjustment::Deref => tcx.mk_imm_ptr(fnty), - Adjustment::RefMut => tcx.mk_mut_ptr(fnty), + Adjustment::Deref { source } => match source { + DerefSource::ImmRef => tcx.mk_imm_ref(tcx.lifetimes.re_erased, fnty), + DerefSource::MutRef => tcx.mk_mut_ref(tcx.lifetimes.re_erased, fnty), + DerefSource::MutPtr => tcx.mk_mut_ptr(fnty), + }, + Adjustment::RefMut => bug!("`RefMut` is never used with indirect calls: {instance:?}"), }; sig.inputs_and_output = tcx.mk_type_list(&inputs_and_output); } @@ -699,7 +715,7 @@ fn build_call_shim<'tcx>( let rcvr = rcvr_adjustment.map(|rcvr_adjustment| match rcvr_adjustment { Adjustment::Identity => Operand::Move(rcvr_place()), - Adjustment::Deref => Operand::Move(tcx.mk_place_deref(rcvr_place())), + Adjustment::Deref { source: _ } => Operand::Move(tcx.mk_place_deref(rcvr_place())), Adjustment::RefMut => { // let rcvr = &mut rcvr; let ref_rcvr = local_decls.push( diff --git a/tests/mir-opt/fn_ptr_shim.core.ops-function-Fn-call.AddMovesForPackedDrops.before.mir b/tests/mir-opt/fn_ptr_shim.core.ops-function-Fn-call.AddMovesForPackedDrops.before.mir index 4fe11435fab9..06cca8323aa1 100644 --- a/tests/mir-opt/fn_ptr_shim.core.ops-function-Fn-call.AddMovesForPackedDrops.before.mir +++ b/tests/mir-opt/fn_ptr_shim.core.ops-function-Fn-call.AddMovesForPackedDrops.before.mir @@ -1,6 +1,6 @@ // MIR for `std::ops::Fn::call` before AddMovesForPackedDrops -fn std::ops::Fn::call(_1: *const fn(), _2: ()) -> >::Output { +fn std::ops::Fn::call(_1: &fn(), _2: ()) -> >::Output { let mut _0: >::Output; bb0: { From 46af169ec599be332d52a4093e3207202130b7d6 Mon Sep 17 00:00:00 2001 From: lcnr Date: Fri, 9 Jun 2023 13:13:31 +0200 Subject: [PATCH 012/103] codegen: fix `OperandRef` subtype handling --- compiler/rustc_codegen_ssa/src/lib.rs | 1 + compiler/rustc_codegen_ssa/src/mir/block.rs | 4 +- .../rustc_codegen_ssa/src/mir/debuginfo.rs | 6 +- compiler/rustc_codegen_ssa/src/mir/locals.rs | 74 +++++++++++++++++++ compiler/rustc_codegen_ssa/src/mir/mod.rs | 43 +++++------ .../rustc_codegen_ssa/src/mir/statement.rs | 2 +- 6 files changed, 101 insertions(+), 29 deletions(-) create mode 100644 compiler/rustc_codegen_ssa/src/mir/locals.rs diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs index 31854c7f4c4e..c26a7422fdd2 100644 --- a/compiler/rustc_codegen_ssa/src/lib.rs +++ b/compiler/rustc_codegen_ssa/src/lib.rs @@ -4,6 +4,7 @@ #![feature(if_let_guard)] #![feature(int_roundings)] #![feature(let_chains)] +#![feature(negative_impls)] #![feature(never_type)] #![feature(strict_provenance)] #![feature(try_blocks)] diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index a4a8aad87269..d97beb0fb6c7 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -1729,7 +1729,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { IndirectOperand(tmp, index) => { let op = bx.load_operand(tmp); tmp.storage_dead(bx); - self.locals[index] = LocalRef::Operand(op); + self.overwrite_local(index, LocalRef::Operand(op)); self.debug_introduce_local(bx, index); } DirectOperand(index) => { @@ -1744,7 +1744,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } else { OperandRef::from_immediate_or_packed_pair(bx, llval, ret_abi.layout) }; - self.locals[index] = LocalRef::Operand(op); + self.overwrite_local(index, LocalRef::Operand(op)); self.debug_introduce_local(bx, index); } } diff --git a/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs b/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs index 4f79c6a3d823..c6589a40392d 100644 --- a/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs +++ b/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs @@ -248,7 +248,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } fn spill_operand_to_stack( - operand: &OperandRef<'tcx, Bx::Value>, + operand: OperandRef<'tcx, Bx::Value>, name: Option, bx: &mut Bx, ) -> PlaceRef<'tcx, Bx::Value> { @@ -375,7 +375,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { return; } - Self::spill_operand_to_stack(operand, name, bx) + Self::spill_operand_to_stack(*operand, name, bx) } LocalRef::Place(place) => *place, @@ -550,7 +550,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { if let Ok(operand) = self.eval_mir_constant_to_operand(bx, &c) { self.set_debug_loc(bx, var.source_info); let base = Self::spill_operand_to_stack( - &operand, + operand, Some(var.name.to_string()), bx, ); diff --git a/compiler/rustc_codegen_ssa/src/mir/locals.rs b/compiler/rustc_codegen_ssa/src/mir/locals.rs new file mode 100644 index 000000000000..b4eb8d0a687d --- /dev/null +++ b/compiler/rustc_codegen_ssa/src/mir/locals.rs @@ -0,0 +1,74 @@ +//! Locals are in a private module as updating `LocalRef::Operand` has to +//! be careful wrt to subtyping. To deal with this we only allow updates by using +//! `FunctionCx::overwrite_local` which handles it automatically. +use crate::mir::{FunctionCx, LocalRef}; +use crate::traits::BuilderMethods; +use rustc_index::IndexVec; +use rustc_middle::mir; +use rustc_middle::ty::print::with_no_trimmed_paths; +use std::ops::{Index, IndexMut}; + +pub(super) struct Locals<'tcx, V> { + values: IndexVec>, +} + +impl<'tcx, V> Index for Locals<'tcx, V> { + type Output = LocalRef<'tcx, V>; + #[inline] + fn index(&self, index: mir::Local) -> &LocalRef<'tcx, V> { + &self.values[index] + } +} + +/// To mutate locals, use `FunctionCx::overwrite_local` instead. +impl<'tcx, V, Idx: ?Sized> !IndexMut for Locals<'tcx, V> {} + +impl<'tcx, V> Locals<'tcx, V> { + pub(super) fn empty() -> Locals<'tcx, V> { + Locals { values: IndexVec::default() } + } + + pub(super) fn indices(&self) -> impl DoubleEndedIterator + Clone + 'tcx { + self.values.indices() + } +} + +impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { + pub(super) fn initialize_locals(&mut self, values: Vec>) { + assert!(self.locals.values.is_empty()); + + for (local, value) in values.into_iter().enumerate() { + match value { + LocalRef::Place(_) | LocalRef::UnsizedPlace(_) | LocalRef::PendingOperand => (), + LocalRef::Operand(op) => { + let local = mir::Local::from_usize(local); + let expected_ty = self.monomorphize(self.mir.local_decls[local].ty); + assert_eq!(expected_ty, op.layout.ty, "unexpected initial operand type"); + } + } + + self.locals.values.push(value); + } + } + + pub(super) fn overwrite_local( + &mut self, + local: mir::Local, + mut value: LocalRef<'tcx, Bx::Value>, + ) { + match value { + LocalRef::Place(_) | LocalRef::UnsizedPlace(_) | LocalRef::PendingOperand => (), + LocalRef::Operand(ref mut op) => { + let local_ty = self.monomorphize(self.mir.local_decls[local].ty); + if local_ty != op.layout.ty { + debug!("updating type of operand due to subtyping"); + with_no_trimmed_paths!(debug!(?op.layout.ty)); + with_no_trimmed_paths!(debug!(?local_ty)); + op.layout.ty = local_ty; + } + } + }; + + self.locals.values[local] = value; + } +} diff --git a/compiler/rustc_codegen_ssa/src/mir/mod.rs b/compiler/rustc_codegen_ssa/src/mir/mod.rs index 2809ec2deb55..15b0e34b8e4d 100644 --- a/compiler/rustc_codegen_ssa/src/mir/mod.rs +++ b/compiler/rustc_codegen_ssa/src/mir/mod.rs @@ -1,21 +1,31 @@ use crate::base; use crate::traits::*; +use rustc_index::bit_set::BitSet; +use rustc_index::IndexVec; use rustc_middle::mir; use rustc_middle::mir::interpret::ErrorHandled; +use rustc_middle::mir::traversal; use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, TyAndLayout}; use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable, TypeVisitableExt}; use rustc_target::abi::call::{FnAbi, PassMode}; use std::iter; -use rustc_index::bit_set::BitSet; -use rustc_index::IndexVec; +mod analyze; +mod block; +pub mod constant; +pub mod coverageinfo; +pub mod debuginfo; +mod intrinsic; +mod locals; +pub mod operand; +pub mod place; +mod rvalue; +mod statement; use self::debuginfo::{FunctionDebugContext, PerLocalVarDebugInfo}; -use self::place::PlaceRef; -use rustc_middle::mir::traversal; - use self::operand::{OperandRef, OperandValue}; +use self::place::PlaceRef; // Used for tracking the state of generated basic blocks. enum CachedLlbb { @@ -91,7 +101,7 @@ pub struct FunctionCx<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> { /// /// Avoiding allocs can also be important for certain intrinsics, /// notably `expect`. - locals: IndexVec>, + locals: locals::Locals<'tcx, Bx::Value>, /// All `VarDebugInfo` from the MIR body, partitioned by `Local`. /// This is `None` if no var`#[non_exhaustive]`iable debuginfo/names are needed. @@ -192,7 +202,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( cleanup_kinds, landing_pads: IndexVec::from_elem(None, &mir.basic_blocks), funclets: IndexVec::from_fn_n(|_| None, mir.basic_blocks.len()), - locals: IndexVec::new(), + locals: locals::Locals::empty(), debug_context, per_local_var_debug_info: None, caller_location: None, @@ -223,7 +233,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( let memory_locals = analyze::non_ssa_locals(&fx); // Allocate variable and temp allocas - fx.locals = { + let local_values = { let args = arg_local_refs(&mut start_bx, &mut fx, &memory_locals); let mut allocate_local = |local| { @@ -256,6 +266,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( .chain(mir.vars_and_temps_iter().map(allocate_local)) .collect() }; + fx.initialize_locals(local_values); // Apply debuginfo to the newly allocated locals. fx.debug_introduce_locals(&mut start_bx); @@ -289,14 +300,13 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( .enumerate() .map(|(arg_index, local)| { let arg_decl = &mir.local_decls[local]; + let arg_ty = fx.monomorphize(arg_decl.ty); if Some(local) == mir.spread_arg { // This argument (e.g., the last argument in the "rust-call" ABI) // is a tuple that was spread at the ABI level and now we have // to reconstruct it into a tuple local variable, from multiple // individual LLVM function arguments. - - let arg_ty = fx.monomorphize(arg_decl.ty); let ty::Tuple(tupled_arg_tys) = arg_ty.kind() else { bug!("spread argument isn't a tuple?!"); }; @@ -331,8 +341,6 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( } if fx.fn_abi.c_variadic && arg_index == fx.fn_abi.args.len() { - let arg_ty = fx.monomorphize(arg_decl.ty); - let va_list = PlaceRef::alloca(bx, bx.layout_of(arg_ty)); bx.va_start(va_list.llval); @@ -429,14 +437,3 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( args } - -mod analyze; -mod block; -pub mod constant; -pub mod coverageinfo; -pub mod debuginfo; -mod intrinsic; -pub mod operand; -pub mod place; -mod rvalue; -mod statement; diff --git a/compiler/rustc_codegen_ssa/src/mir/statement.rs b/compiler/rustc_codegen_ssa/src/mir/statement.rs index 3fd7397ad386..314d364c0c2a 100644 --- a/compiler/rustc_codegen_ssa/src/mir/statement.rs +++ b/compiler/rustc_codegen_ssa/src/mir/statement.rs @@ -20,7 +20,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } LocalRef::PendingOperand => { let operand = self.codegen_rvalue_operand(bx, rvalue); - self.locals[index] = LocalRef::Operand(operand); + self.overwrite_local(index, LocalRef::Operand(operand)); self.debug_introduce_local(bx, index); } LocalRef::Operand(op) => { From 0589cd0f0a9536d028c2118c5b08ee5872d9e9d7 Mon Sep 17 00:00:00 2001 From: lcnr Date: Fri, 9 Jun 2023 13:13:42 +0200 Subject: [PATCH 013/103] mir opt: fix subtype handling --- compiler/rustc_mir_transform/src/dest_prop.rs | 13 +++++++++++++ compiler/rustc_mir_transform/src/ssa.rs | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/compiler/rustc_mir_transform/src/dest_prop.rs b/compiler/rustc_mir_transform/src/dest_prop.rs index 78758e2db28a..9faf2b03f62b 100644 --- a/compiler/rustc_mir_transform/src/dest_prop.rs +++ b/compiler/rustc_mir_transform/src/dest_prop.rs @@ -37,6 +37,10 @@ //! if they do not consistently refer to the same place in memory. This is satisfied if they do //! not contain any indirection through a pointer or any indexing projections. //! +//! * `p` and `q` must have the **same type**. If we replace a local with a subtype or supertype, +//! we may end up with a differnet vtable for that local. See the `subtyping-impacts-selection` +//! tests for an example where that causes issues. +//! //! * We need to make sure that the goal of "merging the memory" is actually structurally possible //! in MIR. For example, even if all the other conditions are satisfied, there is no way to //! "merge" `_5.foo` and `_6.bar`. For now, we ensure this by requiring that both `p` and `q` are @@ -134,6 +138,7 @@ use crate::MirPass; use rustc_data_structures::fx::FxHashMap; use rustc_index::bit_set::BitSet; use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor}; +use rustc_middle::mir::HasLocalDecls; use rustc_middle::mir::{dump_mir, PassWhere}; use rustc_middle::mir::{ traversal, Body, InlineAsmOperand, Local, LocalKind, Location, Operand, Place, Rvalue, @@ -769,6 +774,14 @@ impl<'tcx> Visitor<'tcx> for FindAssignments<'_, '_, 'tcx> { return; } + // As described at the top of this file, we do not touch locals which have different types. + let src_ty = self.body.local_decls()[src].ty; + let dest_ty = self.body.local_decls()[dest].ty; + if src_ty != dest_ty { + trace!("skipped `{src:?} = {dest:?}` due to subtyping: {src_ty} != {dest_ty}"); + return; + } + // Also, we need to make sure that MIR actually allows the `src` to be removed if is_local_required(src, self.body) { return; diff --git a/compiler/rustc_mir_transform/src/ssa.rs b/compiler/rustc_mir_transform/src/ssa.rs index 7a0d3a025f36..5495e3532f76 100644 --- a/compiler/rustc_mir_transform/src/ssa.rs +++ b/compiler/rustc_mir_transform/src/ssa.rs @@ -271,6 +271,13 @@ fn compute_copy_classes(ssa: &mut SsaLocals, body: &Body<'_>) { else { continue }; let Some(rhs) = place.as_local() else { continue }; + let local_ty = body.local_decls()[local].ty; + let rhs_ty = body.local_decls()[rhs].ty; + if local_ty != rhs_ty { + trace!("skipped `{local:?} = {rhs:?}` due to subtyping: {local_ty} != {rhs_ty}"); + continue; + } + if !ssa.is_ssa(rhs) { continue; } From 46973c9c8a775faa92eb10c478490c9b69f2eab6 Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 19 Jun 2023 09:16:26 +0200 Subject: [PATCH 014/103] add FIXME's for a later refactoring --- compiler/rustc_codegen_ssa/src/mir/locals.rs | 1 + compiler/rustc_mir_transform/src/dest_prop.rs | 8 +++++--- compiler/rustc_mir_transform/src/ssa.rs | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/mir/locals.rs b/compiler/rustc_codegen_ssa/src/mir/locals.rs index b4eb8d0a687d..da8bf5e7916a 100644 --- a/compiler/rustc_codegen_ssa/src/mir/locals.rs +++ b/compiler/rustc_codegen_ssa/src/mir/locals.rs @@ -61,6 +61,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { LocalRef::Operand(ref mut op) => { let local_ty = self.monomorphize(self.mir.local_decls[local].ty); if local_ty != op.layout.ty { + // FIXME(#112651): This can be changed to an ICE afterwards. debug!("updating type of operand due to subtyping"); with_no_trimmed_paths!(debug!(?op.layout.ty)); with_no_trimmed_paths!(debug!(?local_ty)); diff --git a/compiler/rustc_mir_transform/src/dest_prop.rs b/compiler/rustc_mir_transform/src/dest_prop.rs index 9faf2b03f62b..a31551cf6199 100644 --- a/compiler/rustc_mir_transform/src/dest_prop.rs +++ b/compiler/rustc_mir_transform/src/dest_prop.rs @@ -768,16 +768,18 @@ impl<'tcx> Visitor<'tcx> for FindAssignments<'_, '_, 'tcx> { return; }; - // As described at the top of the file, we do not go near things that have their address - // taken. + // As described at the top of the file, we do not go near things that have + // their address taken. if self.borrowed.contains(src) || self.borrowed.contains(dest) { return; } - // As described at the top of this file, we do not touch locals which have different types. + // As described at the top of this file, we do not touch locals which have + // different types. let src_ty = self.body.local_decls()[src].ty; let dest_ty = self.body.local_decls()[dest].ty; if src_ty != dest_ty { + // FIXME(#112651): This can be removed afterwards. Also update the module description. trace!("skipped `{src:?} = {dest:?}` due to subtyping: {src_ty} != {dest_ty}"); return; } diff --git a/compiler/rustc_mir_transform/src/ssa.rs b/compiler/rustc_mir_transform/src/ssa.rs index 5495e3532f76..8dc2dfe13bd3 100644 --- a/compiler/rustc_mir_transform/src/ssa.rs +++ b/compiler/rustc_mir_transform/src/ssa.rs @@ -274,6 +274,7 @@ fn compute_copy_classes(ssa: &mut SsaLocals, body: &Body<'_>) { let local_ty = body.local_decls()[local].ty; let rhs_ty = body.local_decls()[rhs].ty; if local_ty != rhs_ty { + // FIXME(#112651): This can be removed afterwards. trace!("skipped `{local:?} = {rhs:?}` due to subtyping: {local_ty} != {rhs_ty}"); continue; } From d50875e24af7671aad9b627fb8c6c4a49fa04e7d Mon Sep 17 00:00:00 2001 From: Lukas Markeffsky <@> Date: Mon, 19 Jun 2023 14:08:38 +0000 Subject: [PATCH 015/103] use `ErrorGuaranteed` instead of booleans --- compiler/rustc_builtin_macros/src/derive.rs | 14 ++- compiler/rustc_builtin_macros/src/test.rs | 115 +++++++++----------- 2 files changed, 63 insertions(+), 66 deletions(-) diff --git a/compiler/rustc_builtin_macros/src/derive.rs b/compiler/rustc_builtin_macros/src/derive.rs index fe4483104eeb..140853db695a 100644 --- a/compiler/rustc_builtin_macros/src/derive.rs +++ b/compiler/rustc_builtin_macros/src/derive.rs @@ -8,7 +8,7 @@ use rustc_feature::AttributeTemplate; use rustc_parse::validate_attr; use rustc_session::Session; use rustc_span::symbol::{sym, Ident}; -use rustc_span::Span; +use rustc_span::{ErrorGuaranteed, Span}; pub(crate) struct Expander(pub bool); @@ -22,7 +22,7 @@ impl MultiItemModifier for Expander { _: bool, ) -> ExpandResult, Annotatable> { let sess = ecx.sess; - if report_bad_target(sess, &item, span) { + if report_bad_target(sess, &item, span).is_err() { // We don't want to pass inappropriate targets to derive macros to avoid // follow up errors, all other errors below are recoverable. return ExpandResult::Ready(vec![item]); @@ -103,7 +103,11 @@ fn dummy_annotatable() -> Annotatable { }) } -fn report_bad_target(sess: &Session, item: &Annotatable, span: Span) -> bool { +fn report_bad_target( + sess: &Session, + item: &Annotatable, + span: Span, +) -> Result<(), ErrorGuaranteed> { let item_kind = match item { Annotatable::Item(item) => Some(&item.kind), Annotatable::Stmt(stmt) => match &stmt.kind { @@ -116,9 +120,9 @@ fn report_bad_target(sess: &Session, item: &Annotatable, span: Span) -> bool { let bad_target = !matches!(item_kind, Some(ItemKind::Struct(..) | ItemKind::Enum(..) | ItemKind::Union(..))); if bad_target { - sess.emit_err(errors::BadDeriveTarget { span, item: item.span() }); + return Err(sess.emit_err(errors::BadDeriveTarget { span, item: item.span() })); } - bad_target + Ok(()) } fn report_unexpected_meta_item_lit(sess: &Session, lit: &ast::MetaItemLit) { diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index fcc68010a34c..d7a92dac50f6 100644 --- a/compiler/rustc_builtin_macros/src/test.rs +++ b/compiler/rustc_builtin_macros/src/test.rs @@ -8,7 +8,7 @@ use rustc_ast_pretty::pprust; use rustc_errors::Applicability; use rustc_expand::base::*; use rustc_span::symbol::{sym, Ident, Symbol}; -use rustc_span::{FileNameDisplayPreference, Span}; +use rustc_span::{ErrorGuaranteed, FileNameDisplayPreference, Span}; use std::iter; use thin_vec::{thin_vec, ThinVec}; @@ -128,12 +128,15 @@ pub fn expand_test_or_bench( }; }; - // has_*_signature will report any errors in the type so compilation + // check_*_signature will report any errors in the type so compilation // will fail. We shouldn't try to expand in this case because the errors // would be spurious. - if (!is_bench && !has_test_signature(cx, &item)) - || (is_bench && !has_bench_signature(cx, &item)) - { + let check_result = if is_bench { + check_bench_signature(cx, &item, &fn_) + } else { + check_test_signature(cx, &item, &fn_) + }; + if check_result.is_err() { return if is_stmt { vec![Annotatable::Stmt(P(cx.stmt_item(item.span, item)))] } else { @@ -523,72 +526,62 @@ fn test_type(cx: &ExtCtxt<'_>) -> TestType { } } -fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool { +fn check_test_signature( + cx: &ExtCtxt<'_>, + i: &ast::Item, + f: &ast::Fn, +) -> Result<(), ErrorGuaranteed> { let has_should_panic_attr = attr::contains_name(&i.attrs, sym::should_panic); let sd = &cx.sess.parse_sess.span_diagnostic; - match &i.kind { - ast::ItemKind::Fn(box ast::Fn { sig, generics, .. }) => { - if let ast::Unsafe::Yes(span) = sig.header.unsafety { - sd.emit_err(errors::TestBadFn { span: i.span, cause: span, kind: "unsafe" }); - return false; - } - if let ast::Async::Yes { span, .. } = sig.header.asyncness { - sd.emit_err(errors::TestBadFn { span: i.span, cause: span, kind: "async" }); - return false; - } - // If the termination trait is active, the compiler will check that the output - // type implements the `Termination` trait as `libtest` enforces that. - let has_output = match &sig.decl.output { - ast::FnRetTy::Default(..) => false, - ast::FnRetTy::Ty(t) if t.kind.is_unit() => false, - _ => true, - }; - - if !sig.decl.inputs.is_empty() { - sd.span_err(i.span, "functions used as tests can not have any arguments"); - return false; - } - - if has_should_panic_attr && has_output { - sd.span_err(i.span, "functions using `#[should_panic]` must return `()`"); - return false; - } - - if generics.params.iter().any(|param| !matches!(param.kind, GenericParamKind::Lifetime)) - { - sd.span_err( - i.span, - "functions used as tests can not have any non-lifetime generic parameters", - ); - return false; - } - - true - } - _ => { - // should be unreachable because `is_test_fn_item` should catch all non-fn items - debug_assert!(false); - false - } + if let ast::Unsafe::Yes(span) = f.sig.header.unsafety { + return Err(sd.emit_err(errors::TestBadFn { span: i.span, cause: span, kind: "unsafe" })); } -} -fn has_bench_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool { - let has_sig = match &i.kind { - // N.B., inadequate check, but we're running - // well before resolve, can't get too deep. - ast::ItemKind::Fn(box ast::Fn { sig, .. }) => sig.decl.inputs.len() == 1, - _ => false, + if let ast::Async::Yes { span, .. } = f.sig.header.asyncness { + return Err(sd.emit_err(errors::TestBadFn { span: i.span, cause: span, kind: "async" })); + } + + // If the termination trait is active, the compiler will check that the output + // type implements the `Termination` trait as `libtest` enforces that. + let has_output = match &f.sig.decl.output { + ast::FnRetTy::Default(..) => false, + ast::FnRetTy::Ty(t) if t.kind.is_unit() => false, + _ => true, }; - if !has_sig { - cx.sess.parse_sess.span_diagnostic.span_err( + if !f.sig.decl.inputs.is_empty() { + return Err(sd.span_err(i.span, "functions used as tests can not have any arguments")); + } + + if has_should_panic_attr && has_output { + return Err(sd.span_err(i.span, "functions using `#[should_panic]` must return `()`")); + } + + if f.generics.params.iter().any(|param| !matches!(param.kind, GenericParamKind::Lifetime)) { + return Err(sd.span_err( + i.span, + "functions used as tests can not have any non-lifetime generic parameters", + )); + } + + Ok(()) +} + +fn check_bench_signature( + cx: &ExtCtxt<'_>, + i: &ast::Item, + f: &ast::Fn, +) -> Result<(), ErrorGuaranteed> { + // N.B., inadequate check, but we're running + // well before resolve, can't get too deep. + if f.sig.decl.inputs.len() != 1 { + return Err(cx.sess.parse_sess.span_diagnostic.span_err( i.span, "functions used as benches must have \ signature `fn(&mut Bencher) -> impl Termination`", - ); + )); } - has_sig + Ok(()) } From 76092263d9297a3771ad4b36f5f41b87e49db6cc Mon Sep 17 00:00:00 2001 From: WANG Rui Date: Tue, 20 Jun 2023 11:38:59 +0800 Subject: [PATCH 016/103] doc: loongarch: Update maintainers --- src/doc/rustc/src/platform-support/loongarch-linux.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/platform-support/loongarch-linux.md b/src/doc/rustc/src/platform-support/loongarch-linux.md index 999e71f80285..17e85590f2c1 100644 --- a/src/doc/rustc/src/platform-support/loongarch-linux.md +++ b/src/doc/rustc/src/platform-support/loongarch-linux.md @@ -28,9 +28,9 @@ While the integer base ABI is implied by the machine field, the floating po ## Target maintainers -- [ZHAI Xiaojuan](https://github.com/zhaixiaojuan) `zhaixiaojuan@loongson.cn` - [WANG Rui](https://github.com/heiher) `wangrui@loongson.cn` - [ZHAI Xiang](https://github.com/xiangzhai) `zhaixiang@loongson.cn` +- [ZHAI Xiaojuan](https://github.com/zhaixiaojuan) `zhaixiaojuan@loongson.cn` - [WANG Xuerui](https://github.com/xen0n) `git@xen0n.name` ## Requirements From a56c829e747a6ee2e1a1d8d20472f3a5a4d95c79 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Fri, 9 Jun 2023 11:16:25 +0200 Subject: [PATCH 017/103] merge target spec and --print=cfg for compiletest target info --- src/tools/compiletest/src/common.rs | 86 ++++++++--------------------- 1 file changed, 23 insertions(+), 63 deletions(-) diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 1b46c42fa4cf..40cf42995b7b 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -453,7 +453,7 @@ impl TargetCfgs { let mut all_families = HashSet::new(); let mut all_pointer_widths = HashSet::new(); - for (target, cfg) in targets.into_iter() { + for (target, cfg) in targets.iter() { all_archs.insert(cfg.arch.clone()); all_oses.insert(cfg.os.clone()); all_oses_and_envs.insert(cfg.os_and_env()); @@ -464,11 +464,11 @@ impl TargetCfgs { } all_pointer_widths.insert(format!("{}bit", cfg.pointer_width)); - all_targets.insert(target.into()); + all_targets.insert(target.clone()); } Self { - current: Self::get_current_target_config(config), + current: Self::get_current_target_config(config, &targets), all_targets, all_archs, all_oses, @@ -480,16 +480,20 @@ impl TargetCfgs { } } - fn get_current_target_config(config: &Config) -> TargetCfg { - let mut arch = None; - let mut os = None; - let mut env = None; - let mut abi = None; - let mut families = Vec::new(); - let mut pointer_width = None; - let mut endian = None; - let mut panic = None; + fn get_current_target_config( + config: &Config, + targets: &HashMap, + ) -> TargetCfg { + let mut cfg = targets[&config.target].clone(); + // To get the target information for the current target, we take the target spec obtained + // from `--print=all-target-specs-json`, and then we enrich it with the information + // gathered from `--print=cfg --target=$target`. + // + // This is done because some parts of the target spec can be overridden with `-C` flags, + // which are respected for `--print=cfg` but not for `--print=all-target-specs-json`. The + // code below extracts them from `--print=cfg`: make sure to only override fields that can + // actually be changed with `-C` flags. for config in rustc_output(config, &["--print=cfg", "--target", &config.target]).trim().lines() { @@ -507,60 +511,16 @@ impl TargetCfgs { }) .unwrap_or_else(|| (config, None)); - match name { - "target_arch" => { - arch = Some(value.expect("target_arch should be a key-value pair").to_string()); - } - "target_os" => { - os = Some(value.expect("target_os sould be a key-value pair").to_string()); - } - "target_env" => { - env = Some(value.expect("target_env should be a key-value pair").to_string()); - } - "target_abi" => { - abi = Some(value.expect("target_abi should be a key-value pair").to_string()); - } - "target_family" => { - families - .push(value.expect("target_family should be a key-value pair").to_string()); - } - "target_pointer_width" => { - pointer_width = Some( - value - .expect("target_pointer_width should be a key-value pair") - .parse::() - .expect("target_pointer_width should be a valid u32"), - ); - } - "target_endian" => { - endian = Some(match value.expect("target_endian should be a key-value pair") { - "big" => Endian::Big, - "little" => Endian::Little, - _ => panic!("target_endian should be either 'big' or 'little'"), - }); - } - "panic" => { - panic = Some(match value.expect("panic should be a key-value pair") { - "abort" => PanicStrategy::Abort, - "unwind" => PanicStrategy::Unwind, - _ => panic!("panic should be either 'abort' or 'unwind'"), - }); - } - _ => (), + match (name, value) { + // Can be overridden with `-C panic=$strategy`. + ("panic", Some("abort")) => cfg.panic = PanicStrategy::Abort, + ("panic", Some("unwind")) => cfg.panic = PanicStrategy::Unwind, + ("panic", other) => panic!("unexpected value for panic cfg: {other:?}"), + _ => {} } } - TargetCfg { - arch: arch.expect("target configuration should specify target_arch"), - os: os.expect("target configuration should specify target_os"), - env: env.expect("target configuration should specify target_env"), - abi: abi.expect("target configuration should specify target_abi"), - families, - pointer_width: pointer_width - .expect("target configuration should specify target_pointer_width"), - endian: endian.expect("target configuration should specify target_endian"), - panic: panic.expect("target configuration should specify panic"), - } + cfg } } From 04f658f3d3d7b5bc0b563fbc2d7d3f578cc3ea2b Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Fri, 9 Jun 2023 11:32:49 +0200 Subject: [PATCH 018/103] avoid dynamic linking on targets that do not support dynamic linking --- src/tools/compiletest/src/common.rs | 2 ++ src/tools/compiletest/src/runtest.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 40cf42995b7b..85a8fbcffbe2 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -542,6 +542,8 @@ pub struct TargetCfg { endian: Endian, #[serde(rename = "panic-strategy", default)] pub(crate) panic: PanicStrategy, + #[serde(default)] + pub(crate) dynamic_linking: bool, } impl TargetCfg { diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 25b16e38e534..5c8ee7895d3b 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1810,8 +1810,8 @@ impl<'test> TestCx<'test> { || self.config.target.contains("wasm32") || self.config.target.contains("nvptx") || self.is_vxworks_pure_static() - || self.config.target.contains("sgx") || self.config.target.contains("bpf") + || !self.config.target_cfg().dynamic_linking { // We primarily compile all auxiliary libraries as dynamic libraries // to avoid code size bloat and large binaries as much as possible From 767c4b9ef17370622aafdb1eae86c12d962f45ad Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Wed, 17 May 2023 10:41:41 +0200 Subject: [PATCH 019/103] add support for needs-dynamic-linking --- src/tools/compiletest/src/header/needs.rs | 5 +++++ tests/ui/issues/issue-12133-3.rs | 2 +- tests/ui/issues/issue-85461.rs | 1 + tests/ui/proc-macro/crt-static.rs | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/tools/compiletest/src/header/needs.rs b/src/tools/compiletest/src/header/needs.rs index 18b3b913a682..0e306696a90c 100644 --- a/src/tools/compiletest/src/header/needs.rs +++ b/src/tools/compiletest/src/header/needs.rs @@ -130,6 +130,11 @@ pub(super) fn handle_needs( condition: config.git_hash, ignore_reason: "ignored when git hashes have been omitted for building", }, + Need { + name: "needs-dynamic-linking", + condition: config.target_cfg().dynamic_linking, + ignore_reason: "ignored on targets without dynamic linking", + }, ]; let (name, comment) = match ln.split_once([':', ' ']) { diff --git a/tests/ui/issues/issue-12133-3.rs b/tests/ui/issues/issue-12133-3.rs index e6b16e2da1dc..988b61e3bafa 100644 --- a/tests/ui/issues/issue-12133-3.rs +++ b/tests/ui/issues/issue-12133-3.rs @@ -4,7 +4,7 @@ // aux-build:issue-12133-dylib2.rs // ignore-emscripten no dylib support // ignore-musl -// ignore-sgx no dylib support +// needs-dynamic-linking // pretty-expanded FIXME #23616 diff --git a/tests/ui/issues/issue-85461.rs b/tests/ui/issues/issue-85461.rs index 9655108876f1..092105df24e2 100644 --- a/tests/ui/issues/issue-85461.rs +++ b/tests/ui/issues/issue-85461.rs @@ -1,6 +1,7 @@ // compile-flags: -Cinstrument-coverage -Ccodegen-units=4 --crate-type dylib -Copt-level=0 // build-pass // needs-profiler-support +// needs-dynamic-linking // Regression test for #85461 where MSVC sometimes fails to link instrument-coverage binaries // with dead code and #[inline(always)]. diff --git a/tests/ui/proc-macro/crt-static.rs b/tests/ui/proc-macro/crt-static.rs index 020128fa2144..78592f82709d 100644 --- a/tests/ui/proc-macro/crt-static.rs +++ b/tests/ui/proc-macro/crt-static.rs @@ -7,6 +7,7 @@ // build-pass // force-host // no-prefer-dynamic +// needs-dynamic-linking #![crate_type = "proc-macro"] From e1c3313d382871bfdace6b2f385e53d2892438b6 Mon Sep 17 00:00:00 2001 From: klensy Date: Wed, 21 Jun 2023 12:32:34 +0300 Subject: [PATCH 020/103] rust-installer: drop clap v3, migrate to v4 --- Cargo.lock | 95 +++-------------------- src/tools/rust-installer/Cargo.toml | 2 +- src/tools/rust-installer/src/combiner.rs | 22 +++--- src/tools/rust-installer/src/generator.rs | 26 +++---- src/tools/rust-installer/src/scripter.rs | 10 +-- src/tools/rust-installer/src/tarballer.rs | 10 +-- src/tools/rust-installer/src/util.rs | 2 +- 7 files changed, 46 insertions(+), 121 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3d0f9e8844e0..549880156def 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -480,23 +480,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "clap" -version = "3.2.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b71c3ce99b7611011217b366d923f1d0a7e07a92bb2dbf1e84508c673ca3bd" -dependencies = [ - "atty", - "bitflags", - "clap_derive 3.2.18", - "clap_lex 0.2.2", - "indexmap", - "once_cell", - "strsim", - "termcolor", - "textwrap", -] - [[package]] name = "clap" version = "4.2.1" @@ -504,7 +487,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "046ae530c528f252094e4a77886ee1374437744b2bff1497aa898bbddbbb29b3" dependencies = [ "clap_builder", - "clap_derive 4.2.0", + "clap_derive", "once_cell", ] @@ -517,7 +500,7 @@ dependencies = [ "anstream", "anstyle", "bitflags", - "clap_lex 0.4.1", + "clap_lex", "once_cell", "strsim", "terminal_size", @@ -529,20 +512,7 @@ version = "4.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10861370d2ba66b0f5989f83ebf35db6421713fd92351790e7fdd6c36774c56b" dependencies = [ - "clap 4.2.1", -] - -[[package]] -name = "clap_derive" -version = "3.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" -dependencies = [ - "heck", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.102", + "clap", ] [[package]] @@ -557,15 +527,6 @@ dependencies = [ "syn 2.0.8", ] -[[package]] -name = "clap_lex" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5538cd660450ebeb4234cfecf8f2284b844ffc4c50531e66d584ad5b91293613" -dependencies = [ - "os_str_bytes", -] - [[package]] name = "clap_lex" version = "0.4.1" @@ -576,7 +537,7 @@ checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" name = "clippy" version = "0.1.72" dependencies = [ - "clap 4.2.1", + "clap", "clippy_lints", "clippy_utils", "compiletest_rs", @@ -605,7 +566,7 @@ name = "clippy_dev" version = "0.0.1" dependencies = [ "aho-corasick", - "clap 4.2.1", + "clap", "indoc", "itertools", "opener", @@ -1749,7 +1710,7 @@ name = "installer" version = "0.0.0" dependencies = [ "anyhow", - "clap 3.2.20", + "clap", "flate2", "num_cpus", "rayon", @@ -1869,7 +1830,7 @@ name = "jsondoclint" version = "0.1.0" dependencies = [ "anyhow", - "clap 4.2.1", + "clap", "fs-err", "rustc-hash", "rustdoc-json-types", @@ -2086,7 +2047,7 @@ dependencies = [ "ammonia", "anyhow", "chrono", - "clap 4.2.1", + "clap", "clap_complete", "elasticlunr-rs", "env_logger 0.10.0", @@ -2370,12 +2331,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "os_str_bytes" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" - [[package]] name = "owo-colors" version = "3.5.0" @@ -2617,30 +2572,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.102", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro-hack" version = "0.5.19" @@ -2897,7 +2828,7 @@ dependencies = [ name = "rustbook" version = "0.1.0" dependencies = [ - "clap 4.2.1", + "clap", "env_logger 0.10.0", "mdbook", ] @@ -4346,7 +4277,7 @@ dependencies = [ "anyhow", "bytecount", "cargo_metadata", - "clap 4.2.1", + "clap", "diff", "dirs", "env_logger 0.10.0", @@ -4874,12 +4805,6 @@ dependencies = [ "term", ] -[[package]] -name = "textwrap" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" - [[package]] name = "thin-vec" version = "0.2.12" diff --git a/src/tools/rust-installer/Cargo.toml b/src/tools/rust-installer/Cargo.toml index 85e979f07bff..060c4bf75bb8 100644 --- a/src/tools/rust-installer/Cargo.toml +++ b/src/tools/rust-installer/Cargo.toml @@ -20,4 +20,4 @@ num_cpus = "1" [dependencies.clap] features = ["derive"] -version = "3.1" +version = "4.2" diff --git a/src/tools/rust-installer/src/combiner.rs b/src/tools/rust-installer/src/combiner.rs index abcf59cfe36c..90816a2ec6e2 100644 --- a/src/tools/rust-installer/src/combiner.rs +++ b/src/tools/rust-installer/src/combiner.rs @@ -13,47 +13,47 @@ actor! { #[derive(Debug)] pub struct Combiner { /// The name of the product, for display. - #[clap(value_name = "NAME")] + #[arg(value_name = "NAME")] product_name: String = "Product", /// The name of the package tarball. - #[clap(value_name = "NAME")] + #[arg(value_name = "NAME")] package_name: String = "package", /// The directory under lib/ where the manifest lives. - #[clap(value_name = "DIR")] + #[arg(value_name = "DIR")] rel_manifest_dir: String = "packagelib", /// The string to print after successful installation. - #[clap(value_name = "MESSAGE")] + #[arg(value_name = "MESSAGE")] success_message: String = "Installed.", /// Places to look for legacy manifests to uninstall. - #[clap(value_name = "DIRS")] + #[arg(value_name = "DIRS")] legacy_manifest_dirs: String = "", /// Installers to combine. - #[clap(value_name = "FILE,FILE")] + #[arg(value_name = "FILE,FILE")] input_tarballs: String = "", /// Directory containing files that should not be installed. - #[clap(value_name = "DIR")] + #[arg(value_name = "DIR")] non_installed_overlay: String = "", /// The directory to do temporary work. - #[clap(value_name = "DIR")] + #[arg(value_name = "DIR")] work_dir: String = "./workdir", /// The location to put the final image and tarball. - #[clap(value_name = "DIR")] + #[arg(value_name = "DIR")] output_dir: String = "./dist", /// The profile used to compress the tarball. - #[clap(value_name = "FORMAT", default_value_t)] + #[arg(value_name = "FORMAT", default_value_t)] compression_profile: CompressionProfile, /// The formats used to compress the tarball - #[clap(value_name = "FORMAT", default_value_t)] + #[arg(value_name = "FORMAT", default_value_t)] compression_formats: CompressionFormats, } } diff --git a/src/tools/rust-installer/src/generator.rs b/src/tools/rust-installer/src/generator.rs index ddd1052599d5..d91a51321e4c 100644 --- a/src/tools/rust-installer/src/generator.rs +++ b/src/tools/rust-installer/src/generator.rs @@ -11,55 +11,55 @@ actor! { #[derive(Debug)] pub struct Generator { /// The name of the product, for display - #[clap(value_name = "NAME")] + #[arg(value_name = "NAME")] product_name: String = "Product", /// The name of the component, distinct from other installed components - #[clap(value_name = "NAME")] + #[arg(value_name = "NAME")] component_name: String = "component", /// The name of the package, tarball - #[clap(value_name = "NAME")] + #[arg(value_name = "NAME")] package_name: String = "package", /// The directory under lib/ where the manifest lives - #[clap(value_name = "DIR")] + #[arg(value_name = "DIR")] rel_manifest_dir: String = "packagelib", /// The string to print after successful installation - #[clap(value_name = "MESSAGE")] + #[arg(value_name = "MESSAGE")] success_message: String = "Installed.", /// Places to look for legacy manifests to uninstall - #[clap(value_name = "DIRS")] + #[arg(value_name = "DIRS")] legacy_manifest_dirs: String = "", /// Directory containing files that should not be installed - #[clap(value_name = "DIR")] + #[arg(value_name = "DIR")] non_installed_overlay: String = "", /// Path prefixes of directories that should be installed/uninstalled in bulk - #[clap(value_name = "DIRS")] + #[arg(value_name = "DIRS")] bulk_dirs: String = "", /// The directory containing the installation medium - #[clap(value_name = "DIR")] + #[arg(value_name = "DIR")] image_dir: String = "./install_image", /// The directory to do temporary work - #[clap(value_name = "DIR")] + #[arg(value_name = "DIR")] work_dir: String = "./workdir", /// The location to put the final image and tarball - #[clap(value_name = "DIR")] + #[arg(value_name = "DIR")] output_dir: String = "./dist", /// The profile used to compress the tarball. - #[clap(value_name = "FORMAT", default_value_t)] + #[arg(value_name = "FORMAT", default_value_t)] compression_profile: CompressionProfile, /// The formats used to compress the tarball - #[clap(value_name = "FORMAT", default_value_t)] + #[arg(value_name = "FORMAT", default_value_t)] compression_formats: CompressionFormats, } } diff --git a/src/tools/rust-installer/src/scripter.rs b/src/tools/rust-installer/src/scripter.rs index 06affc029fd1..4f5130c78f4f 100644 --- a/src/tools/rust-installer/src/scripter.rs +++ b/src/tools/rust-installer/src/scripter.rs @@ -8,23 +8,23 @@ actor! { #[derive(Debug)] pub struct Scripter { /// The name of the product, for display - #[clap(value_name = "NAME")] + #[arg(value_name = "NAME")] product_name: String = "Product", /// The directory under lib/ where the manifest lives - #[clap(value_name = "DIR")] + #[arg(value_name = "DIR")] rel_manifest_dir: String = "manifestlib", /// The string to print after successful installation - #[clap(value_name = "MESSAGE")] + #[arg(value_name = "MESSAGE")] success_message: String = "Installed.", /// Places to look for legacy manifests to uninstall - #[clap(value_name = "DIRS")] + #[arg(value_name = "DIRS")] legacy_manifest_dirs: String = "", /// The name of the output script - #[clap(value_name = "FILE")] + #[arg(value_name = "FILE")] output_script: String = "install.sh", } } diff --git a/src/tools/rust-installer/src/tarballer.rs b/src/tools/rust-installer/src/tarballer.rs index 7353a49fe035..f8b48a378c9d 100644 --- a/src/tools/rust-installer/src/tarballer.rs +++ b/src/tools/rust-installer/src/tarballer.rs @@ -14,23 +14,23 @@ actor! { #[derive(Debug)] pub struct Tarballer { /// The input folder to be compressed. - #[clap(value_name = "NAME")] + #[arg(value_name = "NAME")] input: String = "package", /// The prefix of the tarballs. - #[clap(value_name = "PATH")] + #[arg(value_name = "PATH")] output: String = "./dist", /// The folder in which the input is to be found. - #[clap(value_name = "DIR")] + #[arg(value_name = "DIR")] work_dir: String = "./workdir", /// The profile used to compress the tarball. - #[clap(value_name = "FORMAT", default_value_t)] + #[arg(value_name = "FORMAT", default_value_t)] compression_profile: CompressionProfile, /// The formats used to compress the tarball. - #[clap(value_name = "FORMAT", default_value_t)] + #[arg(value_name = "FORMAT", default_value_t)] compression_formats: CompressionFormats, } } diff --git a/src/tools/rust-installer/src/util.rs b/src/tools/rust-installer/src/util.rs index 6cac314b68d0..b699aa8e8bf6 100644 --- a/src/tools/rust-installer/src/util.rs +++ b/src/tools/rust-installer/src/util.rs @@ -135,7 +135,7 @@ macro_rules! actor { $( #[ $attr ] )+ #[derive(clap::Args)] pub struct $name { - $( $( #[ $field_attr ] )+ #[clap(long, $(default_value = $default)*)] $field : $type, )* + $( $( #[ $field_attr ] )+ #[arg(long, $(default_value = $default)*)] $field : $type, )* } impl Default for $name { From fd1439ed8b715d9304ad847ae52060bf6f28c23f Mon Sep 17 00:00:00 2001 From: klensy Date: Wed, 21 Jun 2023 12:43:14 +0300 Subject: [PATCH 021/103] change edition to 2021, fix clippy warns --- src/tools/rust-installer/Cargo.toml | 2 +- src/tools/rust-installer/src/combiner.rs | 8 ++++---- src/tools/rust-installer/src/compression.rs | 2 +- src/tools/rust-installer/src/generator.rs | 2 +- src/tools/rust-installer/src/scripter.rs | 2 +- src/tools/rust-installer/src/tarballer.rs | 4 ++-- src/tools/rust-installer/src/util.rs | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/tools/rust-installer/Cargo.toml b/src/tools/rust-installer/Cargo.toml index 060c4bf75bb8..471f2b5ac73e 100644 --- a/src/tools/rust-installer/Cargo.toml +++ b/src/tools/rust-installer/Cargo.toml @@ -2,7 +2,7 @@ authors = ["The Rust Project Developers"] name = "installer" version = "0.0.0" -edition = "2018" +edition = "2021" [[bin]] doc = false diff --git a/src/tools/rust-installer/src/combiner.rs b/src/tools/rust-installer/src/combiner.rs index 90816a2ec6e2..19466f63fedf 100644 --- a/src/tools/rust-installer/src/combiner.rs +++ b/src/tools/rust-installer/src/combiner.rs @@ -94,7 +94,7 @@ impl Combiner { let pkg_name = input_tarball.trim_end_matches(&format!(".tar.{}", compression.extension())); let pkg_name = Path::new(pkg_name).file_name().unwrap(); - let pkg_dir = Path::new(&self.work_dir).join(&pkg_name); + let pkg_dir = Path::new(&self.work_dir).join(pkg_name); // Verify the version number. let mut version = String::new(); @@ -114,9 +114,9 @@ impl Combiner { // All we need to do is copy the component directory. We could // move it, but rustbuild wants to reuse the unpacked package // dir for OS-specific installers on macOS and Windows. - let component_dir = package_dir.join(&component); + let component_dir = package_dir.join(component); create_dir(&component_dir)?; - copy_recursive(&pkg_dir.join(&component), &component_dir)?; + copy_recursive(&pkg_dir.join(component), &component_dir)?; // Merge the component name. writeln!(&components, "{}", component).context("failed to write new components")?; @@ -158,7 +158,7 @@ impl Combiner { .input(self.package_name) .output(path_to_str(&output)?.into()) .compression_profile(self.compression_profile) - .compression_formats(self.compression_formats.clone()); + .compression_formats(self.compression_formats); tarballer.run()?; Ok(()) diff --git a/src/tools/rust-installer/src/compression.rs b/src/tools/rust-installer/src/compression.rs index 7c9c946e0b54..902b2ec69078 100644 --- a/src/tools/rust-installer/src/compression.rs +++ b/src/tools/rust-installer/src/compression.rs @@ -166,7 +166,7 @@ impl Default for CompressionFormats { impl CompressionFormats { pub(crate) fn iter(&self) -> impl Iterator + '_ { - self.0.iter().map(|i| *i) + self.0.iter().copied() } } diff --git a/src/tools/rust-installer/src/generator.rs b/src/tools/rust-installer/src/generator.rs index d91a51321e4c..45f8c49d03ea 100644 --- a/src/tools/rust-installer/src/generator.rs +++ b/src/tools/rust-installer/src/generator.rs @@ -118,7 +118,7 @@ impl Generator { .input(self.package_name) .output(path_to_str(&output)?.into()) .compression_profile(self.compression_profile) - .compression_formats(self.compression_formats.clone()); + .compression_formats(self.compression_formats); tarballer.run()?; Ok(()) diff --git a/src/tools/rust-installer/src/scripter.rs b/src/tools/rust-installer/src/scripter.rs index 4f5130c78f4f..8180f925cb0d 100644 --- a/src/tools/rust-installer/src/scripter.rs +++ b/src/tools/rust-installer/src/scripter.rs @@ -2,7 +2,7 @@ use crate::util::*; use anyhow::{Context, Result}; use std::io::Write; -const TEMPLATE: &'static str = include_str!("../install-template.sh"); +const TEMPLATE: &str = include_str!("../install-template.sh"); actor! { #[derive(Debug)] diff --git a/src/tools/rust-installer/src/tarballer.rs b/src/tools/rust-installer/src/tarballer.rs index f8b48a378c9d..c60d5f648ffc 100644 --- a/src/tools/rust-installer/src/tarballer.rs +++ b/src/tools/rust-installer/src/tarballer.rs @@ -98,7 +98,7 @@ fn append_path(builder: &mut Builder, src: &Path, path: &String) -> if cfg!(windows) { // Windows doesn't really have a mode, so `tar` never marks files executable. // Use an extension whitelist to update files that usually should be so. - const EXECUTABLES: [&'static str; 4] = ["exe", "dll", "py", "sh"]; + const EXECUTABLES: [&str; 4] = ["exe", "dll", "py", "sh"]; if let Some(ext) = src.extension().and_then(|s| s.to_str()) { if EXECUTABLES.contains(&ext) { let mode = header.mode()?; @@ -134,7 +134,7 @@ where for entry in WalkDir::new(root.join(name)) { let entry = entry?; let path = entry.path().strip_prefix(root)?; - let path = path_to_str(&path)?; + let path = path_to_str(path)?; if entry.file_type().is_dir() { dirs.push(path.to_owned()); diff --git a/src/tools/rust-installer/src/util.rs b/src/tools/rust-installer/src/util.rs index b699aa8e8bf6..4eb2e75fd7e1 100644 --- a/src/tools/rust-installer/src/util.rs +++ b/src/tools/rust-installer/src/util.rs @@ -117,7 +117,7 @@ where } else { copy(entry.path(), dst)?; } - callback(&path, file_type)?; + callback(path, file_type)?; } Ok(()) } From b551730cd6be9c46d795d9b12a5f932ff2374eca Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Wed, 21 Jun 2023 16:18:52 -0700 Subject: [PATCH 022/103] style-guide: Rewrite let-else section for clarity, without changing formatting The section as written did not cover all cases, and left some of them implicit. Rewrite it to systematically cover all cases. Place examples immediately following the corresponding case. In the process, reorder to move the simplest cases first: start with single-line and add progressively more line breaks. This does not change the meaning of the section at all, and in particular does not change the defined style for let-else statements. --- src/doc/style-guide/src/statements.md | 103 +++++++++++++++----------- 1 file changed, 61 insertions(+), 42 deletions(-) diff --git a/src/doc/style-guide/src/statements.md b/src/doc/style-guide/src/statements.md index 671e6d31a577..b6708e6c72a5 100644 --- a/src/doc/style-guide/src/statements.md +++ b/src/doc/style-guide/src/statements.md @@ -101,22 +101,69 @@ let Foo { #### else blocks (let-else statements) -If a let statement contains an `else` component, also known as a let-else statement, -then the `else` component should be formatted according to the same rules as the `else` block -in [control flow expressions (i.e. if-else, and if-let-else expressions)](./expressions.md#control-flow-expressions). -Apply the same formatting rules to the components preceding -the `else` block (i.e. the `let pattern: Type = initializer_expr ...` portion) -as described [above](#let-statements) +A let statement can contain an `else` component, making it a let-else statement. +In this case, always apply the same formatting rules to the components preceding +the `else` block (i.e. the `let pattern: Type = initializer_expr` portion) +as described [for other let statements](#let-statements). -Similarly to if-else expressions, if the initializer -expression is multi-lined, then the `else` keyword and opening brace of the block (i.e. `else {`) -should be put on the same line as the end of the initializer -expression with a preceding space if all the following are true: +The entire let-else statement may be formatted on a single line if all the +following are true: + +* the entire statement is *short* +* the `else` block contains only a single-line expression and no statements +* the `else` block contains no comments +* the let statement components preceding the `else` block can be formatted on a single line + +```rust +let Some(1) = opt else { return }; +``` + +Formatters may allow users to configure the value of the threshold +used to determine whether a let-else statement is *short*. + +Otherwise, the let-else statement requires some line breaks. + +If breaking a let-else statement across multiple lines, never break between the +`else` and the `{`, and always break before the `}`. + +If the let statement components preceding the `else` can be formatted on a +single line, but the let-else does not qualify to be placed entirely on a +single line, put the `else {` on the same line as the initializer expression, +with a space between them, then break the line after the `{`. Indent the +closing `}` to match the `let`, and indent the contained block one step +further. + +```rust +let Some(1) = opt else { + return; +}; + +let Some(1) = opt else { + // nope + return +}; +``` + +If the let statement components preceding the `else` can be formatted on a +single line, but the `else {` does not fit on the same line, break the line +before the `else`. + +```rust + let Some(x) = some_really_really_really_really_really_really_really_really_really_long_name + else { + return; + }; +``` + +If the initializer expression is multi-line, the `else` keyword and opening +brace of the block (i.e. `else {`) should be put on the same line as the end of +the initializer expression, with a space between them, if all the following are +true: * The initializer expression ends with one or more closing parentheses, square brackets, and/or braces * There is nothing else on that line -* That line is not indented beyond the indent of the first line containing the `let` keyword +* That line has the same indentation level as the initial `let` keyword. For example: @@ -133,7 +180,9 @@ let Some(x) = y.foo( } ``` -Otherwise, the `else` keyword and opening brace should be placed on the next line after the end of the initializer expression, and should not be indented (the `else` keyword should be aligned with the `let` keyword). +Otherwise, the `else` keyword and opening brace should be placed on the next +line after the end of the initializer expression, and the `else` keyword should +have the same indentation level as the `let` keyword. For example: @@ -153,11 +202,6 @@ fn main() { return }; - let Some(x) = some_really_really_really_really_really_really_really_really_really_long_name - else { - return; - }; - let Some(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) = bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb else { @@ -166,31 +210,6 @@ fn main() { } ``` -##### Single line let-else statements - -The entire let-else statement may be formatted on a single line if all the following are true: - -* the entire statement is *short* -* the `else` block contains a single-line expression and no statements -* the `else` block contains no comments -* the let statement components preceding the `else` block can be formatted on a single line - -```rust -let Some(1) = opt else { return }; - -let Some(1) = opt else { - return; -}; - -let Some(1) = opt else { - // nope - return -}; -``` - -Formatters may allow users to configure the value of the threshold -used to determine whether a let-else statement is *short*. - ### Macros in statement position A macro use in statement position should use parentheses or square brackets as From e5e480504f1dffff5f05e07de47234c14547512d Mon Sep 17 00:00:00 2001 From: Preveen P <31464911+preveen-stack@users.noreply.github.com> Date: Thu, 22 Jun 2023 09:59:31 +0530 Subject: [PATCH 023/103] Update runtests.py : grammar correction --- src/etc/test-float-parse/runtests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/etc/test-float-parse/runtests.py b/src/etc/test-float-parse/runtests.py index cf7279534dc8..cc5e31a051fc 100755 --- a/src/etc/test-float-parse/runtests.py +++ b/src/etc/test-float-parse/runtests.py @@ -127,7 +127,7 @@ def write_errors(): if not have_seen_error: have_seen_error = True msg("Something is broken:", *args) - msg("Future errors logged to errors.txt") + msg("Future errors will be logged to errors.txt") exit_status = 101 From da05ed36836077392384573d5277f8a01bbe17db Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Thu, 22 Jun 2023 10:37:51 -0400 Subject: [PATCH 024/103] Remove extra trailing newline --- src/doc/rustc/src/platform-support/netbsd.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/doc/rustc/src/platform-support/netbsd.md b/src/doc/rustc/src/platform-support/netbsd.md index 436a6d4226cf..a1969524a20e 100644 --- a/src/doc/rustc/src/platform-support/netbsd.md +++ b/src/doc/rustc/src/platform-support/netbsd.md @@ -105,4 +105,3 @@ fragment. The pkgsrc rust package has a few files to assist with building pkgsrc packages written in rust, ref. the `rust.mk` and `cargo.mk` Makefile fragments in the `lang/rust` package. - From a8fa961696fcbdef7a74fdd80033c464c156f453 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Thu, 22 Jun 2023 12:16:48 -0700 Subject: [PATCH 025/103] Align search results horizontally for easy scanning The recent PR #110688 added info about an item's kind before its name in search results. However, because the kind and name are inline with no alignment, it's now hard to visually scan downward through the search results, looking at item names. This PR fixes that by horizontally aligning search results such that there are now two columns of information. --- src/librustdoc/html/static/css/rustdoc.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 21c1eb631e07..83b989fc080d 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -891,8 +891,10 @@ so that we can apply CSS-filters to change the arrow color in themes */ color: var(--search-results-grey-color); } .search-results .result-name .typename { + display: inline-block; color: var(--search-results-grey-color); font-size: 0.875rem; + width: 6rem; } .popover { From 070ce235f2c1b72be10ac10cd5474b0ce80a1071 Mon Sep 17 00:00:00 2001 From: The 8472 Date: Mon, 22 May 2023 16:14:19 +0200 Subject: [PATCH 026/103] Specialize StepBy> For ranges < usize we determine the number of items StepBy would yield and then store that in the range.end instead of the actual end. This significantly simplifies calculation of the loop induction variable especially in cases where StepBy::step (an usize) could overflow the Range's item type --- library/core/benches/iter.rs | 52 +++ library/core/src/iter/adapters/step_by.rs | 361 +++++++++++++++++--- library/core/tests/iter/adapters/step_by.rs | 55 +++ 3 files changed, 430 insertions(+), 38 deletions(-) diff --git a/library/core/benches/iter.rs b/library/core/benches/iter.rs index 60ef83223d10..5ec22e5147b1 100644 --- a/library/core/benches/iter.rs +++ b/library/core/benches/iter.rs @@ -2,6 +2,7 @@ use core::borrow::Borrow; use core::iter::*; use core::mem; use core::num::Wrapping; +use core::ops::Range; use test::{black_box, Bencher}; #[bench] @@ -69,6 +70,57 @@ fn bench_max(b: &mut Bencher) { }) } +#[bench] +fn bench_range_step_by_sum_reducible(b: &mut Bencher) { + let r = 0u32..1024; + b.iter(|| { + let r = black_box(r.clone()).step_by(8); + + let mut sum: u32 = 0; + for i in r { + sum += i; + } + + sum + }) +} + +#[bench] +fn bench_range_step_by_loop_u32(b: &mut Bencher) { + let r = 0..(u16::MAX as u32); + b.iter(|| { + let r = black_box(r.clone()).step_by(64); + + let mut sum: u32 = 0; + for i in r { + let i = i ^ i.wrapping_sub(1); + sum = sum.wrapping_add(i); + } + + sum + }) +} + +#[bench] +fn bench_range_step_by_fold_usize(b: &mut Bencher) { + let r: Range = 0..(u16::MAX as usize); + b.iter(|| { + let r = black_box(r.clone()); + r.step_by(64) + .map(|x: usize| x ^ (x.wrapping_sub(1))) + .fold(0usize, |acc, i| acc.wrapping_add(i)) + }) +} + +#[bench] +fn bench_range_step_by_fold_u16(b: &mut Bencher) { + let r: Range = 0..u16::MAX; + b.iter(|| { + let r = black_box(r.clone()); + r.step_by(64).map(|x: u16| x ^ (x.wrapping_sub(1))).fold(0u16, |acc, i| acc.wrapping_add(i)) + }) +} + pub fn copy_zip(xs: &[u8], ys: &mut [u8]) { for (a, b) in ys.iter_mut().zip(xs) { *a = *b; diff --git a/library/core/src/iter/adapters/step_by.rs b/library/core/src/iter/adapters/step_by.rs index 4252c34a0e0f..2f7e66e8c608 100644 --- a/library/core/src/iter/adapters/step_by.rs +++ b/library/core/src/iter/adapters/step_by.rs @@ -1,4 +1,9 @@ -use crate::{intrinsics, iter::from_fn, ops::Try}; +use crate::convert::TryFrom; +use crate::{ + intrinsics, + iter::from_fn, + ops::{Range, Try}, +}; /// An iterator for stepping iterators by a custom amount. /// @@ -17,8 +22,10 @@ pub struct StepBy { } impl StepBy { + #[inline] pub(in crate::iter) fn new(iter: I, step: usize) -> StepBy { assert!(step != 0); + let iter = >::setup(iter, step); StepBy { iter, step: step - 1, first_take: true } } } @@ -32,16 +39,154 @@ where #[inline] fn next(&mut self) -> Option { - if self.first_take { - self.first_take = false; - self.iter.next() - } else { - self.iter.nth(self.step) - } + self.spec_next() } #[inline] fn size_hint(&self) -> (usize, Option) { + self.spec_size_hint() + } + + #[inline] + fn nth(&mut self, n: usize) -> Option { + self.spec_nth(n) + } + + fn try_fold(&mut self, acc: Acc, f: F) -> R + where + F: FnMut(Acc, Self::Item) -> R, + R: Try, + { + self.spec_try_fold(acc, f) + } + + #[inline] + fn fold(self, acc: Acc, f: F) -> Acc + where + F: FnMut(Acc, Self::Item) -> Acc, + { + self.spec_fold(acc, f) + } +} + +impl StepBy +where + I: ExactSizeIterator, +{ + // The zero-based index starting from the end of the iterator of the + // last element. Used in the `DoubleEndedIterator` implementation. + fn next_back_index(&self) -> usize { + let rem = self.iter.len() % (self.step + 1); + if self.first_take { + if rem == 0 { self.step } else { rem - 1 } + } else { + rem + } + } +} + +#[stable(feature = "double_ended_step_by_iterator", since = "1.38.0")] +impl DoubleEndedIterator for StepBy +where + I: DoubleEndedIterator + ExactSizeIterator, +{ + #[inline] + fn next_back(&mut self) -> Option { + self.spec_next_back() + } + + #[inline] + fn nth_back(&mut self, n: usize) -> Option { + self.spec_nth_back(n) + } + + fn try_rfold(&mut self, init: Acc, f: F) -> R + where + F: FnMut(Acc, Self::Item) -> R, + R: Try, + { + self.spec_try_rfold(init, f) + } + + #[inline] + fn rfold(self, init: Acc, f: F) -> Acc + where + Self: Sized, + F: FnMut(Acc, Self::Item) -> Acc, + { + self.spec_rfold(init, f) + } +} + +// StepBy can only make the iterator shorter, so the len will still fit. +#[stable(feature = "iterator_step_by", since = "1.28.0")] +impl ExactSizeIterator for StepBy where I: ExactSizeIterator {} + +trait SpecRangeSetup { + fn setup(inner: T, step: usize) -> T; +} + +impl SpecRangeSetup for T { + #[inline] + default fn setup(inner: T, _step: usize) -> T { + inner + } +} + +trait StepByImpl { + type Item; + + fn spec_next(&mut self) -> Option; + + fn spec_size_hint(&self) -> (usize, Option); + + fn spec_nth(&mut self, n: usize) -> Option; + + fn spec_try_fold(&mut self, acc: Acc, f: F) -> R + where + F: FnMut(Acc, Self::Item) -> R, + R: Try; + + fn spec_fold(self, acc: Acc, f: F) -> Acc + where + F: FnMut(Acc, Self::Item) -> Acc; +} + +trait StepByBackImpl { + type Item; + + fn spec_next_back(&mut self) -> Option + where + I: DoubleEndedIterator + ExactSizeIterator; + + fn spec_nth_back(&mut self, n: usize) -> Option + where + I: DoubleEndedIterator + ExactSizeIterator; + + fn spec_try_rfold(&mut self, init: Acc, f: F) -> R + where + I: DoubleEndedIterator + ExactSizeIterator, + F: FnMut(Acc, Self::Item) -> R, + R: Try; + + fn spec_rfold(self, init: Acc, f: F) -> Acc + where + I: DoubleEndedIterator + ExactSizeIterator, + F: FnMut(Acc, Self::Item) -> Acc; +} + +impl StepByImpl for StepBy { + type Item = I::Item; + + #[inline] + default fn spec_next(&mut self) -> Option { + let step_size = if self.first_take { 0 } else { self.step }; + self.first_take = false; + self.iter.nth(step_size) + } + + #[inline] + default fn spec_size_hint(&self) -> (usize, Option) { #[inline] fn first_size(step: usize) -> impl Fn(usize) -> usize { move |n| if n == 0 { 0 } else { 1 + (n - 1) / (step + 1) } @@ -64,7 +209,7 @@ where } #[inline] - fn nth(&mut self, mut n: usize) -> Option { + default fn spec_nth(&mut self, mut n: usize) -> Option { if self.first_take { self.first_take = false; let first = self.iter.next(); @@ -108,7 +253,7 @@ where } } - fn try_fold(&mut self, mut acc: Acc, mut f: F) -> R + default fn spec_try_fold(&mut self, mut acc: Acc, mut f: F) -> R where F: FnMut(Acc, Self::Item) -> R, R: Try, @@ -128,7 +273,7 @@ where from_fn(nth(&mut self.iter, self.step)).try_fold(acc, f) } - fn fold(mut self, mut acc: Acc, mut f: F) -> Acc + default fn spec_fold(mut self, mut acc: Acc, mut f: F) -> Acc where F: FnMut(Acc, Self::Item) -> Acc, { @@ -148,34 +293,16 @@ where } } -impl StepBy -where - I: ExactSizeIterator, -{ - // The zero-based index starting from the end of the iterator of the - // last element. Used in the `DoubleEndedIterator` implementation. - fn next_back_index(&self) -> usize { - let rem = self.iter.len() % (self.step + 1); - if self.first_take { - if rem == 0 { self.step } else { rem - 1 } - } else { - rem - } - } -} +impl StepByBackImpl for StepBy { + type Item = I::Item; -#[stable(feature = "double_ended_step_by_iterator", since = "1.38.0")] -impl DoubleEndedIterator for StepBy -where - I: DoubleEndedIterator + ExactSizeIterator, -{ #[inline] - fn next_back(&mut self) -> Option { + default fn spec_next_back(&mut self) -> Option { self.iter.nth_back(self.next_back_index()) } #[inline] - fn nth_back(&mut self, n: usize) -> Option { + default fn spec_nth_back(&mut self, n: usize) -> Option { // `self.iter.nth_back(usize::MAX)` does the right thing here when `n` // is out of bounds because the length of `self.iter` does not exceed // `usize::MAX` (because `I: ExactSizeIterator`) and `nth_back` is @@ -184,7 +311,7 @@ where self.iter.nth_back(n) } - fn try_rfold(&mut self, init: Acc, mut f: F) -> R + default fn spec_try_rfold(&mut self, init: Acc, mut f: F) -> R where F: FnMut(Acc, Self::Item) -> R, R: Try, @@ -207,10 +334,10 @@ where } #[inline] - fn rfold(mut self, init: Acc, mut f: F) -> Acc + default fn spec_rfold(mut self, init: Acc, mut f: F) -> Acc where Self: Sized, - F: FnMut(Acc, Self::Item) -> Acc, + F: FnMut(Acc, I::Item) -> Acc, { #[inline] fn nth_back( @@ -230,6 +357,164 @@ where } } -// StepBy can only make the iterator shorter, so the len will still fit. -#[stable(feature = "iterator_step_by", since = "1.28.0")] -impl ExactSizeIterator for StepBy where I: ExactSizeIterator {} +macro_rules! spec_int_ranges { + ($($t:ty)*) => ($( + + const _: () = assert!(usize::BITS >= <$t>::BITS); + + impl SpecRangeSetup> for Range<$t> { + #[inline] + fn setup(mut r: Range<$t>, step: usize) -> Range<$t> { + let inner_len = r.size_hint().0; + // If step exceeds $t::MAX, then the count will be at most 1 and + // thus always fit into $t. + let yield_count = inner_len.div_ceil(step); + // Turn the range end into an iteration counter + r.end = yield_count as $t; + r + } + } + + impl StepByImpl> for StepBy> { + #[inline] + fn spec_next(&mut self) -> Option<$t> { + // if a step size larger than the type has been specified fall back to + // t::MAX, in which case remaining will be at most 1. + // The `+ 1` can't overflow since the constructor substracted 1 from the original value. + let step = <$t>::try_from(self.step + 1).unwrap_or(<$t>::MAX); + let remaining = self.iter.end; + if remaining > 0 { + let val = self.iter.start; + // this can only overflow during the last step, after which the value + // will not be used + self.iter.start = val.wrapping_add(step); + self.iter.end = remaining - 1; + Some(val) + } else { + None + } + } + + fn spec_size_hint(&self) -> (usize, Option) { + let remaining = self.iter.end as usize; + (remaining, Some(remaining)) + } + + // The methods below are all copied from the Iterator trait default impls. + // We have to repeat them here so that the specialization overrides the StepByImpl defaults + + fn spec_nth(&mut self, n: usize) -> Option { + self.advance_by(n).ok()?; + self.next() + } + + fn spec_try_fold(&mut self, init: Acc, mut f: F) -> R + where + F: FnMut(Acc, Self::Item) -> R, + R: Try + { + let mut accum = init; + while let Some(x) = self.next() { + accum = f(accum, x)?; + } + try { accum } + } + + #[inline] + fn spec_fold(self, init: Acc, mut f: F) -> Acc + where + F: FnMut(Acc, Self::Item) -> Acc + { + // if a step size larger than the type has been specified fall back to + // t::MAX, in which case remaining will be at most 1. + let step = <$t>::try_from(self.step + 1).unwrap_or(<$t>::MAX); + let remaining = self.iter.end; + let mut acc = init; + let mut val = self.iter.start; + for _ in 0..remaining { + acc = f(acc, val); + // this can only overflow during the last step, after which the value + // will no longer be used + val = val.wrapping_add(step); + } + acc + } + } + )*) +} + +macro_rules! spec_int_ranges_r { + ($($t:ty)*) => ($( + const _: () = assert!(usize::BITS >= <$t>::BITS); + + impl StepByBackImpl> for StepBy> { + + fn spec_next_back(&mut self) -> Option + where Range<$t>: DoubleEndedIterator + ExactSizeIterator, + { + let step = (self.step + 1) as $t; + let remaining = self.iter.end; + if remaining > 0 { + let start = self.iter.start; + self.iter.end = remaining - 1; + Some(start + step * (remaining - 1)) + } else { + None + } + } + + // The methods below are all copied from the Iterator trait default impls. + // We have to repeat them here so that the specialization overrides the StepByImplBack defaults + + fn spec_nth_back(&mut self, n: usize) -> Option + where Self: DoubleEndedIterator, + { + if self.advance_back_by(n).is_err() { + return None; + } + self.next_back() + } + + fn spec_try_rfold(&mut self, init: Acc, mut f: F) -> R + where + Self: DoubleEndedIterator, + F: FnMut(Acc, Self::Item) -> R, + R: Try + { + let mut accum = init; + while let Some(x) = self.next_back() { + accum = f(accum, x)?; + } + try { accum } + } + + fn spec_rfold(mut self, init: Acc, mut f: F) -> Acc + where + Self: DoubleEndedIterator, + F: FnMut(Acc, Self::Item) -> Acc + { + let mut accum = init; + while let Some(x) = self.next_back() { + accum = f(accum, x); + } + accum + } + } + )*) +} + +#[cfg(target_pointer_width = "64")] +spec_int_ranges!(u8 u16 u32 u64 usize); +// DoubleEndedIterator requires ExactSizeIterator, which isn't implemented for Range +#[cfg(target_pointer_width = "64")] +spec_int_ranges_r!(u8 u16 u32 usize); + +#[cfg(target_pointer_width = "32")] +spec_int_ranges!(u8 u16 u32 usize); +#[cfg(target_pointer_width = "32")] +spec_int_ranges_r!(u8 u16 u32 usize); + +#[cfg(target_pointer_width = "16")] +spec_int_ranges!(u8 u16 usize); +#[cfg(target_pointer_width = "16")] +spec_int_ranges_r!(u8 u16 usize); diff --git a/library/core/tests/iter/adapters/step_by.rs b/library/core/tests/iter/adapters/step_by.rs index 94f2fa8c25e2..4c5b1dd9a6bd 100644 --- a/library/core/tests/iter/adapters/step_by.rs +++ b/library/core/tests/iter/adapters/step_by.rs @@ -244,3 +244,58 @@ fn test_step_by_skip() { assert_eq!((0..=50).step_by(10).nth(3), Some(30)); assert_eq!((200..=255u8).step_by(10).nth(3), Some(230)); } + + +struct DeOpt(I); + +impl Iterator for DeOpt { + type Item = I::Item; + + fn next(&mut self) -> core::option::Option { + self.0.next() + } +} + +impl DoubleEndedIterator for DeOpt { + fn next_back(&mut self) -> core::option::Option { + self.0.next_back() + } +} + +#[test] +fn test_step_by_fold_range_specialization() { + macro_rules! t { + ($range:expr, $var: ident, $body:tt) => { + { + // run the same tests for the non-optimized version + let mut $var = DeOpt($range); + $body + } + { + let mut $var = $range; + $body + } + } + } + + t!((1usize..5).step_by(1), r, { + assert_eq!(r.next_back(), Some(4)); + assert_eq!(r.sum::(), 6); + }); + + t!((0usize..4).step_by(2), r, { + assert_eq!(r.next(), Some(0)); + assert_eq!(r.sum::(), 2); + }); + + + t!((0usize..5).step_by(2), r, { + assert_eq!(r.next(), Some(0)); + assert_eq!(r.sum::(), 6); + }); + + t!((usize::MAX - 6 .. usize::MAX).step_by(5), r, { + assert_eq!(r.next(), Some(usize::MAX - 6)); + assert_eq!(r.sum::(), usize::MAX - 1); + }); +} From 1bc095cd80124d71425bceb6542685f8d95afc1e Mon Sep 17 00:00:00 2001 From: The 8472 Date: Thu, 22 Jun 2023 22:57:46 +0200 Subject: [PATCH 027/103] add inline annotation to concrete impls otherwise they wouldn't be eligible for cross-crate inlining --- library/core/src/iter/adapters/step_by.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/core/src/iter/adapters/step_by.rs b/library/core/src/iter/adapters/step_by.rs index 2f7e66e8c608..ce7bd3b5cb14 100644 --- a/library/core/src/iter/adapters/step_by.rs +++ b/library/core/src/iter/adapters/step_by.rs @@ -395,6 +395,7 @@ macro_rules! spec_int_ranges { } } + #[inline] fn spec_size_hint(&self) -> (usize, Option) { let remaining = self.iter.end as usize; (remaining, Some(remaining)) @@ -403,11 +404,13 @@ macro_rules! spec_int_ranges { // The methods below are all copied from the Iterator trait default impls. // We have to repeat them here so that the specialization overrides the StepByImpl defaults + #[inline] fn spec_nth(&mut self, n: usize) -> Option { self.advance_by(n).ok()?; self.next() } + #[inline] fn spec_try_fold(&mut self, init: Acc, mut f: F) -> R where F: FnMut(Acc, Self::Item) -> R, @@ -449,6 +452,7 @@ macro_rules! spec_int_ranges_r { impl StepByBackImpl> for StepBy> { + #[inline] fn spec_next_back(&mut self) -> Option where Range<$t>: DoubleEndedIterator + ExactSizeIterator, { @@ -466,6 +470,7 @@ macro_rules! spec_int_ranges_r { // The methods below are all copied from the Iterator trait default impls. // We have to repeat them here so that the specialization overrides the StepByImplBack defaults + #[inline] fn spec_nth_back(&mut self, n: usize) -> Option where Self: DoubleEndedIterator, { @@ -475,6 +480,7 @@ macro_rules! spec_int_ranges_r { self.next_back() } + #[inline] fn spec_try_rfold(&mut self, init: Acc, mut f: F) -> R where Self: DoubleEndedIterator, @@ -488,6 +494,7 @@ macro_rules! spec_int_ranges_r { try { accum } } + #[inline] fn spec_rfold(mut self, init: Acc, mut f: F) -> Acc where Self: DoubleEndedIterator, From 6f61f6ba11a1917f3bf7b1bd8054c12bd4e7b6ec Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Fri, 23 Jun 2023 04:47:30 +0200 Subject: [PATCH 028/103] DirEntry::file_name: improve explanation --- library/std/src/fs.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 89dfdfafdb17..c2d82169dc30 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -1755,8 +1755,14 @@ impl DirEntry { self.0.file_type().map(FileType) } - /// Returns the bare file name of this directory entry without any other - /// leading path component. + /// Returns the file name of this directory entry without any + /// leading path component(s). + /// + /// As an example, + /// the output of the function will result in "foo" for all the following paths: + /// - "./foo" + /// - "/the/foo" + /// - "../../foo" /// /// # Examples /// From e7e584b7d9d4eba8b9655b255840ef9caf9b40c0 Mon Sep 17 00:00:00 2001 From: Zephaniah Ong Date: Thu, 22 Jun 2023 16:47:33 +0800 Subject: [PATCH 029/103] display pid of process holding lock --- src/bootstrap/bin/main.rs | 57 +++++++++++++++------------------------ 1 file changed, 21 insertions(+), 36 deletions(-) diff --git a/src/bootstrap/bin/main.rs b/src/bootstrap/bin/main.rs index a80379e85c19..7ce4599c4241 100644 --- a/src/bootstrap/bin/main.rs +++ b/src/bootstrap/bin/main.rs @@ -5,7 +5,9 @@ //! parent directory, and otherwise documentation can be found throughout the `build` //! directory in each respective module. -use std::env; +use std::fs::OpenOptions; +use std::io::Write; +use std::{env, fs, process}; #[cfg(all(any(unix, windows), not(target_os = "solaris")))] use bootstrap::t; @@ -20,22 +22,32 @@ fn main() { #[cfg(all(any(unix, windows), not(target_os = "solaris")))] let _build_lock_guard; #[cfg(all(any(unix, windows), not(target_os = "solaris")))] + // Display PID of process holding the lock + // PID will be stored in a lock file { let path = config.out.join("lock"); - build_lock = fd_lock::RwLock::new(t!(std::fs::File::create(&path))); + let pid = match fs::read_to_string(&path) { + Ok(contents) => contents, + Err(_) => String::new(), + }; + + build_lock = + fd_lock::RwLock::new(t!(OpenOptions::new().write(true).create(true).open(&path))); _build_lock_guard = match build_lock.try_write() { - Ok(lock) => lock, + Ok(mut lock) => { + t!(lock.write(&process::id().to_string().as_ref())); + lock + } err => { drop(err); - if let Some(pid) = get_lock_owner(&path) { - println!("warning: build directory locked by process {pid}, waiting for lock"); - } else { - println!("warning: build directory locked, waiting for lock"); - } - t!(build_lock.write()) + println!("warning: build directory locked by process {pid}, waiting for lock"); + let mut lock = t!(build_lock.write()); + t!(lock.write(&process::id().to_string().as_ref())); + lock } }; } + #[cfg(any(not(any(unix, windows)), target_os = "solaris"))] println!("warning: file locking not supported for target, not locking build directory"); @@ -108,30 +120,3 @@ fn check_version(config: &Config) -> Option { Some(msg) } - -/// Get the PID of the process which took the write lock by -/// parsing `/proc/locks`. -#[cfg(target_os = "linux")] -fn get_lock_owner(f: &std::path::Path) -> Option { - use std::fs::File; - use std::io::{BufRead, BufReader}; - use std::os::unix::fs::MetadataExt; - - let lock_inode = std::fs::metadata(f).ok()?.ino(); - let lockfile = File::open("/proc/locks").ok()?; - BufReader::new(lockfile).lines().find_map(|line| { - // pid--vvvvvv vvvvvvv--- inode - // 21: FLOCK ADVISORY WRITE 359238 08:02:3719774 0 EOF - let line = line.ok()?; - let parts = line.split_whitespace().collect::>(); - let (pid, inode) = (parts[4].parse::().ok()?, &parts[5]); - let inode = inode.rsplit_once(':')?.1.parse::().ok()?; - if inode == lock_inode { Some(pid) } else { None } - }) -} - -#[cfg(not(any(target_os = "linux", target_os = "solaris")))] -fn get_lock_owner(_: &std::path::Path) -> Option { - // FIXME: Implement on other OS's - None -} From 3c2b8b06fc931b84d0c9addc91529491ddbc8246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 23 Jun 2023 11:22:23 +0200 Subject: [PATCH 030/103] Cancel in-progress workflow runs after a push --- .github/workflows/ci.yml | 3 +++ src/ci/github-actions/ci.yml | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f54d2838cf2..fa01f37b1b85 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,9 @@ permissions: defaults: run: shell: bash +concurrency: + group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}" + cancel-in-progress: true jobs: pr: permissions: diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml index a9e42e4a0a0d..87a10a5e87b2 100644 --- a/src/ci/github-actions/ci.yml +++ b/src/ci/github-actions/ci.yml @@ -305,6 +305,10 @@ defaults: # shell is PowerShell.) shell: bash +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: pr: permissions: From 4a9f292e5005fcb0174fe83a329f19d47da21f2d Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Fri, 23 Jun 2023 11:15:34 +0100 Subject: [PATCH 031/103] Expose `compiler-builtins-weak-intrinsics` feature for `-Zbuild-std` This was added in rust-lang/compiler-builtins#526 to force all compiler-builtins intrinsics to use weak linkage. --- library/alloc/Cargo.toml | 1 + library/std/Cargo.toml | 1 + library/sysroot/Cargo.toml | 1 + 3 files changed, 3 insertions(+) diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml index 95c07abf7310..e5f828c4c0b3 100644 --- a/library/alloc/Cargo.toml +++ b/library/alloc/Cargo.toml @@ -35,3 +35,4 @@ compiler-builtins-mem = ['compiler_builtins/mem'] compiler-builtins-c = ["compiler_builtins/c"] compiler-builtins-no-asm = ["compiler_builtins/no-asm"] compiler-builtins-mangled-names = ["compiler_builtins/mangled-names"] +compiler-builtins-weak-intrinsics = ["compiler_builtins/weak-intrinsics"] diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index af74efa6bf84..c3447b4cc783 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -65,6 +65,7 @@ compiler-builtins-c = ["alloc/compiler-builtins-c"] compiler-builtins-mem = ["alloc/compiler-builtins-mem"] compiler-builtins-no-asm = ["alloc/compiler-builtins-no-asm"] compiler-builtins-mangled-names = ["alloc/compiler-builtins-mangled-names"] +compiler-builtins-weak-intrinsics = ["alloc/compiler-builtins-weak-intrinsics"] llvm-libunwind = ["unwind/llvm-libunwind"] system-llvm-libunwind = ["unwind/system-llvm-libunwind"] diff --git a/library/sysroot/Cargo.toml b/library/sysroot/Cargo.toml index 5356ee277cc2..6ff24a8db59c 100644 --- a/library/sysroot/Cargo.toml +++ b/library/sysroot/Cargo.toml @@ -17,6 +17,7 @@ compiler-builtins-c = ["std/compiler-builtins-c"] compiler-builtins-mem = ["std/compiler-builtins-mem"] compiler-builtins-no-asm = ["std/compiler-builtins-no-asm"] compiler-builtins-mangled-names = ["std/compiler-builtins-mangled-names"] +compiler-builtins-weak-intrinsics = ["std/compiler-builtins-weak-intrinsics"] llvm-libunwind = ["std/llvm-libunwind"] system-llvm-libunwind = ["std/system-llvm-libunwind"] panic-unwind = ["std/panic_unwind"] From 8969d974377b17861970d161a46a0fc80e3d34ad Mon Sep 17 00:00:00 2001 From: clubby789 Date: Fri, 23 Jun 2023 14:20:45 +0000 Subject: [PATCH 032/103] Add test for invalid variables --- .../session-diagnostic/example.ftl | 2 ++ .../session-diagnostic/invalid-variable.rs | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/ui-fulldeps/session-diagnostic/invalid-variable.rs diff --git a/tests/ui-fulldeps/session-diagnostic/example.ftl b/tests/ui-fulldeps/session-diagnostic/example.ftl index cb2d476d815d..1d1ba8e1bd5c 100644 --- a/tests/ui-fulldeps/session-diagnostic/example.ftl +++ b/tests/ui-fulldeps/session-diagnostic/example.ftl @@ -3,3 +3,5 @@ no_crate_example = this is an example message used in testing .help = with a help .suggestion = with a suggestion .label = with a label + +no_crate_bad_reference = {$r} does not exist diff --git a/tests/ui-fulldeps/session-diagnostic/invalid-variable.rs b/tests/ui-fulldeps/session-diagnostic/invalid-variable.rs new file mode 100644 index 000000000000..57798dda3eb2 --- /dev/null +++ b/tests/ui-fulldeps/session-diagnostic/invalid-variable.rs @@ -0,0 +1,21 @@ +// run-fail +// compile-flags: --test +// test that messages referencing non-existent fields cause test failures + +#![feature(rustc_private)] +#![crate_type = "lib"] + +extern crate rustc_driver; +extern crate rustc_fluent_macro; +extern crate rustc_macros; +extern crate rustc_errors; +use rustc_fluent_macro::fluent_messages; +use rustc_macros::Diagnostic; +use rustc_errors::{SubdiagnosticMessage, DiagnosticMessage}; +extern crate rustc_session; + +fluent_messages! { "./example.ftl" } + +#[derive(Diagnostic)] +#[diag(no_crate_bad_reference)] +struct BadRef; From 471cd785ccf19e1043875946a040afea783913dd Mon Sep 17 00:00:00 2001 From: Christopher Serr Date: Fri, 23 Jun 2023 18:19:40 +0200 Subject: [PATCH 033/103] Update wasi-libc This updates wasi-libc to the latest master. Resolves #112749 --- .../docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh b/src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh index 5fbce36c39d2..b867db6a1b5c 100755 --- a/src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh +++ b/src/ci/docker/host-x86_64/dist-various-2/build-wasi-toolchain.sh @@ -10,7 +10,7 @@ bin="$PWD/clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04/bin" git clone https://github.com/WebAssembly/wasi-libc cd wasi-libc -git reset --hard 4362b1885fd369e042a7c0ecd8df3b6cd47fb4e8 +git reset --hard 7018e24d8fe248596819d2e884761676f3542a04 make -j$(nproc) \ CC="$bin/clang" \ NM="$bin/llvm-nm" \ From c462291e0c864b7d0e218bde12c9560f99cede3b Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Fri, 23 Jun 2023 17:48:54 +0100 Subject: [PATCH 034/103] Make `UnwindAction::Continue` explicit in MIR dump --- compiler/rustc_middle/src/mir/terminator.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_middle/src/mir/terminator.rs b/compiler/rustc_middle/src/mir/terminator.rs index 561ef371b090..1b9c1438f406 100644 --- a/compiler/rustc_middle/src/mir/terminator.rs +++ b/compiler/rustc_middle/src/mir/terminator.rs @@ -272,7 +272,8 @@ impl<'tcx> Debug for TerminatorKind<'tcx> { let unwind = match self.unwind() { // Not needed or included in successors - None | Some(UnwindAction::Continue) | Some(UnwindAction::Cleanup(_)) => None, + None | Some(UnwindAction::Cleanup(_)) => None, + Some(UnwindAction::Continue) => Some("unwind continue"), Some(UnwindAction::Unreachable) => Some("unwind unreachable"), Some(UnwindAction::Terminate) => Some("unwind terminate"), }; From c4fca7202b83053f12e1f47ec0a44c01de2ec2aa Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Fri, 23 Jun 2023 09:51:53 -0700 Subject: [PATCH 035/103] Abbreviate long typenames so they don't get wrapped in results --- src/librustdoc/html/static/js/search.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 452348dc8650..b8cc0a6db714 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -52,9 +52,9 @@ const longItemTypes = [ "enum variant", "macro", "primitive type", - "associated type", + "assoc type", "constant", - "associated constant", + "assoc const", "union", "foreign type", "keyword", From 5a0c8e3a08245166c4f922787647641411a9c445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Fri, 23 Jun 2023 18:47:13 +0200 Subject: [PATCH 036/103] issue template: add clippy entry which points to the clippy repo --- .github/ISSUE_TEMPLATE/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 7d4cfaece448..a2878a0e0120 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -6,3 +6,6 @@ contact_links: - name: Feature Request url: https://internals.rust-lang.org/ about: Please discuss language feature requests on the internals forum. + - name: Clippy Bug + url: https://github.com/rust-lang/rust-clippy/issues/new/choose + about: Please report Clippy bugs such as false positives in the Clippy repo. From 12de5b7ff33fe37eb8ce5dd92efd1366e43e85aa Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Fri, 23 Jun 2023 10:12:27 -0700 Subject: [PATCH 037/103] Make typenames a bit wider to support "existential type" --- src/librustdoc/html/static/css/rustdoc.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 83b989fc080d..b4ee3482de39 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -894,7 +894,7 @@ so that we can apply CSS-filters to change the arrow color in themes */ display: inline-block; color: var(--search-results-grey-color); font-size: 0.875rem; - width: 6rem; + width: 7rem; } .popover { From 19ce326a08634a4014fb82d8475e4501f1ef5d28 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Fri, 23 Jun 2023 17:53:09 +0100 Subject: [PATCH 038/103] Bless tests --- ...Cfg-elaborate-drops.after.panic-unwind.mir | 4 +-- .../basic_assignment.main.ElaborateDrops.diff | 2 +- ...ain.ElaborateDrops.before.panic-unwind.mir | 6 ++-- ...await.a-{closure#0}.generator_resume.0.mir | 2 +- ...await.b-{closure#0}.generator_resume.0.mir | 2 +- .../terminators.direct_call.built.after.mir | 2 +- .../terminators.drop_first.built.after.mir | 2 +- .../terminators.drop_second.built.after.mir | 2 +- .../terminators.indirect_call.built.after.mir | 2 +- ...y_len.norm2.InstSimplify.panic-unwind.diff | 4 +-- ...pl#0}-clone.InstSimplify.panic-unwind.diff | 2 +- ...aggregate.main.ConstProp.panic-unwind.diff | 2 +- ...ate.main.PreCodegen.after.panic-unwind.mir | 2 +- ...dex.main.ConstProp.32bit.panic-unwind.diff | 4 +-- ...dex.main.ConstProp.64bit.panic-unwind.diff | 4 +-- ...v_by_zero.main.ConstProp.panic-unwind.diff | 8 +++--- ...d_by_zero.main.ConstProp.panic-unwind.diff | 8 +++--- ...ces.main.ConstProp.32bit.panic-unwind.diff | 4 +-- ...ces.main.ConstProp.64bit.panic-unwind.diff | 4 +-- .../boxes.main.ConstProp.panic-unwind.diff | 2 +- ...ecked_add.main.ConstProp.panic-unwind.diff | 4 +-- ...racefully.main.ConstProp.panic-unwind.diff | 2 +- ...fication.hello.ConstProp.panic-unwind.diff | 2 +- .../indirect.main.ConstProp.panic-unwind.diff | 4 +-- ..._overflow.main.ConstProp.panic-unwind.diff | 4 +-- ...sue_66971.main.ConstProp.panic-unwind.diff | 2 +- ...sue_67019.main.ConstProp.panic-unwind.diff | 2 +- ...dex.main.ConstProp.32bit.panic-unwind.diff | 4 +-- ...dex.main.ConstProp.64bit.panic-unwind.diff | 4 +-- ...tial_read.main.ConstProp.panic-unwind.diff | 2 +- ...op_assign.main.ConstProp.panic-unwind.diff | 2 +- ...et_of.concrete.ConstProp.panic-unwind.diff | 8 +++--- ...set_of.generic.ConstProp.panic-unwind.diff | 8 +++--- ...eat.main.ConstProp.32bit.panic-unwind.diff | 4 +-- ...eat.main.ConstProp.64bit.panic-unwind.diff | 4 +-- ...turn_place.add.ConstProp.panic-unwind.diff | 4 +-- ...ace.add.PreCodegen.before.panic-unwind.mir | 2 +- ...opagation.main.ConstProp.panic-unwind.diff | 2 +- ...len.main.ConstProp.32bit.panic-unwind.diff | 4 +-- ...len.main.ConstProp.64bit.panic-unwind.diff | 4 +-- ...witch_int.main.ConstProp.panic-unwind.diff | 4 +-- ...ndition-after-const-prop.panic-unwind.diff | 4 +-- ...opagation.main.ConstProp.panic-unwind.diff | 2 +- ...orrowed_local.f.CopyProp.panic-unwind.diff | 4 +-- .../branch.foo.CopyProp.panic-unwind.diff | 6 ++-- ...agation_arg.bar.CopyProp.panic-unwind.diff | 2 +- ...agation_arg.foo.CopyProp.panic-unwind.diff | 2 +- ...stom_move_arg.f.CopyProp.panic-unwind.diff | 8 +++--- .../cycle.main.CopyProp.panic-unwind.diff | 4 +-- ...es_79191.f.CopyProp.after.panic-unwind.mir | 2 +- ...s_better.f.CopyProp.after.panic-unwind.mir | 2 +- ...sue_107511.main.CopyProp.panic-unwind.diff | 10 +++---- .../move_arg.f.CopyProp.panic-unwind.diff | 4 +-- ...ve_projection.f.CopyProp.panic-unwind.diff | 6 ++-- ...eborrow.demiraw.CopyProp.panic-unwind.diff | 4 +-- .../reborrow.miraw.CopyProp.panic-unwind.diff | 4 +-- .../reborrow.remut.CopyProp.panic-unwind.diff | 4 +-- .../reborrow.reraw.CopyProp.panic-unwind.diff | 4 +-- ...d.main.DataflowConstProp.panic-unwind.diff | 8 +++--- ...w.main.DataflowConstProp.panic-unwind.diff | 4 +-- ...b.main.DataflowConstProp.panic-unwind.diff | 4 +-- ...r.main.DataflowConstProp.panic-unwind.diff | 2 +- ...r.main.DataflowConstProp.panic-unwind.diff | 4 +-- ...cle.DeadStoreElimination.panic-unwind.diff | 4 +-- ...ment_2.DeduplicateBlocks.panic-unwind.diff | 2 +- ...omplex_case.main.Derefer.panic-unwind.diff | 6 ++-- ...inline_test.main.Derefer.panic-unwind.diff | 4 +-- ...inator_test.main.Derefer.panic-unwind.diff | 4 +-- ...o.DestinationPropagation.panic-unwind.diff | 8 +++--- ...r.DestinationPropagation.panic-unwind.diff | 4 +-- ...o.DestinationPropagation.panic-unwind.diff | 4 +-- ...n.DestinationPropagation.panic-unwind.diff | 6 ++-- ...tinationPropagation.after.panic-unwind.mir | 2 +- ...tinationPropagation.after.panic-unwind.mir | 2 +- ...o.DestinationPropagation.panic-unwind.diff | 4 +-- ...n.DestinationPropagation.panic-unwind.diff | 2 +- ...f.DestinationPropagation.panic-unwind.diff | 6 ++-- ...-Fn-call.AddMovesForPackedDrops.before.mir | 2 +- ...nential_common.ConstProp.panic-unwind.diff | 8 +++--- .../asm_unwind.main.Inline.panic-unwind.diff | 4 +-- ...trivial_bound.foo.Inline.panic-unwind.diff | 2 +- .../inline/cycle.g.Inline.panic-unwind.diff | 4 +-- .../cycle.main.Inline.panic-unwind.diff | 4 +-- ...n_trait.get_query.Inline.panic-unwind.diff | 6 ++-- ...yn_trait.mk_cycle.Inline.panic-unwind.diff | 2 +- ...try_execute_query.Inline.panic-unwind.diff | 4 +-- ...tial_runtime.main.Inline.panic-unwind.diff | 28 +++++++++---------- ...lined_no_sanitize.Inline.panic-unwind.diff | 2 +- ...ed_target_feature.Inline.panic-unwind.diff | 2 +- ...nlined_c_variadic.Inline.panic-unwind.diff | 2 +- ...lined_no_sanitize.Inline.panic-unwind.diff | 2 +- ...ed_target_feature.Inline.panic-unwind.diff | 2 +- .../inline_cycle.one.Inline.panic-unwind.diff | 2 +- .../inline_cycle.two.Inline.panic-unwind.diff | 4 +-- ...ycle_generic.main.Inline.panic-unwind.diff | 4 +-- ...nline_diverging.f.Inline.panic-unwind.diff | 2 +- ...nline_diverging.g.Inline.panic-unwind.diff | 4 +-- ...nline_diverging.h.Inline.panic-unwind.diff | 2 +- ...ne_generator.main.Inline.panic-unwind.diff | 2 +- ...to_box_place.main.Inline.panic-unwind.diff | 2 +- ...options.main.Inline.after.panic-unwind.mir | 8 +++--- ...nline_shims.clone.Inline.panic-unwind.diff | 2 +- ...inline_shims.drop.Inline.panic-unwind.diff | 6 ++-- ...ecialization.main.Inline.panic-unwind.diff | 2 +- ..._method.test.Inline.after.panic-unwind.mir | 2 +- ...thod_2.test2.Inline.after.panic-unwind.mir | 2 +- ...ssue_106141.outer.Inline.panic-unwind.diff | 6 ++-- ...l_unsigned_bigger.Inline.panic-unwind.diff | 2 +- ..._unsigned_smaller.Inline.panic-unwind.diff | 2 +- ...shr_signed_bigger.Inline.panic-unwind.diff | 2 +- ...hr_signed_smaller.Inline.panic-unwind.diff | 2 +- ...e_101973.inner.ConstProp.panic-unwind.diff | 8 +++--- ...AbortUnwindingCalls.after.panic-unwind.mir | 2 +- ...1110.test.ElaborateDrops.panic-unwind.diff | 2 +- ...1888.main.ElaborateDrops.panic-unwind.diff | 2 +- ...est.ElaborateDrops.before.panic-unwind.mir | 6 ++-- ...mplifyComparisonIntegral.panic-unwind.diff | 2 +- ...to_digit.PreCodegen.after.panic-unwind.mir | 6 ++-- ..._bound.NormalizeArrayLen.panic-unwind.diff | 2 +- ...nd_mut.NormalizeArrayLen.panic-unwind.diff | 4 +-- ...bound.LowerSliceLenCalls.panic-unwind.diff | 4 +-- ...ain.ElaborateDrops.before.panic-unwind.mir | 2 +- ...e.nrvo.RenameReturnPlace.panic-unwind.diff | 2 +- ...cked_ops.step_forward.PreCodegen.after.mir | 4 +-- .../loops.filter_mapped.PreCodegen.after.mir | 4 +-- .../loops.int_range.PreCodegen.after.mir | 4 +-- .../loops.mapped.PreCodegen.after.mir | 4 +-- .../loops.vec_move.PreCodegen.after.mir | 4 +-- ...ble.main.ConstProp.32bit.panic-unwind.diff | 8 +++--- ...ble.main.ConstProp.64bit.panic-unwind.diff | 8 +++--- ...cementOfAggregates.32bit.panic-unwind.diff | 4 +-- ...cementOfAggregates.64bit.panic-unwind.diff | 4 +-- ...ard_loop.PreCodegen.after.panic-unwind.mir | 2 +- ...ive_loop.PreCodegen.after.panic-unwind.mir | 2 +- ...ter_next.PreCodegen.after.panic-unwind.mir | 2 +- ...ter_next.PreCodegen.after.panic-unwind.mir | 2 +- ...ex_range.PreCodegen.after.panic-unwind.mir | 2 +- ...ex_usize.PreCodegen.after.panic-unwind.mir | 2 +- ...ted_loop.PreCodegen.after.panic-unwind.mir | 2 +- ...ard_loop.PreCodegen.after.panic-unwind.mir | 2 +- ...nge_loop.PreCodegen.after.panic-unwind.mir | 2 +- ...rse_loop.PreCodegen.after.panic-unwind.mir | 2 +- ...ext_back.PreCodegen.after.panic-unwind.mir | 2 +- ...ter_next.PreCodegen.after.panic-unwind.mir | 2 +- ...ns.outer.PreCodegen.after.panic-unwind.mir | 2 +- ...e_prop.debuginfo.ReferencePropagation.diff | 2 +- ...dominate_storage.ReferencePropagation.diff | 2 +- ..._prop.maybe_dead.ReferencePropagation.diff | 6 ++-- ...multiple_storage.ReferencePropagation.diff | 2 +- ...ence_propagation.ReferencePropagation.diff | 20 ++++++------- ...gation_const_ptr.ReferencePropagation.diff | 22 +++++++-------- ..._propagation_mut.ReferencePropagation.diff | 20 ++++++------- ...pagation_mut_ptr.ReferencePropagation.diff | 20 ++++++------- ...ique_with_copies.ReferencePropagation.diff | 4 +-- ...ain.RemoveStorageMarkers.panic-unwind.diff | 4 +-- ....opt.RemoveUnneededDrops.panic-unwind.diff | 2 +- ...copy.RemoveUnneededDrops.panic-unwind.diff | 2 +- ...Cfg-elaborate-drops.after.panic-unwind.mir | 6 ++-- ...mplifyCfg-make_shim.after.panic-unwind.mir | 2 +- ...Cfg-elaborate-drops.after.panic-unwind.mir | 4 +-- ...ndition-after-const-prop.panic-unwind.diff | 2 +- ...foo.SimplifyLocals-final.panic-unwind.diff | 2 +- ...Locals-before-const-prop.panic-unwind.diff | 8 +++--- ...ify_match.main.ConstProp.panic-unwind.diff | 2 +- ...n.UnreachablePropagation.panic-unwind.diff | 2 +- ...n.UnreachablePropagation.panic-unwind.diff | 4 +-- ...ile_loop.PreCodegen.after.panic-unwind.mir | 4 +-- tests/run-make/const_fn_mir/dump.mir | 6 ++-- 168 files changed, 344 insertions(+), 344 deletions(-) diff --git a/tests/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir b/tests/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir index 2f6c92d9e859..4b05610f7310 100644 --- a/tests/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir +++ b/tests/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir @@ -36,7 +36,7 @@ fn main() -> () { StorageLive(_5); StorageLive(_6); _6 = _3; - _5 = foo(move _6) -> bb1; + _5 = foo(move _6) -> [return: bb1, unwind continue]; } bb1: { @@ -45,7 +45,7 @@ fn main() -> () { _7 = _2; _8 = Len(_1); _9 = Lt(_7, _8); - assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> bb2; + assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> [success: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/basic_assignment.main.ElaborateDrops.diff b/tests/mir-opt/basic_assignment.main.ElaborateDrops.diff index 41732211628e..9c7b3c5197b6 100644 --- a/tests/mir-opt/basic_assignment.main.ElaborateDrops.diff +++ b/tests/mir-opt/basic_assignment.main.ElaborateDrops.diff @@ -58,7 +58,7 @@ bb4: { StorageDead(_5); -- drop(_4) -> bb5; +- drop(_4) -> [return: bb5, unwind continue]; + goto -> bb5; } diff --git a/tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-unwind.mir b/tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-unwind.mir index cf63c4f19dac..a72d22a9c9ff 100644 --- a/tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-unwind.mir +++ b/tests/mir-opt/box_expr.main.ElaborateDrops.before.panic-unwind.mir @@ -19,7 +19,7 @@ fn main() -> () { StorageLive(_1); _2 = SizeOf(S); _3 = AlignOf(S); - _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; + _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> [return: bb1, unwind continue]; } bb1: { @@ -30,7 +30,7 @@ fn main() -> () { bb2: { _1 = move _5; - drop(_5) -> bb3; + drop(_5) -> [return: bb3, unwind continue]; } bb3: { @@ -45,7 +45,7 @@ fn main() -> () { StorageDead(_7); StorageDead(_6); _0 = const (); - drop(_1) -> bb5; + drop(_1) -> [return: bb5, unwind continue]; } bb5: { diff --git a/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir index 7e8206b02fcb..074ebddf78bb 100644 --- a/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir @@ -30,7 +30,7 @@ fn a::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:11:14: 11:16]> } bb2: { - assert(const false, "`async fn` resumed after completion") -> bb2; + assert(const false, "`async fn` resumed after completion") -> [success: bb2, unwind continue]; } bb3: { diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir index ed1388718519..f774f32eb23e 100644 --- a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir @@ -310,7 +310,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, } bb28: { - assert(const false, "`async fn` resumed after completion") -> bb28; + assert(const false, "`async fn` resumed after completion") -> [success: bb28, unwind continue]; } bb29: { diff --git a/tests/mir-opt/building/custom/terminators.direct_call.built.after.mir b/tests/mir-opt/building/custom/terminators.direct_call.built.after.mir index 534d7615180a..07044ceaef44 100644 --- a/tests/mir-opt/building/custom/terminators.direct_call.built.after.mir +++ b/tests/mir-opt/building/custom/terminators.direct_call.built.after.mir @@ -4,7 +4,7 @@ fn direct_call(_1: i32) -> i32 { let mut _0: i32; bb0: { - _0 = ident::(_1) -> bb1; + _0 = ident::(_1) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/building/custom/terminators.drop_first.built.after.mir b/tests/mir-opt/building/custom/terminators.drop_first.built.after.mir index aba724a4b0d3..6524f754d9c4 100644 --- a/tests/mir-opt/building/custom/terminators.drop_first.built.after.mir +++ b/tests/mir-opt/building/custom/terminators.drop_first.built.after.mir @@ -4,7 +4,7 @@ fn drop_first(_1: WriteOnDrop<'_>, _2: WriteOnDrop<'_>) -> () { let mut _0: (); bb0: { - drop(_1) -> bb1; + drop(_1) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/building/custom/terminators.drop_second.built.after.mir b/tests/mir-opt/building/custom/terminators.drop_second.built.after.mir index 32d770bb0c13..ed3728121bd6 100644 --- a/tests/mir-opt/building/custom/terminators.drop_second.built.after.mir +++ b/tests/mir-opt/building/custom/terminators.drop_second.built.after.mir @@ -4,7 +4,7 @@ fn drop_second(_1: WriteOnDrop<'_>, _2: WriteOnDrop<'_>) -> () { let mut _0: (); bb0: { - drop(_2) -> bb1; + drop(_2) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/building/custom/terminators.indirect_call.built.after.mir b/tests/mir-opt/building/custom/terminators.indirect_call.built.after.mir index 56371c786660..3b849354dcd8 100644 --- a/tests/mir-opt/building/custom/terminators.indirect_call.built.after.mir +++ b/tests/mir-opt/building/custom/terminators.indirect_call.built.after.mir @@ -4,7 +4,7 @@ fn indirect_call(_1: i32, _2: fn(i32) -> i32) -> i32 { let mut _0: i32; bb0: { - _0 = _2(_1) -> bb1; + _0 = _2(_1) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/combine_array_len.norm2.InstSimplify.panic-unwind.diff b/tests/mir-opt/combine_array_len.norm2.InstSimplify.panic-unwind.diff index ab7a34f840d5..4833c1089e3c 100644 --- a/tests/mir-opt/combine_array_len.norm2.InstSimplify.panic-unwind.diff +++ b/tests/mir-opt/combine_array_len.norm2.InstSimplify.panic-unwind.diff @@ -32,7 +32,7 @@ - _4 = Len(_1); + _4 = const 2_usize; _5 = Lt(_3, _4); - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; + assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; } bb1: { @@ -44,7 +44,7 @@ - _8 = Len(_1); + _8 = const 2_usize; _9 = Lt(_7, _8); - assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> bb2; + assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> [success: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-unwind.diff b/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-unwind.diff index ee0f9fbf8289..1a4372afe697 100644 --- a/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-unwind.diff +++ b/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-unwind.diff @@ -21,7 +21,7 @@ _4 = &((*_1).0: T); - _3 = &(*_4); + _3 = _4; - _2 = ::clone(move _3) -> bb1; + _2 = ::clone(move _3) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-unwind.diff index 73b5baafb332..e4650046bdf1 100644 --- a/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-unwind.diff @@ -27,7 +27,7 @@ StorageLive(_5); - _5 = _1; + _5 = const 1_u8; - _4 = foo(move _5) -> bb1; + _4 = foo(move _5) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir index 93d461a38c4a..9590c7f90aa3 100644 --- a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.panic-unwind.mir @@ -23,7 +23,7 @@ fn main() -> () { StorageLive(_4); StorageLive(_5); _5 = const 1_u8; - _4 = foo(move _5) -> bb1; + _4 = foo(move _5) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-unwind.diff index 9ac2fac6c004..ec11395c3762 100644 --- a/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-unwind.diff @@ -20,10 +20,10 @@ _3 = const 2_usize; - _4 = Len(_2); - _5 = Lt(_3, _4); -- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; +- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; + _4 = const 4_usize; + _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-unwind.diff index 9ac2fac6c004..ec11395c3762 100644 --- a/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-unwind.diff @@ -20,10 +20,10 @@ _3 = const 2_usize; - _4 = Len(_2); - _5 = Lt(_3, _4); -- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; +- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; + _4 = const 4_usize; + _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-unwind.diff index 2aff357cc3e6..a5b51681ec97 100644 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-unwind.diff @@ -24,21 +24,21 @@ StorageLive(_3); - _3 = _1; - _4 = Eq(_3, const 0_i32); -- assert(!move _4, "attempt to divide `{}` by zero", const 1_i32) -> bb1; +- assert(!move _4, "attempt to divide `{}` by zero", const 1_i32) -> [success: bb1, unwind continue]; + _3 = const 0_i32; + _4 = const true; -+ assert(!const true, "attempt to divide `{}` by zero", const 1_i32) -> bb1; ++ assert(!const true, "attempt to divide `{}` by zero", const 1_i32) -> [success: bb1, unwind continue]; } bb1: { - _5 = Eq(_3, const -1_i32); - _6 = Eq(const 1_i32, const i32::MIN); - _7 = BitAnd(move _5, move _6); -- assert(!move _7, "attempt to compute `{} / {}`, which would overflow", const 1_i32, _3) -> bb2; +- assert(!move _7, "attempt to compute `{} / {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind continue]; + _5 = const false; + _6 = const false; + _7 = const false; -+ assert(!const false, "attempt to compute `{} / {}`, which would overflow", const 1_i32, _3) -> bb2; ++ assert(!const false, "attempt to compute `{} / {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-unwind.diff index db93de9630b5..4afddf3c92d7 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-unwind.diff @@ -24,21 +24,21 @@ StorageLive(_3); - _3 = _1; - _4 = Eq(_3, const 0_i32); -- assert(!move _4, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> bb1; +- assert(!move _4, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> [success: bb1, unwind continue]; + _3 = const 0_i32; + _4 = const true; -+ assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> bb1; ++ assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> [success: bb1, unwind continue]; } bb1: { - _5 = Eq(_3, const -1_i32); - _6 = Eq(const 1_i32, const i32::MIN); - _7 = BitAnd(move _5, move _6); -- assert(!move _7, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> bb2; +- assert(!move _7, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind continue]; + _5 = const false; + _6 = const false; + _7 = const false; -+ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> bb2; ++ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-unwind.diff index f39468d9684b..2c0e4844ecc3 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-unwind.diff @@ -36,9 +36,9 @@ _6 = const 3_usize; _7 = const 3_usize; - _8 = Lt(_6, _7); -- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; +- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; + _8 = const false; -+ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; ++ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-unwind.diff index f39468d9684b..2c0e4844ecc3 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-unwind.diff @@ -36,9 +36,9 @@ _6 = const 3_usize; _7 = const 3_usize; - _8 = Lt(_6, _7); -- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; +- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; + _8 = const false; -+ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; ++ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-unwind.diff index 8e3c2f6c8448..6214766c7ee5 100644 --- a/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-unwind.diff @@ -26,7 +26,7 @@ - _5 = AlignOf(i32); + _4 = const 4_usize; + _5 = const 4_usize; - _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> bb1; + _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-unwind.diff index 175e2b51a37c..125407bf285a 100644 --- a/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-unwind.diff @@ -12,9 +12,9 @@ bb0: { StorageLive(_1); - _2 = CheckedAdd(const 1_u32, const 1_u32); -- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> bb1; +- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> [success: bb1, unwind continue]; + _2 = const (2_u32, false); -+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> bb1; ++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-unwind.diff index 01ec24916c89..850b743feb1c 100644 --- a/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/const_prop_fails_gracefully.main.ConstProp.panic-unwind.diff @@ -24,7 +24,7 @@ StorageLive(_4); StorageLive(_5); _5 = _1; - _4 = read(move _5) -> bb1; + _4 = read(move _5) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-unwind.diff index 4593ffaac2bd..7496d2543097 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-unwind.diff @@ -14,7 +14,7 @@ } bb1: { - _2 = begin_panic::<&str>(const "explicit panic"); + _2 = begin_panic::<&str>(const "explicit panic") -> unwind continue; } bb2: { diff --git a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff index affef00bb732..ccfa35f001b5 100644 --- a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff @@ -15,10 +15,10 @@ StorageLive(_2); - _2 = const 2_u32 as u8 (IntToInt); - _3 = CheckedAdd(_2, const 1_u8); -- assert(!move (_3.1: bool), "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> bb1; +- assert(!move (_3.1: bool), "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> [success: bb1, unwind continue]; + _2 = const 2_u8; + _3 = const (3_u8, false); -+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> bb1; ++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff index 9dae4b404aad..4f8e0f0f599b 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff @@ -21,9 +21,9 @@ StorageLive(_3); _3 = const 1_u8; - _4 = CheckedAdd(_2, _3); -- assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> bb1; +- assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> [success: bb1, unwind continue]; + _4 = const (0_u8, true); -+ assert(!const true, "attempt to compute `{} + {}`, which would overflow", _2, _3) -> bb1; ++ assert(!const true, "attempt to compute `{} + {}`, which would overflow", _2, _3) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff index e83c18735b61..5e3443228cd2 100644 --- a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff @@ -9,7 +9,7 @@ bb0: { StorageLive(_2); _2 = (const (), const 0_u8, const 0_u8); - _1 = encode(move _2) -> bb1; + _1 = encode(move _2) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff index cbbc2582973a..95776030162e 100644 --- a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff @@ -14,7 +14,7 @@ + _3 = const (1_u8, 2_u8); _2 = (move _3,); StorageDead(_3); - _1 = test(move _2) -> bb1; + _1 = test(move _2) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-unwind.diff index be245b424c14..658607116c87 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-unwind.diff @@ -20,10 +20,10 @@ _3 = const 2_usize; - _4 = Len(_2); - _5 = Lt(_3, _4); -- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; +- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; + _4 = const 5000_usize; + _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-unwind.diff index be245b424c14..658607116c87 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-unwind.diff @@ -20,10 +20,10 @@ _3 = const 2_usize; - _4 = Len(_2); - _5 = Lt(_3, _4); -- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; +- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; + _4 = const 5000_usize; + _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-unwind.diff index 50006f5f5b5a..7ba2b483dc3f 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-unwind.diff @@ -14,7 +14,7 @@ bb0: { StorageLive(_1); - _1 = foo() -> bb1; + _1 = foo() -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-unwind.diff index 69a0c3e2429e..15ef0fa4dfff 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-unwind.diff @@ -23,7 +23,7 @@ bb0: { StorageLive(_1); - _1 = foo() -> bb1; + _1 = foo() -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff index 29cad611b540..bbb807d8fcdc 100644 --- a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff @@ -29,7 +29,7 @@ StorageLive(_2); - _2 = OffsetOf(Alpha, [0]); + _2 = const 4_usize; - _1 = must_use::(move _2) -> bb1; + _1 = must_use::(move _2) -> [return: bb1, unwind continue]; } bb1: { @@ -38,7 +38,7 @@ StorageLive(_4); - _4 = OffsetOf(Alpha, [1]); + _4 = const 0_usize; - _3 = must_use::(move _4) -> bb2; + _3 = must_use::(move _4) -> [return: bb2, unwind continue]; } bb2: { @@ -47,7 +47,7 @@ StorageLive(_6); - _6 = OffsetOf(Alpha, [2, 0]); + _6 = const 2_usize; - _5 = must_use::(move _6) -> bb3; + _5 = must_use::(move _6) -> [return: bb3, unwind continue]; } bb3: { @@ -56,7 +56,7 @@ StorageLive(_8); - _8 = OffsetOf(Alpha, [2, 1]); + _8 = const 3_usize; - _7 = must_use::(move _8) -> bb4; + _7 = must_use::(move _8) -> [return: bb4, unwind continue]; } bb4: { diff --git a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-unwind.diff index 2a58a1a5ceb4..fd5206e460c6 100644 --- a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-unwind.diff @@ -28,7 +28,7 @@ StorageLive(_1); StorageLive(_2); _2 = OffsetOf(Gamma, [0]); - _1 = must_use::(move _2) -> bb1; + _1 = must_use::(move _2) -> [return: bb1, unwind continue]; } bb1: { @@ -36,7 +36,7 @@ StorageLive(_3); StorageLive(_4); _4 = OffsetOf(Gamma, [1]); - _3 = must_use::(move _4) -> bb2; + _3 = must_use::(move _4) -> [return: bb2, unwind continue]; } bb2: { @@ -44,7 +44,7 @@ StorageLive(_5); StorageLive(_6); _6 = OffsetOf(Delta, [1]); - _5 = must_use::(move _6) -> bb3; + _5 = must_use::(move _6) -> [return: bb3, unwind continue]; } bb3: { @@ -52,7 +52,7 @@ StorageLive(_7); StorageLive(_8); _8 = OffsetOf(Delta, [2]); - _7 = must_use::(move _8) -> bb4; + _7 = must_use::(move _8) -> [return: bb4, unwind continue]; } bb4: { diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-unwind.diff index f94708605eef..571f279a8c14 100644 --- a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-unwind.diff @@ -22,10 +22,10 @@ _4 = const 2_usize; - _5 = Len(_3); - _6 = Lt(_4, _5); -- assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; +- assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind continue]; + _5 = const 8_usize; + _6 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-unwind.diff index f94708605eef..571f279a8c14 100644 --- a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-unwind.diff @@ -22,10 +22,10 @@ _4 = const 2_usize; - _5 = Len(_3); - _6 = Lt(_4, _5); -- assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; +- assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind continue]; + _5 = const 8_usize; + _6 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> bb1; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-unwind.diff index f89e9dd5b635..79f85fcef110 100644 --- a/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-unwind.diff @@ -7,9 +7,9 @@ bb0: { - _1 = CheckedAdd(const 2_u32, const 2_u32); -- assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> bb1; +- assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> [success: bb1, unwind continue]; + _1 = const (4_u32, false); -+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> bb1; ++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-unwind.mir b/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-unwind.mir index 148f16c7ee2d..9a0646974636 100644 --- a/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-unwind.mir +++ b/tests/mir-opt/const_prop/return_place.add.PreCodegen.before.panic-unwind.mir @@ -6,7 +6,7 @@ fn add() -> u32 { bb0: { _1 = const (4_u32, false); - assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> bb1; + assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_u32, const 2_u32) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-unwind.diff index d7d6e8e435e2..a7d7a7224cea 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-unwind.diff @@ -17,7 +17,7 @@ StorageLive(_3); - _3 = _1; + _3 = const 1_u32; - _2 = consume(move _3) -> bb1; + _2 = consume(move _3) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff index b07ec0ad5025..c0f290a9ab49 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff @@ -27,10 +27,10 @@ _6 = const 1_usize; - _7 = Len((*_2)); - _8 = Lt(_6, _7); -- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; +- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; + _7 = const 3_usize; + _8 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff index b07ec0ad5025..c0f290a9ab49 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff @@ -27,10 +27,10 @@ _6 = const 1_usize; - _7 = Len((*_2)); - _8 = Lt(_6, _7); -- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; +- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; + _7 = const 3_usize; + _8 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-unwind.diff index 02dca4d3dea5..1ce28e979a5b 100644 --- a/tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-unwind.diff @@ -13,11 +13,11 @@ } bb1: { - _0 = foo(const -1_i32) -> bb3; + _0 = foo(const -1_i32) -> [return: bb3, unwind continue]; } bb2: { - _0 = foo(const 0_i32) -> bb3; + _0 = foo(const 0_i32) -> [return: bb3, unwind continue]; } bb3: { diff --git a/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff b/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff index 72ce94e14295..e598a0d3df00 100644 --- a/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff +++ b/tests/mir-opt/const_prop/switch_int.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff @@ -13,11 +13,11 @@ } bb1: { - _0 = foo(const -1_i32) -> bb3; + _0 = foo(const -1_i32) -> [return: bb3, unwind continue]; } bb2: { - _0 = foo(const 0_i32) -> bb3; + _0 = foo(const 0_i32) -> [return: bb3, unwind continue]; } bb3: { diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff index d44c69ca4403..6255f9ec5962 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff @@ -18,7 +18,7 @@ StorageLive(_3); - _3 = _1; + _3 = const (1_u32, 2_u32); - _2 = consume(move _3) -> bb1; + _2 = consume(move _3) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.panic-unwind.diff index 074f82702418..b702e3b7d1ed 100644 --- a/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.panic-unwind.diff @@ -13,11 +13,11 @@ _2 = &_1; _3 = _1; _4 = &_3; - _0 = cmp_ref(_2, _4) -> bb1; + _0 = cmp_ref(_2, _4) -> [return: bb1, unwind continue]; } bb1: { - _0 = opaque::(_3) -> bb2; + _0 = opaque::(_3) -> [return: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/copy-prop/branch.foo.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/branch.foo.CopyProp.panic-unwind.diff index 0dcc5cef7340..2f92d8818cff 100644 --- a/tests/mir-opt/copy-prop/branch.foo.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/branch.foo.CopyProp.panic-unwind.diff @@ -16,13 +16,13 @@ bb0: { StorageLive(_1); - _1 = val() -> bb1; + _1 = val() -> [return: bb1, unwind continue]; } bb1: { StorageLive(_2); StorageLive(_3); - _3 = cond() -> bb2; + _3 = cond() -> [return: bb2, unwind continue]; } bb2: { @@ -36,7 +36,7 @@ bb4: { StorageLive(_4); - _4 = val() -> bb5; + _4 = val() -> [return: bb5, unwind continue]; } bb5: { diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.panic-unwind.diff index 95c1c12ee692..ef9c343a264d 100644 --- a/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.panic-unwind.diff @@ -11,7 +11,7 @@ StorageLive(_2); StorageLive(_3); _3 = _1; - _2 = dummy(move _3) -> bb1; + _2 = dummy(move _3) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.panic-unwind.diff index e16d6220ef2c..769089e16f34 100644 --- a/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.panic-unwind.diff @@ -11,7 +11,7 @@ StorageLive(_2); StorageLive(_3); _3 = _1; - _2 = dummy(move _3) -> bb1; + _2 = dummy(move _3) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.panic-unwind.diff index 2d7e34f2d6e3..eb40183c1c95 100644 --- a/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.panic-unwind.diff @@ -8,14 +8,14 @@ bb0: { - _2 = _1; -- _0 = opaque::(move _1) -> bb1; -+ _0 = opaque::(_1) -> bb1; +- _0 = opaque::(move _1) -> [return: bb1, unwind continue]; ++ _0 = opaque::(_1) -> [return: bb1, unwind continue]; } bb1: { - _3 = move _2; -- _0 = opaque::(_3) -> bb2; -+ _0 = opaque::(_1) -> bb2; +- _0 = opaque::(_3) -> [return: bb2, unwind continue]; ++ _0 = opaque::(_1) -> [return: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/copy-prop/cycle.main.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/cycle.main.CopyProp.panic-unwind.diff index bf9e941c7b65..e343b78924ab 100644 --- a/tests/mir-opt/copy-prop/cycle.main.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/cycle.main.CopyProp.panic-unwind.diff @@ -22,7 +22,7 @@ bb0: { StorageLive(_1); - _1 = val() -> bb1; + _1 = val() -> [return: bb1, unwind continue]; } bb1: { @@ -38,7 +38,7 @@ StorageLive(_5); StorageLive(_6); _6 = _1; - _5 = std::mem::drop::(move _6) -> bb2; + _5 = std::mem::drop::(move _6) -> [return: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.panic-unwind.mir b/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.panic-unwind.mir index 617e57d884bf..f8c285ff3843 100644 --- a/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.panic-unwind.mir +++ b/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.panic-unwind.mir @@ -16,7 +16,7 @@ fn f(_1: usize) -> usize { _1 = _2; StorageLive(_4); _4 = _1; - _0 = id::(move _4) -> bb1; + _0 = id::(move _4) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.panic-unwind.mir b/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.panic-unwind.mir index 617e57d884bf..f8c285ff3843 100644 --- a/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.panic-unwind.mir +++ b/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.panic-unwind.mir @@ -16,7 +16,7 @@ fn f(_1: usize) -> usize { _1 = _2; StorageLive(_4); _4 = _1; - _0 = id::(move _4) -> bb1; + _0 = id::(move _4) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-unwind.diff index 69f399bf1fa1..c2d892be35dc 100644 --- a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-unwind.diff @@ -49,14 +49,14 @@ _7 = &_2; _6 = move _7 as &[i32] (Pointer(Unsize)); StorageDead(_7); - _5 = core::slice::::len(move _6) -> bb1; + _5 = core::slice::::len(move _6) -> [return: bb1, unwind continue]; } bb1: { StorageDead(_6); _4 = std::ops::Range:: { start: const 0_usize, end: move _5 }; StorageDead(_5); - _3 = as IntoIterator>::into_iter(move _4) -> bb2; + _3 = as IntoIterator>::into_iter(move _4) -> [return: bb2, unwind continue]; } bb2: { @@ -73,7 +73,7 @@ StorageLive(_13); _13 = &mut _8; _12 = &mut (*_13); - _11 = as Iterator>::next(move _12) -> bb4; + _11 = as Iterator>::next(move _12) -> [return: bb4, unwind continue]; } bb4: { @@ -90,9 +90,9 @@ - _18 = _16; _19 = Len(_2); - _20 = Lt(_18, _19); -- assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _18) -> bb8; +- assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _18) -> [success: bb8, unwind continue]; + _20 = Lt(_16, _19); -+ assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _16) -> bb8; ++ assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _16) -> [success: bb8, unwind continue]; } bb6: { diff --git a/tests/mir-opt/copy-prop/move_arg.f.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/move_arg.f.CopyProp.panic-unwind.diff index cbbf6686b049..0c6a3c6d5c95 100644 --- a/tests/mir-opt/copy-prop/move_arg.f.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/move_arg.f.CopyProp.panic-unwind.diff @@ -21,8 +21,8 @@ - _4 = _1; - StorageLive(_5); - _5 = _2; -- _3 = g::(move _4, move _5) -> bb1; -+ _3 = g::(_1, _1) -> bb1; +- _3 = g::(move _4, move _5) -> [return: bb1, unwind continue]; ++ _3 = g::(_1, _1) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/copy-prop/move_projection.f.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/move_projection.f.CopyProp.panic-unwind.diff index 3ebee0ed80d4..ad3889639e0c 100644 --- a/tests/mir-opt/copy-prop/move_projection.f.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/move_projection.f.CopyProp.panic-unwind.diff @@ -9,13 +9,13 @@ bb0: { - _2 = _1; - _3 = move (_2.0: u8); -- _0 = opaque::(move _1) -> bb1; +- _0 = opaque::(move _1) -> [return: bb1, unwind continue]; + _3 = (_1.0: u8); -+ _0 = opaque::(_1) -> bb1; ++ _0 = opaque::(_1) -> [return: bb1, unwind continue]; } bb1: { - _0 = opaque::(move _3) -> bb2; + _0 = opaque::(move _3) -> [return: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.panic-unwind.diff index 0f14b53e9ade..66a0f49cfb9d 100644 --- a/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/reborrow.demiraw.CopyProp.panic-unwind.diff @@ -36,8 +36,8 @@ StorageLive(_6); - StorageLive(_7); - _7 = _5; -- _6 = opaque::<*mut u8>(move _7) -> bb1; -+ _6 = opaque::<*mut u8>(_2) -> bb1; +- _6 = opaque::<*mut u8>(move _7) -> [return: bb1, unwind continue]; ++ _6 = opaque::<*mut u8>(_2) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.panic-unwind.diff index ba6e09fa95c6..f5a512b89955 100644 --- a/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/reborrow.miraw.CopyProp.panic-unwind.diff @@ -32,8 +32,8 @@ StorageLive(_5); - StorageLive(_6); - _6 = _4; -- _5 = opaque::<*mut u8>(move _6) -> bb1; -+ _5 = opaque::<*mut u8>(_2) -> bb1; +- _5 = opaque::<*mut u8>(move _6) -> [return: bb1, unwind continue]; ++ _5 = opaque::<*mut u8>(_2) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-unwind.diff index 4379aa06385e..67763fdce667 100644 --- a/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/reborrow.remut.CopyProp.panic-unwind.diff @@ -30,8 +30,8 @@ StorageLive(_5); - StorageLive(_6); - _6 = move _4; -- _5 = opaque::<&mut u8>(move _6) -> bb1; -+ _5 = opaque::<&mut u8>(move _2) -> bb1; +- _5 = opaque::<&mut u8>(move _6) -> [return: bb1, unwind continue]; ++ _5 = opaque::<&mut u8>(move _2) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-unwind.diff index 53332f8161ea..becc42563210 100644 --- a/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/reborrow.reraw.CopyProp.panic-unwind.diff @@ -30,8 +30,8 @@ StorageLive(_5); - StorageLive(_6); - _6 = move _4; -- _5 = opaque::<&mut u8>(move _6) -> bb1; -+ _5 = opaque::<&mut u8>(move _2) -> bb1; +- _5 = opaque::<&mut u8>(move _6) -> [return: bb1, unwind continue]; ++ _5 = opaque::<&mut u8>(move _2) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-unwind.diff index 784841eacbfa..0d8a9aca3d8c 100644 --- a/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.panic-unwind.diff @@ -41,10 +41,10 @@ StorageLive(_5); - _5 = _2; - _6 = CheckedAdd(_4, _5); -- assert(!move (_6.1: bool), "attempt to compute `{} + {}`, which would overflow", move _4, move _5) -> bb1; +- assert(!move (_6.1: bool), "attempt to compute `{} + {}`, which would overflow", move _4, move _5) -> [success: bb1, unwind continue]; + _5 = const 2_i32; + _6 = CheckedAdd(const 1_i32, const 2_i32); -+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 1_i32, const 2_i32) -> bb1; ++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 1_i32, const 2_i32) -> [success: bb1, unwind continue]; } bb1: { @@ -58,10 +58,10 @@ StorageLive(_9); - _9 = _7; - _10 = CheckedAdd(_9, const 1_i32); -- assert(!move (_10.1: bool), "attempt to compute `{} + {}`, which would overflow", move _9, const 1_i32) -> bb2; +- assert(!move (_10.1: bool), "attempt to compute `{} + {}`, which would overflow", move _9, const 1_i32) -> [success: bb2, unwind continue]; + _9 = const i32::MAX; + _10 = CheckedAdd(const i32::MAX, const 1_i32); -+ assert(!const true, "attempt to compute `{} + {}`, which would overflow", const i32::MAX, const 1_i32) -> bb2; ++ assert(!const true, "attempt to compute `{} + {}`, which would overflow", const i32::MAX, const 1_i32) -> [success: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff index d79a2da1ddb7..c1d281ab788f 100644 --- a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.panic-unwind.diff @@ -21,9 +21,9 @@ StorageLive(_3); _3 = const 1_u8; - _4 = CheckedAdd(_2, _3); -- assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> bb1; +- assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> [success: bb1, unwind continue]; + _4 = CheckedAdd(const u8::MAX, const 1_u8); -+ assert(!const true, "attempt to compute `{} + {}`, which would overflow", const u8::MAX, const 1_u8) -> bb1; ++ assert(!const true, "attempt to compute `{} + {}`, which would overflow", const u8::MAX, const 1_u8) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.panic-unwind.diff index 83d2f78323e7..4e1d26acfa3f 100644 --- a/tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.panic-unwind.diff @@ -24,7 +24,7 @@ StorageLive(_4); _4 = &_1; _3 = &(*_4); - _2 = escape::(move _3) -> bb1; + _2 = escape::(move _3) -> [return: bb1, unwind continue]; } bb1: { @@ -33,7 +33,7 @@ StorageDead(_2); _1 = const 1_i32; StorageLive(_5); - _5 = some_function() -> bb2; + _5 = some_function() -> [return: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-unwind.diff index 927ca0124bbc..ebeb8619d730 100644 --- a/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.panic-unwind.diff @@ -30,7 +30,7 @@ StorageLive(_4); StorageLive(_5); _5 = _3; - _4 = ptr::mut_ptr::::add(move _5, const 1_usize) -> bb1; + _4 = ptr::mut_ptr::::add(move _5, const 1_usize) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.panic-unwind.diff index f9723a049830..395620fec524 100644 --- a/tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.panic-unwind.diff @@ -22,8 +22,8 @@ + _4 = const 1_i32; + _3 = const 2_i32; StorageDead(_4); -- _2 = foo(move _3) -> bb1; -+ _2 = foo(const 2_i32) -> bb1; +- _2 = foo(move _3) -> [return: bb1, unwind continue]; ++ _2 = foo(const 2_i32) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.panic-unwind.diff b/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.panic-unwind.diff index 80a4dd371839..4b922e05e105 100644 --- a/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.panic-unwind.diff +++ b/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.panic-unwind.diff @@ -28,9 +28,9 @@ bb1: { - StorageLive(_5); -- _5 = cond() -> bb2; +- _5 = cond() -> [return: bb2, unwind continue]; + StorageLive(_4); -+ _4 = cond() -> bb2; ++ _4 = cond() -> [return: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff index 66396d28e704..3d9aa829052d 100644 --- a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff +++ b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff @@ -17,7 +17,7 @@ StorageLive(_2); StorageLive(_3); _3 = &(*_1); - _2 = core::str::::as_bytes(move _3) -> bb1; + _2 = core::str::::as_bytes(move _3) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/derefer_complex_case.main.Derefer.panic-unwind.diff b/tests/mir-opt/derefer_complex_case.main.Derefer.panic-unwind.diff index 62085341d378..da4cc188cfa6 100644 --- a/tests/mir-opt/derefer_complex_case.main.Derefer.panic-unwind.diff +++ b/tests/mir-opt/derefer_complex_case.main.Derefer.panic-unwind.diff @@ -30,7 +30,7 @@ StorageLive(_2); _14 = const _; _2 = &(*_14); - _1 = <&[i32; 2] as IntoIterator>::into_iter(move _2) -> bb1; + _1 = <&[i32; 2] as IntoIterator>::into_iter(move _2) -> [return: bb1, unwind continue]; } bb1: { @@ -47,7 +47,7 @@ StorageLive(_9); _9 = &mut _4; _8 = &mut (*_9); - _7 = as Iterator>::next(move _8) -> bb3; + _7 = as Iterator>::next(move _8) -> [return: bb3, unwind continue]; } bb3: { @@ -63,7 +63,7 @@ + _12 = (*_15); StorageLive(_13); _13 = _12; - _6 = std::mem::drop::(move _13) -> bb7; + _6 = std::mem::drop::(move _13) -> [return: bb7, unwind continue]; } bb5: { diff --git a/tests/mir-opt/derefer_inline_test.main.Derefer.panic-unwind.diff b/tests/mir-opt/derefer_inline_test.main.Derefer.panic-unwind.diff index 50683837097a..2ada087b4bd6 100644 --- a/tests/mir-opt/derefer_inline_test.main.Derefer.panic-unwind.diff +++ b/tests/mir-opt/derefer_inline_test.main.Derefer.panic-unwind.diff @@ -9,7 +9,7 @@ bb0: { StorageLive(_1); StorageLive(_2); - _2 = f() -> bb1; + _2 = f() -> [return: bb1, unwind continue]; } bb1: { @@ -18,7 +18,7 @@ bb2: { StorageDead(_2); - drop(_1) -> bb3; + drop(_1) -> [return: bb3, unwind continue]; } bb3: { diff --git a/tests/mir-opt/derefer_terminator_test.main.Derefer.panic-unwind.diff b/tests/mir-opt/derefer_terminator_test.main.Derefer.panic-unwind.diff index 59168eda2f3e..19b26c901cbf 100644 --- a/tests/mir-opt/derefer_terminator_test.main.Derefer.panic-unwind.diff +++ b/tests/mir-opt/derefer_terminator_test.main.Derefer.panic-unwind.diff @@ -30,12 +30,12 @@ bb0: { StorageLive(_1); - _1 = foo() -> bb1; + _1 = foo() -> [return: bb1, unwind continue]; } bb1: { StorageLive(_2); - _2 = foo() -> bb2; + _2 = foo() -> [return: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/dest-prop/branch.foo.DestinationPropagation.panic-unwind.diff b/tests/mir-opt/dest-prop/branch.foo.DestinationPropagation.panic-unwind.diff index e0734f47de2a..759c1cabf45e 100644 --- a/tests/mir-opt/dest-prop/branch.foo.DestinationPropagation.panic-unwind.diff +++ b/tests/mir-opt/dest-prop/branch.foo.DestinationPropagation.panic-unwind.diff @@ -18,16 +18,16 @@ bb0: { - StorageLive(_1); -- _1 = val() -> bb1; +- _1 = val() -> [return: bb1, unwind continue]; + nop; -+ _0 = val() -> bb1; ++ _0 = val() -> [return: bb1, unwind continue]; } bb1: { - StorageLive(_2); + nop; StorageLive(_3); - _3 = cond() -> bb2; + _3 = cond() -> [return: bb2, unwind continue]; } bb2: { @@ -42,7 +42,7 @@ bb4: { StorageLive(_4); - _4 = val() -> bb5; + _4 = val() -> [return: bb5, unwind continue]; } bb5: { diff --git a/tests/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.panic-unwind.diff b/tests/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.panic-unwind.diff index b181066df047..8b2835c8ced2 100644 --- a/tests/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.panic-unwind.diff +++ b/tests/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.panic-unwind.diff @@ -11,10 +11,10 @@ StorageLive(_2); - StorageLive(_3); - _3 = _1; -- _2 = dummy(move _3) -> bb1; +- _2 = dummy(move _3) -> [return: bb1, unwind continue]; + nop; + nop; -+ _2 = dummy(move _1) -> bb1; ++ _2 = dummy(move _1) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.panic-unwind.diff b/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.panic-unwind.diff index f19728669368..b4c8a89278b9 100644 --- a/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.panic-unwind.diff +++ b/tests/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.panic-unwind.diff @@ -12,8 +12,8 @@ + nop; StorageLive(_3); _3 = _1; -- _2 = dummy(move _3) -> bb1; -+ _1 = dummy(move _3) -> bb1; +- _2 = dummy(move _3) -> [return: bb1, unwind continue]; ++ _1 = dummy(move _3) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-unwind.diff b/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-unwind.diff index 0dc7de31cc47..6f6e01d37b1a 100644 --- a/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-unwind.diff +++ b/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-unwind.diff @@ -24,9 +24,9 @@ bb0: { - StorageLive(_1); -- _1 = val() -> bb1; +- _1 = val() -> [return: bb1, unwind continue]; + nop; -+ _6 = val() -> bb1; ++ _6 = val() -> [return: bb1, unwind continue]; } bb1: { @@ -51,7 +51,7 @@ - _6 = _1; + nop; + nop; - _5 = std::mem::drop::(move _6) -> bb2; + _5 = std::mem::drop::(move _6) -> [return: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-unwind.mir b/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-unwind.mir index bf515d328aef..9147de2ec473 100644 --- a/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-unwind.mir +++ b/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-unwind.mir @@ -20,7 +20,7 @@ fn f(_1: usize) -> usize { nop; nop; nop; - _0 = id::(move _1) -> bb1; + _0 = id::(move _1) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-unwind.mir b/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-unwind.mir index 038bd4b6da9d..185feb4b4181 100644 --- a/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-unwind.mir +++ b/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-unwind.mir @@ -19,7 +19,7 @@ fn f(_1: usize) -> usize { nop; nop; nop; - _0 = id::(move _1) -> bb1; + _0 = id::(move _1) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/dest-prop/simple.nrvo.DestinationPropagation.panic-unwind.diff b/tests/mir-opt/dest-prop/simple.nrvo.DestinationPropagation.panic-unwind.diff index 4e32823c1ee9..9c3cbef38d69 100644 --- a/tests/mir-opt/dest-prop/simple.nrvo.DestinationPropagation.panic-unwind.diff +++ b/tests/mir-opt/dest-prop/simple.nrvo.DestinationPropagation.panic-unwind.diff @@ -25,8 +25,8 @@ StorageLive(_6); _6 = &mut _2; _5 = &mut (*_6); -- _3 = move _4(move _5) -> bb1; -+ _3 = move _1(move _5) -> bb1; +- _3 = move _4(move _5) -> [return: bb1, unwind continue]; ++ _3 = move _1(move _5) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff index 8d1297d02996..d2eef90582d5 100644 --- a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff +++ b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff @@ -18,7 +18,7 @@ bb0: { StorageLive(_1); StorageLive(_2); - _2 = val() -> bb1; + _2 = val() -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-unwind.diff b/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-unwind.diff index e46a318f51ab..7f730a77b06a 100644 --- a/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-unwind.diff +++ b/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-unwind.diff @@ -34,7 +34,7 @@ - _5 = _1; - StorageLive(_6); - _6 = _2; -- _4 = g::(move _5, move _6) -> bb2; +- _4 = g::(move _5, move _6) -> [return: bb2, unwind continue]; - } - - bb2: { @@ -53,9 +53,9 @@ + nop; StorageLive(_9); - _9 = _2; -- _7 = g::(move _8, move _9) -> bb4; +- _7 = g::(move _8, move _9) -> [return: bb4, unwind continue]; + _9 = _1; -+ _7 = g::(move _1, move _9) -> bb2; ++ _7 = g::(move _1, move _9) -> [return: bb2, unwind continue]; } - bb4: { diff --git a/tests/mir-opt/fn_ptr_shim.core.ops-function-Fn-call.AddMovesForPackedDrops.before.mir b/tests/mir-opt/fn_ptr_shim.core.ops-function-Fn-call.AddMovesForPackedDrops.before.mir index 4fe11435fab9..b15a634256f6 100644 --- a/tests/mir-opt/fn_ptr_shim.core.ops-function-Fn-call.AddMovesForPackedDrops.before.mir +++ b/tests/mir-opt/fn_ptr_shim.core.ops-function-Fn-call.AddMovesForPackedDrops.before.mir @@ -4,7 +4,7 @@ fn std::ops::Fn::call(_1: *const fn(), _2: ()) -> >::Output { let mut _0: >::Output; bb0: { - _0 = move (*_1)() -> bb1; + _0 = move (*_1)() -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-unwind.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-unwind.diff index 513ff03c4261..8a3dcfab44bd 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-unwind.diff @@ -38,7 +38,7 @@ StorageLive(_4); StorageLive(_5); _5 = &(*_1); - _4 = Formatter::<'_>::sign_plus(move _5) -> bb1; + _4 = Formatter::<'_>::sign_plus(move _5) -> [return: bb1, unwind continue]; } bb1: { @@ -63,7 +63,7 @@ StorageLive(_7); StorageLive(_8); _8 = &(*_1); - _7 = Formatter::<'_>::precision(move _8) -> bb5; + _7 = Formatter::<'_>::precision(move _8) -> [return: bb5, unwind continue]; } bb5: { @@ -81,7 +81,7 @@ _15 = _10 as u32 (IntToInt); _14 = Add(move _15, const 1_u32); StorageDead(_15); - _0 = float_to_exponential_common_exact::(_1, _2, move _13, move _14, _3) -> bb7; + _0 = float_to_exponential_common_exact::(_1, _2, move _13, move _14, _3) -> [return: bb7, unwind continue]; } bb7: { @@ -93,7 +93,7 @@ bb8: { StorageLive(_20); _20 = _6; - _0 = float_to_exponential_common_shortest::(_1, _2, move _20, _3) -> bb9; + _0 = float_to_exponential_common_shortest::(_1, _2, move _20, _3) -> [return: bb9, unwind continue]; } bb9: { diff --git a/tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff index af67723d9371..684211b53b33 100644 --- a/tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff @@ -15,7 +15,7 @@ bb0: { StorageLive(_1); -- _1 = foo() -> bb1; +- _1 = foo() -> [return: bb1, unwind continue]; + StorageLive(_2); + asm!("", options(MAY_UNWIND)) -> [return: bb2, unwind: bb3]; } @@ -28,7 +28,7 @@ + } + + bb2: { -+ drop(_2) -> bb1; ++ drop(_2) -> [return: bb1, unwind continue]; + } + + bb3 (cleanup): { diff --git a/tests/mir-opt/inline/caller_with_trivial_bound.foo.Inline.panic-unwind.diff b/tests/mir-opt/inline/caller_with_trivial_bound.foo.Inline.panic-unwind.diff index 67f16833435d..d4427b2a8076 100644 --- a/tests/mir-opt/inline/caller_with_trivial_bound.foo.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/caller_with_trivial_bound.foo.Inline.panic-unwind.diff @@ -10,7 +10,7 @@ bb0: { StorageLive(_1); - _1 = bar::() -> bb1; + _1 = bar::() -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/inline/cycle.g.Inline.panic-unwind.diff b/tests/mir-opt/inline/cycle.g.Inline.panic-unwind.diff index 2bdb942379ca..3ce8d9acf368 100644 --- a/tests/mir-opt/inline/cycle.g.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/cycle.g.Inline.panic-unwind.diff @@ -16,7 +16,7 @@ bb0: { StorageLive(_1); -- _1 = f::(main) -> bb1; +- _1 = f::(main) -> [return: bb1, unwind continue]; + StorageLive(_2); + _2 = main; + StorageLive(_4); @@ -46,7 +46,7 @@ + bb4: { + StorageDead(_5); + StorageDead(_3); -+ drop(_2) -> bb1; ++ drop(_2) -> [return: bb1, unwind continue]; } } diff --git a/tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff index c4f97d75308f..198a23226184 100644 --- a/tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff @@ -24,7 +24,7 @@ bb0: { StorageLive(_1); -- _1 = f::(g) -> bb1; +- _1 = f::(g) -> [return: bb1, unwind continue]; + StorageLive(_2); + _2 = g; + StorageLive(_4); @@ -56,7 +56,7 @@ + StorageDead(_6); + StorageDead(_5); + StorageDead(_3); -+ drop(_2) -> bb1; ++ drop(_2) -> [return: bb1, unwind continue]; } } diff --git a/tests/mir-opt/inline/dyn_trait.get_query.Inline.panic-unwind.diff b/tests/mir-opt/inline/dyn_trait.get_query.Inline.panic-unwind.diff index ca772cf43839..941ba24605cd 100644 --- a/tests/mir-opt/inline/dyn_trait.get_query.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/dyn_trait.get_query.Inline.panic-unwind.diff @@ -22,17 +22,17 @@ StorageLive(_2); StorageLive(_3); _3 = &(*_1); - _2 = ::cache::(move _3) -> bb1; + _2 = ::cache::(move _3) -> [return: bb1, unwind continue]; } bb1: { StorageDead(_3); StorageLive(_4); _4 = &(*_2); -- _0 = try_execute_query::<::C>(move _4) -> bb2; +- _0 = try_execute_query::<::C>(move _4) -> [return: bb2, unwind continue]; + StorageLive(_5); + _5 = _4 as &dyn Cache::V> (Pointer(Unsize)); -+ _0 = ::V> as Cache>::store_nocache(_5) -> bb2; ++ _0 = ::V> as Cache>::store_nocache(_5) -> [return: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.panic-unwind.diff b/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.panic-unwind.diff index 12b539fc250c..7b1cf895a873 100644 --- a/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.panic-unwind.diff @@ -9,7 +9,7 @@ bb0: { StorageLive(_2); _2 = &(*_1); - _0 = as Cache>::store_nocache(move _2) -> bb1; + _0 = as Cache>::store_nocache(move _2) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.panic-unwind.diff b/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.panic-unwind.diff index 9bcd73e1c8ba..5e30da400d29 100644 --- a/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.panic-unwind.diff @@ -16,8 +16,8 @@ _3 = &(*_1); _2 = move _3 as &dyn Cache::V> (Pointer(Unsize)); StorageDead(_3); -- _0 = mk_cycle::<::V>(move _2) -> bb1; -+ _0 = ::V> as Cache>::store_nocache(_2) -> bb1; +- _0 = mk_cycle::<::V>(move _2) -> [return: bb1, unwind continue]; ++ _0 = ::V> as Cache>::store_nocache(_2) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-unwind.diff index b87e164e471a..0a4ce40c529d 100644 --- a/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-unwind.diff @@ -37,7 +37,7 @@ bb0: { StorageLive(_1); -- _1 = <() as G>::call() -> bb1; +- _1 = <() as G>::call() -> [return: bb1, unwind continue]; + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); @@ -56,7 +56,7 @@ + StorageLive(_17); + StorageLive(_18); + StorageLive(_19); -+ _17 = <() as A>::call() -> bb12; ++ _17 = <() as A>::call() -> [return: bb12, unwind continue]; } bb1: { @@ -72,63 +72,63 @@ + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); -+ _3 = <() as F>::call() -> bb3; ++ _3 = <() as F>::call() -> [return: bb3, unwind continue]; + } + + bb3: { -+ _4 = <() as F>::call() -> bb1; ++ _4 = <() as F>::call() -> [return: bb1, unwind continue]; + } + + bb4: { + StorageDead(_10); + StorageDead(_9); + StorageDead(_8); -+ _6 = <() as E>::call() -> bb5; ++ _6 = <() as E>::call() -> [return: bb5, unwind continue]; + } + + bb5: { -+ _7 = <() as E>::call() -> bb2; ++ _7 = <() as E>::call() -> [return: bb2, unwind continue]; + } + + bb6: { + StorageDead(_13); + StorageDead(_12); + StorageDead(_11); -+ _9 = <() as D>::call() -> bb7; ++ _9 = <() as D>::call() -> [return: bb7, unwind continue]; + } + + bb7: { -+ _10 = <() as D>::call() -> bb4; ++ _10 = <() as D>::call() -> [return: bb4, unwind continue]; + } + + bb8: { + StorageDead(_16); + StorageDead(_15); + StorageDead(_14); -+ _12 = <() as C>::call() -> bb9; ++ _12 = <() as C>::call() -> [return: bb9, unwind continue]; + } + + bb9: { -+ _13 = <() as C>::call() -> bb6; ++ _13 = <() as C>::call() -> [return: bb6, unwind continue]; + } + + bb10: { + StorageDead(_19); + StorageDead(_18); + StorageDead(_17); -+ _15 = <() as B>::call() -> bb11; ++ _15 = <() as B>::call() -> [return: bb11, unwind continue]; + } + + bb11: { -+ _16 = <() as B>::call() -> bb8; ++ _16 = <() as B>::call() -> [return: bb8, unwind continue]; + } + + bb12: { -+ _18 = <() as A>::call() -> bb13; ++ _18 = <() as A>::call() -> [return: bb13, unwind continue]; + } + + bb13: { -+ _19 = <() as A>::call() -> bb10; ++ _19 = <() as A>::call() -> [return: bb10, unwind continue]; } } diff --git a/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-unwind.diff index 10e0f0efcbcf..eba5ad9cf269 100644 --- a/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-unwind.diff @@ -9,7 +9,7 @@ bb0: { StorageLive(_1); -- _1 = no_sanitize() -> bb1; +- _1 = no_sanitize() -> [return: bb1, unwind continue]; - } - - bb1: { diff --git a/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-unwind.diff index b854e93d9b79..24457819b2c1 100644 --- a/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-unwind.diff @@ -9,7 +9,7 @@ bb0: { StorageLive(_1); -- _1 = target_feature() -> bb1; +- _1 = target_feature() -> [return: bb1, unwind continue]; - } - - bb1: { diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-unwind.diff index d9e7177e6278..364acab6d936 100644 --- a/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-unwind.diff @@ -10,7 +10,7 @@ bb0: { StorageLive(_1); - _1 = sum(const 4_u32, const 4_u32, const 30_u32, const 200_u32, const 1000_u32) -> bb1; + _1 = sum(const 4_u32, const 4_u32, const 30_u32, const 200_u32, const 1000_u32) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-unwind.diff index 7d9b1d847b02..965b7ddca320 100644 --- a/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-unwind.diff @@ -7,7 +7,7 @@ bb0: { StorageLive(_1); - _1 = no_sanitize() -> bb1; + _1 = no_sanitize() -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-unwind.diff index 5bee58652838..bcdbd6e33140 100644 --- a/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-unwind.diff @@ -7,7 +7,7 @@ bb0: { StorageLive(_1); - _1 = target_feature() -> bb1; + _1 = target_feature() -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/inline/inline_cycle.one.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_cycle.one.Inline.panic-unwind.diff index 66d25162cb1b..75ac40bea61f 100644 --- a/tests/mir-opt/inline/inline_cycle.one.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_cycle.one.Inline.panic-unwind.diff @@ -13,7 +13,7 @@ bb0: { StorageLive(_1); - _1 = ::call() -> bb1; + _1 = ::call() -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/inline/inline_cycle.two.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_cycle.two.Inline.panic-unwind.diff index d3bd412d9532..a08662959dd8 100644 --- a/tests/mir-opt/inline/inline_cycle.two.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_cycle.two.Inline.panic-unwind.diff @@ -23,14 +23,14 @@ bb0: { StorageLive(_1); -- _1 = call::(f) -> bb1; +- _1 = call::(f) -> [return: bb1, unwind continue]; + StorageLive(_2); + _2 = f; + StorageLive(_3); + StorageLive(_4); + _4 = const (); + StorageLive(_5); -+ _5 = f() -> bb1; ++ _5 = f() -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/inline/inline_cycle_generic.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_cycle_generic.main.Inline.panic-unwind.diff index 2a4002f0499c..8314526ee043 100644 --- a/tests/mir-opt/inline/inline_cycle_generic.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_cycle_generic.main.Inline.panic-unwind.diff @@ -13,8 +13,8 @@ bb0: { StorageLive(_1); -- _1 = ::call() -> bb1; -+ _1 = as Call>::call() -> bb1; +- _1 = ::call() -> [return: bb1, unwind continue]; ++ _1 = as Call>::call() -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/inline/inline_diverging.f.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_diverging.f.Inline.panic-unwind.diff index 76bb3356f50f..b79918992534 100644 --- a/tests/mir-opt/inline/inline_diverging.f.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_diverging.f.Inline.panic-unwind.diff @@ -10,7 +10,7 @@ bb0: { StorageLive(_2); -- _2 = sleep(); +- _2 = sleep() -> unwind continue; + goto -> bb1; + } + diff --git a/tests/mir-opt/inline/inline_diverging.g.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_diverging.g.Inline.panic-unwind.diff index d65efa43a7b1..5663b4624001 100644 --- a/tests/mir-opt/inline/inline_diverging.g.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_diverging.g.Inline.panic-unwind.diff @@ -33,9 +33,9 @@ bb2: { StorageLive(_6); -- _6 = panic(); +- _6 = panic() -> unwind continue; + StorageLive(_7); -+ _7 = begin_panic::<&str>(const "explicit panic"); ++ _7 = begin_panic::<&str>(const "explicit panic") -> unwind continue; } } diff --git a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff index f7e0e1c55f8b..dfc12db12a88 100644 --- a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff @@ -27,7 +27,7 @@ bb0: { StorageLive(_1); -- _1 = call_twice:: ! {sleep}>(sleep); +- _1 = call_twice:: ! {sleep}>(sleep) -> unwind continue; + StorageLive(_2); + _2 = sleep; + StorageLive(_6); diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff index 588f04048d67..fedcf04231d7 100644 --- a/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff @@ -35,7 +35,7 @@ StorageLive(_2); StorageLive(_3); StorageLive(_4); -- _4 = g() -> bb1; +- _4 = g() -> [return: bb1, unwind continue]; - } - - bb1: { diff --git a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff index 4615a3f98267..0b643b3c7a92 100644 --- a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff @@ -117,7 +117,7 @@ bb0: { StorageLive(_1); StorageLive(_2); -- _2 = Vec::::new() -> bb1; +- _2 = Vec::::new() -> [return: bb1, unwind continue]; + StorageLive(_3); + _3 = const _; + _2 = Vec:: { buf: move _3, len: const 0_usize }; diff --git a/tests/mir-opt/inline/inline_options.main.Inline.after.panic-unwind.mir b/tests/mir-opt/inline/inline_options.main.Inline.after.panic-unwind.mir index d006c73f9542..df0cab513eca 100644 --- a/tests/mir-opt/inline/inline_options.main.Inline.after.panic-unwind.mir +++ b/tests/mir-opt/inline/inline_options.main.Inline.after.panic-unwind.mir @@ -12,7 +12,7 @@ fn main() -> () { bb0: { StorageLive(_1); - _1 = not_inlined() -> bb1; + _1 = not_inlined() -> [return: bb1, unwind continue]; } bb1: { @@ -21,7 +21,7 @@ fn main() -> () { StorageLive(_3); StorageLive(_4); StorageLive(_5); - _3 = g() -> bb3; + _3 = g() -> [return: bb3, unwind continue]; } bb2: { @@ -34,10 +34,10 @@ fn main() -> () { } bb3: { - _4 = g() -> bb4; + _4 = g() -> [return: bb4, unwind continue]; } bb4: { - _5 = g() -> bb2; + _5 = g() -> [return: bb2, unwind continue]; } } diff --git a/tests/mir-opt/inline/inline_shims.clone.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_shims.clone.Inline.panic-unwind.diff index 9897ed78edff..00e92a0f5e5a 100644 --- a/tests/mir-opt/inline/inline_shims.clone.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_shims.clone.Inline.panic-unwind.diff @@ -11,7 +11,7 @@ bb0: { StorageLive(_2); _2 = &_1; -- _0 = ::clone(move _2) -> bb1; +- _0 = ::clone(move _2) -> [return: bb1, unwind continue]; - } - - bb1: { diff --git a/tests/mir-opt/inline/inline_shims.drop.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_shims.drop.Inline.panic-unwind.diff index 1d24756e1d22..4270ae00b668 100644 --- a/tests/mir-opt/inline/inline_shims.drop.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_shims.drop.Inline.panic-unwind.diff @@ -21,7 +21,7 @@ StorageLive(_3); StorageLive(_4); _4 = _1; - _3 = std::ptr::drop_in_place::>(move _4) -> bb1; + _3 = std::ptr::drop_in_place::>(move _4) -> [return: bb1, unwind continue]; } bb1: { @@ -29,7 +29,7 @@ StorageDead(_3); StorageLive(_5); _5 = _2; -- _0 = std::ptr::drop_in_place::>(move _5) -> bb2; +- _0 = std::ptr::drop_in_place::>(move _5) -> [return: bb2, unwind continue]; + StorageLive(_6); + StorageLive(_7); + _6 = discriminant((*_5)); @@ -44,7 +44,7 @@ + } + + bb3: { -+ drop((((*_5) as Some).0: B)) -> bb2; ++ drop((((*_5) as Some).0: B)) -> [return: bb2, unwind continue]; } } diff --git a/tests/mir-opt/inline/inline_specialization.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_specialization.main.Inline.panic-unwind.diff index 0f7b1909f8dd..bc841101df73 100644 --- a/tests/mir-opt/inline/inline_specialization.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_specialization.main.Inline.panic-unwind.diff @@ -12,7 +12,7 @@ bb0: { StorageLive(_1); -- _1 = as Foo>::bar() -> bb1; +- _1 = as Foo>::bar() -> [return: bb1, unwind continue]; - } - - bb1: { diff --git a/tests/mir-opt/inline/inline_trait_method.test.Inline.after.panic-unwind.mir b/tests/mir-opt/inline/inline_trait_method.test.Inline.after.panic-unwind.mir index 9550fdea1920..da18a5adc376 100644 --- a/tests/mir-opt/inline/inline_trait_method.test.Inline.after.panic-unwind.mir +++ b/tests/mir-opt/inline/inline_trait_method.test.Inline.after.panic-unwind.mir @@ -8,7 +8,7 @@ fn test(_1: &dyn X) -> u32 { bb0: { StorageLive(_2); _2 = &(*_1); - _0 = ::y(move _2) -> bb1; + _0 = ::y(move _2) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.panic-unwind.mir b/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.panic-unwind.mir index ffc16bfe6709..5d4979680a48 100644 --- a/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.panic-unwind.mir +++ b/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.panic-unwind.mir @@ -15,7 +15,7 @@ fn test2(_1: &dyn X) -> bool { _3 = &(*_1); _2 = move _3 as &dyn X (Pointer(Unsize)); StorageDead(_3); - _0 = ::y(_2) -> bb1; + _0 = ::y(_2) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/inline/issue_106141.outer.Inline.panic-unwind.diff b/tests/mir-opt/inline/issue_106141.outer.Inline.panic-unwind.diff index 1e407f07d096..16a19f4a3569 100644 --- a/tests/mir-opt/inline/issue_106141.outer.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/issue_106141.outer.Inline.panic-unwind.diff @@ -16,16 +16,16 @@ + } bb0: { -- _0 = inner() -> bb1; +- _0 = inner() -> [return: bb1, unwind continue]; + StorageLive(_1); + _1 = const _; -+ _0 = index() -> bb1; ++ _0 = index() -> [return: bb1, unwind continue]; } bb1: { + StorageLive(_3); + _2 = Lt(_0, const 1_usize); -+ assert(move _2, "index out of bounds: the length is {} but the index is {}", const 1_usize, _0) -> bb2; ++ assert(move _2, "index out of bounds: the length is {} but the index is {}", const 1_usize, _0) -> [success: bb2, unwind continue]; + } + + bb2: { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_bigger.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_bigger.Inline.panic-unwind.diff index 577fc8bee66f..d71b5c4a626e 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_bigger.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_bigger.Inline.panic-unwind.diff @@ -20,7 +20,7 @@ _3 = _1; StorageLive(_4); _4 = _2; -- _0 = core::num::::unchecked_shl(move _3, move _4) -> bb1; +- _0 = core::num::::unchecked_shl(move _3, move _4) -> [return: bb1, unwind continue]; - } - - bb1: { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff index ba159c063b3b..cae25759cd8e 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff @@ -22,7 +22,7 @@ _3 = _1; StorageLive(_4); _4 = _2; -- _0 = core::num::::unchecked_shl(move _3, move _4) -> bb1; +- _0 = core::num::::unchecked_shl(move _3, move _4) -> [return: bb1, unwind continue]; - } - - bb1: { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff index d7ff104b92e9..6aafb61dc557 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff @@ -20,7 +20,7 @@ _3 = _1; StorageLive(_4); _4 = _2; -- _0 = core::num::::unchecked_shr(move _3, move _4) -> bb1; +- _0 = core::num::::unchecked_shr(move _3, move _4) -> [return: bb1, unwind continue]; - } - - bb1: { diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-unwind.diff index 3d398e00fc89..fe5331214866 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-unwind.diff @@ -22,7 +22,7 @@ _3 = _1; StorageLive(_4); _4 = _2; -- _0 = core::num::::unchecked_shr(move _3, move _4) -> bb1; +- _0 = core::num::::unchecked_shr(move _3, move _4) -> [return: bb1, unwind continue]; - } - - bb1: { diff --git a/tests/mir-opt/issue_101973.inner.ConstProp.panic-unwind.diff b/tests/mir-opt/issue_101973.inner.ConstProp.panic-unwind.diff index fbfb8f1fd4e6..a6bd29e1c9d1 100644 --- a/tests/mir-opt/issue_101973.inner.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/issue_101973.inner.ConstProp.panic-unwind.diff @@ -45,10 +45,10 @@ StorageLive(_8); - _10 = const 8_i32 as u32 (IntToInt); - _11 = Lt(move _10, const 32_u32); -- assert(move _11, "attempt to shift right by `{}`, which would overflow", const 8_i32) -> bb1; +- assert(move _11, "attempt to shift right by `{}`, which would overflow", const 8_i32) -> [success: bb1, unwind continue]; + _10 = const 8_u32; + _11 = const true; -+ assert(const true, "attempt to shift right by `{}`, which would overflow", const 8_i32) -> bb1; ++ assert(const true, "attempt to shift right by `{}`, which would overflow", const 8_i32) -> [success: bb1, unwind continue]; } bb1: { @@ -57,10 +57,10 @@ StorageDead(_8); - _12 = const 1_i32 as u32 (IntToInt); - _13 = Lt(move _12, const 32_u32); -- assert(move _13, "attempt to shift left by `{}`, which would overflow", const 1_i32) -> bb2; +- assert(move _13, "attempt to shift left by `{}`, which would overflow", const 1_i32) -> [success: bb2, unwind continue]; + _12 = const 1_u32; + _13 = const true; -+ assert(const true, "attempt to shift left by `{}`, which would overflow", const 1_i32) -> bb2; ++ assert(const true, "attempt to shift left by `{}`, which would overflow", const 1_i32) -> [success: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/issue_104451_unwindable_intrinsics.main.AbortUnwindingCalls.after.panic-unwind.mir b/tests/mir-opt/issue_104451_unwindable_intrinsics.main.AbortUnwindingCalls.after.panic-unwind.mir index 8ffd46311dc5..1851747f0a62 100644 --- a/tests/mir-opt/issue_104451_unwindable_intrinsics.main.AbortUnwindingCalls.after.panic-unwind.mir +++ b/tests/mir-opt/issue_104451_unwindable_intrinsics.main.AbortUnwindingCalls.after.panic-unwind.mir @@ -11,6 +11,6 @@ fn main() -> () { StorageLive(_1); StorageLive(_2); _2 = (); - _1 = const_eval_select::<(), fn() -> ! {ow_ct}, fn() -> ! {ow_ct}, !>(move _2, ow_ct, ow_ct); + _1 = const_eval_select::<(), fn() -> ! {ow_ct}, fn() -> ! {ow_ct}, !>(move _2, ow_ct, ow_ct) -> unwind continue; } } diff --git a/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-unwind.diff b/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-unwind.diff index b33d8fc52b40..254658c810db 100644 --- a/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-unwind.diff +++ b/tests/mir-opt/issue_41110.test.ElaborateDrops.panic-unwind.diff @@ -58,7 +58,7 @@ bb5: { StorageDead(_2); -- drop(_1) -> bb6; +- drop(_1) -> [return: bb6, unwind continue]; + goto -> bb6; } diff --git a/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-unwind.diff b/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-unwind.diff index 04071c72555e..4ef3650cdea3 100644 --- a/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-unwind.diff +++ b/tests/mir-opt/issue_41888.main.ElaborateDrops.panic-unwind.diff @@ -85,7 +85,7 @@ bb9: { StorageDead(_2); -- drop(_1) -> bb10; +- drop(_1) -> [return: bb10, unwind continue]; + goto -> bb19; } diff --git a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir index 4bbfe47299c8..7ecdc428e59e 100644 --- a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir +++ b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir @@ -31,7 +31,7 @@ fn test() -> Option> { StorageLive(_1); _2 = SizeOf(u32); _3 = AlignOf(u32); - _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; + _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> [return: bb1, unwind continue]; } bb1: { @@ -73,13 +73,13 @@ fn test() -> Option> { bb6: { StorageDead(_11); StorageDead(_9); - drop(_5) -> bb9; + drop(_5) -> [return: bb9, unwind continue]; } bb7: { StorageDead(_5); _0 = Option::>::Some(move _1); - drop(_1) -> bb8; + drop(_1) -> [return: bb8, unwind continue]; } bb8: { diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff index 761673ca546b..25df839c2db9 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff @@ -42,7 +42,7 @@ } bb1: { - _15 = core::panicking::panic(const "internal error: entered unreachable code"); + _15 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind continue; } bb2: { diff --git a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir index e7c1be7e6e65..43a1a1eed20d 100644 --- a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir @@ -26,7 +26,7 @@ fn num_to_digit(_1: char) -> u32 { bb0: { StorageLive(_3); StorageLive(_2); - _2 = char::methods::::to_digit(_1, const 8_u32) -> bb1; + _2 = char::methods::::to_digit(_1, const 8_u32) -> [return: bb1, unwind continue]; } bb1: { @@ -39,7 +39,7 @@ fn num_to_digit(_1: char) -> u32 { bb2: { StorageLive(_5); - _5 = char::methods::::to_digit(_1, const 8_u32) -> bb3; + _5 = char::methods::::to_digit(_1, const 8_u32) -> [return: bb3, unwind continue]; } bb3: { @@ -48,7 +48,7 @@ fn num_to_digit(_1: char) -> u32 { } bb4: { - _7 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value"); + _7 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value") -> unwind continue; } bb5: { diff --git a/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff b/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff index 35a1e51a3ac9..1cba0f27afaa 100644 --- a/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff +++ b/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff @@ -42,7 +42,7 @@ _8 = _1; _9 = Len((*_2)); _10 = Lt(_8, _9); - assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, _8) -> bb3; + assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, _8) -> [success: bb3, unwind continue]; } bb3: { diff --git a/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-unwind.diff b/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-unwind.diff index 3c6f37346246..6c450067cc4a 100644 --- a/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-unwind.diff +++ b/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-unwind.diff @@ -45,7 +45,7 @@ _8 = _1; _9 = Len((*_2)); _10 = Lt(_8, _9); - assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, _8) -> bb3; + assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, _8) -> [success: bb3, unwind continue]; } bb3: { @@ -59,7 +59,7 @@ _11 = const 0_usize; _12 = Len((*_2)); _13 = Lt(_11, _12); - assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> bb5; + assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb5, unwind continue]; } bb5: { diff --git a/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-unwind.diff b/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-unwind.diff index d90f3dddf58e..310b3b26ac56 100644 --- a/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-unwind.diff +++ b/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-unwind.diff @@ -20,7 +20,7 @@ StorageLive(_5); StorageLive(_6); _6 = &(*_2); -- _5 = core::slice::::len(move _6) -> bb1; +- _5 = core::slice::::len(move _6) -> [return: bb1, unwind continue]; + _5 = Len((*_6)); + goto -> bb1; } @@ -38,7 +38,7 @@ _7 = _1; _8 = Len((*_2)); _9 = Lt(_7, _8); - assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> bb3; + assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> [success: bb3, unwind continue]; } bb3: { diff --git a/tests/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.panic-unwind.mir b/tests/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.panic-unwind.mir index 568ad441cbcd..6fb107929e6b 100644 --- a/tests/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.panic-unwind.mir +++ b/tests/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.panic-unwind.mir @@ -14,7 +14,7 @@ fn main() -> () { StorageLive(_4); _4 = const ""; _3 = &(*_4); - _2 = ::to_string(move _3) -> bb1; + _2 = ::to_string(move _3) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/nrvo_simple.nrvo.RenameReturnPlace.panic-unwind.diff b/tests/mir-opt/nrvo_simple.nrvo.RenameReturnPlace.panic-unwind.diff index b17675ec1edf..3df8e567f1fe 100644 --- a/tests/mir-opt/nrvo_simple.nrvo.RenameReturnPlace.panic-unwind.diff +++ b/tests/mir-opt/nrvo_simple.nrvo.RenameReturnPlace.panic-unwind.diff @@ -26,7 +26,7 @@ - _6 = &mut _2; + _6 = &mut _0; _5 = &mut (*_6); - _3 = move _4(move _5) -> bb1; + _3 = move _4(move _5) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir index 46c078cea0d6..98c267e8e71e 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir @@ -31,7 +31,7 @@ fn step_forward(_1: u32, _2: usize) -> u32 { StorageLive(_7); StorageLive(_4); StorageLive(_3); - _3 = ::forward_checked(_1, _2) -> bb1; + _3 = ::forward_checked(_1, _2) -> [return: bb1, unwind continue]; } bb1: { @@ -47,7 +47,7 @@ fn step_forward(_1: u32, _2: usize) -> u32 { } bb2: { - assert(!const true, "attempt to compute `{} + {}`, which would overflow", const _, const 1_u32) -> bb3; + assert(!const true, "attempt to compute `{} + {}`, which would overflow", const _, const 1_u32) -> [success: bb3, unwind continue]; } bb3: { diff --git a/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir index b8b2d91adb69..3b49cb711b77 100644 --- a/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir @@ -30,7 +30,7 @@ fn filter_mapped(_1: impl Iterator, _2: impl Fn(T) -> Option) -> () bb0: { StorageLive(_4); StorageLive(_3); - _3 = as Iterator>::filter_map:: Option>(move _1, move _2) -> bb1; + _3 = as Iterator>::filter_map:: Option>(move _1, move _2) -> [return: bb1, unwind continue]; } bb1: { @@ -60,7 +60,7 @@ fn filter_mapped(_1: impl Iterator, _2: impl Fn(T) -> Option) -> () bb4: { StorageDead(_9); - drop(_5) -> bb5; + drop(_5) -> [return: bb5, unwind continue]; } bb5: { diff --git a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir index 609555c8c43e..40bb3a37c585 100644 --- a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir @@ -79,7 +79,7 @@ fn int_range(_1: usize, _2: usize) -> () { bb3: { _12 = ((*_5).0: usize); StorageLive(_13); - _13 = ::forward_unchecked(_12, const 1_usize) -> bb4; + _13 = ::forward_unchecked(_12, const 1_usize) -> [return: bb4, unwind continue]; } bb4: { @@ -104,7 +104,7 @@ fn int_range(_1: usize, _2: usize) -> () { bb7: { _15 = ((_11 as Some).0: usize); - _16 = opaque::(_15) -> bb8; + _16 = opaque::(_15) -> [return: bb8, unwind continue]; } bb8: { diff --git a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir index f756f34b7d66..e4e1d052e733 100644 --- a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir @@ -25,7 +25,7 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { bb0: { StorageLive(_4); StorageLive(_3); - _3 = as Iterator>::map:: U>(move _1, move _2) -> bb1; + _3 = as Iterator>::map:: U>(move _1, move _2) -> [return: bb1, unwind continue]; } bb1: { @@ -49,7 +49,7 @@ fn mapped(_1: impl Iterator, _2: impl Fn(T) -> U) -> () { bb4: { StorageDead(_7); - drop(_5) -> bb5; + drop(_5) -> [return: bb5, unwind continue]; } bb5: { diff --git a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir index 604cb773da57..1b5f2a0884b0 100644 --- a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir @@ -19,7 +19,7 @@ fn vec_move(_1: Vec) -> () { bb0: { StorageLive(_2); - _2 = as IntoIterator>::into_iter(move _1) -> bb1; + _2 = as IntoIterator>::into_iter(move _1) -> [return: bb1, unwind continue]; } bb1: { @@ -41,7 +41,7 @@ fn vec_move(_1: Vec) -> () { bb4: { StorageDead(_5); - drop(_3) -> bb5; + drop(_3) -> [return: bb5, unwind continue]; } bb5: { diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-unwind.diff index a57ce86bc25a..b6929f3f93c6 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-unwind.diff @@ -25,9 +25,9 @@ bb0: { StorageLive(_1); - _2 = CheckedAdd(const 2_i32, const 2_i32); -- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> bb1; +- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue]; + _2 = const (4_i32, false); -+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> bb1; ++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue]; } bb1: { @@ -40,9 +40,9 @@ _5 = const 3_usize; _6 = const 6_usize; - _7 = Lt(_5, _6); -- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb2; +- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind continue]; + _7 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 6_usize, const 3_usize) -> bb2; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 6_usize, const 3_usize) -> [success: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-unwind.diff index a57ce86bc25a..b6929f3f93c6 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-unwind.diff @@ -25,9 +25,9 @@ bb0: { StorageLive(_1); - _2 = CheckedAdd(const 2_i32, const 2_i32); -- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> bb1; +- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue]; + _2 = const (4_i32, false); -+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> bb1; ++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue]; } bb1: { @@ -40,9 +40,9 @@ _5 = const 3_usize; _6 = const 6_usize; - _7 = Lt(_5, _6); -- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb2; +- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind continue]; + _7 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 6_usize, const 3_usize) -> bb2; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 6_usize, const 3_usize) -> [success: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff index 1a5617c7639b..e987969d313a 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.panic-unwind.diff @@ -27,7 +27,7 @@ bb0: { StorageLive(_1); _2 = CheckedAdd(const 2_i32, const 2_i32); - assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> bb1; + assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue]; } bb1: { @@ -39,7 +39,7 @@ _5 = const 3_usize; _6 = Len(_4); _7 = Lt(_5, _6); - assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb2; + assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff index 1a5617c7639b..e987969d313a 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.panic-unwind.diff @@ -27,7 +27,7 @@ bb0: { StorageLive(_1); _2 = CheckedAdd(const 2_i32, const 2_i32); - assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> bb1; + assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue]; } bb1: { @@ -39,7 +39,7 @@ _5 = const 3_usize; _6 = Len(_4); _7 = Lt(_5, _6); - assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb2; + assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir index cf98f2022c5a..fbe16dc3cd47 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -102,7 +102,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb6: { StorageDead(_12); StorageDead(_5); - drop(_3) -> bb7; + drop(_3) -> [return: bb7, unwind continue]; } bb7: { diff --git a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir index a7525b8b9a81..04d6da1d9bd4 100644 --- a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir @@ -52,7 +52,7 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb3: { StorageDead(_7); StorageDead(_5); - drop(_3) -> bb4; + drop(_3) -> [return: bb4, unwind continue]; } bb4: { diff --git a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir index af775b454a7f..fd565fe75ec3 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir @@ -8,7 +8,7 @@ fn range_inclusive_iter_next(_1: &mut RangeInclusive) -> Option { } bb0: { - _0 = as iter::range::RangeInclusiveIteratorImpl>::spec_next(_1) -> bb1; + _0 = as iter::range::RangeInclusiveIteratorImpl>::spec_next(_1) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir index 33752e970d1a..65870f693c06 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.panic-unwind.mir @@ -53,7 +53,7 @@ fn range_iter_next(_1: &mut std::ops::Range) -> Option { bb2: { _7 = ((*_1).0: u32); StorageLive(_8); - _8 = ::forward_unchecked(_7, const 1_usize) -> bb3; + _8 = ::forward_unchecked(_7, const 1_usize) -> [return: bb3, unwind continue]; } bb3: { diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir index 9f7fca639f75..a6b931d2c244 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_index_range.PreCodegen.after.panic-unwind.mir @@ -12,7 +12,7 @@ fn slice_index_range(_1: &[u32], _2: std::ops::Range) -> &[u32] { bb0: { StorageLive(_3); - _3 = as SliceIndex<[u32]>>::index(move _2, _1) -> bb1; + _3 = as SliceIndex<[u32]>>::index(move _2, _1) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_index_usize.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_index_usize.PreCodegen.after.panic-unwind.mir index 13bd84f9596c..d576520a8d56 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_index_usize.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_index_usize.PreCodegen.after.panic-unwind.mir @@ -10,7 +10,7 @@ fn slice_index_usize(_1: &[u32], _2: usize) -> u32 { bb0: { _3 = Len((*_1)); _4 = Lt(_2, _3); - assert(move _4, "index out of bounds: the length is {} but the index is {}", move _3, _2) -> bb1; + assert(move _4, "index out of bounds: the length is {} but the index is {}", move _3, _2) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir index 71162df4bd06..8294a5cb6dc5 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir @@ -164,7 +164,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb6: { StorageDead(_17); StorageDead(_15); - drop(_2) -> bb7; + drop(_2) -> [return: bb7, unwind continue]; } bb7: { diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir index 08d829d52cce..ff40e450968a 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -152,7 +152,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb6: { StorageDead(_16); StorageDead(_14); - drop(_2) -> bb7; + drop(_2) -> [return: bb7, unwind continue]; } bb7: { diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir index 5ce8143d98b3..3423c5d865de 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir @@ -111,7 +111,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { bb6: { StorageDead(_12); StorageDead(_5); - drop(_2) -> bb7; + drop(_2) -> [return: bb7, unwind continue]; } bb7: { diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir index 14ca6004dfe2..b40d9209d253 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir @@ -169,7 +169,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { bb6: { StorageDead(_18); StorageDead(_15); - drop(_2) -> bb7; + drop(_2) -> [return: bb7, unwind continue]; } bb7: { diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir index f9253a321f9c..386f3a9edcd6 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_mut_next_back.PreCodegen.after.panic-unwind.mir @@ -5,7 +5,7 @@ fn slice_iter_mut_next_back(_1: &mut std::slice::IterMut<'_, T>) -> Option<&mut let mut _0: std::option::Option<&mut T>; bb0: { - _0 = as DoubleEndedIterator>::next_back(_1) -> bb1; + _0 = as DoubleEndedIterator>::next_back(_1) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir index 207fc8c752f3..e76ec00391cc 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.slice_iter_next.PreCodegen.after.panic-unwind.mir @@ -5,7 +5,7 @@ fn slice_iter_next(_1: &mut std::slice::Iter<'_, T>) -> Option<&T> { let mut _0: std::option::Option<&T>; bb0: { - _0 = as Iterator>::next(_1) -> bb1; + _0 = as Iterator>::next(_1) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir index 52e85809735e..1e20b1be56b9 100644 --- a/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/spans.outer.PreCodegen.after.panic-unwind.mir @@ -7,7 +7,7 @@ fn outer(_1: u8) -> u8 { bb0: { _2 = &_1; // scope 0 at $DIR/spans.rs:11:11: 11:13 - _0 = inner(_2) -> bb1; // scope 0 at $DIR/spans.rs:11:5: 11:14 + _0 = inner(_2) -> [return: bb1, unwind continue]; // scope 0 at $DIR/spans.rs:11:5: 11:14 // mir::Constant // + span: $DIR/spans.rs:11:5: 11:10 // + literal: Const { ty: for<'a> fn(&'a u8) -> u8 {inner}, val: Value() } diff --git a/tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff b/tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff index 6732f8b4bb3f..132f66a1ad3c 100644 --- a/tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff +++ b/tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff @@ -104,7 +104,7 @@ _13 = &(*_26); StorageLive(_15); _15 = RangeFull; - _12 = <[i32; 10] as Index>::index(move _13, move _15) -> bb5; + _12 = <[i32; 10] as Index>::index(move _13, move _15) -> [return: bb5, unwind continue]; } bb5: { diff --git a/tests/mir-opt/reference_prop.dominate_storage.ReferencePropagation.diff b/tests/mir-opt/reference_prop.dominate_storage.ReferencePropagation.diff index 3baa565f03e4..012efa9693ec 100644 --- a/tests/mir-opt/reference_prop.dominate_storage.ReferencePropagation.diff +++ b/tests/mir-opt/reference_prop.dominate_storage.ReferencePropagation.diff @@ -22,7 +22,7 @@ bb2: { _5 = (*_2); - _0 = opaque::(_5) -> bb3; + _0 = opaque::(_5) -> [return: bb3, unwind continue]; } bb3: { diff --git a/tests/mir-opt/reference_prop.maybe_dead.ReferencePropagation.diff b/tests/mir-opt/reference_prop.maybe_dead.ReferencePropagation.diff index 9ceb5a7634dd..c6bd6c212109 100644 --- a/tests/mir-opt/reference_prop.maybe_dead.ReferencePropagation.diff +++ b/tests/mir-opt/reference_prop.maybe_dead.ReferencePropagation.diff @@ -27,17 +27,17 @@ bb1: { StorageDead(_2); StorageDead(_3); - _0 = opaque::(_6) -> bb2; + _0 = opaque::(_6) -> [return: bb2, unwind continue]; } bb2: { _7 = (*_4); - _0 = opaque::(_7) -> bb3; + _0 = opaque::(_7) -> [return: bb3, unwind continue]; } bb3: { _8 = (*_5); - _0 = opaque::(_8) -> bb4; + _0 = opaque::(_8) -> [return: bb4, unwind continue]; } bb4: { diff --git a/tests/mir-opt/reference_prop.multiple_storage.ReferencePropagation.diff b/tests/mir-opt/reference_prop.multiple_storage.ReferencePropagation.diff index 03add1265450..0fd74155aa30 100644 --- a/tests/mir-opt/reference_prop.multiple_storage.ReferencePropagation.diff +++ b/tests/mir-opt/reference_prop.multiple_storage.ReferencePropagation.diff @@ -14,7 +14,7 @@ StorageDead(_1); StorageLive(_1); _3 = (*_2); - _0 = opaque::(_3) -> bb1; + _0 = opaque::(_3) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/reference_prop.reference_propagation.ReferencePropagation.diff b/tests/mir-opt/reference_prop.reference_propagation.ReferencePropagation.diff index 43292dd7249a..f1f77cffd200 100644 --- a/tests/mir-opt/reference_prop.reference_propagation.ReferencePropagation.diff +++ b/tests/mir-opt/reference_prop.reference_propagation.ReferencePropagation.diff @@ -201,7 +201,7 @@ StorageLive(_7); StorageLive(_8); _8 = (); - _7 = opaque::<()>(move _8) -> bb1; + _7 = opaque::<()>(move _8) -> [return: bb1, unwind continue]; } bb1: { @@ -232,7 +232,7 @@ StorageLive(_16); StorageLive(_17); _17 = (); - _16 = opaque::<()>(move _17) -> bb2; + _16 = opaque::<()>(move _17) -> [return: bb2, unwind continue]; } bb2: { @@ -256,7 +256,7 @@ StorageLive(_23); StorageLive(_24); _24 = _21; - _23 = opaque::<&&usize>(move _24) -> bb3; + _23 = opaque::<&&usize>(move _24) -> [return: bb3, unwind continue]; } bb3: { @@ -280,7 +280,7 @@ StorageLive(_30); StorageLive(_31); _31 = _28; - _30 = opaque::<*mut &usize>(move _31) -> bb4; + _30 = opaque::<*mut &usize>(move _31) -> [return: bb4, unwind continue]; } bb4: { @@ -303,7 +303,7 @@ StorageLive(_36); StorageLive(_37); _37 = _34; - _36 = opaque::<&usize>(move _37) -> bb5; + _36 = opaque::<&usize>(move _37) -> [return: bb5, unwind continue]; } bb5: { @@ -332,7 +332,7 @@ StorageLive(_45); StorageLive(_46); _46 = _44; - _45 = opaque::<&usize>(move _46) -> bb6; + _45 = opaque::<&usize>(move _46) -> [return: bb6, unwind continue]; } bb6: { @@ -355,7 +355,7 @@ StorageLive(_50); StorageLive(_51); _51 = (); - _50 = opaque::<()>(move _51) -> bb7; + _50 = opaque::<()>(move _51) -> [return: bb7, unwind continue]; } bb7: { @@ -381,7 +381,7 @@ StorageLive(_57); StorageLive(_58); _58 = (); - _57 = opaque::<()>(move _58) -> bb8; + _57 = opaque::<()>(move _58) -> [return: bb8, unwind continue]; } bb8: { @@ -404,7 +404,7 @@ StorageLive(_64); StorageLive(_65); _65 = (); - _64 = opaque::<()>(move _65) -> bb9; + _64 = opaque::<()>(move _65) -> [return: bb9, unwind continue]; } bb9: { @@ -428,7 +428,7 @@ StorageLive(_70); StorageLive(_71); _71 = (); - _70 = opaque::<()>(move _71) -> bb10; + _70 = opaque::<()>(move _71) -> [return: bb10, unwind continue]; } bb10: { diff --git a/tests/mir-opt/reference_prop.reference_propagation_const_ptr.ReferencePropagation.diff b/tests/mir-opt/reference_prop.reference_propagation_const_ptr.ReferencePropagation.diff index 3a317853bdb7..05eab7989dfb 100644 --- a/tests/mir-opt/reference_prop.reference_propagation_const_ptr.ReferencePropagation.diff +++ b/tests/mir-opt/reference_prop.reference_propagation_const_ptr.ReferencePropagation.diff @@ -242,7 +242,7 @@ StorageLive(_7); StorageLive(_8); _8 = (); - _7 = opaque::<()>(move _8) -> bb1; + _7 = opaque::<()>(move _8) -> [return: bb1, unwind continue]; } bb1: { @@ -269,7 +269,7 @@ StorageLive(_15); StorageLive(_16); _16 = (); - _15 = opaque::<()>(move _16) -> bb2; + _15 = opaque::<()>(move _16) -> [return: bb2, unwind continue]; } bb2: { @@ -293,7 +293,7 @@ StorageLive(_22); StorageLive(_23); _23 = _20; - _22 = opaque::<&*const usize>(move _23) -> bb3; + _22 = opaque::<&*const usize>(move _23) -> [return: bb3, unwind continue]; } bb3: { @@ -317,7 +317,7 @@ StorageLive(_29); StorageLive(_30); _30 = _27; - _29 = opaque::<*mut *const usize>(move _30) -> bb4; + _29 = opaque::<*mut *const usize>(move _30) -> [return: bb4, unwind continue]; } bb4: { @@ -340,7 +340,7 @@ StorageLive(_35); StorageLive(_36); _36 = _33; - _35 = opaque::<*const usize>(move _36) -> bb5; + _35 = opaque::<*const usize>(move _36) -> [return: bb5, unwind continue]; } bb5: { @@ -369,7 +369,7 @@ StorageLive(_44); StorageLive(_45); _45 = _43; - _44 = opaque::<*const usize>(move _45) -> bb6; + _44 = opaque::<*const usize>(move _45) -> [return: bb6, unwind continue]; } bb6: { @@ -392,7 +392,7 @@ StorageLive(_49); StorageLive(_50); _50 = (); - _49 = opaque::<()>(move _50) -> bb7; + _49 = opaque::<()>(move _50) -> [return: bb7, unwind continue]; } bb7: { @@ -414,7 +414,7 @@ StorageLive(_55); StorageLive(_56); _56 = (); - _55 = opaque::<()>(move _56) -> bb8; + _55 = opaque::<()>(move _56) -> [return: bb8, unwind continue]; } bb8: { @@ -437,7 +437,7 @@ StorageLive(_62); StorageLive(_63); _63 = (); - _62 = opaque::<()>(move _63) -> bb9; + _62 = opaque::<()>(move _63) -> [return: bb9, unwind continue]; } bb9: { @@ -462,7 +462,7 @@ StorageLive(_69); StorageLive(_70); _70 = (); - _69 = opaque::<()>(move _70) -> bb10; + _69 = opaque::<()>(move _70) -> [return: bb10, unwind continue]; } bb10: { @@ -486,7 +486,7 @@ StorageLive(_75); StorageLive(_76); _76 = (); - _75 = opaque::<()>(move _76) -> bb11; + _75 = opaque::<()>(move _76) -> [return: bb11, unwind continue]; } bb11: { diff --git a/tests/mir-opt/reference_prop.reference_propagation_mut.ReferencePropagation.diff b/tests/mir-opt/reference_prop.reference_propagation_mut.ReferencePropagation.diff index 91c6b2b63220..ee680fdb3f21 100644 --- a/tests/mir-opt/reference_prop.reference_propagation_mut.ReferencePropagation.diff +++ b/tests/mir-opt/reference_prop.reference_propagation_mut.ReferencePropagation.diff @@ -201,7 +201,7 @@ StorageLive(_7); StorageLive(_8); _8 = (); - _7 = opaque::<()>(move _8) -> bb1; + _7 = opaque::<()>(move _8) -> [return: bb1, unwind continue]; } bb1: { @@ -232,7 +232,7 @@ StorageLive(_16); StorageLive(_17); _17 = (); - _16 = opaque::<()>(move _17) -> bb2; + _16 = opaque::<()>(move _17) -> [return: bb2, unwind continue]; } bb2: { @@ -256,7 +256,7 @@ StorageLive(_23); StorageLive(_24); _24 = _21; - _23 = opaque::<&&mut usize>(move _24) -> bb3; + _23 = opaque::<&&mut usize>(move _24) -> [return: bb3, unwind continue]; } bb3: { @@ -280,7 +280,7 @@ StorageLive(_30); StorageLive(_31); _31 = _28; - _30 = opaque::<*mut &mut usize>(move _31) -> bb4; + _30 = opaque::<*mut &mut usize>(move _31) -> [return: bb4, unwind continue]; } bb4: { @@ -302,7 +302,7 @@ StorageLive(_36); StorageLive(_37); _37 = move _34; - _36 = opaque::<&mut usize>(move _37) -> bb5; + _36 = opaque::<&mut usize>(move _37) -> [return: bb5, unwind continue]; } bb5: { @@ -329,7 +329,7 @@ StorageLive(_45); StorageLive(_46); _46 = move _44; - _45 = opaque::<&mut usize>(move _46) -> bb6; + _45 = opaque::<&mut usize>(move _46) -> [return: bb6, unwind continue]; } bb6: { @@ -352,7 +352,7 @@ StorageLive(_50); StorageLive(_51); _51 = (); - _50 = opaque::<()>(move _51) -> bb7; + _50 = opaque::<()>(move _51) -> [return: bb7, unwind continue]; } bb7: { @@ -378,7 +378,7 @@ StorageLive(_57); StorageLive(_58); _58 = (); - _57 = opaque::<()>(move _58) -> bb8; + _57 = opaque::<()>(move _58) -> [return: bb8, unwind continue]; } bb8: { @@ -401,7 +401,7 @@ StorageLive(_64); StorageLive(_65); _65 = (); - _64 = opaque::<()>(move _65) -> bb9; + _64 = opaque::<()>(move _65) -> [return: bb9, unwind continue]; } bb9: { @@ -425,7 +425,7 @@ StorageLive(_70); StorageLive(_71); _71 = (); - _70 = opaque::<()>(move _71) -> bb10; + _70 = opaque::<()>(move _71) -> [return: bb10, unwind continue]; } bb10: { diff --git a/tests/mir-opt/reference_prop.reference_propagation_mut_ptr.ReferencePropagation.diff b/tests/mir-opt/reference_prop.reference_propagation_mut_ptr.ReferencePropagation.diff index 8c669644c48a..fb0ef3184f00 100644 --- a/tests/mir-opt/reference_prop.reference_propagation_mut_ptr.ReferencePropagation.diff +++ b/tests/mir-opt/reference_prop.reference_propagation_mut_ptr.ReferencePropagation.diff @@ -219,7 +219,7 @@ StorageLive(_7); StorageLive(_8); _8 = (); - _7 = opaque::<()>(move _8) -> bb1; + _7 = opaque::<()>(move _8) -> [return: bb1, unwind continue]; } bb1: { @@ -246,7 +246,7 @@ StorageLive(_15); StorageLive(_16); _16 = (); - _15 = opaque::<()>(move _16) -> bb2; + _15 = opaque::<()>(move _16) -> [return: bb2, unwind continue]; } bb2: { @@ -270,7 +270,7 @@ StorageLive(_22); StorageLive(_23); _23 = _20; - _22 = opaque::<&*mut usize>(move _23) -> bb3; + _22 = opaque::<&*mut usize>(move _23) -> [return: bb3, unwind continue]; } bb3: { @@ -294,7 +294,7 @@ StorageLive(_29); StorageLive(_30); _30 = _27; - _29 = opaque::<*mut *mut usize>(move _30) -> bb4; + _29 = opaque::<*mut *mut usize>(move _30) -> [return: bb4, unwind continue]; } bb4: { @@ -316,7 +316,7 @@ StorageLive(_35); StorageLive(_36); _36 = _33; - _35 = opaque::<*mut usize>(move _36) -> bb5; + _35 = opaque::<*mut usize>(move _36) -> [return: bb5, unwind continue]; } bb5: { @@ -343,7 +343,7 @@ StorageLive(_44); StorageLive(_45); _45 = _43; - _44 = opaque::<*mut usize>(move _45) -> bb6; + _44 = opaque::<*mut usize>(move _45) -> [return: bb6, unwind continue]; } bb6: { @@ -366,7 +366,7 @@ StorageLive(_49); StorageLive(_50); _50 = (); - _49 = opaque::<()>(move _50) -> bb7; + _49 = opaque::<()>(move _50) -> [return: bb7, unwind continue]; } bb7: { @@ -388,7 +388,7 @@ StorageLive(_55); StorageLive(_56); _56 = (); - _55 = opaque::<()>(move _56) -> bb8; + _55 = opaque::<()>(move _56) -> [return: bb8, unwind continue]; } bb8: { @@ -411,7 +411,7 @@ StorageLive(_62); StorageLive(_63); _63 = (); - _62 = opaque::<()>(move _63) -> bb9; + _62 = opaque::<()>(move _63) -> [return: bb9, unwind continue]; } bb9: { @@ -435,7 +435,7 @@ StorageLive(_68); StorageLive(_69); _69 = (); - _68 = opaque::<()>(move _69) -> bb10; + _68 = opaque::<()>(move _69) -> [return: bb10, unwind continue]; } bb10: { diff --git a/tests/mir-opt/reference_prop.unique_with_copies.ReferencePropagation.diff b/tests/mir-opt/reference_prop.unique_with_copies.ReferencePropagation.diff index b4c34c07022b..b4912a918ba4 100644 --- a/tests/mir-opt/reference_prop.unique_with_copies.ReferencePropagation.diff +++ b/tests/mir-opt/reference_prop.unique_with_copies.ReferencePropagation.diff @@ -34,7 +34,7 @@ StorageLive(_4); StorageLive(_5); _5 = (*_3); - _4 = opaque::(move _5) -> bb1; + _4 = opaque::(move _5) -> [return: bb1, unwind continue]; } bb1: { @@ -47,7 +47,7 @@ StorageLive(_7); - _7 = (*_1); + _7 = (*_3); - _6 = opaque::(move _7) -> bb2; + _6 = opaque::(move _7) -> [return: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-unwind.diff b/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-unwind.diff index d7f867e31dde..faaebc300efa 100644 --- a/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-unwind.diff +++ b/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-unwind.diff @@ -32,7 +32,7 @@ - StorageLive(_2); - StorageLive(_3); _3 = std::ops::Range:: { start: const 0_i32, end: const 10_i32 }; - _2 = as IntoIterator>::into_iter(move _3) -> bb1; + _2 = as IntoIterator>::into_iter(move _3) -> [return: bb1, unwind continue]; } bb1: { @@ -49,7 +49,7 @@ - StorageLive(_9); _9 = &mut _4; _8 = &mut (*_9); - _7 = as Iterator>::next(move _8) -> bb3; + _7 = as Iterator>::next(move _8) -> [return: bb3, unwind continue]; } bb3: { diff --git a/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-unwind.diff b/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-unwind.diff index 8cb773e48076..a335e8853f38 100644 --- a/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-unwind.diff +++ b/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.panic-unwind.diff @@ -14,7 +14,7 @@ - nop; StorageLive(_3); _3 = _1; -- drop(_3) -> bb1; +- drop(_3) -> [return: bb1, unwind continue]; - } - - bb1: { diff --git a/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-unwind.diff b/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-unwind.diff index d189e5879820..1f7a6f9ad59f 100644 --- a/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-unwind.diff +++ b/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-unwind.diff @@ -14,7 +14,7 @@ - nop; StorageLive(_3); _3 = _1; -- drop(_3) -> bb1; +- drop(_3) -> [return: bb1, unwind continue]; - } - - bb1: { diff --git a/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-unwind.mir b/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-unwind.mir index 18eb21d6542e..93f14af29b4e 100644 --- a/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-unwind.mir +++ b/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-unwind.mir @@ -76,7 +76,7 @@ fn array_casts() -> () { StorageLive(_6); StorageLive(_7); _7 = _2; - _6 = ptr::mut_ptr::::add(move _7, const 1_usize) -> bb1; + _6 = ptr::mut_ptr::::add(move _7, const 1_usize) -> [return: bb1, unwind continue]; } bb1: { @@ -102,7 +102,7 @@ fn array_casts() -> () { StorageLive(_16); StorageLive(_17); _17 = _9; - _16 = ptr::const_ptr::::add(move _17, const 1_usize) -> bb2; + _16 = ptr::const_ptr::::add(move _17, const 1_usize) -> [return: bb2, unwind continue]; } bb2: { @@ -154,7 +154,7 @@ fn array_casts() -> () { StorageLive(_34); _34 = Option::>::None; Retag(_34); - _28 = core::panicking::assert_failed::(move _29, move _30, move _32, move _34); + _28 = core::panicking::assert_failed::(move _29, move _30, move _32, move _34) -> unwind continue; } bb4: { diff --git a/tests/mir-opt/retag.core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.panic-unwind.mir b/tests/mir-opt/retag.core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.panic-unwind.mir index 96d2abf98b4f..70c53bafa373 100644 --- a/tests/mir-opt/retag.core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.panic-unwind.mir +++ b/tests/mir-opt/retag.core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.panic-unwind.mir @@ -10,7 +10,7 @@ fn std::ptr::drop_in_place(_1: *mut Test) -> () { _2 = &mut (*_1); Retag([fn entry] _2); _3 = &mut (*_2); - _4 = ::drop(move _3) -> bb1; + _4 = ::drop(move _3) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir b/tests/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir index 483485f2942e..450349463287 100644 --- a/tests/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir +++ b/tests/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir @@ -114,7 +114,7 @@ fn main() -> () { StorageLive(_18); _18 = &_1; _17 = &(*_18); - _15 = move _16(move _17) -> bb3; + _15 = move _16(move _17) -> [return: bb3, unwind continue]; } bb3: { @@ -153,7 +153,7 @@ fn main() -> () { _25 = _26; StorageDead(_26); StorageLive(_27); - _27 = array_casts() -> bb6; + _27 = array_casts() -> [return: bb6, unwind continue]; } bb6: { diff --git a/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff b/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff index 2a841f72ba39..81903c64dbd4 100644 --- a/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff +++ b/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff @@ -14,7 +14,7 @@ } bb1: { - _2 = noop() -> bb2; + _2 = noop() -> [return: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-unwind.diff b/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-unwind.diff index ef3a923fd696..ba5262b0ee14 100644 --- a/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-unwind.diff +++ b/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-unwind.diff @@ -39,7 +39,7 @@ } bb3: { - drop(_1) -> bb4; + drop(_1) -> [return: bb4, unwind continue]; } bb4: { diff --git a/tests/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.panic-unwind.diff b/tests/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.panic-unwind.diff index dca516020214..a5d9bbc49af0 100644 --- a/tests/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.panic-unwind.diff +++ b/tests/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.panic-unwind.diff @@ -36,7 +36,7 @@ + _2 = (move _3, move _4); + StorageDead(_4); StorageDead(_3); -+ _1 = use_zst(move _2) -> bb1; ++ _1 = use_zst(move _2) -> [return: bb1, unwind continue]; + } + + bb1: { @@ -55,8 +55,8 @@ + _6 = Add(move _7, const 2_u8); StorageDead(_7); - StorageDead(_6); -- _4 = use_zst(move _5) -> bb1; -+ _5 = use_u8(move _6) -> bb2; +- _4 = use_zst(move _5) -> [return: bb1, unwind continue]; ++ _5 = use_u8(move _6) -> [return: bb2, unwind continue]; } - bb1: { @@ -70,7 +70,7 @@ - _10 = (_11.0: u8); - _9 = Add(move _10, const 2_u8); - StorageDead(_10); -- _8 = use_u8(move _9) -> bb2; +- _8 = use_u8(move _9) -> [return: bb2, unwind continue]; - } - bb2: { diff --git a/tests/mir-opt/simplify_match.main.ConstProp.panic-unwind.diff b/tests/mir-opt/simplify_match.main.ConstProp.panic-unwind.diff index dc2f75ec9b28..c881dec28c77 100644 --- a/tests/mir-opt/simplify_match.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/simplify_match.main.ConstProp.panic-unwind.diff @@ -20,7 +20,7 @@ } bb2: { - _0 = noop() -> bb3; + _0 = noop() -> [return: bb3, unwind continue]; } bb3: { diff --git a/tests/mir-opt/unreachable.main.UnreachablePropagation.panic-unwind.diff b/tests/mir-opt/unreachable.main.UnreachablePropagation.panic-unwind.diff index 19ea846bf2ce..906dce9819fd 100644 --- a/tests/mir-opt/unreachable.main.UnreachablePropagation.panic-unwind.diff +++ b/tests/mir-opt/unreachable.main.UnreachablePropagation.panic-unwind.diff @@ -19,7 +19,7 @@ bb0: { StorageLive(_1); - _1 = empty() -> bb1; + _1 = empty() -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.panic-unwind.diff b/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.panic-unwind.diff index 9d54a2f234b1..a0479fb91304 100644 --- a/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.panic-unwind.diff +++ b/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.panic-unwind.diff @@ -21,7 +21,7 @@ StorageLive(_1); _1 = const true; StorageLive(_2); - _2 = empty() -> bb1; + _2 = empty() -> [return: bb1, unwind continue]; } bb1: { @@ -39,7 +39,7 @@ } bb3: { - _5 = loop_forever() -> bb5; + _5 = loop_forever() -> [return: bb5, unwind continue]; } bb4: { diff --git a/tests/mir-opt/while_storage.while_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/while_storage.while_loop.PreCodegen.after.panic-unwind.mir index ec4782e5f3c7..7dc4f7ab1a87 100644 --- a/tests/mir-opt/while_storage.while_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/while_storage.while_loop.PreCodegen.after.panic-unwind.mir @@ -12,7 +12,7 @@ fn while_loop(_1: bool) -> () { bb1: { StorageLive(_2); - _2 = get_bool(_1) -> bb2; + _2 = get_bool(_1) -> [return: bb2, unwind continue]; } bb2: { @@ -21,7 +21,7 @@ fn while_loop(_1: bool) -> () { bb3: { StorageLive(_3); - _3 = get_bool(_1) -> bb4; + _3 = get_bool(_1) -> [return: bb4, unwind continue]; } bb4: { diff --git a/tests/run-make/const_fn_mir/dump.mir b/tests/run-make/const_fn_mir/dump.mir index 25ac0c7e852a..ced170bbeee2 100644 --- a/tests/run-make/const_fn_mir/dump.mir +++ b/tests/run-make/const_fn_mir/dump.mir @@ -6,7 +6,7 @@ fn foo() -> i32 { bb0: { _1 = CheckedAdd(const 5_i32, const 6_i32); - assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 5_i32, const 6_i32) -> bb1; + assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 5_i32, const 6_i32) -> [success: bb1, unwind continue]; } bb1: { @@ -22,7 +22,7 @@ fn foo() -> i32 { bb0: { _1 = CheckedAdd(const 5_i32, const 6_i32); - assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 5_i32, const 6_i32) -> bb1; + assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 5_i32, const 6_i32) -> [success: bb1, unwind continue]; } bb1: { @@ -36,7 +36,7 @@ fn main() -> () { let _1: i32; bb0: { - _1 = foo() -> bb1; + _1 = foo() -> [return: bb1, unwind continue]; } bb1: { From 5f433f33ed8d4a8ede25c36d2bb0543e8b101920 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Fri, 23 Jun 2023 12:02:55 -0700 Subject: [PATCH 039/103] Reduce typename width to 6.25rem This makes "existential type" look slightly cramped (though still readable), but it makes all other typenames look better. Existential types are currently very rare, and we can always tweak this later if necessary. --- src/librustdoc/html/static/css/rustdoc.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index b4ee3482de39..b6d90091bbae 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -894,7 +894,7 @@ so that we can apply CSS-filters to change the arrow color in themes */ display: inline-block; color: var(--search-results-grey-color); font-size: 0.875rem; - width: 7rem; + width: 6.25rem; } .popover { From 2cc7782cfd85a2c4dc2fa566fae4d4e356976471 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Fri, 23 Jun 2023 19:18:18 +0000 Subject: [PATCH 040/103] Add suggestion for bad block fragment error --- compiler/rustc_parse/messages.ftl | 1 + compiler/rustc_parse/src/errors.rs | 11 +++++++++++ compiler/rustc_parse/src/parser/expr.rs | 4 ++++ tests/ui/parser/bad-interpolated-block.stderr | 12 ++++++++++++ tests/ui/parser/labeled-no-colon-expr.stderr | 4 ++++ 5 files changed, 32 insertions(+) diff --git a/compiler/rustc_parse/messages.ftl b/compiler/rustc_parse/messages.ftl index 35eec2c8e1b1..9787d98c1a49 100644 --- a/compiler/rustc_parse/messages.ftl +++ b/compiler/rustc_parse/messages.ftl @@ -353,6 +353,7 @@ parse_int_literal_too_large = integer literal is too large parse_invalid_block_macro_segment = cannot use a `block` macro fragment here .label = the `block` fragment is within this context + .suggestion = wrap this in another block parse_invalid_char_in_escape = {parse_invalid_char_in_escape_msg}: `{$ch}` .label = {parse_invalid_char_in_escape_msg} diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index 84494eab855c..96e1c0e3c6d9 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -333,6 +333,17 @@ pub(crate) struct InvalidBlockMacroSegment { pub span: Span, #[label] pub context: Span, + #[subdiagnostic] + pub wrap: WrapInExplicitBlock, +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(parse_suggestion, applicability = "machine-applicable")] +pub(crate) struct WrapInExplicitBlock { + #[suggestion_part(code = "{{ ")] + pub lo: Span, + #[suggestion_part(code = " }}")] + pub hi: Span, } #[derive(Diagnostic)] diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 88c6cc1ae707..1b3d4e301a92 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -2186,6 +2186,10 @@ impl<'a> Parser<'a> { self.sess.emit_err(errors::InvalidBlockMacroSegment { span: self.token.span, context: lo.to(self.token.span), + wrap: errors::WrapInExplicitBlock { + lo: self.token.span.shrink_to_lo(), + hi: self.token.span.shrink_to_hi(), + }, }); } diff --git a/tests/ui/parser/bad-interpolated-block.stderr b/tests/ui/parser/bad-interpolated-block.stderr index 2a0999afdfaf..651036c51c94 100644 --- a/tests/ui/parser/bad-interpolated-block.stderr +++ b/tests/ui/parser/bad-interpolated-block.stderr @@ -10,6 +10,10 @@ LL | m!({}); | ------ in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) +help: wrap this in another block + | +LL | 'lab: { $b }; + | + + error: cannot use a `block` macro fragment here --> $DIR/bad-interpolated-block.rs:6:16 @@ -23,6 +27,10 @@ LL | m!({}); | ------ in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) +help: wrap this in another block + | +LL | unsafe { $b }; + | + + error: cannot use a `block` macro fragment here --> $DIR/bad-interpolated-block.rs:7:23 @@ -34,6 +42,10 @@ LL | m!({}); | ------ in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) +help: wrap this in another block + | +LL | |x: u8| -> () { $b }; + | + + error: aborting due to 3 previous errors diff --git a/tests/ui/parser/labeled-no-colon-expr.stderr b/tests/ui/parser/labeled-no-colon-expr.stderr index 62288fe152da..4d61d9c14034 100644 --- a/tests/ui/parser/labeled-no-colon-expr.stderr +++ b/tests/ui/parser/labeled-no-colon-expr.stderr @@ -77,6 +77,10 @@ LL | m!({}); | ------ in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) +help: wrap this in another block + | +LL | 'l5 { $b }; + | + + error: labeled expression must be followed by `:` --> $DIR/labeled-no-colon-expr.rs:14:8 From 7d2373e48f9fe91520c3a15cd5cd8bd0820b276f Mon Sep 17 00:00:00 2001 From: jyn Date: Sun, 4 Jun 2023 12:10:45 -0500 Subject: [PATCH 041/103] Fix progress messages for configure in bootstrap_test.py Before it would unconditionally print `configure-args = []`. --- src/bootstrap/configure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index a16f77317c82..76a153b60a30 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -280,7 +280,7 @@ def parse_args(args): config = {} - set('build.configure-args', sys.argv[1:], config) + set('build.configure-args', args, config) apply_args(known_args, option_checking, config) return parse_example_config(known_args, config) From 3508cde815941317a8a5ee81c8de9c9854fdb53a Mon Sep 17 00:00:00 2001 From: jyn Date: Sun, 4 Jun 2023 12:16:49 -0500 Subject: [PATCH 042/103] Allow passing arguments to `bootstrap_test.py` Previous, it used the built-in test runner, which doesn't support options unless they're manually passed in the script. --- src/bootstrap/bootstrap_test.py | 16 +++------------- src/bootstrap/test.rs | 7 ++++++- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/bootstrap/bootstrap_test.py b/src/bootstrap/bootstrap_test.py index 5ecda83ee66b..a0c296dc19cc 100644 --- a/src/bootstrap/bootstrap_test.py +++ b/src/bootstrap/bootstrap_test.py @@ -1,4 +1,6 @@ -"""Bootstrap tests""" +"""Bootstrap tests + +Run these with `x test bootstrap`, or `python -m unittest bootstrap_test.py`.""" from __future__ import absolute_import, division, print_function import os @@ -120,15 +122,3 @@ class GenerateAndParseConfig(unittest.TestCase): build = self.serialize_and_parse(["--enable-full-tools"]) self.assertNotEqual(build.config_toml.find("codegen-backends = ['llvm']"), -1) -if __name__ == '__main__': - SUITE = unittest.TestSuite() - TEST_LOADER = unittest.TestLoader() - SUITE.addTest(doctest.DocTestSuite(bootstrap)) - SUITE.addTests([ - TEST_LOADER.loadTestsFromTestCase(VerifyTestCase), - TEST_LOADER.loadTestsFromTestCase(GenerateAndParseConfig), - TEST_LOADER.loadTestsFromTestCase(ProgramOutOfDate)]) - - RUNNER = unittest.TextTestRunner(stream=sys.stdout, verbosity=2) - result = RUNNER.run(SUITE) - sys.exit(0 if result.wasSuccessful() else 1) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 873ed61daf33..9cc5a69b920e 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -2664,7 +2664,12 @@ impl Step for Bootstrap { /// Tests the build system itself. fn run(self, builder: &Builder<'_>) { let mut check_bootstrap = Command::new(&builder.python()); - check_bootstrap.arg("bootstrap_test.py").current_dir(builder.src.join("src/bootstrap/")); + check_bootstrap + .arg("-m") + .arg("unittest") + .arg("bootstrap_test.py") + .current_dir(builder.src.join("src/bootstrap/")) + .args(builder.config.test_args()); try_run(builder, &mut check_bootstrap).unwrap(); let host = builder.config.build; From c5820b50c558943f83a7f8d531f5e96da59989bc Mon Sep 17 00:00:00 2001 From: jyn Date: Sun, 4 Jun 2023 12:22:45 -0500 Subject: [PATCH 043/103] Test cargo arguments passed by bootstrap.py This moves a lot of code around, but the logic itself is not too terribly complicated. - Move almost all logic in `def bootstrap` to the `RustBuild` class, to avoid mixing setting configuration with running commands - Update various doctests to the new (more complete) RustBuild config. In particular, don't pretend that `bin_root` supports `build` being unset. - Change `parse_args` not to use a global, to allow testing it - Set BUILD_DIR appropriately so bootstrap.py doesn't panic because cargo isn't found --- src/bootstrap/bootstrap.py | 123 ++++++++++++++++---------------- src/bootstrap/bootstrap_test.py | 76 +++++++++++++------- src/bootstrap/test.rs | 5 +- 3 files changed, 117 insertions(+), 87 deletions(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 5714613cdf51..9b8fdd38d22a 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -458,23 +458,52 @@ def unpack_component(download_info): verbose=download_info.verbose, ) -class RustBuild(object): - """Provide all the methods required to build Rust""" +class FakeArgs: + """Used for unit tests to avoid updating all call sites""" def __init__(self): - self.checksums_sha256 = {} - self.stage0_compiler = None - self.download_url = '' self.build = '' self.build_dir = '' self.clean = False - self.config_toml = '' - self.rust_root = '' - self.use_locked_deps = False - self.use_vendored_sources = False self.verbose = False + self.json_output = False + +class RustBuild(object): + """Provide all the methods required to build Rust""" + def __init__(self, config_toml="", args=FakeArgs()): self.git_version = None self.nix_deps_dir = None self._should_fix_bins_and_dylibs = None + self.rust_root = os.path.abspath(os.path.join(__file__, '../../..')) + + self.config_toml = config_toml + + self.verbose = args.verbose != 0 + self.clean = args.clean + self.json_output = args.json_output + + profile = self.get_toml('profile') + if profile is not None: + include_file = 'config.{}.toml'.format(profile) + include_dir = os.path.join(self.rust_root, 'src', 'bootstrap', 'defaults') + include_path = os.path.join(include_dir, include_file) + # HACK: This works because `self.get_toml()` returns the first match it finds for a + # specific key, so appending our defaults at the end allows the user to override them + with open(include_path) as included_toml: + self.config_toml += os.linesep + included_toml.read() + + self.use_vendored_sources = self.get_toml('vendor', 'build') == 'true' + self.use_locked_deps = self.get_toml('locked-deps', 'build') == 'true' + + build_dir = args.build_dir or self.get_toml('build-dir', 'build') or 'build' + self.build_dir = os.path.abspath(build_dir) + + with open(os.path.join(self.rust_root, "src", "stage0.json")) as f: + data = json.load(f) + self.checksums_sha256 = data["checksums_sha256"] + self.stage0_compiler = Stage0Toolchain(data["compiler"]) + self.download_url = os.getenv("RUSTUP_DIST_SERVER") or data["config"]["dist_server"] + + self.build = args.build or self.build_triple() def download_toolchain(self): """Fetch the build system for Rust, written in Rust @@ -704,9 +733,10 @@ class RustBuild(object): """Return the path for .rustc-stamp at the given stage >>> rb = RustBuild() + >>> rb.build = "host" >>> rb.build_dir = "build" - >>> rb.rustc_stamp() == os.path.join("build", "stage0", ".rustc-stamp") - True + >>> expected = os.path.join("build", "host", "stage0", ".rustc-stamp") + >>> assert rb.rustc_stamp() == expected, rb.rustc_stamp() """ return os.path.join(self.bin_root(), '.rustc-stamp') @@ -721,15 +751,9 @@ class RustBuild(object): """Return the binary root directory for the given stage >>> rb = RustBuild() - >>> rb.build_dir = "build" - >>> rb.bin_root() == os.path.join("build", "stage0") - True - - When the 'build' property is given should be a nested directory: - >>> rb.build = "devel" - >>> rb.bin_root() == os.path.join("build", "devel", "stage0") - True + >>> expected = os.path.abspath(os.path.join("build", "devel", "stage0")) + >>> assert rb.bin_root() == expected, rb.bin_root() """ subdir = "stage0" return os.path.join(self.build_dir, self.build, subdir) @@ -842,6 +866,16 @@ class RustBuild(object): print("::group::Building bootstrap") else: print("Building bootstrap", file=sys.stderr) + + args = self.build_bootstrap_cmd(env, color, warnings, verbose_count) + # Run this from the source directory so cargo finds .cargo/config + run(args, env=env, verbose=self.verbose, cwd=self.rust_root) + + if "GITHUB_ACTIONS" in env: + print("::endgroup::") + + def build_bootstrap_cmd(self, env, color, warnings, verbose_count): + """For tests.""" build_dir = os.path.join(self.build_dir, "bootstrap") if self.clean and os.path.exists(build_dir): shutil.rmtree(build_dir) @@ -927,11 +961,7 @@ class RustBuild(object): except KeyError: pass - # Run this from the source directory so cargo finds .cargo/config - run(args, env=env, verbose=self.verbose, cwd=self.rust_root) - - if "GITHUB_ACTIONS" in env: - print("::endgroup::") + return args def build_triple(self): """Build triple as in LLVM @@ -981,7 +1011,7 @@ class RustBuild(object): if os.path.exists(cargo_dir): shutil.rmtree(cargo_dir) -def parse_args(): +def parse_args(args): """Parse the command line arguments that the python script needs.""" parser = argparse.ArgumentParser(add_help=False) parser.add_argument('-h', '--help', action='store_true') @@ -994,16 +1024,11 @@ def parse_args(): parser.add_argument('--warnings', choices=['deny', 'warn', 'default'], default='default') parser.add_argument('-v', '--verbose', action='count', default=0) - return parser.parse_known_args(sys.argv)[0] + return parser.parse_known_args(args)[0] def bootstrap(args): """Configure, fetch, build and run the initial bootstrap""" - # Configure initial bootstrap - build = RustBuild() - build.rust_root = os.path.abspath(os.path.join(__file__, '../../..')) - build.verbose = args.verbose != 0 - build.clean = args.clean - build.json_output = args.json_output + rust_root = os.path.abspath(os.path.join(__file__, '../../..')) # Read from `--config`, then `RUST_BOOTSTRAP_CONFIG`, then `./config.toml`, # then `config.toml` in the root directory. @@ -1012,45 +1037,23 @@ def bootstrap(args): if using_default_path: toml_path = 'config.toml' if not os.path.exists(toml_path): - toml_path = os.path.join(build.rust_root, toml_path) + toml_path = os.path.join(rust_root, toml_path) # Give a hard error if `--config` or `RUST_BOOTSTRAP_CONFIG` are set to a missing path, # but not if `config.toml` hasn't been created. if not using_default_path or os.path.exists(toml_path): with open(toml_path) as config: - build.config_toml = config.read() + config_toml = config.read() - profile = build.get_toml('profile') - if profile is not None: - include_file = 'config.{}.toml'.format(profile) - include_dir = os.path.join(build.rust_root, 'src', 'bootstrap', 'defaults') - include_path = os.path.join(include_dir, include_file) - # HACK: This works because `build.get_toml()` returns the first match it finds for a - # specific key, so appending our defaults at the end allows the user to override them - with open(include_path) as included_toml: - build.config_toml += os.linesep + included_toml.read() + # Configure initial bootstrap + build = RustBuild(config_toml, args) + build.check_vendored_status() verbose_count = args.verbose config_verbose_count = build.get_toml('verbose', 'build') if config_verbose_count is not None: verbose_count = max(args.verbose, int(config_verbose_count)) - build.use_vendored_sources = build.get_toml('vendor', 'build') == 'true' - build.use_locked_deps = build.get_toml('locked-deps', 'build') == 'true' - - build.check_vendored_status() - - build_dir = args.build_dir or build.get_toml('build-dir', 'build') or 'build' - build.build_dir = os.path.abspath(build_dir) - - with open(os.path.join(build.rust_root, "src", "stage0.json")) as f: - data = json.load(f) - build.checksums_sha256 = data["checksums_sha256"] - build.stage0_compiler = Stage0Toolchain(data["compiler"]) - build.download_url = os.getenv("RUSTUP_DIST_SERVER") or data["config"]["dist_server"] - - build.build = args.build or build.build_triple() - if not os.path.exists(build.build_dir): os.makedirs(build.build_dir) @@ -1077,7 +1080,7 @@ def main(): if len(sys.argv) > 1 and sys.argv[1] == 'help': sys.argv[1] = '-h' - args = parse_args() + args = parse_args(sys.argv) help_triggered = args.help or len(sys.argv) == 1 # If the user is asking for help, let them know that the whole download-and-build diff --git a/src/bootstrap/bootstrap_test.py b/src/bootstrap/bootstrap_test.py index a0c296dc19cc..6854aafa1c04 100644 --- a/src/bootstrap/bootstrap_test.py +++ b/src/bootstrap/bootstrap_test.py @@ -15,6 +15,23 @@ from shutil import rmtree import bootstrap import configure +def serialize_and_parse(args): + from io import StringIO + + section_order, sections, targets = configure.parse_args(args) + buffer = StringIO() + configure.write_config_toml(buffer, section_order, targets, sections) + build = bootstrap.RustBuild() + build.config_toml = buffer.getvalue() + + try: + import tomllib + # Verify this is actually valid TOML. + tomllib.loads(build.config_toml) + except ImportError: + print("warning: skipping TOML validation, need at least python 3.11", file=sys.stderr) + return build + class VerifyTestCase(unittest.TestCase): """Test Case for verify""" @@ -79,46 +96,57 @@ class ProgramOutOfDate(unittest.TestCase): class GenerateAndParseConfig(unittest.TestCase): """Test that we can serialize and deserialize a config.toml file""" - def serialize_and_parse(self, args): - from io import StringIO - - section_order, sections, targets = configure.parse_args(args) - buffer = StringIO() - configure.write_config_toml(buffer, section_order, targets, sections) - build = bootstrap.RustBuild() - build.config_toml = buffer.getvalue() - - try: - import tomllib - # Verify this is actually valid TOML. - tomllib.loads(build.config_toml) - except ImportError: - print("warning: skipping TOML validation, need at least python 3.11", file=sys.stderr) - return build - def test_no_args(self): - build = self.serialize_and_parse([]) + build = serialize_and_parse([]) self.assertEqual(build.get_toml("changelog-seen"), '2') self.assertEqual(build.get_toml("profile"), 'user') self.assertIsNone(build.get_toml("llvm.download-ci-llvm")) def test_set_section(self): - build = self.serialize_and_parse(["--set", "llvm.download-ci-llvm"]) + build = serialize_and_parse(["--set", "llvm.download-ci-llvm"]) self.assertEqual(build.get_toml("download-ci-llvm", section="llvm"), 'true') def test_set_target(self): - build = self.serialize_and_parse(["--set", "target.x86_64-unknown-linux-gnu.cc=gcc"]) + build = serialize_and_parse(["--set", "target.x86_64-unknown-linux-gnu.cc=gcc"]) self.assertEqual(build.get_toml("cc", section="target.x86_64-unknown-linux-gnu"), 'gcc') def test_set_top_level(self): - build = self.serialize_and_parse(["--set", "profile=compiler"]) + build = serialize_and_parse(["--set", "profile=compiler"]) self.assertEqual(build.get_toml("profile"), 'compiler') def test_set_codegen_backends(self): - build = self.serialize_and_parse(["--set", "rust.codegen-backends=cranelift"]) + build = serialize_and_parse(["--set", "rust.codegen-backends=cranelift"]) self.assertNotEqual(build.config_toml.find("codegen-backends = ['cranelift']"), -1) - build = self.serialize_and_parse(["--set", "rust.codegen-backends=cranelift,llvm"]) + build = serialize_and_parse(["--set", "rust.codegen-backends=cranelift,llvm"]) self.assertNotEqual(build.config_toml.find("codegen-backends = ['cranelift', 'llvm']"), -1) - build = self.serialize_and_parse(["--enable-full-tools"]) + build = serialize_and_parse(["--enable-full-tools"]) self.assertNotEqual(build.config_toml.find("codegen-backends = ['llvm']"), -1) + +class BuildBootstrap(unittest.TestCase): + """Test that we generate the appropriate arguments when building bootstrap""" + + def build_args(self, configure_args=[], args=[], env={}): + env = env.copy() + env["PATH"] = os.environ["PATH"] + + build = serialize_and_parse(configure_args) + build.build_dir = os.environ["BUILD_DIR"] + parsed = bootstrap.parse_args(args) + return build.build_bootstrap_cmd(env, parsed.color, parsed.warnings, parsed.verbose), env + + def test_cargoflags(self): + args, _ = self.build_args(env={"CARGOFLAGS": "--timings"}) + self.assertTrue("--timings" in args) + + def test_warnings(self): + for toml_warnings in ['false', 'true', None]: + configure_args = [] + if toml_warnings is not None: + configure_args = ["--set", "rust.deny-warnings=" + toml_warnings] + + _, env = self.build_args(configure_args, args=["--warnings=warn"]) + self.assertFalse("-Dwarnings" in env["RUSTFLAGS"]) + + _, env = self.build_args(configure_args, args=["--warnings=deny"]) + self.assertTrue("-Dwarnings" in env["RUSTFLAGS"]) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 9cc5a69b920e..9f0f24e0f7b2 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -2665,9 +2665,8 @@ impl Step for Bootstrap { fn run(self, builder: &Builder<'_>) { let mut check_bootstrap = Command::new(&builder.python()); check_bootstrap - .arg("-m") - .arg("unittest") - .arg("bootstrap_test.py") + .args(["-m", "unittest", "bootstrap_test.py"]) + .env("BUILD_DIR", &builder.out) .current_dir(builder.src.join("src/bootstrap/")) .args(builder.config.test_args()); try_run(builder, &mut check_bootstrap).unwrap(); From c7af6fb5b8d75bc767c05585a63a0d075d8c3e5f Mon Sep 17 00:00:00 2001 From: jyn Date: Sun, 4 Jun 2023 12:50:15 -0500 Subject: [PATCH 044/103] Test color/verbose/warnings properly These weren't being passed in to bootstrap consistently before; in particular `serialize_and_parse` forgot to pass them in. --- src/bootstrap/bootstrap.py | 34 ++++++++++++++++++--------------- src/bootstrap/bootstrap_test.py | 13 ++++++------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 9b8fdd38d22a..6d215224abfd 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -466,6 +466,8 @@ class FakeArgs: self.clean = False self.verbose = False self.json_output = False + self.color = 'auto' + self.warnings = 'default' class RustBuild(object): """Provide all the methods required to build Rust""" @@ -477,9 +479,11 @@ class RustBuild(object): self.config_toml = config_toml - self.verbose = args.verbose != 0 self.clean = args.clean self.json_output = args.json_output + self.verbose = args.verbose + self.color = args.color + self.warnings = args.warnings profile = self.get_toml('profile') if profile is not None: @@ -491,6 +495,10 @@ class RustBuild(object): with open(include_path) as included_toml: self.config_toml += os.linesep + included_toml.read() + config_verbose_count = self.get_toml('verbose', 'build') + if config_verbose_count is not None: + self.verbose = max(self.verbose, int(config_verbose_count)) + self.use_vendored_sources = self.get_toml('vendor', 'build') == 'true' self.use_locked_deps = self.get_toml('locked-deps', 'build') == 'true' @@ -505,6 +513,7 @@ class RustBuild(object): self.build = args.build or self.build_triple() + def download_toolchain(self): """Fetch the build system for Rust, written in Rust @@ -859,7 +868,7 @@ class RustBuild(object): """ return os.path.join(self.build_dir, "bootstrap", "debug", "bootstrap") - def build_bootstrap(self, color, warnings, verbose_count): + def build_bootstrap(self): """Build bootstrap""" env = os.environ.copy() if "GITHUB_ACTIONS" in env: @@ -867,14 +876,14 @@ class RustBuild(object): else: print("Building bootstrap", file=sys.stderr) - args = self.build_bootstrap_cmd(env, color, warnings, verbose_count) + args = self.build_bootstrap_cmd(env) # Run this from the source directory so cargo finds .cargo/config run(args, env=env, verbose=self.verbose, cwd=self.rust_root) if "GITHUB_ACTIONS" in env: print("::endgroup::") - def build_bootstrap_cmd(self, env, color, warnings, verbose_count): + def build_bootstrap_cmd(self, env): """For tests.""" build_dir = os.path.join(self.build_dir, "bootstrap") if self.clean and os.path.exists(build_dir): @@ -928,10 +937,10 @@ class RustBuild(object): if target_linker is not None: env["RUSTFLAGS"] += " -C linker=" + target_linker env["RUSTFLAGS"] += " -Wrust_2018_idioms -Wunused_lifetimes" - if warnings == "default": + if self.warnings == "default": deny_warnings = self.get_toml("deny-warnings", "rust") != "false" else: - deny_warnings = warnings == "deny" + deny_warnings = self.warnings == "deny" if deny_warnings: env["RUSTFLAGS"] += " -Dwarnings" @@ -942,7 +951,7 @@ class RustBuild(object): self.cargo())) args = [self.cargo(), "build", "--manifest-path", os.path.join(self.rust_root, "src/bootstrap/Cargo.toml")] - args.extend("--verbose" for _ in range(verbose_count)) + args.extend("--verbose" for _ in range(self.verbose)) if self.use_locked_deps: args.append("--locked") if self.use_vendored_sources: @@ -952,9 +961,9 @@ class RustBuild(object): args.append("build-metrics") if self.json_output: args.append("--message-format=json") - if color == "always": + if self.color == "always": args.append("--color=always") - elif color == "never": + elif self.color == "never": args.append("--color=never") try: args += env["CARGOFLAGS"].split() @@ -1049,18 +1058,13 @@ def bootstrap(args): build = RustBuild(config_toml, args) build.check_vendored_status() - verbose_count = args.verbose - config_verbose_count = build.get_toml('verbose', 'build') - if config_verbose_count is not None: - verbose_count = max(args.verbose, int(config_verbose_count)) - if not os.path.exists(build.build_dir): os.makedirs(build.build_dir) # Fetch/build the bootstrap build.download_toolchain() sys.stdout.flush() - build.build_bootstrap(args.color, args.warnings, verbose_count) + build.build_bootstrap() sys.stdout.flush() # Run the bootstrap diff --git a/src/bootstrap/bootstrap_test.py b/src/bootstrap/bootstrap_test.py index 6854aafa1c04..167b11d421ea 100644 --- a/src/bootstrap/bootstrap_test.py +++ b/src/bootstrap/bootstrap_test.py @@ -15,14 +15,13 @@ from shutil import rmtree import bootstrap import configure -def serialize_and_parse(args): +def serialize_and_parse(configure_args, bootstrap_args=bootstrap.FakeArgs()): from io import StringIO - section_order, sections, targets = configure.parse_args(args) + section_order, sections, targets = configure.parse_args(configure_args) buffer = StringIO() configure.write_config_toml(buffer, section_order, targets, sections) - build = bootstrap.RustBuild() - build.config_toml = buffer.getvalue() + build = bootstrap.RustBuild(config_toml=buffer.getvalue(), args=bootstrap_args) try: import tomllib @@ -130,10 +129,10 @@ class BuildBootstrap(unittest.TestCase): env = env.copy() env["PATH"] = os.environ["PATH"] - build = serialize_and_parse(configure_args) - build.build_dir = os.environ["BUILD_DIR"] parsed = bootstrap.parse_args(args) - return build.build_bootstrap_cmd(env, parsed.color, parsed.warnings, parsed.verbose), env + build = serialize_and_parse(configure_args, parsed) + build.build_dir = os.environ["BUILD_DIR"] + return build.build_bootstrap_cmd(env), env def test_cargoflags(self): args, _ = self.build_args(env={"CARGOFLAGS": "--timings"}) From 13cc8dd580eea454e7fde2331c60c62eb7c9fe80 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sat, 24 Jun 2023 14:27:58 +0900 Subject: [PATCH 045/103] Add a regression test for #109141 Signed-off-by: Yuki Okushi --- .../generic_const_exprs/issue-109141.rs | 13 ++++++++++ .../generic_const_exprs/issue-109141.stderr | 26 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 tests/ui/const-generics/generic_const_exprs/issue-109141.rs create mode 100644 tests/ui/const-generics/generic_const_exprs/issue-109141.stderr diff --git a/tests/ui/const-generics/generic_const_exprs/issue-109141.rs b/tests/ui/const-generics/generic_const_exprs/issue-109141.rs new file mode 100644 index 000000000000..148c3bda8d28 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/issue-109141.rs @@ -0,0 +1,13 @@ +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +impl EntriesBuffer { + fn a(&self) -> impl Iterator { + self.0.iter_mut() //~ ERROR: cannot borrow `*self.0` as mutable, as it is behind a `&` reference + } +} + +struct EntriesBuffer(Box<[[u8; HashesEntryLEN]; 5]>); +//~^ ERROR: cannot find value `HashesEntryLEN` in this scope + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/issue-109141.stderr b/tests/ui/const-generics/generic_const_exprs/issue-109141.stderr new file mode 100644 index 000000000000..f61edd60e3b6 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/issue-109141.stderr @@ -0,0 +1,26 @@ +error[E0425]: cannot find value `HashesEntryLEN` in this scope + --> $DIR/issue-109141.rs:10:32 + | +LL | struct EntriesBuffer(Box<[[u8; HashesEntryLEN]; 5]>); + | ^^^^^^^^^^^^^^ not found in this scope + | +help: you might be missing a const parameter + | +LL | struct EntriesBuffer(Box<[[u8; HashesEntryLEN]; 5]>); + | ++++++++++++++++++++++++++++++++++ + +error[E0596]: cannot borrow `*self.0` as mutable, as it is behind a `&` reference + --> $DIR/issue-109141.rs:6:9 + | +LL | self.0.iter_mut() + | ^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be borrowed as mutable + | +help: consider changing this to be a mutable reference + | +LL | fn a(&mut self) -> impl Iterator { + | ~~~~~~~~~ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0425, E0596. +For more information about an error, try `rustc --explain E0425`. From ab87f72a22e51ba63cf979b03e9d4da94eab918a Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sat, 24 Jun 2023 14:46:02 +0900 Subject: [PATCH 046/103] Add a regression test for #96699 Signed-off-by: Yuki Okushi --- .../generic_const_exprs/issue-96699.rs | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 tests/ui/const-generics/generic_const_exprs/issue-96699.rs diff --git a/tests/ui/const-generics/generic_const_exprs/issue-96699.rs b/tests/ui/const-generics/generic_const_exprs/issue-96699.rs new file mode 100644 index 000000000000..83f329d2a2df --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/issue-96699.rs @@ -0,0 +1,87 @@ +// check-pass + +#![allow(dead_code, incomplete_features)] +#![feature(generic_const_exprs)] + +const fn min(a: usize, b: usize) -> usize { + if a < b { + a + } else { + b + } +} + +trait Trait1 +where + Self: Sized, +{ + fn crash_here() + where + Inner1: Default, + { + Inner1::default(); + } +} + +struct Struct1(T); +impl Trait1 for Struct1 {} + +trait Trait2 +where + Self: Sized, +{ + type Assoc: Trait1; + + fn call_crash() + where + Inner2: Default, + { + // if Inner2 implements Default, we can call crash_here. + Self::Assoc::crash_here(); + } +} + +struct Struct2 {} +/* +where + [(); min(SIZE1, SIZE2)]:, +{ + elem: [i32; min(SIZE1, SIZE2)], +} +*/ + +impl Trait2<[i32; min(SIZE1, SIZE2)]> + for Struct2 +{ + type Assoc = Struct1<[i32; min(SIZE1, SIZE2)]>; + // dose Struct1<[i32; min(SIZE1, SIZE2)]> implement Default? +} + +fn main() { + pattern2(); + + print_fully_name( as Trait2<[i32; min(1, 2)]>>::Assoc::crash_here); + // as compiler_bug2::Trait1<[i32; 1]>>::crash_here +} + +fn pattern1() { + // no crash + as Trait2<[i32; min(1, 2)]>>::Assoc::crash_here(); + as Trait2<[i32; min(1, 2)]>>::call_crash(); +} + +fn pattern2() { + // crash + as Trait2<[i32; min(1, 2)]>>::call_crash(); + + // undefined reference to `compiler_bug2::Trait1::crash_here' +} + +fn pattern3() { + // no crash + as Trait2<[i32; min(1, 2)]>>::Assoc::crash_here(); +} + +fn print_fully_name(_: T) { + let _ = std::any::type_name::(); +} From c643bedf7c90940005da021ba80b6c4e6dcbdaa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Thu, 22 Jun 2023 10:42:02 +0200 Subject: [PATCH 047/103] rustdoc: render gen params & where-clauses of cross-crate assoc tys in impl blocks --- src/librustdoc/clean/mod.rs | 88 ++++++++++--------- .../inline_cross/assoc_item_trait_bounds.rs | 12 +++ .../auxiliary/assoc_item_trait_bounds.rs | 17 ++++ 3 files changed, 74 insertions(+), 43 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index f86c32158e0b..3dd3a6a8394f 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1360,21 +1360,53 @@ pub(crate) fn clean_middle_assoc_item<'tcx>( } } + let mut predicates = tcx.explicit_predicates_of(assoc_item.def_id).predicates; if let ty::TraitContainer = assoc_item.container { let bounds = tcx .explicit_item_bounds(assoc_item.def_id) .subst_identity_iter_copied() .map(|(c, s)| (c.as_predicate(), s)); - let predicates = tcx.explicit_predicates_of(assoc_item.def_id).predicates; - let predicates = - tcx.arena.alloc_from_iter(bounds.chain(predicates.iter().copied())); - let mut generics = clean_ty_generics( - cx, - tcx.generics_of(assoc_item.def_id), - ty::GenericPredicates { parent: None, predicates }, - ); - // Filter out the bounds that are (likely?) directly attached to the associated type, - // as opposed to being located in the where clause. + predicates = tcx.arena.alloc_from_iter(bounds.chain(predicates.iter().copied())); + } + let mut generics = clean_ty_generics( + cx, + tcx.generics_of(assoc_item.def_id), + ty::GenericPredicates { parent: None, predicates }, + ); + // Move bounds that are (likely) directly attached to the parameters of the + // (generic) associated type from the where clause to the respective parameter. + // There is no guarantee that this is what the user actually wrote but we have + // no way of knowing. + let mut where_predicates = ThinVec::new(); + for mut pred in generics.where_predicates { + if let WherePredicate::BoundPredicate { ty: Generic(arg), bounds, .. } = &mut pred + && let Some(GenericParamDef { + kind: GenericParamDefKind::Type { bounds: param_bounds, .. }, + .. + }) = generics.params.iter_mut().find(|param| ¶m.name == arg) + { + param_bounds.append(bounds); + } else if let WherePredicate::RegionPredicate { lifetime: Lifetime(arg), bounds } = &mut pred + && let Some(GenericParamDef { + kind: GenericParamDefKind::Lifetime { outlives: param_bounds }, + .. + }) = generics.params.iter_mut().find(|param| ¶m.name == arg) + { + param_bounds.extend(bounds.drain(..).map(|bound| match bound { + GenericBound::Outlives(lifetime) => lifetime, + _ => unreachable!(), + })); + } else { + where_predicates.push(pred); + } + } + generics.where_predicates = where_predicates; + + if let ty::TraitContainer = assoc_item.container { + // Move bounds that are (likely) directly attached to the associated type + // from the where-clause to the associated type. + // There is no guarantee that this is what the user actually wrote but we have + // no way of knowing. let mut bounds: Vec = Vec::new(); generics.where_predicates.retain_mut(|pred| match *pred { WherePredicate::BoundPredicate { @@ -1431,33 +1463,6 @@ pub(crate) fn clean_middle_assoc_item<'tcx>( } None => bounds.push(GenericBound::maybe_sized(cx)), } - // Move bounds that are (likely) directly attached to the parameters of the - // (generic) associated type from the where clause to the respective parameter. - // There is no guarantee that this is what the user actually wrote but we have - // no way of knowing. - let mut where_predicates = ThinVec::new(); - for mut pred in generics.where_predicates { - if let WherePredicate::BoundPredicate { ty: Generic(arg), bounds, .. } = &mut pred - && let Some(GenericParamDef { - kind: GenericParamDefKind::Type { bounds: param_bounds, .. }, - .. - }) = generics.params.iter_mut().find(|param| ¶m.name == arg) - { - param_bounds.append(bounds); - } else if let WherePredicate::RegionPredicate { lifetime: Lifetime(arg), bounds } = &mut pred - && let Some(GenericParamDef { - kind: GenericParamDefKind::Lifetime { outlives: param_bounds }, - .. - }) = generics.params.iter_mut().find(|param| ¶m.name == arg) { - param_bounds.extend(bounds.drain(..).map(|bound| match bound { - GenericBound::Outlives(lifetime) => lifetime, - _ => unreachable!(), - })); - } else { - where_predicates.push(pred); - } - } - generics.where_predicates = where_predicates; if tcx.defaultness(assoc_item.def_id).has_value() { AssocTypeItem( @@ -1469,7 +1474,6 @@ pub(crate) fn clean_middle_assoc_item<'tcx>( None, ), generics, - // FIXME: should we obtain the Type from HIR and pass it on here? item_type: None, }), bounds, @@ -1478,7 +1482,6 @@ pub(crate) fn clean_middle_assoc_item<'tcx>( TyAssocTypeItem(generics, bounds) } } else { - // FIXME: when could this happen? Associated items in inherent impls? AssocTypeItem( Box::new(Typedef { type_: clean_middle_ty( @@ -1487,12 +1490,11 @@ pub(crate) fn clean_middle_assoc_item<'tcx>( Some(assoc_item.def_id), None, ), - generics: Generics { - params: ThinVec::new(), - where_predicates: ThinVec::new(), - }, + generics, item_type: None, }), + // Associated types inside trait or inherent impls are not allowed to have + // item bounds. Thus we don't attempt to move any bounds there. Vec::new(), ) } diff --git a/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs b/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs index db2491b87b4d..74ceb697af69 100644 --- a/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs +++ b/tests/rustdoc/inline_cross/assoc_item_trait_bounds.rs @@ -42,3 +42,15 @@ pub use aux::Main; // @has main/trait.Aid.html // @has - '//*[@id="associatedtype.Result"]' "type Result<'inter: 'src>" pub use aux::Aid; + +// Below, ensure that we correctly display generic parameters and where-clauses on +// associated types inside trait *impls*. More particularly, check that we don't render +// any bounds (here `Self::Alias: ...`) as item bounds unlike all the trait test cases above. + +// @has main/struct.Implementor.html +// @has - '//*[@id="associatedtype.Alias"]' \ +// "type Alias = T \ +// where \ +// String: From, \ +// ::Alias: From<::Alias>" +pub use aux::Implementor; diff --git a/tests/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs b/tests/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs index 6644c8e41478..551e97a2fa9a 100644 --- a/tests/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs +++ b/tests/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs @@ -44,3 +44,20 @@ pub trait Helper { pub trait Aid<'src> { type Result<'inter: 'src>; } + +pub trait Implementee { + type Alias + where + String: From; +} + +pub struct Implementor; + +impl Implementee for Implementor { + type Alias = T + where + String: From, + // We will check that this bound doesn't get turned into an item bound since + // associated types in impls are not allowed to have any. + Self::Alias: From>; +} From fa1f16116e1c9205f5a3812eaa50d726b99be267 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 24 Jun 2023 14:47:16 +0200 Subject: [PATCH 048/103] Migrate GUI colors test to original CSS color format --- tests/rustdoc-gui/settings.goml | 60 ++++++++++++++++----------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/tests/rustdoc-gui/settings.goml b/tests/rustdoc-gui/settings.goml index c37d969324ce..e40c637dcf7d 100644 --- a/tests/rustdoc-gui/settings.goml +++ b/tests/rustdoc-gui/settings.goml @@ -56,19 +56,19 @@ move-cursor-to: "#settings-menu > a" assert-css: ( "#theme-dark", { - "border-color": "rgb(153, 153, 153)", - "box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset", + "border-color": "#999", + "box-shadow": "#353535 0px 0px 0px 3px inset", "border-width": "2px", }, ) -assert-css: ("#theme-light", {"border-color": "rgb(153, 153, 153)", "box-shadow": "none"}) +assert-css: ("#theme-light", {"border-color": "#999", "box-shadow": "none"}) // Let's start with the hover for radio buttons. move-cursor-to: "#theme-dark" assert-css: ( "#theme-dark", { - "border-color": "rgb(33, 150, 243)", - "box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset", + "border-color": "#2196f3", + "box-shadow": "#353535 0px 0px 0px 3px inset", "border-width": "2px", }, ) @@ -76,7 +76,7 @@ move-cursor-to: "#theme-light" assert-css: ( "#theme-light", { - "border-color": "rgb(33, 150, 243)", + "border-color": "#2196f3", "box-shadow": "none", "border-width": "2px", } @@ -87,8 +87,8 @@ focus: "#theme-dark" assert-css: ( "#theme-dark", { - "border-color": "rgb(153, 153, 153)", - "box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset, rgb(33, 150, 243) 0px 0px 2px 2px", + "border-color": "#999", + "box-shadow": "#353535 0px 0px 0px 3px inset, #2196f3 0px 0px 2px 2px", "border-width": "2px", }, ) @@ -96,8 +96,8 @@ focus: "#theme-light" assert-css: ( "#theme-light", { - "border-color": "rgb(153, 153, 153)", - "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", + "border-color": "#999", + "box-shadow": "#2196f3 0px 0px 1px 1px", "border-width": "2px", }, ) @@ -107,8 +107,8 @@ focus: "#theme-dark" assert-css: ( "#theme-dark", { - "border-color": "rgb(33, 150, 243)", - "box-shadow": "rgb(53, 53, 53) 0px 0px 0px 3px inset, rgb(33, 150, 243) 0px 0px 2px 2px", + "border-color": "#2196f3", + "box-shadow": "#353535 0px 0px 0px 3px inset, #2196f3 0px 0px 2px 2px", "border-width": "2px", }, ) @@ -117,8 +117,8 @@ focus: "#theme-light" assert-css: ( "#theme-light", { - "border-color": "rgb(33, 150, 243)", - "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", + "border-color": "#2196f3", + "box-shadow": "#2196f3 0px 0px 1px 1px", "border-width": "2px", }, ) @@ -154,8 +154,8 @@ compare-elements-position-near: ( assert-css: ( "#auto-hide-large-items", { - "background-color": "rgb(33, 150, 243)", - "border-color": "rgb(153, 153, 153)", + "background-color": "#2196f3", + "border-color": "#999", // 1px border when checked "border-width": "1px", }, @@ -164,7 +164,7 @@ assert-css: ( "#auto-hide-method-docs", { "background-color": "rgba(0, 0, 0, 0)", - "border-color": "rgb(153, 153, 153)", + "border-color": "#999", // 2px border when unchecked "border-width": "2px", }, @@ -174,8 +174,8 @@ move-cursor-to: "#auto-hide-large-items" assert-css: ( "#auto-hide-large-items", { - "background-color": "rgb(33, 150, 243)", - "border-color": "rgb(33, 150, 243)", + "background-color": "#2196f3", + "border-color": "#2196f3", // 1px border when checked "border-width": "1px", }, @@ -185,7 +185,7 @@ assert-css: ( "#auto-hide-method-docs", { "background-color": "rgba(0, 0, 0, 0)", - "border-color": "rgb(33, 150, 243)", + "border-color": "#2196f3", // 2px border when unchecked "border-width": "2px", }, @@ -196,9 +196,9 @@ focus: "#auto-hide-large-items" assert-css: ( "#auto-hide-large-items", { - "background-color": "rgb(33, 150, 243)", - "border-color": "rgb(153, 153, 153)", - "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", + "background-color": "#2196f3", + "border-color": "#999", + "box-shadow": "#2196f3 0px 0px 1px 1px", // 1px border when checked "border-width": "1px", }, @@ -208,8 +208,8 @@ assert-css: ( "#auto-hide-method-docs", { "background-color": "rgba(0, 0, 0, 0)", - "border-color": "rgb(153, 153, 153)", - "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", + "border-color": "#999", + "box-shadow": "#2196f3 0px 0px 1px 1px", // 2px border when unchecked "border-width": "2px", }, @@ -220,9 +220,9 @@ focus: "#auto-hide-large-items" assert-css: ( "#auto-hide-large-items", { - "background-color": "rgb(33, 150, 243)", - "border-color": "rgb(33, 150, 243)", - "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", + "background-color": "#2196f3", + "border-color": "#2196f3", + "box-shadow": "#2196f3 0px 0px 1px 1px", // 1px border when checked "border-width": "1px", }, @@ -233,8 +233,8 @@ assert-css: ( "#auto-hide-method-docs", { "background-color": "rgba(0, 0, 0, 0)", - "border-color": "rgb(33, 150, 243)", - "box-shadow": "rgb(33, 150, 243) 0px 0px 1px 1px", + "border-color": "#2196f3", + "box-shadow": "#2196f3 0px 0px 1px 1px", // 2px border when unchecked "border-width": "2px", }, From a72013f7f039ddf9d248e2194ea87c9e40213e34 Mon Sep 17 00:00:00 2001 From: Ali MJ Al-Nasrawy Date: Fri, 16 Jun 2023 12:33:11 +0000 Subject: [PATCH 049/103] instantiate hidden types in root universe --- compiler/rustc_borrowck/src/type_check/mod.rs | 5 +- compiler/rustc_infer/src/infer/mod.rs | 1 + .../member-constraints-in-root-universe.rs | 17 ++++++ .../normalize-hidden-types.current.stderr | 55 +++++++++++++++++ .../normalize-hidden-types.rs | 60 +++++++++++++++++++ 5 files changed, 135 insertions(+), 3 deletions(-) create mode 100644 tests/ui/traits/new-solver/member-constraints-in-root-universe.rs create mode 100644 tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr create mode 100644 tests/ui/type-alias-impl-trait/normalize-hidden-types.rs diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 00fd3762fa77..d9abe53c238b 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -50,7 +50,6 @@ use rustc_mir_dataflow::impls::MaybeInitializedPlaces; use rustc_mir_dataflow::move_paths::MoveData; use rustc_mir_dataflow::ResultsCursor; -use crate::renumber::RegionCtxt; use crate::session_diagnostics::MoveUnsized; use crate::{ borrow_set::BorrowSet, @@ -1041,9 +1040,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { .collect(); let renumbered_opaques = self.infcx.tcx.fold_regions(opaques, |_, _| { - self.infcx.next_nll_region_var( + self.infcx.next_nll_region_var_in_universe( NllRegionVariableOrigin::Existential { from_forall: false }, - || RegionCtxt::Unknown, + ty::UniverseIndex::ROOT, ) }); diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 9526ed144c34..7dbc18908d5f 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -1474,6 +1474,7 @@ impl<'tcx> InferCtxt<'tcx> { /// universes. Updates `self.universe` to that new universe. pub fn create_next_universe(&self) -> ty::UniverseIndex { let u = self.universe.get().next_universe(); + debug!("create_next_universe {u:?}"); self.universe.set(u); u } diff --git a/tests/ui/traits/new-solver/member-constraints-in-root-universe.rs b/tests/ui/traits/new-solver/member-constraints-in-root-universe.rs new file mode 100644 index 000000000000..97c443058644 --- /dev/null +++ b/tests/ui/traits/new-solver/member-constraints-in-root-universe.rs @@ -0,0 +1,17 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +trait Trait { + type Ty; +} + +impl Trait for for<'a> fn(&'a u8, &'a u8) { + type Ty = (); +} + +// argument is necessary to create universes before registering the hidden type. +fn test<'a>(_: ::Ty) -> impl Sized { + "hidden type is `&'?0 str` with '?0 member of ['static,]" +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr b/tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr new file mode 100644 index 000000000000..dd2737c706d6 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/normalize-hidden-types.current.stderr @@ -0,0 +1,55 @@ +error: concrete type differs from previous defining opaque type use + --> $DIR/normalize-hidden-types.rs:25:20 + | +LL | fn define() -> Opaque { + | ^^^^^^ expected `*const (dyn FnOnce(()) + 'static)`, got `*const dyn for<'a> FnOnce(::Gat<'a>)` + | +note: previous use here + --> $DIR/normalize-hidden-types.rs:27:9 + | +LL | dyn_hoops::<_>(0) + | ^^^^^^^^^^^^^^^^^ + +error: concrete type differs from previous defining opaque type use + --> $DIR/normalize-hidden-types.rs:34:22 + | +LL | fn define_1() -> Opaque { dyn_hoops::<_>(0) } + | ^^^^^^ expected `*const (dyn FnOnce(()) + 'static)`, got `*const dyn for<'a> FnOnce(::Gat<'a>)` + | +note: previous use here + --> $DIR/normalize-hidden-types.rs:34:31 + | +LL | fn define_1() -> Opaque { dyn_hoops::<_>(0) } + | ^^^^^^^^^^^^^^^^^ + +error[E0308]: mismatched types + --> $DIR/normalize-hidden-types.rs:44:25 + | +LL | type Opaque = impl Sized; + | ---------- the expected opaque type +... +LL | let _: Opaque = dyn_hoops::(0); + | ------ ^^^^^^^^^^^^^^^^^^ expected opaque type, found `*const dyn FnOnce(())` + | | + | expected due to this + | + = note: expected opaque type `typeck::Opaque` + found raw pointer `*const (dyn FnOnce(()) + 'static)` + = help: consider constraining the associated type `::Gat<'_>` to `()` or calling a method that returns `::Gat<'_>` + = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html + +error: concrete type differs from previous defining opaque type use + --> $DIR/normalize-hidden-types.rs:54:25 + | +LL | let _: Opaque = dyn_hoops::<_>(0); + | ^^^^^^^^^^^^^^^^^ expected `*const (dyn FnOnce(()) + 'static)`, got `*const dyn for<'a> FnOnce(::Gat<'a>)` + | +note: previous use here + --> $DIR/normalize-hidden-types.rs:56:9 + | +LL | None + | ^^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/type-alias-impl-trait/normalize-hidden-types.rs b/tests/ui/type-alias-impl-trait/normalize-hidden-types.rs new file mode 100644 index 000000000000..8d80546444ad --- /dev/null +++ b/tests/ui/type-alias-impl-trait/normalize-hidden-types.rs @@ -0,0 +1,60 @@ +// Regression test for #112691 +// +// revisions: current next +// [next] compile-flags: -Ztrait-solver=next +// [next] check-pass +// [current]: known-bug: #112691 + +#![feature(type_alias_impl_trait)] + +trait Trait { + type Gat<'lt>; +} + +impl Trait for u8 { + type Gat<'lt> = (); +} + +fn dyn_hoops(_: T) -> *const dyn FnOnce(T::Gat<'_>) { + loop {} +} + +mod typeof_1 { + use super::*; + type Opaque = impl Sized; + fn define() -> Opaque { + //[current]~^ ERROR concrete type differs + dyn_hoops::<_>(0) + } +} + +mod typeof_2 { + use super::*; + type Opaque = impl Sized; + fn define_1() -> Opaque { dyn_hoops::<_>(0) } + //[current]~^ ERROR concrete type differs + fn define_2() -> Opaque { dyn_hoops::(0) } +} + +mod typeck { + use super::*; + type Opaque = impl Sized; + fn define() -> Option { + let _: Opaque = dyn_hoops::<_>(0); + let _: Opaque = dyn_hoops::(0); + //[current]~^ ERROR mismatched types + None + } +} + +mod borrowck { + use super::*; + type Opaque = impl Sized; + fn define() -> Option { + let _: Opaque = dyn_hoops::<_>(0); + //[current]~^ ERROR concrete type differs + None + } +} + +fn main() {} From 8c8c7ef78a213af0b65f22f1748b1d569181a9d3 Mon Sep 17 00:00:00 2001 From: bohan Date: Wed, 21 Jun 2023 02:20:55 +0800 Subject: [PATCH 050/103] fix: add cfg diagnostic for unresolved import error --- compiler/rustc_resolve/src/imports.rs | 13 +++++++- tests/ui/cfg/diagnostics-reexport.rs | 24 +++++++++++++++ tests/ui/cfg/diagnostics-reexport.stderr | 38 ++++++++++++++++++++++-- 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 444533099200..c458fc872aae 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -609,7 +609,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } } - fn throw_unresolved_import_error(&self, errors: Vec<(&Import<'_>, UnresolvedImportError)>) { + fn throw_unresolved_import_error(&mut self, errors: Vec<(&Import<'_>, UnresolvedImportError)>) { if errors.is_empty() { return; } @@ -679,6 +679,17 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { _ => {} } } + + match &import.kind { + ImportKind::Single { source, .. } => { + if let Some(ModuleOrUniformRoot::Module(module)) = import.imported_module.get() + && let Some(module) = module.opt_def_id() + { + self.find_cfg_stripped(&mut diag, &source.name, module) + } + }, + _ => {} + } } diag.emit(); diff --git a/tests/ui/cfg/diagnostics-reexport.rs b/tests/ui/cfg/diagnostics-reexport.rs index 1d43d6ba02f5..b9548e911831 100644 --- a/tests/ui/cfg/diagnostics-reexport.rs +++ b/tests/ui/cfg/diagnostics-reexport.rs @@ -9,6 +9,30 @@ pub mod inner { //~^ NOTE found an item that was configured out } +pub use a::x; +//~^ ERROR unresolved import `a::x` +//~| NOTE no `x` in `a` + +mod a { + #[cfg(no)] + pub fn x() {} + //~^ NOTE found an item that was configured out +} + +pub use b::{x, y}; +//~^ ERROR unresolved imports `b::x`, `b::y` +//~| NOTE no `x` in `b` +//~| NOTE no `y` in `b` + +mod b { + #[cfg(no)] + pub fn x() {} + //~^ NOTE found an item that was configured out + #[cfg(no)] + pub fn y() {} + //~^ NOTE found an item that was configured out +} + fn main() { // There is no uwu at this path - no diagnostic. inner::uwu(); //~ ERROR cannot find function diff --git a/tests/ui/cfg/diagnostics-reexport.stderr b/tests/ui/cfg/diagnostics-reexport.stderr index 6c977cbfa417..e25b7cf86e21 100644 --- a/tests/ui/cfg/diagnostics-reexport.stderr +++ b/tests/ui/cfg/diagnostics-reexport.stderr @@ -1,5 +1,36 @@ +error[E0432]: unresolved import `a::x` + --> $DIR/diagnostics-reexport.rs:12:9 + | +LL | pub use a::x; + | ^^^^ no `x` in `a` + | +note: found an item that was configured out + --> $DIR/diagnostics-reexport.rs:18:12 + | +LL | pub fn x() {} + | ^ + +error[E0432]: unresolved imports `b::x`, `b::y` + --> $DIR/diagnostics-reexport.rs:22:13 + | +LL | pub use b::{x, y}; + | ^ ^ no `y` in `b` + | | + | no `x` in `b` + | +note: found an item that was configured out + --> $DIR/diagnostics-reexport.rs:29:12 + | +LL | pub fn x() {} + | ^ +note: found an item that was configured out + --> $DIR/diagnostics-reexport.rs:32:12 + | +LL | pub fn y() {} + | ^ + error[E0425]: cannot find function `uwu` in module `inner` - --> $DIR/diagnostics-reexport.rs:14:12 + --> $DIR/diagnostics-reexport.rs:38:12 | LL | inner::uwu(); | ^^^ not found in `inner` @@ -10,6 +41,7 @@ note: found an item that was configured out LL | pub use super::uwu; | ^^^ -error: aborting due to previous error +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0425`. +Some errors have detailed explanations: E0425, E0432. +For more information about an error, try `rustc --explain E0425`. From 24e67d51a0fbf20910e19045e038fe646e5b0910 Mon Sep 17 00:00:00 2001 From: jyn Date: Thu, 8 Jun 2023 21:30:04 -0500 Subject: [PATCH 051/103] Don't test the profile override hack It generates invalid TOML. I want to get rid of it eventually, but this avoids the issue in the meantime. --- src/bootstrap/bootstrap.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 6d215224abfd..3dae37ca3502 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -485,16 +485,6 @@ class RustBuild(object): self.color = args.color self.warnings = args.warnings - profile = self.get_toml('profile') - if profile is not None: - include_file = 'config.{}.toml'.format(profile) - include_dir = os.path.join(self.rust_root, 'src', 'bootstrap', 'defaults') - include_path = os.path.join(include_dir, include_file) - # HACK: This works because `self.get_toml()` returns the first match it finds for a - # specific key, so appending our defaults at the end allows the user to override them - with open(include_path) as included_toml: - self.config_toml += os.linesep + included_toml.read() - config_verbose_count = self.get_toml('verbose', 'build') if config_verbose_count is not None: self.verbose = max(self.verbose, int(config_verbose_count)) @@ -794,9 +784,12 @@ class RustBuild(object): >>> rb.get_toml("key1") 'true' """ + return RustBuild.get_toml_static(self.config_toml, key, section) + @staticmethod + def get_toml_static(config_toml, key, section=None): cur_section = None - for line in self.config_toml.splitlines(): + for line in config_toml.splitlines(): section_match = re.match(r'^\s*\[(.*)\]\s*$', line) if section_match is not None: cur_section = section_match.group(1) @@ -805,7 +798,7 @@ class RustBuild(object): if match is not None: value = match.group(1) if section is None or section == cur_section: - return self.get_string(value) or value.strip() + return RustBuild.get_string(value) or value.strip() return None def cargo(self): @@ -1054,6 +1047,16 @@ def bootstrap(args): with open(toml_path) as config: config_toml = config.read() + profile = RustBuild.get_toml_static(config_toml, 'profile') + if profile is not None: + include_file = 'config.{}.toml'.format(profile) + include_dir = os.path.join(rust_root, 'src', 'bootstrap', 'defaults') + include_path = os.path.join(include_dir, include_file) + # HACK: This works because `self.get_toml()` returns the first match it finds for a + # specific key, so appending our defaults at the end allows the user to override them + with open(include_path) as included_toml: + config_toml += os.linesep + included_toml.read() + # Configure initial bootstrap build = RustBuild(config_toml, args) build.check_vendored_status() From 8a7399cd45911e495260886ee96b0e50408adb59 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Sat, 24 Jun 2023 17:30:27 +0100 Subject: [PATCH 052/103] Move arm32 shim to c.rs --- library/std/src/sys/windows/c.rs | 44 ++++++++++++++++++ library/std/src/sys/windows/c/windows_sys.lst | 4 -- library/std/src/sys/windows/c/windows_sys.rs | 45 ------------------- .../generate-windows-sys/src/arm_shim.rs | 20 --------- src/tools/generate-windows-sys/src/main.rs | 4 -- 5 files changed, 44 insertions(+), 73 deletions(-) delete mode 100644 src/tools/generate-windows-sys/src/arm_shim.rs diff --git a/library/std/src/sys/windows/c.rs b/library/std/src/sys/windows/c.rs index 5fc6136ba1fc..31c0e1b49296 100644 --- a/library/std/src/sys/windows/c.rs +++ b/library/std/src/sys/windows/c.rs @@ -432,3 +432,47 @@ compat_fn_with_fallback! { Status as u32 } } + +// # Arm32 shim +// +// AddVectoredExceptionHandler and WSAStartup use platform-specific types. +// However, Microsoft no longer supports thumbv7a so definitions for those targets +// are not included in the win32 metadata. We work around that by defining them here. +// +// Where possible, these definitions should be kept in sync with https://docs.rs/windows-sys +cfg_if::cfg_if! { +if #[cfg(not(target_vendor = "uwp"))] { + #[link(name = "kernel32")] + extern "system" { + pub fn AddVectoredExceptionHandler( + first: u32, + handler: PVECTORED_EXCEPTION_HANDLER, + ) -> *mut c_void; + } + pub type PVECTORED_EXCEPTION_HANDLER = Option< + unsafe extern "system" fn(exceptioninfo: *mut EXCEPTION_POINTERS) -> i32, + >; + #[repr(C)] + pub struct EXCEPTION_POINTERS { + pub ExceptionRecord: *mut EXCEPTION_RECORD, + pub ContextRecord: *mut CONTEXT, + } + #[cfg(target_arch = "arm")] + pub enum CONTEXT {} +}} + +#[link(name = "ws2_32")] +extern "system" { + pub fn WSAStartup(wversionrequested: u16, lpwsadata: *mut WSADATA) -> i32; +} +#[cfg(target_arch = "arm")] +#[repr(C)] +pub struct WSADATA { + pub wVersion: u16, + pub wHighVersion: u16, + pub szDescription: [u8; 257], + pub szSystemStatus: [u8; 129], + pub iMaxSockets: u16, + pub iMaxUdpDg: u16, + pub lpVendorInfo: PSTR, +} diff --git a/library/std/src/sys/windows/c/windows_sys.lst b/library/std/src/sys/windows/c/windows_sys.lst index 2cf1ade99ce5..631aedd26b4e 100644 --- a/library/std/src/sys/windows/c/windows_sys.lst +++ b/library/std/src/sys/windows/c/windows_sys.lst @@ -2171,7 +2171,6 @@ Windows.Win32.Networking.WinSock.WSARecv Windows.Win32.Networking.WinSock.WSASend Windows.Win32.Networking.WinSock.WSASERVICE_NOT_FOUND Windows.Win32.Networking.WinSock.WSASocketW -Windows.Win32.Networking.WinSock.WSAStartup Windows.Win32.Networking.WinSock.WSASYSCALLFAILURE Windows.Win32.Networking.WinSock.WSASYSNOTREADY Windows.Win32.Networking.WinSock.WSATRY_AGAIN @@ -2419,12 +2418,10 @@ Windows.Win32.System.Console.STD_HANDLE Windows.Win32.System.Console.STD_INPUT_HANDLE Windows.Win32.System.Console.STD_OUTPUT_HANDLE Windows.Win32.System.Console.WriteConsoleW -Windows.Win32.System.Diagnostics.Debug.AddVectoredExceptionHandler Windows.Win32.System.Diagnostics.Debug.ARM64_NT_NEON128 Windows.Win32.System.Diagnostics.Debug.CONTEXT Windows.Win32.System.Diagnostics.Debug.CONTEXT Windows.Win32.System.Diagnostics.Debug.CONTEXT -Windows.Win32.System.Diagnostics.Debug.EXCEPTION_POINTERS Windows.Win32.System.Diagnostics.Debug.EXCEPTION_RECORD Windows.Win32.System.Diagnostics.Debug.FACILITY_CODE Windows.Win32.System.Diagnostics.Debug.FACILITY_NT_BIT @@ -2437,7 +2434,6 @@ Windows.Win32.System.Diagnostics.Debug.FORMAT_MESSAGE_IGNORE_INSERTS Windows.Win32.System.Diagnostics.Debug.FORMAT_MESSAGE_OPTIONS Windows.Win32.System.Diagnostics.Debug.FormatMessageW Windows.Win32.System.Diagnostics.Debug.M128A -Windows.Win32.System.Diagnostics.Debug.PVECTORED_EXCEPTION_HANDLER Windows.Win32.System.Diagnostics.Debug.XSAVE_FORMAT Windows.Win32.System.Diagnostics.Debug.XSAVE_FORMAT Windows.Win32.System.Environment.FreeEnvironmentStringsW diff --git a/library/std/src/sys/windows/c/windows_sys.rs b/library/std/src/sys/windows/c/windows_sys.rs index a4294f336fec..02377087173a 100644 --- a/library/std/src/sys/windows/c/windows_sys.rs +++ b/library/std/src/sys/windows/c/windows_sys.rs @@ -39,13 +39,6 @@ extern "system" { pub fn AcquireSRWLockShared(srwlock: *mut RTL_SRWLOCK) -> (); } #[link(name = "kernel32")] -extern "system" { - pub fn AddVectoredExceptionHandler( - first: u32, - handler: PVECTORED_EXCEPTION_HANDLER, - ) -> *mut ::core::ffi::c_void; -} -#[link(name = "kernel32")] extern "system" { pub fn CancelIo(hfile: HANDLE) -> BOOL; } @@ -711,10 +704,6 @@ extern "system" { ) -> SOCKET; } #[link(name = "ws2_32")] -extern "system" { - pub fn WSAStartup(wversionrequested: u16, lpwsadata: *mut WSADATA) -> i32; -} -#[link(name = "ws2_32")] extern "system" { pub fn accept(s: SOCKET, addr: *mut SOCKADDR, addrlen: *mut i32) -> SOCKET; } @@ -3029,17 +3018,6 @@ pub const ERROR_XML_PARSE_ERROR: WIN32_ERROR = 1465u32; pub type EXCEPTION_DISPOSITION = i32; pub const EXCEPTION_MAXIMUM_PARAMETERS: u32 = 15u32; #[repr(C)] -pub struct EXCEPTION_POINTERS { - pub ExceptionRecord: *mut EXCEPTION_RECORD, - pub ContextRecord: *mut CONTEXT, -} -impl ::core::marker::Copy for EXCEPTION_POINTERS {} -impl ::core::clone::Clone for EXCEPTION_POINTERS { - fn clone(&self) -> Self { - *self - } -} -#[repr(C)] pub struct EXCEPTION_RECORD { pub ExceptionCode: NTSTATUS, pub ExceptionFlags: u32, @@ -3748,9 +3726,6 @@ pub const PROFILE_SERVER: PROCESS_CREATION_FLAGS = 1073741824u32; pub const PROFILE_USER: PROCESS_CREATION_FLAGS = 268435456u32; pub const PROGRESS_CONTINUE: u32 = 0u32; pub type PSTR = *mut u8; -pub type PVECTORED_EXCEPTION_HANDLER = ::core::option::Option< - unsafe extern "system" fn(exceptioninfo: *mut EXCEPTION_POINTERS) -> i32, ->; pub type PWSTR = *mut u16; pub const READ_CONTROL: FILE_ACCESS_RIGHTS = 131072u32; pub const REALTIME_PRIORITY_CLASS: PROCESS_CREATION_FLAGS = 256u32; @@ -4275,23 +4250,3 @@ impl ::core::clone::Clone for XSAVE_FORMAT { *self } } -// Begin of ARM32 shim -// The raw content of this file should be processed by `generate-windows-sys` -// to be merged with the generated binding. It is not supposed to be used as -// a normal Rust module. -cfg_if::cfg_if! { -if #[cfg(target_arch = "arm")] { -#[repr(C)] -pub struct WSADATA { - pub wVersion: u16, - pub wHighVersion: u16, - pub szDescription: [u8; 257], - pub szSystemStatus: [u8; 129], - pub iMaxSockets: u16, - pub iMaxUdpDg: u16, - pub lpVendorInfo: PSTR, -} -pub enum CONTEXT {} -} -} -// End of ARM32 shim diff --git a/src/tools/generate-windows-sys/src/arm_shim.rs b/src/tools/generate-windows-sys/src/arm_shim.rs deleted file mode 100644 index 17c2ccb223cc..000000000000 --- a/src/tools/generate-windows-sys/src/arm_shim.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Begin of ARM32 shim -// The raw content of this file should be processed by `generate-windows-sys` -// to be merged with the generated binding. It is not supposed to be used as -// a normal Rust module. -cfg_if::cfg_if! { -if #[cfg(target_arch = "arm")] { -#[repr(C)] -pub struct WSADATA { - pub wVersion: u16, - pub wHighVersion: u16, - pub szDescription: [u8; 257], - pub szSystemStatus: [u8; 129], - pub iMaxSockets: u16, - pub iMaxUdpDg: u16, - pub lpVendorInfo: PSTR, -} -pub enum CONTEXT {} -} -} -// End of ARM32 shim diff --git a/src/tools/generate-windows-sys/src/main.rs b/src/tools/generate-windows-sys/src/main.rs index 65e480715ee2..91d981462e81 100644 --- a/src/tools/generate-windows-sys/src/main.rs +++ b/src/tools/generate-windows-sys/src/main.rs @@ -11,9 +11,6 @@ const PRELUDE: &str = r#"// This file is autogenerated. // ignore-tidy-filelength "#; -/// This is a shim for the ARM (32-bit) architecture, which is no longer supported by windows-rs. -const ARM_SHIM: &str = include_str!("arm_shim.rs"); - fn main() -> io::Result<()> { let mut path: PathBuf = std::env::args_os().nth(1).expect("a path to the rust repository is required").into(); @@ -35,7 +32,6 @@ fn main() -> io::Result<()> { let mut f = std::fs::File::create(&path)?; f.write_all(PRELUDE.as_bytes())?; f.write_all(bindings.as_bytes())?; - f.write_all(ARM_SHIM.as_bytes())?; Ok(()) } From ce326918ec0d66b5460ef343553f2e99f3880283 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Sat, 24 Jun 2023 10:20:52 -0700 Subject: [PATCH 053/103] bootstrap: Backup `settings.json` to the correct filename The old code actually replaced `.json` with `.bak` (so, `settings.bak`), rather than appending `.bak` as claimed (`settings.json.bak`). `Path::set_extension` can instead be used with dots: > The new extension may contain dots and will be used in its entirety, > but only the part after the final dot will be reflected in > self.extension. --- 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 7eb70de91f84..9811cf163e5f 100644 --- a/src/bootstrap/setup.rs +++ b/src/bootstrap/setup.rs @@ -582,7 +582,7 @@ fn create_vscode_settings_maybe(config: &Config) -> io::Result<()> { Some(false) => { // exists and is not current version or outdated, so back it up let mut backup = vscode_settings.clone(); - backup.set_extension("bak"); + backup.set_extension("json.bak"); eprintln!("warning: copying `settings.json` to `settings.json.bak`"); fs::copy(&vscode_settings, &backup)?; "Updated" From f799e78d772abaf1df4c157b39d39b28d1602f41 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Sat, 24 Jun 2023 19:45:42 +0200 Subject: [PATCH 054/103] Fix old python deprecation check in x.py The warning suppression variable was not checked correctly. --- x.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x.py b/x.py index 7163df5cfe99..ba959a3047ed 100755 --- a/x.py +++ b/x.py @@ -31,7 +31,7 @@ if __name__ == '__main__': # soft deprecation of old python versions skip_check = os.environ.get("RUST_IGNORE_OLD_PYTHON") == "1" - if major < 3 or (major == 3 and minor < 6): + if not skip_check and (major < 3 or (major == 3 and minor < 6)): msg = cleandoc(""" Using python {}.{} but >= 3.6 is recommended. Your python version should continue to work for the near future, but this will From b556e28496209611c6ee7fef6f6ac6109af5c199 Mon Sep 17 00:00:00 2001 From: jyn Date: Sat, 24 Jun 2023 11:17:06 -0500 Subject: [PATCH 055/103] outline x.py alternate invocations to the dev guide almost no one on windows builds from source unless they're contributing, and `./x.py` just works on most unix systems. --- README.md | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 41b135972af1..901213d2ca97 100644 --- a/README.md +++ b/README.md @@ -33,24 +33,13 @@ format: ``` This is how the documentation and examples assume you are running `x.py`. -Some alternative ways are: - -```sh -# On a Unix shell if you don't have the necessary `python3` command -./x [flags] - -# On the Windows Command Prompt (if .py files are configured to run Python) -x.py [flags] - -# You can also run Python yourself, e.g.: -python x.py [flags] -``` +See the [rustc dev guide][rustcguidebuild] if this does not work on your platform. More information about `x.py` can be found by running it with the `--help` flag or reading the [rustc dev guide][rustcguidebuild]. [gettingstarted]: https://rustc-dev-guide.rust-lang.org/getting-started.html -[rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html +[rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html#what-is-xpy ### Dependencies From dd314f6533c94125d08220b1ba188c6cf68226c7 Mon Sep 17 00:00:00 2001 From: jyn Date: Sat, 24 Jun 2023 11:17:59 -0500 Subject: [PATCH 056/103] give more helpful suggestions for a missing feature gate test --- src/tools/tidy/src/features.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index 2fd4c797b43f..7ad8f5c5c05f 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -160,10 +160,10 @@ pub fn check( for &(name, _) in gate_untested.iter() { println!("Expected a gate test for the feature '{name}'."); println!( - "Hint: create a failing test file named 'feature-gate-{}.rs'\ - \n in the 'ui' test suite, with its failures due to\ - \n missing usage of `#![feature({})]`.", - name, name + "Hint: create a failing test file named 'tests/ui/feature-gates/feature-gate-{}.rs',\ + \n with its failures due to missing usage of `#![feature({})]`.", + name.replace("_", "-"), + name ); println!( "Hint: If you already have such a test and don't want to rename it,\ From e304a1f13b456df877cae8ca27bf360b1d0c89fc Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 24 Jun 2023 18:35:22 +0000 Subject: [PATCH 057/103] Revert "Structurally resolve correctly in check_pat_lit" This reverts commit 54fb5a48b968b3a329ceeb57226d9ac60f983f04. --- compiler/rustc_hir_typeck/src/pat.rs | 5 +++-- tests/ui/pattern/byte-string-inference.rs | 15 +++++++++++++++ .../ui/traits/new-solver/slice-match-byte-lit.rs | 2 +- .../traits/new-solver/slice-match-byte-lit.stderr | 11 +++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 tests/ui/pattern/byte-string-inference.rs create mode 100644 tests/ui/traits/new-solver/slice-match-byte-lit.stderr diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 2f9871a103a8..5af955d31348 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -393,8 +393,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // They can denote both statically and dynamically-sized byte arrays. let mut pat_ty = ty; if let hir::ExprKind::Lit(Spanned { node: ast::LitKind::ByteStr(..), .. }) = lt.kind { - if let ty::Ref(_, inner_ty, _) = *self.structurally_resolved_type(span, expected).kind() - && self.structurally_resolved_type(span, inner_ty).is_slice() + let expected = self.structurally_resolved_type(span, expected); + if let ty::Ref(_, inner_ty, _) = expected.kind() + && matches!(inner_ty.kind(), ty::Slice(_)) { let tcx = self.tcx; trace!(?lt.hir_id.local_id, "polymorphic byte string lit"); diff --git a/tests/ui/pattern/byte-string-inference.rs b/tests/ui/pattern/byte-string-inference.rs new file mode 100644 index 000000000000..b1517de6b679 --- /dev/null +++ b/tests/ui/pattern/byte-string-inference.rs @@ -0,0 +1,15 @@ +// check-pass + +fn load() -> Option { + todo!() +} + +fn main() { + while let Some(tag) = load() { + match &tag { + b"NAME" => {} + b"DATA" => {} + _ => {} + } + } +} diff --git a/tests/ui/traits/new-solver/slice-match-byte-lit.rs b/tests/ui/traits/new-solver/slice-match-byte-lit.rs index 4f848062595d..5f9c0df64503 100644 --- a/tests/ui/traits/new-solver/slice-match-byte-lit.rs +++ b/tests/ui/traits/new-solver/slice-match-byte-lit.rs @@ -1,5 +1,5 @@ // compile-flags: -Ztrait-solver=next -// check-pass +// known-bug: rust-lang/trait-system-refactor-initiative#38 fn test(s: &[u8]) { match &s[0..3] { diff --git a/tests/ui/traits/new-solver/slice-match-byte-lit.stderr b/tests/ui/traits/new-solver/slice-match-byte-lit.stderr new file mode 100644 index 000000000000..294e8bc94bed --- /dev/null +++ b/tests/ui/traits/new-solver/slice-match-byte-lit.stderr @@ -0,0 +1,11 @@ +error[E0271]: type mismatch resolving `[u8; 3] <: as SliceIndex<[u8]>>::Output` + --> $DIR/slice-match-byte-lit.rs:6:9 + | +LL | match &s[0..3] { + | -------- this expression has type `& as SliceIndex<[u8]>>::Output` +LL | b"uwu" => {} + | ^^^^^^ types differ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0271`. From e2eff0d4ab43946ea23998f1d48d7b4af5a71664 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Sat, 24 Jun 2023 19:56:29 +0100 Subject: [PATCH 058/103] Remove unnecessary `path` attribute --- library/std/src/sys/windows/c.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/library/std/src/sys/windows/c.rs b/library/std/src/sys/windows/c.rs index 5fc6136ba1fc..54e1efb5c62b 100644 --- a/library/std/src/sys/windows/c.rs +++ b/library/std/src/sys/windows/c.rs @@ -12,7 +12,6 @@ use crate::os::windows::io::{AsRawHandle, BorrowedHandle}; use crate::ptr; use core::ffi::NonZero_c_ulong; -#[path = "c/windows_sys.rs"] // c.rs is included from two places so we need to specify this mod windows_sys; pub use windows_sys::*; From fa7e965bf0af41ddd5865ee63782d3536263f964 Mon Sep 17 00:00:00 2001 From: jyn Date: Sat, 24 Jun 2023 13:09:48 -0500 Subject: [PATCH 059/103] Give a better error on Windows if python isn't installed Before: ``` PS C:\Users\vboxuser\rust> ./x x.ps1 PS C:\Users\vboxuser\rust> ``` After: ``` PS C:\Users\vboxuser\rust> ./x x.ps1 C:\Users\vboxuser\rust\x.ps1 : C:\Users\vboxuser\rust\x.ps1: error: did not find python installed help: consider installing it from https://www.python.org/downloads/windows/ At line:1 char:1 + ./x + ~~~ + CategoryInfo : NotInstalled: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,x.ps1 ``` The existing message from the shell script is already decent and I decided not to change it: ``` $ ./x Python was not found but can be installed from the Microsoft Store: ms-windows-store://pdp/?productid=9NJ46SX7X90P ``` --- x.ps1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/x.ps1 b/x.ps1 index a156017628db..b036653e5b44 100755 --- a/x.ps1 +++ b/x.ps1 @@ -16,7 +16,13 @@ foreach ($arg in $args) { } function Get-Application($app) { - return Get-Command $app -ErrorAction SilentlyContinue -CommandType Application + $cmd = Get-Command $app -ErrorAction SilentlyContinue -CommandType Application | Select-Object -First 1 + if ($cmd.source -match '.*AppData\\Local\\Microsoft\\WindowsApps\\.*exe') { + # Windows for some reason puts a `python3.exe` executable in PATH that just opens the windows store. + # Ignore it. + return $false + } + return $cmd } function Invoke-Application($application, $arguments) { @@ -51,5 +57,7 @@ if (($null -ne $found) -and ($found.Length -ge 1)) { Invoke-Application $python $xpy_args } -Write-Error "${PSCommandPath}: error: did not find python installed" +$msg = "${PSCommandPath}: error: did not find python installed`n" +$msg += "help: consider installing it from https://www.python.org/downloads/" +Write-Error $msg -Category NotInstalled Exit 1 From 664ffa419eb4793d2c6e161d6f098b0104550ca2 Mon Sep 17 00:00:00 2001 From: jyn Date: Sat, 24 Jun 2023 13:16:39 -0500 Subject: [PATCH 060/103] Don't print "x.ps1" This is left over from adding `Get-Command -syntax`; it's not helpful. --- x.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x.ps1 b/x.ps1 index b036653e5b44..55f99901645c 100755 --- a/x.ps1 +++ b/x.ps1 @@ -5,7 +5,7 @@ $ErrorActionPreference = "Stop" # syntax check -Get-Command -syntax ${PSCommandPath} +Get-Command -syntax ${PSCommandPath} >$null $xpy = Join-Path $PSScriptRoot x.py # Start-Process for some reason splits arguments on spaces. (Isn't powershell supposed to be simpler than bash?) From 70b6a74c3c43d0ef0c301a61aaa566d743d88730 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Sat, 24 Jun 2023 20:40:40 +0000 Subject: [PATCH 061/103] Add enum for `can_access_statics` boolean `/*can_access_statics:*/ false` is one of the ways to do this, but not the one I like. --- .../src/const_eval/eval_queries.rs | 8 +++---- .../src/const_eval/machine.rs | 21 ++++++++++++++++--- .../rustc_const_eval/src/const_eval/mod.rs | 10 +++++---- .../src/const_eval/valtrees.rs | 7 ++++++- .../src/util/check_validity_requirement.rs | 5 ++--- 5 files changed, 36 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs index 8b8e8ff58e90..417ab78fd548 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -14,7 +14,7 @@ use rustc_middle::ty::{self, TyCtxt}; use rustc_span::source_map::Span; use rustc_target::abi::{self, Abi}; -use super::{CompileTimeEvalContext, CompileTimeInterpreter}; +use super::{CanAccessStatics, CompileTimeEvalContext, CompileTimeInterpreter}; use crate::errors; use crate::interpret::eval_nullary_intrinsic; use crate::interpret::{ @@ -93,7 +93,7 @@ pub(super) fn mk_eval_cx<'mir, 'tcx>( tcx: TyCtxt<'tcx>, root_span: Span, param_env: ty::ParamEnv<'tcx>, - can_access_statics: bool, + can_access_statics: CanAccessStatics, ) -> CompileTimeEvalContext<'mir, 'tcx> { debug!("mk_eval_cx: {:?}", param_env); InterpCx::new( @@ -207,7 +207,7 @@ pub(crate) fn turn_into_const_value<'tcx>( tcx, tcx.def_span(key.value.instance.def_id()), key.param_env, - /*can_access_statics:*/ is_static, + CanAccessStatics::from(is_static), ); let mplace = ecx.raw_const_to_mplace(constant).expect( @@ -309,7 +309,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>( // Statics (and promoteds inside statics) may access other statics, because unlike consts // they do not have to behave "as if" they were evaluated at runtime. CompileTimeInterpreter::new( - /*can_access_statics:*/ is_static, + CanAccessStatics::from(is_static), if tcx.sess.opts.unstable_opts.extra_const_ub_checks { CheckAlignment::Error } else { diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index 7391f5670400..f9f645af41f1 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -57,7 +57,7 @@ pub struct CompileTimeInterpreter<'mir, 'tcx> { /// * Interning makes everything outside of statics immutable. /// * Pointers to allocations inside of statics can never leak outside, to a non-static global. /// This boolean here controls the second part. - pub(super) can_access_statics: bool, + pub(super) can_access_statics: CanAccessStatics, /// Whether to check alignment during evaluation. pub(super) check_alignment: CheckAlignment, @@ -83,8 +83,23 @@ impl CheckAlignment { } } +#[derive(Copy, Clone, PartialEq)] +pub(crate) enum CanAccessStatics { + No, + Yes, +} + +impl From for CanAccessStatics { + fn from(value: bool) -> Self { + if value { Self::Yes } else { Self::No } + } +} + impl<'mir, 'tcx> CompileTimeInterpreter<'mir, 'tcx> { - pub(crate) fn new(can_access_statics: bool, check_alignment: CheckAlignment) -> Self { + pub(crate) fn new( + can_access_statics: CanAccessStatics, + check_alignment: CheckAlignment, + ) -> Self { CompileTimeInterpreter { num_evaluated_steps: 0, stack: Vec::new(), @@ -699,7 +714,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, } } else { // Read access. These are usually allowed, with some exceptions. - if machine.can_access_statics { + if machine.can_access_statics == CanAccessStatics::Yes { // Machine configuration allows us read from anything (e.g., `static` initializer). Ok(()) } else if static_def_id.is_some() { diff --git a/compiler/rustc_const_eval/src/const_eval/mod.rs b/compiler/rustc_const_eval/src/const_eval/mod.rs index 6e462d3a1e98..b9ab0a4b7c8f 100644 --- a/compiler/rustc_const_eval/src/const_eval/mod.rs +++ b/compiler/rustc_const_eval/src/const_eval/mod.rs @@ -26,7 +26,7 @@ pub(crate) fn const_caller_location( (file, line, col): (Symbol, u32, u32), ) -> ConstValue<'_> { trace!("const_caller_location: {}:{}:{}", file, line, col); - let mut ecx = mk_eval_cx(tcx, DUMMY_SP, ty::ParamEnv::reveal_all(), false); + let mut ecx = mk_eval_cx(tcx, DUMMY_SP, ty::ParamEnv::reveal_all(), CanAccessStatics::No); let loc_place = ecx.alloc_caller_location(file, line, col); if intern_const_alloc_recursive(&mut ecx, InternKind::Constant, &loc_place).is_err() { @@ -55,10 +55,12 @@ pub(crate) fn eval_to_valtree<'tcx>( // FIXME Need to provide a span to `eval_to_valtree` let ecx = mk_eval_cx( - tcx, DUMMY_SP, param_env, + tcx, + DUMMY_SP, + param_env, // It is absolutely crucial for soundness that // we do not read from static items or other mutable memory. - false, + CanAccessStatics::No, ); let place = ecx.raw_const_to_mplace(const_alloc).unwrap(); debug!(?place); @@ -91,7 +93,7 @@ pub(crate) fn try_destructure_mir_constant<'tcx>( val: mir::ConstantKind<'tcx>, ) -> InterpResult<'tcx, mir::DestructuredConstant<'tcx>> { trace!("destructure_mir_constant: {:?}", val); - let ecx = mk_eval_cx(tcx, DUMMY_SP, param_env, false); + let ecx = mk_eval_cx(tcx, DUMMY_SP, param_env, CanAccessStatics::No); let op = ecx.eval_mir_constant(&val, None, None)?; // We go to `usize` as we cannot allocate anything bigger anyway. diff --git a/compiler/rustc_const_eval/src/const_eval/valtrees.rs b/compiler/rustc_const_eval/src/const_eval/valtrees.rs index b10f2e9f862d..e574df27694f 100644 --- a/compiler/rustc_const_eval/src/const_eval/valtrees.rs +++ b/compiler/rustc_const_eval/src/const_eval/valtrees.rs @@ -1,6 +1,7 @@ use super::eval_queries::{mk_eval_cx, op_to_const}; use super::machine::CompileTimeEvalContext; use super::{ValTreeCreationError, ValTreeCreationResult, VALTREE_MAX_NODES}; +use crate::const_eval::CanAccessStatics; use crate::interpret::{ intern_const_alloc_recursive, ConstValue, ImmTy, Immediate, InternKind, MemPlaceMeta, MemoryKind, PlaceTy, Scalar, @@ -263,7 +264,11 @@ pub fn valtree_to_const_value<'tcx>( // FIXME Does this need an example? let (param_env, ty) = param_env_ty.into_parts(); - let mut ecx = mk_eval_cx(tcx, DUMMY_SP, param_env, false); + let mut ecx: crate::interpret::InterpCx< + '_, + '_, + crate::const_eval::CompileTimeInterpreter<'_, '_>, + > = mk_eval_cx(tcx, DUMMY_SP, param_env, CanAccessStatics::No); match ty.kind() { ty::FnDef(..) => { diff --git a/compiler/rustc_const_eval/src/util/check_validity_requirement.rs b/compiler/rustc_const_eval/src/util/check_validity_requirement.rs index 29063261adab..f56798d4c323 100644 --- a/compiler/rustc_const_eval/src/util/check_validity_requirement.rs +++ b/compiler/rustc_const_eval/src/util/check_validity_requirement.rs @@ -2,7 +2,7 @@ use rustc_middle::ty::layout::{LayoutCx, LayoutError, LayoutOf, TyAndLayout, Val use rustc_middle::ty::{ParamEnv, ParamEnvAnd, Ty, TyCtxt}; use rustc_target::abi::{Abi, FieldsShape, Scalar, Variants}; -use crate::const_eval::{CheckAlignment, CompileTimeInterpreter}; +use crate::const_eval::{CanAccessStatics, CheckAlignment, CompileTimeInterpreter}; use crate::interpret::{InterpCx, MemoryKind, OpTy}; /// Determines if this type permits "raw" initialization by just transmuting some memory into an @@ -44,8 +44,7 @@ fn might_permit_raw_init_strict<'tcx>( tcx: TyCtxt<'tcx>, kind: ValidityRequirement, ) -> Result> { - let machine = - CompileTimeInterpreter::new(/*can_access_statics:*/ false, CheckAlignment::Error); + let machine = CompileTimeInterpreter::new(CanAccessStatics::No, CheckAlignment::Error); let mut cx = InterpCx::new(tcx, rustc_span::DUMMY_SP, ParamEnv::reveal_all(), machine); From 9b97ae1d8c6e99a4832c84dec4d4b6faf5f583f6 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Sat, 24 Jun 2023 14:30:35 -0700 Subject: [PATCH 062/103] rustdoc: Update GUI test --- tests/rustdoc-gui/search-result-display.goml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/rustdoc-gui/search-result-display.goml b/tests/rustdoc-gui/search-result-display.goml index afb3a44be303..6593c1a9c45a 100644 --- a/tests/rustdoc-gui/search-result-display.goml +++ b/tests/rustdoc-gui/search-result-display.goml @@ -14,7 +14,8 @@ set-window-size: (600, 100) assert-size: (".search-results div.desc", {"width": 566}) // The result set is all on one line. -assert-css: (".search-results .result-name > span", {"display": "inline"}) +assert-css: (".search-results .result-name > span:not(.typename)", {"display": "inline"}) +assert-css: (".search-results .result-name > span.typename", {"display": "inline-block"}) // Check that the crate filter `