|
1 | 1 | use rustc::lint::*;
|
| 2 | +use rustc::middle::subst::Subst; |
2 | 3 | use rustc::middle::ty::TypeVariants;
|
3 | 4 | use rustc::middle::ty::fast_reject::simplify_type;
|
4 | 5 | use rustc::middle::ty;
|
@@ -70,16 +71,17 @@ impl LintPass for Derive {
|
70 | 71 |
|
71 | 72 | impl LateLintPass for Derive {
|
72 | 73 | fn check_item(&mut self, cx: &LateContext, item: &Item) {
|
73 |
| - let ast_ty_to_ty_cache = cx.tcx.ast_ty_to_ty_cache.borrow(); |
| 74 | + |
74 | 75 |
|
75 | 76 | if_let_chain! {[
|
76 |
| - let ItemImpl(_, _, ref ast_generics, Some(ref trait_ref), ref ast_ty, _) = item.node, |
77 |
| - let Some(&ty) = ast_ty_to_ty_cache.get(&ast_ty.id) |
| 77 | + let ItemImpl(_, _, _, Some(ref trait_ref), _, _) = item.node |
78 | 78 | ], {
|
| 79 | + |
| 80 | + let ty = cx.tcx.lookup_item_type(cx.tcx.map.local_def_id(item.id)).ty; |
79 | 81 | if item.attrs.iter().any(is_automatically_derived) {
|
80 | 82 | check_hash_peq(cx, item.span, trait_ref, ty);
|
81 | 83 | }
|
82 |
| - else if !ast_generics.is_lt_parameterized() { |
| 84 | + else { |
83 | 85 | check_copy_clone(cx, item, trait_ref, ty);
|
84 | 86 | }
|
85 | 87 | }}
|
@@ -132,8 +134,9 @@ fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>,
|
132 | 134 | trait_ref: &TraitRef, ty: ty::Ty<'tcx>) {
|
133 | 135 | if match_path(&trait_ref.path, &CLONE_TRAIT_PATH) {
|
134 | 136 | let parameter_environment = ty::ParameterEnvironment::for_item(cx.tcx, item.id);
|
| 137 | + let subst_ty = ty.subst(cx.tcx, ¶meter_environment.free_substs); |
135 | 138 |
|
136 |
| - if ty.moves_by_default(¶meter_environment, item.span) { |
| 139 | + if subst_ty.moves_by_default(¶meter_environment, item.span) { |
137 | 140 | return; // ty is not Copy
|
138 | 141 | }
|
139 | 142 |
|
|
0 commit comments