Skip to content

Commit bbe4971

Browse files
committed
Don't crash on Vec<DoesNotExist>
1 parent 3576f5d commit bbe4971

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/librustdoc/core.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_hir::def::{Namespace::TypeNS, Res};
99
use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
1010
use rustc_hir::HirId;
1111
use rustc_hir::{
12-
intravisit::{NestedVisitorMap, Visitor},
12+
intravisit::{self, NestedVisitorMap, Visitor},
1313
Path,
1414
};
1515
use rustc_interface::interface;
@@ -622,7 +622,7 @@ impl<'hir> Visitor<'hir> for EmitIgnoredResolutionErrors<'_, 'hir> {
622622
NestedVisitorMap::OnlyBodies(self.hir_map)
623623
}
624624

625-
fn visit_path(&mut self, path: &'v Path<'v>, _id: HirId) {
625+
fn visit_path(&mut self, path: &'hir Path<'_>, _id: HirId) {
626626
debug!("visiting path {:?}", path);
627627
if path.res == Res::Err {
628628
// We have less context here than in rustc_resolve,
@@ -648,7 +648,10 @@ impl<'hir> Visitor<'hir> for EmitIgnoredResolutionErrors<'_, 'hir> {
648648
err.note("try running again with `rustc` and you may get a more detailed error");
649649
err.emit();
650650
}
651-
// NOTE: this does _not_ visit the path segments
651+
// We could have an outer resolution that succeeded,
652+
// but with generic parameters that failed.
653+
// Recurse into the segments so we catch those too.
654+
intravisit::walk_path(self, path);
652655
}
653656
}
654657

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
trait ValidTrait {}
2+
3+
/// This has docs
4+
pub fn f() -> impl ValidTrait {
5+
Vec::<DoesNotExist>::new()
6+
//~^ ERROR failed to resolve
7+
}

0 commit comments

Comments
 (0)