Skip to content

Commit

Permalink
Force callers of resolve_ast_path to deal with Res::Err correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Aug 5, 2019
1 parent 18130ef commit 3cd7f08
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3cd7f08

Please sign in to comment.