@@ -11,6 +11,7 @@ use rustc_hir::def::Res;
1111use rustc_hir:: { Block , Expr , ExprKind , PatKind , QPath , Stmt , StmtKind } ;
1212use rustc_lint:: { LateContext , LateLintPass } ;
1313use rustc_middle:: ty;
14+ use rustc_middle:: ty:: print:: with_forced_trimmed_paths;
1415use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
1516use rustc_span:: symbol:: { Ident , Symbol } ;
1617use rustc_span:: Span ;
@@ -98,9 +99,7 @@ impl<'tcx> LateLintPass<'tcx> for Default {
9899 if let ty:: Adt ( def, ..) = expr_ty. kind( ) ;
99100 if !is_from_proc_macro( cx, expr) ;
100101 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( ) ) ) ) ;
104103 span_lint_and_sugg(
105104 cx,
106105 DEFAULT_TRAIT_ACCESS ,
@@ -170,7 +169,7 @@ impl<'tcx> LateLintPass<'tcx> for Default {
170169 // find out if and which field was set by this `consecutive_statement`
171170 if let Some ( ( field_ident, assign_rhs) ) = field_reassigned_by_stmt ( consecutive_statement, binding_name) {
172171 // 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 ) {
174173 cancel_lint = true ;
175174 break ;
176175 }
0 commit comments