@@ -182,7 +182,7 @@ crate fn placeholder_type_error<'tcx>(
182
182
sugg. push ( ( span, format ! ( ", {}" , type_name) ) ) ;
183
183
}
184
184
185
- let mut err = bad_placeholder_type ( tcx, placeholder_types, kind) ;
185
+ let mut err = bad_placeholder ( tcx, "type" , placeholder_types, kind) ;
186
186
187
187
// Suggest, but only if it is not a function in const or static
188
188
if suggest {
@@ -314,8 +314,9 @@ impl<'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
314
314
///////////////////////////////////////////////////////////////////////////
315
315
// Utility types and common code for the above passes.
316
316
317
- fn bad_placeholder_type < ' tcx > (
317
+ fn bad_placeholder < ' tcx > (
318
318
tcx : TyCtxt < ' tcx > ,
319
+ placeholder_kind : & ' static str ,
319
320
mut spans : Vec < Span > ,
320
321
kind : & ' static str ,
321
322
) -> rustc_errors:: DiagnosticBuilder < ' tcx > {
@@ -326,7 +327,8 @@ fn bad_placeholder_type<'tcx>(
326
327
tcx. sess,
327
328
spans. clone( ) ,
328
329
E0121 ,
329
- "the type placeholder `_` is not allowed within types on item signatures for {}" ,
330
+ "the {} placeholder `_` is not allowed within types on item signatures for {}" ,
331
+ placeholder_kind,
330
332
kind
331
333
) ;
332
334
for span in spans {
@@ -393,7 +395,7 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
393
395
_: Option < & ty:: GenericParamDef > ,
394
396
span : Span ,
395
397
) -> & ' tcx Const < ' tcx > {
396
- bad_placeholder_type ( self . tcx ( ) , vec ! [ span] , "generic" ) . emit ( ) ;
398
+ bad_placeholder ( self . tcx ( ) , "const" , vec ! [ span] , "generic" ) . emit ( ) ;
397
399
// Typeck doesn't expect erased regions to be returned from `type_of`.
398
400
let ty = self . tcx . fold_regions ( ty, & mut false , |r, _| match r {
399
401
ty:: ReErased => self . tcx . lifetimes . re_static ,
@@ -1482,7 +1484,11 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
1482
1484
// `enum` discriminants (i.e. `D` in `enum Foo { Bar = D }`),
1483
1485
// as they shouldn't be able to cause query cycle errors.
1484
1486
Node :: Expr ( & Expr { kind : ExprKind :: Repeat ( _, ref constant) , .. } )
1485
- | Node :: Variant ( Variant { disr_expr : Some ( ref constant) , .. } )
1487
+ if constant. hir_id ( ) == hir_id =>
1488
+ {
1489
+ Some ( parent_def_id. to_def_id ( ) )
1490
+ }
1491
+ Node :: Variant ( Variant { disr_expr : Some ( ref constant) , .. } )
1486
1492
if constant. hir_id == hir_id =>
1487
1493
{
1488
1494
Some ( parent_def_id. to_def_id ( ) )
@@ -1788,7 +1794,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
1788
1794
1789
1795
let mut visitor = PlaceholderHirTyCollector :: default ( ) ;
1790
1796
visitor. visit_ty ( ty) ;
1791
- let mut diag = bad_placeholder_type ( tcx, visitor. 0 , "return type" ) ;
1797
+ let mut diag = bad_placeholder ( tcx, "type" , visitor. 0 , "return type" ) ;
1792
1798
let ret_ty = fn_sig. skip_binder ( ) . output ( ) ;
1793
1799
if !ret_ty. references_error ( ) {
1794
1800
if !ret_ty. is_closure ( ) {
0 commit comments