File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed
compiler/rustc_lint/src/types Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -274,7 +274,7 @@ fn lint_int_literal<'tcx>(
274274 return ;
275275 }
276276
277- let span = if negative { type_limits. negated_expr_span . unwrap ( ) } else { span } ;
277+ let span = if negative { type_limits. negated_expr_span . unwrap_or ( span ) } else { span } ;
278278 let lit = cx
279279 . sess ( )
280280 . source_map ( )
Original file line number Diff line number Diff line change 1+ fn main ( ) {
2+ if let -129 = 0i8 { } //~ ERROR literal out of range for `i8`
3+ let x: i8 = -129 ; //~ ERROR literal out of range for `i8`
4+ }
Original file line number Diff line number Diff line change 1+ error: literal out of range for `i8`
2+ --> $DIR/lint-overflowing-int-136675.rs:2:12
3+ |
4+ LL | if let -129 = 0i8 {}
5+ | ^^^^
6+ |
7+ = note: the literal `-129` does not fit into the type `i8` whose range is `-128..=127`
8+ = help: consider using the type `i16` instead
9+ = note: `#[deny(overflowing_literals)]` on by default
10+
11+ error: literal out of range for `i8`
12+ --> $DIR/lint-overflowing-int-136675.rs:3:17
13+ |
14+ LL | let x: i8 = -129;
15+ | ^^^^
16+ |
17+ = note: the literal `-129` does not fit into the type `i8` whose range is `-128..=127`
18+ = help: consider using the type `i16` instead
19+
20+ error: aborting due to 2 previous errors
21+
You can’t perform that action at this time.
0 commit comments