Skip to content

Commit

Permalink
update tests, adding known-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed Jul 27, 2023
1 parent e6b423a commit 2d59451
Show file tree
Hide file tree
Showing 65 changed files with 288 additions and 660 deletions.
1 change: 0 additions & 1 deletion tests/ui/const-generics/issue-93647.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
struct X<const N: usize = {
(||1usize)()
//~^ ERROR cannot call non-const closure
//~| ERROR the trait bound
}>;

fn main() {}
19 changes: 2 additions & 17 deletions tests/ui/const-generics/issue-93647.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
error[E0277]: the trait bound `[closure@$DIR/issue-93647.rs:2:6: 2:8]: Fn<()>` is not satisfied
--> $DIR/issue-93647.rs:2:5
|
LL | (||1usize)()
| ^^^^^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-93647.rs:2:6: 2:8]`
|
= help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-93647.rs:2:6: 2:8]`
note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-93647.rs:2:6: 2:8]`, but that implementation is not `const`
--> $DIR/issue-93647.rs:2:5
|
LL | (||1usize)()
| ^^^^^^^^^^^^
= note: wrap the `[closure@$DIR/issue-93647.rs:2:6: 2:8]` in a closure with no arguments: `|| { /* code */ }`

error[E0015]: cannot call non-const closure in constants
--> $DIR/issue-93647.rs:2:5
|
Expand All @@ -22,7 +8,6 @@ LL | (||1usize)()
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable

error: aborting due to 2 previous errors
error: aborting due to previous error

Some errors have detailed explanations: E0015, E0277.
For more information about an error, try `rustc --explain E0015`.
For more information about this error, try `rustc --explain E0015`.
4 changes: 3 additions & 1 deletion tests/ui/consts/const-block-const-bound.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// known-bug: #103507

#![allow(unused)]
#![feature(const_trait_impl, inline_const, negative_impls)]

Expand All @@ -14,6 +16,6 @@ impl Drop for UnconstDrop {
fn main() {
const {
f(UnconstDrop);
//~^ ERROR can't drop
//FIXME ~^ ERROR can't drop
}
}
20 changes: 7 additions & 13 deletions tests/ui/consts/const-block-const-bound.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
error[E0277]: can't drop `UnconstDrop` in const contexts
--> $DIR/const-block-const-bound.rs:16:9
error[E0493]: destructor of `T` cannot be evaluated at compile-time
--> $DIR/const-block-const-bound.rs:8:32
|
LL | f(UnconstDrop);
| ^^^^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `UnconstDrop`
|
= note: the trait bound `UnconstDrop: ~const Destruct` is not satisfied
help: consider borrowing here
|
LL | &f(UnconstDrop);
| +
LL | &mut f(UnconstDrop);
| ++++
LL | const fn f<T: ~const Destruct>(x: T) {}
| ^ - value is dropped here
| |
| the destructor for this type cannot be evaluated in constant functions

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
For more information about this error, try `rustc --explain E0493`.
44 changes: 2 additions & 42 deletions tests/ui/consts/const_cmp_type_id.stderr
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
error[E0277]: can't compare `TypeId` with `TypeId` in const contexts
--> $DIR/const_cmp_type_id.rs:8:13
|
LL | assert!(TypeId::of::<u8>() == TypeId::of::<u8>());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId == TypeId`
|
= help: the trait `~const PartialEq` is not implemented for `TypeId`
note: the trait `PartialEq` is implemented for `TypeId`, but that implementation is not `const`
--> $DIR/const_cmp_type_id.rs:8:13
|
LL | assert!(TypeId::of::<u8>() == TypeId::of::<u8>());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0015]: cannot call non-const operator in constant functions
--> $DIR/const_cmp_type_id.rs:8:13
|
Expand All @@ -21,19 +8,6 @@ note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/any.rs:LL:COL
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants

error[E0277]: can't compare `TypeId` with `TypeId` in const contexts
--> $DIR/const_cmp_type_id.rs:9:13
|
LL | assert!(TypeId::of::<()>() != TypeId::of::<u8>());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId == TypeId`
|
= help: the trait `~const PartialEq` is not implemented for `TypeId`
note: the trait `PartialEq` is implemented for `TypeId`, but that implementation is not `const`
--> $DIR/const_cmp_type_id.rs:9:13
|
LL | assert!(TypeId::of::<()>() != TypeId::of::<u8>());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0015]: cannot call non-const operator in constant functions
--> $DIR/const_cmp_type_id.rs:9:13
|
Expand All @@ -44,19 +18,6 @@ note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/any.rs:LL:COL
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants

error[E0277]: can't compare `TypeId` with `TypeId` in const contexts
--> $DIR/const_cmp_type_id.rs:10:22
|
LL | const _A: bool = TypeId::of::<u8>() < TypeId::of::<u16>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId < TypeId` and `TypeId > TypeId`
|
= help: the trait `~const PartialOrd` is not implemented for `TypeId`
note: the trait `PartialOrd` is implemented for `TypeId`, but that implementation is not `const`
--> $DIR/const_cmp_type_id.rs:10:22
|
LL | const _A: bool = TypeId::of::<u8>() < TypeId::of::<u16>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0015]: cannot call non-const operator in constants
--> $DIR/const_cmp_type_id.rs:10:22
|
Expand All @@ -68,7 +29,6 @@ note: impl defined here, but it is not `const`
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 6 previous errors
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0015, E0277.
For more information about an error, try `rustc --explain E0015`.
For more information about this error, try `rustc --explain E0015`.
1 change: 0 additions & 1 deletion tests/ui/consts/invalid-inline-const-in-match-arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ fn main() {
match () {
const { (|| {})() } => {}
//~^ ERROR cannot call non-const closure in constants
//~| ERROR the trait bound
}
}
19 changes: 2 additions & 17 deletions tests/ui/consts/invalid-inline-const-in-match-arm.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
error[E0277]: the trait bound `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]: Fn<()>` is not satisfied
--> $DIR/invalid-inline-const-in-match-arm.rs:6:17
|
LL | const { (|| {})() } => {}
| ^^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]`
|
= help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]`
note: the trait `Fn<()>` is implemented for `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]`, but that implementation is not `const`
--> $DIR/invalid-inline-const-in-match-arm.rs:6:17
|
LL | const { (|| {})() } => {}
| ^^^^^^^^^
= note: wrap the `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]` in a closure with no arguments: `|| { /* code */ }`

error[E0015]: cannot call non-const closure in constants
--> $DIR/invalid-inline-const-in-match-arm.rs:6:17
|
Expand All @@ -22,7 +8,6 @@ LL | const { (|| {})() } => {}
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable

error: aborting due to 2 previous errors
error: aborting due to previous error

Some errors have detailed explanations: E0015, E0277.
For more information about an error, try `rustc --explain E0015`.
For more information about this error, try `rustc --explain E0015`.
1 change: 0 additions & 1 deletion tests/ui/consts/issue-28113.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const X: u8 =
|| -> u8 { 5 }()
//~^ ERROR cannot call non-const closure
//~| ERROR the trait bound
;

fn main() {}
19 changes: 2 additions & 17 deletions tests/ui/consts/issue-28113.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
error[E0277]: the trait bound `[closure@$DIR/issue-28113.rs:4:5: 4:13]: Fn<()>` is not satisfied
--> $DIR/issue-28113.rs:4:5
|
LL | || -> u8 { 5 }()
| ^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-28113.rs:4:5: 4:13]`
|
= help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-28113.rs:4:5: 4:13]`
note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-28113.rs:4:5: 4:13]`, but that implementation is not `const`
--> $DIR/issue-28113.rs:4:5
|
LL | || -> u8 { 5 }()
| ^^^^^^^^^^^^^^^^
= note: wrap the `[closure@$DIR/issue-28113.rs:4:5: 4:13]` in a closure with no arguments: `|| { /* code */ }`

error[E0015]: cannot call non-const closure in constants
--> $DIR/issue-28113.rs:4:5
|
Expand All @@ -22,7 +8,6 @@ LL | || -> u8 { 5 }()
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable

error: aborting due to 2 previous errors
error: aborting due to previous error

Some errors have detailed explanations: E0015, E0277.
For more information about an error, try `rustc --explain E0015`.
For more information about this error, try `rustc --explain E0015`.
1 change: 0 additions & 1 deletion tests/ui/consts/issue-56164.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const fn foo() { (||{})() }
//~^ ERROR cannot call non-const closure
//~| ERROR the trait bound

const fn bad(input: fn()) {
input()
Expand Down
21 changes: 3 additions & 18 deletions tests/ui/consts/issue-56164.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
error[E0277]: the trait bound `[closure@$DIR/issue-56164.rs:1:19: 1:21]: Fn<()>` is not satisfied
--> $DIR/issue-56164.rs:1:18
|
LL | const fn foo() { (||{})() }
| ^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-56164.rs:1:19: 1:21]`
|
= help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-56164.rs:1:19: 1:21]`
note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-56164.rs:1:19: 1:21]`, but that implementation is not `const`
--> $DIR/issue-56164.rs:1:18
|
LL | const fn foo() { (||{})() }
| ^^^^^^^^
= note: wrap the `[closure@$DIR/issue-56164.rs:1:19: 1:21]` in a closure with no arguments: `|| { /* code */ }`

error[E0015]: cannot call non-const closure in constant functions
--> $DIR/issue-56164.rs:1:18
|
Expand All @@ -23,12 +9,11 @@ LL | const fn foo() { (||{})() }
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable

error: function pointer calls are not allowed in constant functions
--> $DIR/issue-56164.rs:6:5
--> $DIR/issue-56164.rs:5:5
|
LL | input()
| ^^^^^^^

error: aborting due to 3 previous errors
error: aborting due to 2 previous errors

Some errors have detailed explanations: E0015, E0277.
For more information about an error, try `rustc --explain E0015`.
For more information about this error, try `rustc --explain E0015`.
1 change: 0 additions & 1 deletion tests/ui/consts/issue-68542-closure-in-array-len.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

struct Bug {
a: [(); (|| { 0 })()] //~ ERROR cannot call non-const closure
//~^ ERROR the trait bound
}

fn main() {}
19 changes: 2 additions & 17 deletions tests/ui/consts/issue-68542-closure-in-array-len.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
error[E0277]: the trait bound `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]: Fn<()>` is not satisfied
--> $DIR/issue-68542-closure-in-array-len.rs:6:13
|
LL | a: [(); (|| { 0 })()]
| ^^^^^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]`
|
= help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]`
note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]`, but that implementation is not `const`
--> $DIR/issue-68542-closure-in-array-len.rs:6:13
|
LL | a: [(); (|| { 0 })()]
| ^^^^^^^^^^^^
= note: wrap the `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]` in a closure with no arguments: `|| { /* code */ }`

error[E0015]: cannot call non-const closure in constants
--> $DIR/issue-68542-closure-in-array-len.rs:6:13
|
Expand All @@ -22,7 +8,6 @@ LL | a: [(); (|| { 0 })()]
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable

error: aborting due to 2 previous errors
error: aborting due to previous error

Some errors have detailed explanations: E0015, E0277.
For more information about an error, try `rustc --explain E0015`.
For more information about this error, try `rustc --explain E0015`.
18 changes: 2 additions & 16 deletions tests/ui/consts/issue-73976-monomorphic.stderr
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
error[E0277]: can't compare `TypeId` with `TypeId` in const contexts
--> $DIR/issue-73976-monomorphic.rs:21:5
|
LL | GetTypeId::<T>::VALUE == GetTypeId::<usize>::VALUE
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `TypeId == TypeId`
|
= help: the trait `~const PartialEq` is not implemented for `TypeId`
note: the trait `PartialEq` is implemented for `TypeId`, but that implementation is not `const`
--> $DIR/issue-73976-monomorphic.rs:21:5
|
LL | GetTypeId::<T>::VALUE == GetTypeId::<usize>::VALUE
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0015]: cannot call non-const operator in constant functions
--> $DIR/issue-73976-monomorphic.rs:21:5
|
Expand All @@ -21,7 +8,6 @@ note: impl defined here, but it is not `const`
--> $SRC_DIR/core/src/any.rs:LL:COL
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants

error: aborting due to 2 previous errors
error: aborting due to previous error

Some errors have detailed explanations: E0015, E0277.
For more information about an error, try `rustc --explain E0015`.
For more information about this error, try `rustc --explain E0015`.
8 changes: 5 additions & 3 deletions tests/ui/consts/issue-94675.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// known-bug: #103507

#![feature(const_trait_impl, const_mut_refs)]

struct Foo<'a> {
Expand All @@ -7,9 +9,9 @@ struct Foo<'a> {
impl<'a> Foo<'a> {
const fn spam(&mut self, baz: &mut Vec<u32>) {
self.bar[0] = baz.len();
//~^ ERROR: cannot call
//~| ERROR: cannot call
//~| ERROR: the trait bound
//FIXME ~^ ERROR: cannot call
//FIXME ~| ERROR: cannot call
//FIXME ~| ERROR: the trait bound
}
}

Expand Down
22 changes: 4 additions & 18 deletions tests/ui/consts/issue-94675.stderr
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
error[E0015]: cannot call non-const fn `Vec::<u32>::len` in constant functions
--> $DIR/issue-94675.rs:9:27
--> $DIR/issue-94675.rs:11:27
|
LL | self.bar[0] = baz.len();
| ^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants

error[E0277]: the trait bound `Vec<usize>: ~const IndexMut<usize>` is not satisfied
--> $DIR/issue-94675.rs:9:9
|
LL | self.bar[0] = baz.len();
| ^^^^^^^^^^^ vector indices are of type `usize` or ranges of `usize`
|
= help: the trait `~const IndexMut<usize>` is not implemented for `Vec<usize>`
note: the trait `IndexMut<usize>` is implemented for `Vec<usize>`, but that implementation is not `const`
--> $DIR/issue-94675.rs:9:9
|
LL | self.bar[0] = baz.len();
| ^^^^^^^^^^^

error[E0015]: cannot call non-const operator in constant functions
--> $DIR/issue-94675.rs:9:9
--> $DIR/issue-94675.rs:11:9
|
LL | self.bar[0] = baz.len();
| ^^^^^^^^^^^
Expand All @@ -29,7 +16,6 @@ note: impl defined here, but it is not `const`
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants

error: aborting due to 3 previous errors
error: aborting due to 2 previous errors

Some errors have detailed explanations: E0015, E0277.
For more information about an error, try `rustc --explain E0015`.
For more information about this error, try `rustc --explain E0015`.
8 changes: 7 additions & 1 deletion tests/ui/consts/precise-drop-with-promoted.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// Regression test for issue #89938.
// check-pass
// compile-flags: --crate-type=lib
// known-bug: #103507
// failure-status: 101
// normalize-stderr-test "note: .*\n\n" -> ""
// normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
// normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "
// rustc-env:RUST_BACKTRACE=0

#![feature(const_precise_live_drops)]

pub const fn f() {
Expand Down
6 changes: 6 additions & 0 deletions tests/ui/consts/precise-drop-with-promoted.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
error: the compiler unexpectedly panicked. this is a bug.

query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `f`
#1 [analysis] running analysis passes on this crate
end of query stack
Loading

0 comments on commit 2d59451

Please sign in to comment.