diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-10-24 15:48:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-24 15:48:45 +0200 |
| commit | d576393e347a2ab9126a83c992d922ba07a6f299 (patch) | |
| tree | f440b26366c42d3949a883ab09e54ed4ba841c24 /src/test | |
| parent | c16ee19dd4d81d3b1150d67cfb4ea84c826f4c36 (diff) | |
| parent | 4b970231fd1254580fbddabab74a125404fea0de (diff) | |
| download | rust-d576393e347a2ab9126a83c992d922ba07a6f299.tar.gz rust-d576393e347a2ab9126a83c992d922ba07a6f299.zip | |
Rollup merge of #90221 - JakobDegen:issue-90213, r=cjgillot
Fix ICE when forgetting to `Box` a parameter to a `Self::func` call Closes #90213 . Assuming we can get the `DefId` of the receiver causes an ICE if the receiver is `Self`. We can just avoid doing this though.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/suggestions/issue-90213-expected-boxfuture-self-ice.rs | 13 | ||||
| -rw-r--r-- | src/test/ui/suggestions/issue-90213-expected-boxfuture-self-ice.stderr | 17 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/test/ui/suggestions/issue-90213-expected-boxfuture-self-ice.rs b/src/test/ui/suggestions/issue-90213-expected-boxfuture-self-ice.rs new file mode 100644 index 00000000000..1e36b2fabf2 --- /dev/null +++ b/src/test/ui/suggestions/issue-90213-expected-boxfuture-self-ice.rs @@ -0,0 +1,13 @@ +// Checks that we do not ICE when comparing `Self` to `Pin` +// edition:2021 + +struct S; + +impl S { + fn foo(_: Box<Option<S>>) {} + fn bar() { + Self::foo(None) //~ ERROR mismatched types + } +} + +fn main() {} diff --git a/src/test/ui/suggestions/issue-90213-expected-boxfuture-self-ice.stderr b/src/test/ui/suggestions/issue-90213-expected-boxfuture-self-ice.stderr new file mode 100644 index 00000000000..c15b772b79c --- /dev/null +++ b/src/test/ui/suggestions/issue-90213-expected-boxfuture-self-ice.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/issue-90213-expected-boxfuture-self-ice.rs:9:19 + | +LL | Self::foo(None) + | ^^^^ expected struct `Box`, found enum `Option` + | + = note: expected struct `Box<Option<S>>` + found enum `Option<_>` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL | Self::foo(Box::new(None)) + | +++++++++ + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. |
