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

dropck rule may have ample room for improvement #829

Closed
pnkfelix opened this issue Feb 11, 2015 · 2 comments
Closed

dropck rule may have ample room for improvement #829

pnkfelix opened this issue Feb 11, 2015 · 2 comments
Assignees
Labels
T-lang Relevant to the language team, which will review and decide on the RFC.

Comments

@pnkfelix
Copy link
Member

While writing the clarification PR #828, I realized there may be other ways to further narrow the Drop-Check rule in a sound manner. For example, if D has multiple type parameters where some are bounded and some are unbounded, it could be that the fact that the bounded type parameters could never actually gain access to the data of lifetime 'a.

More concretely:

trait Bound { fn act(&mut self); }
impl Bound for String { ... }
struct Two<A,B:Bound> { a: A, b: B }
impl<A,B:Bound> Drop for Two<A,B> { ... }
fn foo<'a>(t: Two<&'a u8, String>) { ... }

In the above example, I think one can argue that even though Two has a type parameter B with code that is effectively hidden from dropck, there is no way the impl Bound for String could access the &'a u8 that the A holds, and therefore we do not need to force 'a to strictly outlive t when dropck is analyzing fn foo.

This may actually matter in real code; I am imagining in particular the example of CheckedHashMap<K,V>, where a Eq+Hash bound on K need not restrict the choices that we select for V.

@pnkfelix
Copy link
Member Author

(this is essentially covered by the Eyepatch RFC PR #1327 , I think...)

@petrochenkov petrochenkov added the T-lang Relevant to the language team, which will review and decide on the RFC. label Jan 30, 2018
@Centril
Copy link
Contributor

Centril commented Oct 7, 2018

Closing since this is essentially covered by #1327.

@Centril Centril closed this as completed Oct 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-lang Relevant to the language team, which will review and decide on the RFC.
Projects
None yet
Development

No branches or pull requests

4 participants