Skip to content

Rollup of 9 pull requests #141868

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

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5f294f0
Improve test for FQS tuple struct pat/expr
WaffleLapkin Apr 26, 2025
bce7fe1
Make error for tuple struct pat/expr w/ FQS clearer
WaffleLapkin Apr 27, 2025
8f765fc
bless tests
WaffleLapkin Apr 27, 2025
f886925
Exclude `CARGO_HOME` from `generate-copyright` in-tree determination
Hoverbear May 30, 2025
95115b9
Drive-by refactor: use `OnceCell` for the reverse region SCC graph
amandasystems May 31, 2025
a8b5e70
source_span_for_markdown_range: fix utf8 violation
lolbinarycat May 27, 2025
f388c98
terminology: allocated object → allocation
RalfJung May 18, 2025
810a564
Fix TLS model on bootstrap for cygwin
Berrysoft Jun 1, 2025
bdd680f
Add unimplemented `current_dll_path()` for WASI
Timmmm Mar 22, 2025
f023a69
Async drop - type instead of async drop fn and incorrect drop signatu…
azhogin May 28, 2025
a71c00a
resolve if-let-chain FIXME on bootstrap
onur-ozkan Jun 1, 2025
dde892c
Rollup merge of #140370 - WaffleLapkin:unqualified, r=jdonszelmann
GuillaumeGomez Jun 1, 2025
ad649bd
Rollup merge of #141224 - RalfJung:no-objects, r=traviscross
GuillaumeGomez Jun 1, 2025
d1fa33d
Rollup merge of #141666 - lolbinarycat:rustdoc-source_span_for_markdo…
GuillaumeGomez Jun 1, 2025
dc46f17
Rollup merge of #141677 - azhogin:azhogin/async-drop-unexpected-type-…
GuillaumeGomez Jun 1, 2025
861144c
Rollup merge of #141789 - ferrocene:hoverbear/exclude-cargo-home-from…
GuillaumeGomez Jun 1, 2025
04c9bb0
Rollup merge of #141823 - amandasystems:reverse_scc_graph_once_cell, …
GuillaumeGomez Jun 1, 2025
0288f6b
Rollup merge of #141834 - Timmmm:user/timh/wasi, r=Noratrieb
GuillaumeGomez Jun 1, 2025
1b4a695
Rollup merge of #141846 - Berrysoft:cygwin-bootstrap-tls, r=mati865
GuillaumeGomez Jun 1, 2025
b3cbb97
Rollup merge of #141852 - onur-ozkan:resolve-if-let-fixme, r=jieyouxu
GuillaumeGomez Jun 1, 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
12 changes: 5 additions & 7 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::cell::OnceCell;
use std::collections::VecDeque;
use std::rc::Rc;

Expand Down Expand Up @@ -197,8 +198,8 @@ pub struct RegionInferenceContext<'tcx> {

/// Reverse of the SCC constraint graph -- i.e., an edge `A -> B` exists if
/// `B: A`. This is used to compute the universal regions that are required
/// to outlive a given SCC. Computed lazily.
rev_scc_graph: Option<ReverseSccGraph>,
/// to outlive a given SCC.
rev_scc_graph: OnceCell<ReverseSccGraph>,

/// The "R0 member of [R1..Rn]" constraints, indexed by SCC.
member_constraints: Rc<MemberConstraintSet<'tcx, ConstraintSccIndex>>,
Expand Down Expand Up @@ -502,7 +503,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
constraint_graph,
constraint_sccs,
scc_annotations,
rev_scc_graph: None,
rev_scc_graph: OnceCell::new(),
member_constraints,
member_constraints_applied: Vec::new(),
universe_causes,
Expand Down Expand Up @@ -809,9 +810,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
member_constraint_index: NllMemberConstraintIndex,
choice_regions: &[ty::RegionVid],
) {
// Lazily compute the reverse graph, we'll need it later.
self.compute_reverse_scc_graph();

// Create a mutable vector of the options. We'll try to winnow
// them down.
let mut choice_regions: Vec<ty::RegionVid> = choice_regions.to_vec();
Expand Down Expand Up @@ -849,7 +847,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
// R0`). Therefore, we need only keep an option `O` if `UB: O`
// for all UB.
let universal_region_relations = &self.universal_region_relations;
for ub in self.rev_scc_graph.as_ref().unwrap().upper_bounds(scc) {
for ub in self.reverse_scc_graph().upper_bounds(scc) {
debug!(?ub);
choice_regions.retain(|&o_r| universal_region_relations.outlives(ub, o_r));
}
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_borrowck/src/region_infer/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
// FIXME: We could probably compute the LUB if there is one.
let scc = self.constraint_sccs.scc(vid);
let upper_bounds: Vec<_> = self
.rev_scc_graph
.as_ref()
.unwrap()
.reverse_scc_graph()
.upper_bounds(scc)
.filter_map(|vid| self.definitions[vid].external_name)
.filter(|r| !r.is_static())
Expand Down
13 changes: 5 additions & 8 deletions compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,10 @@ impl ReverseSccGraph {
}

impl RegionInferenceContext<'_> {
/// Compute the reverse SCC-based constraint graph (lazily).
pub(super) fn compute_reverse_scc_graph(&mut self) {
if self.rev_scc_graph.is_some() {
return;
}

self.rev_scc_graph =
Some(ReverseSccGraph::compute(&self.constraint_sccs, self.universal_regions()));
/// Return the reverse graph of the region SCCs, initialising it if needed.
pub(super) fn reverse_scc_graph(&self) -> &ReverseSccGraph {
self.rev_scc_graph.get_or_init(|| {
ReverseSccGraph::compute(&self.constraint_sccs, self.universal_regions())
})
}
}
16 changes: 14 additions & 2 deletions compiler/rustc_mir_transform/src/elaborate_drop.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{fmt, iter, mem};

use rustc_abi::{FIRST_VARIANT, FieldIdx, VariantIdx};
use rustc_hir::def::DefKind;
use rustc_hir::lang_items::LangItem;
use rustc_index::Idx;
use rustc_middle::mir::*;
Expand Down Expand Up @@ -254,8 +255,19 @@ where
// impl_item_refs may be empty if drop fn is not implemented in 'impl AsyncDrop for ...'
// (#140974).
// Such code will report error, so just generate sync drop here and return
let Some(drop_fn_def_id) =
tcx.associated_item_def_ids(drop_trait).into_iter().nth(0).copied()
let Some(drop_fn_def_id) = tcx
.associated_item_def_ids(drop_trait)
.first()
.and_then(|def_id| {
if tcx.def_kind(def_id) == DefKind::AssocFn
&& tcx.check_args_compatible(*def_id, trait_args)
{
Some(def_id)
} else {
None
}
})
.copied()
else {
tcx.dcx().span_delayed_bug(
self.elaborator.body().span,
Expand Down
31 changes: 19 additions & 12 deletions compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ pub(crate) enum AliasPossibility {
}

#[derive(Copy, Clone, Debug)]
pub(crate) enum PathSource<'a> {
pub(crate) enum PathSource<'a, 'c> {
/// Type paths `Path`.
Type,
/// Trait paths in bounds or impls.
Expand All @@ -429,7 +429,10 @@ pub(crate) enum PathSource<'a> {
/// Paths in tuple struct patterns `Path(..)`.
TupleStruct(Span, &'a [Span]),
/// `m::A::B` in `<T as m::A>::B::C`.
TraitItem(Namespace),
///
/// Second field holds the "cause" of this one, i.e. the context within
/// which the trait item is resolved. Used for diagnostics.
TraitItem(Namespace, &'c PathSource<'a, 'c>),
/// Paths in delegation item
Delegation,
/// An arg in a `use<'a, N>` precise-capturing bound.
Expand All @@ -440,7 +443,7 @@ pub(crate) enum PathSource<'a> {
DefineOpaques,
}

impl<'a> PathSource<'a> {
impl<'a> PathSource<'a, '_> {
fn namespace(self) -> Namespace {
match self {
PathSource::Type
Expand All @@ -452,7 +455,7 @@ impl<'a> PathSource<'a> {
| PathSource::TupleStruct(..)
| PathSource::Delegation
| PathSource::ReturnTypeNotation => ValueNS,
PathSource::TraitItem(ns) => ns,
PathSource::TraitItem(ns, _) => ns,
PathSource::PreciseCapturingArg(ns) => ns,
}
}
Expand Down Expand Up @@ -480,8 +483,9 @@ impl<'a> PathSource<'a> {
PathSource::Trait(_) => "trait",
PathSource::Pat => "unit struct, unit variant or constant",
PathSource::Struct => "struct, variant or union type",
PathSource::TupleStruct(..) => "tuple struct or tuple variant",
PathSource::TraitItem(ns) => match ns {
PathSource::TraitItem(ValueNS, PathSource::TupleStruct(..))
| PathSource::TupleStruct(..) => "tuple struct or tuple variant",
PathSource::TraitItem(ns, _) => match ns {
TypeNS => "associated type",
ValueNS => "method or associated constant",
MacroNS => bug!("associated macro"),
Expand Down Expand Up @@ -585,7 +589,7 @@ impl<'a> PathSource<'a> {
) | Res::SelfTyParam { .. }
| Res::SelfTyAlias { .. }
),
PathSource::TraitItem(ns) => match res {
PathSource::TraitItem(ns, _) => match res {
Res::Def(DefKind::AssocConst | DefKind::AssocFn, _) if ns == ValueNS => true,
Res::Def(DefKind::AssocTy, _) if ns == TypeNS => true,
_ => false,
Expand Down Expand Up @@ -2007,7 +2011,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
&mut self,
partial_res: PartialRes,
path: &[Segment],
source: PathSource<'_>,
source: PathSource<'_, '_>,
path_span: Span,
) {
let proj_start = path.len() - partial_res.unresolved_segments();
Expand Down Expand Up @@ -4206,7 +4210,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
id: NodeId,
qself: &Option<P<QSelf>>,
path: &Path,
source: PathSource<'ast>,
source: PathSource<'ast, '_>,
) {
self.smart_resolve_path_fragment(
qself,
Expand All @@ -4223,7 +4227,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
&mut self,
qself: &Option<P<QSelf>>,
path: &[Segment],
source: PathSource<'ast>,
source: PathSource<'ast, '_>,
finalize: Finalize,
record_partial_res: RecordPartialRes,
parent_qself: Option<&QSelf>,
Expand Down Expand Up @@ -4404,6 +4408,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
path_span,
source.defer_to_typeck(),
finalize,
source,
) {
Ok(Some(partial_res)) if let Some(res) = partial_res.full_res() => {
// if we also have an associated type that matches the ident, stash a suggestion
Expand Down Expand Up @@ -4526,12 +4531,13 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
span: Span,
defer_to_typeck: bool,
finalize: Finalize,
source: PathSource<'ast, '_>,
) -> Result<Option<PartialRes>, Spanned<ResolutionError<'ra>>> {
let mut fin_res = None;

for (i, &ns) in [primary_ns, TypeNS, ValueNS].iter().enumerate() {
if i == 0 || ns != primary_ns {
match self.resolve_qpath(qself, path, ns, finalize)? {
match self.resolve_qpath(qself, path, ns, finalize, source)? {
Some(partial_res)
if partial_res.unresolved_segments() == 0 || defer_to_typeck =>
{
Expand Down Expand Up @@ -4568,6 +4574,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
path: &[Segment],
ns: Namespace,
finalize: Finalize,
source: PathSource<'ast, '_>,
) -> Result<Option<PartialRes>, Spanned<ResolutionError<'ra>>> {
debug!(
"resolve_qpath(qself={:?}, path={:?}, ns={:?}, finalize={:?})",
Expand Down Expand Up @@ -4615,7 +4622,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
let partial_res = self.smart_resolve_path_fragment(
&None,
&path[..=qself.position],
PathSource::TraitItem(ns),
PathSource::TraitItem(ns, &source),
Finalize::with_root_span(finalize.node_id, finalize.path_span, qself.path_span),
RecordPartialRes::No,
Some(&qself),
Expand Down
Loading
Loading