diff options
| author | Michael Goulet <michael@errs.io> | 2022-01-14 03:39:29 -0800 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-01-14 13:05:16 -0800 |
| commit | b9a3c32f31d4aff6988c678036c563c4b425f0bc (patch) | |
| tree | 945e32995e620d7cc9fd8e2b0aaefd97927c04fe /src | |
| parent | 22e491ac7ed454d34669151a8b6464cb643c9b41 (diff) | |
| download | rust-b9a3c32f31d4aff6988c678036c563c4b425f0bc.tar.gz rust-b9a3c32f31d4aff6988c678036c563c4b425f0bc.zip | |
Do not fail evaluation in const blocks
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/consts/const-block-const-bound.rs | 17 | ||||
| -rw-r--r-- | src/test/ui/consts/const-block-const-bound.stderr | 21 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/test/ui/consts/const-block-const-bound.rs b/src/test/ui/consts/const-block-const-bound.rs new file mode 100644 index 00000000000..3bfc759a9ae --- /dev/null +++ b/src/test/ui/consts/const-block-const-bound.rs @@ -0,0 +1,17 @@ +#![allow(unused)] +#![feature(const_fn_trait_bound, const_trait_impl, inline_const)] + +const fn f<T: ~const Drop>(x: T) {} + +struct UnconstDrop; + +impl Drop for UnconstDrop { + fn drop(&mut self) {} +} + +fn main() { + const { + f(UnconstDrop); + //~^ ERROR the trait bound `UnconstDrop: 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 new file mode 100644 index 00000000000..0e6e426e7c2 --- /dev/null +++ b/src/test/ui/consts/const-block-const-bound.stderr @@ -0,0 +1,21 @@ +error[E0277]: the trait bound `UnconstDrop: Drop` is not satisfied + --> $DIR/const-block-const-bound.rs:14:11 + | +LL | f(UnconstDrop); + | - ^^^^^^^^^^^ the trait `Drop` is not implemented for `UnconstDrop` + | | + | 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` +help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement + | +LL | fn main() where UnconstDrop: Drop { + | +++++++++++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. |
