Skip to content

Fix iteration of destructor checker. #27138

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

Closed
wants to merge 1 commit into from

Conversation

keiichiw
Copy link

Don't add a type to breadcrumbs vector when it is reference, pointer, or bare functions.
Fixes #25750

The following example contains two &Sized.

fn foo() -> Option<(Box<Fn(&Sized)>, Box<Fn(&Sized)>)> {
    None
}

So &Sized appears twice as typ here.
Each time &Sized appears, walker.skip_current_subtree() should be called here in this case.
However, if &Sized is pushed to breadcrumbs at the first appearance, skip_current_subtree() will not be called at the second time.

Don't add a type to breadcrumbs vector when it is reference, pointer, or bare functions.
Fixes rust-lang#25750
@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nrc (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@nrc
Copy link
Member

nrc commented Jul 20, 2015

reassigning to @pnkfelix because dropck.

r? @pnkfelix

@rust-highfive rust-highfive assigned pnkfelix and unassigned nrc Jul 20, 2015
@pnkfelix
Copy link
Member

Hmm, I'm worried this is papering over the real problem here. Namely, I would have thought that the two distinct instances of the Ty representing each occurrence of &Sized would not be considered Eq to each-other (since they have distinct inference variables for the implicit region sitting in there, i.e. &'_ Sized.

So I'm not going to immediately r+ this (but I'm not going to close the ticket either) ... I just want to take some time to investigate this myself directly, and figure out if I should be calling something other than breadcrumbs.contains in the code.


Update: Ah, of course; the types in question have the form for<'r> Fn(&'r S + 'r) by the time that dropck sees them, and it is stashing breadcrumbs that include the bound region 'r, even though those breadcrumbs don't make sense when we pop back out from the for <'r> ...

@pnkfelix
Copy link
Member

closing in favor of #27236. (but thank you so much for your investigative efforts, @kw-udon )

@pnkfelix pnkfelix closed this Jul 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants