mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Add another test case + fmt
This commit is contained in:
parent
49ac725d51
commit
146abdd119
@ -119,10 +119,8 @@ impl Qualif for NeedsNonConstDrop {
|
|||||||
// without having the lang item present.
|
// without having the lang item present.
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
let trait_ref = ty::TraitRef {
|
let trait_ref =
|
||||||
def_id: drop_trait,
|
ty::TraitRef { def_id: drop_trait, substs: cx.tcx.mk_substs_trait(ty, &[]) };
|
||||||
substs: cx.tcx.mk_substs_trait(ty, &[]),
|
|
||||||
};
|
|
||||||
let obligation = Obligation::new(
|
let obligation = Obligation::new(
|
||||||
ObligationCause::dummy(),
|
ObligationCause::dummy(),
|
||||||
cx.param_env,
|
cx.param_env,
|
||||||
|
@ -1,27 +1,59 @@
|
|||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/const-drop-fail.rs:27:35
|
||||||
|
|
|
||||||
|
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
|
||||||
|
| ^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: only allowed on bounds on traits' associated types and functions, const fns, const impls and its associated functions
|
||||||
|
|
||||||
error[E0277]: the trait bound `NonTrivialDrop: Drop` is not satisfied
|
error[E0277]: the trait bound `NonTrivialDrop: Drop` is not satisfied
|
||||||
--> $DIR/const-drop-fail.rs:30:5
|
--> $DIR/const-drop-fail.rs:45:5
|
||||||
|
|
|
|
||||||
LL | NonTrivialDrop,
|
LL | NonTrivialDrop,
|
||||||
| ^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `NonTrivialDrop`
|
| ^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `NonTrivialDrop`
|
||||||
|
|
|
|
||||||
note: required by a bound in `check`
|
note: required by a bound in `check`
|
||||||
--> $DIR/const-drop-fail.rs:21:19
|
--> $DIR/const-drop-fail.rs:36:19
|
||||||
|
|
|
|
||||||
LL | const fn check<T: ~const Drop>(_: T) {}
|
LL | const fn check<T: ~const Drop>(_: T) {}
|
||||||
| ^^^^^^^^^^^ required by this bound in `check`
|
| ^^^^^^^^^^^ required by this bound in `check`
|
||||||
|
|
||||||
error[E0277]: the trait bound `ConstImplWithDropGlue: Drop` is not satisfied
|
error[E0277]: the trait bound `ConstImplWithDropGlue: Drop` is not satisfied
|
||||||
--> $DIR/const-drop-fail.rs:32:5
|
--> $DIR/const-drop-fail.rs:47:5
|
||||||
|
|
|
|
||||||
LL | ConstImplWithDropGlue(NonTrivialDrop),
|
LL | ConstImplWithDropGlue(NonTrivialDrop),
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `ConstImplWithDropGlue`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `ConstImplWithDropGlue`
|
||||||
|
|
|
|
||||||
note: required by a bound in `check`
|
note: required by a bound in `check`
|
||||||
--> $DIR/const-drop-fail.rs:21:19
|
--> $DIR/const-drop-fail.rs:36:19
|
||||||
|
|
|
|
||||||
LL | const fn check<T: ~const Drop>(_: T) {}
|
LL | const fn check<T: ~const Drop>(_: T) {}
|
||||||
| ^^^^^^^^^^^ required by this bound in `check`
|
| ^^^^^^^^^^^ required by this bound in `check`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error[E0277]: the trait bound `NonTrivialDrop: A` is not satisfied
|
||||||
|
--> $DIR/const-drop-fail.rs:49:5
|
||||||
|
|
|
||||||
|
LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData),
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `A` is not implemented for `NonTrivialDrop`
|
||||||
|
|
|
||||||
|
note: required by `ConstDropImplWithBounds`
|
||||||
|
--> $DIR/const-drop-fail.rs:27:1
|
||||||
|
|
|
||||||
|
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0277]: the trait bound `NonTrivialDrop: A` is not satisfied
|
||||||
|
--> $DIR/const-drop-fail.rs:49:5
|
||||||
|
|
|
||||||
|
LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData),
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `A` is not implemented for `NonTrivialDrop`
|
||||||
|
|
|
||||||
|
note: required by a bound in `ConstDropImplWithBounds`
|
||||||
|
--> $DIR/const-drop-fail.rs:27:35
|
||||||
|
|
|
||||||
|
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
|
||||||
|
| ^^^^^^^^ required by this bound in `ConstDropImplWithBounds`
|
||||||
|
|
||||||
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0277`.
|
For more information about this error, try `rustc --explain E0277`.
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#![feature(const_fn_trait_bound)]
|
#![feature(const_fn_trait_bound)]
|
||||||
#![cfg_attr(precise, feature(const_precise_live_drops))]
|
#![cfg_attr(precise, feature(const_precise_live_drops))]
|
||||||
|
|
||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
struct NonTrivialDrop;
|
struct NonTrivialDrop;
|
||||||
|
|
||||||
impl Drop for NonTrivialDrop {
|
impl Drop for NonTrivialDrop {
|
||||||
@ -18,6 +20,19 @@ impl const Drop for ConstImplWithDropGlue {
|
|||||||
fn drop(&mut self) {}
|
fn drop(&mut self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trait A { fn a() { println!("A"); } }
|
||||||
|
|
||||||
|
impl A for NonTrivialDrop {}
|
||||||
|
|
||||||
|
struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
|
||||||
|
//~^ ERROR `~const` is not allowed
|
||||||
|
|
||||||
|
impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
T::a();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const fn check<T: ~const Drop>(_: T) {}
|
const fn check<T: ~const Drop>(_: T) {}
|
||||||
|
|
||||||
macro_rules! check_all {
|
macro_rules! check_all {
|
||||||
@ -31,6 +46,9 @@ check_all! {
|
|||||||
//~^ ERROR the trait bound
|
//~^ ERROR the trait bound
|
||||||
ConstImplWithDropGlue(NonTrivialDrop),
|
ConstImplWithDropGlue(NonTrivialDrop),
|
||||||
//~^ ERROR the trait bound
|
//~^ ERROR the trait bound
|
||||||
|
ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData),
|
||||||
|
//~^ ERROR the trait bound
|
||||||
|
//~| ERROR the trait bound
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -1,27 +1,59 @@
|
|||||||
|
error: `~const` is not allowed here
|
||||||
|
--> $DIR/const-drop-fail.rs:27:35
|
||||||
|
|
|
||||||
|
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
|
||||||
|
| ^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: only allowed on bounds on traits' associated types and functions, const fns, const impls and its associated functions
|
||||||
|
|
||||||
error[E0277]: the trait bound `NonTrivialDrop: Drop` is not satisfied
|
error[E0277]: the trait bound `NonTrivialDrop: Drop` is not satisfied
|
||||||
--> $DIR/const-drop-fail.rs:30:5
|
--> $DIR/const-drop-fail.rs:45:5
|
||||||
|
|
|
|
||||||
LL | NonTrivialDrop,
|
LL | NonTrivialDrop,
|
||||||
| ^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `NonTrivialDrop`
|
| ^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `NonTrivialDrop`
|
||||||
|
|
|
|
||||||
note: required by a bound in `check`
|
note: required by a bound in `check`
|
||||||
--> $DIR/const-drop-fail.rs:21:19
|
--> $DIR/const-drop-fail.rs:36:19
|
||||||
|
|
|
|
||||||
LL | const fn check<T: ~const Drop>(_: T) {}
|
LL | const fn check<T: ~const Drop>(_: T) {}
|
||||||
| ^^^^^^^^^^^ required by this bound in `check`
|
| ^^^^^^^^^^^ required by this bound in `check`
|
||||||
|
|
||||||
error[E0277]: the trait bound `ConstImplWithDropGlue: Drop` is not satisfied
|
error[E0277]: the trait bound `ConstImplWithDropGlue: Drop` is not satisfied
|
||||||
--> $DIR/const-drop-fail.rs:32:5
|
--> $DIR/const-drop-fail.rs:47:5
|
||||||
|
|
|
|
||||||
LL | ConstImplWithDropGlue(NonTrivialDrop),
|
LL | ConstImplWithDropGlue(NonTrivialDrop),
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `ConstImplWithDropGlue`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `ConstImplWithDropGlue`
|
||||||
|
|
|
|
||||||
note: required by a bound in `check`
|
note: required by a bound in `check`
|
||||||
--> $DIR/const-drop-fail.rs:21:19
|
--> $DIR/const-drop-fail.rs:36:19
|
||||||
|
|
|
|
||||||
LL | const fn check<T: ~const Drop>(_: T) {}
|
LL | const fn check<T: ~const Drop>(_: T) {}
|
||||||
| ^^^^^^^^^^^ required by this bound in `check`
|
| ^^^^^^^^^^^ required by this bound in `check`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error[E0277]: the trait bound `NonTrivialDrop: A` is not satisfied
|
||||||
|
--> $DIR/const-drop-fail.rs:49:5
|
||||||
|
|
|
||||||
|
LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData),
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `A` is not implemented for `NonTrivialDrop`
|
||||||
|
|
|
||||||
|
note: required by `ConstDropImplWithBounds`
|
||||||
|
--> $DIR/const-drop-fail.rs:27:1
|
||||||
|
|
|
||||||
|
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error[E0277]: the trait bound `NonTrivialDrop: A` is not satisfied
|
||||||
|
--> $DIR/const-drop-fail.rs:49:5
|
||||||
|
|
|
||||||
|
LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData),
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `A` is not implemented for `NonTrivialDrop`
|
||||||
|
|
|
||||||
|
note: required by a bound in `ConstDropImplWithBounds`
|
||||||
|
--> $DIR/const-drop-fail.rs:27:35
|
||||||
|
|
|
||||||
|
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
|
||||||
|
| ^^^^^^^^ required by this bound in `ConstDropImplWithBounds`
|
||||||
|
|
||||||
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0277`.
|
For more information about this error, try `rustc --explain E0277`.
|
||||||
|
Loading…
Reference in New Issue
Block a user