Skip to content

Commit 1f41fbe

Browse files
committed
introduce tests
1 parent 221e274 commit 1f41fbe

6 files changed

+310
-0
lines changed
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![feature(effects)]
2+
//~^ WARN: the feature `effects` is incomplete
3+
4+
struct A();
5+
6+
impl const Drop for A {}
7+
//~^ ERROR: const trait impls are experimental
8+
//~| const `impl` for trait `Drop` which is not marked with `#[const_trait]`
9+
//~| not all trait items implemented, missing: `drop`
10+
11+
fn main() {}
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
error[E0658]: const trait impls are experimental
2+
--> $DIR/const_drop_is_valid.rs:6:6
3+
|
4+
LL | impl const Drop for A {}
5+
| ^^^^^
6+
|
7+
= note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
8+
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes
12+
--> $DIR/const_drop_is_valid.rs:1:12
13+
|
14+
LL | #![feature(effects)]
15+
| ^^^^^^^
16+
|
17+
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information
18+
= note: `#[warn(incomplete_features)]` on by default
19+
20+
error: using `#![feature(effects)]` without enabling next trait solver globally
21+
|
22+
= note: the next trait solver must be enabled globally for the effects feature to work correctly
23+
= help: use `-Znext-solver` to enable
24+
25+
error: const `impl` for trait `Drop` which is not marked with `#[const_trait]`
26+
--> $DIR/const_drop_is_valid.rs:6:12
27+
|
28+
LL | impl const Drop for A {}
29+
| ^^^^
30+
|
31+
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
32+
= note: adding a non-const method body in the future would be a breaking change
33+
34+
error[E0046]: not all trait items implemented, missing: `drop`
35+
--> $DIR/const_drop_is_valid.rs:6:1
36+
|
37+
LL | impl const Drop for A {}
38+
| ^^^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation
39+
|
40+
= help: implement the missing item: `fn drop(&mut self) { todo!() }`
41+
42+
error: aborting due to 4 previous errors; 1 warning emitted
43+
44+
Some errors have detailed explanations: E0046, E0658.
45+
For more information about an error, try `rustc --explain E0046`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
struct Foo<T: Trait>(T);
2+
3+
trait Trait {
4+
type Assoc;
5+
}
6+
7+
impl<T: Trait<Assoc = U>, U: ?Sized> Drop for Foo<T> {
8+
//~^ ERROR: `Drop` impl requires `<T as Trait>::Assoc == U`
9+
fn drop(&mut self) {}
10+
}
11+
12+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0367]: `Drop` impl requires `<T as Trait>::Assoc == U` but the struct it is implemented for does not
2+
--> $DIR/constrained_by_assoc_type_equality.rs:7:15
3+
|
4+
LL | impl<T: Trait<Assoc = U>, U: ?Sized> Drop for Foo<T> {
5+
| ^^^^^^^^^
6+
|
7+
note: the implementor must specify the same requirement
8+
--> $DIR/constrained_by_assoc_type_equality.rs:1:1
9+
|
10+
LL | struct Foo<T: Trait>(T);
11+
| ^^^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to 1 previous error
14+
15+
For more information about this error, try `rustc --explain E0367`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ known-bug: unknown
2+
//@ failure-status: 101
3+
4+
struct Foo {}
5+
6+
impl<const UNUSED: usize> Drop for Foo {}
7+
8+
fn main() {}

0 commit comments

Comments
 (0)