Skip to content

Commit 33e5efb

Browse files
adjust tests
1 parent 6ed42a7 commit 33e5efb

File tree

4 files changed

+67
-67
lines changed

4 files changed

+67
-67
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
error: `~const` is not allowed here
2-
--> $DIR/const-drop-fail.rs:27:35
3-
|
4-
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
5-
| ^^^^^^^^
6-
|
7-
= note: only allowed on bounds on traits' associated types and functions, const fns, const impls and its associated functions
8-
91
error[E0277]: the trait bound `NonTrivialDrop: Drop` is not satisfied
10-
--> $DIR/const-drop-fail.rs:45:5
2+
--> $DIR/const-drop-fail.rs:44:5
113
|
124
LL | const _: () = check($exp);
135
| ----- required by a bound introduced by this call
@@ -16,50 +8,51 @@ LL | NonTrivialDrop,
168
| ^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `NonTrivialDrop`
179
|
1810
note: required by a bound in `check`
19-
--> $DIR/const-drop-fail.rs:36:19
11+
--> $DIR/const-drop-fail.rs:35:19
2012
|
2113
LL | const fn check<T: ~const Drop>(_: T) {}
2214
| ^^^^^^^^^^^ required by this bound in `check`
2315

24-
error[E0277]: the trait bound `ConstImplWithDropGlue: Drop` is not satisfied
25-
--> $DIR/const-drop-fail.rs:47:5
16+
error[E0277]: the trait bound `NonTrivialDrop: Drop` is not satisfied in `ConstImplWithDropGlue`
17+
--> $DIR/const-drop-fail.rs:46:5
2618
|
2719
LL | const _: () = check($exp);
2820
| ----- required by a bound introduced by this call
2921
...
3022
LL | ConstImplWithDropGlue(NonTrivialDrop),
31-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `ConstImplWithDropGlue`
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `ConstImplWithDropGlue`, the trait `Drop` is not implemented for `NonTrivialDrop`
3224
|
25+
note: required because it appears within the type `ConstImplWithDropGlue`
26+
--> $DIR/const-drop-fail.rs:17:8
27+
|
28+
LL | struct ConstImplWithDropGlue(NonTrivialDrop);
29+
| ^^^^^^^^^^^^^^^^^^^^^
3330
note: required by a bound in `check`
34-
--> $DIR/const-drop-fail.rs:36:19
31+
--> $DIR/const-drop-fail.rs:35:19
3532
|
3633
LL | const fn check<T: ~const Drop>(_: T) {}
3734
| ^^^^^^^^^^^ required by this bound in `check`
3835

3936
error[E0277]: the trait bound `NonTrivialDrop: A` is not satisfied
40-
--> $DIR/const-drop-fail.rs:49:5
41-
|
42-
LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData),
43-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `A` is not implemented for `NonTrivialDrop`
44-
|
45-
note: required by a bound in `ConstDropImplWithBounds`
46-
--> $DIR/const-drop-fail.rs:27:35
47-
|
48-
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
49-
| ^^^^^^^^ required by this bound in `ConstDropImplWithBounds`
50-
51-
error[E0277]: the trait bound `NonTrivialDrop: A` is not satisfied
52-
--> $DIR/const-drop-fail.rs:49:5
37+
--> $DIR/const-drop-fail.rs:48:5
5338
|
39+
LL | const _: () = check($exp);
40+
| ----- required by a bound introduced by this call
41+
...
5442
LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData),
5543
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `A` is not implemented for `NonTrivialDrop`
5644
|
57-
note: required by a bound in `ConstDropImplWithBounds`
58-
--> $DIR/const-drop-fail.rs:27:35
45+
note: required because of the requirements on the impl of `Drop` for `ConstDropImplWithBounds<NonTrivialDrop>`
46+
--> $DIR/const-drop-fail.rs:29:25
5947
|
60-
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
61-
| ^^^^^^^^ required by this bound in `ConstDropImplWithBounds`
48+
LL | impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> {
49+
| ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^
50+
note: required by a bound in `check`
51+
--> $DIR/const-drop-fail.rs:35:19
52+
|
53+
LL | const fn check<T: ~const Drop>(_: T) {}
54+
| ^^^^^^^^^^^ required by this bound in `check`
6255

63-
error: aborting due to 5 previous errors
56+
error: aborting due to 3 previous errors
6457

6558
For more information about this error, try `rustc --explain E0277`.

src/test/ui/rfc-2632-const-trait-impl/const-drop-fail.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ trait A { fn a() { println!("A"); } }
2424

2525
impl A for NonTrivialDrop {}
2626

27-
struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
28-
//~^ ERROR `~const` is not allowed
27+
struct ConstDropImplWithBounds<T: A>(PhantomData<T>);
2928

3029
impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> {
3130
fn drop(&mut self) {
@@ -48,7 +47,6 @@ check_all! {
4847
//~^ ERROR the trait bound
4948
ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData),
5049
//~^ ERROR the trait bound
51-
//~| ERROR the trait bound
5250
}
5351

5452
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
error: `~const` is not allowed here
2-
--> $DIR/const-drop-fail.rs:27:35
3-
|
4-
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
5-
| ^^^^^^^^
6-
|
7-
= note: only allowed on bounds on traits' associated types and functions, const fns, const impls and its associated functions
8-
91
error[E0277]: the trait bound `NonTrivialDrop: Drop` is not satisfied
10-
--> $DIR/const-drop-fail.rs:45:5
2+
--> $DIR/const-drop-fail.rs:44:5
113
|
124
LL | const _: () = check($exp);
135
| ----- required by a bound introduced by this call
@@ -16,50 +8,51 @@ LL | NonTrivialDrop,
168
| ^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `NonTrivialDrop`
179
|
1810
note: required by a bound in `check`
19-
--> $DIR/const-drop-fail.rs:36:19
11+
--> $DIR/const-drop-fail.rs:35:19
2012
|
2113
LL | const fn check<T: ~const Drop>(_: T) {}
2214
| ^^^^^^^^^^^ required by this bound in `check`
2315

24-
error[E0277]: the trait bound `ConstImplWithDropGlue: Drop` is not satisfied
25-
--> $DIR/const-drop-fail.rs:47:5
16+
error[E0277]: the trait bound `NonTrivialDrop: Drop` is not satisfied in `ConstImplWithDropGlue`
17+
--> $DIR/const-drop-fail.rs:46:5
2618
|
2719
LL | const _: () = check($exp);
2820
| ----- required by a bound introduced by this call
2921
...
3022
LL | ConstImplWithDropGlue(NonTrivialDrop),
31-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Drop` is not implemented for `ConstImplWithDropGlue`
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `ConstImplWithDropGlue`, the trait `Drop` is not implemented for `NonTrivialDrop`
3224
|
25+
note: required because it appears within the type `ConstImplWithDropGlue`
26+
--> $DIR/const-drop-fail.rs:17:8
27+
|
28+
LL | struct ConstImplWithDropGlue(NonTrivialDrop);
29+
| ^^^^^^^^^^^^^^^^^^^^^
3330
note: required by a bound in `check`
34-
--> $DIR/const-drop-fail.rs:36:19
31+
--> $DIR/const-drop-fail.rs:35:19
3532
|
3633
LL | const fn check<T: ~const Drop>(_: T) {}
3734
| ^^^^^^^^^^^ required by this bound in `check`
3835

3936
error[E0277]: the trait bound `NonTrivialDrop: A` is not satisfied
40-
--> $DIR/const-drop-fail.rs:49:5
41-
|
42-
LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData),
43-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `A` is not implemented for `NonTrivialDrop`
44-
|
45-
note: required by a bound in `ConstDropImplWithBounds`
46-
--> $DIR/const-drop-fail.rs:27:35
47-
|
48-
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
49-
| ^^^^^^^^ required by this bound in `ConstDropImplWithBounds`
50-
51-
error[E0277]: the trait bound `NonTrivialDrop: A` is not satisfied
52-
--> $DIR/const-drop-fail.rs:49:5
37+
--> $DIR/const-drop-fail.rs:48:5
5338
|
39+
LL | const _: () = check($exp);
40+
| ----- required by a bound introduced by this call
41+
...
5442
LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData),
5543
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `A` is not implemented for `NonTrivialDrop`
5644
|
57-
note: required by a bound in `ConstDropImplWithBounds`
58-
--> $DIR/const-drop-fail.rs:27:35
45+
note: required because of the requirements on the impl of `Drop` for `ConstDropImplWithBounds<NonTrivialDrop>`
46+
--> $DIR/const-drop-fail.rs:29:25
5947
|
60-
LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>);
61-
| ^^^^^^^^ required by this bound in `ConstDropImplWithBounds`
48+
LL | impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> {
49+
| ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^
50+
note: required by a bound in `check`
51+
--> $DIR/const-drop-fail.rs:35:19
52+
|
53+
LL | const fn check<T: ~const Drop>(_: T) {}
54+
| ^^^^^^^^^^^ required by this bound in `check`
6255

63-
error: aborting due to 5 previous errors
56+
error: aborting due to 3 previous errors
6457

6558
For more information about this error, try `rustc --explain E0277`.

src/test/ui/rfc-2632-const-trait-impl/const-drop.rs

+16
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,21 @@ mod t {
4545

4646
pub struct HasConstDrop(pub ConstDrop);
4747
pub struct TrivialFields(pub u8, pub i8, pub usize, pub isize);
48+
49+
pub trait SomeTrait {
50+
fn foo();
51+
}
52+
impl const SomeTrait for () {
53+
fn foo() {}
54+
}
55+
56+
pub struct ConstDropWithBound<T: SomeTrait>(pub core::marker::PhantomData<T>);
57+
58+
impl<T: ~const SomeTrait> const Drop for ConstDropWithBound<T> {
59+
fn drop(&mut self) {
60+
T::foo();
61+
}
62+
}
4863
}
4964

5065
use t::*;
@@ -61,6 +76,7 @@ implements_const_drop! {
6176
TrivialFields(1, 2, 3, 4),
6277
&1,
6378
&1 as *const i32,
79+
ConstDropWithBound::<()>,
6480
}
6581

6682
fn main() {

0 commit comments

Comments
 (0)