Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow coercions from never-type when ref binding is involved
When we type-check a binding that uses ref patterns, we do not perform coercions between the expression type and the pattern type. However, this has the unfortunate result of disallow code like: `let Foo { ref my_field } = diverging_expr();`. This code is accepted without the `ref` keyword. We now explicitly allow coercions when the expression type is ! In all other cases, we still avoid performing coersions. This avoids causing broader changes in type-checking (with potential soundness implications for 'ref mut'),
- Loading branch information
Showing
3 changed files
with
23 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// check-pass | ||
|
||
pub struct Foo { | ||
bar: u8 | ||
} | ||
|
||
#[allow(unused_variables)] | ||
fn main() { | ||
let Foo { ref bar } = loop {}; | ||
} |