forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#10954 - y21:issue10158, r=llogiq
[`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
- Loading branch information
Showing
3 changed files
with
74 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters