diff --git a/tests/ui/parallel-rustc/dyn-trait-ice-153366.rs b/tests/ui/parallel-rustc/dyn-trait-ice-153366.rs new file mode 100644 index 000000000000..9fd53f31a9f6 --- /dev/null +++ b/tests/ui/parallel-rustc/dyn-trait-ice-153366.rs @@ -0,0 +1,25 @@ +// Regression test for ICE from issue #153366. + +#![feature(unboxed_closures)] + +fn iso(a: Fn) -> Option<_> +//~^ ERROR missing generics for trait `Fn` +//~| ERROR the placeholder `_` is not allowed within types on item signatures for return types +//~| WARN trait objects without an explicit `dyn` are deprecated +//~| WARN this is accepted in the current edition +where + dyn Fn(A) -> (): Sized, +{ + Box::new(iso_un_option) + //~^ ERROR mismatched types +} +fn iso_un_option() -> Box<_> { +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types + iso(()) + //~^ ERROR the size for values of type `(dyn Fn(_) + 'static)` cannot be known at compilation +} + +fn main() { + iso(()) + //~^ ERROR the size for values of type `(dyn Fn(_) + 'static)` cannot be known at compilation +} diff --git a/tests/ui/parallel-rustc/dyn-trait-ice-153366.stderr b/tests/ui/parallel-rustc/dyn-trait-ice-153366.stderr new file mode 100644 index 000000000000..ba21ace81c7e --- /dev/null +++ b/tests/ui/parallel-rustc/dyn-trait-ice-153366.stderr @@ -0,0 +1,93 @@ +warning: trait objects without an explicit `dyn` are deprecated + --> $DIR/dyn-trait-ice-153366.rs:5:14 + | +LL | fn iso(a: Fn) -> Option<_> + | ^^ + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! + = note: for more information, see + = note: `#[warn(bare_trait_objects)]` (part of `#[warn(rust_2021_compatibility)]`) on by default +help: if this is a dyn-compatible trait, use `dyn` + | +LL | fn iso(a: dyn Fn) -> Option<_> + | +++ + +error[E0107]: missing generics for trait `Fn` + --> $DIR/dyn-trait-ice-153366.rs:5:14 + | +LL | fn iso(a: Fn) -> Option<_> + | ^^ expected 1 generic argument + | +help: add missing generic argument + | +LL | fn iso(a: Fn) -> Option<_> + | ++++++ + +error[E0277]: the size for values of type `(dyn Fn(_) + 'static)` cannot be known at compilation time + --> $DIR/dyn-trait-ice-153366.rs:18:5 + | +LL | iso(()) + | ^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Fn(_) + 'static)` +note: required by a bound in `iso` + --> $DIR/dyn-trait-ice-153366.rs:11:22 + | +LL | fn iso(a: Fn) -> Option<_> + | --- required by a bound in this function +... +LL | dyn Fn(A) -> (): Sized, + | ^^^^^ required by this bound in `iso` + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types + --> $DIR/dyn-trait-ice-153366.rs:16:30 + | +LL | fn iso_un_option() -> Box<_> { + | ^ not allowed in type signatures + +error[E0308]: mismatched types + --> $DIR/dyn-trait-ice-153366.rs:13:5 + | +LL | fn iso(a: Fn) -> Option<_> + | --------- expected `Option<_>` because of return type +... +LL | Box::new(iso_un_option) + | ^^^^^^^^^^^^^^^^^^^^^^^ expected `Option<_>`, found `Box ... {iso_un_option::<_>}>` + | + = note: expected enum `Option<_>` + found struct `Box {type error} {iso_un_option::<_>}>` +help: use parentheses to call this function + | +LL | Box::new(iso_un_option)() + | ++ +help: try wrapping the expression in `Some` + | +LL | Some(Box::new(iso_un_option)) + | +++++ + + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types + --> $DIR/dyn-trait-ice-153366.rs:5:28 + | +LL | fn iso(a: Fn) -> Option<_> + | ^ not allowed in type signatures + +error[E0277]: the size for values of type `(dyn Fn(_) + 'static)` cannot be known at compilation time + --> $DIR/dyn-trait-ice-153366.rs:23:5 + | +LL | iso(()) + | ^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Fn(_) + 'static)` +note: required by a bound in `iso` + --> $DIR/dyn-trait-ice-153366.rs:11:22 + | +LL | fn iso(a: Fn) -> Option<_> + | --- required by a bound in this function +... +LL | dyn Fn(A) -> (): Sized, + | ^^^^^ required by this bound in `iso` + +error: aborting due to 6 previous errors; 1 warning emitted + +Some errors have detailed explanations: E0107, E0121, E0277, E0308. +For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/parallel-rustc/fn-sig-cycle-ice-154560.rs b/tests/ui/parallel-rustc/fn-sig-cycle-ice-154560.rs new file mode 100644 index 000000000000..752d7b1dafe1 --- /dev/null +++ b/tests/ui/parallel-rustc/fn-sig-cycle-ice-154560.rs @@ -0,0 +1,14 @@ +// Regression test for ICE from issue #154056. + +//@ ignore-parallel-frontend query cycle + ICE + +#![feature(min_generic_const_args)] +#![feature(return_type_notation)] + +trait IntFactory { + fn stream(&self) -> impl IntFactory; + //~^ ERROR cycle detected when resolving lifetimes for `IntFactory::stream` +} +trait SendIntFactory: IntFactory + Send {} + +fn main() {} diff --git a/tests/ui/parallel-rustc/fn-sig-cycle-ice-154560.stderr b/tests/ui/parallel-rustc/fn-sig-cycle-ice-154560.stderr new file mode 100644 index 000000000000..43f39eca38d9 --- /dev/null +++ b/tests/ui/parallel-rustc/fn-sig-cycle-ice-154560.stderr @@ -0,0 +1,19 @@ +error[E0391]: cycle detected when resolving lifetimes for `IntFactory::stream` + --> $DIR/fn-sig-cycle-ice-154560.rs:9:5 + | +LL | fn stream(&self) -> impl IntFactory; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: ...which requires computing function signature of `IntFactory::stream`... + = note: ...which requires looking up late bound vars inside `IntFactory::stream`... + = note: ...which again requires resolving lifetimes for `IntFactory::stream`, completing the cycle +note: cycle used when listing captured lifetimes for opaque `IntFactory::stream::{opaque#0}` + --> $DIR/fn-sig-cycle-ice-154560.rs:9:25 + | +LL | fn stream(&self) -> impl IntFactory; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: for more information, see and + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/parallel-rustc/variances-cycle-ice-154560.rs b/tests/ui/parallel-rustc/variances-cycle-ice-154560.rs new file mode 100644 index 000000000000..2f0690ab4373 --- /dev/null +++ b/tests/ui/parallel-rustc/variances-cycle-ice-154560.rs @@ -0,0 +1,16 @@ +// Regression test for ICE from issue #154560. +//~^ ERROR cycle detected when computing the variances for items in this crate + +//@ ignore-parallel-frontend query cycle + ICE + +pub struct T<'a>(&'a str); + +pub fn f() -> _ { + T +} + +pub fn g<'a>(val: T<'a>) -> _ { + T +} + +fn main() {} diff --git a/tests/ui/parallel-rustc/variances-cycle-ice-154560.stderr b/tests/ui/parallel-rustc/variances-cycle-ice-154560.stderr new file mode 100644 index 000000000000..6cfdadf5c5d5 --- /dev/null +++ b/tests/ui/parallel-rustc/variances-cycle-ice-154560.stderr @@ -0,0 +1,24 @@ +error[E0391]: cycle detected when computing the variances for items in this crate + | +note: ...which requires computing function signature of `f`... + --> $DIR/variances-cycle-ice-154560.rs:8:1 + | +LL | pub fn f() -> _ { + | ^^^^^^^^^^^^^^^^^^ + = note: ...which requires type-checking `f`... +note: ...which requires computing the variances of `T`... + --> $DIR/variances-cycle-ice-154560.rs:6:1 + | +LL | pub struct T<'a>(&'a str); + | ^^^^^^^^^^^^^^^^ + = note: ...which again requires computing the variances for items in this crate, completing the cycle +note: cycle used when computing the variances of `T` + --> $DIR/variances-cycle-ice-154560.rs:6:1 + | +LL | pub struct T<'a>(&'a str); + | ^^^^^^^^^^^^^^^^ + = note: for more information, see and + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0391`.