Adapt type path reporting to field path elements
@@ -418,6 +418,9 @@ fn report_ty_path(l: &label::Label, files: &mut Files<String>) -> (Label<FileId>
let (msg, notes) = if l.path.is_empty() {
(String::from("expected type"), Vec::new())
}
+ else if ty_path::is_only_field(&l.path) {
+ (String::from("expected field type"), Vec::new())
+ }
// If the path is only composed of codomains, polarity is necessarily true and the cause of the
// blame is the return value of the function
else if ty_path::is_only_codom(&l.path) {
@@ -435,7 +438,8 @@ fn report_ty_path(l: &label::Label, files: &mut Files<String>) -> (Label<FileId>
],
)
} else {
- match l.path.last().unwrap() {
+ let last_ign_fld = l.path.iter().filter(|elt| match *elt { ty_path::Elem::Field(_) => false, _ => true}).last().unwrap();
+ match last_ign_fld {
ty_path::Elem::Domain if l.polarity => {
(String::from("expected type of an argument of an inner call"),
vec![
@@ -480,6 +484,7 @@ fn report_ty_path(l: &label::Label, files: &mut Files<String>) -> (Label<FileId>
end_note,
])
}
+ _ => panic!(),
}
};
