-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Erase late bound regions for dropped instances #107936
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include ../../run-make-fulldeps/tools.mk | ||
|
||
all: | ||
$(RUSTC) main.rs |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,16 @@ | ||||
use std::fmt; | ||||
|
||||
pub struct Wrapper(fn(val: &())); | ||||
|
||||
impl fmt::Debug for Wrapper { | ||||
fn fmt<'a>(&'a self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||||
f.debug_tuple("Wrapper").field(&self.0 as &fn(&'a ())).finish() | ||||
} | ||||
} | ||||
|
||||
fn useful(_: &()) { | ||||
} | ||||
|
||||
fn main() { | ||||
println!("{:?}", Wrapper(useful)); | ||||
} | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you try to turn this into a
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved it under |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I tried that but normalizing late bound regions is not enough in this case. There's still a mismatch because one symbol looks like
core::ptr::drop_in_place::<for<'a> fn(&'a ())>
and the other likecore::ptr::drop_in_place::<fn(&())>
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed my suggestion to use
erase_regions
that should erase everything.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, not sure actually. It's probably the instance resolution code that needs to be fortified against leaking regions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this already happening without desired effect wrt to this bug:
Instance::expect_resolve
->Instance::resolve
->Instance::resolve_opt_const_arg
->tcx.erase_regions(substs)
. Anyway, I'm going to give it a try.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I thought too, but it doesn't seem to be the case:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checked, it doesn't erase late bound regions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rust/compiler/rustc_middle/src/ty/erase_regions.rs
Lines 54 to 64 in b5c8c32
this is the
TypeFolder
invoked duringerase_regions