Use last segment

This commit is contained in:
hi-rustin 2021-06-15 19:35:03 +08:00
parent 92d4164aca
commit 8c5938d049
4 changed files with 23 additions and 28 deletions

View file

@ -828,10 +828,7 @@ impl Visitor<'tcx> for Checker<'tcx> {
fn visit_path(&mut self, path: &'tcx hir::Path<'tcx>, id: hir::HirId) {
if let Some(def_id) = path.res.opt_def_id() {
let method_span = match path.segments {
[.., _, last] => Some(last.ident.span),
_ => None,
};
let method_span = path.segments.last().map(|s| s.ident.span);
self.tcx.check_stability(def_id, Some(id), path.span, method_span)
}
intravisit::walk_path(self, path)