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

[beta] Backport unstabilization of extended varargs abi support #136934

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
c09561c
update version placeholders
pietroalbini Jan 6, 2025
3bc7fca
update channel to beta
pietroalbini Jan 6, 2025
031ad72
Pass objcopy args for stripping on OSX
Noratrieb Jan 2, 2025
3d6fdff
rustfmt: drop nightly-gating of the `--style-edition` flag registration
jieyouxu Jan 7, 2025
fc252e9
Revert "fix missing rustfmt for apple darwin"
pietroalbini Jan 8, 2025
b2ab974
Revert "fix missing rustfmt and clippy for msi"
pietroalbini Jan 8, 2025
e30eeff
Auto merge of #135163 - pietroalbini:pa-beta, r=pietroalbini
bors Jan 8, 2025
9e57baf
bump stage0 to 1.84.0
cuviper Jan 10, 2025
4475508
run borrowck tests on BIDs and emit tail-expr-drop-order lints for
dingxiangfei2009 Dec 4, 2024
e398428
apply suggestions on fn name
dingxiangfei2009 Dec 19, 2024
61c0bcf
remove an extraneous comment
dingxiangfei2009 Dec 19, 2024
273873a
Don't create cycles by normalizing opaques defined in the body we're …
compiler-errors Jan 5, 2025
1b8413e
Don't do AccessDepth::Drop for types with no drop impl
compiler-errors Jan 5, 2025
18d3153
Try to explain borrow for tail expr temporary drop order change in 2024
compiler-errors Jan 6, 2025
ce4e43f
Bless test UI changes in backport
cuviper Jan 11, 2025
fe9b975
Auto merge of #135351 - cuviper:beta-next, r=cuviper
bors Jan 11, 2025
402eeff
[beta] TRPL: incorporate all backward-compatible Edition changes
chriskrycho Jan 14, 2025
f836dc2
Mark rustbook as an external tool
ehuss Jan 13, 2025
5904ea4
Backport rust-lang/rust-analyzer#18760: internal: Workaround salsa cy…
Veykril Jan 16, 2025
8a7dc21
do not in-place-iterate over flatmap/flatten
the8472 Jan 4, 2025
ae37d1c
add regression test for unsound Flatten/FlatMap specialization
the8472 Jan 4, 2025
e126c8d
Make sure to mark IMPL_TRAIT_REDUNDANT_CAPTURES as Allow in edition 2024
compiler-errors Jan 13, 2025
1c85981
Update to LLVM 19.1.7
nikic Jan 14, 2025
d0d224d
Auto merge of #135508 - chriskrycho:trpl-edition-updates, r=ehuss
bors Jan 17, 2025
752fecf
Auto merge of #135609 - cuviper:beta-next, r=cuviper
bors Jan 17, 2025
4416507
Auto merge of #135575 - Veykril:push-ynurtulswkpo, r=Mark-Simulacrum
bors Jan 20, 2025
a41d236
Always force non-trimming of path in `unreachable_patterns` lint
estebank Jan 9, 2025
eb03c32
Add logic to override profile for non git sources
tanvincible Jan 13, 2025
f379706
resolve symlinks of LLVM tool binaries before copying them
onur-ozkan Jan 16, 2025
953a1a0
avoid running the overlap check twice
lcnr Jan 15, 2025
e35db42
add cache to `AmbiguityCausesVisitor`
lcnr Jan 17, 2025
f6aed49
add test
lcnr Jan 17, 2025
4595e11
When LLVM's location discriminator value limit is exceeded, emit loca…
khuey Jan 17, 2025
e92addf
make it possible to use ci-rustc on tarball sources
onur-ozkan Jan 19, 2025
5f5e70b
Remove test panic from File::open
ChrisDenton Jan 21, 2025
f05d305
Only assert the `Parser` size on specific arches
cuviper Jan 22, 2025
ee2ff9d
[beta] TRPL: more backward-compatible Edition changes
chriskrycho Jan 21, 2025
130f951
[beta] TRPL: integrate edits to Chapter 17
chriskrycho Jan 21, 2025
14445aa
Auto merge of #136017 - cuviper:beta-next, r=cuviper
bors Jan 26, 2025
ee94112
Rollup merge of #135852 - lukas-code:asyncfn-prelude-core, r=compiler…
matthiaskrgr Jan 30, 2025
2fa9d47
Disable some incorrect rust-analyzer diagnostics on beta
Veykril Jan 29, 2025
fdc22dc
Rollup merge of #136312 - compiler-errors:overflow_delimited_expr-202…
jhpratt Jan 31, 2025
b5a02ff
Update edition-guide
ehuss Feb 1, 2025
cfe3de2
Fix core AsyncFn stability attribute
ehuss Feb 1, 2025
0277061
Auto merge of #136391 - ehuss:rust-1.85-beta-backports, r=ehuss
bors Feb 1, 2025
887965d
Ensure that we don't try to access fields on a non-struct pattern typ…
estebank Jan 7, 2025
e98d524
Add check for missing fields in enum variant pattern
estebank Jan 8, 2025
f264675
modify test to side-step platform-dependent stderr output
estebank Jan 8, 2025
13c3f9b
Do not include GCC source code in source tarballs
Kobzol Jan 17, 2025
7302b30
Revert "Auto merge of #134330 - scottmcm:no-more-rvalue-len, r=matthe…
lqd Jan 18, 2025
c6063d4
Revert "Rollup merge of #134371 - scottmcm:fix-134352, r=oli-obk"
lqd Jan 18, 2025
197b416
Revert "Auto merge of #133734 - scottmcm:lower-indexing-to-ptrmetadat…
lqd Jan 18, 2025
9405480
add tests for issue 135671
lqd Jan 18, 2025
741fa9e
ensure sufficient stack in tail call check
lqd Jan 31, 2025
01283c4
ensure sufficient stack in unsafety check
lqd Jan 31, 2025
bf24cad
Enable kernel sanitizers for aarch64-unknown-none-softfloat
workingjubilee Jan 22, 2025
3821385
Auto merge of #136650 - cuviper:beta-next, r=cuviper
bors Feb 6, 2025
74c0e61
Revert "Stabilize `extended_varargs_abi_support`"
workingjubilee Feb 12, 2025
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
4 changes: 4 additions & 0 deletions compiler/rustc_borrowck/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ borrowck_suggest_create_fresh_reborrow =
borrowck_suggest_iterate_over_slice =
consider iterating over a slice of the `{$ty}`'s content to avoid moving into the `for` loop

borrowck_tail_expr_drop_order = relative drop order changing in Rust 2024
.label = this temporary value will be dropped at the end of the block
.note = consider using a `let` binding to ensure the value will live long enough

borrowck_ty_no_impl_copy =
{$is_partial_move ->
[true] partial move
Expand Down
18 changes: 9 additions & 9 deletions compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use std::assert_matches::assert_matches;

use rustc_errors::{Applicability, Diag};
use rustc_errors::{Applicability, Diag, EmissionGuarantee};
use rustc_hir as hir;
use rustc_hir::intravisit::Visitor;
use rustc_index::IndexSlice;
Expand Down Expand Up @@ -60,12 +60,12 @@ impl<'tcx> BorrowExplanation<'tcx> {
pub(crate) fn is_explained(&self) -> bool {
!matches!(self, BorrowExplanation::Unexplained)
}
pub(crate) fn add_explanation_to_diagnostic(
pub(crate) fn add_explanation_to_diagnostic<G: EmissionGuarantee>(
&self,
tcx: TyCtxt<'tcx>,
body: &Body<'tcx>,
local_names: &IndexSlice<Local, Option<Symbol>>,
err: &mut Diag<'_>,
err: &mut Diag<'_, G>,
borrow_desc: &str,
borrow_span: Option<Span>,
multiple_borrow_span: Option<(Span, Span)>,
Expand Down Expand Up @@ -348,10 +348,10 @@ impl<'tcx> BorrowExplanation<'tcx> {
}
}

fn add_object_lifetime_default_note(
fn add_object_lifetime_default_note<G: EmissionGuarantee>(
&self,
tcx: TyCtxt<'tcx>,
err: &mut Diag<'_>,
err: &mut Diag<'_, G>,
unsize_ty: Ty<'tcx>,
) {
if let ty::Adt(def, args) = unsize_ty.kind() {
Expand Down Expand Up @@ -405,9 +405,9 @@ impl<'tcx> BorrowExplanation<'tcx> {
}
}

fn add_lifetime_bound_suggestion_to_diagnostic(
fn add_lifetime_bound_suggestion_to_diagnostic<G: EmissionGuarantee>(
&self,
err: &mut Diag<'_>,
err: &mut Diag<'_, G>,
category: &ConstraintCategory<'tcx>,
span: Span,
region_name: &RegionName,
Expand All @@ -434,14 +434,14 @@ impl<'tcx> BorrowExplanation<'tcx> {
}
}

fn suggest_rewrite_if_let(
fn suggest_rewrite_if_let<G: EmissionGuarantee>(
tcx: TyCtxt<'_>,
expr: &hir::Expr<'_>,
pat: &str,
init: &hir::Expr<'_>,
conseq: &hir::Expr<'_>,
alt: Option<&hir::Expr<'_>>,
err: &mut Diag<'_>,
err: &mut Diag<'_, G>,
) {
let source_map = tcx.sess.source_map();
err.span_note(
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
kind,
};
}

normal_ret
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/region_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::fmt::{self, Display};
use std::iter;

use rustc_data_structures::fx::IndexEntry;
use rustc_errors::Diag;
use rustc_errors::{Diag, EmissionGuarantee};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_middle::ty::print::RegionHighlightMode;
Expand Down Expand Up @@ -108,7 +108,7 @@ impl RegionName {
}
}

pub(crate) fn highlight_region_name(&self, diag: &mut Diag<'_>) {
pub(crate) fn highlight_region_name<G: EmissionGuarantee>(&self, diag: &mut Diag<'_, G>) {
match &self.source {
RegionNameSource::NamedLateParamRegion(span)
| RegionNameSource::NamedEarlyParamRegion(span) => {
Expand Down
115 changes: 98 additions & 17 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
#![warn(unreachable_pub)]
// tidy-alphabetical-end

use std::borrow::Cow;
use std::cell::RefCell;
use std::marker::PhantomData;
use std::ops::Deref;

use rustc_abi::FieldIdx;
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_data_structures::graph::dominators::Dominators;
use rustc_errors::LintDiagnostic;
use rustc_hir as hir;
use rustc_hir::CRATE_HIR_ID;
use rustc_hir::def_id::LocalDefId;
use rustc_index::bit_set::{BitSet, MixedBitSet};
use rustc_index::{IndexSlice, IndexVec};
Expand All @@ -42,7 +45,7 @@ use rustc_mir_dataflow::move_paths::{
InitIndex, InitLocation, LookupResult, MoveData, MovePathIndex,
};
use rustc_mir_dataflow::{Analysis, EntryStates, Results, ResultsVisitor, visit_results};
use rustc_session::lint::builtin::UNUSED_MUT;
use rustc_session::lint::builtin::{TAIL_EXPR_DROP_ORDER, UNUSED_MUT};
use rustc_span::{Span, Symbol};
use smallvec::SmallVec;
use tracing::{debug, instrument};
Expand Down Expand Up @@ -636,9 +639,11 @@ impl<'a, 'tcx> ResultsVisitor<'a, 'tcx, Borrowck<'a, 'tcx>> for MirBorrowckCtxt<
| StatementKind::Coverage(..)
// These do not actually affect borrowck
| StatementKind::ConstEvalCounter
// This do not affect borrowck
| StatementKind::BackwardIncompatibleDropHint { .. }
| StatementKind::StorageLive(..) => {}
// This does not affect borrowck
StatementKind::BackwardIncompatibleDropHint { place, reason: BackwardIncompatibleDropReason::Edition2024 } => {
self.check_backward_incompatible_drop(location, (**place, span), state);
}
StatementKind::StorageDead(local) => {
self.access_place(
location,
Expand Down Expand Up @@ -823,6 +828,7 @@ use self::ReadOrWrite::{Activation, Read, Reservation, Write};

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
enum ArtificialField {
ArrayLength,
FakeBorrow,
}

Expand Down Expand Up @@ -1007,6 +1013,24 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
}
}

fn borrows_in_scope<'s>(
&self,
location: Location,
state: &'s BorrowckDomain,
) -> Cow<'s, BitSet<BorrowIndex>> {
if let Some(polonius) = &self.polonius_output {
// Use polonius output if it has been enabled.
let location = self.location_table.start_index(location);
let mut polonius_output = BitSet::new_empty(self.borrow_set.len());
for &idx in polonius.errors_at(location) {
polonius_output.insert(idx);
}
Cow::Owned(polonius_output)
} else {
Cow::Borrowed(&state.borrows)
}
}

#[instrument(level = "debug", skip(self, state))]
fn check_access_for_conflict(
&mut self,
Expand All @@ -1018,18 +1042,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
) -> bool {
let mut error_reported = false;

// Use polonius output if it has been enabled.
let mut polonius_output;
let borrows_in_scope = if let Some(polonius) = &self.polonius_output {
let location = self.location_table.start_index(location);
polonius_output = BitSet::new_empty(self.borrow_set.len());
for &idx in polonius.errors_at(location) {
polonius_output.insert(idx);
}
&polonius_output
} else {
&state.borrows
};
let borrows_in_scope = self.borrows_in_scope(location, state);

each_borrow_involving_path(
self,
Expand Down Expand Up @@ -1149,6 +1162,69 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
error_reported
}

/// Through #123739, backward incompatible drops (BIDs) are introduced.
/// We would like to emit lints whether borrow checking fails at these future drop locations.
#[instrument(level = "debug", skip(self, state))]
fn check_backward_incompatible_drop(
&mut self,
location: Location,
(place, place_span): (Place<'tcx>, Span),
state: &BorrowckDomain,
) {
let tcx = self.infcx.tcx;
// If this type does not need `Drop`, then treat it like a `StorageDead`.
// This is needed because we track the borrows of refs to thread locals,
// and we'll ICE because we don't track borrows behind shared references.
let sd = if place.ty(self.body, tcx).ty.needs_drop(tcx, self.body.typing_env(tcx)) {
AccessDepth::Drop
} else {
AccessDepth::Shallow(None)
};

let borrows_in_scope = self.borrows_in_scope(location, state);

// This is a very simplified version of `Self::check_access_for_conflict`.
// We are here checking on BIDs and specifically still-live borrows of data involving the BIDs.
each_borrow_involving_path(
self,
self.infcx.tcx,
self.body,
(sd, place),
self.borrow_set,
|borrow_index| borrows_in_scope.contains(borrow_index),
|this, _borrow_index, borrow| {
if matches!(borrow.kind, BorrowKind::Fake(_)) {
return Control::Continue;
}
let borrowed = this.retrieve_borrow_spans(borrow).var_or_use_path_span();
let explain = this.explain_why_borrow_contains_point(
location,
borrow,
Some((WriteKind::StorageDeadOrDrop, place)),
);
this.infcx.tcx.node_span_lint(
TAIL_EXPR_DROP_ORDER,
CRATE_HIR_ID,
borrowed,
|diag| {
session_diagnostics::TailExprDropOrder { borrowed }.decorate_lint(diag);
explain.add_explanation_to_diagnostic(
this.infcx.tcx,
this.body,
&this.local_names,
diag,
"",
None,
None,
);
},
);
// We may stop at the first case
Control::Break
},
);
}

fn mutate_place(
&mut self,
location: Location,
Expand Down Expand Up @@ -1270,11 +1346,16 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
);
}

&Rvalue::Discriminant(place) => {
&(Rvalue::Len(place) | Rvalue::Discriminant(place)) => {
let af = match *rvalue {
Rvalue::Len(..) => Some(ArtificialField::ArrayLength),
Rvalue::Discriminant(..) => None,
_ => unreachable!(),
};
self.access_place(
location,
(place, span),
(Shallow(None), Read(ReadKind::Copy)),
(Shallow(af), Read(ReadKind::Copy)),
LocalMutationIsAllowed::No,
state,
);
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_borrowck/src/places_conflict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ fn place_components_conflict<'tcx>(
let base_ty = base.ty(body, tcx).ty;

match (elem, base_ty.kind(), access) {
(_, _, Shallow(Some(ArtificialField::FakeBorrow))) => {
(_, _, Shallow(Some(ArtificialField::ArrayLength)))
| (_, _, Shallow(Some(ArtificialField::FakeBorrow))) => {
// The array length is like additional fields on the
// type; it does not overlap any existing data there.
// Furthermore, if cannot actually be a prefix of any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,16 @@ impl<'a, 'tcx> LoanInvalidationsGenerator<'a, 'tcx> {
self.consume_operand(location, op);
}

&Rvalue::Discriminant(place) => {
&(Rvalue::Len(place) | Rvalue::Discriminant(place)) => {
let af = match rvalue {
Rvalue::Len(..) => Some(ArtificialField::ArrayLength),
Rvalue::Discriminant(..) => None,
_ => unreachable!(),
};
self.access_place(
location,
place,
(Shallow(None), Read(ReadKind::Copy)),
(Shallow(af), Read(ReadKind::Copy)),
LocalMutationIsAllowed::No,
);
}
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_borrowck/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,3 +480,10 @@ pub(crate) struct SimdIntrinsicArgConst {
pub arg: usize,
pub intrinsic: String,
}

#[derive(LintDiagnostic)]
#[diag(borrowck_tail_expr_drop_order)]
pub(crate) struct TailExprDropOrder {
#[label]
pub borrowed: Span,
}
2 changes: 2 additions & 0 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2221,6 +2221,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {

Rvalue::RawPtr(..)
| Rvalue::ThreadLocalRef(..)
| Rvalue::Len(..)
| Rvalue::Discriminant(..)
| Rvalue::NullaryOp(NullOp::OffsetOf(..), _) => {}
}
Expand All @@ -2236,6 +2237,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
| Rvalue::Repeat(..)
| Rvalue::Ref(..)
| Rvalue::RawPtr(..)
| Rvalue::Len(..)
| Rvalue::Cast(..)
| Rvalue::ShallowInitBox(..)
| Rvalue::BinaryOp(..)
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_codegen_cranelift/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,12 @@ fn codegen_stmt<'tcx>(
fx.bcx.ins().nop();
}
}
Rvalue::Len(place) => {
let place = codegen_place(fx, place);
let usize_layout = fx.layout_of(fx.tcx.types.usize);
let len = codegen_array_len(fx, place);
lval.write_cvalue(fx, CValue::by_val(len, usize_layout));
}
Rvalue::ShallowInitBox(ref operand, content_ty) => {
let content_ty = fx.monomorphize(content_ty);
let box_layout = fx.layout_of(Ty::new_box(fx.tcx, content_ty));
Expand Down
Loading
Loading