Skip to content

Commit 804746e

Browse files
committed
Auto merge of #127174 - matthiaskrgr:rollup-q87j6cn, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #126018 (Remove the `box_pointers` lint.) - #126895 (Fix simd_gather documentation) - #126981 (Replace some magic booleans in match-lowering with enums) - #127038 (Update test comment) - #127053 (Update the LoongArch target documentation) - #127069 (small correction to fmt::Pointer impl) - #127157 (coverage: Avoid getting extra unexpansion info when we don't need it) - #127160 (Add a regression test for #123630) - #127161 (Improve `run-make-support` library `args` API) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ef3d6fd + 4037197 commit 804746e

File tree

33 files changed

+427
-346
lines changed

33 files changed

+427
-346
lines changed

compiler/rustc_lint/messages.ftl

-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ lint_builtin_asm_labels = avoid using named labels in inline assembly
5656
.help = only local labels of the form `<number>:` should be used in inline asm
5757
.note = see the asm section of Rust By Example <https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html#labels> for more information
5858
59-
lint_builtin_box_pointers = type uses owned (Box type) pointers: {$ty}
60-
6159
lint_builtin_clashing_extern_diff_name = `{$this}` redeclares `{$orig}` with a different signature
6260
.previous_decl_label = `{$orig}` previously declared here
6361
.mismatch_label = this signature doesn't match the previous declaration

compiler/rustc_lint/src/builtin.rs

+3-79
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ use crate::fluent_generated as fluent;
2424
use crate::{
2525
errors::BuiltinEllipsisInclusiveRangePatterns,
2626
lints::{
27-
BuiltinAnonymousParams, BuiltinBoxPointers, BuiltinConstNoMangle,
28-
BuiltinDeprecatedAttrLink, BuiltinDeprecatedAttrLinkSuggestion, BuiltinDeprecatedAttrUsed,
29-
BuiltinDerefNullptr, BuiltinEllipsisInclusiveRangePatternsLint, BuiltinExplicitOutlives,
27+
BuiltinAnonymousParams, BuiltinConstNoMangle, BuiltinDeprecatedAttrLink,
28+
BuiltinDeprecatedAttrLinkSuggestion, BuiltinDeprecatedAttrUsed, BuiltinDerefNullptr,
29+
BuiltinEllipsisInclusiveRangePatternsLint, BuiltinExplicitOutlives,
3030
BuiltinExplicitOutlivesSuggestion, BuiltinFeatureIssueNote, BuiltinIncompleteFeatures,
3131
BuiltinIncompleteFeaturesHelp, BuiltinInternalFeatures, BuiltinKeywordIdents,
3232
BuiltinMissingCopyImpl, BuiltinMissingDebugImpl, BuiltinMissingDoc,
@@ -56,7 +56,6 @@ use rustc_middle::bug;
5656
use rustc_middle::lint::in_external_macro;
5757
use rustc_middle::ty::layout::LayoutOf;
5858
use rustc_middle::ty::print::with_no_trimmed_paths;
59-
use rustc_middle::ty::GenericArgKind;
6059
use rustc_middle::ty::TypeVisitableExt;
6160
use rustc_middle::ty::Upcast;
6261
use rustc_middle::ty::{self, Ty, TyCtxt, VariantDef};
@@ -134,80 +133,6 @@ impl EarlyLintPass for WhileTrue {
134133
}
135134
}
136135

137-
declare_lint! {
138-
/// The `box_pointers` lints use of the Box type.
139-
///
140-
/// ### Example
141-
///
142-
/// ```rust,compile_fail
143-
/// #![deny(box_pointers)]
144-
/// struct Foo {
145-
/// x: Box<i32>,
146-
/// }
147-
/// ```
148-
///
149-
/// {{produces}}
150-
///
151-
/// ### Explanation
152-
///
153-
/// This lint is mostly historical, and not particularly useful. `Box<T>`
154-
/// used to be built into the language, and the only way to do heap
155-
/// allocation. Today's Rust can call into other allocators, etc.
156-
BOX_POINTERS,
157-
Allow,
158-
"use of owned (Box type) heap memory"
159-
}
160-
161-
declare_lint_pass!(BoxPointers => [BOX_POINTERS]);
162-
163-
impl BoxPointers {
164-
fn check_heap_type(&self, cx: &LateContext<'_>, span: Span, ty: Ty<'_>) {
165-
for leaf in ty.walk() {
166-
if let GenericArgKind::Type(leaf_ty) = leaf.unpack()
167-
&& leaf_ty.is_box()
168-
{
169-
cx.emit_span_lint(BOX_POINTERS, span, BuiltinBoxPointers { ty });
170-
}
171-
}
172-
}
173-
}
174-
175-
impl<'tcx> LateLintPass<'tcx> for BoxPointers {
176-
fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
177-
match it.kind {
178-
hir::ItemKind::Fn(..)
179-
| hir::ItemKind::TyAlias(..)
180-
| hir::ItemKind::Enum(..)
181-
| hir::ItemKind::Struct(..)
182-
| hir::ItemKind::Union(..) => self.check_heap_type(
183-
cx,
184-
it.span,
185-
cx.tcx.type_of(it.owner_id).instantiate_identity(),
186-
),
187-
_ => (),
188-
}
189-
190-
// If it's a struct, we also have to check the fields' types
191-
match it.kind {
192-
hir::ItemKind::Struct(ref struct_def, _) | hir::ItemKind::Union(ref struct_def, _) => {
193-
for field in struct_def.fields() {
194-
self.check_heap_type(
195-
cx,
196-
field.span,
197-
cx.tcx.type_of(field.def_id).instantiate_identity(),
198-
);
199-
}
200-
}
201-
_ => (),
202-
}
203-
}
204-
205-
fn check_expr(&mut self, cx: &LateContext<'_>, e: &hir::Expr<'_>) {
206-
let ty = cx.typeck_results().node_type(e.hir_id);
207-
self.check_heap_type(cx, e.span, ty);
208-
}
209-
}
210-
211136
declare_lint! {
212137
/// The `non_shorthand_field_patterns` lint detects using `Struct { x: x }`
213138
/// instead of `Struct { x }` in a pattern.
@@ -1640,7 +1565,6 @@ declare_lint_pass!(
16401565
/// which are used by other parts of the compiler.
16411566
SoftLints => [
16421567
WHILE_TRUE,
1643-
BOX_POINTERS,
16441568
NON_SHORTHAND_FIELD_PATTERNS,
16451569
UNSAFE_CODE,
16461570
MISSING_DOCS,

compiler/rustc_lint/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ late_lint_methods!(
187187
ImproperCTypesDefinitions: ImproperCTypesDefinitions,
188188
InvalidFromUtf8: InvalidFromUtf8,
189189
VariantSizeDifferences: VariantSizeDifferences,
190-
BoxPointers: BoxPointers,
191190
PathStatements: PathStatements,
192191
LetUnderscore: LetUnderscore,
193192
InvalidReferenceCasting: InvalidReferenceCasting,
@@ -551,6 +550,10 @@ fn register_builtins(store: &mut LintStore) {
551550
"converted into hard error, see RFC #3535 \
552551
<https://rust-lang.github.io/rfcs/3535-constants-in-patterns.html> for more information",
553552
);
553+
store.register_removed(
554+
"box_pointers",
555+
"it does not detect other kinds of allocations, and existed only for historical reasons",
556+
);
554557
}
555558

556559
fn register_internals(store: &mut LintStore) {

compiler/rustc_lint/src/lints.rs

-6
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ pub struct BuiltinWhileTrue {
6666
pub replace: String,
6767
}
6868

69-
#[derive(LintDiagnostic)]
70-
#[diag(lint_builtin_box_pointers)]
71-
pub struct BuiltinBoxPointers<'a> {
72-
pub ty: Ty<'a>,
73-
}
74-
7569
#[derive(LintDiagnostic)]
7670
#[diag(lint_builtin_non_shorthand_field_patterns)]
7771
pub struct BuiltinNonShorthandFieldPatterns {

compiler/rustc_mir_build/src/build/block.rs

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::build::matches::{DeclareLetBindings, EmitStorageLive, ScheduleDrops};
12
use crate::build::ForGuard::OutsideGuard;
23
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
34
use rustc_middle::middle::region::Scope;
@@ -201,7 +202,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
201202
pattern,
202203
UserTypeProjections::none(),
203204
&mut |this, _, _, node, span, _, _| {
204-
this.storage_live_binding(block, node, span, OutsideGuard, true);
205+
this.storage_live_binding(
206+
block,
207+
node,
208+
span,
209+
OutsideGuard,
210+
ScheduleDrops::Yes,
211+
);
205212
},
206213
);
207214
let else_block_span = this.thir[*else_block].span;
@@ -213,8 +220,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
213220
pattern,
214221
None,
215222
initializer_span,
216-
false,
217-
true,
223+
DeclareLetBindings::No,
224+
EmitStorageLive::No,
218225
)
219226
});
220227
matching.and(failure)
@@ -291,7 +298,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
291298
pattern,
292299
UserTypeProjections::none(),
293300
&mut |this, _, _, node, span, _, _| {
294-
this.storage_live_binding(block, node, span, OutsideGuard, true);
301+
this.storage_live_binding(
302+
block,
303+
node,
304+
span,
305+
OutsideGuard,
306+
ScheduleDrops::Yes,
307+
);
295308
this.schedule_drop_for_binding(node, span, OutsideGuard);
296309
},
297310
)

compiler/rustc_mir_build/src/build/expr/into.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! See docs in build/expr/mod.rs
22
33
use crate::build::expr::category::{Category, RvalueFunc};
4+
use crate::build::matches::DeclareLetBindings;
45
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, NeedsTemporary};
56
use rustc_ast::InlineAsmOptions;
67
use rustc_data_structures::fx::FxHashMap;
@@ -86,7 +87,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
8687
cond,
8788
Some(condition_scope), // Temp scope
8889
source_info,
89-
true, // Declare `let` bindings normally
90+
DeclareLetBindings::Yes, // Declare `let` bindings normally
9091
));
9192

9293
// Lower the `then` arm into its block.
@@ -163,7 +164,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
163164
source_info,
164165
// This flag controls how inner `let` expressions are lowered,
165166
// but either way there shouldn't be any of those in here.
166-
true,
167+
DeclareLetBindings::LetNotPermitted,
167168
)
168169
});
169170
let (short_circuit, continuation, constant) = match op {

0 commit comments

Comments
 (0)