default_trait_access skips <F as Default>::default()

This includes the type name, so is clear, and may be necessary.

There doesn't seem to be an obviously cleaner way to pull out the
literal text of the named type here.

Fixes #2879
This commit is contained in:
Daniel Wagner-Hall 2018-08-27 23:22:07 +01:00
parent 43c629ebac
commit 350036a0c7
2 changed files with 11 additions and 1 deletions

View File

@ -48,6 +48,13 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
then {
match qpath {
QPath::Resolved(..) => {
if let ExprKind::Call(ref method, ref _args) = expr.node {
if format!("{:?}", method).contains(" as Default>") {
return
}
}
// TODO: Work out a way to put "whatever the imported way of referencing
// this type in this file" rather than a fully-qualified type.
let expr_ty = cx.tables.expr_ty(expr);

View File

@ -41,8 +41,10 @@ fn main() {
let s18 = TupleStructDerivedDefault::default();
let s19 = <DerivedDefault as Default>::default();
println!(
"[{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}]",
"[{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}] [{:?}], [{:?}]",
s1,
s2,
s3,
@ -61,6 +63,7 @@ fn main() {
s16,
s17,
s18,
s19,
);
}