Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit993553c

Browse files
Uplift EarlyBinder
1 parentbbcdb4f commit993553c

File tree

13 files changed

+679
-613
lines changed

13 files changed

+679
-613
lines changed

‎Cargo.lock‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4686,6 +4686,7 @@ dependencies = [
46864686
"rustc_span",
46874687
"rustc_type_ir_macros",
46884688
"smallvec",
4689+
"tracing",
46894690
]
46904691

46914692
[[package]]

‎compiler/rustc_middle/src/ty/consts.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,15 @@ impl<'tcx> rustc_type_ir::inherent::Const<TyCtxt<'tcx>> for Const<'tcx> {
184184
Const::new_var(tcx, vid, ty)
185185
}
186186

187+
fnnew_bound(
188+
interner:TyCtxt<'tcx>,
189+
debruijn: ty::DebruijnIndex,
190+
var: ty::BoundVar,
191+
ty:Ty<'tcx>,
192+
) ->Self{
193+
Const::new_bound(interner, debruijn, var, ty)
194+
}
195+
187196
fnnew_anon_bound(
188197
tcx:TyCtxt<'tcx>,
189198
debruijn: ty::DebruijnIndex,

‎compiler/rustc_middle/src/ty/fold.rs‎

Lines changed: 3 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ use rustc_data_structures::fx::FxIndexMap;
33
use rustc_hir::def_id::DefId;
44
use tracing::{debug, instrument};
55

6-
pubuse rustc_type_ir::fold::{FallibleTypeFolder,TypeFoldable,TypeFolder,TypeSuperFoldable};
6+
pubuse rustc_type_ir::fold::{
7+
shift_region, shift_vars,FallibleTypeFolder,TypeFoldable,TypeFolder,TypeSuperFoldable,
8+
};
79

810
///////////////////////////////////////////////////////////////////////////
911
// Some sample folders
@@ -412,103 +414,3 @@ impl<'tcx> TyCtxt<'tcx> {
412414
Binder::bind_with_vars(inner, bound_vars)
413415
}
414416
}
415-
416-
///////////////////////////////////////////////////////////////////////////
417-
// Shifter
418-
//
419-
// Shifts the De Bruijn indices on all escaping bound vars by a
420-
// fixed amount. Useful in instantiation or when otherwise introducing
421-
// a binding level that is not intended to capture the existing bound
422-
// vars. See comment on `shift_vars_through_binders` method in
423-
// `rustc_middle/src/ty/generic_args.rs` for more details.
424-
425-
structShifter<'tcx>{
426-
tcx:TyCtxt<'tcx>,
427-
current_index: ty::DebruijnIndex,
428-
amount:u32,
429-
}
430-
431-
impl<'tcx>Shifter<'tcx>{
432-
pubfnnew(tcx:TyCtxt<'tcx>,amount:u32) ->Self{
433-
Shifter{ tcx,current_index: ty::INNERMOST, amount}
434-
}
435-
}
436-
437-
impl<'tcx>TypeFolder<TyCtxt<'tcx>>forShifter<'tcx>{
438-
fninterner(&self) ->TyCtxt<'tcx>{
439-
self.tcx
440-
}
441-
442-
fnfold_binder<T:TypeFoldable<TyCtxt<'tcx>>>(
443-
&mutself,
444-
t: ty::Binder<'tcx,T>,
445-
) -> ty::Binder<'tcx,T>{
446-
self.current_index.shift_in(1);
447-
let t = t.super_fold_with(self);
448-
self.current_index.shift_out(1);
449-
t
450-
}
451-
452-
fnfold_region(&mutself,r: ty::Region<'tcx>) -> ty::Region<'tcx>{
453-
match*r{
454-
ty::ReBound(debruijn, br)if debruijn >=self.current_index =>{
455-
let debruijn = debruijn.shifted_in(self.amount);
456-
ty::Region::new_bound(self.tcx, debruijn, br)
457-
}
458-
_ => r,
459-
}
460-
}
461-
462-
fnfold_ty(&mutself,ty:Ty<'tcx>) ->Ty<'tcx>{
463-
match*ty.kind(){
464-
ty::Bound(debruijn, bound_ty)if debruijn >=self.current_index =>{
465-
let debruijn = debruijn.shifted_in(self.amount);
466-
Ty::new_bound(self.tcx, debruijn, bound_ty)
467-
}
468-
469-
_if ty.has_vars_bound_at_or_above(self.current_index) => ty.super_fold_with(self),
470-
_ => ty,
471-
}
472-
}
473-
474-
fnfold_const(&mutself,ct: ty::Const<'tcx>) -> ty::Const<'tcx>{
475-
iflet ty::ConstKind::Bound(debruijn, bound_ct) = ct.kind()
476-
&& debruijn >=self.current_index
477-
{
478-
let debruijn = debruijn.shifted_in(self.amount);
479-
ty::Const::new_bound(self.tcx, debruijn, bound_ct, ct.ty())
480-
}else{
481-
ct.super_fold_with(self)
482-
}
483-
}
484-
485-
fnfold_predicate(&mutself,p: ty::Predicate<'tcx>) -> ty::Predicate<'tcx>{
486-
if p.has_vars_bound_at_or_above(self.current_index){ p.super_fold_with(self)}else{ p}
487-
}
488-
}
489-
490-
pubfnshift_region<'tcx>(
491-
tcx:TyCtxt<'tcx>,
492-
region: ty::Region<'tcx>,
493-
amount:u32,
494-
) -> ty::Region<'tcx>{
495-
match*region{
496-
ty::ReBound(debruijn, br)if amount >0 =>{
497-
ty::Region::new_bound(tcx, debruijn.shifted_in(amount), br)
498-
}
499-
_ => region,
500-
}
501-
}
502-
503-
pubfnshift_vars<'tcx,T>(tcx:TyCtxt<'tcx>,value:T,amount:u32) ->T
504-
where
505-
T:TypeFoldable<TyCtxt<'tcx>>,
506-
{
507-
debug!("shift_vars(value={:?}, amount={})", value, amount);
508-
509-
if amount ==0 || !value.has_escaping_bound_vars(){
510-
return value;
511-
}
512-
513-
value.fold_with(&mutShifter::new(tcx, amount))
514-
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp