Skip to content

Commit 25a754c

Browse files
Initial work on the type system layer
1 parent 13f6e74 commit 25a754c

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
@@ -1638,6 +1638,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
16381638
| ty::Slice(_)
16391639
| ty::FnDef(_, _)
16401640
| ty::FnPtr(..)
1641+
| ty::UnsafeBinder(_)
16411642
| ty::Dynamic(_, _, _)
16421643
| ty::Closure(_, _)
16431644
| ty::CoroutineClosure(_, _)
@@ -1683,6 +1684,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
16831684
| ty::Ref(_, _, _)
16841685
| ty::FnDef(_, _)
16851686
| ty::FnPtr(..)
1687+
| ty::UnsafeBinder(_)
16861688
| ty::Dynamic(_, _, _)
16871689
| ty::CoroutineWitness(..)
16881690
| 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
@@ -433,6 +433,7 @@ fn push_debuginfo_type_name<'tcx>(
433433
push_closure_or_coroutine_name(tcx, def_id, args, qualified, output, visited);
434434
}
435435
}
436+
ty::UnsafeBinder(_) => todo!("FIXME(unsafe_binder)"),
436437
// Type parameters from polymorphized functions.
437438
ty::Param(_) => {
438439
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
@@ -2052,7 +2052,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
20522052
self.lower_fn_ty(hir_ty.hir_id, bf.safety, bf.abi, bf.decl, None, Some(hir_ty)),
20532053
)
20542054
}
2055-
hir::TyKind::UnsafeBinder(_binder) => todo!(),
2055+
hir::TyKind::UnsafeBinder(binder) => Ty::new_unsafe_binder(
2056+
tcx,
2057+
ty::Binder::bind_with_vars(
2058+
self.lower_ty(binder.inner_ty),
2059+
tcx.late_bound_vars(binder.hir_id),
2060+
),
2061+
),
20562062
hir::TyKind::TraitObject(bounds, lifetime, repr) => {
20572063
self.prohibit_or_lint_bare_trait_object_ty(hir_ty);
20582064

0 commit comments

Comments
 (0)