1
Fork 0

Prefer new associated numeric consts in float error messages

This commit is contained in:
Rustin-Liu 2020-10-27 14:14:08 +08:00
parent 28f03ac4c0
commit 650e3cb176
2 changed files with 5 additions and 5 deletions

View file

@ -439,7 +439,7 @@ fn lint_literal<'tcx>(
cx.struct_span_lint(OVERFLOWING_LITERALS, e.span, |lint| { cx.struct_span_lint(OVERFLOWING_LITERALS, e.span, |lint| {
lint.build(&format!("literal out of range for `{}`", t.name_str())) lint.build(&format!("literal out of range for `{}`", t.name_str()))
.note(&format!( .note(&format!(
"the literal `{}` does not fit into the type `{}` and will be converted to `std::{}::INFINITY`", "the literal `{}` does not fit into the type `{}` and will be converted to `{}::INFINITY`",
cx.sess() cx.sess()
.source_map() .source_map()
.span_to_snippet(lit.span) .span_to_snippet(lit.span)

View file

@ -17,7 +17,7 @@ error: literal out of range for `f32`
LL | let x = -3.40282357e+38_f32; LL | let x = -3.40282357e+38_f32;
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
| |
= note: the literal `3.40282357e+38_f32` does not fit into the type `f32` and will be converted to `std::f32::INFINITY` = note: the literal `3.40282357e+38_f32` does not fit into the type `f32` and will be converted to `f32::INFINITY`
error: literal out of range for `f32` error: literal out of range for `f32`
--> $DIR/lint-type-overflow2.rs:10:14 --> $DIR/lint-type-overflow2.rs:10:14
@ -25,7 +25,7 @@ error: literal out of range for `f32`
LL | let x = 3.40282357e+38_f32; LL | let x = 3.40282357e+38_f32;
| ^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^
| |
= note: the literal `3.40282357e+38_f32` does not fit into the type `f32` and will be converted to `std::f32::INFINITY` = note: the literal `3.40282357e+38_f32` does not fit into the type `f32` and will be converted to `f32::INFINITY`
error: literal out of range for `f64` error: literal out of range for `f64`
--> $DIR/lint-type-overflow2.rs:11:14 --> $DIR/lint-type-overflow2.rs:11:14
@ -33,7 +33,7 @@ error: literal out of range for `f64`
LL | let x = -1.7976931348623159e+308_f64; LL | let x = -1.7976931348623159e+308_f64;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= note: the literal `1.7976931348623159e+308_f64` does not fit into the type `f64` and will be converted to `std::f64::INFINITY` = note: the literal `1.7976931348623159e+308_f64` does not fit into the type `f64` and will be converted to `f64::INFINITY`
error: literal out of range for `f64` error: literal out of range for `f64`
--> $DIR/lint-type-overflow2.rs:12:14 --> $DIR/lint-type-overflow2.rs:12:14
@ -41,7 +41,7 @@ error: literal out of range for `f64`
LL | let x = 1.7976931348623159e+308_f64; LL | let x = 1.7976931348623159e+308_f64;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
= note: the literal `1.7976931348623159e+308_f64` does not fit into the type `f64` and will be converted to `std::f64::INFINITY` = note: the literal `1.7976931348623159e+308_f64` does not fit into the type `f64` and will be converted to `f64::INFINITY`
error: aborting due to 5 previous errors error: aborting due to 5 previous errors