Skip to content

Commit 3cb1f33

Browse files
committed
Fix circular fn_sig queries to return the correct number of arguments for methods
1 parent 28e8f01 commit 3cb1f33

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

Diff for: compiler/rustc_middle/src/values.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl<'tcx> Value<TyCtxt<'tcx>> for ty::Binder<'_, ty::FnSig<'_>> {
5656
&& let Some(node) = tcx.hir().get_if_local(def_id)
5757
&& let Some(sig) = node.fn_sig()
5858
{
59-
sig.decl.inputs.len() + sig.decl.implicit_self.has_implicit_self() as usize
59+
sig.decl.inputs.len()
6060
} else {
6161
tcx.dcx().abort_if_errors();
6262
unreachable!()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
trait Bar {
2+
fn foo(&mut self) -> _ {
3+
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
4+
Self::foo() //~ ERROR this function takes 1 argument but 0 arguments were supplied
5+
}
6+
}
7+
8+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error[E0061]: this function takes 1 argument but 0 arguments were supplied
2+
--> $DIR/mismatch-args-crash-issue-130400.rs:4:9
3+
|
4+
LL | Self::foo()
5+
| ^^^^^^^^^-- argument #1 is missing
6+
|
7+
note: method defined here
8+
--> $DIR/mismatch-args-crash-issue-130400.rs:2:8
9+
|
10+
LL | fn foo(&mut self) -> _ {
11+
| ^^^ ---------
12+
help: provide the argument
13+
|
14+
LL | Self::foo(/* value */)
15+
| ~~~~~~~~~~~~~
16+
17+
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
18+
--> $DIR/mismatch-args-crash-issue-130400.rs:2:26
19+
|
20+
LL | fn foo(&mut self) -> _ {
21+
| ^ not allowed in type signatures
22+
23+
error: aborting due to 2 previous errors
24+
25+
Some errors have detailed explanations: E0061, E0121.
26+
For more information about an error, try `rustc --explain E0061`.

0 commit comments

Comments
 (0)