Rollup merge of #128449 - Urgau:tmp-allow-negative-lit-lint, r=compiler-errors
Temporarily switch `ambiguous_negative_literals` lint to allow This PR temporarily switch the `ambiguous_negative_literals` lint to `allow-by-default`, as asked by T-lang in https://github.com/rust-lang/rust/issues/128287#issuecomment-2260902036.
This commit is contained in:
commit
046664bdea
@ -16,6 +16,7 @@ declare_lint! {
|
|||||||
/// ### Example
|
/// ### Example
|
||||||
///
|
///
|
||||||
/// ```rust,compile_fail
|
/// ```rust,compile_fail
|
||||||
|
/// # #![deny(ambiguous_negative_literals)]
|
||||||
/// # #![allow(unused)]
|
/// # #![allow(unused)]
|
||||||
/// -1i32.abs(); // equals -1, while `(-1i32).abs()` equals 1
|
/// -1i32.abs(); // equals -1, while `(-1i32).abs()` equals 1
|
||||||
/// ```
|
/// ```
|
||||||
@ -27,7 +28,7 @@ declare_lint! {
|
|||||||
/// Method calls take precedence over unary precedence. Setting the
|
/// Method calls take precedence over unary precedence. Setting the
|
||||||
/// precedence explicitly makes the code clearer and avoid potential bugs.
|
/// precedence explicitly makes the code clearer and avoid potential bugs.
|
||||||
pub AMBIGUOUS_NEGATIVE_LITERALS,
|
pub AMBIGUOUS_NEGATIVE_LITERALS,
|
||||||
Deny,
|
Allow,
|
||||||
"ambiguous negative literals operations",
|
"ambiguous negative literals operations",
|
||||||
report_in_external_macro
|
report_in_external_macro
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
//@ check-fail
|
//@ check-fail
|
||||||
|
|
||||||
|
#![deny(ambiguous_negative_literals)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = -1i32.abs();
|
let _ = -1i32.abs();
|
||||||
//~^ ERROR `-` has lower precedence than method calls
|
//~^ ERROR `-` has lower precedence than method calls
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
error: `-` has lower precedence than method calls, which might be unexpected
|
error: `-` has lower precedence than method calls, which might be unexpected
|
||||||
--> $DIR/negative_literals.rs:4:13
|
--> $DIR/negative_literals.rs:6:13
|
||||||
|
|
|
|
||||||
LL | let _ = -1i32.abs();
|
LL | let _ = -1i32.abs();
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: e.g. `-4.abs()` equals `-4`; while `(-4).abs()` equals `4`
|
= note: e.g. `-4.abs()` equals `-4`; while `(-4).abs()` equals `4`
|
||||||
= note: `#[deny(ambiguous_negative_literals)]` on by default
|
note: the lint level is defined here
|
||||||
|
--> $DIR/negative_literals.rs:3:9
|
||||||
|
|
|
||||||
|
LL | #![deny(ambiguous_negative_literals)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
help: add parentheses around the `-` and the literal to call the method on a negative literal
|
help: add parentheses around the `-` and the literal to call the method on a negative literal
|
||||||
|
|
|
|
||||||
LL | let _ = (-1i32).abs();
|
LL | let _ = (-1i32).abs();
|
||||||
@ -16,7 +20,7 @@ LL | let _ = -(1i32.abs());
|
|||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: `-` has lower precedence than method calls, which might be unexpected
|
error: `-` has lower precedence than method calls, which might be unexpected
|
||||||
--> $DIR/negative_literals.rs:6:13
|
--> $DIR/negative_literals.rs:8:13
|
||||||
|
|
|
|
||||||
LL | let _ = -1f32.abs();
|
LL | let _ = -1f32.abs();
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
@ -32,7 +36,7 @@ LL | let _ = -(1f32.abs());
|
|||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: `-` has lower precedence than method calls, which might be unexpected
|
error: `-` has lower precedence than method calls, which might be unexpected
|
||||||
--> $DIR/negative_literals.rs:8:13
|
--> $DIR/negative_literals.rs:10:13
|
||||||
|
|
|
|
||||||
LL | let _ = -1f64.asin();
|
LL | let _ = -1f64.asin();
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
@ -48,7 +52,7 @@ LL | let _ = -(1f64.asin());
|
|||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: `-` has lower precedence than method calls, which might be unexpected
|
error: `-` has lower precedence than method calls, which might be unexpected
|
||||||
--> $DIR/negative_literals.rs:10:13
|
--> $DIR/negative_literals.rs:12:13
|
||||||
|
|
|
|
||||||
LL | let _ = -1f64.asinh();
|
LL | let _ = -1f64.asinh();
|
||||||
| ^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^
|
||||||
@ -64,7 +68,7 @@ LL | let _ = -(1f64.asinh());
|
|||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: `-` has lower precedence than method calls, which might be unexpected
|
error: `-` has lower precedence than method calls, which might be unexpected
|
||||||
--> $DIR/negative_literals.rs:12:13
|
--> $DIR/negative_literals.rs:14:13
|
||||||
|
|
|
|
||||||
LL | let _ = -1f64.tan();
|
LL | let _ = -1f64.tan();
|
||||||
| ^^^^^^^^^^^
|
| ^^^^^^^^^^^
|
||||||
@ -80,7 +84,7 @@ LL | let _ = -(1f64.tan());
|
|||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: `-` has lower precedence than method calls, which might be unexpected
|
error: `-` has lower precedence than method calls, which might be unexpected
|
||||||
--> $DIR/negative_literals.rs:14:13
|
--> $DIR/negative_literals.rs:16:13
|
||||||
|
|
|
|
||||||
LL | let _ = -1f64.tanh();
|
LL | let _ = -1f64.tanh();
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
@ -96,7 +100,7 @@ LL | let _ = -(1f64.tanh());
|
|||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: `-` has lower precedence than method calls, which might be unexpected
|
error: `-` has lower precedence than method calls, which might be unexpected
|
||||||
--> $DIR/negative_literals.rs:16:13
|
--> $DIR/negative_literals.rs:18:13
|
||||||
|
|
|
|
||||||
LL | let _ = -1.0_f64.cos().cos();
|
LL | let _ = -1.0_f64.cos().cos();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
@ -112,7 +116,7 @@ LL | let _ = -(1.0_f64.cos().cos());
|
|||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: `-` has lower precedence than method calls, which might be unexpected
|
error: `-` has lower precedence than method calls, which might be unexpected
|
||||||
--> $DIR/negative_literals.rs:18:13
|
--> $DIR/negative_literals.rs:20:13
|
||||||
|
|
|
|
||||||
LL | let _ = -1.0_f64.cos().sin();
|
LL | let _ = -1.0_f64.cos().sin();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
@ -128,7 +132,7 @@ LL | let _ = -(1.0_f64.cos().sin());
|
|||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: `-` has lower precedence than method calls, which might be unexpected
|
error: `-` has lower precedence than method calls, which might be unexpected
|
||||||
--> $DIR/negative_literals.rs:20:13
|
--> $DIR/negative_literals.rs:22:13
|
||||||
|
|
|
|
||||||
LL | let _ = -1.0_f64.sin().cos();
|
LL | let _ = -1.0_f64.sin().cos();
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
@ -144,7 +148,7 @@ LL | let _ = -(1.0_f64.sin().cos());
|
|||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: `-` has lower precedence than method calls, which might be unexpected
|
error: `-` has lower precedence than method calls, which might be unexpected
|
||||||
--> $DIR/negative_literals.rs:22:13
|
--> $DIR/negative_literals.rs:24:13
|
||||||
|
|
|
|
||||||
LL | let _ = -1f64.sin().sin();
|
LL | let _ = -1f64.sin().sin();
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
@ -160,7 +164,7 @@ LL | let _ = -(1f64.sin().sin());
|
|||||||
| + +
|
| + +
|
||||||
|
|
||||||
error: `-` has lower precedence than method calls, which might be unexpected
|
error: `-` has lower precedence than method calls, which might be unexpected
|
||||||
--> $DIR/negative_literals.rs:25:11
|
--> $DIR/negative_literals.rs:27:11
|
||||||
|
|
|
|
||||||
LL | dbg!( -1.0_f32.cos() );
|
LL | dbg!( -1.0_f32.cos() );
|
||||||
| ^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
|
Loading…
x
Reference in New Issue
Block a user