diff options
Diffstat (limited to 'tests/ui')
28 files changed, 372 insertions, 41 deletions
diff --git a/tests/ui/asm/s390x/bad-reg.rs b/tests/ui/asm/s390x/bad-reg.rs index 56b2d709372..eb9138755e7 100644 --- a/tests/ui/asm/s390x/bad-reg.rs +++ b/tests/ui/asm/s390x/bad-reg.rs @@ -1,7 +1,7 @@ //@ add-core-stubs //@ needs-asm-support //@ revisions: s390x s390x_vector s390x_vector_stable -//@[s390x] compile-flags: --target s390x-unknown-linux-gnu +//@[s390x] compile-flags: --target s390x-unknown-linux-gnu -C target-feature=-vector //@[s390x] needs-llvm-components: systemz //@[s390x_vector] compile-flags: --target s390x-unknown-linux-gnu -C target-feature=+vector //@[s390x_vector] needs-llvm-components: systemz diff --git a/tests/ui/drop/if-let-guards.rs b/tests/ui/drop/if-let-guards.rs new file mode 100644 index 00000000000..bd353112c09 --- /dev/null +++ b/tests/ui/drop/if-let-guards.rs @@ -0,0 +1,88 @@ +//! Tests drop order for `if let` guard bindings and temporaries. This is for behavior specific to +//! `match` expressions, whereas `tests/ui/drop/drop-order-comparisons.rs` compares `let` chains in +//! guards to `let` chains in `if` expressions. Drop order for `let` chains in guards shouldn't +//! differ between Editions, so we test on both 2021 and 2024, expecting the same results. +//@ revisions: e2021 e2024 +//@ [e2021] edition: 2021 +//@ [e2024] edition: 2024 +//@ run-pass + +#![feature(if_let_guard)] +#![deny(rust_2024_compatibility)] + +use core::{cell::RefCell, ops::Drop}; + +fn main() { + // Test that `let` guard bindings and temps are dropped before the arm's pattern's bindings. + assert_drop_order(1..=6, |o| { + // We move out of the scrutinee, so the drop order of the array's elements are based on + // binding declaration order, and they're dropped in the arm's scope. + match [o.log(6), o.log(5)] { + // Partially move from the guard temporary to test drops both for temps and the binding. + [_x, _y] if let [_, _z, _] = [o.log(4), o.log(2), o.log(3)] + && true => { let _a = o.log(1); } + _ => unreachable!(), + } + }); + + // Sanity check: we don't move out of the match scrutinee when the guard fails. + assert_drop_order(1..=4, |o| { + // The scrutinee uses the drop order for arrays since its elements aren't moved. + match [o.log(3), o.log(4)] { + [_x, _y] if let _z = o.log(1) + && false => unreachable!(), + _ => { let _a = o.log(2); } + } + }); + + // Test `let` guards' temporaries are dropped immediately when a guard fails, even if the guard + // is lowered and run multiple times on the same arm due to or-patterns. + assert_drop_order(1..=8, |o| { + let mut _x = 1; + // The match's scrutinee isn't bound by-move, so it outlives the match. + match o.log(8) { + // Failing a guard breaks out of the arm's scope, dropping the `let` guard's scrutinee. + _ | _ | _ if let _ = o.log(_x) + && { _x += 1; false } => unreachable!(), + // The temporaries from a failed guard are dropped before testing the next guard. + _ if let _ = o.log(5) + && { o.push(4); false } => unreachable!(), + // If the guard succeeds, we stay in the arm's scope to execute its body. + _ if let _ = o.log(7) + && true => { o.log(6); } + _ => unreachable!(), + } + }); +} + +// # Test scaffolding... + +struct DropOrder(RefCell<Vec<u64>>); +struct LogDrop<'o>(&'o DropOrder, u64); + +impl DropOrder { + fn log(&self, n: u64) -> LogDrop<'_> { + LogDrop(self, n) + } + fn push(&self, n: u64) { + self.0.borrow_mut().push(n); + } +} + +impl<'o> Drop for LogDrop<'o> { + fn drop(&mut self) { + self.0.push(self.1); + } +} + +#[track_caller] +fn assert_drop_order( + ex: impl IntoIterator<Item = u64>, + f: impl Fn(&DropOrder), +) { + let order = DropOrder(RefCell::new(Vec::new())); + f(&order); + let order = order.0.into_inner(); + let expected: Vec<u64> = ex.into_iter().collect(); + assert_eq!(order, expected); +} diff --git a/tests/ui/impl-trait/issues/type-error-post-normalization-test.rs b/tests/ui/impl-trait/issues/type-error-post-normalization-test.rs new file mode 100644 index 00000000000..0108bb23611 --- /dev/null +++ b/tests/ui/impl-trait/issues/type-error-post-normalization-test.rs @@ -0,0 +1,24 @@ +//@ compile-flags: -Zvalidate-mir -Zinline-mir=yes + +// This previously introduced a `{type_error}`` in the MIR body +// during the `PostAnalysisNormalize` pass. While the underlying issue +// #135528 did not get fixed, this reproducer no longer ICEs. + +#![feature(type_alias_impl_trait)] +type Tait = impl Copy; + +fn set(x: &isize) -> isize { + *x +} + +#[define_opaque(Tait)] +fn d(x: Tait) { + set(x); +} + +#[define_opaque(Tait)] +fn other_define() -> Tait { + () //~^ ERROR concrete type differs from previous defining opaque type use +} + +fn main() {} diff --git a/tests/ui/impl-trait/issues/type-error-post-normalization-test.stderr b/tests/ui/impl-trait/issues/type-error-post-normalization-test.stderr new file mode 100644 index 00000000000..7d63c1cfbd6 --- /dev/null +++ b/tests/ui/impl-trait/issues/type-error-post-normalization-test.stderr @@ -0,0 +1,14 @@ +error: concrete type differs from previous defining opaque type use + --> $DIR/type-error-post-normalization-test.rs:20:22 + | +LL | fn other_define() -> Tait { + | ^^^^ expected `&isize`, got `()` + | +note: previous use here + --> $DIR/type-error-post-normalization-test.rs:16:9 + | +LL | set(x); + | ^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/impl-trait/member-constraints/apply_member_constraint-no-req-eq.rs b/tests/ui/impl-trait/member-constraints/apply_member_constraint-no-req-eq.rs new file mode 100644 index 00000000000..3aa52fe2644 --- /dev/null +++ b/tests/ui/impl-trait/member-constraints/apply_member_constraint-no-req-eq.rs @@ -0,0 +1,24 @@ +//@ check-pass +// FIXME(-Znext-solver): enable this test + +trait Id { + type This; +} +impl<T> Id for T { + type This = T; +} + +// We have two member constraints here: +// +// - 'unconstrained member ['a, 'static] +// - 'unconstrained member ['static] +// +// Applying the first constraint results in `'unconstrained: 'a` +// while the second then adds `'unconstrained: 'static`. If applying +// member constraints were to require the member region equal to the +// choice region, applying the first constraint first and then the +// second would result in a `'a: 'static` requirement. +fn test<'a>() -> impl Id<This = impl Sized + use<>> + use<'a> { + &() +} +fn main() {} diff --git a/tests/ui/impl-trait/member-constraints/incomplete-constraint.rs b/tests/ui/impl-trait/member-constraints/incomplete-constraint.rs new file mode 100644 index 00000000000..4c085cc1eed --- /dev/null +++ b/tests/ui/impl-trait/member-constraints/incomplete-constraint.rs @@ -0,0 +1,21 @@ +//@ check-pass +// FIXME(-Znext-solver): enable this test + +// These functions currently do not normalize the opaque type but will do +// so in the future. At this point we've got a new use of the opaque with fully +// universal arguments but for which lifetimes in the hidden type are unconstrained. +// +// Applying the member constraints would then incompletely infer `'unconstrained` to `'static`. +fn new_defining_use<F: FnOnce(T) -> R, T, R>(_: F) {} + +fn rpit1<'a, 'b: 'b>(x: &'b ()) -> impl Sized + use<'a, 'b> { + new_defining_use(rpit1::<'a, 'b>); + x +} + +struct Inv<'a, 'b>(*mut (&'a (), &'b ())); +fn rpit2<'a>(_: ()) -> impl Sized + use<'a> { + new_defining_use(rpit2::<'a>); + Inv::<'a, 'static>(std::ptr::null_mut()) +} +fn main() {} diff --git a/tests/ui/nll/member-constraints/min-choice-reject-ambiguous.rs b/tests/ui/impl-trait/member-constraints/min-choice-reject-ambiguous.rs index 09138095523..09138095523 100644 --- a/tests/ui/nll/member-constraints/min-choice-reject-ambiguous.rs +++ b/tests/ui/impl-trait/member-constraints/min-choice-reject-ambiguous.rs diff --git a/tests/ui/nll/member-constraints/min-choice-reject-ambiguous.stderr b/tests/ui/impl-trait/member-constraints/min-choice-reject-ambiguous.stderr index 911ddd3dc80..911ddd3dc80 100644 --- a/tests/ui/nll/member-constraints/min-choice-reject-ambiguous.stderr +++ b/tests/ui/impl-trait/member-constraints/min-choice-reject-ambiguous.stderr diff --git a/tests/ui/nll/member-constraints/min-choice.rs b/tests/ui/impl-trait/member-constraints/min-choice.rs index 4fbffeb4b2a..4fbffeb4b2a 100644 --- a/tests/ui/nll/member-constraints/min-choice.rs +++ b/tests/ui/impl-trait/member-constraints/min-choice.rs diff --git a/tests/ui/nll/member-constraints/nested-impl-trait-fail.rs b/tests/ui/impl-trait/member-constraints/nested-impl-trait-fail.rs index 0bf32a2624f..0bf32a2624f 100644 --- a/tests/ui/nll/member-constraints/nested-impl-trait-fail.rs +++ b/tests/ui/impl-trait/member-constraints/nested-impl-trait-fail.rs diff --git a/tests/ui/nll/member-constraints/nested-impl-trait-fail.stderr b/tests/ui/impl-trait/member-constraints/nested-impl-trait-fail.stderr index 1a0611e715e..1a0611e715e 100644 --- a/tests/ui/nll/member-constraints/nested-impl-trait-fail.stderr +++ b/tests/ui/impl-trait/member-constraints/nested-impl-trait-fail.stderr diff --git a/tests/ui/nll/member-constraints/nested-impl-trait-pass.rs b/tests/ui/impl-trait/member-constraints/nested-impl-trait-pass.rs index 4633ad68230..6860fc5e6a5 100644 --- a/tests/ui/nll/member-constraints/nested-impl-trait-pass.rs +++ b/tests/ui/impl-trait/member-constraints/nested-impl-trait-pass.rs @@ -1,6 +1,7 @@ // Nested impl-traits can impose different member constraints on the same region variable. //@ check-pass +// FIXME(-Znext-solver): enable this test trait Cap<'a> {} impl<T> Cap<'_> for T {} @@ -8,7 +9,9 @@ impl<T> Cap<'_> for T {} // Assuming the hidden type is `[&'?15 u8; 1]`, we have two distinct member constraints: // - '?15 member ['static, 'a, 'b] // from outer impl-trait // - '?15 member ['static, 'a] // from inner impl-trait -// To satisfy both we can only choose 'a. +// To satisfy both we can only choose 'a. Concretely, first member constraint requires ?15 +// to outlive at least 'b while the second requires ?15 to outlive 'a. As 'a outlives 'b we +// end up with 'a as the final member region. fn pass_early_bound<'s, 'a, 'b>(a: &'s u8) -> impl IntoIterator<Item = impl Cap<'a>> + Cap<'b> where 's: 'a, diff --git a/tests/ui/impl-trait/member-constraints/reject-choice-due-to-prev-constraint.rs b/tests/ui/impl-trait/member-constraints/reject-choice-due-to-prev-constraint.rs new file mode 100644 index 00000000000..33f2d277fe5 --- /dev/null +++ b/tests/ui/impl-trait/member-constraints/reject-choice-due-to-prev-constraint.rs @@ -0,0 +1,34 @@ +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ check-pass + +// We've got `'0 member ['a, 'b, 'static]` and `'1 member ['a, 'b, 'static]`. +// +// As '0 gets outlived by 'a - its "upper bound" - the only applicable choice +// region is 'a. +// +// '1 has to outlive 'b so the only applicable choice regions are 'b and 'static. +// Considering this member constraint by itself would choose 'b as it is the +// smaller of the two regions. +// +// However, this is only the case when ignoring the member constraint on '0. +// After applying this constraint and requiring '0 to outlive 'a. As '1 outlives +// '0, the region 'b is no longer an applicable choice region for '1 as 'b does +// does not outlive 'a. We would therefore choose 'static. +// +// This means applying member constraints is order dependent. We handle this by +// first applying member constraints for regions 'x and then consider the resulting +// constraints when applying member constraints for regions 'y with 'y: 'x. +fn with_constraints<'r0, 'r1, 'a, 'b>() -> *mut (&'r0 (), &'r1 ()) +where + 'r1: 'r0, + 'a: 'r0, + 'r1: 'b, +{ + loop {} +} +fn foo<'a, 'b>() -> impl Sized + use<'a, 'b> { + with_constraints::<'_, '_, 'a, 'b>() +} +fn main() {} diff --git a/tests/ui/impl-trait/no-anonymize-regions.rs b/tests/ui/impl-trait/no-anonymize-regions.rs new file mode 100644 index 00000000000..4f7f7c0641c --- /dev/null +++ b/tests/ui/impl-trait/no-anonymize-regions.rs @@ -0,0 +1,18 @@ +//@ check-pass +// FIXME(-Znext-solver): enable this test + +// A regression test for an error in `redis` while working on #139587. +// +// We check for structural equality when adding defining uses of opaques. +// In this test one defining use had anonymized regions while the other +// one did not, causing an error. +struct W<T>(T); +fn constrain<F: FnOnce(T) -> R, T, R>(f: F) -> R { + loop {} +} +fn foo<'a>(x: for<'b> fn(&'b ())) -> impl Sized + use<'a> { + let mut r = constrain(foo::<'_>); + r = W(x); + r +} +fn main() {} diff --git a/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.rs b/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.rs index 4cf2d1ac4a6..80a4ab35527 100644 --- a/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.rs +++ b/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.rs @@ -41,6 +41,7 @@ mod capture_tait_complex_pass { #[define_opaque(Opq2)] fn test() -> Opq2 {} //~^ ERROR: expected generic lifetime parameter, found `'a` + //~| ERROR: expected generic lifetime parameter, found `'b` } // Same as the above, but make sure that different placeholder regions are not equal. @@ -80,6 +81,7 @@ mod constrain_pass { #[define_opaque(Opq2)] fn test() -> Opq2 {} //~^ ERROR: expected generic lifetime parameter, found `'a` + //~| ERROR: expected generic lifetime parameter, found `'a` } fn main() {} diff --git a/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.stderr b/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.stderr index 3614fc8f45c..665b9a91696 100644 --- a/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.stderr +++ b/tests/ui/rfcs/type-alias-impl-trait/higher-ranked-regions-basic.stderr @@ -36,8 +36,17 @@ LL | type Opq1<'a> = impl for<'b> Trait<'b, Ty = Opq0<'b>>; // <- Note 'b LL | fn test() -> Opq2 {} | ^^ +error[E0792]: expected generic lifetime parameter, found `'b` + --> $DIR/higher-ranked-regions-basic.rs:42:23 + | +LL | type Opq0<'a> = impl Sized; + | -- this generic parameter must be used with a generic lifetime parameter +... +LL | fn test() -> Opq2 {} + | ^^ + error[E0700]: hidden type for `capture_tait_complex_fail::Opq0<'a>` captures lifetime that does not appear in bounds - --> $DIR/higher-ranked-regions-basic.rs:53:23 + --> $DIR/higher-ranked-regions-basic.rs:54:23 | LL | type Opq0<'a> = impl Sized; | ---------- opaque type defined here @@ -48,7 +57,7 @@ LL | fn test() -> Opq2 {} | ^^ error[E0792]: expected generic lifetime parameter, found `'a` - --> $DIR/higher-ranked-regions-basic.rs:62:65 + --> $DIR/higher-ranked-regions-basic.rs:63:65 | LL | type Opq0<'a, 'b> = impl Sized; | -- this generic parameter must be used with a generic lifetime parameter @@ -57,7 +66,7 @@ LL | fn test() -> impl for<'a> Trait<'a, Ty = Opq0<'a, 'static>> {} | ^^ error[E0792]: expected generic lifetime parameter, found `'a` - --> $DIR/higher-ranked-regions-basic.rs:71:60 + --> $DIR/higher-ranked-regions-basic.rs:72:60 | LL | type Opq0<'a, 'b> = impl Sized; | -- this generic parameter must be used with a generic lifetime parameter @@ -66,7 +75,7 @@ LL | fn test() -> impl for<'a> Trait<'a, Ty = Opq0<'a, 'a>> {} | ^^ error[E0792]: expected generic lifetime parameter, found `'a` - --> $DIR/higher-ranked-regions-basic.rs:81:23 + --> $DIR/higher-ranked-regions-basic.rs:82:23 | LL | type Opq1<'a> = impl for<'b> Trait<'b, Ty = Opq0<'a, 'b>>; | -- this generic parameter must be used with a generic lifetime parameter @@ -74,7 +83,16 @@ LL | type Opq1<'a> = impl for<'b> Trait<'b, Ty = Opq0<'a, 'b>>; LL | fn test() -> Opq2 {} | ^^ -error: aborting due to 8 previous errors +error[E0792]: expected generic lifetime parameter, found `'a` + --> $DIR/higher-ranked-regions-basic.rs:82:23 + | +LL | type Opq0<'a, 'b> = impl Sized; + | -- this generic parameter must be used with a generic lifetime parameter +... +LL | fn test() -> Opq2 {} + | ^^ + +error: aborting due to 10 previous errors Some errors have detailed explanations: E0700, E0792. For more information about an error, try `rustc --explain E0700`. diff --git a/tests/ui/rustc_public-ir-print/async-closure.stdout b/tests/ui/rustc_public-ir-print/async-closure.stdout index 4afb15af7a9..73e9b8fc097 100644 --- a/tests/ui/rustc_public-ir-print/async-closure.stdout +++ b/tests/ui/rustc_public-ir-print/async-closure.stdout @@ -63,7 +63,7 @@ fn foo::{closure#0}::{closure#0}(_1: Pin<&mut {async closure body@$DIR/async-clo StorageDead(_3); _0 = std::task::Poll::Ready(move _5); _10 = CopyForDeref((_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6})); - discriminant((*_10) = 1; + discriminant((*_10)) = 1; return; } bb2: { @@ -101,7 +101,7 @@ fn foo::{closure#0}::{synthetic#0}(_1: Pin<&mut {async closure body@$DIR/async-c StorageDead(_3); _0 = std::task::Poll::Ready(move _5); _10 = CopyForDeref((_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6})); - discriminant((*_10) = 1; + discriminant((*_10)) = 1; return; } bb2: { diff --git a/tests/ui/stats/macro-stats.rs b/tests/ui/stats/macro-stats.rs index d986904ddd6..1b7d58bf058 100644 --- a/tests/ui/stats/macro-stats.rs +++ b/tests/ui/stats/macro-stats.rs @@ -49,10 +49,32 @@ fn opt(x: Option<u32>) { } } -macro_rules! long_name_that_fits_on_a_single_line { - () => {} -} -long_name_that_fits_on_a_single_line!(); +macro_rules! long_name_that_fits_on_one_line { () => {} } +long_name_that_fits_on_one_line!(); +long_name_that_fits_on_one_line!(); +long_name_that_fits_on_one_line!(); +long_name_that_fits_on_one_line!(); +long_name_that_fits_on_one_line!(); +long_name_that_fits_on_one_line!(); +long_name_that_fits_on_one_line!(); +long_name_that_fits_on_one_line!(); +long_name_that_fits_on_one_line!(); +long_name_that_fits_on_one_line!(); + +macro_rules! long_name_that_fits_on_one_line_ { () => {} } +long_name_that_fits_on_one_line_!(); + +macro_rules! long_name_that_fits_on_one_line__ { () => {} } +long_name_that_fits_on_one_line__!(); + +macro_rules! long_name_that_fits_on_one_line___ { () => {} } +long_name_that_fits_on_one_line___!(); + +macro_rules! long_name_that_fits_on_one_line____ { () => {} } +long_name_that_fits_on_one_line____!(); + +macro_rules! long_name_that_fits_on_one_line_____ { () => {} } +long_name_that_fits_on_one_line_____!(); macro_rules! long_name_that_doesnt_fit_on_one_line { ($t:ty) => { diff --git a/tests/ui/stats/macro-stats.stderr b/tests/ui/stats/macro-stats.stderr index 8d0fdb8958a..75b90df6466 100644 --- a/tests/ui/stats/macro-stats.stderr +++ b/tests/ui/stats/macro-stats.stderr @@ -22,6 +22,11 @@ macro-stats trait_tys! 1 2 2.0 macro-stats n99! 2 2 1.0 4 2.0 macro-stats none! 1 1 1.0 4 4.0 macro-stats u32! 1 1 1.0 3 3.0 -macro-stats long_name_that_fits_on_a_single_line! 1 1 1.0 0 0.0 +macro-stats long_name_that_fits_on_one_line! 10 10 1.0 0 0.0 +macro-stats long_name_that_fits_on_one_line_____! 1 1 1.0 0 0.0 +macro-stats long_name_that_fits_on_one_line____! 1 1 1.0 0 0.0 +macro-stats long_name_that_fits_on_one_line___! 1 1 1.0 0 0.0 +macro-stats long_name_that_fits_on_one_line__! 1 1 1.0 0 0.0 +macro-stats long_name_that_fits_on_one_line_! 1 1 1.0 0 0.0 macro-stats #[test] 1 1 1.0 0 0.0 macro-stats =================================================================================== diff --git a/tests/ui/suggestions/for-loop-missing-in.fixed b/tests/ui/suggestions/for-loop-missing-in.fixed index ff376b5a52c..396c3ff87ff 100644 --- a/tests/ui/suggestions/for-loop-missing-in.fixed +++ b/tests/ui/suggestions/for-loop-missing-in.fixed @@ -1,8 +1,7 @@ //@ run-rustfix fn main() { - for _i in 0..2 { //~ ERROR missing `in` - } - for _i in 0..2 { //~ ERROR missing `in` - } + for _i in 0..2 {} //~ ERROR missing `in` + for _i in 0..2 {} //~ ERROR missing `in` + for _i in 0..2 {} //~ ERROR missing `in` } diff --git a/tests/ui/suggestions/for-loop-missing-in.rs b/tests/ui/suggestions/for-loop-missing-in.rs index 28c12aec665..6c2092106cb 100644 --- a/tests/ui/suggestions/for-loop-missing-in.rs +++ b/tests/ui/suggestions/for-loop-missing-in.rs @@ -1,8 +1,7 @@ //@ run-rustfix fn main() { - for _i 0..2 { //~ ERROR missing `in` - } - for _i of 0..2 { //~ ERROR missing `in` - } + for _i 0..2 {} //~ ERROR missing `in` + for _i of 0..2 {} //~ ERROR missing `in` + for _i = 0..2 {} //~ ERROR missing `in` } diff --git a/tests/ui/suggestions/for-loop-missing-in.stderr b/tests/ui/suggestions/for-loop-missing-in.stderr index 4e0cb229d50..b9c8c393406 100644 --- a/tests/ui/suggestions/for-loop-missing-in.stderr +++ b/tests/ui/suggestions/for-loop-missing-in.stderr @@ -1,25 +1,37 @@ error: missing `in` in `for` loop --> $DIR/for-loop-missing-in.rs:4:11 | -LL | for _i 0..2 { +LL | for _i 0..2 {} | ^ | help: try adding `in` here | -LL | for _i in 0..2 { +LL | for _i in 0..2 {} | ++ error: missing `in` in `for` loop - --> $DIR/for-loop-missing-in.rs:6:12 + --> $DIR/for-loop-missing-in.rs:5:12 | -LL | for _i of 0..2 { +LL | for _i of 0..2 {} | ^^ | help: try using `in` here instead | -LL - for _i of 0..2 { -LL + for _i in 0..2 { +LL - for _i of 0..2 {} +LL + for _i in 0..2 {} + | + +error: missing `in` in `for` loop + --> $DIR/for-loop-missing-in.rs:6:12 + | +LL | for _i = 0..2 {} + | ^ + | +help: try using `in` here instead + | +LL - for _i = 0..2 {} +LL + for _i in 0..2 {} | -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/type-alias-impl-trait/hkl_forbidden.rs b/tests/ui/type-alias-impl-trait/hkl_forbidden.rs index 994adc476e2..72da2af96b8 100644 --- a/tests/ui/type-alias-impl-trait/hkl_forbidden.rs +++ b/tests/ui/type-alias-impl-trait/hkl_forbidden.rs @@ -8,7 +8,9 @@ type Opaque<'a> = impl Sized + 'a; #[define_opaque(Opaque)] fn test(s: &str) -> (impl Fn(&str) -> Opaque<'_>, impl Fn(&str) -> Opaque<'_>) { - (id, id) //~ ERROR expected generic lifetime parameter, found `'_` + (id, id) + //~^ ERROR expected generic lifetime parameter, found `'_` + //~| ERROR expected generic lifetime parameter, found `'_` } fn id2<'a, 'b>(s: (&'a str, &'b str)) -> (&'a str, &'b str) { @@ -19,7 +21,9 @@ type Opaque2<'a> = impl Sized + 'a; #[define_opaque(Opaque2)] fn test2() -> impl for<'a, 'b> Fn((&'a str, &'b str)) -> (Opaque2<'a>, Opaque2<'b>) { - id2 //~ ERROR expected generic lifetime parameter, found `'a` + id2 + //~^ ERROR expected generic lifetime parameter, found `'a` + //~| ERROR expected generic lifetime parameter, found `'b` } type Opaque3<'a> = impl Sized + 'a; diff --git a/tests/ui/type-alias-impl-trait/hkl_forbidden.stderr b/tests/ui/type-alias-impl-trait/hkl_forbidden.stderr index d404d60f31e..315bdfb2272 100644 --- a/tests/ui/type-alias-impl-trait/hkl_forbidden.stderr +++ b/tests/ui/type-alias-impl-trait/hkl_forbidden.stderr @@ -7,8 +7,28 @@ LL | type Opaque<'a> = impl Sized + 'a; LL | (id, id) | ^^^^^^^^ +error[E0792]: expected generic lifetime parameter, found `'_` + --> $DIR/hkl_forbidden.rs:11:5 + | +LL | type Opaque<'a> = impl Sized + 'a; + | -- this generic parameter must be used with a generic lifetime parameter +... +LL | (id, id) + | ^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0792]: expected generic lifetime parameter, found `'a` - --> $DIR/hkl_forbidden.rs:22:5 + --> $DIR/hkl_forbidden.rs:24:5 + | +LL | type Opaque2<'a> = impl Sized + 'a; + | -- this generic parameter must be used with a generic lifetime parameter +... +LL | id2 + | ^^^ + +error[E0792]: expected generic lifetime parameter, found `'b` + --> $DIR/hkl_forbidden.rs:24:5 | LL | type Opaque2<'a> = impl Sized + 'a; | -- this generic parameter must be used with a generic lifetime parameter @@ -17,7 +37,7 @@ LL | id2 | ^^^ error[E0792]: expected generic lifetime parameter, found `'_` - --> $DIR/hkl_forbidden.rs:29:5 + --> $DIR/hkl_forbidden.rs:33:5 | LL | type Opaque3<'a> = impl Sized + 'a; | -- this generic parameter must be used with a generic lifetime parameter @@ -26,7 +46,7 @@ LL | (id, s) | ^^^^^^^ error[E0792]: expected generic lifetime parameter, found `'_` - --> $DIR/hkl_forbidden.rs:35:5 + --> $DIR/hkl_forbidden.rs:39:5 | LL | type Opaque4<'a> = impl Sized + 'a; | -- this generic parameter must be used with a generic lifetime parameter @@ -35,7 +55,7 @@ LL | (s, id) | ^^^^^^^ error[E0792]: expected generic lifetime parameter, found `'a` - --> $DIR/hkl_forbidden.rs:41:5 + --> $DIR/hkl_forbidden.rs:45:5 | LL | type Inner<'a> = impl Sized; | -- this generic parameter must be used with a generic lifetime parameter @@ -43,6 +63,6 @@ LL | type Inner<'a> = impl Sized; LL | |x| x | ^^^^^ -error: aborting due to 5 previous errors +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/type-alias-impl-trait/param_mismatch2.rs b/tests/ui/type-alias-impl-trait/param_mismatch2.rs index f6a99711411..94c495cb330 100644 --- a/tests/ui/type-alias-impl-trait/param_mismatch2.rs +++ b/tests/ui/type-alias-impl-trait/param_mismatch2.rs @@ -11,7 +11,9 @@ type Opaque<'a> = impl Sized + 'a; #[define_opaque(Opaque)] fn test(s: &str) -> (impl Fn(&str) -> Opaque<'_>, impl Fn(&str) -> Opaque<'_>) { - (id, id) //~ ERROR: expected generic lifetime parameter, found `'_` + (id, id) + //~^ ERROR: expected generic lifetime parameter, found `'_` + //~| ERROR: expected generic lifetime parameter, found `'_` } fn main() {} diff --git a/tests/ui/type-alias-impl-trait/param_mismatch2.stderr b/tests/ui/type-alias-impl-trait/param_mismatch2.stderr index f5ecade2f02..5c8a8af6501 100644 --- a/tests/ui/type-alias-impl-trait/param_mismatch2.stderr +++ b/tests/ui/type-alias-impl-trait/param_mismatch2.stderr @@ -7,6 +7,17 @@ LL | type Opaque<'a> = impl Sized + 'a; LL | (id, id) | ^^^^^^^^ -error: aborting due to 1 previous error +error[E0792]: expected generic lifetime parameter, found `'_` + --> $DIR/param_mismatch2.rs:14:5 + | +LL | type Opaque<'a> = impl Sized + 'a; + | -- this generic parameter must be used with a generic lifetime parameter +... +LL | (id, id) + | ^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/type-alias-impl-trait/param_mismatch3.rs b/tests/ui/type-alias-impl-trait/param_mismatch3.rs index 17b6f8bce2a..1514dd66db9 100644 --- a/tests/ui/type-alias-impl-trait/param_mismatch3.rs +++ b/tests/ui/type-alias-impl-trait/param_mismatch3.rs @@ -11,7 +11,9 @@ type Opaque<'a> = impl Sized + 'a; #[define_opaque(Opaque)] fn test() -> impl for<'a, 'b> Fn((&'a str, &'b str)) -> (Opaque<'a>, Opaque<'b>) { - id2 //~ ERROR expected generic lifetime parameter, found `'a` + id2 + //~^ ERROR expected generic lifetime parameter, found `'a` + //~| ERROR expected generic lifetime parameter, found `'b` } fn id(s: &str) -> &str { diff --git a/tests/ui/type-alias-impl-trait/param_mismatch3.stderr b/tests/ui/type-alias-impl-trait/param_mismatch3.stderr index 7565bbfc6ff..76be07ce38f 100644 --- a/tests/ui/type-alias-impl-trait/param_mismatch3.stderr +++ b/tests/ui/type-alias-impl-trait/param_mismatch3.stderr @@ -7,8 +7,17 @@ LL | type Opaque<'a> = impl Sized + 'a; LL | id2 | ^^^ +error[E0792]: expected generic lifetime parameter, found `'b` + --> $DIR/param_mismatch3.rs:14:5 + | +LL | type Opaque<'a> = impl Sized + 'a; + | -- this generic parameter must be used with a generic lifetime parameter +... +LL | id2 + | ^^^ + error[E0792]: expected generic lifetime parameter, found `'_` - --> $DIR/param_mismatch3.rs:25:5 + --> $DIR/param_mismatch3.rs:27:5 | LL | type Opaque2<'a> = impl Sized + 'a; | -- this generic parameter must be used with a generic lifetime parameter @@ -16,6 +25,6 @@ LL | type Opaque2<'a> = impl Sized + 'a; LL | (id, s) | ^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0792`. |
