Auto merge of #6833 - daxpedda:use-self, r=Manishearth
Fix false-positive in `use_self` Fixes #6818. changelog: Fix false positives for use_self in macros.
This commit is contained in:
@@ -262,7 +262,11 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
|
||||
// FIXME: this span manipulation should not be necessary
|
||||
// @flip1995 found an ast lowering issue in
|
||||
// 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();
|
||||
let id = hir.get_parent_node(hir_ty.hir_id);
|
||||
|
||||
if !hir.opt_span(id).map(in_macro).unwrap_or(false) {
|
||||
match hir.find(id) {
|
||||
Some(Node::Expr(Expr {
|
||||
kind: ExprKind::Path(QPath::TypeRelative(_, segment)),
|
||||
..
|
||||
@@ -271,6 +275,7 @@ impl<'tcx> LateLintPass<'tcx> for UseSelf {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
|
||||
fn expr_ty_matches(cx: &LateContext<'_>, expr: &Expr<'_>, self_ty: Ty<'_>) -> bool {
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user