Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
ac609f9
Distinguish or/refutable/irrefutable patterns in `InterPat`
Zalathar Aug 2, 2026
b12184e
Distinguish or/testable patterns in `MatchPairTree`
Zalathar Aug 2, 2026
128c8a9
Fix HIR lowering of params of trait assoc fns
ChayimFriedman2 Aug 17, 2026
5a9a6d8
ci: Move dependency installs to a separate script
tgross35 Aug 13, 2026
c2a81bf
ci: Enable `CARGO_TERM_VERBOSE`
tgross35 Aug 17, 2026
ca1a7c0
ci: Increase the timeout of MSRV builds
tgross35 Aug 17, 2026
90e1401
ci: Fix the command for local Docker use
tgross35 Aug 17, 2026
d03ac90
ci: Set `-Dlinker_messages`
tgross35 Aug 17, 2026
34ed943
ci: Split and sort docker dependencies
tgross35 Aug 17, 2026
482100d
bench: Update pinned nightly to 2026-08-06
tgross35 Aug 7, 2026
e45bb36
ci: Delete `RUST_TEST_THREADS=1`
tgross35 Aug 17, 2026
cfb82de
enable `f128` tests against system libs on windows
folkertdev Aug 14, 2026
7c99e94
Push a generic params scope for consts
ChayimFriedman2 Aug 17, 2026
06a0163
ci: Don't test with `--benches` in debug mode
tgross35 Aug 18, 2026
90c7ab4
ci: Group output into sections
tgross35 Aug 18, 2026
a52423a
Fix unsafeck of `&raw *`
ChayimFriedman2 Aug 18, 2026
c0a0e10
Rename `#[ppc_alias]` to `#[ppc_name]`
beetrees Aug 18, 2026
18af4dd
c-b: Remove `#[aapcs_on_arm]`
beetrees Aug 18, 2026
c757f71
Prepare for merging from rust-lang/rust
invalid-email-address Aug 20, 2026
ad6805c
Merge ref 'f7d782a3be46' from rust-lang/rust
invalid-email-address Aug 20, 2026
c49aa70
bench: Update pinned nightly to 2026-08-19
tgross35 Aug 20, 2026
b055fad
Switch from `temp-dir` to a homemade `NamedTempFile` implementation
ChayimFriedman2 Aug 20, 2026
1c2b8a1
minor: offer 'add_return_type' after l_curly
A4-Tacks Aug 22, 2026
dee480f
fix: adds-arrow unmap ranges when fn inside macro
A4-Tacks Aug 22, 2026
37c18db
Merge pull request #23215 from A4-Tacks/ret-ty-after-curly
ChayimFriedman2 Aug 24, 2026
04b6536
fix outdated comments
BenjaminBrienen Aug 24, 2026
e4adf9d
Merge pull request #23222 from BenjaminBrienen/outdated-comments
lnicola Aug 24, 2026
4a21a99
Remove callback
A4-Tacks Aug 24, 2026
f5c0420
Merge pull request #23216 from A4-Tacks/arrow-in-macro
ChayimFriedman2 Aug 24, 2026
c5c0004
Remove non-longer-needed remnants from previous versions of the tt en…
ChayimFriedman2 Aug 24, 2026
44ecb1e
Merge pull request #23226 from ChayimFriedman2/remnants-tt
ChayimFriedman2 Aug 24, 2026
20da4a3
Revert "ci: Add a patch for compiler-rt execstack"
nicholasbishop Aug 23, 2026
467cc0c
ci: Disable install-action fallback for nextest
Gelbpunkt Aug 7, 2026
3d8ae4d
test: Allow Clippy's `needless-range-loop`
tgross35 Aug 25, 2026
1df776d
fix: Panic on accessing numeric fields in unions
Wilfred Aug 25, 2026
0ecada9
internal: Improve panic messages on invalid AST nodes
Wilfred Aug 25, 2026
81a8ebe
Merge pull request #23229 from Wilfred/fix/union-tuple-index-panic
ChayimFriedman2 Aug 25, 2026
8dfc9c7
Merge pull request #23230 from Wilfred/ast_node_panics
ChayimFriedman2 Aug 25, 2026
bceece1
fix: Panic on deref of unresolved aliases
Wilfred Aug 21, 2026
68c2ddf
Merge pull request #23212 from Wilfred/fix/deref-projection-panic
ChayimFriedman2 Aug 25, 2026
610f6ff
fix: reinfer never type in array repeat expressions
phpont Aug 25, 2026
e732f6d
Add tests for `extract_variable` assist not applying to patterns.
kpreid Aug 21, 2026
c620c1c
implement `Complex` mul and div
folkertdev Aug 17, 2026
aef7e8b
feat: Allow “Extract variable” to be invoked on field names in record…
kpreid Aug 21, 2026
e853a10
test: Move `AlignedSlice` from the benchmark to `builtins-test`
tgross35 Aug 26, 2026
53e4a92
test: Move `mem` config and setup functions to `builtins-test`
tgross35 Aug 26, 2026
6fcc4fc
bench: Move `mem` from `AlignedVec` to `AlignedSlice`
tgross35 Aug 26, 2026
8c6c020
test: Add a test and icount benchmark for `strlen`
tgross35 Aug 26, 2026
1e4d3fd
ci: build and test with s390x-resolute runner
marcoieni Jul 9, 2026
d7e9e51
Merge pull request #23184 from ChayimFriedman2/raw-ref-deref-twice
ShoyuVanilla Aug 26, 2026
b0b43b4
Merge pull request #23162 from ChayimFriedman2/trait-fn-param
ShoyuVanilla Aug 26, 2026
9acfd1e
Merge pull request #23206 from ChayimFriedman2/tempfile
ShoyuVanilla Aug 26, 2026
f803acc
Merge pull request #23176 from ChayimFriedman2/const-is-type-owner
ShoyuVanilla Aug 26, 2026
75c1da3
Require rustc citation for analysis changes when using AI
ChayimFriedman2 Aug 25, 2026
bbf7921
Change relationship to uv's AI policy from "adapted from" to "inspire…
ChayimFriedman2 Aug 26, 2026
2a525f3
Merge pull request #23233 from rust-lang/require-rustc-citation
ChayimFriedman2 Aug 26, 2026
aa4f033
Merge pull request #23232 from phpont/fix/23177-array-repeat-never
ChayimFriedman2 Aug 26, 2026
1c026c4
fix: Panic when computing extract_variable with macros
Wilfred Aug 26, 2026
5cca6c2
Merge pull request #23213 from kpreid/extract
A4-Tacks Aug 26, 2026
8787b0c
fix: strip leading asterisk decoration from block doc comments
kivancgnlp Aug 26, 2026
0882b29
Merge pull request #22901 from kivancgnlp/fix-block-doc-asterisks
ChayimFriedman2 Aug 26, 2026
ccc0ca9
libm: Remove an MSRV hack that is no longer needed
tgross35 Aug 26, 2026
f9cb5fd
Re-use `substr_range()` in docs
ChayimFriedman2 Aug 26, 2026
6fbb86d
Merge pull request #23238 from Wilfred/fix/extract-variable-multiarg-…
ChayimFriedman2 Aug 26, 2026
650a526
Merge pull request #23239 from ChayimFriedman2/fixup-doc
ChayimFriedman2 Aug 26, 2026
1cbc439
Fix some subtle bugs in docs rendering
ChayimFriedman2 Aug 26, 2026
15bea68
Add `rustup toolchain install nightly` to Miri CI
ChayimFriedman2 Aug 26, 2026
2114c7e
Merge pull request #23241 from rust-lang/ChayimFriedman2-patch-1
ChayimFriedman2 Aug 26, 2026
8e8e72c
fix: range pattern inside a parenthesis parsed as tuple pattern
dfireBird Aug 26, 2026
486fec6
Merge pull request #23242 from dfireBird/push-vrtuqvnutkrn
A4-Tacks Aug 28, 2026
d0f5f03
Print the ABI for fn pointers (if not the default)
ChayimFriedman2 Aug 28, 2026
3f504af
Merge pull request #23245 from ChayimFriedman2/extern-fnptr-display
ChayimFriedman2 Aug 28, 2026
e72874d
fix: Panic when hovering a dyn trait with a binder
Wilfred Aug 28, 2026
dd4a7cf
Merge pull request #23235 from ChayimFriedman2/docs-sugar-rustdoc
Veykril Aug 29, 2026
82ee18a
stabilize map functions
Qelxiros Aug 4, 2026
eb87088
Fix `NamedTempFile`
ChayimFriedman2 Aug 30, 2026
2c64e0a
Merge pull request #23257 from ChayimFriedman2/tmp-file
ChayimFriedman2 Aug 30, 2026
7b2fc49
Merge pull request #23250 from Wilfred/dyn_panic_scip
ChayimFriedman2 Aug 30, 2026
e77df4c
fix: hover on generic output now shows correct type, instead of impl …
j-ricardo-goncalves Aug 29, 2026
f5798ce
Merge pull request #23256 from j-ricardo-goncalves/master
ChayimFriedman2 Aug 30, 2026
178eb4b
attach naked function target features to module assembly
folkertdev Aug 6, 2026
61dec22
c-b: Drop the removed `abi_unadjusted` feature gate
HuzaifaAbdulRehman Aug 30, 2026
7b98255
ci: Disable the i686-pc-windows-gnu job
tgross35 Aug 31, 2026
41258df
Move more `rustdoc-html` tests using `--test` into the right folder
GuillaumeGomez Aug 30, 2026
2a534f5
`BUILTIN_ATTRIBUTE_MAP` improvements
nnethercote Aug 31, 2026
9670dfa
Use `GateFn` in `AttributeStability`
nnethercote Aug 31, 2026
cd09177
Derive `StableHash` for three feature structs
nnethercote Aug 31, 2026
b18fed1
Return a slice instead of `&Vec<T>` in two methods
nnethercote Aug 31, 2026
799c6d0
Various comment improvements
nnethercote Aug 31, 2026
6146d3a
Use `NonZero<u32>` consistently
nnethercote Aug 31, 2026
ca967fa
Add a missing backtick
nnethercote Aug 31, 2026
ef2ae3a
Streamline a check
nnethercote Aug 31, 2026
60be562
Simplify `find_gated_cfg`
nnethercote Aug 31, 2026
8517e0f
Also proc-macro-srv tests on Windows
lnicola Aug 31, 2026
61f12cc
Fix proc-macro-srv on Windows
lnicola Aug 31, 2026
892c6bb
explicitly track inherent const generic args kind
khyperia Aug 31, 2026
614d9ea
Fix invalid `compile-args` ui tests argument
GuillaumeGomez Aug 30, 2026
af2d4bc
Switch dist-aarch64-linux to EC2 and update dist-x86_64-linux
Mark-Simulacrum Aug 30, 2026
6b1b19c
Merge pull request #23264 from lnicola/proc-macro-srv-win-ci
ChayimFriedman2 Aug 31, 2026
1483f9b
remove `_{style}` recovery for diagnostic structs
mejrs Aug 31, 2026
12a11b5
Prepare for merging from rust-lang/rust
folkertdev Aug 31, 2026
56095fb
Merge ref '45f215f136e0' from rust-lang/rust
folkertdev Aug 31, 2026
5d441ff
fix `overprovisioned-secrets` zizmor finding
marcoieni Aug 31, 2026
3d677d3
Merge pull request #23265 from marcoieni/overprovisioned-secrets
lnicola Aug 31, 2026
e18a012
Move track_caller on closures gating to attribute parsing
mejrs Aug 31, 2026
9f89751
Move polonius loan liveness computation prior to RegionInferenceConte…
jackh726 Aug 28, 2026
6ad5c17
Move record_live_region_variance to be a freestanding function
jackh726 Aug 28, 2026
b58ee5b
Minor trace updates
jackh726 Aug 28, 2026
9b44a90
Rollup merge of #162045 - lnicola:sync-from-ra, r=lnicola
JonathanBrouwer Aug 31, 2026
bea8d92
Rollup merge of #162077 - folkertdev:compiler-builtins-sync-2026-09-3…
JonathanBrouwer Aug 31, 2026
4c648c3
Rollup merge of #137720 - folkertdev:naked-function-target-feature, r…
JonathanBrouwer Aug 31, 2026
87181a0
Rollup merge of #160534 - Qelxiros:stabilize-smart-pointer-map, r=nia-e
JonathanBrouwer Aug 31, 2026
392523a
Rollup merge of #160551 - Zalathar:inter-pat, r=Nadrieril
JonathanBrouwer Aug 31, 2026
f2d0e33
Rollup merge of #161929 - khyperia:explicitly-track-inherent-args, r=…
JonathanBrouwer Aug 31, 2026
afcf818
Rollup merge of #162063 - Mark-Simulacrum:aarch64-ec2, r=Kobzol
JonathanBrouwer Aug 31, 2026
fc6c09c
Rollup merge of #161937 - jackh726:polonius-cleanups-2, r=lqd
JonathanBrouwer Aug 31, 2026
5479bda
Rollup merge of #162014 - GuillaumeGomez:more-ui-tests, r=fmease
JonathanBrouwer Aug 31, 2026
bdb840b
Rollup merge of #162051 - nnethercote:rustc_feature-cleanups, r=Jonat…
JonathanBrouwer Aug 31, 2026
0c399be
Rollup merge of #162055 - mejrs:_style, r=JonathanBrouwer
JonathanBrouwer Aug 31, 2026
dca4e59
Rollup merge of #162075 - mejrs:track_caller_closure_gating, r=Jonath…
JonathanBrouwer Aug 31, 2026
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: 2 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3634,6 +3634,7 @@ version = "0.0.0"
dependencies = [
"rustc_abi",
"rustc_ast",
"rustc_attr_ir",
"rustc_attr_parsing",
"rustc_data_structures",
"rustc_errors",
Expand Down Expand Up @@ -4068,6 +4069,7 @@ name = "rustc_feature"
version = "0.0.0"
dependencies = [
"rustc_data_structures",
"rustc_macros",
"rustc_span",
"serde",
"serde_json",
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_ast_lowering/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ doctest = false
# tidy-alphabetical-start
rustc_abi = { path = "../rustc_abi" }
rustc_ast = { path = "../rustc_ast" }
rustc_attr_ir = { path = "../rustc_attr_ir" }
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
Expand Down
42 changes: 12 additions & 30 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ use std::ops::ControlFlow;
use std::sync::Arc;

use rustc_ast::node_id::NodeMap;
use rustc_ast::visit::{Visitor, walk_expr};
use rustc_ast::*;
use rustc_attr_ir::lang_items::LangItem;
use rustc_attr_ir::target::Target;
use rustc_errors::msg;
use rustc_hir as hir;
use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::HirId;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::{HirId, Target, find_attr};
use rustc_middle::span_bug;
use rustc_middle::ty::TyCtxt;
use rustc_session::diagnostics::report_lit_error;
use rustc_span::{ByteSymbol, DUMMY_SP, DesugaringKind, Ident, Span, Spanned, Symbol, respan, sym};
use thin_vec::{ThinVec, thin_vec};
use visit::{Visitor, walk_expr};

mod closure;

use crate::diagnostics::{
Expand Down Expand Up @@ -882,35 +882,17 @@ impl<'hir> LoweringContext<'_, 'hir> {

/// Forwards a possible `#[track_caller]` annotation from `outer_hir_id` to
/// `inner_hir_id` in case the `async_fn_track_caller` feature is enabled.
pub(super) fn maybe_forward_track_caller(
&mut self,
span: Span,
outer_hir_id: HirId,
inner_hir_id: HirId,
) {
pub(super) fn maybe_forward_track_caller(&mut self, outer_hir_id: HirId, inner_hir_id: HirId) {
if self.tcx.features().async_fn_track_caller()
&& let Some(attrs) = self.attrs.get(&outer_hir_id.local_id)
&& find_attr!(*attrs, TrackCaller(_))
&& let Some(t) = attrs.iter().find(|a| {
matches!(
a,
rustc_attr_ir::Attribute::Parsed(rustc_attr_ir::AttributeKind::TrackCaller(_))
)
})
{
let unstable_span = self.mark_span_with_reason(
DesugaringKind::Async,
span,
Some(Arc::clone(&self.allow_gen_future)),
);
self.lower_attrs(
inner_hir_id,
&[Attribute {
kind: AttrKind::Normal(Box::new(NormalAttr::from_ident(Ident::new(
sym::track_caller,
span,
)))),
id: self.tcx.sess.psess.attr_id_generator.mk_attr_id(),
style: AttrStyle::Outer,
span: unstable_span,
}],
span,
Target::Fn,
);
self.attrs.insert(inner_hir_id.local_id, std::slice::from_ref(t));
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/expr/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
)
});

this.maybe_forward_track_caller(body.span, closure_hir_id, expr.hir_id);
this.maybe_forward_track_caller(closure_hir_id, expr.hir_id);

(parameters, expr)
});
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,7 @@ impl<'hir> LoweringContext<'_, 'hir> {

// FIXME(async_fn_track_caller): Can this be moved above?
let hir_id = expr.hir_id;
this.maybe_forward_track_caller(body.span, fn_id, hir_id);
this.maybe_forward_track_caller(fn_id, hir_id);

(parameters, expr)
})
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ fn parse_cfg_attr_internal<'a>(
}

fn try_gate_cfg(name: Symbol, span: Span, sess: &Session, features: Option<&Features>) {
let gate = find_gated_cfg(|sym| sym == name);
let gate = find_gated_cfg(name);
if let (Some(feats), Some(gated_cfg)) = (features, gate) {
gate_cfg(gated_cfg, span, sess, feats);
}
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,15 @@ impl NoArgsAttributeParser for TrackCallerParser {
});
}
}
Target::Closure if !cx.features().closure_track_caller() => {
feature_err(
cx.sess(),
sym::closure_track_caller,
attr_span,
"`#[track_caller]` on closures is currently unstable",
)
.emit();
}
_ => {}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn check_keyword(cx: &mut AcceptContext<'_, '_>, keyword: Symbol, span: Span) ->

fn check_attribute(cx: &mut AcceptContext<'_, '_>, attribute: Symbol, span: Span) -> bool {
// FIXME: This should support attributes with namespace like `diagnostic::do_not_recommend`.
if rustc_feature::BUILTIN_ATTRIBUTE_MAP.contains(&attribute) {
if rustc_feature::BUILTIN_ATTRIBUTE_SET.contains(&attribute) {
return true;
}
cx.emit_err(DocAttributeNotAttribute { span, attribute });
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_attr_parsing/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc_attr_ir::target::Target;
use rustc_attr_ir::{AttrArgs, AttrItem, AttrPath, Attribute, AttributeKind, HashIgnoredAttrId};
use rustc_data_structures::sync::{DynSend, DynSync};
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level, MultiSpan};
use rustc_feature::{BUILTIN_ATTRIBUTE_MAP, Features};
use rustc_feature::{BUILTIN_ATTRIBUTE_SET, Features};
use rustc_lint_defs::{LintId, RegisteredTools};
use rustc_session::Session;
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Symbol, sym};
Expand Down Expand Up @@ -376,7 +376,7 @@ impl<'sess> AttributeParser<'sess> {
);
self.check_attribute_stability(&attr_path, attr_span, accept.stability);
if let [part] = parts.as_slice() {
debug_assert!(BUILTIN_ATTRIBUTE_MAP.contains(part));
debug_assert!(BUILTIN_ATTRIBUTE_SET.contains(part));
}

let Some(args) = ArgParser::from_attr_args(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_attr_parsing/src/validate_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rustc_ast::{
};
use rustc_attr_ir::AttrPath;
use rustc_errors::{Applicability, Diagnostic, PResult};
use rustc_feature::BUILTIN_ATTRIBUTE_MAP;
use rustc_feature::BUILTIN_ATTRIBUTE_SET;
use rustc_lint_defs::builtin::ILL_FORMED_ATTRIBUTE_INPUT;
use rustc_parse::parse_in;
use rustc_session::diagnostics::report_lit_error;
Expand All @@ -27,7 +27,7 @@ pub fn check_attr(psess: &ParseSess, attr: &Attribute) {
AttrKind::Synthetic(CfgTrace(_) | CfgAttrTrace(_)) | AttrKind::DocComment(..) => return,
}

let builtin_attr_info = attr.name().and_then(|name| BUILTIN_ATTRIBUTE_MAP.get(&name));
let builtin_attr_info = attr.name().and_then(|name| BUILTIN_ATTRIBUTE_SET.get(&name));

// Check input tokens for built-in and key-value attributes.
if let Some(name) = builtin_attr_info {
Expand Down
23 changes: 15 additions & 8 deletions compiler/rustc_borrowck/src/nll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub(crate) fn compute_regions<'tcx>(
let polonius_output = root_cx.consumer.as_ref().map_or(false, |c| c.polonius_output())
|| infcx.tcx.sess.opts.unstable_opts.polonius.is_legacy_enabled();

let lowered_constraints = compute_sccs_applying_placeholder_outlives_constraints(
let mut lowered_constraints = compute_sccs_applying_placeholder_outlives_constraints(
constraints,
&universal_region_relations,
infcx,
Expand All @@ -144,20 +144,27 @@ pub(crate) fn compute_regions<'tcx>(
&lowered_constraints,
);

// If requested for `-Zpolonius=next`, compute loan liveness information.
// This is done prior to `RegionInferenceContext::new`, because we may add
// additional liveness constraints.
if let Some(polonius_context) = polonius_context.as_mut() {
let _timer = infcx.tcx.prof.generic_activity("borrowck_polonius_loan_liveness");
polonius_context.compute_loan_liveness(
&mut lowered_constraints.liveness_constraints,
lowered_constraints.outlives_constraints.outlives().iter().copied(),
&universal_region_relations.universal_regions,
body,
borrow_set,
);
}

let mut regioncx = RegionInferenceContext::new(
infcx,
lowered_constraints,
universal_region_relations,
location_map,
);

// If requested for `-Zpolonius=next`, convert NLL constraints to localized outlives constraints
// and use them to compute loan liveness.
if let Some(polonius_context) = polonius_context.as_mut() {
let _timer = infcx.tcx.prof.generic_activity("borrowck_polonius_loan_liveness");
polonius_context.compute_loan_liveness(&mut regioncx, body, borrow_set)
}

// If requested: dump NLL facts, and run legacy polonius analysis.
let polonius_output = polonius_facts.as_ref().and_then(|polonius_facts| {
if infcx.tcx.sess.opts.unstable_opts.nll_facts {
Expand Down
32 changes: 15 additions & 17 deletions compiler/rustc_borrowck/src/polonius/liveness_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,23 @@ use rustc_middle::ty::relate::{
};
use rustc_middle::ty::{self, RegionVid, Ty, TyCtxt, TypeVisitable};

use super::{ConstraintDirection, PoloniusContext};
use super::ConstraintDirection;
use crate::universal_regions::UniversalRegions;

impl PoloniusContext {
/// Record the variance of each region contained within the given value.
pub(crate) fn record_live_region_variance<'tcx>(
&mut self,
tcx: TyCtxt<'tcx>,
universal_regions: &UniversalRegions<'tcx>,
value: impl TypeVisitable<TyCtxt<'tcx>> + Relate<TyCtxt<'tcx>>,
) {
let mut extractor = VarianceExtractor {
tcx,
ambient_variance: ty::Variance::Covariant,
directions: &mut self.live_region_variances,
universal_regions,
};
extractor.relate(value, value).expect("Can't have a type error relating to itself");
}
/// Record the variance of each region contained within the given value.
pub(crate) fn record_live_region_variance<'tcx>(
tcx: TyCtxt<'tcx>,
live_region_variances: &mut BTreeMap<RegionVid, ConstraintDirection>,
universal_regions: &UniversalRegions<'tcx>,
value: impl TypeVisitable<TyCtxt<'tcx>> + Relate<TyCtxt<'tcx>>,
) {
let mut extractor = VarianceExtractor {
tcx,
ambient_variance: ty::Variance::Covariant,
directions: live_region_variances,
universal_regions,
};
extractor.relate(value, value).expect("Can't have a type error relating to itself");
}

/// Extracts variances for regions contained within types. Follows the same structure as
Expand Down
21 changes: 12 additions & 9 deletions compiler/rustc_borrowck/src/polonius/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ use rustc_mir_dataflow::points::PointIndex;

pub(self) use self::constraints::*;
pub(crate) use self::dump::dump_polonius_mir;
pub(crate) use self::liveness_constraints::record_live_region_variance;
use crate::BorrowSet;
use crate::constraints::OutlivesConstraint;
use crate::dataflow::BorrowIndex;
use crate::region_infer::values::LivenessValues;
use crate::{BorrowSet, RegionInferenceContext};
use crate::universal_regions::UniversalRegions;

pub(crate) type LiveLoans = SparseBitMatrix<PointIndex, BorrowIndex>;

Expand All @@ -65,7 +68,7 @@ pub(crate) struct PoloniusContext {

/// The expected edge direction per live region: the kind of directed edge we'll create as
/// liveness constraints depends on the variance of types with respect to each contained region.
live_region_variances: BTreeMap<RegionVid, ConstraintDirection>,
pub(crate) live_region_variances: BTreeMap<RegionVid, ConstraintDirection>,

/// The regions that outlive free regions are used to distinguish relevant live locals from
/// boring locals. A boring local is one whose type contains only such regions. Polonius
Expand All @@ -77,7 +80,7 @@ pub(crate) struct PoloniusContext {
/// The direction a constraint can flow into. Used to create liveness constraints according to
/// variance.
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
enum ConstraintDirection {
pub(crate) enum ConstraintDirection {
/// For covariant cases, we add a forward edge `O at P1 -> O at P2`.
Forward,

Expand All @@ -101,31 +104,31 @@ impl PoloniusContext {
/// The constraint data will be used to compute errors and diagnostics.
pub(crate) fn compute_loan_liveness<'tcx>(
&mut self,
regioncx: &mut RegionInferenceContext<'tcx>,
liveness: &mut LivenessValues,
outlives_constraints: impl Iterator<Item = OutlivesConstraint<'tcx>>,
universal_regions: &UniversalRegions<'tcx>,
body: &Body<'tcx>,
borrow_set: &BorrowSet<'tcx>,
) {
let liveness = regioncx.liveness_constraints();

// We don't need to prepare the graph (index NLL constraints, etc.) if we have no loans to
// trace throughout localized constraints.
if borrow_set.len() > 0 {
// From the outlives constraints, liveness, and variances, we can compute reachability
// on the lazy localized constraint graph to trace the liveness of loans, for the next
// step in the chain (the NLL loan scope and active loans computations).
let graph = LocalizedConstraintGraph::new(liveness, regioncx.outlives_constraints());
let graph = LocalizedConstraintGraph::new(liveness, outlives_constraints);

let mut live_loans = LiveLoans::new(borrow_set.len());
let mut visitor = LoanLivenessVisitor { liveness, live_loans: &mut live_loans };
graph.traverse(
body,
liveness,
&self.live_region_variances,
regioncx.universal_regions(),
universal_regions,
borrow_set,
&mut visitor,
);
regioncx.record_live_loans(live_loans);
liveness.record_live_loans(live_loans);

// The graph can be traversed again during MIR dumping, so we store it here.
self.graph = Some(graph);
Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use crate::constraints::{ConstraintSccIndex, OutlivesConstraint, OutlivesConstra
use crate::dataflow::BorrowIndex;
use crate::diagnostics::{RegionErrorKind, RegionErrors, UniverseInfo};
use crate::handle_placeholders::{LoweredConstraints, RegionTracker};
use crate::polonius::LiveLoans;
use crate::polonius::legacy::PoloniusOutput;
use crate::region_infer::values::{LivenessValues, RegionElement, RegionValues};
use crate::type_check::Locations;
Expand Down Expand Up @@ -1874,12 +1873,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
&self.liveness_constraints
}

/// When using `-Zpolonius=next`, records the given live loans for the loan scopes and active
/// loans dataflow computations.
pub(crate) fn record_live_loans(&mut self, live_loans: LiveLoans) {
self.liveness_constraints.record_live_loans(live_loans);
}

/// Returns whether the `loan_idx` is live at the given `location`: whether its issuing
/// region is contained within the type of a variable that is live at this point.
/// Note: for now, the sets of live loans is only available when using `-Zpolonius=next`.
Expand Down
11 changes: 8 additions & 3 deletions compiler/rustc_borrowck/src/type_check/liveness/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use tracing::debug;

use super::TypeChecker;
use crate::constraints::OutlivesConstraintSet;
use crate::polonius::PoloniusContext;
use crate::polonius::{PoloniusContext, record_live_region_variance};
use crate::region_infer::values::LivenessValues;
use crate::universal_regions::UniversalRegions;

Expand Down Expand Up @@ -67,7 +67,7 @@ pub(super) fn generate<'tcx>(
let (relevant_live_locals, boring_locals) =
compute_relevant_live_locals(typeck.tcx(), &free_regions, typeck.body);

trace::trace(typeck, location_map, move_data, relevant_live_locals, boring_locals);
trace::trace(typeck, location_map, move_data, &relevant_live_locals, &boring_locals);

// Mark regions that should be live where they appear within rvalues or within a call: like
// args, regions, and types.
Expand Down Expand Up @@ -220,7 +220,12 @@ impl<'a, 'tcx> LiveVariablesVisitor<'a, 'tcx> {

// When using `-Zpolonius=next`, we record the variance of each live region.
if let Some(polonius_context) = self.polonius_context {
polonius_context.record_live_region_variance(self.tcx, self.universal_regions, value);
record_live_region_variance(
self.tcx,
&mut polonius_context.live_region_variances,
self.universal_regions,
value,
);
}
}
}
Loading
Loading