Fix false-positive in use_self
This commit is contained in:
parent
43d19f63f7
commit
5656510eed
3 changed files with 25 additions and 6 deletions
|
@ -262,12 +262,17 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
|
||||||
// FIXME: this span manipulation should not be necessary
|
// FIXME: this span manipulation should not be necessary
|
||||||
// @flip1995 found an ast lowering issue in
|
// @flip1995 found an ast lowering issue in
|
||||||
// https://github.com/rust-lang/rust/blob/master/src/librustc_ast_lowering/path.rs#l142-l162
|
// https://github.com/rust-lang/rust/blob/master/src/librustc_ast_lowering/path.rs#l142-l162
|
||||||
match cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_ty.hir_id)) {
|
let hir = cx.tcx.hir();
|
||||||
Some(Node::Expr(Expr {
|
let id = hir.get_parent_node(hir_ty.hir_id);
|
||||||
kind: ExprKind::Path(QPath::TypeRelative(_, segment)),
|
|
||||||
..
|
if !hir.opt_span(id).map(in_macro).unwrap_or(false) {
|
||||||
})) => span_lint_until_last_segment(cx, hir_ty.span, segment),
|
match hir.find(id) {
|
||||||
_ => span_lint(cx, hir_ty.span),
|
Some(Node::Expr(Expr {
|
||||||
|
kind: ExprKind::Path(QPath::TypeRelative(_, segment)),
|
||||||
|
..
|
||||||
|
})) => span_lint_until_last_segment(cx, hir_ty.span, segment),
|
||||||
|
_ => span_lint(cx, hir_ty.span),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -454,3 +454,10 @@ mod nested_paths {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod issue6818 {
|
||||||
|
#[derive(serde::Deserialize)]
|
||||||
|
struct A {
|
||||||
|
a: i32,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -454,3 +454,10 @@ mod nested_paths {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod issue6818 {
|
||||||
|
#[derive(serde::Deserialize)]
|
||||||
|
struct A {
|
||||||
|
a: i32,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue