@@ -18,7 +18,7 @@ use rustc::ty::layout::{
18
18
HasDataLayout , HasTyCtxt , LayoutError , LayoutOf , Size , TargetDataLayout , TyLayout ,
19
19
} ;
20
20
use rustc:: ty:: subst:: { InternalSubsts , Subst } ;
21
- use rustc:: ty:: { self , Instance , ParamEnv , Ty , TyCtxt , TypeFoldable } ;
21
+ use rustc:: ty:: { self , ConstKind , Instance , ParamEnv , Ty , TyCtxt , TypeFoldable } ;
22
22
use rustc_data_structures:: fx:: FxHashMap ;
23
23
use rustc_hir:: def:: DefKind ;
24
24
use rustc_hir:: def_id:: DefId ;
@@ -441,8 +441,15 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
441
441
Ok ( op) => Some ( op) ,
442
442
Err ( error) => {
443
443
let err = error_to_const_error ( & self . ecx , error) ;
444
- match self . lint_root ( source_info) {
445
- Some ( lint_root) if c. literal . needs_subst ( ) => {
444
+ if let Some ( lint_root) = self . lint_root ( source_info) {
445
+ let lint_only = match c. literal . val {
446
+ // Promoteds must lint and not error as the user didn't ask for them
447
+ ConstKind :: Unevaluated ( _, _, Some ( _) ) => true ,
448
+ // Out of backwards compatibility we cannot report hard errors in unused
449
+ // generic functions using associated constants of the generic parameters.
450
+ _ => c. literal . needs_subst ( ) ,
451
+ } ;
452
+ if lint_only {
446
453
// Out of backwards compatibility we cannot report hard errors in unused
447
454
// generic functions using associated constants of the generic parameters.
448
455
err. report_as_lint (
@@ -451,10 +458,11 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
451
458
lint_root,
452
459
Some ( c. span ) ,
453
460
) ;
454
- }
455
- _ => {
461
+ } else {
456
462
err. report_as_error ( self . ecx . tcx , "erroneous constant used" ) ;
457
463
}
464
+ } else {
465
+ err. report_as_error ( self . ecx . tcx , "erroneous constant used" ) ;
458
466
}
459
467
None
460
468
}
0 commit comments