Skip to content

Commit b05f0be

Browse files
committed
Suggest replacing patterns with underscores
1 parent 90a6954 commit b05f0be

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/librustc_passes/ast_validation.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,11 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
344344
trait_item.id, span,
345345
"patterns aren't allowed in methods without bodies");
346346
} else {
347-
struct_span_err!(self.session, span, E0642,
348-
"patterns aren't allowed in methods without bodies").emit();
347+
let mut err = struct_span_err!(self.session, span, E0642,
348+
"patterns aren't allowed in methods without bodies");
349+
err.span_suggestion(span,
350+
"use an underscore to ignore the name", "_".to_owned());
351+
err.emit();
349352
}
350353
});
351354
}

src/test/ui/E0642.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0642]: patterns aren't allowed in methods without bodies
22
--> $DIR/E0642.rs:12:12
33
|
44
LL | fn foo((x, y): (i32, i32)); //~ ERROR patterns aren't allowed in methods without bodies
5-
| ^^^^^^
5+
| ^^^^^^ help: use an underscore to ignore the name: `_`
66

77
error: aborting due to previous error
88

0 commit comments

Comments
 (0)