From 4a63b07d24082c86cedb30b0ad5fcc2fc6b45fb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Le=C3=B3n=20Orell=20Valerian=20Liehr?= Date: Tue, 23 May 2023 23:49:45 +0200 Subject: [PATCH] Add tests for pretty-printing inherent projections --- .../ui/associated-inherent-types/issue-111879-0.rs | 14 ++++++++++++++ .../issue-111879-0.stderr | 8 ++++++++ .../ui/associated-inherent-types/issue-111879-1.rs | 12 ++++++++++++ .../issue-111879-1.stderr | 12 ++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 tests/ui/associated-inherent-types/issue-111879-0.rs create mode 100644 tests/ui/associated-inherent-types/issue-111879-0.stderr create mode 100644 tests/ui/associated-inherent-types/issue-111879-1.rs create mode 100644 tests/ui/associated-inherent-types/issue-111879-1.stderr diff --git a/tests/ui/associated-inherent-types/issue-111879-0.rs b/tests/ui/associated-inherent-types/issue-111879-0.rs new file mode 100644 index 0000000000000..e37f7d34ab5b8 --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-111879-0.rs @@ -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); + +impl<'a> Carrier<'a> { + pub type Focus = &'a mut User; //~ ERROR overflow evaluating associated type +} + +fn main() {} diff --git a/tests/ui/associated-inherent-types/issue-111879-0.stderr b/tests/ui/associated-inherent-types/issue-111879-0.stderr new file mode 100644 index 0000000000000..7bdbad4401762 --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-111879-0.stderr @@ -0,0 +1,8 @@ +error: overflow evaluating associated type `Carrier<'b>::Focus` + --> $DIR/issue-111879-0.rs:11:25 + | +LL | pub type Focus = &'a mut User; + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/associated-inherent-types/issue-111879-1.rs b/tests/ui/associated-inherent-types/issue-111879-1.rs new file mode 100644 index 0000000000000..7acc4f945051e --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-111879-1.rs @@ -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); + +impl<'a> Foo { + type Assoc = &'a (); +} + +fn main(_: for<'a> fn(Foo::Assoc)) {} //~ ERROR `main` function has wrong type diff --git a/tests/ui/associated-inherent-types/issue-111879-1.stderr b/tests/ui/associated-inherent-types/issue-111879-1.stderr new file mode 100644 index 0000000000000..689b45e09aaac --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-111879-1.stderr @@ -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::Assoc)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters + | + = note: expected fn pointer `fn()` + found fn pointer `fn(for<'a> fn(Foo::Assoc))` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0580`.