diff --git a/tests/ui/const-generics/generic_const_exprs/escaping-late-bound-region-in-canonical-ice-113870.rs b/tests/ui/const-generics/generic_const_exprs/escaping-late-bound-region-in-canonical-ice-113870.rs new file mode 100644 index 0000000000000..6a75bf6ca4b73 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/escaping-late-bound-region-in-canonical-ice-113870.rs @@ -0,0 +1,24 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/113870 + +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +const fn allow<'b, 'b>() -> usize +//~^ ERROR the name `'b` is already used for a generic parameter in this item's generic parameters +where + for<'b> [u8; foo::<'a, 'b>()]: Sized, + //~^ ERROR lifetime name `'b` shadows a lifetime name that is already in scope + //~| ERROR use of undeclared lifetime name `'a` + //~| ERROR cannot capture late-bound lifetime in constant +{ + 4 +} + +const fn foo<'a, 'b>() -> usize +where + &'a (): Sized, + &'b (): Sized, +{ + 4 +} +//~^ ERROR `main` function not found in crate diff --git a/tests/ui/const-generics/generic_const_exprs/escaping-late-bound-region-in-canonical-ice-113870.stderr b/tests/ui/const-generics/generic_const_exprs/escaping-late-bound-region-in-canonical-ice-113870.stderr new file mode 100644 index 0000000000000..f036a2a341e3c --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/escaping-late-bound-region-in-canonical-ice-113870.stderr @@ -0,0 +1,52 @@ +error[E0403]: the name `'b` is already used for a generic parameter in this item's generic parameters + --> $DIR/escaping-late-bound-region-in-canonical-ice-113870.rs:6:20 + | +LL | const fn allow<'b, 'b>() -> usize + | -- ^^ already used + | | + | first use of `'b` + +error[E0496]: lifetime name `'b` shadows a lifetime name that is already in scope + --> $DIR/escaping-late-bound-region-in-canonical-ice-113870.rs:9:9 + | +LL | const fn allow<'b, 'b>() -> usize + | -- first declared here +... +LL | for<'b> [u8; foo::<'a, 'b>()]: Sized, + | ^^ lifetime `'b` already in scope + +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/escaping-late-bound-region-in-canonical-ice-113870.rs:9:24 + | +LL | for<'b> [u8; foo::<'a, 'b>()]: Sized, + | ^^ undeclared lifetime + | + = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html +help: consider making the bound lifetime-generic with a new `'a` lifetime + | +LL | for<'a, 'b> [u8; foo::<'a, 'b>()]: Sized, + | +++ +help: consider introducing lifetime `'a` here + | +LL | const fn allow<'a, 'b, 'b>() -> usize + | +++ + +error[E0601]: `main` function not found in crate `escaping_late_bound_region_in_canonical_ice_113870` + --> $DIR/escaping-late-bound-region-in-canonical-ice-113870.rs:23:2 + | +LL | } + | ^ consider adding a `main` function to `$DIR/escaping-late-bound-region-in-canonical-ice-113870.rs` + +error: cannot capture late-bound lifetime in constant + --> $DIR/escaping-late-bound-region-in-canonical-ice-113870.rs:9:28 + | +LL | const fn allow<'b, 'b>() -> usize + | -- lifetime defined here +... +LL | for<'b> [u8; foo::<'a, 'b>()]: Sized, + | ^^ + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0261, E0403, E0496, E0601. +For more information about an error, try `rustc --explain E0261`. diff --git a/tests/ui/const-generics/generic_const_exprs/ice-wrapper-impl-trait-with-const-bound-118278.rs b/tests/ui/const-generics/generic_const_exprs/ice-wrapper-impl-trait-with-const-bound-118278.rs new file mode 100644 index 0000000000000..02dff02430989 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/ice-wrapper-impl-trait-with-const-bound-118278.rs @@ -0,0 +1,28 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/118278 + +//@ check-pass + +#![allow(incomplete_features)] +#![feature(generic_const_exprs)] + +pub trait Foo { + const SIZE: usize; +} + +impl Foo for u64 { + const SIZE: usize = 8; +} + +pub struct Wrapper +where + T: Foo, + [(); T::SIZE]:, +{ + pub t: T, +} + +pub fn bar() -> Wrapper { + Wrapper { t: 10 } +} + +fn main() {} diff --git a/tests/ui/typeck/index-out-of-bounds-on-partial-cmp-ice-114056.rs b/tests/ui/typeck/index-out-of-bounds-on-partial-cmp-ice-114056.rs new file mode 100644 index 0000000000000..73230055908d1 --- /dev/null +++ b/tests/ui/typeck/index-out-of-bounds-on-partial-cmp-ice-114056.rs @@ -0,0 +1,12 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/114056 + +struct P(Q); + +impl P { + fn foo(&self) { + self.partial_cmp(()) + //~^ ERROR the method `partial_cmp` exists for reference `&P`, but its trait bounds were not satisfied + } +} + +fn main() {} diff --git a/tests/ui/typeck/index-out-of-bounds-on-partial-cmp-ice-114056.stderr b/tests/ui/typeck/index-out-of-bounds-on-partial-cmp-ice-114056.stderr new file mode 100644 index 0000000000000..47e0d2d90357a --- /dev/null +++ b/tests/ui/typeck/index-out-of-bounds-on-partial-cmp-ice-114056.stderr @@ -0,0 +1,27 @@ +error[E0599]: the method `partial_cmp` exists for reference `&P`, but its trait bounds were not satisfied + --> $DIR/index-out-of-bounds-on-partial-cmp-ice-114056.rs:7:14 + | +LL | struct P(Q); + | ----------- doesn't satisfy `P: Iterator` or `P: PartialOrd<_>` +... +LL | self.partial_cmp(()) + | ^^^^^^^^^^^ method cannot be called on `&P` due to unsatisfied trait bounds + | + = note: the following trait bounds were not satisfied: + `P: PartialOrd<_>` + which is required by `&P: PartialOrd<&_>` + `&P: Iterator` + which is required by `&mut &P: Iterator` + `P: Iterator` + which is required by `&mut P: Iterator` +note: the trait `Iterator` must be implemented + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL +help: consider annotating `P` with `#[derive(PartialEq, PartialOrd)]` + | +LL + #[derive(PartialEq, PartialOrd)] +LL | struct P(Q); + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0599`.