Skip to content

Commit c66c6b7

Browse files
authored
Rollup merge of rust-lang#47844 - CAD97:patch-1, r=estebank
Fix regression: account for trait methods in arg count mismatch error Fixed rust-lang#47706 (rust-lang#47706 (comment)) Original PR rust-lang#47747 missed methods on trait definitions. This edit was done in GitHub. I think I got the signature of the variant right, going by the ICE debug output and the other cases above.
2 parents 0370717 + c06c707 commit c66c6b7

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

src/librustc/traits/error_reporting.rs

+5
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
831831
span,
832832
node: hir::ImplItemKind::Method(hir::MethodSig { ref decl, .. }, _),
833833
..
834+
}) |
835+
hir::map::NodeTraitItem(&hir::TraitItem {
836+
span,
837+
node: hir::TraitItemKind::Method(hir::MethodSig { ref decl, .. }, _),
838+
..
834839
}) => {
835840
(self.tcx.sess.codemap().def_span(span), decl.inputs.iter()
836841
.map(|arg| match arg.clone().into_inner().node {

src/test/ui/issue-47706-trait.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
trait T {
12+
fn f(&self, _: ()) {
13+
None::<()>.map(Self::f);
14+
}
15+
//~^^ ERROR function is expected to take a single 0-tuple as argument
16+
}

src/test/ui/issue-47706-trait.stderr

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0601]: main function not found
2+
3+
error[E0593]: function is expected to take a single 0-tuple as argument, but it takes 2 distinct arguments
4+
--> $DIR/issue-47706-trait.rs:13:20
5+
|
6+
12 | fn f(&self, _: ()) {
7+
| ------------------ takes 2 distinct arguments
8+
13 | None::<()>.map(Self::f);
9+
| ^^^ expected function that takes a single 0-tuple as argument
10+
11+
error: aborting due to 2 previous errors
12+

0 commit comments

Comments
 (0)