Skip to content

Commit bef9b19

Browse files
authored
Unrolled build for rust-lang#128449
Rollup merge of rust-lang#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 rust-lang#128287 (comment).
2 parents 28a58f2 + 840ca3c commit bef9b19

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

compiler/rustc_lint/src/precedence.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ declare_lint! {
1616
/// ### Example
1717
///
1818
/// ```rust,compile_fail
19+
/// # #![deny(ambiguous_negative_literals)]
1920
/// # #![allow(unused)]
2021
/// -1i32.abs(); // equals -1, while `(-1i32).abs()` equals 1
2122
/// ```
@@ -27,7 +28,7 @@ declare_lint! {
2728
/// Method calls take precedence over unary precedence. Setting the
2829
/// precedence explicitly makes the code clearer and avoid potential bugs.
2930
pub AMBIGUOUS_NEGATIVE_LITERALS,
30-
Deny,
31+
Allow,
3132
"ambiguous negative literals operations",
3233
report_in_external_macro
3334
}

tests/ui/lint/negative_literals.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//@ check-fail
22

3+
#![deny(ambiguous_negative_literals)]
4+
35
fn main() {
46
let _ = -1i32.abs();
57
//~^ ERROR `-` has lower precedence than method calls

tests/ui/lint/negative_literals.stderr

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
error: `-` has lower precedence than method calls, which might be unexpected
2-
--> $DIR/negative_literals.rs:4:13
2+
--> $DIR/negative_literals.rs:6:13
33
|
44
LL | let _ = -1i32.abs();
55
| ^^^^^^^^^^^
66
|
77
= note: e.g. `-4.abs()` equals `-4`; while `(-4).abs()` equals `4`
8-
= note: `#[deny(ambiguous_negative_literals)]` on by default
8+
note: the lint level is defined here
9+
--> $DIR/negative_literals.rs:3:9
10+
|
11+
LL | #![deny(ambiguous_negative_literals)]
12+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
913
help: add parentheses around the `-` and the literal to call the method on a negative literal
1014
|
1115
LL | let _ = (-1i32).abs();
@@ -16,7 +20,7 @@ LL | let _ = -(1i32.abs());
1620
| + +
1721

1822
error: `-` has lower precedence than method calls, which might be unexpected
19-
--> $DIR/negative_literals.rs:6:13
23+
--> $DIR/negative_literals.rs:8:13
2024
|
2125
LL | let _ = -1f32.abs();
2226
| ^^^^^^^^^^^
@@ -32,7 +36,7 @@ LL | let _ = -(1f32.abs());
3236
| + +
3337

3438
error: `-` has lower precedence than method calls, which might be unexpected
35-
--> $DIR/negative_literals.rs:8:13
39+
--> $DIR/negative_literals.rs:10:13
3640
|
3741
LL | let _ = -1f64.asin();
3842
| ^^^^^^^^^^^^
@@ -48,7 +52,7 @@ LL | let _ = -(1f64.asin());
4852
| + +
4953

5054
error: `-` has lower precedence than method calls, which might be unexpected
51-
--> $DIR/negative_literals.rs:10:13
55+
--> $DIR/negative_literals.rs:12:13
5256
|
5357
LL | let _ = -1f64.asinh();
5458
| ^^^^^^^^^^^^^
@@ -64,7 +68,7 @@ LL | let _ = -(1f64.asinh());
6468
| + +
6569

6670
error: `-` has lower precedence than method calls, which might be unexpected
67-
--> $DIR/negative_literals.rs:12:13
71+
--> $DIR/negative_literals.rs:14:13
6872
|
6973
LL | let _ = -1f64.tan();
7074
| ^^^^^^^^^^^
@@ -80,7 +84,7 @@ LL | let _ = -(1f64.tan());
8084
| + +
8185

8286
error: `-` has lower precedence than method calls, which might be unexpected
83-
--> $DIR/negative_literals.rs:14:13
87+
--> $DIR/negative_literals.rs:16:13
8488
|
8589
LL | let _ = -1f64.tanh();
8690
| ^^^^^^^^^^^^
@@ -96,7 +100,7 @@ LL | let _ = -(1f64.tanh());
96100
| + +
97101

98102
error: `-` has lower precedence than method calls, which might be unexpected
99-
--> $DIR/negative_literals.rs:16:13
103+
--> $DIR/negative_literals.rs:18:13
100104
|
101105
LL | let _ = -1.0_f64.cos().cos();
102106
| ^^^^^^^^^^^^^^^^^^^^
@@ -112,7 +116,7 @@ LL | let _ = -(1.0_f64.cos().cos());
112116
| + +
113117

114118
error: `-` has lower precedence than method calls, which might be unexpected
115-
--> $DIR/negative_literals.rs:18:13
119+
--> $DIR/negative_literals.rs:20:13
116120
|
117121
LL | let _ = -1.0_f64.cos().sin();
118122
| ^^^^^^^^^^^^^^^^^^^^
@@ -128,7 +132,7 @@ LL | let _ = -(1.0_f64.cos().sin());
128132
| + +
129133

130134
error: `-` has lower precedence than method calls, which might be unexpected
131-
--> $DIR/negative_literals.rs:20:13
135+
--> $DIR/negative_literals.rs:22:13
132136
|
133137
LL | let _ = -1.0_f64.sin().cos();
134138
| ^^^^^^^^^^^^^^^^^^^^
@@ -144,7 +148,7 @@ LL | let _ = -(1.0_f64.sin().cos());
144148
| + +
145149

146150
error: `-` has lower precedence than method calls, which might be unexpected
147-
--> $DIR/negative_literals.rs:22:13
151+
--> $DIR/negative_literals.rs:24:13
148152
|
149153
LL | let _ = -1f64.sin().sin();
150154
| ^^^^^^^^^^^^^^^^^
@@ -160,7 +164,7 @@ LL | let _ = -(1f64.sin().sin());
160164
| + +
161165

162166
error: `-` has lower precedence than method calls, which might be unexpected
163-
--> $DIR/negative_literals.rs:25:11
167+
--> $DIR/negative_literals.rs:27:11
164168
|
165169
LL | dbg!( -1.0_f32.cos() );
166170
| ^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)