File tree 3 files changed +31
-1
lines changed
compiler/rustc_hir_analysis/src
3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -176,7 +176,7 @@ pub(crate) fn placeholder_type_error<'tcx>(
176
176
pub ( crate ) fn placeholder_type_error_diag < ' tcx > (
177
177
tcx : TyCtxt < ' tcx > ,
178
178
generics : Option < & hir:: Generics < ' _ > > ,
179
- placeholder_types : Vec < Span > ,
179
+ mut placeholder_types : Vec < Span > ,
180
180
additional_spans : Vec < Span > ,
181
181
suggest : bool ,
182
182
hir_ty : Option < & hir:: Ty < ' _ > > ,
@@ -188,6 +188,8 @@ pub(crate) fn placeholder_type_error_diag<'tcx>(
188
188
189
189
let params = generics. map ( |g| g. params ) . unwrap_or_default ( ) ;
190
190
let type_name = params. next_type_param_name ( None ) ;
191
+
192
+ placeholder_types. dedup ( ) ;
191
193
let mut sugg: Vec < _ > =
192
194
placeholder_types. iter ( ) . map ( |sp| ( * sp, ( * type_name) . to_string ( ) ) ) . collect ( ) ;
193
195
Original file line number Diff line number Diff line change
1
+ macro_rules! foo {
2
+ ( $ty: ty) => {
3
+ fn foo( _: $ty, _: $ty) { }
4
+ }
5
+ }
6
+
7
+ foo ! ( _) ;
8
+ //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
9
+
10
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
2
+ --> $DIR/issue-118048.rs:7:6
3
+ |
4
+ LL | foo!(_);
5
+ | ^ not allowed in type signatures
6
+ |
7
+ help: use type parameters instead
8
+ |
9
+ LL ~ fn foo<T>(_: $ty, _: $ty) {}
10
+ LL | }
11
+ LL | }
12
+ LL |
13
+ LL ~ foo!(T);
14
+ |
15
+
16
+ error: aborting due to previous error
17
+
18
+ For more information about this error, try `rustc --explain E0121`.
You can’t perform that action at this time.
0 commit comments