Skip to content
Open
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
3 changes: 3 additions & 0 deletions compiler/rustc_hir_analysis/src/hir_wf_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ pub(super) fn diagnostic_hir_wf_check<'tcx>(
vec![]
}
}
// Synthetic nodes are created by query feeding for items like RPITIT
// opaque types that have no corresponding HIR type to walk.
hir::Node::Synthetic => vec![],
ref node => bug!("Unexpected node {:?}", node),
},
WellFormedLoc::Param { function: _, param_idx } => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Regression test for #148630 (simpler reproduction).

#![feature(unboxed_closures)]

trait Tr {}
trait Foo {
fn foo() -> impl Sized
//~^ ERROR expected a `FnOnce<&'a i32>` closure, found `()`
//~| ERROR expected a `FnOnce<&'a i32>` closure, found `()`
//~| ERROR expected a `FnOnce<&'a i32>` closure, found `()`
//~| ERROR expected a `FnOnce<&'a i32>` closure, found `()`
//~| ERROR expected a `FnOnce<&'a i32>` closure, found `()`
//~| ERROR expected a `FnOnce<&'a i32>` closure, found `()`
//~| ERROR expected a `FnOnce<&'a i32>` closure, found `()`
where
for<'a> <() as FnOnce<&'a i32>>::Output: Tr,
{
}
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
error[E0277]: expected a `FnOnce<&'a i32>` closure, found `()`
--> $DIR/unexpected-node-synthetic-2-issue-148630.rs:7:17
|
LL | fn foo() -> impl Sized
| ^^^^^^^^^^ expected an `FnOnce<&'a i32>` closure, found `()`
|
= help: the trait `for<'a> FnOnce<&'a i32>` is not implemented for `()`

error[E0277]: expected a `FnOnce<&'a i32>` closure, found `()`
--> $DIR/unexpected-node-synthetic-2-issue-148630.rs:7:17
|
LL | fn foo() -> impl Sized
| ^^^^^^^^^^ expected an `FnOnce<&'a i32>` closure, found `()`
|
= help: the trait `for<'a> FnOnce<&'a i32>` is not implemented for `()`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error[E0277]: expected a `FnOnce<&'a i32>` closure, found `()`
--> $DIR/unexpected-node-synthetic-2-issue-148630.rs:7:5
|
LL | / fn foo() -> impl Sized
... |
LL | | where
LL | | for<'a> <() as FnOnce<&'a i32>>::Output: Tr,
| |____________________________________________________^ expected an `FnOnce<&'a i32>` closure, found `()`
|
= help: the trait `for<'a> FnOnce<&'a i32>` is not implemented for `()`

error[E0277]: expected a `FnOnce<&'a i32>` closure, found `()`
--> $DIR/unexpected-node-synthetic-2-issue-148630.rs:7:17
|
LL | fn foo() -> impl Sized
| ^^^^^^^^^^ expected an `FnOnce<&'a i32>` closure, found `()`
|
= help: the trait `for<'a> FnOnce<&'a i32>` is not implemented for `()`

error[E0277]: expected a `FnOnce<&'a i32>` closure, found `()`
--> $DIR/unexpected-node-synthetic-2-issue-148630.rs:7:22
|
LL | fn foo() -> impl Sized
| ^^^^^ expected an `FnOnce<&'a i32>` closure, found `()`
|
= help: the trait `for<'a> FnOnce<&'a i32>` is not implemented for `()`

error[E0277]: expected a `FnOnce<&'a i32>` closure, found `()`
--> $DIR/unexpected-node-synthetic-2-issue-148630.rs:7:17
|
LL | fn foo() -> impl Sized
| ^^^^^^^^^^ expected an `FnOnce<&'a i32>` closure, found `()`
|
= help: the trait `for<'a> FnOnce<&'a i32>` is not implemented for `()`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error[E0277]: expected a `FnOnce<&'a i32>` closure, found `()`
--> $DIR/unexpected-node-synthetic-2-issue-148630.rs:7:17
|
LL | fn foo() -> impl Sized
| ^^^^^^^^^^ expected an `FnOnce<&'a i32>` closure, found `()`
|
= help: the trait `for<'a> FnOnce<&'a i32>` is not implemented for `()`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: aborting due to 7 previous errors

For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Regression test for #148630.

#![feature(unboxed_closures)]

use std::future::Future;

trait Foo {
fn foo() -> impl Sized
//~^ ERROR expected a `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
//~| ERROR expected a `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
//~| ERROR expected a `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
//~| ERROR expected a `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
//~| ERROR expected a `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
//~| ERROR expected a `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
//~| ERROR expected a `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
where
for<'a> <dyn Foo as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
//~^ ERROR the trait `Foo` is not dyn compatible [E0038]
{
}
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
--> $DIR/unexpected-node-synthetic-issue-148630.rs:8:17
|
LL | fn foo() -> impl Sized
| ^^^^^^^^^^ expected an `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
|
= help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `(dyn Foo + 'static)`

error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
--> $DIR/unexpected-node-synthetic-issue-148630.rs:8:17
|
LL | fn foo() -> impl Sized
| ^^^^^^^^^^ expected an `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
|
= help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `(dyn Foo + 'static)`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
--> $DIR/unexpected-node-synthetic-issue-148630.rs:8:5
|
LL | / fn foo() -> impl Sized
... |
LL | | where
LL | | for<'a> <dyn Foo as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
| |______________________________________________________________________________________^ expected an `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
|
= help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `(dyn Foo + 'static)`

error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
--> $DIR/unexpected-node-synthetic-issue-148630.rs:8:17
|
LL | fn foo() -> impl Sized
| ^^^^^^^^^^ expected an `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
|
= help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `(dyn Foo + 'static)`

error[E0038]: the trait `Foo` is not dyn compatible
--> $DIR/unexpected-node-synthetic-issue-148630.rs:17:84
|
LL | for<'a> <dyn Foo as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a,
| ^^ `Foo` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
--> $DIR/unexpected-node-synthetic-issue-148630.rs:8:8
|
LL | trait Foo {
| --- this trait is not dyn compatible...
LL | fn foo() -> impl Sized
| ^^^ ...because associated function `foo` has no `self` parameter
help: consider turning `foo` into a method by giving it a `&self` argument
|
LL | fn foo(&self) -> impl Sized
| +++++
help: alternatively, consider constraining `foo` so it does not apply to trait objects
|
LL | for<'a> <dyn Foo as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a, Self: Sized
| +++++++++++

error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
--> $DIR/unexpected-node-synthetic-issue-148630.rs:8:22
|
LL | fn foo() -> impl Sized
| ^^^^^ expected an `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
|
= help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `(dyn Foo + 'static)`

error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
--> $DIR/unexpected-node-synthetic-issue-148630.rs:8:17
|
LL | fn foo() -> impl Sized
| ^^^^^^^^^^ expected an `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
|
= help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `(dyn Foo + 'static)`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
--> $DIR/unexpected-node-synthetic-issue-148630.rs:8:17
|
LL | fn foo() -> impl Sized
| ^^^^^^^^^^ expected an `FnOnce(&'a mut i32)` closure, found `(dyn Foo + 'static)`
|
= help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `(dyn Foo + 'static)`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: aborting due to 8 previous errors

Some errors have detailed explanations: E0038, E0277.
For more information about an error, try `rustc --explain E0038`.
Loading