Skip to content

Fix ICE in DerivePass #666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use rustc::lint::*;
use rustc::middle::ty::fast_reject::simplify_type;
use rustc::middle::ty;
use rustc_front::hir::*;
use syntax::ast::{Attribute, MetaItemKind};
use syntax::ast::{Attribute, MetaItemKind, NodeId};
use syntax::codemap::Span;
use utils::{CLONE_TRAIT_PATH, HASH_PATH};
use utils::{match_path, span_lint_and_then};
Expand Down Expand Up @@ -80,7 +80,7 @@ impl LateLintPass for Derive {
check_hash_peq(cx, item.span, trait_ref, ty);
}
else {
check_copy_clone(cx, item.span, trait_ref, ty);
check_copy_clone(cx, item.span, trait_ref, ty, item.id);
}
}}
}
Expand Down Expand Up @@ -127,9 +127,11 @@ fn check_hash_peq(cx: &LateContext, span: Span, trait_ref: &TraitRef, ty: ty::Ty
}

/// Implementation of the `EXPL_IMPL_CLONE_ON_COPY` lint.
fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, span: Span, trait_ref: &TraitRef, ty: ty::Ty<'tcx>) {
fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, span: Span,
trait_ref: &TraitRef, ty: ty::Ty<'tcx>,
item: NodeId) {
if match_path(&trait_ref.path, &CLONE_TRAIT_PATH) {
let parameter_environment = cx.tcx.empty_parameter_environment();
let parameter_environment = ty::ParameterEnvironment::for_item(cx.tcx, item);

if ty.moves_by_default(&parameter_environment, span) {
return; // ty is not Copy
Expand Down