Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
6cee56a
Update rustc
Nadrieril Jul 1, 2025
1ca3abe
Don't overuse the `tcx` arena
Nadrieril Jul 1, 2025
7dac848
Add an explicit `Self: Trait` clause to trait assoc items
Nadrieril Jul 2, 2025
358c68c
Merge branch 'explicit-self-clause' into dev
Nadrieril Jul 2, 2025
6471ff2
Don't add `Drop` clauses to some more marker traits
Nadrieril Jul 3, 2025
ae0f212
Normalize projections before translating them
Nadrieril Jul 3, 2025
8c92b50
Resolve assoc ty predicates in builtin `ImplExpr`s
Nadrieril Jul 3, 2025
7382371
Merge branch 'fix-builtin-impl-exprs' into dev
Nadrieril Jul 3, 2025
407c121
Don't use `SInto` derive for `FullDefKind`
Nadrieril Jun 20, 2025
6ed2039
Don't add drop bounds for closure fake type params
Nadrieril Jul 7, 2025
904ed63
Make `Drop` bounds on traits be implied instead of required
Nadrieril Jul 7, 2025
55ef02f
Don't add `Drop` bounds to the `Tuple` marker trait
Nadrieril Jul 7, 2025
9981e4e
Provide resolved `ImplExpr`s for virtual trait impls
Nadrieril Jul 7, 2025
0d9d42a
Merge branch 'fix-drops' into dev
Nadrieril Jul 7, 2025
b955547
Update rustc again
Nadrieril Jul 9, 2025
6e6d25d
Merge branch 'update-rustc' into dev
Nadrieril Jul 9, 2025
c73c480
Add variance information to generic parameters
Nadrieril Jul 9, 2025
855ed3e
Merge branch 'variance' into dev
Nadrieril Jul 9, 2025
e2d69df
Cleanup the creation of `State` structs
Nadrieril Jul 8, 2025
8c3e3a7
Remove `HasXXXSetter` traits
Nadrieril Jul 8, 2025
78946d1
Reorder `State` fields
Nadrieril Jul 10, 2025
29ba2d6
Track the type of surrounding expression in THIR translation
Nadrieril Jul 10, 2025
ddae0ab
Add metadata information to unsize coercions
Nadrieril Jul 10, 2025
d6d523d
Merge branch 'unsize-metadata' into dev
Nadrieril Jul 10, 2025
88346de
Never construct `ItemRef`s by hand
Nadrieril Jul 10, 2025
25795fa
resolution: let `PredicateSearcher` index clauses itself
Nadrieril Jul 10, 2025
fac3d69
Resolve `dyn` projection predicates
Nadrieril Jul 10, 2025
d30960b
Merge branch 'resolve-dyn' into dev
Nadrieril Jul 11, 2025
3972a6c
Fix `import_thir` after the `dyn` PR
Nadrieril Jul 11, 2025
9641a29
full_def: inline `get_ctor_contents`
Nadrieril Jul 8, 2025
a6be3d1
full_def: merge the three ADT types
Nadrieril Jul 8, 2025
00f4cf2
full_def: merge `AdtDef` into `FullDefKind`
Nadrieril Jul 8, 2025
83cc3e4
full_def: merge the various kinds of constant items
Nadrieril Jul 8, 2025
d4762a3
full_def: remove `parent` fields
Nadrieril Jul 10, 2025
2d7e20f
full_def: move heavy rustc logic to `rustc_utils`
Nadrieril Jul 10, 2025
9d12de0
full_def: add helper
Nadrieril Jul 10, 2025
e91aedb
full_def: better way to translate type aliases
Nadrieril Jul 10, 2025
32a73b4
Merge branch 'fulldef-cleanup' into dev
Nadrieril Jul 17, 2025
e837a1a
full_def: provide virtual impl for `Drop`
Nadrieril Jul 18, 2025
f3a3e1c
Tweak the representation of special `ImplExpr`s for `Drop`
Nadrieril Jul 18, 2025
700932c
Merge branch 'improve-drop-impl' into dev
Nadrieril Jul 21, 2025
773fc14
Fix equality on `Ty`
Nadrieril Jul 19, 2025
0af2fc5
full_def: don't store entire `FullDef`s in assoc items
Nadrieril Jul 17, 2025
f98a7c8
Implement `SInto` for `AssocItem` manually
Nadrieril Jul 11, 2025
60d847f
Allow recovering the `ty::GenericArgs` from an `ItemRef`
Nadrieril Jul 10, 2025
7bfa499
full_def: allow instantiating `FullDef` with generics
Nadrieril Jul 11, 2025
040d9a9
full_def: store a self-reference in `FullDef`
Nadrieril Jul 18, 2025
7d1c872
full_def: track parent item with appropriate args
Nadrieril Jul 19, 2025
b2d6177
full_def: cache instantiated translation
Nadrieril Jul 18, 2025
edbffed
Translate arguments of implemented item in `AssocItem`
Nadrieril Jul 18, 2025
f46482c
Normalize after substituting
Nadrieril Jul 19, 2025
97c713f
ItemRef: add erasure capabilities
Nadrieril Jul 21, 2025
8eded27
Merge branch 'mono-fulldef' into dev
Nadrieril Jul 21, 2025
6776d63
Merge remote-tracking branch 'upstream/main' into upstream-pr
Nadrieril Jul 22, 2025
60c354f
Commit test outputs
Nadrieril Jul 22, 2025
2864c04
Merge remote-tracking branch 'origin/main' into nadrieril-upstream-pr
W95Psp Jul 28, 2025
b2a2a29
fix(rengine): respect env var `HAX_ENGINE_BINARY`
W95Psp Jul 28, 2025
4952add
chore: refresh tests
W95Psp Jul 28, 2025
f68b3ab
chore: update rustc-coverage-tests
W95Psp Jul 28, 2025
108105f
fix: typo
Nadrieril Jul 29, 2025
501a8aa
Merge branch 'main' into upstream-pr
W95Psp Sep 4, 2025
d7f6869
Merge remote-tracking branch 'origin/main' into nadrieril-upstream-pr
W95Psp Sep 9, 2025
18727c3
chore: update changlelog
W95Psp Sep 9, 2025
1df28c4
fix(engine): rewrite `Self`
W95Psp Jul 28, 2025
3a54634
chore: update test snapshots
W95Psp Sep 9, 2025
44f041c
Merge branch 'main' into upstream-pr
W95Psp Sep 9, 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
11 changes: 11 additions & 0 deletions frontend/exporter/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,17 @@ pub trait WithItemCacheExt<'tcx>: UnderOwnerState<'tcx> {
fn with_cache<T>(&self, f: impl FnOnce(&mut ItemCache<'tcx>) -> T) -> T {
self.with_item_cache(self.owner_id(), f)
}
fn with_predicate_searcher<T>(&self, f: impl FnOnce(&mut PredicateSearcher<'tcx>) -> T) -> T {
self.with_cache(|cache| {
f(cache.predicate_searcher.get_or_insert_with(|| {
PredicateSearcher::new_for_owner(
self.base().tcx,
self.owner_id(),
self.base().options.resolve_drop_bounds,
)
}))
})
}
}
impl<'tcx, S: UnderOwnerState<'tcx>> WithItemCacheExt<'tcx> for S {}

Expand Down
83 changes: 7 additions & 76 deletions frontend/exporter/src/traits.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::prelude::*;

#[cfg(feature = "rustc")]
mod resolution;
pub mod resolution;
#[cfg(feature = "rustc")]
mod utils;
#[cfg(feature = "rustc")]
Expand Down Expand Up @@ -52,18 +52,11 @@ impl<'tcx, S: UnderOwnerState<'tcx>> SInto<S, ImplExprPathChunk> for resolution:
resolution::PathChunk::AssocItem {
item,
generic_args,
impl_exprs,
predicate,
index,
..
} => ImplExprPathChunk::AssocItem {
item: ItemRef::new(
s,
item.def_id.sinto(s),
generic_args.sinto(s),
impl_exprs.sinto(s),
None,
),
item: translate_item_ref(s, item.def_id, generic_args),
assoc_item: item.sinto(s),
predicate: predicate.sinto(s),
predicate_id: <_ as SInto<_, Clause>>::sinto(predicate, s).id,
Expand All @@ -88,14 +81,8 @@ impl<'tcx, S: UnderOwnerState<'tcx>> SInto<S, ImplExprPathChunk> for resolution:
#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, JsonSchema)]
pub enum ImplExprAtom {
/// A concrete `impl Trait for Type {}` item.
#[custom_arm(FROM_TYPE::Concrete { def_id, generics, impl_exprs } => TO_TYPE::Concrete(
ItemRef::new(
s,
def_id.sinto(s),
generics.sinto(s),
impl_exprs.sinto(s),
None,
)
#[custom_arm(FROM_TYPE::Concrete { def_id, generics } => TO_TYPE::Concrete(
translate_item_ref(s, *def_id, generics),
),)]
Concrete(ItemRef),
/// A context-bound clause like `where T: Trait`.
Expand Down Expand Up @@ -231,18 +218,8 @@ pub fn solve_trait<'tcx, S: UnderOwnerState<'tcx>>(
if let Some(impl_expr) = s.with_cache(|cache| cache.impl_exprs.get(&trait_ref).cloned()) {
return impl_expr;
}
let resolved = s.with_cache(|cache| {
cache
.predicate_searcher
.get_or_insert_with(|| {
PredicateSearcher::new_for_owner(
s.base().tcx,
s.owner_id(),
s.base().options.resolve_drop_bounds,
)
})
.resolve(&trait_ref, &warn)
});
let resolved =
s.with_predicate_searcher(|pred_searcher| pred_searcher.resolve(&trait_ref, &warn));
let impl_expr = match resolved {
Ok(x) => x.sinto(s),
Err(e) => crate::fatal!(s, "{}", e),
Expand All @@ -259,53 +236,7 @@ pub fn translate_item_ref<'tcx, S: UnderOwnerState<'tcx>>(
def_id: RDefId,
generics: ty::GenericArgsRef<'tcx>,
) -> ItemRef {
let key = (def_id, generics);
if let Some(item) = s.with_cache(|cache| cache.item_refs.get(&key).cloned()) {
return item;
}
let mut impl_exprs = solve_item_required_traits(s, def_id, generics);
let mut generic_args = generics.sinto(s);

// If this is an associated item, resolve the trait reference.
let trait_info = self_clause_for_item(s, def_id, generics);
// Fixup the generics.
if let Some(tinfo) = &trait_info {
// The generics are split in two: the arguments of the trait and the arguments of the
// method.
//
// For instance, if we have:
// ```
// trait Foo<T> {
// fn baz<U>(...) { ... }
// }
//
// fn test<T : Foo<u32>(x: T) {
// x.baz(...);
// ...
// }
// ```
// The generics for the call to `baz` will be the concatenation: `<T, u32, U>`, which we
// split into `<T, u32>` and `<U>`.
let trait_ref = tinfo.r#trait.hax_skip_binder_ref();
let num_trait_generics = trait_ref.generic_args.len();
generic_args.drain(0..num_trait_generics);
let num_trait_trait_clauses = trait_ref.impl_exprs.len();
// Associated items take a `Self` clause as first clause, we skip that one too. Note: that
// clause is the same as `tinfo`.
impl_exprs.drain(0..num_trait_trait_clauses + 1);
}

let content = ItemRefContents {
def_id: def_id.sinto(s),
generic_args,
impl_exprs,
in_trait: trait_info,
};
let item = content.intern(s);
s.with_cache(|cache| {
cache.item_refs.insert(key, item.clone());
});
item
ItemRef::translate(s, def_id, generics)
}

/// Solve the trait obligations for a specific item use (for example, a method call, an ADT, etc.)
Expand Down
Loading