Force callers of resolve_ast_path to deal with Res::Err correctly

This commit is contained in:
Mark Rousskov 2019-08-05 12:25:32 -04:00
parent 18130ef044
commit 3cd7f08ed1
2 changed files with 9 additions and 10 deletions

View File

@ -1858,16 +1858,8 @@ impl<'a> Resolver<'a> {
.collect(),
}
};
match self.resolve_ast_path_inner(&path, is_value) {
Ok(res) => {
if res == Res::Err {
Err(())
} else {
Ok((path, res))
}
}
Err(_) => Err(()),
}
let res = self.resolve_ast_path_inner(&path, is_value).map_err(|_| ())?;
Ok((path, res))
}
/// Like `resolve_ast_path`, but takes a callback in case there was an error.

View File

@ -71,6 +71,10 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
resolver.resolve_str_path_error(DUMMY_SP, &path_str, ns == ValueNS)
})
});
let result = match result {
Ok((_, Res::Err)) => Err(()),
_ => result,
};
if let Ok((_, res)) = result {
let res = res.map_id(|_| panic!("unexpected node_id"));
@ -134,6 +138,9 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
let (_, ty_res) = cx.enter_resolver(|resolver| resolver.with_scope(node_id, |resolver| {
resolver.resolve_str_path_error(DUMMY_SP, &path, false)
}))?;
if let Res::Err = ty_res {
return Err(());
}
let ty_res = ty_res.map_id(|_| panic!("unexpected node_id"));
match ty_res {
Res::Def(DefKind::Struct, did)