Skip to content

rustup https://github.com/rust-lang/rust/pull/59096/ #3902

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

Merged
merged 2 commits into from
Mar 23, 2019
Merged
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
3 changes: 1 addition & 2 deletions clippy_lints/src/functions.rs
Original file line number Diff line number Diff line change
@@ -256,8 +256,7 @@ impl<'a, 'tcx> Functions {
hir_id: hir::HirId,
) {
let expr = &body.value;
let node_id = cx.tcx.hir().hir_to_node_id(hir_id);
if unsafety == hir::Unsafety::Normal && cx.access_levels.is_exported(node_id) {
if unsafety == hir::Unsafety::Normal && cx.access_levels.is_exported(hir_id) {
let raw_ptrs = iter_input_pats(decl, body)
.zip(decl.inputs.iter())
.filter_map(|(arg, ty)| raw_ptr_arg(arg, ty))
11 changes: 3 additions & 8 deletions clippy_lints/src/len_zero.rs
Original file line number Diff line number Diff line change
@@ -148,9 +148,7 @@ fn check_trait_items(cx: &LateContext<'_, '_>, visited_trait: &Item, trait_items
}
}

let trait_node_id = cx.tcx.hir().hir_to_node_id(visited_trait.hir_id);

if cx.access_levels.is_exported(trait_node_id) && trait_items.iter().any(|i| is_named_self(cx, i, "len")) {
if cx.access_levels.is_exported(visited_trait.hir_id) && trait_items.iter().any(|i| is_named_self(cx, i, "len")) {
let mut current_and_super_traits = FxHashSet::default();
let visited_trait_def_id = cx.tcx.hir().local_def_id_from_hir_id(visited_trait.hir_id);
fill_trait_set(visited_trait_def_id, &mut current_and_super_traits, cx);
@@ -193,10 +191,7 @@ fn check_impl_items(cx: &LateContext<'_, '_>, item: &Item, impl_items: &[ImplIte
}

let is_empty = if let Some(is_empty) = impl_items.iter().find(|i| is_named_self(cx, i, "is_empty")) {
if cx
.access_levels
.is_exported(cx.tcx.hir().hir_to_node_id(is_empty.id.hir_id))
{
if cx.access_levels.is_exported(is_empty.id.hir_id) {
return;
} else {
"a private"
@@ -206,7 +201,7 @@ fn check_impl_items(cx: &LateContext<'_, '_>, item: &Item, impl_items: &[ImplIte
};

if let Some(i) = impl_items.iter().find(|i| is_named_self(cx, i, "len")) {
if cx.access_levels.is_exported(cx.tcx.hir().hir_to_node_id(i.id.hir_id)) {
if cx.access_levels.is_exported(i.id.hir_id) {
let def_id = cx.tcx.hir().local_def_id_from_hir_id(item.hir_id);
let ty = cx.tcx.type_of(def_id);

3 changes: 1 addition & 2 deletions clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
@@ -918,8 +918,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
if let Some(first_arg) = iter_input_pats(&sig.decl, cx.tcx.hir().body(id)).next();
if let hir::ItemKind::Impl(_, _, _, _, None, ref self_ty, _) = item.node;
then {
let node_id = cx.tcx.hir().hir_to_node_id(implitem.hir_id);
if cx.access_levels.is_exported(node_id) {
if cx.access_levels.is_exported(implitem.hir_id) {
// check missing trait implementations
for &(method_name, n_args, self_kind, out_type, trait_name) in &TRAIT_METHODS {
if name == method_name &&
9 changes: 4 additions & 5 deletions clippy_lints/src/missing_inline.rs
Original file line number Diff line number Diff line change
@@ -95,7 +95,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
return;
}

if !cx.access_levels.is_exported(cx.tcx.hir().hir_to_node_id(it.hir_id)) {
if !cx.access_levels.is_exported(it.hir_id) {
return;
}
match it.node {
@@ -146,8 +146,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
}

// If the item being implemented is not exported, then we don't need #[inline]
let node_id = cx.tcx.hir().hir_to_node_id(impl_item.hir_id);
if !cx.access_levels.is_exported(node_id) {
if !cx.access_levels.is_exported(impl_item.hir_id) {
return;
}

@@ -163,8 +162,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
};

if let Some(trait_def_id) = trait_def_id {
if let Some(n) = cx.tcx.hir().as_local_node_id(trait_def_id) {
if !cx.access_levels.is_exported(n) {
if cx.tcx.hir().as_local_node_id(trait_def_id).is_some() {
if !cx.access_levels.is_exported(impl_item.hir_id) {
// If a trait is being implemented for an item, and the
// trait is not exported, we don't need #[inline]
return;
3 changes: 1 addition & 2 deletions clippy_lints/src/new_without_default.rs
Original file line number Diff line number Diff line change
@@ -111,7 +111,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
if let hir::ImplItemKind::Method(ref sig, _) = impl_item.node {
let name = impl_item.ident.name;
let id = impl_item.hir_id;
let node_id = cx.tcx.hir().hir_to_node_id(id);
if sig.header.constness == hir::Constness::Const {
// can't be implemented by default
return;
@@ -129,7 +128,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
// impl of `Default`
return;
}
if sig.decl.inputs.is_empty() && name == "new" && cx.access_levels.is_reachable(node_id) {
if sig.decl.inputs.is_empty() && name == "new" && cx.access_levels.is_reachable(id) {
let self_did = cx.tcx.hir().local_def_id_from_hir_id(cx.tcx.hir().get_parent_item(id));
let self_ty = cx.tcx.type_of(self_did);
if_chain! {
2 changes: 1 addition & 1 deletion clippy_lints/src/types.rs
Original file line number Diff line number Diff line change
@@ -2075,7 +2075,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitHasher {
}
}

if !cx.access_levels.is_exported(cx.tcx.hir().hir_to_node_id(item.hir_id)) {
if !cx.access_levels.is_exported(item.hir_id) {
return;
}