Skip to content

Commit 3aeb43c

Browse files
committed
add and bless tests
1 parent 6bf2c4d commit 3aeb43c

5 files changed

+65
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#[rustc_do_not_const_check]
2+
//~^ ERROR this is an internal attribute that will never be stable
3+
const fn foo() {}
4+
5+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0658]: this is an internal attribute that will never be stable
2+
--> $DIR/gate-do-not-const-check.rs:1:1
3+
|
4+
LL | #[rustc_do_not_const_check]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0658`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// check-pass
2+
#![feature(const_trait_impl, rustc_attrs)]
3+
4+
#[const_trait]
5+
trait Foo {
6+
#[rustc_do_not_const_check]
7+
fn into_iter(&self) { println!("FEAR ME!") }
8+
}
9+
10+
11+
impl const Foo for () {
12+
fn into_iter(&self) {
13+
// ^_^
14+
}
15+
}
16+
17+
const _: () = Foo::into_iter(&());
18+
19+
fn main() {}

tests/ui/typeck/typeck_type_placeholder_item.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,6 @@ fn evens_squared(n: usize) -> _ {
227227
}
228228

229229
const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
230-
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
230+
//~^ ERROR the trait bound
231+
//~| ERROR the trait bound
232+
//~| ERROR the placeholder

tests/ui/typeck/typeck_type_placeholder_item.stderr

+27-7
Original file line numberDiff line numberDiff line change
@@ -437,17 +437,37 @@ LL | fn evens_squared(n: usize) -> _ {
437437
| not allowed in type signatures
438438
| help: replace with an appropriate return type: `impl Iterator<Item = usize>`
439439

440-
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
441-
--> $DIR/typeck_type_placeholder_item.rs:229:10
440+
error[E0277]: the trait bound `std::ops::Range<{integer}>: Iterator` is not satisfied
441+
--> $DIR/typeck_type_placeholder_item.rs:229:22
442442
|
443443
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
444-
| ^ not allowed in type signatures
444+
| ^^^^^^ `std::ops::Range<{integer}>` is not an iterator
445+
|
446+
= help: the trait `~const Iterator` is not implemented for `std::ops::Range<{integer}>`
447+
note: the trait `Iterator` is implemented for `std::ops::Range<{integer}>`, but that implementation is not `const`
448+
--> $DIR/typeck_type_placeholder_item.rs:229:14
449+
|
450+
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
451+
| ^^^^^^^
452+
453+
error[E0277]: the trait bound `Filter<std::ops::Range<{integer}>, [closure@$DIR/typeck_type_placeholder_item.rs:229:29: 229:32]>: Iterator` is not satisfied
454+
--> $DIR/typeck_type_placeholder_item.rs:229:45
445455
|
446-
note: however, the inferred type `Map<Filter<Range<i32>, [closure@typeck_type_placeholder_item.rs:229:29]>, [closure@typeck_type_placeholder_item.rs:229:49]>` cannot be named
456+
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
457+
| ^^^ `Filter<std::ops::Range<{integer}>, [closure@$DIR/typeck_type_placeholder_item.rs:229:29: 229:32]>` is not an iterator
458+
|
459+
= help: the trait `~const Iterator` is not implemented for `Filter<std::ops::Range<{integer}>, [closure@$DIR/typeck_type_placeholder_item.rs:229:29: 229:32]>`
460+
note: the trait `Iterator` is implemented for `Filter<std::ops::Range<{integer}>, [closure@$DIR/typeck_type_placeholder_item.rs:229:29: 229:32]>`, but that implementation is not `const`
447461
--> $DIR/typeck_type_placeholder_item.rs:229:14
448462
|
449463
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
450-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
464+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
465+
466+
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
467+
--> $DIR/typeck_type_placeholder_item.rs:229:10
468+
|
469+
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
470+
| ^ not allowed in type signatures
451471

452472
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
453473
--> $DIR/typeck_type_placeholder_item.rs:140:31
@@ -657,7 +677,7 @@ LL | const D: _ = 42;
657677
| not allowed in type signatures
658678
| help: replace with the correct type: `i32`
659679

660-
error: aborting due to 71 previous errors
680+
error: aborting due to 73 previous errors
661681

662-
Some errors have detailed explanations: E0121, E0282, E0403.
682+
Some errors have detailed explanations: E0121, E0277, E0282, E0403.
663683
For more information about an error, try `rustc --explain E0121`.

0 commit comments

Comments
 (0)