File tree Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -1173,9 +1173,12 @@ fn convert_enum_def<'tcx>(tcx: &ty::ctxt<'tcx>,
1173
1173
None
1174
1174
} ,
1175
1175
Err ( err) => {
1176
- span_err ! ( tcx. sess, err. span, E0080 ,
1177
- "constant evaluation error: {}" ,
1178
- err. description( ) ) ;
1176
+ span_err ! ( tcx. sess, err. span, E0080 ,
1177
+ "constant evaluation error: {}" ,
1178
+ err. description( ) ) ;
1179
+ if !e. span . contains ( err. span ) {
1180
+ tcx. sess . span_note ( e. span , "for enum discriminant here" ) ;
1181
+ }
1179
1182
None
1180
1183
}
1181
1184
}
Original file line number Diff line number Diff line change
1
+ // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ // Check that error in constant evaluation of enum discriminant
12
+ // provides the context for what caused the evaluation.
13
+
14
+ struct S ( i32 ) ;
15
+
16
+ const CONSTANT : S = S ( 0 ) ;
17
+ //~^ ERROR: constant evaluation error: unsupported constant expr
18
+
19
+ enum E {
20
+ V = CONSTANT ,
21
+ //~^ NOTE: for enum discriminant here
22
+ }
23
+
24
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments