Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix RPIT ICE for implicit HRTB when missing dyn #101468

Merged
merged 1 commit into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1568,8 +1568,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {

LifetimeRes::Fresh { param, binder: _ } => {
debug_assert_eq!(lifetime.ident.name, kw::UnderscoreLifetime);
let old_def_id = self.local_def_id(param);
if remapping.get(&old_def_id).is_none() {
if let Some(old_def_id) = self.opt_local_def_id(param) && remapping.get(&old_def_id).is_none() {
let node_id = self.next_node_id();

let new_def_id = self.create_def(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0277]: the trait bound `(): AsRef<(dyn for<'r> Fn(&'r ()) + 'static)>` is not satisfied
--> $DIR/generic-with-implicit-hrtb-without-dyn.rs:6:13
|
LL | fn ice() -> impl AsRef<Fn(&())> {
| ^^^^^^^^^^^^^^^^^^^ the trait `AsRef<(dyn for<'r> Fn(&'r ()) + 'static)>` is not implemented for `()`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
error[E0782]: trait objects must include the `dyn` keyword
--> $DIR/generic-with-implicit-hrtb-without-dyn.rs:6:24
|
LL | fn ice() -> impl AsRef<Fn(&())> {
| ^^^^^^^
|
help: add `dyn` keyword before this trait
|
LL - fn ice() -> impl AsRef<Fn(&())> {
LL + fn ice() -> impl AsRef<dyn Fn(&())> {
|

error[E0277]: the trait bound `(): AsRef<(dyn for<'r> Fn(&'r ()) + 'static)>` is not satisfied
--> $DIR/generic-with-implicit-hrtb-without-dyn.rs:6:13
|
LL | fn ice() -> impl AsRef<Fn(&())> {
| ^^^^^^^^^^^^^^^^^^^ the trait `AsRef<(dyn for<'r> Fn(&'r ()) + 'static)>` is not implemented for `()`

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0277, E0782.
For more information about an error, try `rustc --explain E0277`.
12 changes: 12 additions & 0 deletions src/test/ui/impl-trait/generic-with-implicit-hrtb-without-dyn.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// revisions: edition2015 edition2021
//[edition2021]edition:2021

#![allow(warnings)]

fn ice() -> impl AsRef<Fn(&())> {
spastorino marked this conversation as resolved.
Show resolved Hide resolved
//~^ ERROR: the trait bound `(): AsRef<(dyn for<'r> Fn(&'r ()) + 'static)>` is not satisfied [E0277]
//[edition2021]~| ERROR: trait objects must include the `dyn` keyword [E0782]
todo!()
}

fn main() {}