Use trait select logic instead of query

This commit is contained in:
Deadbeef 2021-09-02 10:59:53 +00:00
parent f0a52128ee
commit 1ca83c6451
No known key found for this signature in database
GPG key ID: 027DF9338862ADDD
5 changed files with 100 additions and 31 deletions

View file

@ -16,16 +16,19 @@ impl const Drop for ConstImplWithDropGlue {
fn drop(&mut self) {}
}
const fn check<T: ~const Drop>() {}
const fn check<T: ~const Drop>(_: T) {}
macro_rules! check_all {
($($T:ty),*$(,)?) => {$(
const _: () = check::<$T>();
($($exp:expr),*$(,)?) => {$(
const _: () = check($exp);
)*};
}
check_all! {
ConstImplWithDropGlue,
NonTrivialDrop,
//~^ ERROR the trait bound
ConstImplWithDropGlue(NonTrivialDrop),
//~^ ERROR the trait bound
}
fn main() {}

View file

@ -0,0 +1,27 @@
error[E0277]: the trait bound `NonTrivialDrop: Drop` is not satisfied
--> $DIR/const-drop-fail.rs:28:5
|
LL | NonTrivialDrop,
| ^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `NonTrivialDrop`
|
note: required by a bound in `check`
--> $DIR/const-drop-fail.rs:19:19
|
LL | const fn check<T: ~const Drop>(_: T) {}
| ^^^^^^^^^^^ required by this bound in `check`
error[E0277]: the trait bound `ConstImplWithDropGlue: Drop` is not satisfied
--> $DIR/const-drop-fail.rs:30:5
|
LL | ConstImplWithDropGlue(NonTrivialDrop),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `ConstImplWithDropGlue`
|
note: required by a bound in `check`
--> $DIR/const-drop-fail.rs:19:19
|
LL | const fn check<T: ~const Drop>(_: T) {}
| ^^^^^^^^^^^ required by this bound in `check`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.