about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-02-15 06:41:35 +0000
committerbors <bors@rust-lang.org>2023-02-15 06:41:35 +0000
commite018a2c8bd8a9ae48b8a922e5eb4d4f565274ac7 (patch)
tree1c219a0e675166df7fe4cb36a68533dda36bbb58 /tests
parent4c28fddfa7b08f108bf147830c3bcad5760542ad (diff)
parent17cb2e47e5503494fa506af42be289f38a3a8d73 (diff)
downloadrust-e018a2c8bd8a9ae48b8a922e5eb4d4f565274ac7.tar.gz
rust-e018a2c8bd8a9ae48b8a922e5eb4d4f565274ac7.zip
Auto merge of #10328 - compiler-errors:fix-re-erased-in-needless_pass_by_value, r=matthiaskrgr
Liberate late-bound regions rather than erasing them in `needless_pass_by_value`

changelog: [`needless_pass_by_value`]: fixes an ICE when there are late-bound regions in function arguments that are needlessly passed by value

Fixes rust-lang/rust#107147
r? `@matthiaskrgr`
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/crashes/needless_pass_by_value-w-late-bound.rs9
-rw-r--r--tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr15
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/ui/crashes/needless_pass_by_value-w-late-bound.rs b/tests/ui/crashes/needless_pass_by_value-w-late-bound.rs
new file mode 100644
index 00000000000..dd3d8b8b6d1
--- /dev/null
+++ b/tests/ui/crashes/needless_pass_by_value-w-late-bound.rs
@@ -0,0 +1,9 @@
+// https://github.com/rust-lang/rust/issues/107147
+
+#![warn(clippy::needless_pass_by_value)]
+
+struct Foo<'a>(&'a [(); 100]);
+
+fn test(x: Foo<'_>) {}
+
+fn main() {}
diff --git a/tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr b/tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr
new file mode 100644
index 00000000000..7a0a648974f
--- /dev/null
+++ b/tests/ui/crashes/needless_pass_by_value-w-late-bound.stderr
@@ -0,0 +1,15 @@
+error: this argument is passed by value, but not consumed in the function body
+  --> $DIR/needless_pass_by_value-w-late-bound.rs:7:12
+   |
+LL | fn test(x: Foo<'_>) {}
+   |            ^^^^^^^ help: consider taking a reference instead: `&Foo<'_>`
+   |
+help: consider marking this type as `Copy`
+  --> $DIR/needless_pass_by_value-w-late-bound.rs:5:1
+   |
+LL | struct Foo<'a>(&'a [(); 100]);
+   | ^^^^^^^^^^^^^^
+   = note: `-D clippy::needless-pass-by-value` implied by `-D warnings`
+
+error: aborting due to previous error
+