1
Fork 0

Make hir::PathSegment::res non-optional.

This commit is contained in:
Nicholas Nethercote 2022-08-30 15:10:28 +10:00
parent ee244bf196
commit 6d850d936b
20 changed files with 65 additions and 76 deletions

View file

@ -957,7 +957,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
path.segments
.iter()
.filter_map(move |segment| {
let res = segment.res?;
let res = segment.res;
let generics_def_id = tcx.res_generics_def_id(res)?;
let generics = tcx.generics_of(generics_def_id);
if generics.has_impl_trait() {

View file

@ -154,16 +154,11 @@ impl<'tcx> Visitor<'tcx> for TypeParamSpanVisitor<'tcx> {
}
hir::TyKind::Path(hir::QPath::Resolved(None, path)) => match &path.segments {
[segment]
if segment
.res
.map(|res| {
matches!(
res,
Res::SelfTy { trait_: _, alias_to: _ }
| Res::Def(hir::def::DefKind::TyParam, _)
)
})
.unwrap_or(false) =>
if matches!(
segment.res,
Res::SelfTy { trait_: _, alias_to: _ }
| Res::Def(hir::def::DefKind::TyParam, _)
) =>
{
self.types.push(path.span);
}