about summary refs log tree commit diff
path: root/src/test/ui/issues
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-04-05 01:53:32 +0200
committerGitHub <noreply@github.com>2022-04-05 01:53:32 +0200
commit92e53f5cc9216f019bc732741d13086f29855dc1 (patch)
tree68df1c5468cd96709148ffd4d43fbc2bff61f191 /src/test/ui/issues
parent3bf33b9060065b69f22c50d0ec924eaf51da830a (diff)
parentb899251f2dfe3a9849f844418e0d11e2073c2423 (diff)
downloadrust-92e53f5cc9216f019bc732741d13086f29855dc1.tar.gz
rust-92e53f5cc9216f019bc732741d13086f29855dc1.zip
Rollup merge of #95603 - compiler-errors:dyn-return, r=oli-obk
Fix late-bound ICE in `dyn` return type suggestion

This fixes the root-cause of the attached issues -- the root problem is that we're using the return type from a signature with late-bound instead of early-bound regions. The change on line 1087 (`let Some(liberated_sig) = typeck_results.liberated_fn_sigs().get(fn_hir_id) else { return false; };`) makes sure we're grabbing the _right_ return type for this suggestion to check the `dyn` predicates with.

Fixes #91801
Fixes #91803

This fix also includes some drive-by changes, specifically:

1. Don't suggest boxing when we have `-> dyn Trait` and are already returning `Box<T>` where `T: Trait` (before we always boxed the value).
2. Suggestion applies even when the return type is a type alias (e.g. `type Foo = dyn Trait`). This does cause the suggestion to expand to the aliased type, but I think it's still beneficial.
3. Split up the multipart suggestion because there's a 6-line max in the printed output...

I am open to splitting out the above changes, if we just want to fix the ICE first.

cc: ```@terrarier2111``` and #92289
Diffstat (limited to 'src/test/ui/issues')
-rw-r--r--src/test/ui/issues/issue-18107.stderr2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/test/ui/issues/issue-18107.stderr b/src/test/ui/issues/issue-18107.stderr
index 1eb6822b8a1..28478457b29 100644
--- a/src/test/ui/issues/issue-18107.stderr
+++ b/src/test/ui/issues/issue-18107.stderr
@@ -15,7 +15,7 @@ LL |     impl AbstractRenderer
 help: use a boxed trait object if all return paths implement trait `AbstractRenderer`
    |
 LL |     Box<dyn AbstractRenderer>
-   |
+   |     ++++                    +
 
 error: aborting due to previous error