Skip to content

Commit 29fa325

Browse files
Initial work on the type system layer
1 parent 888211f commit 29fa325

File tree

54 files changed

+284
-29
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+284
-29
lines changed

compiler/rustc_borrowck/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,6 +1634,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
16341634
| ty::Slice(_)
16351635
| ty::FnDef(_, _)
16361636
| ty::FnPtr(..)
1637+
| ty::UnsafeBinder(_)
16371638
| ty::Dynamic(_, _, _)
16381639
| ty::Closure(_, _)
16391640
| ty::CoroutineClosure(_, _)
@@ -1679,6 +1680,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
16791680
| ty::Ref(_, _, _)
16801681
| ty::FnDef(_, _)
16811682
| ty::FnPtr(..)
1683+
| ty::UnsafeBinder(_)
16821684
| ty::Dynamic(_, _, _)
16831685
| ty::CoroutineWitness(..)
16841686
| ty::Never

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ fn push_debuginfo_type_name<'tcx>(
435435
push_closure_or_coroutine_name(tcx, def_id, args, qualified, output, visited);
436436
}
437437
}
438+
ty::UnsafeBinder(_) => todo!("FIXME(unsafe_binder)"),
438439
// Type parameters from polymorphized functions.
439440
ty::Param(_) => {
440441
write!(output, "{t:?}").unwrap();

compiler/rustc_const_eval/src/const_eval/valtrees.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ fn const_to_valtree_inner<'tcx>(
178178
| ty::Closure(..)
179179
| ty::CoroutineClosure(..)
180180
| ty::Coroutine(..)
181-
| ty::CoroutineWitness(..) => Err(ValTreeCreationError::NonSupportedType(ty)),
181+
| ty::CoroutineWitness(..)
182+
| ty::UnsafeBinder(_) => Err(ValTreeCreationError::NonSupportedType(ty)),
182183
}
183184
}
184185

@@ -356,7 +357,10 @@ pub fn valtree_to_const_value<'tcx>(
356357
| ty::FnPtr(..)
357358
| ty::Str
358359
| ty::Slice(_)
359-
| ty::Dynamic(..) => bug!("no ValTree should have been created for type {:?}", ty.kind()),
360+
| ty::Dynamic(..)
361+
| ty::UnsafeBinder(_) => {
362+
bug!("no ValTree should have been created for type {:?}", ty.kind())
363+
}
360364
}
361365
}
362366

compiler/rustc_const_eval/src/interpret/intrinsics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ pub(crate) fn eval_nullary_intrinsic<'tcx>(
8787
| ty::CoroutineClosure(_, _)
8888
| ty::Coroutine(_, _)
8989
| ty::CoroutineWitness(..)
90+
| ty::UnsafeBinder(_)
9091
| ty::Never
9192
| ty::Tuple(_)
9293
| ty::Error(_) => ConstValue::from_target_usize(0u64, &tcx),

compiler/rustc_const_eval/src/interpret/stack.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
505505
// We don't want to do any queries, so there is not much we can do with ADTs.
506506
ty::Adt(..) => false,
507507

508+
ty::UnsafeBinder(_) => false,
509+
508510
ty::Alias(..) | ty::Param(_) | ty::Placeholder(..) => false,
509511

510512
ty::Infer(ty::TyVar(_)) => false,

compiler/rustc_const_eval/src/interpret/validity.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
760760
// Nothing to check.
761761
Ok(true)
762762
}
763+
ty::UnsafeBinder(_) => todo!("FIXME(unsafe_binder)"),
763764
// The above should be all the primitive types. The rest is compound, we
764765
// check them by visiting their fields/variants.
765766
ty::Adt(..)

compiler/rustc_const_eval/src/util/type_name.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
3838
| ty::FnPtr(..)
3939
| ty::Never
4040
| ty::Tuple(_)
41-
| ty::Dynamic(_, _, _) => self.pretty_print_type(ty),
41+
| ty::Dynamic(_, _, _)
42+
| ty::UnsafeBinder(_) => self.pretty_print_type(ty),
4243

4344
// Placeholders (all printed as `_` to uniformize them).
4445
ty::Param(_) | ty::Bound(..) | ty::Placeholder(_) | ty::Infer(_) | ty::Error(_) => {

compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ impl<'tcx> InherentCollect<'tcx> {
177177
| ty::Ref(..)
178178
| ty::Never
179179
| ty::FnPtr(..)
180-
| ty::Tuple(..) => self.check_primitive_impl(id, self_ty),
180+
| ty::Tuple(..)
181+
| ty::UnsafeBinder(_) => self.check_primitive_impl(id, self_ty),
181182
ty::Alias(ty::Projection | ty::Inherent | ty::Opaque, _) | ty::Param(_) => {
182183
Err(self.tcx.dcx().emit_err(errors::InherentNominal { span: item_span }))
183184
}

compiler/rustc_hir_analysis/src/coherence/orphan.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ pub(crate) fn orphan_check_impl(
225225
| ty::FnDef(..)
226226
| ty::FnPtr(..)
227227
| ty::Never
228-
| ty::Tuple(..) => (LocalImpl::Allow, NonlocalImpl::DisallowOther),
228+
| ty::Tuple(..)
229+
| ty::UnsafeBinder(_) => (LocalImpl::Allow, NonlocalImpl::DisallowOther),
229230

230231
ty::Closure(..)
231232
| ty::CoroutineClosure(..)

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2062,7 +2062,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
20622062
self.lower_fn_ty(hir_ty.hir_id, bf.safety, bf.abi, bf.decl, None, Some(hir_ty)),
20632063
)
20642064
}
2065-
hir::TyKind::UnsafeBinder(_binder) => todo!(),
2065+
hir::TyKind::UnsafeBinder(binder) => Ty::new_unsafe_binder(
2066+
tcx,
2067+
ty::Binder::bind_with_vars(
2068+
self.lower_ty(binder.inner_ty),
2069+
tcx.late_bound_vars(binder.hir_id),
2070+
),
2071+
),
20662072
hir::TyKind::TraitObject(bounds, lifetime, repr) => {
20672073
self.prohibit_or_lint_bare_trait_object_ty(hir_ty);
20682074

0 commit comments

Comments
 (0)