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

Rollup of 9 pull requests #127174

Merged
merged 21 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
dbf7018
Fix simd_gather documentation
betelgeuse Jun 24, 2024
c053e89
Remove the `box_pointers` lint.
nnethercote Jun 5, 2024
64be3a3
Update the LoongArch target documentation
xen0n Jun 27, 2024
35f2093
small correction to fmt::Pointer impl
Sky9x Jun 28, 2024
617de8c
coverage: Move span unexpansion into its own submodule
Zalathar Jun 30, 2024
ad575b0
Replace a magic boolean with enum `DeclareLetBindings`
Zalathar Jun 26, 2024
3b22589
Replace a magic boolean with enum `EmitStorageLive`
Zalathar Jun 26, 2024
ed07712
Replace a magic boolean with enum `ScheduleDrops`
Zalathar Jun 26, 2024
6c33149
coverage: Avoid getting extra unexpansion info when we don't need it
Zalathar Jun 30, 2024
4b516f5
Improve `run-make-support` library `args` API
GuillaumeGomez Jun 30, 2024
8a0e1ab
Add a regression test for #123630
pacak Jun 30, 2024
f79bf19
Update test comment
BoxyUwU Jun 30, 2024
6f57655
Rollup merge of #126018 - nnethercote:rm-box_pointers-lint, r=lcnr
matthiaskrgr Jun 30, 2024
5f43a89
Rollup merge of #126895 - betelgeuse:improve_simd_gather_documentatio…
matthiaskrgr Jun 30, 2024
d404ce7
Rollup merge of #126981 - Zalathar:enums, r=Nadrieril
matthiaskrgr Jun 30, 2024
1fac8de
Rollup merge of #127038 - BoxyUwU:reword_comment, r=camelid
matthiaskrgr Jun 30, 2024
7e05bc3
Rollup merge of #127053 - xen0n:update-loong-docs, r=Nilstrieb,heiher
matthiaskrgr Jun 30, 2024
7a43417
Rollup merge of #127069 - Sky9x:fmt-pointer-use-addr, r=Nilstrieb
matthiaskrgr Jun 30, 2024
b2aebc1
Rollup merge of #127157 - Zalathar:unexpand, r=cjgillot
matthiaskrgr Jun 30, 2024
6335b83
Rollup merge of #127160 - pacak:123630-test, r=Nadrieril
matthiaskrgr Jun 30, 2024
4037197
Rollup merge of #127161 - GuillaumeGomez:improve-run-make-args, r=Kobzol
matthiaskrgr Jun 30, 2024
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
2 changes: 0 additions & 2 deletions compiler/rustc_lint/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ lint_builtin_asm_labels = avoid using named labels in inline assembly
.help = only local labels of the form `<number>:` should be used in inline asm
.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

lint_builtin_box_pointers = type uses owned (Box type) pointers: {$ty}

lint_builtin_clashing_extern_diff_name = `{$this}` redeclares `{$orig}` with a different signature
.previous_decl_label = `{$orig}` previously declared here
.mismatch_label = this signature doesn't match the previous declaration
Expand Down
82 changes: 3 additions & 79 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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};
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ late_lint_methods!(
ImproperCTypesDefinitions: ImproperCTypesDefinitions,
InvalidFromUtf8: InvalidFromUtf8,
VariantSizeDifferences: VariantSizeDifferences,
BoxPointers: BoxPointers,
PathStatements: PathStatements,
LetUnderscore: LetUnderscore,
InvalidReferenceCasting: InvalidReferenceCasting,
Expand Down Expand Up @@ -551,6 +550,10 @@ fn register_builtins(store: &mut LintStore) {
"converted into hard error, see RFC #3535 \
<https://rust-lang.github.io/rfcs/3535-constants-in-patterns.html> for more information",
);
store.register_removed(
"box_pointers",
"it does not detect other kinds of allocations, and existed only for historical reasons",
);
}

fn register_internals(store: &mut LintStore) {
Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_lint/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ pub struct BuiltinWhileTrue {
pub replace: String,
}

#[derive(LintDiagnostic)]
#[diag(lint_builtin_box_pointers)]
pub struct BuiltinBoxPointers<'a> {
pub ty: Ty<'a>,
}

#[derive(LintDiagnostic)]
#[diag(lint_builtin_non_shorthand_field_patterns)]
pub struct BuiltinNonShorthandFieldPatterns {
Expand Down
21 changes: 17 additions & 4 deletions compiler/rustc_mir_build/src/build/block.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::build::matches::{DeclareLetBindings, EmitStorageLive, ScheduleDrops};
use crate::build::ForGuard::OutsideGuard;
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
use rustc_middle::middle::region::Scope;
Expand Down Expand Up @@ -201,7 +202,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
pattern,
UserTypeProjections::none(),
&mut |this, _, _, node, span, _, _| {
this.storage_live_binding(block, node, span, OutsideGuard, true);
this.storage_live_binding(
block,
node,
span,
OutsideGuard,
ScheduleDrops::Yes,
);
},
);
let else_block_span = this.thir[*else_block].span;
Expand All @@ -213,8 +220,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
pattern,
None,
initializer_span,
false,
true,
DeclareLetBindings::No,
EmitStorageLive::No,
)
});
matching.and(failure)
Expand Down Expand Up @@ -291,7 +298,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
pattern,
UserTypeProjections::none(),
&mut |this, _, _, node, span, _, _| {
this.storage_live_binding(block, node, span, OutsideGuard, true);
this.storage_live_binding(
block,
node,
span,
OutsideGuard,
ScheduleDrops::Yes,
);
this.schedule_drop_for_binding(node, span, OutsideGuard);
},
)
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_mir_build/src/build/expr/into.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! See docs in build/expr/mod.rs

use crate::build::expr::category::{Category, RvalueFunc};
use crate::build::matches::DeclareLetBindings;
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, NeedsTemporary};
use rustc_ast::InlineAsmOptions;
use rustc_data_structures::fx::FxHashMap;
Expand Down Expand Up @@ -86,7 +87,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
cond,
Some(condition_scope), // Temp scope
source_info,
true, // Declare `let` bindings normally
DeclareLetBindings::Yes, // Declare `let` bindings normally
));

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