Skip to content

Commit d7daac0

Browse files
committed
Auto merge of #152562 - Zalathar:rollup-tQDKhYQ, r=Zalathar
Rollup of 17 pull requests Successful merges: - #150551 (Compute localized outlives constraints lazily) - #150988 (Improve code suggestion for incorrect macro_rules! usage) - #152422 (Change query proc macro to be more rust-analyzer friendly) - #152496 (Fix multi-cgu+debug builds using autodiff by delaying autodiff till lto) - #152514 (Collect active query jobs into struct `QueryJobMap`) - #152520 (Don't use `DepContext` in `rustc_middle::traits::cache`) - #152528 (Support serializing CodegenContext) - #152082 (Move tests) - #152232 (Add must_use for FileTimes) - #152329 (Simplify parallel! macro) - #152444 (`-Znext-solver` Prevent committing unfulfilled unsized coercion) - #152486 (remove redundant backchain attribute in codegen) - #152519 (Fix feature gating for new `try bikeshed` expressions) - #152529 (sparc64: enable abi compatibility test) - #152548 (reject inline const patterns pre-expansion) - #152550 (Port #[prelude_import] to the attribute parser) - #152552 (Add 2048-bit HvxVectorPair support to Hexagon SIMD ABI checks) Failed merges: - #152515 (Extract `DepKindVTable` constructors to their own module)
2 parents 47611e1 + b9ce1e0 commit d7daac0

File tree

111 files changed

+1548
-1282
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+1548
-1282
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,15 +338,11 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
338338
fn visit_expr(&mut self, e: &'a ast::Expr) {
339339
match e.kind {
340340
ast::ExprKind::TryBlock(_, None) => {
341+
// `try { ... }` is old and is only gated post-expansion here.
341342
gate!(&self, try_blocks, e.span, "`try` expression is experimental");
342343
}
343344
ast::ExprKind::TryBlock(_, Some(_)) => {
344-
gate!(
345-
&self,
346-
try_blocks_heterogeneous,
347-
e.span,
348-
"`try bikeshed` expression is experimental"
349-
);
345+
// `try_blocks_heterogeneous` is new, and gated pre-expansion instead.
350346
}
351347
ast::ExprKind::Lit(token::Lit {
352348
kind: token::LitKind::Float | token::LitKind::Integer,
@@ -522,6 +518,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
522518
half_open_range_patterns_in_slices,
523519
"half-open range patterns in slices are unstable"
524520
);
521+
gate_all!(try_blocks_heterogeneous, "`try bikeshed` expression is experimental");
525522
gate_all!(yeet_expr, "`do yeet` expression is experimental");
526523
gate_all!(const_closures, "const closures are experimental");
527524
gate_all!(builtin_syntax, "`builtin #` syntax is unstable");

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,3 +1211,12 @@ impl<S: Stage> SingleAttributeParser<S> for RustcReservationImplParser {
12111211
Some(AttributeKind::RustcReservationImpl(cx.attr_span, value_str))
12121212
}
12131213
}
1214+
1215+
pub(crate) struct PreludeImportParser;
1216+
1217+
impl<S: Stage> NoArgsAttributeParser<S> for PreludeImportParser {
1218+
const PATH: &[Symbol] = &[sym::prelude_import];
1219+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
1220+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Use)]);
1221+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::PreludeImport;
1222+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ attribute_parsers!(
258258
Single<WithoutArgs<PassByValueParser>>,
259259
Single<WithoutArgs<PinV2Parser>>,
260260
Single<WithoutArgs<PointeeParser>>,
261+
Single<WithoutArgs<PreludeImportParser>>,
261262
Single<WithoutArgs<ProcMacroAttributeParser>>,
262263
Single<WithoutArgs<ProcMacroParser>>,
263264
Single<WithoutArgs<ProfilerRuntimeParser>>,

compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,8 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
649649
// We want to focus on relevant live locals in diagnostics, so when polonius is enabled, we
650650
// ensure that we don't emit live boring locals as explanations.
651651
let is_local_boring = |local| {
652-
if let Some(polonius_diagnostics) = self.polonius_diagnostics {
653-
polonius_diagnostics.boring_nll_locals.contains(&local)
652+
if let Some(polonius_context) = self.polonius_context {
653+
polonius_context.boring_nll_locals.contains(&local)
654654
} else {
655655
assert!(!tcx.sess.opts.unstable_opts.polonius.is_next_enabled());
656656

compiler/rustc_borrowck/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ use crate::diagnostics::{
6363
use crate::path_utils::*;
6464
use crate::place_ext::PlaceExt;
6565
use crate::places_conflict::{PlaceConflictBias, places_conflict};
66+
use crate::polonius::PoloniusContext;
6667
use crate::polonius::legacy::{
6768
PoloniusFacts, PoloniusFactsExt, PoloniusLocationTable, PoloniusOutput,
6869
};
69-
use crate::polonius::{PoloniusContext, PoloniusDiagnosticsContext};
7070
use crate::prefixes::PrefixSet;
7171
use crate::region_infer::RegionInferenceContext;
7272
use crate::region_infer::opaque_types::DeferredOpaqueTypeError;
@@ -424,7 +424,7 @@ fn borrowck_check_region_constraints<'tcx>(
424424
polonius_output,
425425
opt_closure_req,
426426
nll_errors,
427-
polonius_diagnostics,
427+
polonius_context,
428428
} = nll::compute_regions(
429429
root_cx,
430430
&infcx,
@@ -448,7 +448,7 @@ fn borrowck_check_region_constraints<'tcx>(
448448
&regioncx,
449449
&opt_closure_req,
450450
&borrow_set,
451-
polonius_diagnostics.as_ref(),
451+
polonius_context.as_ref(),
452452
);
453453

454454
// We also have a `#[rustc_regions]` annotation that causes us to dump
@@ -490,7 +490,7 @@ fn borrowck_check_region_constraints<'tcx>(
490490
polonius_output: None,
491491
move_errors: Vec::new(),
492492
diags_buffer,
493-
polonius_diagnostics: polonius_diagnostics.as_ref(),
493+
polonius_context: polonius_context.as_ref(),
494494
};
495495
struct MoveVisitor<'a, 'b, 'infcx, 'tcx> {
496496
ctxt: &'a mut MirBorrowckCtxt<'b, 'infcx, 'tcx>,
@@ -529,7 +529,7 @@ fn borrowck_check_region_constraints<'tcx>(
529529
move_errors: Vec::new(),
530530
diags_buffer,
531531
polonius_output: polonius_output.as_deref(),
532-
polonius_diagnostics: polonius_diagnostics.as_ref(),
532+
polonius_context: polonius_context.as_ref(),
533533
};
534534

535535
// Compute and report region errors, if any.
@@ -779,7 +779,7 @@ struct MirBorrowckCtxt<'a, 'infcx, 'tcx> {
779779
/// Results of Polonius analysis.
780780
polonius_output: Option<&'a PoloniusOutput>,
781781
/// When using `-Zpolonius=next`: the data used to compute errors and diagnostics.
782-
polonius_diagnostics: Option<&'a PoloniusDiagnosticsContext>,
782+
polonius_context: Option<&'a PoloniusContext>,
783783
}
784784

785785
// Check that:

compiler/rustc_borrowck/src/nll.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ use crate::borrow_set::BorrowSet;
2323
use crate::consumers::RustcFacts;
2424
use crate::diagnostics::RegionErrors;
2525
use crate::handle_placeholders::compute_sccs_applying_placeholder_outlives_constraints;
26+
use crate::polonius::PoloniusContext;
2627
use crate::polonius::legacy::{
2728
PoloniusFacts, PoloniusFactsExt, PoloniusLocationTable, PoloniusOutput,
2829
};
29-
use crate::polonius::{PoloniusContext, PoloniusDiagnosticsContext};
3030
use crate::region_infer::RegionInferenceContext;
3131
use crate::type_check::MirTypeckRegionConstraints;
3232
use crate::type_check::free_region_relations::UniversalRegionRelations;
@@ -47,7 +47,7 @@ pub(crate) struct NllOutput<'tcx> {
4747

4848
/// When using `-Zpolonius=next`: the data used to compute errors and diagnostics, e.g.
4949
/// localized typeck and liveness constraints.
50-
pub polonius_diagnostics: Option<PoloniusDiagnosticsContext>,
50+
pub polonius_context: Option<PoloniusContext>,
5151
}
5252

5353
/// Rewrites the regions in the MIR to use NLL variables, also scraping out the set of universal
@@ -122,7 +122,7 @@ pub(crate) fn compute_regions<'tcx>(
122122
universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>,
123123
constraints: MirTypeckRegionConstraints<'tcx>,
124124
mut polonius_facts: Option<AllFacts<RustcFacts>>,
125-
polonius_context: Option<PoloniusContext>,
125+
mut polonius_context: Option<PoloniusContext>,
126126
) -> NllOutput<'tcx> {
127127
let polonius_output = root_cx.consumer.as_ref().map_or(false, |c| c.polonius_output())
128128
|| infcx.tcx.sess.opts.unstable_opts.polonius.is_legacy_enabled();
@@ -154,9 +154,9 @@ pub(crate) fn compute_regions<'tcx>(
154154

155155
// If requested for `-Zpolonius=next`, convert NLL constraints to localized outlives constraints
156156
// and use them to compute loan liveness.
157-
let polonius_diagnostics = polonius_context.map(|polonius_context| {
158-
polonius_context.compute_loan_liveness(infcx.tcx, &mut regioncx, body, borrow_set)
159-
});
157+
if let Some(polonius_context) = polonius_context.as_mut() {
158+
polonius_context.compute_loan_liveness(&mut regioncx, body, borrow_set)
159+
}
160160

161161
// If requested: dump NLL facts, and run legacy polonius analysis.
162162
let polonius_output = polonius_facts.as_ref().and_then(|polonius_facts| {
@@ -189,7 +189,7 @@ pub(crate) fn compute_regions<'tcx>(
189189
polonius_output,
190190
opt_closure_req: closure_region_requirements,
191191
nll_errors,
192-
polonius_diagnostics,
192+
polonius_context,
193193
}
194194
}
195195

0 commit comments

Comments
 (0)