Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
80 changes: 52 additions & 28 deletions frontend/exporter/src/traits/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,32 @@ pub fn predicates_defined_on(tcx: TyCtxt<'_>, def_id: DefId) -> Predicates<'_> {
result
}

/// Add `T: Drop` bounds for every generic parameter of the given item.
fn add_drop_bounds<'tcx>(
tcx: TyCtxt<'tcx>,
def_id: DefId,
predicates: &mut Vec<(Clause<'tcx>, Span)>,
) {
let def_kind = tcx.def_kind(def_id);
if matches!(def_kind, DefKind::Closure) {
// Closures have fictitious weird type parameters in their `own_args` that we don't want to
// add `Drop` bounds for.
return;
}
// Add a `T: Drop` bound for every generic.
let drop_trait = tcx.lang_items().drop_trait().unwrap();
let extra_bounds = tcx
.generics_of(def_id)
.own_params
.iter()
.filter(|param| matches!(param.kind, GenericParamDefKind::Type { .. }))
.map(|param| tcx.mk_param_from_def(param))
.map(|ty| Binder::dummy(TraitRef::new(tcx, drop_trait, [ty])))
.map(|tref| tref.upcast(tcx))
.map(|clause| (clause, DUMMY_SP));
predicates.extend(extra_bounds);
}

/// The predicates that must hold to mention this item. E.g.
///
/// ```ignore
Expand Down Expand Up @@ -92,33 +118,10 @@ pub fn required_predicates<'tcx>(
let self_clause = self_predicate(tcx, trait_def_id).upcast(tcx);
predicates.to_mut().insert(0, (self_clause, DUMMY_SP));
}
if add_drop {
// Add a `T: Drop` bound for every generic, unless the current trait is `Drop` itself, or a
// built-in marker trait that we know doesn't need the bound.
let lang_item = tcx.as_lang_item(def_id);
if !matches!(
lang_item,
Some(
LangItem::Drop
| LangItem::Sized
| LangItem::MetaSized
| LangItem::PointeeSized
| LangItem::DiscriminantKind
| LangItem::PointeeTrait
)
) {
let drop_trait = tcx.lang_items().drop_trait().unwrap();
let extra_bounds = tcx
.generics_of(def_id)
.own_params
.iter()
.filter(|param| matches!(param.kind, GenericParamDefKind::Type { .. }))
.map(|param| tcx.mk_param_from_def(param))
.map(|ty| Binder::dummy(TraitRef::new(tcx, drop_trait, [ty])))
.map(|tref| tref.upcast(tcx))
.map(|clause| (clause, DUMMY_SP));
predicates.to_mut().extend(extra_bounds);
}
if add_drop && !matches!(def_kind, Trait | TraitAlias) {
// Add a `T: Drop` bound for every generic. For traits we consider these predicates implied
// instead of required.
add_drop_bounds(tcx, def_id, predicates.to_mut());
}
predicates
}
Expand Down Expand Up @@ -151,7 +154,28 @@ pub fn implied_predicates<'tcx>(
let parent = tcx.opt_parent(def_id);
match tcx.def_kind(def_id) {
// We consider all predicates on traits to be outputs
Trait | TraitAlias => predicates_defined_on(tcx, def_id),
Trait | TraitAlias => {
let mut predicates = predicates_defined_on(tcx, def_id);
if add_drop {
// Add a `T: Drop` bound for every generic, unless the current trait is `Drop` itself, or a
// built-in marker trait that we know doesn't need the bound.
if !matches!(
tcx.as_lang_item(def_id),
Some(
LangItem::Drop
| LangItem::Sized
| LangItem::MetaSized
| LangItem::PointeeSized
| LangItem::DiscriminantKind
| LangItem::PointeeTrait
| LangItem::Tuple
)
) {
add_drop_bounds(tcx, def_id, predicates.to_mut());
}
}
predicates
}
AssocTy if matches!(tcx.def_kind(parent.unwrap()), Trait) => {
// `skip_binder` is for the GAT `EarlyBinder`
let mut predicates = Cow::Borrowed(tcx.explicit_item_bounds(def_id).skip_binder());
Expand Down
Loading