diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-01-18 04:42:09 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-18 04:42:09 +0100 |
| commit | baeff67b5fed70a5bf49c050aa901d7a377bc924 (patch) | |
| tree | 42596d4660fb12da5058e58131b6cae3d8604d91 | |
| parent | 71e5bfed706616ed85efe57244db95cc358716ad (diff) | |
| parent | e6aef256e6155b33394868b4d3ee1984e6b59bc6 (diff) | |
| download | rust-baeff67b5fed70a5bf49c050aa901d7a377bc924.tar.gz rust-baeff67b5fed70a5bf49c050aa901d7a377bc924.zip | |
Rollup merge of #92997 - woppopo:test92114, r=Mark-Simulacrum
Add `~const` bound test for negative impls Resolves #92114 which has been fixed in #92892.
| -rw-r--r-- | src/test/ui/consts/const-block-const-bound.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/consts/const-block-const-bound.stderr | 18 |
2 files changed, 23 insertions, 3 deletions
diff --git a/src/test/ui/consts/const-block-const-bound.rs b/src/test/ui/consts/const-block-const-bound.rs index 3bfc759a9ae..3d7e171f18c 100644 --- a/src/test/ui/consts/const-block-const-bound.rs +++ b/src/test/ui/consts/const-block-const-bound.rs @@ -1,5 +1,5 @@ #![allow(unused)] -#![feature(const_fn_trait_bound, const_trait_impl, inline_const)] +#![feature(const_fn_trait_bound, const_trait_impl, inline_const, negative_impls)] const fn f<T: ~const Drop>(x: T) {} @@ -9,9 +9,15 @@ impl Drop for UnconstDrop { fn drop(&mut self) {} } +struct NonDrop; + +impl !Drop for NonDrop {} + fn main() { const { f(UnconstDrop); //~^ ERROR the trait bound `UnconstDrop: Drop` is not satisfied + f(NonDrop); + //~^ ERROR the trait bound `NonDrop: Drop` is not satisfied } } diff --git a/src/test/ui/consts/const-block-const-bound.stderr b/src/test/ui/consts/const-block-const-bound.stderr index 0e6e426e7c2..5f912c66bb9 100644 --- a/src/test/ui/consts/const-block-const-bound.stderr +++ b/src/test/ui/consts/const-block-const-bound.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `UnconstDrop: Drop` is not satisfied - --> $DIR/const-block-const-bound.rs:14:11 + --> $DIR/const-block-const-bound.rs:18:11 | LL | f(UnconstDrop); | - ^^^^^^^^^^^ the trait `Drop` is not implemented for `UnconstDrop` @@ -16,6 +16,20 @@ help: consider introducing a `where` bound, but there might be an alternative be LL | fn main() where UnconstDrop: Drop { | +++++++++++++++++++++++ -error: aborting due to previous error +error[E0277]: the trait bound `NonDrop: Drop` is not satisfied + --> $DIR/const-block-const-bound.rs:20:11 + | +LL | f(NonDrop); + | - ^^^^^^^ the trait `Drop` is not implemented for `NonDrop` + | | + | required by a bound introduced by this call + | +note: required by a bound in `f` + --> $DIR/const-block-const-bound.rs:4:15 + | +LL | const fn f<T: ~const Drop>(x: T) {} + | ^^^^^^^^^^^ required by this bound in `f` + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. |
