Skip to content

Commit

Permalink
IAT: Add a few regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fmease committed May 4, 2023
1 parent e8139df commit 46ec348
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/ui/associated-inherent-types/issue-109768.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// incremental

struct Wrapper<T>(T);

struct Local<T, U>(T, U);

impl<T> Local { //~ ERROR missing generics for struct `Local`
type AssocType3 = T; //~ ERROR inherent associated types are unstable

const WRAPPED_ASSOC_3: Wrapper<Self::AssocType3> = Wrapper();
}
//~^ ERROR `main` function not found
35 changes: 35 additions & 0 deletions tests/ui/associated-inherent-types/issue-109768.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
error[E0601]: `main` function not found in crate `issue_109768`
--> $DIR/issue-109768.rs:11:2
|
LL | }
| ^ consider adding a `main` function to `$DIR/issue-109768.rs`

error[E0107]: missing generics for struct `Local`
--> $DIR/issue-109768.rs:7:9
|
LL | impl<T> Local {
| ^^^^^ expected 2 generic arguments
|
note: struct defined here, with 2 generic parameters: `T`, `U`
--> $DIR/issue-109768.rs:5:8
|
LL | struct Local<T, U>(T, U);
| ^^^^^ - -
help: add missing generic arguments
|
LL | impl<T> Local<T, U> {
| ++++++

error[E0658]: inherent associated types are unstable
--> $DIR/issue-109768.rs:8:5
|
LL | type AssocType3 = T;
| ^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information
= help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0107, E0601, E0658.
For more information about an error, try `rustc --explain E0107`.
22 changes: 22 additions & 0 deletions tests/ui/associated-inherent-types/issue-109789.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#![feature(inherent_associated_types)]
#![allow(incomplete_features)]

struct Foo<T>(T);

impl Foo<fn(&'static ())> {
type Assoc = u32;
}

trait Other {}
impl Other for u32 {}

// FIXME(inherent_associated_types): Avoid emitting two diagnostics (they only differ in span).
// FIXME(inherent_associated_types): Enhancement: Spruce up the diagnostic by saying something like
// "implementation is not general enough" as is done for traits via
// `try_report_trait_placeholder_mismatch`.

fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {}
//~^ ERROR mismatched types
//~| ERROR mismatched types

fn main() {}
21 changes: 21 additions & 0 deletions tests/ui/associated-inherent-types/issue-109789.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error[E0308]: mismatched types
--> $DIR/issue-109789.rs:18:1
|
LL | fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected struct `Foo<fn(&'static ())>`
found struct `Foo<for<'a> fn(&'a ())>`

error[E0308]: mismatched types
--> $DIR/issue-109789.rs:18:11
|
LL | fn bar(_: Foo<for<'a> fn(&'a ())>::Assoc) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
= note: expected struct `Foo<fn(&'static ())>`
found struct `Foo<for<'a> fn(&'a ())>`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
17 changes: 17 additions & 0 deletions tests/ui/associated-inherent-types/issue-109790.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// check-pass

#![feature(inherent_associated_types)]
#![allow(incomplete_features)]

struct Foo<T>(T);

impl<'a> Foo<fn(&'a ())> {
type Assoc = &'a ();
}

trait Other {}
impl Other for u32 {}

fn bar(_: for<'a> fn(Foo<fn(&'a ())>::Assoc)) {}

fn main() {}

0 comments on commit 46ec348

Please sign in to comment.