Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed Sep 22, 2023
1 parent da11957 commit e26db41
Show file tree
Hide file tree
Showing 16 changed files with 307 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,42 +1,32 @@
error[E0391]: cycle detected when computing predicates of `Foo`
error[E0391]: cycle detected when computing the inferred outlives predicates for items in this crate
|
note: ...which requires computing type of `Foo::bar`...
--> $DIR/cycle-iat-inside-of-adt.rs:8:5
|
LL | bar: Self::Bar,
| ^^^^^^^^^^^^^^
note: ...which requires computing normalized predicates of `Foo`...
--> $DIR/cycle-iat-inside-of-adt.rs:7:1
|
LL | struct Foo {
| ^^^^^^^^^^
|
note: ...which requires computing predicates of `Foo`...
--> $DIR/cycle-iat-inside-of-adt.rs:7:1
|
LL | struct Foo {
| ^^^^^^^^^^
note: ...which requires computing inferred outlives predicates of `Foo`...
note: ...which requires computing predicates of `Foo`...
--> $DIR/cycle-iat-inside-of-adt.rs:7:1
|
LL | struct Foo {
| ^^^^^^^^^^
= note: ...which requires computing the inferred outlives predicates for items in this crate...
note: ...which requires computing type of `Foo::bar`...
--> $DIR/cycle-iat-inside-of-adt.rs:8:5
|
LL | bar: Self::Bar,
| ^^^^^^^^^^^^^^
note: ...which requires computing normalized predicates of `Foo`...
note: ...which requires computing inferred outlives predicates of `Foo`...
--> $DIR/cycle-iat-inside-of-adt.rs:7:1
|
LL | struct Foo {
| ^^^^^^^^^^
= note: ...which again requires computing predicates of `Foo`, completing the cycle
note: cycle used when collecting item types in top-level module
--> $DIR/cycle-iat-inside-of-adt.rs:3:1
|
LL | / #![feature(inherent_associated_types)]
LL | | #![allow(incomplete_features)]
LL | | // FIXME(inherent_associated_types): This should pass.
LL | |
... |
LL | |
LL | | fn main() {}
| |____________^
= note: ...which again requires computing the inferred outlives predicates for items in this crate, completing the cycle
= note: cycle used when running analysis passes on this crate
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error: aborting due to previous error
Expand Down
11 changes: 11 additions & 0 deletions tests/ui/const-generics/issues/issue-83765.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
trait TensorDimension {
const DIM: usize;
//~^ ERROR cycle detected when resolving instance
//~| ERROR cycle detected when resolving instance
// FIXME Given the current state of the compiler its expected that we cycle here,
// but the cycle is still wrong.
const ISSCALAR: bool = Self::DIM == 0;
Expand Down Expand Up @@ -57,10 +58,14 @@ impl<'a, T: Broadcastable, const DIM: usize> Broadcastable for LazyUpdim<'a, T,
fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> {
assert!(DIM >= T::DIM);
if !self.inbounds(index) {
//~^ ERROR unconstrained generic constant
//~| ERROR mismatched types
return None;
}
let size = self.size();
//~^ ERROR unconstrained generic constant
let newindex: [usize; T::DIM] = Default::default();
//~^ ERROR the trait bound `[usize; T::DIM]: Default` is not satisfied [E0277]
self.reference.bget(newindex)
}
}
Expand All @@ -79,7 +84,10 @@ impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> TensorSi
for BMap<'a, R, T, F, DIM>
{
fn size(&self) -> [usize; DIM] {
//~^ ERROR method not compatible with trait
self.reference.size()
//~^ ERROR unconstrained generic constant
//~| ERROR mismatched types
}
}

Expand All @@ -88,7 +96,10 @@ impl<'a, R, T: Broadcastable, F: Fn(T::Element) -> R, const DIM: usize> Broadcas
{
type Element = R;
fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> {
//~^ ERROR method not compatible with trait
self.reference.bget(index).map(&self.closure)
//~^ ERROR unconstrained generic constant
//~| ERROR mismatched types
}
}

Expand Down
138 changes: 136 additions & 2 deletions tests/ui/const-generics/issues/issue-83765.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,140 @@ LL | trait TensorDimension {
| ^^^^^^^^^^^^^^^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error: aborting due to previous error
error[E0391]: cycle detected when resolving instance `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>::DIM`
--> $DIR/issue-83765.rs:5:5
|
LL | const DIM: usize;
| ^^^^^^^^^^^^^^^^
|
note: ...which requires computing candidate for `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>`...
--> $DIR/issue-83765.rs:4:1
|
LL | trait TensorDimension {
| ^^^^^^^^^^^^^^^^^^^^^
= note: ...which again requires resolving instance `<LazyUpdim<'_, T, <T as TensorDimension>::DIM, DIM> as TensorDimension>::DIM`, completing the cycle
note: cycle used when checking item types in top-level module
--> $DIR/issue-83765.rs:1:1
|
LL | / #![feature(generic_const_exprs)]
LL | | #![allow(incomplete_features)]
LL | |
LL | | trait TensorDimension {
... |
LL | | println!("The size of v is {:?}", bbv.bget([0, 2]).expect("Out of bounds."));
LL | | }
| |_^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error[E0308]: method not compatible with trait
--> $DIR/issue-83765.rs:86:5
|
LL | fn size(&self) -> [usize; DIM] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM`
|
= note: expected constant `Self::DIM`
found constant `DIM`

error[E0308]: method not compatible with trait
--> $DIR/issue-83765.rs:98:5
|
LL | fn bget(&self, index: [usize; DIM]) -> Option<Self::Element> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM`
|
= note: expected constant `Self::DIM`
found constant `DIM`

error: unconstrained generic constant
--> $DIR/issue-83765.rs:60:13
|
LL | if !self.inbounds(index) {
| ^^^^
|
= help: try adding a `where` bound using this expression: `where [(); Self::DIM]:`
note: required by a bound in `TensorSize::inbounds`
--> $DIR/issue-83765.rs:18:39
|
LL | fn inbounds(&self, index: [usize; Self::DIM]) -> bool {
| ^^^^^^^^^ required by this bound in `TensorSize::inbounds`

error[E0308]: mismatched types
--> $DIR/issue-83765.rs:60:27
|
LL | if !self.inbounds(index) {
| ^^^^^ expected `Self::DIM`, found `DIM`
|
= note: expected constant `Self::DIM`
found constant `DIM`

error: unconstrained generic constant
--> $DIR/issue-83765.rs:65:25
|
LL | let size = self.size();
| ^^^^
|
= help: try adding a `where` bound using this expression: `where [(); Self::DIM]:`
note: required by a bound in `TensorSize::size`
--> $DIR/issue-83765.rs:17:31
|
LL | fn size(&self) -> [usize; Self::DIM];
| ^^^^^^^^^ required by this bound in `TensorSize::size`

error[E0277]: the trait bound `[usize; T::DIM]: Default` is not satisfied
--> $DIR/issue-83765.rs:67:41
|
LL | let newindex: [usize; T::DIM] = Default::default();
| ^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[usize; T::DIM]`
|
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | impl<'a, T: Broadcastable, const DIM: usize> Broadcastable for LazyUpdim<'a, T, { T::DIM }, DIM> where [usize; T::DIM]: Default {
| ++++++++++++++++++++++++++++++

error: unconstrained generic constant
--> $DIR/issue-83765.rs:88:24
|
LL | self.reference.size()
| ^^^^
|
= help: try adding a `where` bound using this expression: `where [(); Self::DIM]:`
note: required by a bound in `TensorSize::size`
--> $DIR/issue-83765.rs:17:31
|
LL | fn size(&self) -> [usize; Self::DIM];
| ^^^^^^^^^ required by this bound in `TensorSize::size`

error[E0308]: mismatched types
--> $DIR/issue-83765.rs:88:9
|
LL | self.reference.size()
| ^^^^^^^^^^^^^^^^^^^^^ expected `DIM`, found `Self::DIM`
|
= note: expected constant `DIM`
found constant `Self::DIM`

error: unconstrained generic constant
--> $DIR/issue-83765.rs:100:9
|
LL | self.reference.bget(index).map(&self.closure)
| ^^^^^^^^^^^^^^
|
= help: try adding a `where` bound using this expression: `where [(); Self::DIM]:`
note: required by a bound in `Broadcastable::bget`
--> $DIR/issue-83765.rs:25:35
|
LL | fn bget(&self, index: [usize; Self::DIM]) -> Option<Self::Element>;
| ^^^^^^^^^ required by this bound in `Broadcastable::bget`

error[E0308]: mismatched types
--> $DIR/issue-83765.rs:100:29
|
LL | self.reference.bget(index).map(&self.closure)
| ^^^^^ expected `Self::DIM`, found `DIM`
|
= note: expected constant `Self::DIM`
found constant `DIM`

error: aborting due to 12 previous errors

For more information about this error, try `rustc --explain E0391`.
Some errors have detailed explanations: E0277, E0308, E0391.
For more information about an error, try `rustc --explain E0277`.
2 changes: 1 addition & 1 deletion tests/ui/impl-trait/issues/issue-86800.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// edition:2021
// compile-flags:-Z treat-err-as-bug=1
// error-pattern: aborting due to `-Z treat-err-as-bug=1`
// failure-status:101
// failure-status:1
// normalize-stderr-test ".*note: .*\n\n" -> ""
// normalize-stderr-test "thread 'rustc' panicked.*:\n.*\n" -> ""
// rustc-env:RUST_BACKTRACE=0
Expand Down
16 changes: 16 additions & 0 deletions tests/ui/impl-trait/issues/issue-86800.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,19 @@ query stack during panic:
#0 [type_of_opaque] computing type of opaque `TransactionFuture::{opaque#0}`
#1 [type_of] computing type of `TransactionFuture::{opaque#0}`
end of query stack
error[E0792]: expected generic lifetime parameter, found `'_`
--> $DIR/issue-86800.rs:39:5
|
LL | type TransactionFuture<'__, O> = impl '__ + Future<Output = TransactionResult<O>>;
| --- this generic parameter must be used with a generic lifetime parameter
...
LL | f
| ^


error: the compiler unexpectedly panicked. this is a bug.

query stack during panic:
#0 [mir_borrowck] borrow-checking `execute_transaction_fut`
#1 [type_of_opaque] computing type of opaque `execute_transaction_fut::{opaque#0}`
end of query stack
2 changes: 2 additions & 0 deletions tests/ui/lang-items/lang-item-generic-requirements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ trait MyIndex<'a, T> {}
#[lang = "phantom_data"]
//~^ ERROR `phantom_data` language item must be applied to a struct with 1 generic argument
struct MyPhantomData<T, U>;
//~^ ERROR parameter `T` is never used
//~| ERROR parameter `U` is never used

#[lang = "owned_box"]
//~^ ERROR `owned_box` language item must be applied to a struct with at least 1 generic argument
Expand Down
27 changes: 23 additions & 4 deletions tests/ui/lang-items/lang-item-generic-requirements.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ LL | struct MyPhantomData<T, U>;
| ------ this struct has 2 generic arguments

error[E0718]: `owned_box` language item must be applied to a struct with at least 1 generic argument
--> $DIR/lang-item-generic-requirements.rs:26:1
--> $DIR/lang-item-generic-requirements.rs:28:1
|
LL | #[lang = "owned_box"]
| ^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -42,14 +42,33 @@ LL | struct Foo;
| - this struct has 0 generic arguments

error[E0718]: `start` language item must be applied to a function with 1 generic argument
--> $DIR/lang-item-generic-requirements.rs:32:1
--> $DIR/lang-item-generic-requirements.rs:34:1
|
LL | #[lang = "start"]
| ^^^^^^^^^^^^^^^^^
LL |
LL | fn start(_: *const u8, _: isize, _: *const *const u8) -> isize {
| - this function has 0 generic arguments

error: aborting due to 6 previous errors
error[E0392]: parameter `T` is never used
--> $DIR/lang-item-generic-requirements.rs:24:22
|
LL | struct MyPhantomData<T, U>;
| ^ unused parameter
|
= help: consider removing `T` or referring to it in a field
= help: if you intended `T` to be a const parameter, use `const T: usize` instead

error[E0392]: parameter `U` is never used
--> $DIR/lang-item-generic-requirements.rs:24:25
|
LL | struct MyPhantomData<T, U>;
| ^ unused parameter
|
= help: consider removing `U` or referring to it in a field
= help: if you intended `U` to be a const parameter, use `const U: usize` instead

error: aborting due to 8 previous errors

For more information about this error, try `rustc --explain E0718`.
Some errors have detailed explanations: E0392, E0718.
For more information about an error, try `rustc --explain E0392`.
8 changes: 7 additions & 1 deletion tests/ui/panic-handler/panic-handler-std.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ LL | fn panic(info: PanicInfo) -> ! {
= note: first definition in `std` loaded from SYSROOT/libstd-*.rlib
= note: second definition in the local crate (`panic_handler_std`)

error: aborting due to previous error
error: argument should be `&PanicInfo`
--> $DIR/panic-handler-std.rs:8:16
|
LL | fn panic(info: PanicInfo) -> ! {
| ^^^^^^^^^

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0152`.
3 changes: 2 additions & 1 deletion tests/ui/span/issue-35987.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ struct Foo<T: Clone>(T);
use std::ops::Add;

impl<T: Clone, Add> Add for Foo<T> {
//~^ ERROR expected trait, found type parameter
//~^ ERROR expected trait, found type parameter
type Output = usize;

fn add(self, rhs: Self) -> Self::Output {
//~^ ERROR ambiguous associated type
unimplemented!();
}
}
Expand Down
11 changes: 9 additions & 2 deletions tests/ui/span/issue-35987.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ help: consider importing this trait instead
LL + use std::ops::Add;
|

error: aborting due to previous error
error[E0223]: ambiguous associated type
--> $DIR/issue-35987.rs:9:32
|
LL | fn add(self, rhs: Self) -> Self::Output {
| ^^^^^^^^^^^^ help: use the fully-qualified path: `<Foo<T> as IntoFuture>::Output`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0404`.
Some errors have detailed explanations: E0223, E0404.
For more information about an error, try `rustc --explain E0223`.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ impl<'a, T> Struct<T> for Trait<'a, T> {}

impl<'a, T> Enum<T> for Trait<'a, T> {}
//~^ ERROR expected trait, found enum `Enum`
//~| ERROR trait objects must include the `dyn` keyword

impl<'a, T> Union<T> for Trait<'a, T> {}
//~^ ERROR expected trait, found union `Union`
//~| ERROR trait objects must include the `dyn` keyword

fn main() {}
Loading

0 comments on commit e26db41

Please sign in to comment.