diff options
Diffstat (limited to 'tests')
43 files changed, 690 insertions, 160 deletions
diff --git a/tests/codegen/sanitizer/kcfi-add-kcfi-flag.rs b/tests/codegen/sanitizer/kcfi-add-kcfi-flag.rs index c2eb852aec3..6d466b93c40 100644 --- a/tests/codegen/sanitizer/kcfi-add-kcfi-flag.rs +++ b/tests/codegen/sanitizer/kcfi-add-kcfi-flag.rs @@ -1,9 +1,20 @@ // Verifies that "kcfi" module flag is added. // -// needs-sanitizer-kcfi +// revisions: aarch64 x86_64 +// [aarch64] compile-flags: --target aarch64-unknown-none +// [aarch64] needs-llvm-components: aarch64 +// [x86_64] compile-flags: --target x86_64-unknown-none +// [x86_64] needs-llvm-components: x86 // compile-flags: -Ctarget-feature=-crt-static -Zsanitizer=kcfi +#![feature(no_core, lang_items)] #![crate_type="lib"] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="copy"] +trait Copy { } pub fn foo() { } diff --git a/tests/run-make/dump-ice-to-disk/check.sh b/tests/run-make/dump-ice-to-disk/check.sh index 91109596a45..ab6f9ab6018 100644 --- a/tests/run-make/dump-ice-to-disk/check.sh +++ b/tests/run-make/dump-ice-to-disk/check.sh @@ -22,8 +22,8 @@ rm $TMPDIR/rustc-ice-*.txt # Explicitly disabling ICE dump export RUSTC_ICE=0 $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-disabled.log 2>&1 -should_be_empty_tmp=$(ls -l $TMPDIR/rustc-ice-*.txt | wc -l) -should_be_empty_dot=$(ls -l ./rustc-ice-*.txt | wc -l) +should_be_empty_tmp=$(ls -l $TMPDIR/rustc-ice-*.txt 2>/dev/null | wc -l) +should_be_empty_dot=$(ls -l ./rustc-ice-*.txt 2>/dev/null | wc -l) echo "#### ICE Dump content:" echo $content diff --git a/tests/rustdoc-ui/custom_code_classes_in_docs-warning.rs b/tests/rustdoc-ui/custom_code_classes_in_docs-warning.rs index dd8759b7e37..5398d5833c7 100644 --- a/tests/rustdoc-ui/custom_code_classes_in_docs-warning.rs +++ b/tests/rustdoc-ui/custom_code_classes_in_docs-warning.rs @@ -57,25 +57,23 @@ pub fn foo8() {} /// ```{class=one=two} /// main; /// ``` -//~^^^ ERROR unexpected `=` +//~^^^ ERROR unexpected `=` character pub fn foo9() {} /// ```{.one.two} /// main; /// ``` -//~^^^ ERROR unexpected `.` character pub fn foo10() {} -/// ```{class=.one} +/// ```{class=(one} /// main; /// ``` -//~^^^ ERROR unexpected `.` character after `=` +//~^^^ ERROR unexpected `(` character after `=` pub fn foo11() {} /// ```{class=one.two} /// main; /// ``` -//~^^^ ERROR unexpected `.` character pub fn foo12() {} /// ```{(comment)} diff --git a/tests/rustdoc-ui/custom_code_classes_in_docs-warning.stderr b/tests/rustdoc-ui/custom_code_classes_in_docs-warning.stderr index 3e0dc4b2f7a..14b4b3bab3f 100644 --- a/tests/rustdoc-ui/custom_code_classes_in_docs-warning.stderr +++ b/tests/rustdoc-ui/custom_code_classes_in_docs-warning.stderr @@ -77,37 +77,21 @@ LL | | /// main; LL | | /// ``` | |_______^ -error: unexpected `.` character - --> $DIR/custom_code_classes_in_docs-warning.rs:63:1 +error: unexpected `(` character after `=` + --> $DIR/custom_code_classes_in_docs-warning.rs:68:1 | -LL | / /// ```{.one.two} -LL | | /// main; -LL | | /// ``` - | |_______^ - -error: unexpected `.` character after `=` - --> $DIR/custom_code_classes_in_docs-warning.rs:69:1 - | -LL | / /// ```{class=.one} -LL | | /// main; -LL | | /// ``` - | |_______^ - -error: unexpected `.` character - --> $DIR/custom_code_classes_in_docs-warning.rs:75:1 - | -LL | / /// ```{class=one.two} +LL | / /// ```{class=(one} LL | | /// main; LL | | /// ``` | |_______^ error: unexpected character `(` - --> $DIR/custom_code_classes_in_docs-warning.rs:81:1 + --> $DIR/custom_code_classes_in_docs-warning.rs:79:1 | LL | / /// ```{(comment)} LL | | /// main; LL | | /// ``` | |_______^ -error: aborting due to 13 previous errors +error: aborting due to 11 previous errors diff --git a/tests/rustdoc-ui/feature-gate-custom_code_classes_in_docs.rs b/tests/rustdoc-ui/feature-gate-custom_code_classes_in_docs.rs index 3f0f8b5b9f9..99263a944f8 100644 --- a/tests/rustdoc-ui/feature-gate-custom_code_classes_in_docs.rs +++ b/tests/rustdoc-ui/feature-gate-custom_code_classes_in_docs.rs @@ -8,3 +8,8 @@ //~| NOTE see issue #79483 <https://github.com/rust-lang/rust/issues/79483> //~| HELP add `#![feature(custom_code_classes_in_docs)]` to the crate attributes to enable pub struct Bar; + +/// ```ASN.1 +/// int main(void) { return 0; } +/// ``` +pub struct Bar2; diff --git a/tests/ui/abi/compatibility.rs b/tests/ui/abi/compatibility.rs index b3e75bb8233..d4f42cdda97 100644 --- a/tests/ui/abi/compatibility.rs +++ b/tests/ui/abi/compatibility.rs @@ -10,7 +10,6 @@ use std::ptr::NonNull; // Hence there are `cfg` throughout this test to disable parts of it on those targets. // sparc64: https://github.com/rust-lang/rust/issues/115336 // mips64: https://github.com/rust-lang/rust/issues/115404 -// riscv64: https://github.com/rust-lang/rust/issues/115481 // loongarch64: https://github.com/rust-lang/rust/issues/115509 macro_rules! assert_abi_compatible { @@ -110,7 +109,7 @@ macro_rules! test_transparent { test_abi_compatible!(wrap1, $t, Wrapper1<$t>); test_abi_compatible!(wrap2, $t, Wrapper2<$t>); test_abi_compatible!(wrap3, $t, Wrapper3<$t>); - #[cfg(not(any(target_arch = "riscv64", target_arch = "loongarch64")))] + #[cfg(not(target_arch = "loongarch64"))] test_abi_compatible!(wrap4, $t, WrapperUnion<$t>); } }; diff --git a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs new file mode 100644 index 00000000000..85d17ddff94 --- /dev/null +++ b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs @@ -0,0 +1,38 @@ +// edition: 2021 +// build-fail +//~^^ ERROR overflow evaluating the requirement `<A as Second>::{opaque#0} == _` + +#![feature(async_fn_in_trait)] + +fn main() { + let _ = async { + A.first().await.second().await; + }; +} + +pub trait First { + type Second: Second; + async fn first(self) -> Self::Second; +} + +struct A; + +impl First for A { + type Second = A; + async fn first(self) -> Self::Second { + A + } +} + +pub trait Second { + async fn second(self); +} + +impl<C> Second for C +where + C: First, +{ + async fn second(self) { + self.first().await.second().await; + } +} diff --git a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr new file mode 100644 index 00000000000..3f487a6e5fe --- /dev/null +++ b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr @@ -0,0 +1,5 @@ +error[E0275]: overflow evaluating the requirement `<A as Second>::{opaque#0} == _` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/async-await/issues/issue-66695-static-refs.rs b/tests/ui/async-await/issues/issue-66695-static-refs.rs index f0609713b4d..1b0e1c6c9e7 100644 --- a/tests/ui/async-await/issues/issue-66695-static-refs.rs +++ b/tests/ui/async-await/issues/issue-66695-static-refs.rs @@ -1,12 +1,15 @@ // build-pass // edition:2018 +#![feature(if_let_guard)] + static A: [i32; 5] = [1, 2, 3, 4, 5]; async fn fun() { let u = A[async { 1 }.await]; match A { i if async { true }.await => (), + i if let Some(1) = async { Some(1) }.await => (), _ => (), } } @@ -18,6 +21,7 @@ fn main() { async { match A { i if async { true }.await => (), + i if let Some(2) = async { Some(2) }.await => (), _ => (), } }; diff --git a/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs b/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs index c4f8f607d25..80d824d3b2e 100644 --- a/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs +++ b/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs @@ -5,6 +5,8 @@ // [drop_tracking] compile-flags: -Zdrop-tracking // [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir +#![feature(if_let_guard)] + static mut A: [i32; 5] = [1, 2, 3, 4, 5]; fn is_send_sync<T: Send + Sync>(_: T) {} @@ -14,6 +16,7 @@ async fn fun() { unsafe { match A { i if async { true }.await => (), + i if let Some(1) = async { Some(1) }.await => (), _ => (), } } @@ -27,6 +30,7 @@ fn main() { unsafe { match A { i if async { true }.await => (), + i if let Some(2) = async { Some(2) }.await => (), _ => (), } } diff --git a/tests/ui/async-await/missed-capture-issue-107414.rs b/tests/ui/async-await/missed-capture-issue-107414.rs index 0ab4f5ade98..bb14eb74b3a 100644 --- a/tests/ui/async-await/missed-capture-issue-107414.rs +++ b/tests/ui/async-await/missed-capture-issue-107414.rs @@ -1,6 +1,8 @@ // check-pass // edition:2018 +#![feature(if_let_guard)] + fn main() {} struct StructA {} @@ -22,3 +24,10 @@ async fn ice() { _ => {} } } + +async fn if_let() { + match Some(StructB {}) { + Some(struct_b) if let true = get_struct_a_async().await.fn_taking_struct_b(&struct_b) => {} + _ => {} + } +} diff --git a/tests/ui/binding/match-beginning-vert.rs b/tests/ui/binding/match-beginning-vert.rs index 79267400b28..93c08f0b710 100644 --- a/tests/ui/binding/match-beginning-vert.rs +++ b/tests/ui/binding/match-beginning-vert.rs @@ -1,4 +1,7 @@ // run-pass + +#![feature(if_let_guard)] + enum Foo { A, B, @@ -13,6 +16,7 @@ fn main() { match *foo { | A => println!("A"), | B | C if 1 < 2 => println!("BC!"), + | D if let 1 = 1 => println!("D!"), | _ => {}, } } diff --git a/tests/ui/const-generics/late-bound-vars/in_closure.rs b/tests/ui/const-generics/late-bound-vars/in_closure.rs index 6549cad629b..443c755c601 100644 --- a/tests/ui/const-generics/late-bound-vars/in_closure.rs +++ b/tests/ui/const-generics/late-bound-vars/in_closure.rs @@ -1,23 +1,5 @@ -// failure-status: 1 // known-bug: unknown -// error-pattern:internal compiler error -// normalize-stderr-test "internal compiler error.*" -> "" -// normalize-stderr-test "DefId\([^)]*\)" -> "..." -// normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> "" -// normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> "" -// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" -// normalize-stderr-test "note: compiler flags.*\n\n" -> "" -// normalize-stderr-test "note: rustc.*running on.*\n\n" -> "" -// normalize-stderr-test "thread.*panicked.*:\n.*\n" -> "" -// normalize-stderr-test "stack backtrace:\n" -> "" -// normalize-stderr-test "\s\d{1,}: .*\n" -> "" -// normalize-stderr-test "\s at .*\n" -> "" -// normalize-stderr-test ".*note: Some details.*\n" -> "" -// normalize-stderr-test "\n[ ]*\n" -> "" -// normalize-stderr-test "compiler/.*: projection" -> "projection" -// normalize-stderr-test ".*omitted \d{1,} frame.*\n" -> "" -// normalize-stderr-test "error: [\s\n]*query stack during panic:\n" -> "" -// this should run-pass +// see comment on `tests/ui/const-generics/late-bound-vars/simple.rs` #![feature(generic_const_exprs)] #![allow(incomplete_features)] diff --git a/tests/ui/const-generics/late-bound-vars/in_closure.stderr b/tests/ui/const-generics/late-bound-vars/in_closure.stderr index ac406bf2bb1..e15496454a0 100644 --- a/tests/ui/const-generics/late-bound-vars/in_closure.stderr +++ b/tests/ui/const-generics/late-bound-vars/in_closure.stderr @@ -1,10 +1,20 @@ -#0 [mir_borrowck] borrow-checking `test::{closure#0}::{constant#1}` -#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `test::{closure#0}::{constant#1}` -#2 [mir_for_ctfe] caching mir of `test::{closure#0}::{constant#1}` for CTFE -#3 [eval_to_allocation_raw] const-evaluating + checking `test::{closure#0}::{constant#1}` -#4 [eval_to_allocation_raw] const-evaluating + checking `test::{closure#0}::{constant#1}` -#5 [eval_to_valtree] evaluating type-level constant -#6 [typeck] type-checking `test` -#7 [analysis] running analysis passes on this crate -end of query stack -error: aborting due to previous error \ No newline at end of file +error: cannot capture late-bound lifetime in constant + --> $DIR/in_closure.rs:16:29 + | +LL | fn test<'a>() { + | -- lifetime defined here +LL | let _ = || { +LL | let _: [u8; inner::<'a>()]; + | ^^ + +error: cannot capture late-bound lifetime in constant + --> $DIR/in_closure.rs:17:29 + | +LL | fn test<'a>() { + | -- lifetime defined here +... +LL | let _ = [0; inner::<'a>()]; + | ^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/const-generics/late-bound-vars/late-bound-in-return-issue-77357.rs b/tests/ui/const-generics/late-bound-vars/late-bound-in-return-issue-77357.rs new file mode 100644 index 00000000000..b81aa50d9a9 --- /dev/null +++ b/tests/ui/const-generics/late-bound-vars/late-bound-in-return-issue-77357.rs @@ -0,0 +1,13 @@ +// known-bug: unknown +// see comment on `tests/ui/const-generics/late-bound-vars/simple.rs` + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +trait MyTrait<T> {} + +fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> { + todo!() +} + +fn main() {} diff --git a/tests/ui/const-generics/late-bound-vars/late-bound-in-return-issue-77357.stderr b/tests/ui/const-generics/late-bound-vars/late-bound-in-return-issue-77357.stderr new file mode 100644 index 00000000000..21c8fe6865c --- /dev/null +++ b/tests/ui/const-generics/late-bound-vars/late-bound-in-return-issue-77357.stderr @@ -0,0 +1,8 @@ +error: cannot capture late-bound lifetime in constant + --> $DIR/late-bound-in-return-issue-77357.rs:9:53 + | +LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> { + | -- lifetime defined here ^^ + +error: aborting due to previous error + diff --git a/tests/ui/const-generics/late-bound-vars/late-bound-in-where-issue-83993.rs b/tests/ui/const-generics/late-bound-vars/late-bound-in-where-issue-83993.rs new file mode 100644 index 00000000000..89f01748fc9 --- /dev/null +++ b/tests/ui/const-generics/late-bound-vars/late-bound-in-where-issue-83993.rs @@ -0,0 +1,15 @@ +// known-bug: unknown +// see comment on `tests/ui/const-generics/late-bound-vars/simple.rs` + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +fn bug<'a>() +where + for<'b> [(); { + let x: &'b (); + 0 + }]: +{} + +fn main() {} diff --git a/tests/ui/const-generics/late-bound-vars/late-bound-in-where-issue-83993.stderr b/tests/ui/const-generics/late-bound-vars/late-bound-in-where-issue-83993.stderr new file mode 100644 index 00000000000..a66dc8db914 --- /dev/null +++ b/tests/ui/const-generics/late-bound-vars/late-bound-in-where-issue-83993.stderr @@ -0,0 +1,10 @@ +error: cannot capture late-bound lifetime in constant + --> $DIR/late-bound-in-where-issue-83993.rs:10:17 + | +LL | for<'b> [(); { + | -- lifetime defined here +LL | let x: &'b (); + | ^^ + +error: aborting due to previous error + diff --git a/tests/ui/const-generics/late-bound-vars/simple.rs b/tests/ui/const-generics/late-bound-vars/simple.rs index 544073b5a56..a562bd8cb41 100644 --- a/tests/ui/const-generics/late-bound-vars/simple.rs +++ b/tests/ui/const-generics/late-bound-vars/simple.rs @@ -1,22 +1,13 @@ -// failure-status: 101 // known-bug: unknown -// error-pattern:internal compiler error -// normalize-stderr-test "internal compiler error.*" -> "" -// normalize-stderr-test "DefId\([^)]*\)" -> "..." -// normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> "" -// normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> "" -// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" -// normalize-stderr-test "note: compiler flags.*\n\n" -> "" -// normalize-stderr-test "note: rustc.*running on.*\n\n" -> "" -// normalize-stderr-test "thread.*panicked.*:\n.*\n" -> "" -// normalize-stderr-test "stack backtrace:\n" -> "" -// normalize-stderr-test "\s\d{1,}: .*\n" -> "" -// normalize-stderr-test "\s at .*\n" -> "" -// normalize-stderr-test ".*note: Some details.*\n" -> "" -// normalize-stderr-test "\n\n[ ]*\n" -> "" -// normalize-stderr-test "compiler/.*: projection" -> "projection" -// normalize-stderr-test ".*omitted \d{1,} frame.*\n" -> "" -// normalize-stderr-test "error: [\s\n]*query stack" -> "error: query stack" + +// If we want this to compile, then we'd need to do something like RPITs do, +// where nested associated constants have early-bound versions of their captured +// late-bound vars inserted into their generics. This gives us substitutable +// lifetimes to actually use when borrow-checking the associated const, which is +// lowered as a totally separate body from its parent. Since this doesn't exist, +// we should just error rather than resolving this late-bound var with no +// binder to actually attach it to, or worse, as a free region that can't even be +// substituted correctly, and ICEing. - @compiler-errors #![feature(generic_const_exprs)] #![allow(incomplete_features)] diff --git a/tests/ui/const-generics/late-bound-vars/simple.stderr b/tests/ui/const-generics/late-bound-vars/simple.stderr index c9f2164b635..e72e373630d 100644 --- a/tests/ui/const-generics/late-bound-vars/simple.stderr +++ b/tests/ui/const-generics/late-bound-vars/simple.stderr @@ -1,12 +1,19 @@ -error: query stack during panic: -#0 [mir_borrowck] borrow-checking `test::{constant#1}` -#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `test::{constant#1}` -#2 [mir_for_ctfe] caching mir of `test::{constant#1}` for CTFE -#3 [eval_to_allocation_raw] const-evaluating + checking `test::{constant#1}` -#4 [eval_to_allocation_raw] const-evaluating + checking `test::{constant#1}` -#5 [eval_to_valtree] evaluating type-level constant -#6 [typeck] type-checking `test` -#7 [analysis] running analysis passes on this crate -end of query stack -error: aborting due to previous error +error: cannot capture late-bound lifetime in constant + --> $DIR/simple.rs:20:25 + | +LL | fn test<'a>() { + | -- lifetime defined here +LL | let _: [u8; inner::<'a>()]; + | ^^ + +error: cannot capture late-bound lifetime in constant + --> $DIR/simple.rs:21:25 + | +LL | fn test<'a>() { + | -- lifetime defined here +LL | let _: [u8; inner::<'a>()]; +LL | let _ = [0; inner::<'a>()]; + | ^^ + +error: aborting due to 2 previous errors diff --git a/tests/ui/consts/escaping-bound-var.rs b/tests/ui/consts/escaping-bound-var.rs new file mode 100644 index 00000000000..7c1fbd24f55 --- /dev/null +++ b/tests/ui/consts/escaping-bound-var.rs @@ -0,0 +1,13 @@ +#![feature(generic_const_exprs)] +//~^ WARN the feature `generic_const_exprs` is incomplete + +fn test<'a>( + _: &'a (), +) -> [(); { + let x: &'a (); + //~^ ERROR cannot capture late-bound lifetime in constant + 1 +}] { +} + +fn main() {} diff --git a/tests/ui/consts/escaping-bound-var.stderr b/tests/ui/consts/escaping-bound-var.stderr new file mode 100644 index 00000000000..d26ae2cee1c --- /dev/null +++ b/tests/ui/consts/escaping-bound-var.stderr @@ -0,0 +1,20 @@ +warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/escaping-bound-var.rs:1:12 + | +LL | #![feature(generic_const_exprs)] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information + = note: `#[warn(incomplete_features)]` on by default + +error: cannot capture late-bound lifetime in constant + --> $DIR/escaping-bound-var.rs:7:13 + | +LL | fn test<'a>( + | -- lifetime defined here +... +LL | let x: &'a (); + | ^^ + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/ui/drop/dynamic-drop.rs b/tests/ui/drop/dynamic-drop.rs index 9e51d3adaaa..caef6358ea7 100644 --- a/tests/ui/drop/dynamic-drop.rs +++ b/tests/ui/drop/dynamic-drop.rs @@ -2,6 +2,7 @@ // needs-unwind #![feature(generators, generator_trait)] +#![feature(if_let_guard)] #![allow(unused_assignments)] #![allow(unused_variables)] @@ -332,6 +333,16 @@ fn move_ref_pattern(a: &Allocator) { let (ref _a, ref mut _b, _c, mut _d) = tup; } +fn if_let_guard(a: &Allocator, c: bool, d: i32) { + let foo = if c { Some(a.alloc()) } else { None }; + + match d == 0 { + false if let Some(a) = foo => { let b = a; } + true if let true = { drop(foo.unwrap_or_else(|| a.alloc())); d == 1 } => {} + _ => {} + } +} + fn panic_after_return(a: &Allocator) -> Ptr<'_> { // Panic in the drop of `p` or `q` can leak let exceptions = vec![8, 9]; @@ -497,6 +508,13 @@ fn main() { run_test(|a| move_ref_pattern(a)); + run_test(|a| if_let_guard(a, true, 0)); + run_test(|a| if_let_guard(a, true, 1)); + run_test(|a| if_let_guard(a, true, 2)); + run_test(|a| if_let_guard(a, false, 0)); + run_test(|a| if_let_guard(a, false, 1)); + run_test(|a| if_let_guard(a, false, 2)); + run_test(|a| { panic_after_return(a); }); diff --git a/tests/ui/match/issue-115681.rs b/tests/ui/match/issue-115681.rs new file mode 100644 index 00000000000..c41e808e170 --- /dev/null +++ b/tests/ui/match/issue-115681.rs @@ -0,0 +1,32 @@ +// run-pass +// compile-flags: -C opt-level=1 + +// Make sure LLVM does not miscompile this match. +fn main() { + enum Bits { + None = 0x00, + Low = 0x40, + High = 0x80, + Both = 0xC0, + } + + let value = Box::new(0x40u8); + let mut out = Box::new(0u8); + + let bits = match *value { + 0x00 => Bits::None, + 0x40 => Bits::Low, + 0x80 => Bits::High, + 0xC0 => Bits::Both, + _ => return, + }; + + match bits { + Bits::None | Bits::Low => { + *out = 1; + } + _ => (), + } + + assert_eq!(*out, 1); +} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/const-expr.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/const-expr.rs new file mode 100644 index 00000000000..5c42c0d8bec --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/const-expr.rs @@ -0,0 +1,26 @@ +// Ensure if let guards can be used in constant expressions. +// build-pass + +#![feature(if_let_guard)] + +const fn match_if_let(x: Option<i32>, y: Option<i32>) -> i32 { + match x { + None if let Some(a @ 5) = y => a, + Some(z) if let (Some(_), 12) = (y, z) => 2, + _ => 3, + } +} + +const ASSERTS: usize = { + assert!(match_if_let(None, Some(5)) == 5); + assert!(match_if_let(Some(12), Some(3)) == 2); + assert!(match_if_let(None, Some(4)) == 3); + assert!(match_if_let(Some(11), Some(3)) == 3); + assert!(match_if_let(Some(12), None) == 3); + assert!(match_if_let(None, None) == 3); + 0 +}; + +fn main() { + let _: [(); ASSERTS]; +} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let-chain.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let-chain.rs new file mode 100644 index 00000000000..5c333cd7795 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let-chain.rs @@ -0,0 +1,97 @@ +#![feature(if_let_guard)] +#![feature(let_chains)] +#![allow(irrefutable_let_patterns)] + +fn same_pattern(c: bool) { + let x: Box<_> = Box::new(1); + + let v = (1, 2); + + match v { + (1, 2) if let y = x && c => (), + (1, 2) if let z = x => (), //~ ERROR use of moved value: `x` + _ => (), + } +} + +fn same_pattern_ok(c: bool) { + let x: Box<_> = Box::new(1); + + let v = (1, 2); + + match v { + (1, 2) if c && let y = x => (), + (1, 2) if let z = x => (), + _ => (), + } +} + +fn different_patterns(c: bool) { + let x: Box<_> = Box::new(1); + + let v = (1, 2); + + match v { + (1, _) if let y = x && c => (), + (_, 2) if let z = x => (), //~ ERROR use of moved value: `x` + _ => (), + } +} + +fn different_patterns_ok(c: bool) { + let x: Box<_> = Box::new(1); + + let v = (1, 2); + + match v { + (1, _) if c && let y = x => (), + (_, 2) if let z = x => (), + _ => (), + } +} + +fn or_pattern(c: bool) { + let x: Box<_> = Box::new(1); + + let v = (1, 2); + + match v { + (1, _) | (_, 2) if let y = x && c => (), //~ ERROR use of moved value: `x` + _ => (), + } +} + +fn or_pattern_ok(c: bool) { + let x: Box<_> = Box::new(1); + + let v = (1, 2); + + match v { + (1, _) | (_, 2) if c && let y = x => (), + _ => (), + } +} + +fn use_in_arm(c: bool) { + let x: Box<_> = Box::new(1); + + let v = (1, 2); + + match v { + (1, 2) if let y = x && c => false, + _ => { *x == 1 }, //~ ERROR use of moved value: `x` + }; +} + +fn use_in_arm_ok(c: bool) { + let x: Box<_> = Box::new(1); + + let v = (1, 2); + + match v { + (1, 2) if c && let y = x => false, + _ => { *x == 1 }, + }; +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let-chain.stderr b/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let-chain.stderr new file mode 100644 index 00000000000..d27fde58244 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let-chain.stderr @@ -0,0 +1,67 @@ +error[E0382]: use of moved value: `x` + --> $DIR/move-guard-if-let-chain.rs:12:27 + | +LL | let x: Box<_> = Box::new(1); + | - move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait +... +LL | (1, 2) if let y = x && c => (), + | - value moved here +LL | (1, 2) if let z = x => (), + | ^ value used here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | (1, 2) if let ref y = x && c => (), + | +++ + +error[E0382]: use of moved value: `x` + --> $DIR/move-guard-if-let-chain.rs:36:27 + | +LL | let x: Box<_> = Box::new(1); + | - move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait +... +LL | (1, _) if let y = x && c => (), + | - value moved here +LL | (_, 2) if let z = x => (), + | ^ value used here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | (1, _) if let ref y = x && c => (), + | +++ + +error[E0382]: use of moved value: `x` + --> $DIR/move-guard-if-let-chain.rs:59:36 + | +LL | let x: Box<_> = Box::new(1); + | - move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait +... +LL | (1, _) | (_, 2) if let y = x && c => (), + | - ^ value used here after move + | | + | value moved here + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | (1, _) | (_, 2) if let ref y = x && c => (), + | +++ + +error[E0382]: use of moved value: `x` + --> $DIR/move-guard-if-let-chain.rs:82:16 + | +LL | let x: Box<_> = Box::new(1); + | - move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait +... +LL | (1, 2) if let y = x && c => false, + | - value moved here +LL | _ => { *x == 1 }, + | ^^ value used here after move + | +help: borrow this binding in the pattern to avoid moving the value + | +LL | (1, 2) if let ref y = x && c => false, + | +++ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let.rs new file mode 100644 index 00000000000..071b86e2e14 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/move-guard-if-let.rs @@ -0,0 +1,41 @@ +// Check that borrowck knows that moves in the pattern for if-let guards +// only happen when the pattern is matched. + +// build-pass + +#![feature(if_let_guard)] +#![allow(irrefutable_let_patterns)] + +fn same_pattern() { + let x: Box<_> = Box::new(1); + + let v = (1, 2); + + match v { + (1, 2) if let y = x => (), + (1, 2) if let z = x => (), + _ => (), + } +} + +fn or_pattern() { + let x: Box<_> = Box::new(1); + + let v = (1, 2); + + match v { + (1, _) | (_, 2) if let y = x => (), + _ => (), + } +} + +fn main() { + let x: Box<_> = Box::new(1); + + let v = (1, 2); + + match v { + (1, 2) if let y = x => false, + _ => { *x == 1 }, + }; +} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/type-inference.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/type-inference.rs new file mode 100644 index 00000000000..ef7a772e6c5 --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/type-inference.rs @@ -0,0 +1,16 @@ +// check-pass + +#![feature(if_let_guard)] + +struct S; + +fn get<T>() -> Option<T> { + None +} + +fn main() { + match get() { + x if let Some(S) = x => {} + _ => {} + } +} diff --git a/tests/ui/sanitize/cfg.rs b/tests/ui/sanitize/cfg.rs index 523de1ceaee..f8ccf3b042d 100644 --- a/tests/ui/sanitize/cfg.rs +++ b/tests/ui/sanitize/cfg.rs @@ -1,15 +1,15 @@ // Verifies that when compiling with -Zsanitizer=option, // the `#[cfg(sanitize = "option")]` attribute is configured. -// needs-sanitizer-support // check-pass // revisions: address cfi kcfi leak memory thread //[address]needs-sanitizer-address //[address]compile-flags: -Zsanitizer=address --cfg address //[cfi]needs-sanitizer-cfi -//[cfi]compile-flags: -Zsanitizer=cfi --cfg cfi -Clto -//[kcfi]needs-sanitizer-kcfi -//[kcfi]compile-flags: -Zsanitizer=kcfi --cfg kcfi +//[cfi]compile-flags: -Zsanitizer=cfi --cfg cfi +//[cfi]compile-flags: -Clto -Ccodegen-units=1 -Ctarget-feature=-crt-static +//[kcfi]needs-llvm-components: x86 +//[kcfi]compile-flags: -Zsanitizer=kcfi --cfg kcfi --target x86_64-unknown-none //[leak]needs-sanitizer-leak //[leak]compile-flags: -Zsanitizer=leak --cfg leak //[memory]needs-sanitizer-memory @@ -17,7 +17,14 @@ //[thread]needs-sanitizer-thread //[thread]compile-flags: -Zsanitizer=thread --cfg thread -#![feature(cfg_sanitize)] +#![feature(cfg_sanitize, no_core, lang_items)] +#![crate_type="lib"] +#![no_core] + +#[lang="sized"] +trait Sized { } +#[lang="copy"] +trait Copy { } #[cfg(all(sanitize = "address", address))] fn main() {} @@ -36,3 +43,7 @@ fn main() {} #[cfg(all(sanitize = "thread", thread))] fn main() {} + +pub fn check() { + main(); +} diff --git a/tests/ui/traits/non_lifetime_binders/capture-late-ct-in-anon.rs b/tests/ui/traits/non_lifetime_binders/capture-late-ct-in-anon.rs index 91c6dfb8e0a..bbae67f0bad 100644 --- a/tests/ui/traits/non_lifetime_binders/capture-late-ct-in-anon.rs +++ b/tests/ui/traits/non_lifetime_binders/capture-late-ct-in-anon.rs @@ -4,7 +4,7 @@ fn b() where for<const C: usize> [(); C]: Copy, - //~^ ERROR cannot capture late-bound const parameter in a constant + //~^ ERROR cannot capture late-bound const parameter in constant { } diff --git a/tests/ui/traits/non_lifetime_binders/capture-late-ct-in-anon.stderr b/tests/ui/traits/non_lifetime_binders/capture-late-ct-in-anon.stderr index 69bb605bf41..d65892ec6df 100644 --- a/tests/ui/traits/non_lifetime_binders/capture-late-ct-in-anon.stderr +++ b/tests/ui/traits/non_lifetime_binders/capture-late-ct-in-anon.stderr @@ -7,7 +7,7 @@ LL | #![feature(non_lifetime_binders)] = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information = note: `#[warn(incomplete_features)]` on by default -error: cannot capture late-bound const parameter in a constant +error: cannot capture late-bound const parameter in constant --> $DIR/capture-late-ct-in-anon.rs:6:30 | LL | for<const C: usize> [(); C]: Copy, diff --git a/tests/ui/traits/non_lifetime_binders/late-bound-in-anon-ct.rs b/tests/ui/traits/non_lifetime_binders/late-bound-in-anon-ct.rs index 3903bfe9bcf..64f09f823fc 100644 --- a/tests/ui/traits/non_lifetime_binders/late-bound-in-anon-ct.rs +++ b/tests/ui/traits/non_lifetime_binders/late-bound-in-anon-ct.rs @@ -5,7 +5,7 @@ fn foo() -> usize where for<T> [i32; { let _: T = todo!(); 0 }]:, - //~^ ERROR cannot capture late-bound type parameter in a constant + //~^ ERROR cannot capture late-bound type parameter in constant {} fn main() {} diff --git a/tests/ui/traits/non_lifetime_binders/late-bound-in-anon-ct.stderr b/tests/ui/traits/non_lifetime_binders/late-bound-in-anon-ct.stderr index fafff02dea6..dc54e1acc39 100644 --- a/tests/ui/traits/non_lifetime_binders/late-bound-in-anon-ct.stderr +++ b/tests/ui/traits/non_lifetime_binders/late-bound-in-anon-ct.stderr @@ -15,7 +15,7 @@ LL | #![feature(non_lifetime_binders, generic_const_exprs)] | = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information -error: cannot capture late-bound type parameter in a constant +error: cannot capture late-bound type parameter in constant --> $DIR/late-bound-in-anon-ct.rs:7:27 | LL | for<T> [i32; { let _: T = todo!(); 0 }]:, diff --git a/tests/ui/type-alias-impl-trait/escaping-bound-var.rs b/tests/ui/type-alias-impl-trait/escaping-bound-var.rs new file mode 100644 index 00000000000..bf27e76db2b --- /dev/null +++ b/tests/ui/type-alias-impl-trait/escaping-bound-var.rs @@ -0,0 +1,22 @@ +#![feature(type_alias_impl_trait)] + +pub trait Trait<'a> { + type Assoc; +} + +trait Test<'a> {} + +pub type Foo = impl for<'a> Trait<'a, Assoc = impl Test<'a>>; +//~^ ERROR cannot capture late-bound lifetime in type alias impl trait + +impl Trait<'_> for () { + type Assoc = (); +} + +impl Test<'_> for () {} + +fn constrain() -> Foo { + () +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/escaping-bound-var.stderr b/tests/ui/type-alias-impl-trait/escaping-bound-var.stderr new file mode 100644 index 00000000000..8205a60ccdd --- /dev/null +++ b/tests/ui/type-alias-impl-trait/escaping-bound-var.stderr @@ -0,0 +1,8 @@ +error: cannot capture late-bound lifetime in type alias impl trait + --> $DIR/escaping-bound-var.rs:9:57 + | +LL | pub type Foo = impl for<'a> Trait<'a, Assoc = impl Test<'a>>; + | -- lifetime defined here ^^ + +error: aborting due to previous error + diff --git a/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.rs b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.rs new file mode 100644 index 00000000000..baa22e1ce18 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.rs @@ -0,0 +1,29 @@ +// edition: 2021 +// build-fail +//~^^ ERROR overflow evaluating the requirement `<() as Recur>::Recur == _` + +#![feature(impl_trait_in_assoc_type)] + +use core::future::Future; + +trait Recur { + type Recur: Future<Output = ()>; + + fn recur(self) -> Self::Recur; +} + +async fn recur(t: impl Recur) { + t.recur().await; +} + +impl Recur for () { + type Recur = impl Future<Output = ()>; + + fn recur(self) -> Self::Recur { + async move { recur(self).await; } + } +} + +fn main() { + recur(()); +} diff --git a/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr new file mode 100644 index 00000000000..0238694c24d --- /dev/null +++ b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr @@ -0,0 +1,5 @@ +error[E0275]: overflow evaluating the requirement `<() as Recur>::Recur == _` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/type-alias-impl-trait/mututally-recursive-overflow.rs b/tests/ui/type-alias-impl-trait/mututally-recursive-overflow.rs new file mode 100644 index 00000000000..1ccd1b0cbad --- /dev/null +++ b/tests/ui/type-alias-impl-trait/mututally-recursive-overflow.rs @@ -0,0 +1,40 @@ +// edition: 2021 +// build-fail +//~^^ ERROR overflow evaluating the requirement `<() as B>::Assoc == _` + +#![feature(rustc_attrs)] +#![feature(impl_trait_in_assoc_type)] + +#[rustc_coinductive] +trait A { + type Assoc; + + fn test() -> Self::Assoc; +} + +#[rustc_coinductive] +trait B { + type Assoc; + + fn test() -> Self::Assoc; +} + +impl<T: A> B for T { + type Assoc = impl Sized; + + fn test() -> <Self as B>::Assoc { + <T as A>::test() + } +} + +fn main() { + <() as A>::test(); +} + +impl<T: B> A for T { + type Assoc = impl Sized; + + fn test() -> <Self as A>::Assoc { + <T as B>::test() + } +} diff --git a/tests/ui/type-alias-impl-trait/mututally-recursive-overflow.stderr b/tests/ui/type-alias-impl-trait/mututally-recursive-overflow.stderr new file mode 100644 index 00000000000..49c59f7eb37 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/mututally-recursive-overflow.stderr @@ -0,0 +1,5 @@ +error[E0275]: overflow evaluating the requirement `<() as B>::Assoc == _` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/type-alias-impl-trait/variance.rs b/tests/ui/type-alias-impl-trait/variance.rs index eba4816003b..e92cf2513e7 100644 --- a/tests/ui/type-alias-impl-trait/variance.rs +++ b/tests/ui/type-alias-impl-trait/variance.rs @@ -9,42 +9,36 @@ type NotCapturedEarly<'a> = impl Sized; //~ [o] type CapturedEarly<'a> = impl Sized + Captures<'a>; //~ [o] +// TAIT does *not* capture `'b` type NotCapturedLate<'a> = dyn for<'b> Iterator<Item = impl Sized>; //~ [o] -type CapturedLate<'a> = dyn for<'b> Iterator<Item = impl Sized + Captures<'b>>; //~ [o] - -type Captured<'a> = dyn for<'b> Iterator<Item = impl Sized + Captures<'a> + Captures<'b>>; //~ [o] +// TAIT does *not* capture `'b` +type Captured<'a> = dyn for<'b> Iterator<Item = impl Sized + Captures<'a>>; //~ [o] type Bar<'a, 'b: 'b, T> = impl Sized; //~ ERROR [o, o, o] trait Foo<'i> { - type ImplicitCapturedEarly<'a>; - - type ExplicitCaptureEarly<'a>; + type ImplicitCapture<'a>; - type ImplicitCaptureLate<'a>; + type ExplicitCaptureFromHeader<'a>; - type ExplicitCaptureLate<'a>; + type ExplicitCaptureFromGat<'a>; } impl<'i> Foo<'i> for &'i () { - type ImplicitCapturedEarly<'a> = impl Sized; //~ [o, o] + type ImplicitCapture<'a> = impl Sized; //~ [o, o] - type ExplicitCaptureEarly<'a> = impl Sized + Captures<'i>; //~ [o, o] + type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>; //~ [o, o] - type ImplicitCaptureLate<'a> = impl Sized; //~ [o, o] - - type ExplicitCaptureLate<'a> = impl Sized + Captures<'a>; //~ [o, o] + type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>; //~ [o, o] } impl<'i> Foo<'i> for () { - type ImplicitCapturedEarly<'a> = impl Sized; //~ [o, o] - - type ExplicitCaptureEarly<'a> = impl Sized + Captures<'i>; //~ [o, o] + type ImplicitCapture<'a> = impl Sized; //~ [o, o] - type ImplicitCaptureLate<'a> = impl Sized; //~ [o, o] + type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>; //~ [o, o] - type ExplicitCaptureLate<'a> = impl Sized + Captures<'a>; //~ [o, o] + type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>; //~ [o, o] } fn main() {} diff --git a/tests/ui/type-alias-impl-trait/variance.stderr b/tests/ui/type-alias-impl-trait/variance.stderr index f73cf617a4c..1794447c89a 100644 --- a/tests/ui/type-alias-impl-trait/variance.stderr +++ b/tests/ui/type-alias-impl-trait/variance.stderr @@ -11,22 +11,16 @@ LL | type CapturedEarly<'a> = impl Sized + Captures<'a>; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: [o] - --> $DIR/variance.rs:12:56 + --> $DIR/variance.rs:13:56 | LL | type NotCapturedLate<'a> = dyn for<'b> Iterator<Item = impl Sized>; | ^^^^^^^^^^ error: [o] - --> $DIR/variance.rs:14:53 - | -LL | type CapturedLate<'a> = dyn for<'b> Iterator<Item = impl Sized + Captures<'b>>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [o] --> $DIR/variance.rs:16:49 | -LL | type Captured<'a> = dyn for<'b> Iterator<Item = impl Sized + Captures<'a> + Captures<'b>>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type Captured<'a> = dyn for<'b> Iterator<Item = impl Sized + Captures<'a>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: [o, o, o] --> $DIR/variance.rs:18:27 @@ -35,52 +29,40 @@ LL | type Bar<'a, 'b: 'b, T> = impl Sized; | ^^^^^^^^^^ error: [o, o] - --> $DIR/variance.rs:31:38 - | -LL | type ImplicitCapturedEarly<'a> = impl Sized; - | ^^^^^^^^^^ - -error: [o, o] - --> $DIR/variance.rs:33:37 - | -LL | type ExplicitCaptureEarly<'a> = impl Sized + Captures<'i>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: [o, o] - --> $DIR/variance.rs:35:36 + --> $DIR/variance.rs:29:32 | -LL | type ImplicitCaptureLate<'a> = impl Sized; - | ^^^^^^^^^^ +LL | type ImplicitCapture<'a> = impl Sized; + | ^^^^^^^^^^ error: [o, o] - --> $DIR/variance.rs:37:36 + --> $DIR/variance.rs:31:42 | -LL | type ExplicitCaptureLate<'a> = impl Sized + Captures<'a>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: [o, o] - --> $DIR/variance.rs:41:38 + --> $DIR/variance.rs:33:39 | -LL | type ImplicitCapturedEarly<'a> = impl Sized; - | ^^^^^^^^^^ +LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: [o, o] - --> $DIR/variance.rs:43:37 + --> $DIR/variance.rs:37:32 | -LL | type ExplicitCaptureEarly<'a> = impl Sized + Captures<'i>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type ImplicitCapture<'a> = impl Sized; + | ^^^^^^^^^^ error: [o, o] - --> $DIR/variance.rs:45:36 + --> $DIR/variance.rs:39:42 | -LL | type ImplicitCaptureLate<'a> = impl Sized; - | ^^^^^^^^^^ +LL | type ExplicitCaptureFromHeader<'a> = impl Sized + Captures<'i>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: [o, o] - --> $DIR/variance.rs:47:36 + --> $DIR/variance.rs:41:39 | -LL | type ExplicitCaptureLate<'a> = impl Sized + Captures<'a>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 14 previous errors +error: aborting due to 11 previous errors diff --git a/tests/ui/unreachable-code.rs b/tests/ui/unreachable-code.rs index 28b938edc63..64174db7afb 100644 --- a/tests/ui/unreachable-code.rs +++ b/tests/ui/unreachable-code.rs @@ -2,25 +2,32 @@ #![allow(unused_must_use)] #![allow(dead_code)] - #![allow(path_statements)] #![allow(unreachable_code)] #![allow(unused_variables)] +#![feature(if_let_guard)] -fn id(x: bool) -> bool { x } +fn id(x: bool) -> bool { + x +} fn call_id() { let c = panic!(); id(c); } -fn call_id_2() { id(true) && id(return); } +fn call_id_2() { + id(true) && id(return); +} -fn call_id_3() { id(return) && id(return); } +fn call_id_3() { + id(return) && id(return); +} fn ret_guard() { match 2 { x if (return) => { x; } + x if let true = return => { x; } _ => {} } } |
