diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:11:28 +0000 |
commit | 94a0819fe3a0d679c3042a77bfe6a2afc505daea (patch) | |
tree | 2b827afe6a05f3538db3f7803a88c4587fe85648 /src/test/ui/mir | |
parent | Adding upstream version 1.64.0+dfsg1. (diff) | |
download | rustc-94a0819fe3a0d679c3042a77bfe6a2afc505daea.tar.xz rustc-94a0819fe3a0d679c3042a77bfe6a2afc505daea.zip |
Adding upstream version 1.66.0+dfsg1.upstream/1.66.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/mir')
-rw-r--r-- | src/test/ui/mir/drop-elaboration-after-borrowck-error.rs | 8 | ||||
-rw-r--r-- | src/test/ui/mir/drop-elaboration-after-borrowck-error.stderr | 21 | ||||
-rw-r--r-- | src/test/ui/mir/issue-100476-recursion-check-blewup.rs | 42 | ||||
-rw-r--r-- | src/test/ui/mir/issue-101844.rs | 73 | ||||
-rw-r--r-- | src/test/ui/mir/issue-102389.rs | 8 | ||||
-rw-r--r-- | src/test/ui/mir/issue-102389.stderr | 9 | ||||
-rw-r--r-- | src/test/ui/mir/issue-99852.rs | 24 | ||||
-rw-r--r-- | src/test/ui/mir/issue-99866.rs | 25 | ||||
-rw-r--r-- | src/test/ui/mir/mir-inlining/ice-issue-100550-unnormalized-projection.rs | 30 | ||||
-rw-r--r-- | src/test/ui/mir/mir_calls_to_shims.rs | 1 | ||||
-rw-r--r-- | src/test/ui/mir/mir_codegen_calls_diverging_drops.rs | 2 | ||||
-rw-r--r-- | src/test/ui/mir/mir_drop_order.rs | 1 | ||||
-rw-r--r-- | src/test/ui/mir/mir_drop_panics.rs | 1 | ||||
-rw-r--r-- | src/test/ui/mir/mir_let_chains_drop_order.rs | 9 | ||||
-rw-r--r-- | src/test/ui/mir/thir-constparam-temp.stderr | 2 |
15 files changed, 192 insertions, 64 deletions
diff --git a/src/test/ui/mir/drop-elaboration-after-borrowck-error.rs b/src/test/ui/mir/drop-elaboration-after-borrowck-error.rs index fc7341a56..624b464ec 100644 --- a/src/test/ui/mir/drop-elaboration-after-borrowck-error.rs +++ b/src/test/ui/mir/drop-elaboration-after-borrowck-error.rs @@ -3,9 +3,9 @@ static A: () = { let a: [String; 1]; - //~^ ERROR destructors cannot be evaluated at compile-time + //~^ ERROR destructor of a[0] = String::new(); - //~^ ERROR destructors cannot be evaluated at compile-time + //~^ ERROR destructor of //~| ERROR binding `a` isn't initialized }; @@ -14,9 +14,9 @@ struct B<T>([T; 1]); impl<T> B<T> { pub const fn f(mut self, other: T) -> Self { let _this = self; - //~^ ERROR destructors cannot be evaluated at compile-time + //~^ ERROR destructor of self.0[0] = other; - //~^ ERROR destructors cannot be evaluated at compile-time + //~^ ERROR destructor of //~| ERROR use of moved value self } diff --git a/src/test/ui/mir/drop-elaboration-after-borrowck-error.stderr b/src/test/ui/mir/drop-elaboration-after-borrowck-error.stderr index d8154f8d2..d96106172 100644 --- a/src/test/ui/mir/drop-elaboration-after-borrowck-error.stderr +++ b/src/test/ui/mir/drop-elaboration-after-borrowck-error.stderr @@ -1,17 +1,17 @@ -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `String` cannot be evaluated at compile-time --> $DIR/drop-elaboration-after-borrowck-error.rs:7:5 | LL | a[0] = String::new(); | ^^^^ | | - | statics cannot evaluate destructors + | the destructor for this type cannot be evaluated in statics | value is dropped here -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `[String; 1]` cannot be evaluated at compile-time --> $DIR/drop-elaboration-after-borrowck-error.rs:5:9 | LL | let a: [String; 1]; - | ^ statics cannot evaluate destructors + | ^ the destructor for this type cannot be evaluated in statics ... LL | }; | - value is dropped here @@ -24,21 +24,26 @@ LL | let a: [String; 1]; LL | LL | a[0] = String::new(); | ^^^^ `a` used here but it isn't initialized + | +help: consider assigning a value + | +LL | let a: [String; 1] = todo!(); + | +++++++++ -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `T` cannot be evaluated at compile-time --> $DIR/drop-elaboration-after-borrowck-error.rs:18:9 | LL | self.0[0] = other; | ^^^^^^^^^ | | - | constant functions cannot evaluate destructors + | the destructor for this type cannot be evaluated in constant functions | value is dropped here -error[E0493]: destructors cannot be evaluated at compile-time +error[E0493]: destructor of `B<T>` cannot be evaluated at compile-time --> $DIR/drop-elaboration-after-borrowck-error.rs:16:13 | LL | let _this = self; - | ^^^^^ constant functions cannot evaluate destructors + | ^^^^^ the destructor for this type cannot be evaluated in constant functions ... LL | } | - value is dropped here diff --git a/src/test/ui/mir/issue-100476-recursion-check-blewup.rs b/src/test/ui/mir/issue-100476-recursion-check-blewup.rs deleted file mode 100644 index bc2f32f4c..000000000 --- a/src/test/ui/mir/issue-100476-recursion-check-blewup.rs +++ /dev/null @@ -1,42 +0,0 @@ -// check-pass - -// compile-flags: --emit=mir,link -O - -// At one point the MIR inlining, when guarding against infinitely (or even just -// excessive) recursion, was using `ty::Instance` as the basis for its history -// check. The problem is that when you have polymorphic recursion, you can have -// distinct instances of the same code (because you're inlining the same code -// with differing substitutions), causing the amount of inlining to blow up -// exponentially. -// -// This test illustrates an example of that filed in issue rust#100476. - -#![allow(unconditional_recursion)] -#![feature(decl_macro)] - -macro emit($($m:ident)*) {$( - // Randomize `def_path_hash` by defining them under a module with - // different names - pub mod $m { - pub trait Tr { - type Next: Tr; - } - - pub fn hoge<const N: usize, T: Tr>() { - inner::<N, T>(); - } - - #[inline(always)] - fn inner<const N: usize, T: Tr>() { - inner::<N, T::Next>(); - } - } -)*} - -// Increase the chance of triggering the bug -emit!( - m00 m01 m02 m03 m04 m05 m06 m07 m08 m09 - m10 m11 m12 m13 m14 m15 m16 m17 m18 m19 -); - -fn main() { } diff --git a/src/test/ui/mir/issue-101844.rs b/src/test/ui/mir/issue-101844.rs new file mode 100644 index 000000000..da8a25f5f --- /dev/null +++ b/src/test/ui/mir/issue-101844.rs @@ -0,0 +1,73 @@ +// check-pass + +pub trait FirstTrait { + type Item; + type Extra: Extra<(), Error = Self::Item>; +} + +trait SecondTrait { + type Item2; +} + +trait ThirdTrait: SecondTrait { + type Item3; +} + +trait FourthTrait { + type Item4; +} + +impl<First> SecondTrait for First +where + First: FirstTrait, +{ + type Item2 = First::Extra; +} + +impl<Second, T> ThirdTrait for Second +where + Second: SecondTrait<Item2 = T>, +{ + type Item3 = T; +} + +impl<S, Third: ?Sized> FourthTrait for Third +where + Third: ThirdTrait<Item3 = S>, +{ + type Item4 = S; +} + +pub trait Extra<Request> { + type Error; +} + +struct ImplShoulExist<D, Req> { + _gen: (D, Req), +} + +impl<D, Req> ImplShoulExist<D, Req> +where + D: FourthTrait, + D::Item4: Extra<Req>, + <D::Item4 as Extra<Req>>::Error: Into<()>, +{ + fn access_fn(_: D) { + todo!() + } +} + +impl<D, Req> Extra<Req> for ImplShoulExist<D, Req> { + type Error = (); +} + +pub fn broken<MS>(ms: MS) +where + MS: FirstTrait, + MS::Item: Into<()>, +{ + // Error: Apparently Balance::new doesn't exist during MIR validation + let _ = ImplShoulExist::<MS, ()>::access_fn(ms); +} + +fn main() {} diff --git a/src/test/ui/mir/issue-102389.rs b/src/test/ui/mir/issue-102389.rs new file mode 100644 index 000000000..8b27d5e55 --- /dev/null +++ b/src/test/ui/mir/issue-102389.rs @@ -0,0 +1,8 @@ +enum Enum { A, B, C } + +fn func(inbounds: &Enum, array: &[i16; 3]) -> i16 { + array[*inbounds as usize] + //~^ ERROR [E0507] +} + +fn main() {} diff --git a/src/test/ui/mir/issue-102389.stderr b/src/test/ui/mir/issue-102389.stderr new file mode 100644 index 000000000..925dc258a --- /dev/null +++ b/src/test/ui/mir/issue-102389.stderr @@ -0,0 +1,9 @@ +error[E0507]: cannot move out of `*inbounds` which is behind a shared reference + --> $DIR/issue-102389.rs:4:11 + | +LL | array[*inbounds as usize] + | ^^^^^^^^^ move occurs because `*inbounds` has type `Enum`, which does not implement the `Copy` trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/src/test/ui/mir/issue-99852.rs b/src/test/ui/mir/issue-99852.rs new file mode 100644 index 000000000..1c675788e --- /dev/null +++ b/src/test/ui/mir/issue-99852.rs @@ -0,0 +1,24 @@ +// check-pass +// compile-flags: -Z validate-mir +#![feature(let_chains)] + +fn lambda<T, U>() -> U +where + T: Default, + U: Default, +{ + let foo: Result<T, ()> = Ok(T::default()); + let baz: U = U::default(); + + if let Ok(foo) = foo && let Ok(bar) = transform(foo) { + bar + } else { + baz + } +} + +fn transform<T, U>(input: T) -> Result<U, ()> { + todo!() +} + +fn main() {} diff --git a/src/test/ui/mir/issue-99866.rs b/src/test/ui/mir/issue-99866.rs new file mode 100644 index 000000000..d39ae6ebf --- /dev/null +++ b/src/test/ui/mir/issue-99866.rs @@ -0,0 +1,25 @@ +// check-pass +pub trait Backend { + type DescriptorSetLayout; +} + +pub struct Back; + +impl Backend for Back { + type DescriptorSetLayout = u32; +} + +pub struct HalSetLayouts { + vertex_layout: <Back as Backend>::DescriptorSetLayout, +} + +impl HalSetLayouts { + pub fn iter<DSL>(self) -> DSL + where + Back: Backend<DescriptorSetLayout = DSL>, + { + self.vertex_layout + } +} + +fn main() {} diff --git a/src/test/ui/mir/mir-inlining/ice-issue-100550-unnormalized-projection.rs b/src/test/ui/mir/mir-inlining/ice-issue-100550-unnormalized-projection.rs new file mode 100644 index 000000000..f67b07354 --- /dev/null +++ b/src/test/ui/mir/mir-inlining/ice-issue-100550-unnormalized-projection.rs @@ -0,0 +1,30 @@ +// This test verifies that we do not ICE due to MIR inlining in case of normalization failure +// in a projection. +// +// compile-flags: --crate-type lib -C opt-level=3 +// build-pass + +pub trait Trait { + type Associated; +} +impl<T> Trait for T { + type Associated = T; +} + +pub struct Struct<T>(<T as Trait>::Associated); + +pub fn foo<T>() -> Struct<T> +where + T: Trait, +{ + bar() +} + +#[inline] +fn bar<T>() -> Struct<T> { + Struct(baz()) +} + +fn baz<T>() -> T { + unimplemented!() +} diff --git a/src/test/ui/mir/mir_calls_to_shims.rs b/src/test/ui/mir/mir_calls_to_shims.rs index 42eaab77d..9dc0acfbf 100644 --- a/src/test/ui/mir/mir_calls_to_shims.rs +++ b/src/test/ui/mir/mir_calls_to_shims.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default #![feature(fn_traits)] #![feature(never_type)] diff --git a/src/test/ui/mir/mir_codegen_calls_diverging_drops.rs b/src/test/ui/mir/mir_codegen_calls_diverging_drops.rs index 796d74477..19dba4970 100644 --- a/src/test/ui/mir/mir_codegen_calls_diverging_drops.rs +++ b/src/test/ui/mir/mir_codegen_calls_diverging_drops.rs @@ -1,7 +1,7 @@ // run-fail // error-pattern:diverging_fn called // error-pattern:0 dropped -// ignore-emscripten no processes +// needs-unwind this test checks that a destructor is called after panicking struct Droppable(u8); impl Drop for Droppable { diff --git a/src/test/ui/mir/mir_drop_order.rs b/src/test/ui/mir/mir_drop_order.rs index 853efb0fe..75f5b171a 100644 --- a/src/test/ui/mir/mir_drop_order.rs +++ b/src/test/ui/mir/mir_drop_order.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default use std::cell::RefCell; use std::panic; diff --git a/src/test/ui/mir/mir_drop_panics.rs b/src/test/ui/mir/mir_drop_panics.rs index b4093d704..0d00426d6 100644 --- a/src/test/ui/mir/mir_drop_panics.rs +++ b/src/test/ui/mir/mir_drop_panics.rs @@ -2,7 +2,6 @@ // needs-unwind // error-pattern:panic 1 // error-pattern:drop 2 -// ignore-emscripten no processes struct Droppable(u32); impl Drop for Droppable { diff --git a/src/test/ui/mir/mir_let_chains_drop_order.rs b/src/test/ui/mir/mir_let_chains_drop_order.rs index 6498a5195..6471553e9 100644 --- a/src/test/ui/mir/mir_let_chains_drop_order.rs +++ b/src/test/ui/mir/mir_let_chains_drop_order.rs @@ -1,6 +1,5 @@ // run-pass // needs-unwind -// ignore-wasm32-bare compiled with panic=abort by default // See `mir_drop_order.rs` for more information @@ -13,7 +12,7 @@ use std::panic; pub struct DropLogger<'a, T> { extra: T, id: usize, - log: &'a panic::AssertUnwindSafe<RefCell<Vec<usize>>> + log: &'a panic::AssertUnwindSafe<RefCell<Vec<usize>>>, } impl<'a, T> Drop for DropLogger<'a, T> { @@ -56,9 +55,9 @@ fn main() { else { // 10 is not constructed d(10, None) - } + }, ); - assert_eq!(get(), vec![3, 8, 7, 1, 2]); + assert_eq!(get(), vec![8, 7, 1, 3, 2]); } assert_eq!(get(), vec![0, 4, 6, 9, 5]); @@ -90,5 +89,5 @@ fn main() { panic::panic_any(InjectedFailure) ); }); - assert_eq!(get(), vec![14, 19, 20, 17, 15, 11, 18, 16, 12, 13]); + assert_eq!(get(), vec![20, 17, 15, 11, 19, 18, 16, 12, 14, 13]); } diff --git a/src/test/ui/mir/thir-constparam-temp.stderr b/src/test/ui/mir/thir-constparam-temp.stderr index ed2766c00..b77d67e08 100644 --- a/src/test/ui/mir/thir-constparam-temp.stderr +++ b/src/test/ui/mir/thir-constparam-temp.stderr @@ -4,7 +4,6 @@ warning: taking a mutable reference to a `const` item LL | YIKES.mut_self() | ^^^^^^^^^^^^^^^^ | - = note: `#[warn(const_item_mutation)]` on by default = note: each usage of a `const` item creates a new temporary = note: the mutable reference will refer to this temporary, not the original `const` item note: mutable reference created due to call to this method @@ -17,6 +16,7 @@ note: `const` item defined here | LL | fn foo<const YIKES: Yikes>() { | ^^^^^^^^^^^^^^^^^^ + = note: `#[warn(const_item_mutation)]` on by default warning: 1 warning emitted |