@@ -93,14 +93,14 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
93
93
message : & str )
94
94
-> Option < DiagnosticBuilder < ' tcx > >
95
95
{
96
- self . struct_generic ( tcx, message, None , true )
96
+ self . struct_generic ( tcx, message, None )
97
97
}
98
98
99
99
pub fn report_as_error ( & self ,
100
100
tcx : TyCtxtAt < ' a , ' gcx , ' tcx > ,
101
101
message : & str
102
102
) {
103
- let err = self . struct_generic ( tcx, message, None , true ) ;
103
+ let err = self . struct_generic ( tcx, message, None ) ;
104
104
if let Some ( mut err) = err {
105
105
err. emit ( ) ;
106
106
}
@@ -115,7 +115,6 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
115
115
tcx,
116
116
message,
117
117
Some ( lint_root) ,
118
- false ,
119
118
) ;
120
119
if let Some ( mut lint) = lint {
121
120
lint. emit ( ) ;
@@ -127,7 +126,6 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
127
126
tcx : TyCtxtAt < ' a , ' gcx , ' tcx > ,
128
127
message : & str ,
129
128
lint_root : Option < ast:: NodeId > ,
130
- as_err : bool ,
131
129
) -> Option < DiagnosticBuilder < ' tcx > > {
132
130
let ( msg, frames) : ( _ , & [ _ ] ) = match * self . kind {
133
131
ErrKind :: TypeckError | ErrKind :: CheckMatchError => return None ,
@@ -136,7 +134,7 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
136
134
:: mir:: interpret:: EvalErrorKind :: TypeckError |
137
135
:: mir:: interpret:: EvalErrorKind :: Layout ( _) => return None ,
138
136
:: mir:: interpret:: EvalErrorKind :: ReferencedConstant ( ref inner) => {
139
- inner. struct_generic ( tcx, "referenced constant" , lint_root, as_err ) ?. emit ( ) ;
137
+ inner. struct_generic ( tcx, "referenced constant" , lint_root) ?. emit ( ) ;
140
138
( miri. to_string ( ) , frames)
141
139
} ,
142
140
_ => ( miri. to_string ( ) , frames) ,
@@ -145,22 +143,21 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
145
143
_ => ( self . description ( ) . into_oneline ( ) . to_string ( ) , & [ ] ) ,
146
144
} ;
147
145
trace ! ( "reporting const eval failure at {:?}" , self . span) ;
148
- let mut err = if as_err {
149
- struct_error ( tcx, message)
150
- } else {
146
+ let mut err = if let Some ( lint_root) = lint_root {
151
147
let node_id = frames
152
148
. iter ( )
153
149
. rev ( )
154
150
. filter_map ( |frame| frame. lint_root )
155
151
. next ( )
156
- . or ( lint_root)
157
- . expect ( "some part of a failing const eval must be local" ) ;
152
+ . unwrap_or ( lint_root) ;
158
153
tcx. struct_span_lint_node (
159
154
:: rustc:: lint:: builtin:: CONST_ERR ,
160
155
node_id,
161
156
tcx. span ,
162
157
message,
163
158
)
159
+ } else {
160
+ struct_error ( tcx, message)
164
161
} ;
165
162
err. span_label ( self . span , msg) ;
166
163
for FrameInfo { span, location, .. } in frames {
0 commit comments