mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-03 18:43:38 +00:00
Merge #7722
7722: Fix incorrect missing field diagnostic with box patterns r=Veykril a=lnicola Closes #7711 Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
This commit is contained in:
commit
900ba71168
@ -681,6 +681,30 @@ fn baz(s: S) -> i32 {
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_record_pat_field_box() {
|
||||
check_diagnostics(
|
||||
r"
|
||||
struct S { s: Box<u32> }
|
||||
fn x(a: S) {
|
||||
let S { box s } = a;
|
||||
}
|
||||
",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_record_pat_field_ref() {
|
||||
check_diagnostics(
|
||||
r"
|
||||
struct S { s: u32 }
|
||||
fn x(a: S) {
|
||||
let S { ref s } = a;
|
||||
}
|
||||
",
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn break_outside_of_loop() {
|
||||
check_diagnostics(
|
||||
|
@ -381,11 +381,20 @@ impl ast::RecordPatField {
|
||||
if let Some(name_ref) = self.name_ref() {
|
||||
return Some(NameOrNameRef::NameRef(name_ref));
|
||||
}
|
||||
if let Some(ast::Pat::IdentPat(pat)) = self.pat() {
|
||||
match self.pat() {
|
||||
Some(ast::Pat::IdentPat(pat)) => {
|
||||
let name = pat.name()?;
|
||||
return Some(NameOrNameRef::Name(name));
|
||||
Some(NameOrNameRef::Name(name))
|
||||
}
|
||||
Some(ast::Pat::BoxPat(pat)) => match pat.pat() {
|
||||
Some(ast::Pat::IdentPat(pat)) => {
|
||||
let name = pat.name()?;
|
||||
Some(NameOrNameRef::Name(name))
|
||||
}
|
||||
_ => None,
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user