From 3919b71b4879396791ba3d54c6e77e780a9fe9c6 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 2 Jan 2023 11:47:36 +0100 Subject: [PATCH 1/6] Fix rustdoc ICE on bad typedef with mismatching types --- src/librustdoc/clean/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 8f4099653562e..3253c3ae87c72 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1853,7 +1853,7 @@ pub(crate) fn clean_middle_ty<'tcx>( ty::Placeholder(..) => panic!("Placeholder"), ty::GeneratorWitness(..) => panic!("GeneratorWitness"), ty::Infer(..) => panic!("Infer"), - ty::Error(_) => panic!("Error"), + ty::Error(_) => rustc_errors::FatalError.raise(), } } From e8853563df4d9b736fa063d5669c7295c3c27d36 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 2 Jan 2023 11:47:56 +0100 Subject: [PATCH 2/6] Add regression test for #106226 --- src/test/rustdoc-ui/issue-106226.rs | 3 +++ src/test/rustdoc-ui/issue-106226.stderr | 9 +++++++++ 2 files changed, 12 insertions(+) create mode 100644 src/test/rustdoc-ui/issue-106226.rs create mode 100644 src/test/rustdoc-ui/issue-106226.stderr diff --git a/src/test/rustdoc-ui/issue-106226.rs b/src/test/rustdoc-ui/issue-106226.rs new file mode 100644 index 0000000000000..71b497a9adc73 --- /dev/null +++ b/src/test/rustdoc-ui/issue-106226.rs @@ -0,0 +1,3 @@ +// This is a regression test for . +type F = [_; ()]; +//~^ ERROR diff --git a/src/test/rustdoc-ui/issue-106226.stderr b/src/test/rustdoc-ui/issue-106226.stderr new file mode 100644 index 0000000000000..2beffbc125bd4 --- /dev/null +++ b/src/test/rustdoc-ui/issue-106226.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/issue-106226.rs:2:14 + | +LL | type F = [_; ()]; + | ^^ expected `usize`, found `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. From ed3c3d3ddd9c505b446c2f2bdf245e97683bb4cf Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 2 Jan 2023 14:29:02 +0100 Subject: [PATCH 3/6] Add regression test for #105334 --- src/test/rustdoc-ui/issue-105334.rs | 2 ++ src/test/rustdoc-ui/issue-105334.stderr | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 src/test/rustdoc-ui/issue-105334.rs create mode 100644 src/test/rustdoc-ui/issue-105334.stderr diff --git a/src/test/rustdoc-ui/issue-105334.rs b/src/test/rustdoc-ui/issue-105334.rs new file mode 100644 index 0000000000000..ee1adc6a02914 --- /dev/null +++ b/src/test/rustdoc-ui/issue-105334.rs @@ -0,0 +1,2 @@ +impl Vec< br##"*.."## > {} +//~^ ERROR diff --git a/src/test/rustdoc-ui/issue-105334.stderr b/src/test/rustdoc-ui/issue-105334.stderr new file mode 100644 index 0000000000000..e163bb4db9ee6 --- /dev/null +++ b/src/test/rustdoc-ui/issue-105334.stderr @@ -0,0 +1,9 @@ +error[E0747]: constant provided when a type was expected + --> $DIR/issue-105334.rs:1:11 + | +LL | impl Vec< br##"*.."## > {} + | ^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0747`. From 1a9432255eac349e4349f323123f3b49234d4f6b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 2 Jan 2023 14:29:22 +0100 Subject: [PATCH 4/6] Add regression test for #105737 --- src/test/rustdoc-ui/issue-105737.rs | 4 ++++ src/test/rustdoc-ui/issue-105737.stderr | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/test/rustdoc-ui/issue-105737.rs create mode 100644 src/test/rustdoc-ui/issue-105737.stderr diff --git a/src/test/rustdoc-ui/issue-105737.rs b/src/test/rustdoc-ui/issue-105737.rs new file mode 100644 index 0000000000000..154f069d8ffac --- /dev/null +++ b/src/test/rustdoc-ui/issue-105737.rs @@ -0,0 +1,4 @@ +impl Vec {} +//~^ ERROR + +pub fn lol() {} diff --git a/src/test/rustdoc-ui/issue-105737.stderr b/src/test/rustdoc-ui/issue-105737.stderr new file mode 100644 index 0000000000000..2dd9beb17da9b --- /dev/null +++ b/src/test/rustdoc-ui/issue-105737.stderr @@ -0,0 +1,12 @@ +error[E0747]: constant provided when a type was expected + --> $DIR/issue-105737.rs:1:10 + | +LL | impl Vec {} + | ^^^ + | + = help: `lol` is a function item, not a type + = help: function item types cannot be named directly + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0747`. From a167435b76c1070fa0290e27f7756c9bb5b6548b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 2 Jan 2023 14:29:38 +0100 Subject: [PATCH 5/6] Add regression test for #105742 --- src/test/rustdoc-ui/issue-105742.rs | 40 +++ src/test/rustdoc-ui/issue-105742.stderr | 385 ++++++++++++++++++++++++ 2 files changed, 425 insertions(+) create mode 100644 src/test/rustdoc-ui/issue-105742.rs create mode 100644 src/test/rustdoc-ui/issue-105742.stderr diff --git a/src/test/rustdoc-ui/issue-105742.rs b/src/test/rustdoc-ui/issue-105742.rs new file mode 100644 index 0000000000000..cb1de7433cfaa --- /dev/null +++ b/src/test/rustdoc-ui/issue-105742.rs @@ -0,0 +1,40 @@ +// compile-flags: -Znormalize-docs + +use std::ops::Index; + +pub fn next<'a, T>(s: &'a mut dyn SVec) { +//~^ ERROR +//~^^ ERROR +//~^^^ ERROR + let _ = s; +} + +pub trait SVec: Index< + ::Item, +//~^ ERROR +//~^^ ERROR +//~^^^ ERROR +//~^^^^ ERROR + Output = ::Item, +//~^ ERROR +//~^^ ERROR +//~^^^ ERROR +//~^^^^ ERROR + Output = ::Item> as SVec>::Item, +//~^ ERROR +//~^^ ERROR +//~^^^ ERROR +//~^^^^ ERROR +//~^^^^^ ERROR +//~^^^^^^ ERROR +//~^^^^^^^ ERROR +//~^^^^^^^^ ERROR +> { + type Item<'a, T>; + + fn len(&self) -> ::Item; + //~^ ERROR + //~^^ ERROR + //~^^^ ERROR + //~^^^^ ERROR +} diff --git a/src/test/rustdoc-ui/issue-105742.stderr b/src/test/rustdoc-ui/issue-105742.stderr new file mode 100644 index 0000000000000..cc101b7ff3757 --- /dev/null +++ b/src/test/rustdoc-ui/issue-105742.stderr @@ -0,0 +1,385 @@ +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:13:21 + | +LL | ::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | ::Item<'a>, + | ~~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:13:21 + | +LL | ::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | ::Item, + | ~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:18:37 + | +LL | Output = ::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | Output = ::Item<'a>, + | ~~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:18:37 + | +LL | Output = ::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | Output = ::Item, + | ~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:23:30 + | +LL | Output = ::Item> as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | Output = ::Item<'a>> as SVec>::Item, + | ~~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:23:30 + | +LL | Output = ::Item> as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | Output = ::Item> as SVec>::Item, + | ~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:23:46 + | +LL | Output = ::Item> as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | Output = ::Item> as SVec>::Item<'a>, + | ~~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:23:46 + | +LL | Output = ::Item> as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | Output = ::Item> as SVec>::Item, + | ~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:5:40 + | +LL | pub fn next<'a, T>(s: &'a mut dyn SVec) { + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | pub fn next<'a, T>(s: &'a mut dyn SVec = T, Output = T>) { + | ~~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:5:40 + | +LL | pub fn next<'a, T>(s: &'a mut dyn SVec) { + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | pub fn next<'a, T>(s: &'a mut dyn SVec = T, Output = T>) { + | ~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:13:21 + | +LL | ::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | ::Item<'a>, + | ~~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:13:21 + | +LL | ::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | ::Item, + | ~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:18:37 + | +LL | Output = ::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | Output = ::Item<'a>, + | ~~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:18:37 + | +LL | Output = ::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | Output = ::Item, + | ~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:23:30 + | +LL | Output = ::Item> as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | Output = ::Item<'a>> as SVec>::Item, + | ~~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:23:30 + | +LL | Output = ::Item> as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | Output = ::Item> as SVec>::Item, + | ~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:23:46 + | +LL | Output = ::Item> as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | Output = ::Item> as SVec>::Item<'a>, + | ~~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:23:46 + | +LL | Output = ::Item> as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | Output = ::Item> as SVec>::Item, + | ~~~~~~~ + +error[E0038]: the trait `SVec` cannot be made into an object + --> $DIR/issue-105742.rs:5:31 + | +LL | pub fn next<'a, T>(s: &'a mut dyn SVec) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SVec` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit + --> $DIR/issue-105742.rs:12:17 + | +LL | pub trait SVec: Index< + | ____________----__^ + | | | + | | this trait cannot be made into an object... +LL | | ::Item, +LL | | +LL | | +... | +LL | |/ Output = ::Item, +LL | || +LL | || +LL | || +LL | || +LL | || Output = ::Item> as SVec>::Item, + | ||_________________________________________________^ ...because it uses `Self` as a type parameter +... | +LL | | +LL | | > { + | |__^ ...because it uses `Self` as a type parameter + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:35:38 + | +LL | fn len(&self) -> ::Item; + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | fn len(&self) -> ::Item<'_>; + | ~~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:35:38 + | +LL | fn len(&self) -> ::Item; + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | fn len(&self) -> ::Item; + | ~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:35:38 + | +LL | fn len(&self) -> ::Item; + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ -- +help: add missing lifetime argument + | +LL | fn len(&self) -> ::Item<'_>; + | ~~~~~~~~ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:35:38 + | +LL | fn len(&self) -> ::Item; + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:33:10 + | +LL | type Item<'a, T>; + | ^^^^ - +help: add missing generic argument + | +LL | fn len(&self) -> ::Item; + | ~~~~~~~ + +error: aborting due to 23 previous errors + +Some errors have detailed explanations: E0038, E0107. +For more information about an error, try `rustc --explain E0038`. From c1567730c0ea07e41fcabd14332ad701857d9f93 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 2 Jan 2023 14:29:56 +0100 Subject: [PATCH 6/6] Add regression test for #96287 --- src/test/rustdoc-ui/issue-96287.rs | 17 +++++++++++++++++ src/test/rustdoc-ui/issue-96287.stderr | 15 +++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/test/rustdoc-ui/issue-96287.rs create mode 100644 src/test/rustdoc-ui/issue-96287.stderr diff --git a/src/test/rustdoc-ui/issue-96287.rs b/src/test/rustdoc-ui/issue-96287.rs new file mode 100644 index 0000000000000..8d8b4456e6335 --- /dev/null +++ b/src/test/rustdoc-ui/issue-96287.rs @@ -0,0 +1,17 @@ +#![feature(type_alias_impl_trait)] + +pub trait TraitWithAssoc { + type Assoc; +} + +pub type Foo = impl Trait; +//~^ ERROR +//~^^ ERROR + +pub trait Trait {} + +impl Trait for () {} + +pub fn foo_desugared(_: T) -> Foo { + () +} diff --git a/src/test/rustdoc-ui/issue-96287.stderr b/src/test/rustdoc-ui/issue-96287.stderr new file mode 100644 index 0000000000000..0236b9fe64775 --- /dev/null +++ b/src/test/rustdoc-ui/issue-96287.stderr @@ -0,0 +1,15 @@ +error[E0220]: associated type `Assoc` not found for `V` + --> $DIR/issue-96287.rs:7:33 + | +LL | pub type Foo = impl Trait; + | ^^^^^ there is a similarly named associated type `Assoc` in the trait `TraitWithAssoc` + +error[E0220]: associated type `Assoc` not found for `V` + --> $DIR/issue-96287.rs:7:33 + | +LL | pub type Foo = impl Trait; + | ^^^^^ there is a similarly named associated type `Assoc` in the trait `TraitWithAssoc` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0220`.