Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ~const bound test for negative impls #92997

Merged
merged 1 commit into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/test/ui/consts/const-block-const-bound.rs
Original file line number Diff line number Diff line change
@@ -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) {}

Expand All @@ -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
}
}
18 changes: 16 additions & 2 deletions src/test/ui/consts/const-block-const-bound.stderr
Original file line number Diff line number Diff line change
@@ -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`
Expand All @@ -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`.