Skip to content

Add regression tests for pretty-printing inherent projections #111887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/ui/associated-inherent-types/issue-111879-0.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#![feature(inherent_associated_types)]
#![allow(incomplete_features)]

// Check that we don't crash when printing inherent projections in diagnostics.

pub struct Carrier<'a>(&'a ());

pub type User = for<'b> fn(Carrier<'b>::Focus<i32>);

impl<'a> Carrier<'a> {
pub type Focus<T> = &'a mut User; //~ ERROR overflow evaluating associated type
}

fn main() {}
8 changes: 8 additions & 0 deletions tests/ui/associated-inherent-types/issue-111879-0.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: overflow evaluating associated type `Carrier<'b>::Focus<i32>`
--> $DIR/issue-111879-0.rs:11:25
|
LL | pub type Focus<T> = &'a mut User;
| ^^^^^^^^^^^^

error: aborting due to previous error

12 changes: 12 additions & 0 deletions tests/ui/associated-inherent-types/issue-111879-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![feature(inherent_associated_types)]
#![allow(incomplete_features)]

// Check that we don't crash when printing inherent projections in diagnostics.

struct Foo<T>(T);

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

fn main(_: for<'a> fn(Foo<fn(&'a ())>::Assoc)) {} //~ ERROR `main` function has wrong type
12 changes: 12 additions & 0 deletions tests/ui/associated-inherent-types/issue-111879-1.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0580]: `main` function has wrong type
--> $DIR/issue-111879-1.rs:12:1
|
LL | fn main(_: for<'a> fn(Foo<fn(&'a ())>::Assoc)) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters
|
= note: expected fn pointer `fn()`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side-note, it would be nice if we got this to say "expected signature"... but the problem is that require_same_types takes (fn ptr) types instead of poly fn sigs. Whatever, I guess.

found fn pointer `fn(for<'a> fn(Foo<fn(&'a ())>::Assoc))`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0580`.