Skip to content

Commit e03780f

Browse files
authored
Rollup merge of #120056 - oli-obk:arg_mismatch_ice, r=compiler-errors
Use FnOnceOutput instead of FnOnce where expected fixes #119847
2 parents 42ccea6 + d6b99b9 commit e03780f

File tree

3 files changed

+100
-1
lines changed

3 files changed

+100
-1
lines changed

compiler/rustc_middle/src/ty/print/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
10131013
.extend(
10141014
// Group the return ty with its def id, if we had one.
10151015
entry.return_ty.map(|ty| {
1016-
(tcx.require_lang_item(LangItem::FnOnce, None), ty)
1016+
(tcx.require_lang_item(LangItem::FnOnceOutput, None), ty)
10171017
}),
10181018
);
10191019
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//! This is a regression test to avoid an ICE in diagnostics code.
2+
//! A typo in the compiler used to get the DefId of FnOnce, and
3+
//! use it where an associated item was expected.
4+
5+
fn frob() -> impl Fn<P, Output = T> + '_ {}
6+
//~^ ERROR missing lifetime specifier
7+
//~| ERROR cannot find type `P`
8+
//~| ERROR cannot find type `T`
9+
//~| ERROR `Fn`-family traits' type parameters is subject to change
10+
11+
fn open_parent<'path>() {
12+
todo!()
13+
}
14+
15+
fn main() {
16+
let old_path = frob("hello");
17+
//~^ ERROR function takes 0 arguments
18+
19+
open_parent(&old_path)
20+
//~^ ERROR function takes 0 arguments
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
error[E0106]: missing lifetime specifier
2+
--> $DIR/opaque-used-in-extraneous-argument.rs:5:39
3+
|
4+
LL | fn frob() -> impl Fn<P, Output = T> + '_ {}
5+
| ^^ expected named lifetime parameter
6+
|
7+
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
8+
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`, or if you will only have owned values
9+
|
10+
LL | fn frob() -> impl Fn<P, Output = T> + 'static {}
11+
| ~~~~~~~
12+
13+
error[E0412]: cannot find type `P` in this scope
14+
--> $DIR/opaque-used-in-extraneous-argument.rs:5:22
15+
|
16+
LL | fn frob() -> impl Fn<P, Output = T> + '_ {}
17+
| ^ not found in this scope
18+
|
19+
help: you might be missing a type parameter
20+
|
21+
LL | fn frob<P>() -> impl Fn<P, Output = T> + '_ {}
22+
| +++
23+
24+
error[E0412]: cannot find type `T` in this scope
25+
--> $DIR/opaque-used-in-extraneous-argument.rs:5:34
26+
|
27+
LL | fn frob() -> impl Fn<P, Output = T> + '_ {}
28+
| ^ not found in this scope
29+
|
30+
help: you might be missing a type parameter
31+
|
32+
LL | fn frob<T>() -> impl Fn<P, Output = T> + '_ {}
33+
| +++
34+
35+
error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change
36+
--> $DIR/opaque-used-in-extraneous-argument.rs:5:19
37+
|
38+
LL | fn frob() -> impl Fn<P, Output = T> + '_ {}
39+
| ^^^^^^^^^^^^^^^^^ help: use parenthetical notation instead: `Fn(P) -> T`
40+
|
41+
= note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
42+
= help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
43+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
44+
45+
error[E0061]: this function takes 0 arguments but 1 argument was supplied
46+
--> $DIR/opaque-used-in-extraneous-argument.rs:16:20
47+
|
48+
LL | let old_path = frob("hello");
49+
| ^^^^ -------
50+
| |
51+
| unexpected argument of type `&'static str`
52+
| help: remove the extra argument
53+
|
54+
note: function defined here
55+
--> $DIR/opaque-used-in-extraneous-argument.rs:5:4
56+
|
57+
LL | fn frob() -> impl Fn<P, Output = T> + '_ {}
58+
| ^^^^
59+
60+
error[E0061]: this function takes 0 arguments but 1 argument was supplied
61+
--> $DIR/opaque-used-in-extraneous-argument.rs:19:5
62+
|
63+
LL | open_parent(&old_path)
64+
| ^^^^^^^^^^^ ---------
65+
| |
66+
| unexpected argument of type `&impl FnOnce<{type error}, Output = {type error}> + Fn<{type error}> + 'static`
67+
| help: remove the extra argument
68+
|
69+
note: function defined here
70+
--> $DIR/opaque-used-in-extraneous-argument.rs:11:4
71+
|
72+
LL | fn open_parent<'path>() {
73+
| ^^^^^^^^^^^
74+
75+
error: aborting due to 6 previous errors
76+
77+
Some errors have detailed explanations: E0061, E0106, E0412, E0658.
78+
For more information about an error, try `rustc --explain E0061`.

0 commit comments

Comments
 (0)