Skip to content

Commit 3dcb616

Browse files
committed
Auto merge of #98959 - cjgillot:late-bound-order, r=michaelwoerister
Return a FxIndexSet in is_late_bound query. This return value is iterated upon by borrowck, hence the need to preserve a deterministic iteration order. Fixes #98890 Affects #96655 I don't know if this supersedes #98924 or fixes an unrelated bug. r? `@michaelwoerister` This may deserve a backport.
2 parents 049308c + 8ff4115 commit 3dcb616

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

compiler/rustc_middle/src/arena.rs

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ macro_rules! arena_types {
9696
// (during lowering) and the `librustc_middle` arena (for decoding MIR)
9797
[decode] asm_template: rustc_ast::InlineAsmTemplatePiece,
9898
[decode] used_trait_imports: rustc_data_structures::fx::FxHashSet<rustc_hir::def_id::LocalDefId>,
99+
[decode] is_late_bound_map: rustc_data_structures::fx::FxIndexSet<rustc_hir::def_id::LocalDefId>,
99100
[decode] impl_source: rustc_middle::traits::ImplSource<'tcx, ()>,
100101

101102
[] dep_kind: rustc_middle::dep_graph::DepKindStruct,

compiler/rustc_middle/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ rustc_queries! {
15731573
Option<&'tcx FxHashMap<ItemLocalId, Region>> {
15741574
desc { "looking up a named region" }
15751575
}
1576-
query is_late_bound_map(_: LocalDefId) -> Option<&'tcx FxHashSet<LocalDefId>> {
1576+
query is_late_bound_map(_: LocalDefId) -> Option<&'tcx FxIndexSet<LocalDefId>> {
15771577
desc { "testing if a region is late bound" }
15781578
}
15791579
/// For a given item (like a struct), gets the default lifetimes to be used

compiler/rustc_resolve/src/late/lifetimes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2539,12 +2539,12 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
25392539
/// "Constrained" basically means that it appears in any type but
25402540
/// not amongst the inputs to a projection. In other words, `<&'a
25412541
/// T as Trait<''b>>::Foo` does not constrain `'a` or `'b`.
2542-
fn is_late_bound_map(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<&FxHashSet<LocalDefId>> {
2542+
fn is_late_bound_map(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<&FxIndexSet<LocalDefId>> {
25432543
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
25442544
let decl = tcx.hir().fn_decl_by_hir_id(hir_id)?;
25452545
let generics = tcx.hir().get_generics(def_id)?;
25462546

2547-
let mut late_bound = FxHashSet::default();
2547+
let mut late_bound = FxIndexSet::default();
25482548

25492549
let mut constrained_by_input = ConstrainedCollector::default();
25502550
for arg_ty in decl.inputs {
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// revisions: rpass1 rpass2
2+
// edition:2021
3+
4+
// See https://github.com/rust-lang/rust/issues/98890
5+
6+
#![allow(unused)]
7+
8+
struct Foo;
9+
10+
impl Foo {
11+
async fn f(&self, _: &&()) -> &() {
12+
&()
13+
}
14+
}
15+
16+
#[cfg(rpass2)]
17+
enum Bar {}
18+
19+
fn main() {}

0 commit comments

Comments
 (0)