summaryrefslogtreecommitdiffstats
path: root/tests/ui/lint
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/lint')
-rw-r--r--tests/ui/lint/cli-unknown-force-warn.rs6
-rw-r--r--tests/ui/lint/cli-unknown-force-warn.stderr11
-rw-r--r--tests/ui/lint/command-line-lint-group-deny.stderr1
-rw-r--r--tests/ui/lint/command-line-lint-group-forbid.stderr1
-rw-r--r--tests/ui/lint/command-line-lint-group-warn.stderr1
-rw-r--r--tests/ui/lint/expr-field.rs15
-rw-r--r--tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr1
-rw-r--r--tests/ui/lint/force-warn/lint-group-allow-warnings.stderr1
-rw-r--r--tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr1
-rw-r--r--tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr1
-rw-r--r--tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr1
-rw-r--r--tests/ui/lint/future-incompat-test.stderr1
-rw-r--r--tests/ui/lint/invalid_from_utf8.rs27
-rw-r--r--tests/ui/lint/invalid_from_utf8.stderr135
-rw-r--r--tests/ui/lint/issue-99387.rs2
-rw-r--r--tests/ui/lint/large_assignments/box_rc_arc_allowed.rs29
-rw-r--r--tests/ui/lint/large_assignments/box_rc_arc_allowed.stderr23
-rw-r--r--tests/ui/lint/large_assignments/large_future.attribute.stderr23
-rw-r--r--tests/ui/lint/large_assignments/large_future.option.stderr23
-rw-r--r--tests/ui/lint/large_assignments/large_future.rs26
-rw-r--r--tests/ui/lint/lint-ctypes-94223.rs7
-rw-r--r--tests/ui/lint/lint-ctypes-94223.stderr27
-rw-r--r--tests/ui/lint/lint-ctypes-fn.rs2
-rw-r--r--tests/ui/lint/lint-ctypes-option-nonnull-unsized.rs8
-rw-r--r--tests/ui/lint/lint-ctypes-option-nonnull-unsized.stderr16
-rw-r--r--tests/ui/lint/lint-ctypes.rs2
-rw-r--r--tests/ui/lint/lint-pre-expansion-extern-module.stderr1
-rw-r--r--tests/ui/lint/lint-removed-cmdline-deny.rs13
-rw-r--r--tests/ui/lint/lint-removed-cmdline-deny.stderr28
-rw-r--r--tests/ui/lint/lint-removed-cmdline.rs1
-rw-r--r--tests/ui/lint/lint-removed-cmdline.stderr5
-rw-r--r--tests/ui/lint/lint-renamed-cmdline-deny.rs10
-rw-r--r--tests/ui/lint/lint-renamed-cmdline-deny.stderr31
-rw-r--r--tests/ui/lint/lint-renamed-cmdline.rs1
-rw-r--r--tests/ui/lint/lint-renamed-cmdline.stderr8
-rw-r--r--tests/ui/lint/lint-unexported-no-mangle.stderr1
-rw-r--r--tests/ui/lint/lint-unknown-lint-cmdline-allow.rs4
-rw-r--r--tests/ui/lint/lint-unknown-lint-cmdline-deny.rs9
-rw-r--r--tests/ui/lint/lint-unknown-lint-cmdline-deny.stderr31
-rw-r--r--tests/ui/lint/lint-unknown-lint-cmdline.rs2
-rw-r--r--tests/ui/lint/lint-unknown-lint-cmdline.stderr20
-rw-r--r--tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr21
-rw-r--r--tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr33
-rw-r--r--tests/ui/lint/must_not_suspend/dedup.rs8
-rw-r--r--tests/ui/lint/must_not_suspend/dedup.stderr (renamed from tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr)7
-rw-r--r--tests/ui/lint/must_not_suspend/ref-drop-tracking.rs30
-rw-r--r--tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr27
-rw-r--r--tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr27
-rw-r--r--tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr27
-rw-r--r--tests/ui/lint/must_not_suspend/ref.rs5
-rw-r--r--tests/ui/lint/must_not_suspend/ref.stderr (renamed from tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr)8
-rw-r--r--tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr37
-rw-r--r--tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr37
-rw-r--r--tests/ui/lint/must_not_suspend/trait.rs6
-rw-r--r--tests/ui/lint/must_not_suspend/trait.stderr (renamed from tests/ui/lint/must_not_suspend/trait.drop_tracking.stderr)10
-rw-r--r--tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr26
-rw-r--r--tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr26
-rw-r--r--tests/ui/lint/must_not_suspend/unit.rs4
-rw-r--r--tests/ui/lint/must_not_suspend/unit.stderr (renamed from tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr)8
-rw-r--r--tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr26
-rw-r--r--tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr26
-rw-r--r--tests/ui/lint/must_not_suspend/warn.rs7
-rw-r--r--tests/ui/lint/must_not_suspend/warn.stderr (renamed from tests/ui/lint/must_not_suspend/warn.drop_tracking_mir.stderr)20
-rw-r--r--tests/ui/lint/no-coverage.rs40
-rw-r--r--tests/ui/lint/no-coverage.stderr72
-rw-r--r--tests/ui/lint/noop-method-call.fixed13
-rw-r--r--tests/ui/lint/noop-method-call.rs13
-rw-r--r--tests/ui/lint/noop-method-call.stderr14
-rw-r--r--tests/ui/lint/ptr_null_checks.rs14
-rw-r--r--tests/ui/lint/ptr_null_checks.stderr38
-rw-r--r--tests/ui/lint/reference_casting.rs62
-rw-r--r--tests/ui/lint/reference_casting.stderr209
-rw-r--r--tests/ui/lint/trivial_casts.stderr2
-rw-r--r--tests/ui/lint/unused/unused-doc-comments-edge-cases.rs26
-rw-r--r--tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr30
-rw-r--r--tests/ui/lint/unused/unused-parens-issue-106413.rs32
-rw-r--r--tests/ui/lint/unused/unused-parens-issue-106413.stderr127
77 files changed, 1113 insertions, 561 deletions
diff --git a/tests/ui/lint/cli-unknown-force-warn.rs b/tests/ui/lint/cli-unknown-force-warn.rs
index f3dea87a6..a9e4e4a60 100644
--- a/tests/ui/lint/cli-unknown-force-warn.rs
+++ b/tests/ui/lint/cli-unknown-force-warn.rs
@@ -1,7 +1,11 @@
// Checks that rustc correctly errors when passed an invalid lint with
// `--force-warn`. This is a regression test for issue #86958.
-//
+
+// check-pass
// compile-flags: --force-warn foo-qux
+
// error-pattern: unknown lint: `foo_qux`
+// error-pattern: requested on the command line with `--force-warn foo_qux`
+// error-pattern: `#[warn(unknown_lints)]` on by default
fn main() {}
diff --git a/tests/ui/lint/cli-unknown-force-warn.stderr b/tests/ui/lint/cli-unknown-force-warn.stderr
index 9ce9f405a..2ee718a8c 100644
--- a/tests/ui/lint/cli-unknown-force-warn.stderr
+++ b/tests/ui/lint/cli-unknown-force-warn.stderr
@@ -1,11 +1,16 @@
-error[E0602]: unknown lint: `foo_qux`
+warning[E0602]: unknown lint: `foo_qux`
|
= note: requested on the command line with `--force-warn foo_qux`
+ = note: `#[warn(unknown_lints)]` on by default
-error[E0602]: unknown lint: `foo_qux`
+warning[E0602]: unknown lint: `foo_qux`
|
= note: requested on the command line with `--force-warn foo_qux`
-error: aborting due to 2 previous errors
+warning[E0602]: unknown lint: `foo_qux`
+ |
+ = note: requested on the command line with `--force-warn foo_qux`
+
+warning: 3 warnings emitted
For more information about this error, try `rustc --explain E0602`.
diff --git a/tests/ui/lint/command-line-lint-group-deny.stderr b/tests/ui/lint/command-line-lint-group-deny.stderr
index 04c3f6f26..59d8429ea 100644
--- a/tests/ui/lint/command-line-lint-group-deny.stderr
+++ b/tests/ui/lint/command-line-lint-group-deny.stderr
@@ -5,6 +5,7 @@ LL | let _InappropriateCamelCasing = true;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `_inappropriate_camel_casing`
|
= note: `-D non-snake-case` implied by `-D bad-style`
+ = help: to override `-D bad-style` add `#[allow(non_snake_case)]`
error: aborting due to previous error
diff --git a/tests/ui/lint/command-line-lint-group-forbid.stderr b/tests/ui/lint/command-line-lint-group-forbid.stderr
index 736782140..486d32a9f 100644
--- a/tests/ui/lint/command-line-lint-group-forbid.stderr
+++ b/tests/ui/lint/command-line-lint-group-forbid.stderr
@@ -5,6 +5,7 @@ LL | let _InappropriateCamelCasing = true;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `_inappropriate_camel_casing`
|
= note: `-F non-snake-case` implied by `-F bad-style`
+ = help: to override `-F bad-style` add `#[allow(non_snake_case)]`
error: aborting due to previous error
diff --git a/tests/ui/lint/command-line-lint-group-warn.stderr b/tests/ui/lint/command-line-lint-group-warn.stderr
index e9c80b4ef..cfe346a5b 100644
--- a/tests/ui/lint/command-line-lint-group-warn.stderr
+++ b/tests/ui/lint/command-line-lint-group-warn.stderr
@@ -5,6 +5,7 @@ LL | let _InappropriateCamelCasing = true;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `_inappropriate_camel_casing`
|
= note: `-W non-snake-case` implied by `-W bad-style`
+ = help: to override `-W bad-style` add `#[allow(non_snake_case)]`
warning: 1 warning emitted
diff --git a/tests/ui/lint/expr-field.rs b/tests/ui/lint/expr-field.rs
new file mode 100644
index 000000000..638fbf521
--- /dev/null
+++ b/tests/ui/lint/expr-field.rs
@@ -0,0 +1,15 @@
+// check-pass
+
+pub struct A {
+ pub x: u32,
+}
+
+#[deny(unused_comparisons)]
+pub fn foo(y: u32) -> A {
+ A {
+ #[allow(unused_comparisons)]
+ x: if y < 0 { 1 } else { 2 },
+ }
+}
+
+fn main() {}
diff --git a/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr
index d1b764b34..01c2ed84c 100644
--- a/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr
+++ b/tests/ui/lint/force-warn/cap-lints-warn-allowed-warn-by-default-lint.stderr
@@ -7,6 +7,7 @@ LL | 0...100 => true,
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
= note: `--force-warn ellipsis-inclusive-range-patterns` implied by `--force-warn rust-2021-compatibility`
+ = help: to override `--force-warn rust-2021-compatibility` add `#[allow(ellipsis_inclusive_range_patterns)]`
warning: 1 warning emitted
diff --git a/tests/ui/lint/force-warn/lint-group-allow-warnings.stderr b/tests/ui/lint/force-warn/lint-group-allow-warnings.stderr
index dc7b1b7b9..e925a195f 100644
--- a/tests/ui/lint/force-warn/lint-group-allow-warnings.stderr
+++ b/tests/ui/lint/force-warn/lint-group-allow-warnings.stderr
@@ -5,6 +5,7 @@ LL | pub fn FUNCTION() {}
| ^^^^^^^^ help: convert the identifier to snake case: `function`
|
= note: `--force-warn non-snake-case` implied by `--force-warn nonstandard-style`
+ = help: to override `--force-warn nonstandard-style` add `#[allow(non_snake_case)]`
warning: 1 warning emitted
diff --git a/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr
index e17630fd3..b0cd3ddd2 100644
--- a/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr
+++ b/tests/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.stderr
@@ -7,6 +7,7 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
= note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms`
+ = help: to override `--force-warn rust-2018-idioms` add `#[allow(bare_trait_objects)]`
help: use `dyn`
|
LL | pub fn function(_x: Box<dyn SomeTrait>) {}
diff --git a/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr b/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr
index 72198541a..8c841916c 100644
--- a/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr
+++ b/tests/ui/lint/force-warn/lint-group-allowed-lint-group.stderr
@@ -7,6 +7,7 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
= note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms`
+ = help: to override `--force-warn rust-2018-idioms` add `#[allow(bare_trait_objects)]`
help: use `dyn`
|
LL | pub fn function(_x: Box<dyn SomeTrait>) {}
diff --git a/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr b/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr
index 52c870ac2..c0144205d 100644
--- a/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr
+++ b/tests/ui/lint/force-warn/lint-group-allowed-warn-by-default-lint.stderr
@@ -7,6 +7,7 @@ LL | pub fn function(_x: Box<SomeTrait>) {}
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
= note: `--force-warn bare-trait-objects` implied by `--force-warn rust-2018-idioms`
+ = help: to override `--force-warn rust-2018-idioms` add `#[allow(bare_trait_objects)]`
help: use `dyn`
|
LL | pub fn function(_x: Box<dyn SomeTrait>) {}
diff --git a/tests/ui/lint/future-incompat-test.stderr b/tests/ui/lint/future-incompat-test.stderr
index 52674a843..2951f904f 100644
--- a/tests/ui/lint/future-incompat-test.stderr
+++ b/tests/ui/lint/future-incompat-test.stderr
@@ -6,4 +6,5 @@ LL | let x = 1;
| ^ help: if this is intentional, prefix it with an underscore: `_x`
|
= note: `-A unused-variables` implied by `-A unused`
+ = help: to override `-A unused` add `#[allow(unused_variables)]`
diff --git a/tests/ui/lint/invalid_from_utf8.rs b/tests/ui/lint/invalid_from_utf8.rs
index 9c8c63681..43ceffb71 100644
--- a/tests/ui/lint/invalid_from_utf8.rs
+++ b/tests/ui/lint/invalid_from_utf8.rs
@@ -1,6 +1,8 @@
// check-pass
+#![feature(inline_const)]
#![feature(concat_bytes)]
+
#![warn(invalid_from_utf8_unchecked)]
#![warn(invalid_from_utf8)]
@@ -90,4 +92,29 @@ pub fn from_utf8() {
}
}
+pub fn from_utf8_with_indirections() {
+ let mut a = [99, 108, 130, 105, 112, 112, 121];
+ std::str::from_utf8_mut(&mut a);
+ //~^ WARN calls to `std::str::from_utf8_mut`
+ let mut b = &mut a;
+ let mut c = b;
+ std::str::from_utf8_mut(c);
+ //~^ WARN calls to `std::str::from_utf8_mut`
+ let mut c = &[99, 108, 130, 105, 112, 112, 121];
+ std::str::from_utf8(c);
+ //~^ WARN calls to `std::str::from_utf8`
+ const INVALID_1: [u8; 7] = [99, 108, 130, 105, 112, 112, 121];
+ std::str::from_utf8(&INVALID_1);
+ //~^ WARN calls to `std::str::from_utf8`
+ static INVALID_2: [u8; 7] = [99, 108, 130, 105, 112, 112, 121];
+ std::str::from_utf8(&INVALID_2);
+ //~^ WARN calls to `std::str::from_utf8`
+ const INVALID_3: &'static [u8; 7] = &[99, 108, 130, 105, 112, 112, 121];
+ std::str::from_utf8(INVALID_3);
+ //~^ WARN calls to `std::str::from_utf8`
+ const INVALID_4: &'static [u8; 7] = { &[99, 108, 130, 105, 112, 112, 121] };
+ std::str::from_utf8(INVALID_4);
+ //~^ WARN calls to `std::str::from_utf8`
+}
+
fn main() {}
diff --git a/tests/ui/lint/invalid_from_utf8.stderr b/tests/ui/lint/invalid_from_utf8.stderr
index 8e00d3bf8..884165d4f 100644
--- a/tests/ui/lint/invalid_from_utf8.stderr
+++ b/tests/ui/lint/invalid_from_utf8.stderr
@@ -1,43 +1,43 @@
warning: calls to `std::str::from_utf8_unchecked_mut` with a invalid literal are undefined behavior
- --> $DIR/invalid_from_utf8.rs:19:9
+ --> $DIR/invalid_from_utf8.rs:21:9
|
LL | std::str::from_utf8_unchecked_mut(&mut [99, 108, 130, 105, 112, 112, 121]);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------^
- | |
- | the literal was valid UTF-8 up to the 2 bytes
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^
+ | |
+ | the literal was valid UTF-8 up to the 2 bytes
|
note: the lint level is defined here
- --> $DIR/invalid_from_utf8.rs:4:9
+ --> $DIR/invalid_from_utf8.rs:6:9
|
LL | #![warn(invalid_from_utf8_unchecked)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: calls to `std::str::from_utf8_unchecked_mut` with a invalid literal are undefined behavior
- --> $DIR/invalid_from_utf8.rs:21:9
+ --> $DIR/invalid_from_utf8.rs:23:9
|
LL | std::str::from_utf8_unchecked_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------------------^
- | |
- | the literal was valid UTF-8 up to the 2 bytes
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^
+ | |
+ | the literal was valid UTF-8 up to the 2 bytes
warning: calls to `std::str::from_utf8_unchecked` with a invalid literal are undefined behavior
- --> $DIR/invalid_from_utf8.rs:39:9
+ --> $DIR/invalid_from_utf8.rs:41:9
|
LL | std::str::from_utf8_unchecked(&[99, 108, 130, 105, 112, 112, 121]);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^
- | |
- | the literal was valid UTF-8 up to the 2 bytes
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^
+ | |
+ | the literal was valid UTF-8 up to the 2 bytes
warning: calls to `std::str::from_utf8_unchecked` with a invalid literal are undefined behavior
- --> $DIR/invalid_from_utf8.rs:41:9
+ --> $DIR/invalid_from_utf8.rs:43:9
|
LL | std::str::from_utf8_unchecked(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------------------^
- | |
- | the literal was valid UTF-8 up to the 2 bytes
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^
+ | |
+ | the literal was valid UTF-8 up to the 2 bytes
warning: calls to `std::str::from_utf8_unchecked` with a invalid literal are undefined behavior
- --> $DIR/invalid_from_utf8.rs:43:9
+ --> $DIR/invalid_from_utf8.rs:45:9
|
LL | std::str::from_utf8_unchecked(b"cl\x82ippy");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------^
@@ -45,7 +45,7 @@ LL | std::str::from_utf8_unchecked(b"cl\x82ippy");
| the literal was valid UTF-8 up to the 2 bytes
warning: calls to `std::str::from_utf8_unchecked` with a invalid literal are undefined behavior
- --> $DIR/invalid_from_utf8.rs:45:9
+ --> $DIR/invalid_from_utf8.rs:47:9
|
LL | std::str::from_utf8_unchecked(concat_bytes!(b"cl", b"\x82ippy"));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------^
@@ -53,45 +53,45 @@ LL | std::str::from_utf8_unchecked(concat_bytes!(b"cl", b"\x82ippy"));
| the literal was valid UTF-8 up to the 2 bytes
warning: calls to `std::str::from_utf8_mut` with a invalid literal always return an error
- --> $DIR/invalid_from_utf8.rs:62:9
+ --> $DIR/invalid_from_utf8.rs:64:9
|
LL | std::str::from_utf8_mut(&mut [99, 108, 130, 105, 112, 112, 121]);
- | ^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------^
- | |
- | the literal was valid UTF-8 up to the 2 bytes
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^
+ | |
+ | the literal was valid UTF-8 up to the 2 bytes
|
note: the lint level is defined here
- --> $DIR/invalid_from_utf8.rs:5:9
+ --> $DIR/invalid_from_utf8.rs:7:9
|
LL | #![warn(invalid_from_utf8)]
| ^^^^^^^^^^^^^^^^^
warning: calls to `std::str::from_utf8_mut` with a invalid literal always return an error
- --> $DIR/invalid_from_utf8.rs:64:9
+ --> $DIR/invalid_from_utf8.rs:66:9
|
LL | std::str::from_utf8_mut(&mut [b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
- | ^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------------------^
- | |
- | the literal was valid UTF-8 up to the 2 bytes
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^
+ | |
+ | the literal was valid UTF-8 up to the 2 bytes
warning: calls to `std::str::from_utf8` with a invalid literal always return an error
- --> $DIR/invalid_from_utf8.rs:82:9
+ --> $DIR/invalid_from_utf8.rs:84:9
|
LL | std::str::from_utf8(&[99, 108, 130, 105, 112, 112, 121]);
- | ^^^^^^^^^^^^^^^^^^^^-----------------------------------^
- | |
- | the literal was valid UTF-8 up to the 2 bytes
+ | ^^^^^^^^^^^^^^^^^^^^^----------------------------------^
+ | |
+ | the literal was valid UTF-8 up to the 2 bytes
warning: calls to `std::str::from_utf8` with a invalid literal always return an error
- --> $DIR/invalid_from_utf8.rs:84:9
+ --> $DIR/invalid_from_utf8.rs:86:9
|
LL | std::str::from_utf8(&[b'c', b'l', b'\x82', b'i', b'p', b'p', b'y']);
- | ^^^^^^^^^^^^^^^^^^^^----------------------------------------------^
- | |
- | the literal was valid UTF-8 up to the 2 bytes
+ | ^^^^^^^^^^^^^^^^^^^^^---------------------------------------------^
+ | |
+ | the literal was valid UTF-8 up to the 2 bytes
warning: calls to `std::str::from_utf8` with a invalid literal always return an error
- --> $DIR/invalid_from_utf8.rs:86:9
+ --> $DIR/invalid_from_utf8.rs:88:9
|
LL | std::str::from_utf8(b"cl\x82ippy");
| ^^^^^^^^^^^^^^^^^^^^-------------^
@@ -99,12 +99,69 @@ LL | std::str::from_utf8(b"cl\x82ippy");
| the literal was valid UTF-8 up to the 2 bytes
warning: calls to `std::str::from_utf8` with a invalid literal always return an error
- --> $DIR/invalid_from_utf8.rs:88:9
+ --> $DIR/invalid_from_utf8.rs:90:9
|
LL | std::str::from_utf8(concat_bytes!(b"cl", b"\x82ippy"));
| ^^^^^^^^^^^^^^^^^^^^---------------------------------^
| |
| the literal was valid UTF-8 up to the 2 bytes
-warning: 12 warnings emitted
+warning: calls to `std::str::from_utf8_mut` with a invalid literal always return an error
+ --> $DIR/invalid_from_utf8.rs:97:5
+ |
+LL | let mut a = [99, 108, 130, 105, 112, 112, 121];
+ | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
+LL | std::str::from_utf8_mut(&mut a);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: calls to `std::str::from_utf8_mut` with a invalid literal always return an error
+ --> $DIR/invalid_from_utf8.rs:101:5
+ |
+LL | let mut a = [99, 108, 130, 105, 112, 112, 121];
+ | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
+...
+LL | std::str::from_utf8_mut(c);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: calls to `std::str::from_utf8` with a invalid literal always return an error
+ --> $DIR/invalid_from_utf8.rs:104:5
+ |
+LL | let mut c = &[99, 108, 130, 105, 112, 112, 121];
+ | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
+LL | std::str::from_utf8(c);
+ | ^^^^^^^^^^^^^^^^^^^^^^
+
+warning: calls to `std::str::from_utf8` with a invalid literal always return an error
+ --> $DIR/invalid_from_utf8.rs:107:5
+ |
+LL | const INVALID_1: [u8; 7] = [99, 108, 130, 105, 112, 112, 121];
+ | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
+LL | std::str::from_utf8(&INVALID_1);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: calls to `std::str::from_utf8` with a invalid literal always return an error
+ --> $DIR/invalid_from_utf8.rs:110:5
+ |
+LL | static INVALID_2: [u8; 7] = [99, 108, 130, 105, 112, 112, 121];
+ | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
+LL | std::str::from_utf8(&INVALID_2);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: calls to `std::str::from_utf8` with a invalid literal always return an error
+ --> $DIR/invalid_from_utf8.rs:113:5
+ |
+LL | const INVALID_3: &'static [u8; 7] = &[99, 108, 130, 105, 112, 112, 121];
+ | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
+LL | std::str::from_utf8(INVALID_3);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: calls to `std::str::from_utf8` with a invalid literal always return an error
+ --> $DIR/invalid_from_utf8.rs:116:5
+ |
+LL | const INVALID_4: &'static [u8; 7] = { &[99, 108, 130, 105, 112, 112, 121] };
+ | ---------------------------------- the literal was valid UTF-8 up to the 2 bytes
+LL | std::str::from_utf8(INVALID_4);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: 19 warnings emitted
diff --git a/tests/ui/lint/issue-99387.rs b/tests/ui/lint/issue-99387.rs
index ba5031167..571d4194f 100644
--- a/tests/ui/lint/issue-99387.rs
+++ b/tests/ui/lint/issue-99387.rs
@@ -2,7 +2,7 @@
//! opaque types.
#![feature(type_alias_impl_trait)]
-#![allow(private_in_public)]
+#![allow(private_interfaces)]
pub type Successors<'a> = impl Iterator<Item = &'a ()>;
diff --git a/tests/ui/lint/large_assignments/box_rc_arc_allowed.rs b/tests/ui/lint/large_assignments/box_rc_arc_allowed.rs
new file mode 100644
index 000000000..331136420
--- /dev/null
+++ b/tests/ui/lint/large_assignments/box_rc_arc_allowed.rs
@@ -0,0 +1,29 @@
+#![deny(large_assignments)]
+#![feature(large_assignments)]
+#![move_size_limit = "1000"]
+// build-fail
+// only-x86_64
+
+// edition:2018
+// compile-flags: -Zmir-opt-level=0
+
+use std::{sync::Arc, rc::Rc};
+
+fn main() {
+ let _ = Arc::new([0; 9999]); // OK!
+ let _ = Box::new([0; 9999]); // OK!
+ let _ = Rc::new([0; 9999]); // OK!
+ let _ = NotBox::new([0; 9999]); //~ ERROR large_assignments
+}
+
+struct NotBox {
+ data: [u8; 9999],
+}
+
+impl NotBox {
+ fn new(data: [u8; 9999]) -> Self {
+ Self {
+ data, //~ ERROR large_assignments
+ }
+ }
+}
diff --git a/tests/ui/lint/large_assignments/box_rc_arc_allowed.stderr b/tests/ui/lint/large_assignments/box_rc_arc_allowed.stderr
new file mode 100644
index 000000000..b45cbe5da
--- /dev/null
+++ b/tests/ui/lint/large_assignments/box_rc_arc_allowed.stderr
@@ -0,0 +1,23 @@
+error: moving 9999 bytes
+ --> $DIR/box_rc_arc_allowed.rs:16:13
+ |
+LL | let _ = NotBox::new([0; 9999]);
+ | ^^^^^^^^^^^^^^^^^^^^^^ value moved from here
+ |
+ = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
+note: the lint level is defined here
+ --> $DIR/box_rc_arc_allowed.rs:1:9
+ |
+LL | #![deny(large_assignments)]
+ | ^^^^^^^^^^^^^^^^^
+
+error: moving 9999 bytes
+ --> $DIR/box_rc_arc_allowed.rs:26:13
+ |
+LL | data,
+ | ^^^^ value moved from here
+ |
+ = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/lint/large_assignments/large_future.attribute.stderr b/tests/ui/lint/large_assignments/large_future.attribute.stderr
new file mode 100644
index 000000000..734b7ff7b
--- /dev/null
+++ b/tests/ui/lint/large_assignments/large_future.attribute.stderr
@@ -0,0 +1,23 @@
+error: moving 10024 bytes
+ --> $DIR/large_future.rs:19:14
+ |
+LL | let z = (x, 42);
+ | ^ value moved from here
+ |
+ = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
+note: the lint level is defined here
+ --> $DIR/large_future.rs:1:9
+ |
+LL | #![deny(large_assignments)]
+ | ^^^^^^^^^^^^^^^^^
+
+error: moving 10024 bytes
+ --> $DIR/large_future.rs:20:13
+ |
+LL | let a = z.0;
+ | ^^^ value moved from here
+ |
+ = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/lint/large_assignments/large_future.option.stderr b/tests/ui/lint/large_assignments/large_future.option.stderr
new file mode 100644
index 000000000..734b7ff7b
--- /dev/null
+++ b/tests/ui/lint/large_assignments/large_future.option.stderr
@@ -0,0 +1,23 @@
+error: moving 10024 bytes
+ --> $DIR/large_future.rs:19:14
+ |
+LL | let z = (x, 42);
+ | ^ value moved from here
+ |
+ = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
+note: the lint level is defined here
+ --> $DIR/large_future.rs:1:9
+ |
+LL | #![deny(large_assignments)]
+ | ^^^^^^^^^^^^^^^^^
+
+error: moving 10024 bytes
+ --> $DIR/large_future.rs:20:13
+ |
+LL | let a = z.0;
+ | ^^^ value moved from here
+ |
+ = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/lint/large_assignments/large_future.rs b/tests/ui/lint/large_assignments/large_future.rs
new file mode 100644
index 000000000..834746fa9
--- /dev/null
+++ b/tests/ui/lint/large_assignments/large_future.rs
@@ -0,0 +1,26 @@
+#![deny(large_assignments)]
+#![cfg_attr(attribute, feature(large_assignments))]
+#![cfg_attr(attribute, move_size_limit = "1000")]
+// build-fail
+// only-x86_64
+// revisions: attribute option
+// [option]compile-flags: -Zmove-size-limit=1000
+
+// edition:2018
+// compile-flags: -Zmir-opt-level=0
+
+fn main() {
+ let x = async {
+ let y = [0; 9999];
+ dbg!(y);
+ thing(&y).await;
+ dbg!(y);
+ };
+ let z = (x, 42); //~ ERROR large_assignments
+ let a = z.0; //~ ERROR large_assignments
+ let b = z.1;
+}
+
+async fn thing(y: &[u8]) {
+ dbg!(y);
+}
diff --git a/tests/ui/lint/lint-ctypes-94223.rs b/tests/ui/lint/lint-ctypes-94223.rs
index 70dd2a71f..ac24f61b0 100644
--- a/tests/ui/lint/lint-ctypes-94223.rs
+++ b/tests/ui/lint/lint-ctypes-94223.rs
@@ -24,6 +24,13 @@ enum BadUnion {
type Foo = extern "C" fn([u8]);
//~^ ERROR `extern` fn uses type `[u8]`, which is not FFI-safe
+pub trait FooTrait {
+ type FooType;
+}
+
+pub type Foo2<T> = extern "C" fn(Option<&<T as FooTrait>::FooType>);
+//~^ ERROR `extern` fn uses type `Option<&<T as FooTrait>::FooType>`, which is not FFI-safe
+
pub struct FfiUnsafe;
#[allow(improper_ctypes_definitions)]
diff --git a/tests/ui/lint/lint-ctypes-94223.stderr b/tests/ui/lint/lint-ctypes-94223.stderr
index 49e64ed51..bd127cf60 100644
--- a/tests/ui/lint/lint-ctypes-94223.stderr
+++ b/tests/ui/lint/lint-ctypes-94223.stderr
@@ -66,8 +66,17 @@ LL | type Foo = extern "C" fn([u8]);
= help: consider using a raw pointer instead
= note: slices have no C equivalent
+error: `extern` fn uses type `Option<&<T as FooTrait>::FooType>`, which is not FFI-safe
+ --> $DIR/lint-ctypes-94223.rs:31:20
+ |
+LL | pub type Foo2<T> = extern "C" fn(Option<&<T as FooTrait>::FooType>);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
+ |
+ = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
+ = note: enum has no representation hint
+
error: `extern` fn uses type `FfiUnsafe`, which is not FFI-safe
- --> $DIR/lint-ctypes-94223.rs:34:17
+ --> $DIR/lint-ctypes-94223.rs:41:17
|
LL | pub static BAD: extern "C" fn(FfiUnsafe) = f;
| ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -75,13 +84,13 @@ LL | pub static BAD: extern "C" fn(FfiUnsafe) = f;
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
- --> $DIR/lint-ctypes-94223.rs:27:1
+ --> $DIR/lint-ctypes-94223.rs:34:1
|
LL | pub struct FfiUnsafe;
| ^^^^^^^^^^^^^^^^^^^^
error: `extern` fn uses type `FfiUnsafe`, which is not FFI-safe
- --> $DIR/lint-ctypes-94223.rs:37:30
+ --> $DIR/lint-ctypes-94223.rs:44:30
|
LL | pub static BAD_TWICE: Result<extern "C" fn(FfiUnsafe), extern "C" fn(FfiUnsafe)> = Ok(f);
| ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -89,13 +98,13 @@ LL | pub static BAD_TWICE: Result<extern "C" fn(FfiUnsafe), extern "C" fn(FfiUns
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
- --> $DIR/lint-ctypes-94223.rs:27:1
+ --> $DIR/lint-ctypes-94223.rs:34:1
|
LL | pub struct FfiUnsafe;
| ^^^^^^^^^^^^^^^^^^^^
error: `extern` fn uses type `FfiUnsafe`, which is not FFI-safe
- --> $DIR/lint-ctypes-94223.rs:37:56
+ --> $DIR/lint-ctypes-94223.rs:44:56
|
LL | pub static BAD_TWICE: Result<extern "C" fn(FfiUnsafe), extern "C" fn(FfiUnsafe)> = Ok(f);
| ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -103,13 +112,13 @@ LL | pub static BAD_TWICE: Result<extern "C" fn(FfiUnsafe), extern "C" fn(FfiUns
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
- --> $DIR/lint-ctypes-94223.rs:27:1
+ --> $DIR/lint-ctypes-94223.rs:34:1
|
LL | pub struct FfiUnsafe;
| ^^^^^^^^^^^^^^^^^^^^
error: `extern` fn uses type `FfiUnsafe`, which is not FFI-safe
- --> $DIR/lint-ctypes-94223.rs:41:22
+ --> $DIR/lint-ctypes-94223.rs:48:22
|
LL | pub const BAD_CONST: extern "C" fn(FfiUnsafe) = f;
| ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
@@ -117,10 +126,10 @@ LL | pub const BAD_CONST: extern "C" fn(FfiUnsafe) = f;
= help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
= note: this struct has unspecified layout
note: the type is defined here
- --> $DIR/lint-ctypes-94223.rs:27:1
+ --> $DIR/lint-ctypes-94223.rs:34:1
|
LL | pub struct FfiUnsafe;
| ^^^^^^^^^^^^^^^^^^^^
-error: aborting due to 11 previous errors
+error: aborting due to 12 previous errors
diff --git a/tests/ui/lint/lint-ctypes-fn.rs b/tests/ui/lint/lint-ctypes-fn.rs
index d3b36a9d5..14831e247 100644
--- a/tests/ui/lint/lint-ctypes-fn.rs
+++ b/tests/ui/lint/lint-ctypes-fn.rs
@@ -1,6 +1,6 @@
#![feature(rustc_private)]
-#![allow(private_in_public)]
+#![allow(private_interfaces)]
#![deny(improper_ctypes_definitions)]
extern crate libc;
diff --git a/tests/ui/lint/lint-ctypes-option-nonnull-unsized.rs b/tests/ui/lint/lint-ctypes-option-nonnull-unsized.rs
new file mode 100644
index 000000000..ca08eb23a
--- /dev/null
+++ b/tests/ui/lint/lint-ctypes-option-nonnull-unsized.rs
@@ -0,0 +1,8 @@
+#![deny(improper_ctypes_definitions)]
+
+extern "C" fn foo<T: ?Sized + 'static>() -> Option<&'static T> {
+ //~^ ERROR `extern` fn uses type `Option<&T>`, which is not FFI-safe
+ None
+}
+
+fn main() {}
diff --git a/tests/ui/lint/lint-ctypes-option-nonnull-unsized.stderr b/tests/ui/lint/lint-ctypes-option-nonnull-unsized.stderr
new file mode 100644
index 000000000..f59fb3cc7
--- /dev/null
+++ b/tests/ui/lint/lint-ctypes-option-nonnull-unsized.stderr
@@ -0,0 +1,16 @@
+error: `extern` fn uses type `Option<&T>`, which is not FFI-safe
+ --> $DIR/lint-ctypes-option-nonnull-unsized.rs:3:45
+ |
+LL | extern "C" fn foo<T: ?Sized + 'static>() -> Option<&'static T> {
+ | ^^^^^^^^^^^^^^^^^^ not FFI-safe
+ |
+ = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
+ = note: enum has no representation hint
+note: the lint level is defined here
+ --> $DIR/lint-ctypes-option-nonnull-unsized.rs:1:9
+ |
+LL | #![deny(improper_ctypes_definitions)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/lint/lint-ctypes.rs b/tests/ui/lint/lint-ctypes.rs
index 9165e14b7..3dd731625 100644
--- a/tests/ui/lint/lint-ctypes.rs
+++ b/tests/ui/lint/lint-ctypes.rs
@@ -1,6 +1,6 @@
#![feature(rustc_private)]
-#![allow(private_in_public)]
+#![allow(private_interfaces)]
#![deny(improper_ctypes)]
extern crate libc;
diff --git a/tests/ui/lint/lint-pre-expansion-extern-module.stderr b/tests/ui/lint/lint-pre-expansion-extern-module.stderr
index ce3e8806a..8a6e1531d 100644
--- a/tests/ui/lint/lint-pre-expansion-extern-module.stderr
+++ b/tests/ui/lint/lint-pre-expansion-extern-module.stderr
@@ -7,6 +7,7 @@ LL | pub fn try() {}
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
= note: `-W keyword-idents` implied by `-W rust-2018-compatibility`
+ = help: to override `-W rust-2018-compatibility` add `#[allow(keyword_idents)]`
warning: 1 warning emitted
diff --git a/tests/ui/lint/lint-removed-cmdline-deny.rs b/tests/ui/lint/lint-removed-cmdline-deny.rs
new file mode 100644
index 000000000..8cf91cf60
--- /dev/null
+++ b/tests/ui/lint/lint-removed-cmdline-deny.rs
@@ -0,0 +1,13 @@
+// The raw_pointer_derived lint warns about its removal
+// cc #30346
+
+// compile-flags:-D renamed-and-removed-lints -D raw_pointer_derive
+
+// error-pattern:lint `raw_pointer_derive` has been removed
+// error-pattern:requested on the command line with `-D raw_pointer_derive`
+// error-pattern:requested on the command line with `-D renamed-and-removed-lints`
+
+#![warn(unused)]
+
+#[deny(warnings)]
+fn main() { let unused = (); }
diff --git a/tests/ui/lint/lint-removed-cmdline-deny.stderr b/tests/ui/lint/lint-removed-cmdline-deny.stderr
new file mode 100644
index 000000000..80c85d01e
--- /dev/null
+++ b/tests/ui/lint/lint-removed-cmdline-deny.stderr
@@ -0,0 +1,28 @@
+error: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok
+ |
+ = note: requested on the command line with `-D raw_pointer_derive`
+ = note: requested on the command line with `-D renamed-and-removed-lints`
+
+error: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok
+ |
+ = note: requested on the command line with `-D raw_pointer_derive`
+
+error: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok
+ |
+ = note: requested on the command line with `-D raw_pointer_derive`
+
+error: unused variable: `unused`
+ --> $DIR/lint-removed-cmdline-deny.rs:13:17
+ |
+LL | fn main() { let unused = (); }
+ | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused`
+ |
+note: the lint level is defined here
+ --> $DIR/lint-removed-cmdline-deny.rs:12:8
+ |
+LL | #[deny(warnings)]
+ | ^^^^^^^^
+ = note: `#[deny(unused_variables)]` implied by `#[deny(warnings)]`
+
+error: aborting due to 4 previous errors
+
diff --git a/tests/ui/lint/lint-removed-cmdline.rs b/tests/ui/lint/lint-removed-cmdline.rs
index 462beabb9..34373df3a 100644
--- a/tests/ui/lint/lint-removed-cmdline.rs
+++ b/tests/ui/lint/lint-removed-cmdline.rs
@@ -4,6 +4,7 @@
// compile-flags:-D raw_pointer_derive
// error-pattern:lint `raw_pointer_derive` has been removed
+// error-pattern:`#[warn(renamed_and_removed_lints)]` on by default
// error-pattern:requested on the command line with `-D raw_pointer_derive`
#![warn(unused)]
diff --git a/tests/ui/lint/lint-removed-cmdline.stderr b/tests/ui/lint/lint-removed-cmdline.stderr
index 9be532ef2..ebfae34ad 100644
--- a/tests/ui/lint/lint-removed-cmdline.stderr
+++ b/tests/ui/lint/lint-removed-cmdline.stderr
@@ -1,6 +1,7 @@
warning: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok
|
= note: requested on the command line with `-D raw_pointer_derive`
+ = note: `#[warn(renamed_and_removed_lints)]` on by default
warning: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok
|
@@ -11,13 +12,13 @@ warning: lint `raw_pointer_derive` has been removed: using derive with raw point
= note: requested on the command line with `-D raw_pointer_derive`
error: unused variable: `unused`
- --> $DIR/lint-removed-cmdline.rs:12:17
+ --> $DIR/lint-removed-cmdline.rs:13:17
|
LL | fn main() { let unused = (); }
| ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused`
|
note: the lint level is defined here
- --> $DIR/lint-removed-cmdline.rs:11:8
+ --> $DIR/lint-removed-cmdline.rs:12:8
|
LL | #[deny(warnings)]
| ^^^^^^^^
diff --git a/tests/ui/lint/lint-renamed-cmdline-deny.rs b/tests/ui/lint/lint-renamed-cmdline-deny.rs
new file mode 100644
index 000000000..01629aaca
--- /dev/null
+++ b/tests/ui/lint/lint-renamed-cmdline-deny.rs
@@ -0,0 +1,10 @@
+// compile-flags:-D renamed-and-removed-lints -D bare_trait_object
+
+// error-pattern:lint `bare_trait_object` has been renamed to `bare_trait_objects`
+// error-pattern:use the new name `bare_trait_objects`
+// error-pattern:requested on the command line with `-D bare_trait_object`
+// error-pattern:requested on the command line with `-D renamed-and-removed-lints`
+// error-pattern:unused
+
+#[deny(unused)]
+fn main() { let unused = (); }
diff --git a/tests/ui/lint/lint-renamed-cmdline-deny.stderr b/tests/ui/lint/lint-renamed-cmdline-deny.stderr
new file mode 100644
index 000000000..df22ef60d
--- /dev/null
+++ b/tests/ui/lint/lint-renamed-cmdline-deny.stderr
@@ -0,0 +1,31 @@
+error: lint `bare_trait_object` has been renamed to `bare_trait_objects`
+ |
+ = help: use the new name `bare_trait_objects`
+ = note: requested on the command line with `-D bare_trait_object`
+ = note: requested on the command line with `-D renamed-and-removed-lints`
+
+error: lint `bare_trait_object` has been renamed to `bare_trait_objects`
+ |
+ = help: use the new name `bare_trait_objects`
+ = note: requested on the command line with `-D bare_trait_object`
+
+error: lint `bare_trait_object` has been renamed to `bare_trait_objects`
+ |
+ = help: use the new name `bare_trait_objects`
+ = note: requested on the command line with `-D bare_trait_object`
+
+error: unused variable: `unused`
+ --> $DIR/lint-renamed-cmdline-deny.rs:10:17
+ |
+LL | fn main() { let unused = (); }
+ | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused`
+ |
+note: the lint level is defined here
+ --> $DIR/lint-renamed-cmdline-deny.rs:9:8
+ |
+LL | #[deny(unused)]
+ | ^^^^^^
+ = note: `#[deny(unused_variables)]` implied by `#[deny(unused)]`
+
+error: aborting due to 4 previous errors
+
diff --git a/tests/ui/lint/lint-renamed-cmdline.rs b/tests/ui/lint/lint-renamed-cmdline.rs
index c873771e3..fba7c3331 100644
--- a/tests/ui/lint/lint-renamed-cmdline.rs
+++ b/tests/ui/lint/lint-renamed-cmdline.rs
@@ -2,6 +2,7 @@
// error-pattern:lint `bare_trait_object` has been renamed to `bare_trait_objects`
// error-pattern:requested on the command line with `-D bare_trait_object`
+// error-pattern:`#[warn(renamed_and_removed_lints)]` on by default
// error-pattern:unused
#[deny(unused)]
diff --git a/tests/ui/lint/lint-renamed-cmdline.stderr b/tests/ui/lint/lint-renamed-cmdline.stderr
index 8dfd61ac9..a41284003 100644
--- a/tests/ui/lint/lint-renamed-cmdline.stderr
+++ b/tests/ui/lint/lint-renamed-cmdline.stderr
@@ -1,23 +1,27 @@
warning: lint `bare_trait_object` has been renamed to `bare_trait_objects`
|
+ = help: use the new name `bare_trait_objects`
= note: requested on the command line with `-D bare_trait_object`
+ = note: `#[warn(renamed_and_removed_lints)]` on by default
warning: lint `bare_trait_object` has been renamed to `bare_trait_objects`
|
+ = help: use the new name `bare_trait_objects`
= note: requested on the command line with `-D bare_trait_object`
warning: lint `bare_trait_object` has been renamed to `bare_trait_objects`
|
+ = help: use the new name `bare_trait_objects`
= note: requested on the command line with `-D bare_trait_object`
error: unused variable: `unused`
- --> $DIR/lint-renamed-cmdline.rs:8:17
+ --> $DIR/lint-renamed-cmdline.rs:9:17
|
LL | fn main() { let unused = (); }
| ^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused`
|
note: the lint level is defined here
- --> $DIR/lint-renamed-cmdline.rs:7:8
+ --> $DIR/lint-renamed-cmdline.rs:8:8
|
LL | #[deny(unused)]
| ^^^^^^
diff --git a/tests/ui/lint/lint-unexported-no-mangle.stderr b/tests/ui/lint/lint-unexported-no-mangle.stderr
index a11ee769c..858527822 100644
--- a/tests/ui/lint/lint-unexported-no-mangle.stderr
+++ b/tests/ui/lint/lint-unexported-no-mangle.stderr
@@ -1,6 +1,7 @@
warning: lint `private_no_mangle_fns` has been removed: no longer a warning, `#[no_mangle]` functions always exported
|
= note: requested on the command line with `-F private_no_mangle_fns`
+ = note: `#[warn(renamed_and_removed_lints)]` on by default
warning: lint `private_no_mangle_statics` has been removed: no longer a warning, `#[no_mangle]` statics always exported
|
diff --git a/tests/ui/lint/lint-unknown-lint-cmdline-allow.rs b/tests/ui/lint/lint-unknown-lint-cmdline-allow.rs
new file mode 100644
index 000000000..c7f8d434c
--- /dev/null
+++ b/tests/ui/lint/lint-unknown-lint-cmdline-allow.rs
@@ -0,0 +1,4 @@
+// check-pass
+// compile-flags:-A unknown-lints -D bogus -D dead_cod
+
+fn main() { }
diff --git a/tests/ui/lint/lint-unknown-lint-cmdline-deny.rs b/tests/ui/lint/lint-unknown-lint-cmdline-deny.rs
new file mode 100644
index 000000000..31bc20473
--- /dev/null
+++ b/tests/ui/lint/lint-unknown-lint-cmdline-deny.rs
@@ -0,0 +1,9 @@
+// compile-flags:-D unknown-lints -D bogus -D dead_cod
+
+// error-pattern:unknown lint: `bogus`
+// error-pattern:requested on the command line with `-D bogus`
+// error-pattern:requested on the command line with `-D dead_cod`
+// error-pattern:requested on the command line with `-D unknown-lints`
+// error-pattern:did you mean: `dead_code`
+
+fn main() { }
diff --git a/tests/ui/lint/lint-unknown-lint-cmdline-deny.stderr b/tests/ui/lint/lint-unknown-lint-cmdline-deny.stderr
new file mode 100644
index 000000000..677b5edc8
--- /dev/null
+++ b/tests/ui/lint/lint-unknown-lint-cmdline-deny.stderr
@@ -0,0 +1,31 @@
+error[E0602]: unknown lint: `bogus`
+ |
+ = note: requested on the command line with `-D bogus`
+ = note: requested on the command line with `-D unknown-lints`
+
+error[E0602]: unknown lint: `dead_cod`
+ |
+ = help: did you mean: `dead_code`
+ = note: requested on the command line with `-D dead_cod`
+
+error[E0602]: unknown lint: `bogus`
+ |
+ = note: requested on the command line with `-D bogus`
+
+error[E0602]: unknown lint: `dead_cod`
+ |
+ = help: did you mean: `dead_code`
+ = note: requested on the command line with `-D dead_cod`
+
+error[E0602]: unknown lint: `bogus`
+ |
+ = note: requested on the command line with `-D bogus`
+
+error[E0602]: unknown lint: `dead_cod`
+ |
+ = help: did you mean: `dead_code`
+ = note: requested on the command line with `-D dead_cod`
+
+error: aborting due to 6 previous errors
+
+For more information about this error, try `rustc --explain E0602`.
diff --git a/tests/ui/lint/lint-unknown-lint-cmdline.rs b/tests/ui/lint/lint-unknown-lint-cmdline.rs
index 7f3f55fba..81539cb6d 100644
--- a/tests/ui/lint/lint-unknown-lint-cmdline.rs
+++ b/tests/ui/lint/lint-unknown-lint-cmdline.rs
@@ -1,7 +1,9 @@
+// check-pass
// compile-flags:-D bogus -D dead_cod
// error-pattern:unknown lint: `bogus`
// error-pattern:requested on the command line with `-D bogus`
+// error-pattern:`#[warn(unknown_lints)]` on by default
// error-pattern:unknown lint: `dead_cod`
// error-pattern:requested on the command line with `-D dead_cod`
// error-pattern:did you mean: `dead_code`
diff --git a/tests/ui/lint/lint-unknown-lint-cmdline.stderr b/tests/ui/lint/lint-unknown-lint-cmdline.stderr
index 3855d5527..10db76ac4 100644
--- a/tests/ui/lint/lint-unknown-lint-cmdline.stderr
+++ b/tests/ui/lint/lint-unknown-lint-cmdline.stderr
@@ -1,21 +1,31 @@
-error[E0602]: unknown lint: `bogus`
+warning[E0602]: unknown lint: `bogus`
|
= note: requested on the command line with `-D bogus`
+ = note: `#[warn(unknown_lints)]` on by default
-error[E0602]: unknown lint: `dead_cod`
+warning[E0602]: unknown lint: `dead_cod`
|
= help: did you mean: `dead_code`
= note: requested on the command line with `-D dead_cod`
-error[E0602]: unknown lint: `bogus`
+warning[E0602]: unknown lint: `bogus`
|
= note: requested on the command line with `-D bogus`
-error[E0602]: unknown lint: `dead_cod`
+warning[E0602]: unknown lint: `dead_cod`
|
= help: did you mean: `dead_code`
= note: requested on the command line with `-D dead_cod`
-error: aborting due to 4 previous errors
+warning[E0602]: unknown lint: `bogus`
+ |
+ = note: requested on the command line with `-D bogus`
+
+warning[E0602]: unknown lint: `dead_cod`
+ |
+ = help: did you mean: `dead_code`
+ = note: requested on the command line with `-D dead_cod`
+
+warning: 6 warnings emitted
For more information about this error, try `rustc --explain E0602`.
diff --git a/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr
deleted file mode 100644
index cd3baa857..000000000
--- a/tests/ui/lint/must_not_suspend/dedup.drop_tracking_mir.stderr
+++ /dev/null
@@ -1,21 +0,0 @@
-error: `No` held across a suspend point, but should not be
- --> $DIR/dedup.rs:19:9
- |
-LL | let no = No {};
- | ^^
-LL | wheeee(&no).await;
- | ----- the value is held across this suspend point
- |
-help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/dedup.rs:19:9
- |
-LL | let no = No {};
- | ^^
-note: the lint level is defined here
- --> $DIR/dedup.rs:6:9
- |
-LL | #![deny(must_not_suspend)]
- | ^^^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr
deleted file mode 100644
index aff2f7c32..000000000
--- a/tests/ui/lint/must_not_suspend/dedup.no_drop_tracking.stderr
+++ /dev/null
@@ -1,33 +0,0 @@
-error: `No` held across a suspend point, but should not be
- --> $DIR/dedup.rs:19:9
- |
-LL | let no = No {};
- | ^^
-LL | wheeee(&no).await;
- | ----- the value is held across this suspend point
- |
-help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/dedup.rs:19:9
- |
-LL | let no = No {};
- | ^^
-note: the lint level is defined here
- --> $DIR/dedup.rs:6:9
- |
-LL | #![deny(must_not_suspend)]
- | ^^^^^^^^^^^^^^^^
-
-error: `No` held across a suspend point, but should not be
- --> $DIR/dedup.rs:20:13
- |
-LL | wheeee(&no).await;
- | ^^ ----- the value is held across this suspend point
- |
-help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/dedup.rs:20:13
- |
-LL | wheeee(&no).await;
- | ^^
-
-error: aborting due to 2 previous errors
-
diff --git a/tests/ui/lint/must_not_suspend/dedup.rs b/tests/ui/lint/must_not_suspend/dedup.rs
index 96bdb7715..867bdf2ec 100644
--- a/tests/ui/lint/must_not_suspend/dedup.rs
+++ b/tests/ui/lint/must_not_suspend/dedup.rs
@@ -1,6 +1,3 @@
-// revisions: no_drop_tracking drop_tracking drop_tracking_mir
-// [drop_tracking] compile-flags: -Zdrop-tracking
-// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir
// edition:2018
#![feature(must_not_suspend)]
#![deny(must_not_suspend)]
@@ -16,8 +13,9 @@ async fn wheeee<T>(t: T) {
}
async fn yes() {
- let no = No {}; //~ ERROR `No` held across
- wheeee(&no).await; //[no_drop_tracking]~ ERROR `No` held across
+ let no = No {};
+ //~^ ERROR `No` held across
+ wheeee(&no).await;
drop(no);
}
diff --git a/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/dedup.stderr
index cd3baa857..5d5b04a5d 100644
--- a/tests/ui/lint/must_not_suspend/dedup.drop_tracking.stderr
+++ b/tests/ui/lint/must_not_suspend/dedup.stderr
@@ -1,18 +1,19 @@
error: `No` held across a suspend point, but should not be
- --> $DIR/dedup.rs:19:9
+ --> $DIR/dedup.rs:16:9
|
LL | let no = No {};
| ^^
+LL |
LL | wheeee(&no).await;
| ----- the value is held across this suspend point
|
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/dedup.rs:19:9
+ --> $DIR/dedup.rs:16:9
|
LL | let no = No {};
| ^^
note: the lint level is defined here
- --> $DIR/dedup.rs:6:9
+ --> $DIR/dedup.rs:3:9
|
LL | #![deny(must_not_suspend)]
| ^^^^^^^^^^^^^^^^
diff --git a/tests/ui/lint/must_not_suspend/ref-drop-tracking.rs b/tests/ui/lint/must_not_suspend/ref-drop-tracking.rs
deleted file mode 100644
index 1bc4a3812..000000000
--- a/tests/ui/lint/must_not_suspend/ref-drop-tracking.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-// edition:2018
-// compile-flags: -Zdrop-tracking
-#![feature(must_not_suspend)]
-#![deny(must_not_suspend)]
-
-#[must_not_suspend = "You gotta use Umm's, ya know?"]
-struct Umm {
- i: i64
-}
-
-struct Bar {
- u: Umm,
-}
-
-async fn other() {}
-
-impl Bar {
- async fn uhoh(&mut self) {
- let guard = &mut self.u; //~ ERROR `Umm` held across
-
- other().await;
-
- *guard = Umm {
- i: 2
- }
- }
-}
-
-fn main() {
-}
diff --git a/tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr b/tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr
deleted file mode 100644
index 348880b9c..000000000
--- a/tests/ui/lint/must_not_suspend/ref-drop-tracking.stderr
+++ /dev/null
@@ -1,27 +0,0 @@
-error: reference to `Umm` held across a suspend point, but should not be
- --> $DIR/ref-drop-tracking.rs:19:13
- |
-LL | let guard = &mut self.u;
- | ^^^^^
-LL |
-LL | other().await;
- | ----- the value is held across this suspend point
- |
-note: You gotta use Umm's, ya know?
- --> $DIR/ref-drop-tracking.rs:19:13
- |
-LL | let guard = &mut self.u;
- | ^^^^^
-help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/ref-drop-tracking.rs:19:13
- |
-LL | let guard = &mut self.u;
- | ^^^^^
-note: the lint level is defined here
- --> $DIR/ref-drop-tracking.rs:4:9
- |
-LL | #![deny(must_not_suspend)]
- | ^^^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr
deleted file mode 100644
index fb18c2be9..000000000
--- a/tests/ui/lint/must_not_suspend/ref.drop_tracking.stderr
+++ /dev/null
@@ -1,27 +0,0 @@
-error: reference to `Umm` held across a suspend point, but should not be
- --> $DIR/ref.rs:22:13
- |
-LL | let guard = &mut self.u;
- | ^^^^^
-LL |
-LL | other().await;
- | ----- the value is held across this suspend point
- |
-note: You gotta use Umm's, ya know?
- --> $DIR/ref.rs:22:13
- |
-LL | let guard = &mut self.u;
- | ^^^^^
-help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/ref.rs:22:13
- |
-LL | let guard = &mut self.u;
- | ^^^^^
-note: the lint level is defined here
- --> $DIR/ref.rs:7:9
- |
-LL | #![deny(must_not_suspend)]
- | ^^^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr
deleted file mode 100644
index 6976dd349..000000000
--- a/tests/ui/lint/must_not_suspend/ref.no_drop_tracking.stderr
+++ /dev/null
@@ -1,27 +0,0 @@
-error: `Umm` held across a suspend point, but should not be
- --> $DIR/ref.rs:22:26
- |
-LL | let guard = &mut self.u;
- | ^^^^^^
-LL |
-LL | other().await;
- | ----- the value is held across this suspend point
- |
-note: You gotta use Umm's, ya know?
- --> $DIR/ref.rs:22:26
- |
-LL | let guard = &mut self.u;
- | ^^^^^^
-help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/ref.rs:22:26
- |
-LL | let guard = &mut self.u;
- | ^^^^^^
-note: the lint level is defined here
- --> $DIR/ref.rs:7:9
- |
-LL | #![deny(must_not_suspend)]
- | ^^^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/tests/ui/lint/must_not_suspend/ref.rs b/tests/ui/lint/must_not_suspend/ref.rs
index d05dcb83a..3b6ef39c9 100644
--- a/tests/ui/lint/must_not_suspend/ref.rs
+++ b/tests/ui/lint/must_not_suspend/ref.rs
@@ -1,8 +1,4 @@
// edition:2018
-// revisions: no_drop_tracking drop_tracking drop_tracking_mir
-// [drop_tracking] compile-flags: -Zdrop-tracking
-// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir
-
#![feature(must_not_suspend)]
#![deny(must_not_suspend)]
@@ -23,7 +19,6 @@ impl Bar {
other().await;
- let _g = &*guard;
*guard = Umm { i: 2 }
}
}
diff --git a/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/ref.stderr
index fb18c2be9..ed91a4a0b 100644
--- a/tests/ui/lint/must_not_suspend/ref.drop_tracking_mir.stderr
+++ b/tests/ui/lint/must_not_suspend/ref.stderr
@@ -1,5 +1,5 @@
error: reference to `Umm` held across a suspend point, but should not be
- --> $DIR/ref.rs:22:13
+ --> $DIR/ref.rs:18:13
|
LL | let guard = &mut self.u;
| ^^^^^
@@ -8,17 +8,17 @@ LL | other().await;
| ----- the value is held across this suspend point
|
note: You gotta use Umm's, ya know?
- --> $DIR/ref.rs:22:13
+ --> $DIR/ref.rs:18:13
|
LL | let guard = &mut self.u;
| ^^^^^
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/ref.rs:22:13
+ --> $DIR/ref.rs:18:13
|
LL | let guard = &mut self.u;
| ^^^^^
note: the lint level is defined here
- --> $DIR/ref.rs:7:9
+ --> $DIR/ref.rs:3:9
|
LL | #![deny(must_not_suspend)]
| ^^^^^^^^^^^^^^^^
diff --git a/tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr
deleted file mode 100644
index 8c8ad1f37..000000000
--- a/tests/ui/lint/must_not_suspend/trait.drop_tracking_mir.stderr
+++ /dev/null
@@ -1,37 +0,0 @@
-error: implementer of `Wow` held across a suspend point, but should not be
- --> $DIR/trait.rs:24:9
- |
-LL | let _guard1 = r#impl();
- | ^^^^^^^
-...
-LL | other().await;
- | ----- the value is held across this suspend point
- |
-help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/trait.rs:24:9
- |
-LL | let _guard1 = r#impl();
- | ^^^^^^^
-note: the lint level is defined here
- --> $DIR/trait.rs:6:9
- |
-LL | #![deny(must_not_suspend)]
- | ^^^^^^^^^^^^^^^^
-
-error: boxed `Wow` trait object held across a suspend point, but should not be
- --> $DIR/trait.rs:25:9
- |
-LL | let _guard2 = r#dyn();
- | ^^^^^^^
-LL |
-LL | other().await;
- | ----- the value is held across this suspend point
- |
-help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/trait.rs:25:9
- |
-LL | let _guard2 = r#dyn();
- | ^^^^^^^
-
-error: aborting due to 2 previous errors
-
diff --git a/tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr
deleted file mode 100644
index 8c8ad1f37..000000000
--- a/tests/ui/lint/must_not_suspend/trait.no_drop_tracking.stderr
+++ /dev/null
@@ -1,37 +0,0 @@
-error: implementer of `Wow` held across a suspend point, but should not be
- --> $DIR/trait.rs:24:9
- |
-LL | let _guard1 = r#impl();
- | ^^^^^^^
-...
-LL | other().await;
- | ----- the value is held across this suspend point
- |
-help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/trait.rs:24:9
- |
-LL | let _guard1 = r#impl();
- | ^^^^^^^
-note: the lint level is defined here
- --> $DIR/trait.rs:6:9
- |
-LL | #![deny(must_not_suspend)]
- | ^^^^^^^^^^^^^^^^
-
-error: boxed `Wow` trait object held across a suspend point, but should not be
- --> $DIR/trait.rs:25:9
- |
-LL | let _guard2 = r#dyn();
- | ^^^^^^^
-LL |
-LL | other().await;
- | ----- the value is held across this suspend point
- |
-help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/trait.rs:25:9
- |
-LL | let _guard2 = r#dyn();
- | ^^^^^^^
-
-error: aborting due to 2 previous errors
-
diff --git a/tests/ui/lint/must_not_suspend/trait.rs b/tests/ui/lint/must_not_suspend/trait.rs
index cc3ae298d..6c911cb4b 100644
--- a/tests/ui/lint/must_not_suspend/trait.rs
+++ b/tests/ui/lint/must_not_suspend/trait.rs
@@ -1,6 +1,3 @@
-// revisions: no_drop_tracking drop_tracking drop_tracking_mir
-// [drop_tracking] compile-flags: -Zdrop-tracking
-// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir
// edition:2018
#![feature(must_not_suspend)]
#![deny(must_not_suspend)]
@@ -25,9 +22,6 @@ pub async fn uhoh() {
let _guard2 = r#dyn(); //~ ERROR boxed `Wow` trait object held across
other().await;
-
- drop(_guard1);
- drop(_guard2);
}
fn main() {
diff --git a/tests/ui/lint/must_not_suspend/trait.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/trait.stderr
index 8c8ad1f37..2c03f8e82 100644
--- a/tests/ui/lint/must_not_suspend/trait.drop_tracking.stderr
+++ b/tests/ui/lint/must_not_suspend/trait.stderr
@@ -1,5 +1,5 @@
error: implementer of `Wow` held across a suspend point, but should not be
- --> $DIR/trait.rs:24:9
+ --> $DIR/trait.rs:21:9
|
LL | let _guard1 = r#impl();
| ^^^^^^^
@@ -8,18 +8,18 @@ LL | other().await;
| ----- the value is held across this suspend point
|
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/trait.rs:24:9
+ --> $DIR/trait.rs:21:9
|
LL | let _guard1 = r#impl();
| ^^^^^^^
note: the lint level is defined here
- --> $DIR/trait.rs:6:9
+ --> $DIR/trait.rs:3:9
|
LL | #![deny(must_not_suspend)]
| ^^^^^^^^^^^^^^^^
error: boxed `Wow` trait object held across a suspend point, but should not be
- --> $DIR/trait.rs:25:9
+ --> $DIR/trait.rs:22:9
|
LL | let _guard2 = r#dyn();
| ^^^^^^^
@@ -28,7 +28,7 @@ LL | other().await;
| ----- the value is held across this suspend point
|
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/trait.rs:25:9
+ --> $DIR/trait.rs:22:9
|
LL | let _guard2 = r#dyn();
| ^^^^^^^
diff --git a/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr
deleted file mode 100644
index e24cffdd0..000000000
--- a/tests/ui/lint/must_not_suspend/unit.drop_tracking_mir.stderr
+++ /dev/null
@@ -1,26 +0,0 @@
-error: `Umm` held across a suspend point, but should not be
- --> $DIR/unit.rs:22:9
- |
-LL | let _guard = bar();
- | ^^^^^^
-LL | other().await;
- | ----- the value is held across this suspend point
- |
-note: You gotta use Umm's, ya know?
- --> $DIR/unit.rs:22:9
- |
-LL | let _guard = bar();
- | ^^^^^^
-help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/unit.rs:22:9
- |
-LL | let _guard = bar();
- | ^^^^^^
-note: the lint level is defined here
- --> $DIR/unit.rs:6:9
- |
-LL | #![deny(must_not_suspend)]
- | ^^^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr
deleted file mode 100644
index e24cffdd0..000000000
--- a/tests/ui/lint/must_not_suspend/unit.no_drop_tracking.stderr
+++ /dev/null
@@ -1,26 +0,0 @@
-error: `Umm` held across a suspend point, but should not be
- --> $DIR/unit.rs:22:9
- |
-LL | let _guard = bar();
- | ^^^^^^
-LL | other().await;
- | ----- the value is held across this suspend point
- |
-note: You gotta use Umm's, ya know?
- --> $DIR/unit.rs:22:9
- |
-LL | let _guard = bar();
- | ^^^^^^
-help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/unit.rs:22:9
- |
-LL | let _guard = bar();
- | ^^^^^^
-note: the lint level is defined here
- --> $DIR/unit.rs:6:9
- |
-LL | #![deny(must_not_suspend)]
- | ^^^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/tests/ui/lint/must_not_suspend/unit.rs b/tests/ui/lint/must_not_suspend/unit.rs
index fbc51b366..af4a76caa 100644
--- a/tests/ui/lint/must_not_suspend/unit.rs
+++ b/tests/ui/lint/must_not_suspend/unit.rs
@@ -1,6 +1,3 @@
-// revisions: no_drop_tracking drop_tracking drop_tracking_mir
-// [drop_tracking] compile-flags: -Zdrop-tracking
-// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir
// edition:2018
#![feature(must_not_suspend)]
#![deny(must_not_suspend)]
@@ -10,6 +7,7 @@ struct Umm {
i: i64
}
+
fn bar() -> Umm {
Umm {
i: 1
diff --git a/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/unit.stderr
index e24cffdd0..11c95c146 100644
--- a/tests/ui/lint/must_not_suspend/unit.drop_tracking.stderr
+++ b/tests/ui/lint/must_not_suspend/unit.stderr
@@ -1,5 +1,5 @@
error: `Umm` held across a suspend point, but should not be
- --> $DIR/unit.rs:22:9
+ --> $DIR/unit.rs:20:9
|
LL | let _guard = bar();
| ^^^^^^
@@ -7,17 +7,17 @@ LL | other().await;
| ----- the value is held across this suspend point
|
note: You gotta use Umm's, ya know?
- --> $DIR/unit.rs:22:9
+ --> $DIR/unit.rs:20:9
|
LL | let _guard = bar();
| ^^^^^^
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/unit.rs:22:9
+ --> $DIR/unit.rs:20:9
|
LL | let _guard = bar();
| ^^^^^^
note: the lint level is defined here
- --> $DIR/unit.rs:6:9
+ --> $DIR/unit.rs:3:9
|
LL | #![deny(must_not_suspend)]
| ^^^^^^^^^^^^^^^^
diff --git a/tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr b/tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr
deleted file mode 100644
index 4f7b40a5e..000000000
--- a/tests/ui/lint/must_not_suspend/warn.drop_tracking.stderr
+++ /dev/null
@@ -1,26 +0,0 @@
-warning: `Umm` held across a suspend point, but should not be
- --> $DIR/warn.rs:24:9
- |
-LL | let _guard = bar();
- | ^^^^^^
-LL | other().await;
- | ----- the value is held across this suspend point
- |
-note: You gotta use Umm's, ya know?
- --> $DIR/warn.rs:24:9
- |
-LL | let _guard = bar();
- | ^^^^^^
-help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/warn.rs:24:9
- |
-LL | let _guard = bar();
- | ^^^^^^
-note: the lint level is defined here
- --> $DIR/warn.rs:7:9
- |
-LL | #![warn(must_not_suspend)]
- | ^^^^^^^^^^^^^^^^
-
-warning: 1 warning emitted
-
diff --git a/tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr b/tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr
deleted file mode 100644
index 4f7b40a5e..000000000
--- a/tests/ui/lint/must_not_suspend/warn.no_drop_tracking.stderr
+++ /dev/null
@@ -1,26 +0,0 @@
-warning: `Umm` held across a suspend point, but should not be
- --> $DIR/warn.rs:24:9
- |
-LL | let _guard = bar();
- | ^^^^^^
-LL | other().await;
- | ----- the value is held across this suspend point
- |
-note: You gotta use Umm's, ya know?
- --> $DIR/warn.rs:24:9
- |
-LL | let _guard = bar();
- | ^^^^^^
-help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/warn.rs:24:9
- |
-LL | let _guard = bar();
- | ^^^^^^
-note: the lint level is defined here
- --> $DIR/warn.rs:7:9
- |
-LL | #![warn(must_not_suspend)]
- | ^^^^^^^^^^^^^^^^
-
-warning: 1 warning emitted
-
diff --git a/tests/ui/lint/must_not_suspend/warn.rs b/tests/ui/lint/must_not_suspend/warn.rs
index 5a4863169..2d5dd01e5 100644
--- a/tests/ui/lint/must_not_suspend/warn.rs
+++ b/tests/ui/lint/must_not_suspend/warn.rs
@@ -1,6 +1,3 @@
-// revisions: no_drop_tracking drop_tracking drop_tracking_mir
-// [drop_tracking] compile-flags: -Zdrop-tracking
-// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir
// edition:2018
// run-pass
#![feature(must_not_suspend)]
@@ -21,9 +18,9 @@ fn bar() -> Umm {
async fn other() {}
pub async fn uhoh() {
- let _guard = bar(); //~ WARNING `Umm` held across
+ let guard = bar(); //~ WARNING `Umm` held across
other().await;
- drop(_guard);
+ drop(guard);
}
fn main() {
diff --git a/tests/ui/lint/must_not_suspend/warn.drop_tracking_mir.stderr b/tests/ui/lint/must_not_suspend/warn.stderr
index 4f7b40a5e..e59656e50 100644
--- a/tests/ui/lint/must_not_suspend/warn.drop_tracking_mir.stderr
+++ b/tests/ui/lint/must_not_suspend/warn.stderr
@@ -1,23 +1,23 @@
warning: `Umm` held across a suspend point, but should not be
- --> $DIR/warn.rs:24:9
+ --> $DIR/warn.rs:21:9
|
-LL | let _guard = bar();
- | ^^^^^^
+LL | let guard = bar();
+ | ^^^^^
LL | other().await;
| ----- the value is held across this suspend point
|
note: You gotta use Umm's, ya know?
- --> $DIR/warn.rs:24:9
+ --> $DIR/warn.rs:21:9
|
-LL | let _guard = bar();
- | ^^^^^^
+LL | let guard = bar();
+ | ^^^^^
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
- --> $DIR/warn.rs:24:9
+ --> $DIR/warn.rs:21:9
|
-LL | let _guard = bar();
- | ^^^^^^
+LL | let guard = bar();
+ | ^^^^^
note: the lint level is defined here
- --> $DIR/warn.rs:7:9
+ --> $DIR/warn.rs:4:9
|
LL | #![warn(must_not_suspend)]
| ^^^^^^^^^^^^^^^^
diff --git a/tests/ui/lint/no-coverage.rs b/tests/ui/lint/no-coverage.rs
index 07906a434..907d25d33 100644
--- a/tests/ui/lint/no-coverage.rs
+++ b/tests/ui/lint/no-coverage.rs
@@ -1,55 +1,55 @@
#![feature(extern_types)]
-#![feature(no_coverage)]
+#![feature(coverage_attribute)]
#![feature(impl_trait_in_assoc_type)]
#![warn(unused_attributes)]
-#![no_coverage]
-//~^ WARN: `#[no_coverage]` does not propagate into items and must be applied to the contained functions directly
+#![coverage(off)]
+//~^ WARN: `#[coverage]` does not propagate into items and must be applied to the contained functions directly
-#[no_coverage]
-//~^ WARN: `#[no_coverage]` does not propagate into items and must be applied to the contained functions directly
+#[coverage(off)]
+//~^ WARN: `#[coverage]` does not propagate into items and must be applied to the contained functions directly
trait Trait {
- #[no_coverage] //~ ERROR `#[no_coverage]` must be applied to coverable code
+ #[coverage(off)] //~ ERROR `#[coverage]` must be applied to coverable code
const X: u32;
- #[no_coverage] //~ ERROR `#[no_coverage]` must be applied to coverable code
+ #[coverage(off)] //~ ERROR `#[coverage]` must be applied to coverable code
type T;
type U;
}
-#[no_coverage]
-//~^ WARN: `#[no_coverage]` does not propagate into items and must be applied to the contained functions directly
+#[coverage(off)]
+//~^ WARN: `#[coverage]` does not propagate into items and must be applied to the contained functions directly
impl Trait for () {
const X: u32 = 0;
- #[no_coverage] //~ ERROR `#[no_coverage]` must be applied to coverable code
+ #[coverage(off)] //~ ERROR `#[coverage]` must be applied to coverable code
type T = Self;
- #[no_coverage] //~ ERROR `#[no_coverage]` must be applied to coverable code
+ #[coverage(off)] //~ ERROR `#[coverage]` must be applied to coverable code
type U = impl Trait; //~ ERROR unconstrained opaque type
}
extern "C" {
- #[no_coverage] //~ ERROR `#[no_coverage]` must be applied to coverable code
+ #[coverage(off)] //~ ERROR `#[coverage]` must be applied to coverable code
static X: u32;
- #[no_coverage] //~ ERROR `#[no_coverage]` must be applied to coverable code
+ #[coverage(off)] //~ ERROR `#[coverage]` must be applied to coverable code
type T;
}
-#[no_coverage]
+#[coverage(off)]
fn main() {
- #[no_coverage]
- //~^ WARN `#[no_coverage]` may only be applied to function definitions
+ #[coverage(off)]
+ //~^ WARN `#[coverage]` may only be applied to function definitions
let _ = ();
match () {
- #[no_coverage]
- //~^ WARN `#[no_coverage]` may only be applied to function definitions
+ #[coverage(off)]
+ //~^ WARN `#[coverage]` may only be applied to function definitions
() => (),
}
- #[no_coverage]
- //~^ WARN `#[no_coverage]` may only be applied to function definitions
+ #[coverage(off)]
+ //~^ WARN `#[coverage]` may only be applied to function definitions
return ();
}
diff --git a/tests/ui/lint/no-coverage.stderr b/tests/ui/lint/no-coverage.stderr
index 404efbeac..a87b0fb49 100644
--- a/tests/ui/lint/no-coverage.stderr
+++ b/tests/ui/lint/no-coverage.stderr
@@ -1,8 +1,8 @@
-warning: `#[no_coverage]` does not propagate into items and must be applied to the contained functions directly
+warning: `#[coverage]` does not propagate into items and must be applied to the contained functions directly
--> $DIR/no-coverage.rs:8:1
|
-LL | #[no_coverage]
- | ^^^^^^^^^^^^^^
+LL | #[coverage(off)]
+ | ^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/no-coverage.rs:4:9
@@ -10,83 +10,83 @@ note: the lint level is defined here
LL | #![warn(unused_attributes)]
| ^^^^^^^^^^^^^^^^^
-warning: `#[no_coverage]` does not propagate into items and must be applied to the contained functions directly
+warning: `#[coverage]` does not propagate into items and must be applied to the contained functions directly
--> $DIR/no-coverage.rs:20:1
|
-LL | #[no_coverage]
- | ^^^^^^^^^^^^^^
+LL | #[coverage(off)]
+ | ^^^^^^^^^^^^^^^^
-warning: `#[no_coverage]` may only be applied to function definitions
+warning: `#[coverage]` may only be applied to function definitions
--> $DIR/no-coverage.rs:42:5
|
-LL | #[no_coverage]
- | ^^^^^^^^^^^^^^
+LL | #[coverage(off)]
+ | ^^^^^^^^^^^^^^^^
-warning: `#[no_coverage]` may only be applied to function definitions
+warning: `#[coverage]` may only be applied to function definitions
--> $DIR/no-coverage.rs:47:9
|
-LL | #[no_coverage]
- | ^^^^^^^^^^^^^^
+LL | #[coverage(off)]
+ | ^^^^^^^^^^^^^^^^
-warning: `#[no_coverage]` may only be applied to function definitions
+warning: `#[coverage]` may only be applied to function definitions
--> $DIR/no-coverage.rs:52:5
|
-LL | #[no_coverage]
- | ^^^^^^^^^^^^^^
+LL | #[coverage(off)]
+ | ^^^^^^^^^^^^^^^^
-error[E0788]: `#[no_coverage]` must be applied to coverable code
+error[E0788]: `#[coverage]` must be applied to coverable code
--> $DIR/no-coverage.rs:11:5
|
-LL | #[no_coverage]
- | ^^^^^^^^^^^^^^
+LL | #[coverage(off)]
+ | ^^^^^^^^^^^^^^^^
LL | const X: u32;
| ------------- not coverable code
-error[E0788]: `#[no_coverage]` must be applied to coverable code
+error[E0788]: `#[coverage]` must be applied to coverable code
--> $DIR/no-coverage.rs:14:5
|
-LL | #[no_coverage]
- | ^^^^^^^^^^^^^^
+LL | #[coverage(off)]
+ | ^^^^^^^^^^^^^^^^
LL | type T;
| ------- not coverable code
-error[E0788]: `#[no_coverage]` must be applied to coverable code
+error[E0788]: `#[coverage]` must be applied to coverable code
--> $DIR/no-coverage.rs:25:5
|
-LL | #[no_coverage]
- | ^^^^^^^^^^^^^^
+LL | #[coverage(off)]
+ | ^^^^^^^^^^^^^^^^
LL | type T = Self;
| -------------- not coverable code
-error[E0788]: `#[no_coverage]` must be applied to coverable code
+error[E0788]: `#[coverage]` must be applied to coverable code
--> $DIR/no-coverage.rs:28:5
|
-LL | #[no_coverage]
- | ^^^^^^^^^^^^^^
+LL | #[coverage(off)]
+ | ^^^^^^^^^^^^^^^^
LL | type U = impl Trait;
| -------------------- not coverable code
-error[E0788]: `#[no_coverage]` must be applied to coverable code
+error[E0788]: `#[coverage]` must be applied to coverable code
--> $DIR/no-coverage.rs:33:5
|
-LL | #[no_coverage]
- | ^^^^^^^^^^^^^^
+LL | #[coverage(off)]
+ | ^^^^^^^^^^^^^^^^
LL | static X: u32;
| -------------- not coverable code
-error[E0788]: `#[no_coverage]` must be applied to coverable code
+error[E0788]: `#[coverage]` must be applied to coverable code
--> $DIR/no-coverage.rs:36:5
|
-LL | #[no_coverage]
- | ^^^^^^^^^^^^^^
+LL | #[coverage(off)]
+ | ^^^^^^^^^^^^^^^^
LL | type T;
| ------- not coverable code
-warning: `#[no_coverage]` does not propagate into items and must be applied to the contained functions directly
+warning: `#[coverage]` does not propagate into items and must be applied to the contained functions directly
--> $DIR/no-coverage.rs:5:1
|
-LL | #![no_coverage]
- | ^^^^^^^^^^^^^^^
+LL | #![coverage(off)]
+ | ^^^^^^^^^^^^^^^^^
error: unconstrained opaque type
--> $DIR/no-coverage.rs:29:14
diff --git a/tests/ui/lint/noop-method-call.fixed b/tests/ui/lint/noop-method-call.fixed
index eeb80279f..4d9834f7d 100644
--- a/tests/ui/lint/noop-method-call.fixed
+++ b/tests/ui/lint/noop-method-call.fixed
@@ -1,6 +1,7 @@
// check-pass
// run-rustfix
+#![feature(rustc_attrs)]
#![allow(unused)]
use std::borrow::Borrow;
@@ -49,3 +50,15 @@ fn non_generic(non_clone_type: &PlainType<u32>) {
non_clone_type;
//~^ WARN call to `.clone()` on a reference in this situation does nothing
}
+
+struct DiagnosticClone;
+impl Clone for DiagnosticClone {
+ #[rustc_diagnostic_item = "other_clone"]
+ fn clone(&self) -> Self {
+ DiagnosticClone
+ }
+}
+
+fn with_other_diagnostic_item(x: DiagnosticClone) {
+ x.clone();
+}
diff --git a/tests/ui/lint/noop-method-call.rs b/tests/ui/lint/noop-method-call.rs
index 9569a0dfc..6242a00e0 100644
--- a/tests/ui/lint/noop-method-call.rs
+++ b/tests/ui/lint/noop-method-call.rs
@@ -1,6 +1,7 @@
// check-pass
// run-rustfix
+#![feature(rustc_attrs)]
#![allow(unused)]
use std::borrow::Borrow;
@@ -49,3 +50,15 @@ fn non_generic(non_clone_type: &PlainType<u32>) {
non_clone_type.clone();
//~^ WARN call to `.clone()` on a reference in this situation does nothing
}
+
+struct DiagnosticClone;
+impl Clone for DiagnosticClone {
+ #[rustc_diagnostic_item = "other_clone"]
+ fn clone(&self) -> Self {
+ DiagnosticClone
+ }
+}
+
+fn with_other_diagnostic_item(x: DiagnosticClone) {
+ x.clone();
+}
diff --git a/tests/ui/lint/noop-method-call.stderr b/tests/ui/lint/noop-method-call.stderr
index aefc2706f..d04f44022 100644
--- a/tests/ui/lint/noop-method-call.stderr
+++ b/tests/ui/lint/noop-method-call.stderr
@@ -1,5 +1,5 @@
warning: call to `.clone()` on a reference in this situation does nothing
- --> $DIR/noop-method-call.rs:15:25
+ --> $DIR/noop-method-call.rs:16:25
|
LL | let _ = &mut encoded.clone();
| ^^^^^^^^ help: remove this redundant call
@@ -8,7 +8,7 @@ LL | let _ = &mut encoded.clone();
= note: `#[warn(noop_method_call)]` on by default
warning: call to `.clone()` on a reference in this situation does nothing
- --> $DIR/noop-method-call.rs:17:21
+ --> $DIR/noop-method-call.rs:18:21
|
LL | let _ = &encoded.clone();
| ^^^^^^^^ help: remove this redundant call
@@ -16,7 +16,7 @@ LL | let _ = &encoded.clone();
= note: the type `[u8]` does not implement `Clone`, so calling `clone` on `&[u8]` copies the reference, which does not do anything and can be removed
warning: call to `.clone()` on a reference in this situation does nothing
- --> $DIR/noop-method-call.rs:23:71
+ --> $DIR/noop-method-call.rs:24:71
|
LL | let non_clone_type_ref_clone: &PlainType<u32> = non_clone_type_ref.clone();
| ^^^^^^^^ help: remove this redundant call
@@ -24,7 +24,7 @@ LL | let non_clone_type_ref_clone: &PlainType<u32> = non_clone_type_ref.clon
= note: the type `PlainType<u32>` does not implement `Clone`, so calling `clone` on `&PlainType<u32>` copies the reference, which does not do anything and can be removed
warning: call to `.deref()` on a reference in this situation does nothing
- --> $DIR/noop-method-call.rs:31:63
+ --> $DIR/noop-method-call.rs:32:63
|
LL | let non_deref_type_deref: &PlainType<u32> = non_deref_type.deref();
| ^^^^^^^^ help: remove this redundant call
@@ -32,7 +32,7 @@ LL | let non_deref_type_deref: &PlainType<u32> = non_deref_type.deref();
= note: the type `PlainType<u32>` does not implement `Deref`, so calling `deref` on `&PlainType<u32>` copies the reference, which does not do anything and can be removed
warning: call to `.borrow()` on a reference in this situation does nothing
- --> $DIR/noop-method-call.rs:35:66
+ --> $DIR/noop-method-call.rs:36:66
|
LL | let non_borrow_type_borrow: &PlainType<u32> = non_borrow_type.borrow();
| ^^^^^^^^^ help: remove this redundant call
@@ -40,7 +40,7 @@ LL | let non_borrow_type_borrow: &PlainType<u32> = non_borrow_type.borrow();
= note: the type `PlainType<u32>` does not implement `Borrow`, so calling `borrow` on `&PlainType<u32>` copies the reference, which does not do anything and can be removed
warning: call to `.clone()` on a reference in this situation does nothing
- --> $DIR/noop-method-call.rs:44:19
+ --> $DIR/noop-method-call.rs:45:19
|
LL | non_clone_type.clone();
| ^^^^^^^^ help: remove this redundant call
@@ -48,7 +48,7 @@ LL | non_clone_type.clone();
= note: the type `PlainType<T>` does not implement `Clone`, so calling `clone` on `&PlainType<T>` copies the reference, which does not do anything and can be removed
warning: call to `.clone()` on a reference in this situation does nothing
- --> $DIR/noop-method-call.rs:49:19
+ --> $DIR/noop-method-call.rs:50:19
|
LL | non_clone_type.clone();
| ^^^^^^^^ help: remove this redundant call
diff --git a/tests/ui/lint/ptr_null_checks.rs b/tests/ui/lint/ptr_null_checks.rs
index e677ea309..3028084e9 100644
--- a/tests/ui/lint/ptr_null_checks.rs
+++ b/tests/ui/lint/ptr_null_checks.rs
@@ -38,15 +38,15 @@ fn main() {
if (&mut 8 as *mut i32).is_null() {}
//~^ WARN references are not nullable
if ptr::from_mut(&mut 8).is_null() {}
- //~^ WARN references are not nullable
+ //~^ WARN call is never null
if (&8 as *const i32).is_null() {}
//~^ WARN references are not nullable
if ptr::from_ref(&8).is_null() {}
- //~^ WARN references are not nullable
+ //~^ WARN call is never null
if ptr::from_ref(&8).cast_mut().is_null() {}
- //~^ WARN references are not nullable
+ //~^ WARN call is never null
if (ptr::from_ref(&8).cast_mut() as *mut i32).is_null() {}
- //~^ WARN references are not nullable
+ //~^ WARN call is never null
if (&8 as *const i32) == std::ptr::null() {}
//~^ WARN references are not nullable
let ref_num = &8;
@@ -65,6 +65,12 @@ fn main() {
if (&*{ static_i32() } as *const i32).is_null() {}
//~^ WARN references are not nullable
+ // ---------------- Functions -------------------
+ if ptr::NonNull::new(&mut 8).unwrap().as_ptr().is_null() {}
+ //~^ WARN call is never null
+ if ptr::NonNull::<u8>::dangling().as_ptr().is_null() {}
+ //~^ WARN call is never null
+
// ----------------------------------------------
const ZPTR: *const () = 0 as *const _;
const NOT_ZPTR: *const () = 1 as *const _;
diff --git a/tests/ui/lint/ptr_null_checks.stderr b/tests/ui/lint/ptr_null_checks.stderr
index 3cee1804b..0edc1b865 100644
--- a/tests/ui/lint/ptr_null_checks.stderr
+++ b/tests/ui/lint/ptr_null_checks.stderr
@@ -117,13 +117,11 @@ LL | if (&mut 8 as *mut i32).is_null() {}
| |
| expression has type `&mut i32`
-warning: references are not nullable, so checking them for null will always return false
+warning: returned pointer of `from_mut` call is never null, so checking it for null will always return false
--> $DIR/ptr_null_checks.rs:40:8
|
LL | if ptr::from_mut(&mut 8).is_null() {}
- | ^^^^^^^^^^^^^^------^^^^^^^^^^^
- | |
- | expression has type `&mut i32`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: references are not nullable, so checking them for null will always return false
--> $DIR/ptr_null_checks.rs:42:8
@@ -133,29 +131,23 @@ LL | if (&8 as *const i32).is_null() {}
| |
| expression has type `&i32`
-warning: references are not nullable, so checking them for null will always return false
+warning: returned pointer of `from_ref` call is never null, so checking it for null will always return false
--> $DIR/ptr_null_checks.rs:44:8
|
LL | if ptr::from_ref(&8).is_null() {}
- | ^^^^^^^^^^^^^^--^^^^^^^^^^^
- | |
- | expression has type `&i32`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
-warning: references are not nullable, so checking them for null will always return false
+warning: returned pointer of `from_ref` call is never null, so checking it for null will always return false
--> $DIR/ptr_null_checks.rs:46:8
|
LL | if ptr::from_ref(&8).cast_mut().is_null() {}
- | ^^^^^^^^^^^^^^--^^^^^^^^^^^^^^^^^^^^^^
- | |
- | expression has type `&i32`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-warning: references are not nullable, so checking them for null will always return false
+warning: returned pointer of `from_ref` call is never null, so checking it for null will always return false
--> $DIR/ptr_null_checks.rs:48:8
|
LL | if (ptr::from_ref(&8).cast_mut() as *mut i32).is_null() {}
- | ^^^^^^^^^^^^^^^--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- | |
- | expression has type `&i32`
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: references are not nullable, so checking them for null will always return false
--> $DIR/ptr_null_checks.rs:50:8
@@ -221,5 +213,17 @@ LL | if (&*{ static_i32() } as *const i32).is_null() {}
| |
| expression has type `&i32`
-warning: 25 warnings emitted
+warning: returned pointer of `as_ptr` call is never null, so checking it for null will always return false
+ --> $DIR/ptr_null_checks.rs:69:8
+ |
+LL | if ptr::NonNull::new(&mut 8).unwrap().as_ptr().is_null() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: returned pointer of `as_ptr` call is never null, so checking it for null will always return false
+ --> $DIR/ptr_null_checks.rs:71:8
+ |
+LL | if ptr::NonNull::<u8>::dangling().as_ptr().is_null() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: 27 warnings emitted
diff --git a/tests/ui/lint/reference_casting.rs b/tests/ui/lint/reference_casting.rs
index 6c38bca3d..fba8789e9 100644
--- a/tests/ui/lint/reference_casting.rs
+++ b/tests/ui/lint/reference_casting.rs
@@ -36,6 +36,12 @@ unsafe fn ref_to_mut() {
//~^ ERROR casting `&T` to `&mut T` is undefined behavior
let _num = &mut *std::mem::transmute::<_, *mut i32>(num);
//~^ ERROR casting `&T` to `&mut T` is undefined behavior
+ let _num = &mut *(std::mem::transmute::<_, *mut i32>(num) as *mut i32);
+ //~^ ERROR casting `&T` to `&mut T` is undefined behavior
+ let _num = &mut *std::cell::UnsafeCell::raw_get(
+ //~^ ERROR casting `&T` to `&mut T` is undefined behavior
+ num as *const i32 as *const std::cell::UnsafeCell<i32>
+ );
let deferred = num as *const i32 as *mut i32;
let _num = &mut *deferred;
@@ -43,13 +49,35 @@ unsafe fn ref_to_mut() {
let deferred = (std::ptr::from_ref(num) as *const i32 as *const i32).cast_mut() as *mut i32;
let _num = &mut *deferred;
//~^ ERROR casting `&T` to `&mut T` is undefined behavior
+ let deferred_rebind = deferred;
+ let _num = &mut *deferred_rebind;
+ //~^ ERROR casting `&T` to `&mut T` is undefined behavior
let _num = &mut *(num as *const _ as usize as *mut i32);
//~^ ERROR casting `&T` to `&mut T` is undefined behavior
+ let _num = &mut *(std::mem::transmute::<_, *mut _>(num as *const i32) as *mut i32);
+ //~^ ERROR casting `&T` to `&mut T` is undefined behavior
+
+ static NUM: &'static i32 = &2;
+ let num = NUM as *const i32 as *mut i32;
+ let num = num;
+ let num = num;
+ let _num = &mut *num;
+ //~^ ERROR casting `&T` to `&mut T` is undefined behavior
unsafe fn generic_ref_cast_mut<T>(this: &T) -> &mut T {
&mut *((this as *const _) as *mut _)
//~^ ERROR casting `&T` to `&mut T` is undefined behavior
}
+
+ fn as_mut<T>(x: &T) -> &mut T {
+ unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *const _) }
+ //~^ ERROR casting `&T` to `&mut T` is undefined behavior
+ }
+
+ fn as_mut_i32(x: &i32) -> &mut i32 {
+ unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *const _) }
+ //~^ ERROR casting `&T` to `&mut T` is undefined behavior
+ }
}
unsafe fn assign_to_ref() {
@@ -71,14 +99,30 @@ unsafe fn assign_to_ref() {
//~^ ERROR assigning to `&T` is undefined behavior
*std::mem::transmute::<_, *mut i32>(num) += 1;
//~^ ERROR assigning to `&T` is undefined behavior
+ *(std::mem::transmute::<_, *mut i32>(num) as *mut i32) += 1;
+ //~^ ERROR assigning to `&T` is undefined behavior
+ std::ptr::write(
+ //~^ ERROR assigning to `&T` is undefined behavior
+ std::mem::transmute::<*const i32, *mut i32>(num),
+ -1i32,
+ );
let value = num as *const i32 as *mut i32;
*value = 1;
//~^ ERROR assigning to `&T` is undefined behavior
+ let value_rebind = value;
+ *value_rebind = 1;
+ //~^ ERROR assigning to `&T` is undefined behavior
*(num as *const i32).cast::<i32>().cast_mut() = 2;
//~^ ERROR assigning to `&T` is undefined behavior
*(num as *const _ as usize as *mut i32) = 2;
//~^ ERROR assigning to `&T` is undefined behavior
+ std::ptr::write(value, 2);
+ //~^ ERROR assigning to `&T` is undefined behavior
+ std::ptr::write_unaligned(value, 2);
+ //~^ ERROR assigning to `&T` is undefined behavior
+ std::ptr::write_volatile(value, 2);
+ //~^ ERROR assigning to `&T` is undefined behavior
unsafe fn generic_assign_to_ref<T>(this: &T, a: T) {
*(this as *const _ as *mut _) = a;
@@ -86,6 +130,7 @@ unsafe fn assign_to_ref() {
}
}
+const RAW_PTR: *mut u8 = 1 as *mut u8;
unsafe fn no_warn() {
let num = &3i32;
let mut_num = &mut 3i32;
@@ -100,6 +145,23 @@ unsafe fn no_warn() {
let mut value = 3;
let value: *const i32 = &mut value;
*(value as *const i16 as *mut i16) = 42;
+ *RAW_PTR = 42; // RAW_PTR is defined outside the function body,
+ // make sure we don't ICE on it when trying to
+ // determine if we should lint on it or not.
+
+ fn safe_as_mut<T>(x: &std::cell::UnsafeCell<T>) -> &mut T {
+ unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *const _) }
+ }
+
+ fn cell_as_mut(x: &std::cell::Cell<i32>) -> &mut i32 {
+ unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *const _) }
+ }
+
+ #[repr(transparent)]
+ struct DoesContainUnsafeCell(std::cell::UnsafeCell<i32>);
+ fn safe_as_mut2(x: &DoesContainUnsafeCell) -> &mut DoesContainUnsafeCell {
+ unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *const _) }
+ }
}
fn main() {}
diff --git a/tests/ui/lint/reference_casting.stderr b/tests/ui/lint/reference_casting.stderr
index 7ff9b76a8..8f89cf980 100644
--- a/tests/ui/lint/reference_casting.stderr
+++ b/tests/ui/lint/reference_casting.stderr
@@ -4,6 +4,7 @@ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is
LL | let _num = &mut *(num as *const i32 as *mut i32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
= note: `#[deny(invalid_reference_casting)]` on by default
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
@@ -11,150 +12,328 @@ error: casting `&T` to `&mut T` is undefined behavior, even if the reference is
|
LL | let _num = &mut *(num as *const i32).cast_mut();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
--> $DIR/reference_casting.rs:23:16
|
LL | let _num = &mut *std::ptr::from_ref(num).cast_mut();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
--> $DIR/reference_casting.rs:25:16
|
LL | let _num = &mut *std::ptr::from_ref({ num }).cast_mut();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
--> $DIR/reference_casting.rs:27:16
|
LL | let _num = &mut *{ std::ptr::from_ref(num) }.cast_mut();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
--> $DIR/reference_casting.rs:29:16
|
LL | let _num = &mut *(std::ptr::from_ref({ num }) as *mut i32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
--> $DIR/reference_casting.rs:31:16
|
LL | let _num = &mut *(num as *const i32).cast::<i32>().cast_mut();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
--> $DIR/reference_casting.rs:33:16
|
LL | let _num = &mut *(num as *const i32).cast::<i32>().cast_mut().cast_const().cast_mut();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
--> $DIR/reference_casting.rs:35:16
|
LL | let _num = &mut *(std::ptr::from_ref(static_u8()) as *mut i32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
--> $DIR/reference_casting.rs:37:16
|
LL | let _num = &mut *std::mem::transmute::<_, *mut i32>(num);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
+
+error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
+ --> $DIR/reference_casting.rs:39:16
+ |
+LL | let _num = &mut *(std::mem::transmute::<_, *mut i32>(num) as *mut i32);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
--> $DIR/reference_casting.rs:41:16
|
+LL | let _num = &mut *std::cell::UnsafeCell::raw_get(
+ | ________________^
+LL | |
+LL | | num as *const i32 as *const std::cell::UnsafeCell<i32>
+LL | | );
+ | |_____^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
+
+error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
+ --> $DIR/reference_casting.rs:47:16
+ |
LL | let deferred = num as *const i32 as *mut i32;
| ----------------------------- casting happend here
LL | let _num = &mut *deferred;
| ^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
- --> $DIR/reference_casting.rs:44:16
+ --> $DIR/reference_casting.rs:50:16
|
LL | let deferred = (std::ptr::from_ref(num) as *const i32 as *const i32).cast_mut() as *mut i32;
| ---------------------------------------------------------------------------- casting happend here
LL | let _num = &mut *deferred;
| ^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
- --> $DIR/reference_casting.rs:46:16
+ --> $DIR/reference_casting.rs:53:16
+ |
+LL | let deferred = (std::ptr::from_ref(num) as *const i32 as *const i32).cast_mut() as *mut i32;
+ | ---------------------------------------------------------------------------- casting happend here
+...
+LL | let _num = &mut *deferred_rebind;
+ | ^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
+
+error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
+ --> $DIR/reference_casting.rs:55:16
|
LL | let _num = &mut *(num as *const _ as usize as *mut i32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
- --> $DIR/reference_casting.rs:50:9
+ --> $DIR/reference_casting.rs:57:16
+ |
+LL | let _num = &mut *(std::mem::transmute::<_, *mut _>(num as *const i32) as *mut i32);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
+
+error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
+ --> $DIR/reference_casting.rs:64:16
+ |
+LL | let num = NUM as *const i32 as *mut i32;
+ | ----------------------------- casting happend here
+...
+LL | let _num = &mut *num;
+ | ^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
+
+error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
+ --> $DIR/reference_casting.rs:68:9
|
LL | &mut *((this as *const _) as *mut _)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
+
+error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
+ --> $DIR/reference_casting.rs:73:18
+ |
+LL | unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *const _) }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
+
+error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell`
+ --> $DIR/reference_casting.rs:78:18
+ |
+LL | unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *const _) }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
- --> $DIR/reference_casting.rs:60:5
+ --> $DIR/reference_casting.rs:88:5
|
LL | *(a as *const _ as *mut _) = String::from("Replaced");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
- --> $DIR/reference_casting.rs:62:5
+ --> $DIR/reference_casting.rs:90:5
|
LL | *(a as *const _ as *mut String) += " world";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
- --> $DIR/reference_casting.rs:64:5
+ --> $DIR/reference_casting.rs:92:5
|
LL | *std::ptr::from_ref(num).cast_mut() += 1;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
- --> $DIR/reference_casting.rs:66:5
+ --> $DIR/reference_casting.rs:94:5
|
LL | *std::ptr::from_ref({ num }).cast_mut() += 1;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
- --> $DIR/reference_casting.rs:68:5
+ --> $DIR/reference_casting.rs:96:5
|
LL | *{ std::ptr::from_ref(num) }.cast_mut() += 1;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
- --> $DIR/reference_casting.rs:70:5
+ --> $DIR/reference_casting.rs:98:5
|
LL | *(std::ptr::from_ref({ num }) as *mut i32) += 1;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
- --> $DIR/reference_casting.rs:72:5
+ --> $DIR/reference_casting.rs:100:5
|
LL | *std::mem::transmute::<_, *mut i32>(num) += 1;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
+
+error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
+ --> $DIR/reference_casting.rs:102:5
+ |
+LL | *(std::mem::transmute::<_, *mut i32>(num) as *mut i32) += 1;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
- --> $DIR/reference_casting.rs:76:5
+ --> $DIR/reference_casting.rs:104:5
+ |
+LL | / std::ptr::write(
+LL | |
+LL | | std::mem::transmute::<*const i32, *mut i32>(num),
+LL | | -1i32,
+LL | | );
+ | |_____^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
+
+error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
+ --> $DIR/reference_casting.rs:111:5
|
LL | let value = num as *const i32 as *mut i32;
| ----------------------------- casting happend here
LL | *value = 1;
| ^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
+
+error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
+ --> $DIR/reference_casting.rs:114:5
+ |
+LL | let value = num as *const i32 as *mut i32;
+ | ----------------------------- casting happend here
+...
+LL | *value_rebind = 1;
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
- --> $DIR/reference_casting.rs:78:5
+ --> $DIR/reference_casting.rs:116:5
|
LL | *(num as *const i32).cast::<i32>().cast_mut() = 2;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
- --> $DIR/reference_casting.rs:80:5
+ --> $DIR/reference_casting.rs:118:5
|
LL | *(num as *const _ as usize as *mut i32) = 2;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
- --> $DIR/reference_casting.rs:84:9
+ --> $DIR/reference_casting.rs:120:5
+ |
+LL | let value = num as *const i32 as *mut i32;
+ | ----------------------------- casting happend here
+...
+LL | std::ptr::write(value, 2);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
+
+error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
+ --> $DIR/reference_casting.rs:122:5
+ |
+LL | let value = num as *const i32 as *mut i32;
+ | ----------------------------- casting happend here
+...
+LL | std::ptr::write_unaligned(value, 2);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
+
+error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
+ --> $DIR/reference_casting.rs:124:5
+ |
+LL | let value = num as *const i32 as *mut i32;
+ | ----------------------------- casting happend here
+...
+LL | std::ptr::write_volatile(value, 2);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
+
+error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`
+ --> $DIR/reference_casting.rs:128:9
|
LL | *(this as *const _ as *mut _) = a;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html>
-error: aborting due to 25 previous errors
+error: aborting due to 38 previous errors
diff --git a/tests/ui/lint/trivial_casts.stderr b/tests/ui/lint/trivial_casts.stderr
index 74f962835..5e2115574 100644
--- a/tests/ui/lint/trivial_casts.stderr
+++ b/tests/ui/lint/trivial_casts.stderr
@@ -128,7 +128,7 @@ LL | let _ = &baz as &dyn Fn(i32);
|
= help: cast can be replaced by coercion; this might require a temporary variable
-error: trivial cast: `&[closure@$DIR/trivial_casts.rs:72:13: 72:22]` as `&dyn Fn(i32)`
+error: trivial cast: `&{closure@$DIR/trivial_casts.rs:72:13: 72:22}` as `&dyn Fn(i32)`
--> $DIR/trivial_casts.rs:73:13
|
LL | let _ = &x as &dyn Fn(i32);
diff --git a/tests/ui/lint/unused/unused-doc-comments-edge-cases.rs b/tests/ui/lint/unused/unused-doc-comments-edge-cases.rs
index 54d86c31f..ba32fb566 100644
--- a/tests/ui/lint/unused/unused-doc-comments-edge-cases.rs
+++ b/tests/ui/lint/unused/unused-doc-comments-edge-cases.rs
@@ -26,6 +26,32 @@ fn doc_comment_on_expr(num: u8) -> bool {
num == 3
}
+fn doc_comment_on_expr_field() -> bool {
+ struct S { foo: i32 }
+
+ let x = S {
+ /// useless doc comment
+ //~^ ERROR: unused doc comment
+ foo: 3
+ };
+
+ true
+}
+
+fn doc_comment_on_pat_field() -> bool {
+ struct S { foo: i32 }
+
+ let S {
+ /// useless doc comment
+ //~^ ERROR: unused doc comment
+ foo
+ } = S {
+ foo: 3
+ };
+
+ true
+}
+
fn doc_comment_on_generic<#[doc = "x"] T>(val: T) {}
//~^ ERROR: unused doc comment
diff --git a/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr b/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr
index 078b780d8..b5aa62157 100644
--- a/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr
+++ b/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr
@@ -42,7 +42,29 @@ LL | num == 3
= help: use `//` for a plain comment
error: unused doc comment
- --> $DIR/unused-doc-comments-edge-cases.rs:29:27
+ --> $DIR/unused-doc-comments-edge-cases.rs:33:9
+ |
+LL | /// useless doc comment
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | foo: 3
+ | ------ rustdoc does not generate documentation for expression fields
+ |
+ = help: use `//` for a plain comment
+
+error: unused doc comment
+ --> $DIR/unused-doc-comments-edge-cases.rs:45:9
+ |
+LL | /// useless doc comment
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+LL |
+LL | foo
+ | --- rustdoc does not generate documentation for pattern fields
+ |
+ = help: use `//` for a plain comment
+
+error: unused doc comment
+ --> $DIR/unused-doc-comments-edge-cases.rs:55:27
|
LL | fn doc_comment_on_generic<#[doc = "x"] T>(val: T) {}
| ^^^^^^^^^^^^ - rustdoc does not generate documentation for generic parameters
@@ -50,7 +72,7 @@ LL | fn doc_comment_on_generic<#[doc = "x"] T>(val: T) {}
= help: use `//` for a plain comment
error: unused doc comment
- --> $DIR/unused-doc-comments-edge-cases.rs:33:5
+ --> $DIR/unused-doc-comments-edge-cases.rs:59:5
|
LL | /// unused doc comment
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -63,7 +85,7 @@ LL | | }
= help: use `//` for a plain comment
error: unused doc comment
- --> $DIR/unused-doc-comments-edge-cases.rs:40:1
+ --> $DIR/unused-doc-comments-edge-cases.rs:66:1
|
LL | /// unused doc comment
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -89,7 +111,7 @@ help: you might have meant to return this value
LL | return true;
| ++++++ +
-error: aborting due to 8 previous errors
+error: aborting due to 10 previous errors
Some errors have detailed explanations: E0308, E0658.
For more information about an error, try `rustc --explain E0308`.
diff --git a/tests/ui/lint/unused/unused-parens-issue-106413.rs b/tests/ui/lint/unused/unused-parens-issue-106413.rs
new file mode 100644
index 000000000..7e76ab073
--- /dev/null
+++ b/tests/ui/lint/unused/unused-parens-issue-106413.rs
@@ -0,0 +1,32 @@
+// check-pass
+#![warn(unused_parens)]
+
+fn id<T>(t: T) -> T { t }
+
+fn main() {
+ // This should not warn
+ let _ = 1 as (i32) < 2;
+ let _ = id(1 as (i32) < 2);
+ let _ = id(1 as i32)
+ as (i32) < 2;
+ // These should warn
+ let _ = 1 as ((i32)) < 2; //~WARN unnecessary parentheses
+ let _ = 1 as (i32); //~WARN unnecessary parentheses
+ let _ = 1 as (i32) > 2; //~WARN unnecessary parentheses
+ let _ = id(1 as (i32)) //~WARN unnecessary parentheses
+ as (i32) < 2;
+ let _ = id(1 as (i32)) < 2; //~WARN unnecessary parentheses
+
+ // This should not warn
+ let _ = 1 as (i32) << 2;
+ let _ = id(1 as (i32) << 2);
+ let _ = id(1 as i32)
+ as (i32) << 2;
+ // These should warn
+ let _ = 1 as ((i32)) << 2; //~WARN unnecessary parentheses
+ let _ = 1 as (i32); //~WARN unnecessary parentheses
+ let _ = 1 as (i32) >> 2; //~WARN unnecessary parentheses
+ let _ = id(1 as (i32)) //~WARN unnecessary parentheses
+ as (i32) << 2;
+ let _ = id(1 as (i32)) << 2; //~WARN unnecessary parentheses
+}
diff --git a/tests/ui/lint/unused/unused-parens-issue-106413.stderr b/tests/ui/lint/unused/unused-parens-issue-106413.stderr
new file mode 100644
index 000000000..d2d8f76d9
--- /dev/null
+++ b/tests/ui/lint/unused/unused-parens-issue-106413.stderr
@@ -0,0 +1,127 @@
+warning: unnecessary parentheses around type
+ --> $DIR/unused-parens-issue-106413.rs:13:19
+ |
+LL | let _ = 1 as ((i32)) < 2;
+ | ^ ^
+ |
+note: the lint level is defined here
+ --> $DIR/unused-parens-issue-106413.rs:2:9
+ |
+LL | #![warn(unused_parens)]
+ | ^^^^^^^^^^^^^
+help: remove these parentheses
+ |
+LL - let _ = 1 as ((i32)) < 2;
+LL + let _ = 1 as (i32) < 2;
+ |
+
+warning: unnecessary parentheses around type
+ --> $DIR/unused-parens-issue-106413.rs:14:18
+ |
+LL | let _ = 1 as (i32);
+ | ^ ^
+ |
+help: remove these parentheses
+ |
+LL - let _ = 1 as (i32);
+LL + let _ = 1 as i32;
+ |
+
+warning: unnecessary parentheses around type
+ --> $DIR/unused-parens-issue-106413.rs:15:18
+ |
+LL | let _ = 1 as (i32) > 2;
+ | ^ ^
+ |
+help: remove these parentheses
+ |
+LL - let _ = 1 as (i32) > 2;
+LL + let _ = 1 as i32 > 2;
+ |
+
+warning: unnecessary parentheses around type
+ --> $DIR/unused-parens-issue-106413.rs:16:21
+ |
+LL | let _ = id(1 as (i32))
+ | ^ ^
+ |
+help: remove these parentheses
+ |
+LL - let _ = id(1 as (i32))
+LL + let _ = id(1 as i32)
+ |
+
+warning: unnecessary parentheses around type
+ --> $DIR/unused-parens-issue-106413.rs:18:21
+ |
+LL | let _ = id(1 as (i32)) < 2;
+ | ^ ^
+ |
+help: remove these parentheses
+ |
+LL - let _ = id(1 as (i32)) < 2;
+LL + let _ = id(1 as i32) < 2;
+ |
+
+warning: unnecessary parentheses around type
+ --> $DIR/unused-parens-issue-106413.rs:26:19
+ |
+LL | let _ = 1 as ((i32)) << 2;
+ | ^ ^
+ |
+help: remove these parentheses
+ |
+LL - let _ = 1 as ((i32)) << 2;
+LL + let _ = 1 as (i32) << 2;
+ |
+
+warning: unnecessary parentheses around type
+ --> $DIR/unused-parens-issue-106413.rs:27:18
+ |
+LL | let _ = 1 as (i32);
+ | ^ ^
+ |
+help: remove these parentheses
+ |
+LL - let _ = 1 as (i32);
+LL + let _ = 1 as i32;
+ |
+
+warning: unnecessary parentheses around type
+ --> $DIR/unused-parens-issue-106413.rs:28:18
+ |
+LL | let _ = 1 as (i32) >> 2;
+ | ^ ^
+ |
+help: remove these parentheses
+ |
+LL - let _ = 1 as (i32) >> 2;
+LL + let _ = 1 as i32 >> 2;
+ |
+
+warning: unnecessary parentheses around type
+ --> $DIR/unused-parens-issue-106413.rs:29:21
+ |
+LL | let _ = id(1 as (i32))
+ | ^ ^
+ |
+help: remove these parentheses
+ |
+LL - let _ = id(1 as (i32))
+LL + let _ = id(1 as i32)
+ |
+
+warning: unnecessary parentheses around type
+ --> $DIR/unused-parens-issue-106413.rs:31:21
+ |
+LL | let _ = id(1 as (i32)) << 2;
+ | ^ ^
+ |
+help: remove these parentheses
+ |
+LL - let _ = id(1 as (i32)) << 2;
+LL + let _ = id(1 as i32) << 2;
+ |
+
+warning: 10 warnings emitted
+