@@ -11,6 +11,7 @@ use rustc_hir::def::Res;
11
11
use rustc_hir:: { Block , Expr , ExprKind , PatKind , QPath , Stmt , StmtKind } ;
12
12
use rustc_lint:: { LateContext , LateLintPass } ;
13
13
use rustc_middle:: ty;
14
+ use rustc_middle:: ty:: print:: with_forced_trimmed_paths;
14
15
use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
15
16
use rustc_span:: symbol:: { Ident , Symbol } ;
16
17
use rustc_span:: Span ;
@@ -98,9 +99,7 @@ impl<'tcx> LateLintPass<'tcx> for Default {
98
99
if let ty:: Adt ( def, ..) = expr_ty. kind( ) ;
99
100
if !is_from_proc_macro( cx, expr) ;
100
101
then {
101
- // TODO: Work out a way to put "whatever the imported way of referencing
102
- // this type in this file" rather than a fully-qualified type.
103
- let replacement = format!( "{}::default()" , cx. tcx. def_path_str( def. did( ) ) ) ;
102
+ let replacement = with_forced_trimmed_paths!( format!( "{}::default()" , cx. tcx. def_path_str( def. did( ) ) ) ) ;
104
103
span_lint_and_sugg(
105
104
cx,
106
105
DEFAULT_TRAIT_ACCESS ,
@@ -170,7 +169,7 @@ impl<'tcx> LateLintPass<'tcx> for Default {
170
169
// find out if and which field was set by this `consecutive_statement`
171
170
if let Some ( ( field_ident, assign_rhs) ) = field_reassigned_by_stmt ( consecutive_statement, binding_name) {
172
171
// interrupt and cancel lint if assign_rhs references the original binding
173
- if contains_name ( binding_name, assign_rhs) {
172
+ if contains_name ( binding_name, assign_rhs, cx ) {
174
173
cancel_lint = true ;
175
174
break ;
176
175
}
0 commit comments