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

Refactor TypeContents to be more scrutable. In particular, do not requir... #10158

Conversation

nikomatsakis
Copy link
Contributor

...e types

to register such fine-grained distinctions, but rather focus on the end
properties we're trying to compute. Also, cleanly distinguish when properties
must be found in owned types vs reachable types.

Fixes #10157

r? whomever.

@nikomatsakis
Copy link
Contributor Author

I'm going to add a commit to address #9509

@brson
Copy link
Contributor

brson commented Oct 29, 2013

That's very scrutable!

@nikomatsakis
Copy link
Contributor Author

Grrrrr. Such a simple patch and already bitrotted twice in 24 hours. :) OK, let me rebase again...

…rser bits

than the current ones, which were very fine-grained.  Also, cleanly distinguish
when properties must be found in *owned* types vs *reachable* types.

Fixes rust-lang#10157
@nikomatsakis
Copy link
Contributor Author

Github seems confused. Going to close this PR and open another.

flip1995 pushed a commit to flip1995/rust that referenced this pull request Jun 30, 2023
[`derivable_impls`]: don't lint if `default()` call expr unsize-coerces to trait object

Fixes rust-lang#10158.

This fixes a FP where the derive-generated Default impl would have different behavior because of unsize coercion from `Box<T>` to `Box<dyn Trait>`:
```rs
struct S {
  x: Box<dyn std::fmt::Debug>
}
impl Default for S {
  fn default() -> Self {
    Self {
      x: Box::<()>::default()
     // ^~ Box<()> coerces to Box<dyn Debug>
     // #[derive(Default)] would call Box::<dyn Debug>::default()
    }
  }
}
```
(this intentionally only looks for trait objects `dyn` specifically, and not any unsize coercion, e.g. `&[i32; 5]` to `&[i32]`, because that breaks existing tests and isn't actually problematic, as far as I can tell)

changelog: [`derivable_impls`]: don't lint if `default()` call expression unsize-coerces to trait object
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.

TypeContents code is inscrutable
2 participants