Skip to content

Commit

Permalink
add and bless tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed Jan 31, 2023
1 parent 6bf2c4d commit 3aeb43c
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 8 deletions.
5 changes: 5 additions & 0 deletions tests/ui/consts/gate-do-not-const-check.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#[rustc_do_not_const_check]
//~^ ERROR this is an internal attribute that will never be stable
const fn foo() {}

fn main() {}
11 changes: 11 additions & 0 deletions tests/ui/consts/gate-do-not-const-check.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0658]: this is an internal attribute that will never be stable
--> $DIR/gate-do-not-const-check.rs:1:1
|
LL | #[rustc_do_not_const_check]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
19 changes: 19 additions & 0 deletions tests/ui/rfc-2632-const-trait-impl/do-not-const-check-override.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// check-pass
#![feature(const_trait_impl, rustc_attrs)]

#[const_trait]
trait Foo {
#[rustc_do_not_const_check]
fn into_iter(&self) { println!("FEAR ME!") }
}


impl const Foo for () {
fn into_iter(&self) {
// ^_^
}
}

const _: () = Foo::into_iter(&());

fn main() {}
4 changes: 3 additions & 1 deletion tests/ui/typeck/typeck_type_placeholder_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,6 @@ fn evens_squared(n: usize) -> _ {
}

const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
//~^ ERROR the trait bound
//~| ERROR the trait bound
//~| ERROR the placeholder
34 changes: 27 additions & 7 deletions tests/ui/typeck/typeck_type_placeholder_item.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -437,17 +437,37 @@ LL | fn evens_squared(n: usize) -> _ {
| not allowed in type signatures
| help: replace with an appropriate return type: `impl Iterator<Item = usize>`

error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
--> $DIR/typeck_type_placeholder_item.rs:229:10
error[E0277]: the trait bound `std::ops::Range<{integer}>: Iterator` is not satisfied
--> $DIR/typeck_type_placeholder_item.rs:229:22
|
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
| ^ not allowed in type signatures
| ^^^^^^ `std::ops::Range<{integer}>` is not an iterator
|
= help: the trait `~const Iterator` is not implemented for `std::ops::Range<{integer}>`
note: the trait `Iterator` is implemented for `std::ops::Range<{integer}>`, but that implementation is not `const`
--> $DIR/typeck_type_placeholder_item.rs:229:14
|
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
| ^^^^^^^

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
--> $DIR/typeck_type_placeholder_item.rs:229:45
|
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
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
| ^^^ `Filter<std::ops::Range<{integer}>, [closure@$DIR/typeck_type_placeholder_item.rs:229:29: 229:32]>` is not an iterator
|
= 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]>`
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`
--> $DIR/typeck_type_placeholder_item.rs:229:14
|
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
--> $DIR/typeck_type_placeholder_item.rs:229:10
|
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
| ^ not allowed in type signatures

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

error: aborting due to 71 previous errors
error: aborting due to 73 previous errors

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

0 comments on commit 3aeb43c

Please sign in to comment.