diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-08-05 12:25:32 -0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-08-05 12:31:00 -0400 |
| commit | 3cd7f08ed1f801c2fa4983d9eef9162739922373 (patch) | |
| tree | 5a18f1d3009245c8dc21707050d9da6b655ef762 | |
| parent | 18130ef044cfa83af341c4a3500ab576f8cc4c38 (diff) | |
| download | rust-3cd7f08ed1f801c2fa4983d9eef9162739922373.tar.gz rust-3cd7f08ed1f801c2fa4983d9eef9162739922373.zip | |
Force callers of resolve_ast_path to deal with Res::Err correctly
| -rw-r--r-- | src/librustc_resolve/lib.rs | 12 | ||||
| -rw-r--r-- | src/librustdoc/passes/collect_intra_doc_links.rs | 7 |
2 files changed, 9 insertions, 10 deletions
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 3dd1d7d274d..ba703558998 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -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. diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 04de3374d05..84cfdd790b7 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -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) |
