Skip to content

Commit 09143cd

Browse files
committed
Update tests; make it work with generics on context
1 parent b0616df commit 09143cd

File tree

2 files changed

+6
-31
lines changed

2 files changed

+6
-31
lines changed

clippy_lints/src/new_without_default.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
108108
// can't be implemented by default
109109
return;
110110
}
111-
//TODO: There is no sig.generics anymore and I don't know how to fix this.
112-
//if !sig.generics.ty_params.is_empty() {
113-
// // when the result of `new()` depends on a type parameter we should not require
114-
// // an
115-
// // impl of `Default`
116-
// return;
117-
//}
111+
if !cx.generics.expect("method must have generics").ty_params.is_empty() {
112+
// when the result of `new()` depends on a type parameter we should not require
113+
// an
114+
// impl of `Default`
115+
return;
116+
}
118117
if decl.inputs.is_empty() && name == "new" && cx.access_levels.is_reachable(id) {
119118
let self_ty = cx.tcx
120119
.type_of(cx.tcx.hir.local_def_id(cx.tcx.hir.get_parent(id)));

tests/ui/mut_mut.stderr

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ error: generally you want to avoid `&mut &mut _` if possible
3939
30 | let y : &mut &mut u32 = &mut &mut 2;
4040
| ^^^^^^^^^^^^^
4141

42-
error: generally you want to avoid `&mut &mut _` if possible
43-
--> $DIR/mut_mut.rs:30:17
44-
|
45-
30 | let y : &mut &mut u32 = &mut &mut 2;
46-
| ^^^^^^^^^^^^^
47-
4842
error: generally you want to avoid `&mut &mut _` if possible
4943
--> $DIR/mut_mut.rs:35:38
5044
|
@@ -63,21 +57,3 @@ error: generally you want to avoid `&mut &mut _` if possible
6357
35 | let y : &mut &mut &mut u32 = &mut &mut &mut 2;
6458
| ^^^^^^^^^^^^^
6559

66-
error: generally you want to avoid `&mut &mut _` if possible
67-
--> $DIR/mut_mut.rs:35:17
68-
|
69-
35 | let y : &mut &mut &mut u32 = &mut &mut &mut 2;
70-
| ^^^^^^^^^^^^^^^^^^
71-
72-
error: generally you want to avoid `&mut &mut _` if possible
73-
--> $DIR/mut_mut.rs:35:22
74-
|
75-
35 | let y : &mut &mut &mut u32 = &mut &mut &mut 2;
76-
| ^^^^^^^^^^^^^
77-
78-
error: generally you want to avoid `&mut &mut _` if possible
79-
--> $DIR/mut_mut.rs:35:22
80-
|
81-
35 | let y : &mut &mut &mut u32 = &mut &mut &mut 2;
82-
| ^^^^^^^^^^^^^
83-

0 commit comments

Comments
 (0)