Remove the box_pointers
lint.
As the comment says, this lint "is mostly historical, and not particularly useful". It's not worth keeping it around.
This commit is contained in:
parent
4bc39f028d
commit
c053e8939b
9 changed files with 11 additions and 125 deletions
|
@ -24,9 +24,9 @@ use crate::fluent_generated as fluent;
|
|||
use crate::{
|
||||
errors::BuiltinEllipsisInclusiveRangePatterns,
|
||||
lints::{
|
||||
BuiltinAnonymousParams, BuiltinBoxPointers, BuiltinConstNoMangle,
|
||||
BuiltinDeprecatedAttrLink, BuiltinDeprecatedAttrLinkSuggestion, BuiltinDeprecatedAttrUsed,
|
||||
BuiltinDerefNullptr, BuiltinEllipsisInclusiveRangePatternsLint, BuiltinExplicitOutlives,
|
||||
BuiltinAnonymousParams, BuiltinConstNoMangle, BuiltinDeprecatedAttrLink,
|
||||
BuiltinDeprecatedAttrLinkSuggestion, BuiltinDeprecatedAttrUsed, BuiltinDerefNullptr,
|
||||
BuiltinEllipsisInclusiveRangePatternsLint, BuiltinExplicitOutlives,
|
||||
BuiltinExplicitOutlivesSuggestion, BuiltinFeatureIssueNote, BuiltinIncompleteFeatures,
|
||||
BuiltinIncompleteFeaturesHelp, BuiltinInternalFeatures, BuiltinKeywordIdents,
|
||||
BuiltinMissingCopyImpl, BuiltinMissingDebugImpl, BuiltinMissingDoc,
|
||||
|
@ -56,7 +56,6 @@ use rustc_middle::bug;
|
|||
use rustc_middle::lint::in_external_macro;
|
||||
use rustc_middle::ty::layout::LayoutOf;
|
||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||
use rustc_middle::ty::GenericArgKind;
|
||||
use rustc_middle::ty::TypeVisitableExt;
|
||||
use rustc_middle::ty::Upcast;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt, VariantDef};
|
||||
|
@ -134,80 +133,6 @@ impl EarlyLintPass for WhileTrue {
|
|||
}
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `box_pointers` lints use of the Box type.
|
||||
///
|
||||
/// ### Example
|
||||
///
|
||||
/// ```rust,compile_fail
|
||||
/// #![deny(box_pointers)]
|
||||
/// struct Foo {
|
||||
/// x: Box<i32>,
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// {{produces}}
|
||||
///
|
||||
/// ### Explanation
|
||||
///
|
||||
/// This lint is mostly historical, and not particularly useful. `Box<T>`
|
||||
/// used to be built into the language, and the only way to do heap
|
||||
/// allocation. Today's Rust can call into other allocators, etc.
|
||||
BOX_POINTERS,
|
||||
Allow,
|
||||
"use of owned (Box type) heap memory"
|
||||
}
|
||||
|
||||
declare_lint_pass!(BoxPointers => [BOX_POINTERS]);
|
||||
|
||||
impl BoxPointers {
|
||||
fn check_heap_type(&self, cx: &LateContext<'_>, span: Span, ty: Ty<'_>) {
|
||||
for leaf in ty.walk() {
|
||||
if let GenericArgKind::Type(leaf_ty) = leaf.unpack()
|
||||
&& leaf_ty.is_box()
|
||||
{
|
||||
cx.emit_span_lint(BOX_POINTERS, span, BuiltinBoxPointers { ty });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for BoxPointers {
|
||||
fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
|
||||
match it.kind {
|
||||
hir::ItemKind::Fn(..)
|
||||
| hir::ItemKind::TyAlias(..)
|
||||
| hir::ItemKind::Enum(..)
|
||||
| hir::ItemKind::Struct(..)
|
||||
| hir::ItemKind::Union(..) => self.check_heap_type(
|
||||
cx,
|
||||
it.span,
|
||||
cx.tcx.type_of(it.owner_id).instantiate_identity(),
|
||||
),
|
||||
_ => (),
|
||||
}
|
||||
|
||||
// If it's a struct, we also have to check the fields' types
|
||||
match it.kind {
|
||||
hir::ItemKind::Struct(ref struct_def, _) | hir::ItemKind::Union(ref struct_def, _) => {
|
||||
for field in struct_def.fields() {
|
||||
self.check_heap_type(
|
||||
cx,
|
||||
field.span,
|
||||
cx.tcx.type_of(field.def_id).instantiate_identity(),
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn check_expr(&mut self, cx: &LateContext<'_>, e: &hir::Expr<'_>) {
|
||||
let ty = cx.typeck_results().node_type(e.hir_id);
|
||||
self.check_heap_type(cx, e.span, ty);
|
||||
}
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `non_shorthand_field_patterns` lint detects using `Struct { x: x }`
|
||||
/// instead of `Struct { x }` in a pattern.
|
||||
|
@ -1640,7 +1565,6 @@ declare_lint_pass!(
|
|||
/// which are used by other parts of the compiler.
|
||||
SoftLints => [
|
||||
WHILE_TRUE,
|
||||
BOX_POINTERS,
|
||||
NON_SHORTHAND_FIELD_PATTERNS,
|
||||
UNSAFE_CODE,
|
||||
MISSING_DOCS,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue