Skip to content
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

Lint fix #62

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
11 changes: 8 additions & 3 deletions alohomora_lints/src/alohomora_sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@ fn check_crate(cx: &LateContext<'_>) {
}

let nested_trait_impls = cx.tcx.trait_impls_of(def_id.unwrap());
let trait_impls = nested_trait_impls.non_blanket_impls().iter().fold(Vec::new(), |mut acc, (_, v)| { acc.extend(v.iter()); acc });
trait_impls.iter().filter(|def_id| !contains_secret(cx, def_id)).for_each(|def_id| {
error_message(cx, def_id);
let trait_impls = nested_trait_impls.non_blanket_impls()
.iter().fold(Vec::new(), |mut acc, (_, v)| { acc.extend(v.iter()); acc });
trait_impls.iter()
.filter(|def_id|
!contains_secret(cx, def_id)
&& def_id.krate == rustc_hir::def_id::LOCAL_CRATE)
.for_each(|def_id| {
error_message(cx, def_id);
});
}

Expand Down
14 changes: 10 additions & 4 deletions alohomora_lints/src/alohomora_sandbox_identity_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,14 @@ fn check_crate(cx: &LateContext<'_>) {
}

let nested_trait_impls = cx.tcx.trait_impls_of(def_id.unwrap());
let trait_impls = nested_trait_impls.non_blanket_impls().iter().fold(Vec::new(), |mut acc, (_, v)| { acc.extend(v.iter()); acc });
trait_impls.iter().filter(|def_id| !contains_secret(cx, def_id)).for_each(|def_id| {
error_message(cx, def_id);
});
let trait_impls = nested_trait_impls.non_blanket_impls()
.iter().fold(Vec::new(), |mut acc, (_, v)| { acc.extend(v.iter()); acc });

trait_impls.iter()
.filter(|def_id|
!contains_secret(cx, def_id)
&& def_id.krate == rustc_hir::def_id::LOCAL_CRATE)
.for_each(|def_id| {
error_message(cx, def_id);
});
}
12 changes: 9 additions & 3 deletions alohomora_lints/src/alohomora_sandbox_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,15 @@ fn check_crate(cx: &LateContext<'_>) {
}

let nested_trait_impls = cx.tcx.trait_impls_of(def_id.unwrap());
let trait_impls = nested_trait_impls.non_blanket_impls().iter().fold(Vec::new(), |mut acc, (_, v)| { acc.extend(v.iter()); acc });
trait_impls.iter().filter(|def_id| !contains_secret(cx, def_id)).for_each(|def_id| {
error_message(cx, def_id);
let trait_impls = nested_trait_impls.non_blanket_impls()
.iter().fold(Vec::new(), |mut acc, (_, v)| { acc.extend(v.iter()); acc });

trait_impls.iter()
.filter(|def_id|
!contains_secret(cx, def_id)
&& def_id.krate == rustc_hir::def_id::LOCAL_CRATE)
.for_each(|def_id| {
error_message(cx, def_id);
});
}

Expand Down
12 changes: 9 additions & 3 deletions alohomora_lints/src/alohomora_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,15 @@ fn check_crate(cx: &LateContext<'_>) {
}

let nested_trait_impls = cx.tcx.trait_impls_of(aloh_ty_def_id.unwrap());
let trait_impls = nested_trait_impls.non_blanket_impls().iter().fold(Vec::new(), |mut acc, (_, v)| { acc.extend(v.iter()); acc });
trait_impls.iter().filter(|def_id| !contains_secret(cx, def_id)).for_each(|def_id| {
error_message(cx, def_id);
let trait_impls: Vec<DefId> = nested_trait_impls.non_blanket_impls()
.iter().fold(Vec::new(), |mut acc, (_, v)| { acc.extend(v.iter()); acc });

trait_impls.iter()
.filter(|def_id|
!contains_secret(cx, def_id)
&& def_id.krate == rustc_hir::def_id::LOCAL_CRATE)
.for_each(|def_id| {
error_message(cx, def_id);
});
}

Expand Down
1 change: 1 addition & 0 deletions alohomora_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ extern crate rustc_lint;
extern crate rustc_middle;
extern crate rustc_session;
extern crate rustc_span;
extern crate rustc_hir;

// Helper for declaring lints without too much boilerplate.
macro_rules! declare_alohomora_lint {
Expand Down