Skip to content

Commit c1581fc

Browse files
Initial work on the type system layer
1 parent 85641f7 commit c1581fc

File tree

54 files changed

+286
-39
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

+286
-39
lines changed

compiler/rustc_borrowck/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,6 +1626,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
16261626
| ty::Slice(_)
16271627
| ty::FnDef(_, _)
16281628
| ty::FnPtr(..)
1629+
| ty::UnsafeBinder(_)
16291630
| ty::Dynamic(_, _, _)
16301631
| ty::Closure(_, _)
16311632
| ty::CoroutineClosure(_, _)
@@ -1671,6 +1672,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
16711672
| ty::Ref(_, _, _)
16721673
| ty::FnDef(_, _)
16731674
| ty::FnPtr(..)
1675+
| ty::UnsafeBinder(_)
16741676
| ty::Dynamic(_, _, _)
16751677
| ty::CoroutineWitness(..)
16761678
| 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
@@ -432,6 +432,7 @@ fn push_debuginfo_type_name<'tcx>(
432432
push_closure_or_coroutine_name(tcx, def_id, args, qualified, output, visited);
433433
}
434434
}
435+
ty::UnsafeBinder(_) => todo!("FIXME(unsafe_binders)"),
435436
ty::Param(_)
436437
| ty::Error(_)
437438
| ty::Infer(_)

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

@@ -358,7 +359,10 @@ pub fn valtree_to_const_value<'tcx>(
358359
| ty::FnPtr(..)
359360
| ty::Str
360361
| ty::Slice(_)
361-
| ty::Dynamic(..) => bug!("no ValTree should have been created for type {:?}", ty.kind()),
362+
| ty::Dynamic(..)
363+
| ty::UnsafeBinder(_) => {
364+
bug!("no ValTree should have been created for type {:?}", ty.kind())
365+
}
362366
}
363367
}
364368

compiler/rustc_const_eval/src/interpret/intrinsics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ pub(crate) fn eval_nullary_intrinsic<'tcx>(
9090
| ty::CoroutineClosure(_, _)
9191
| ty::Coroutine(_, _)
9292
| ty::CoroutineWitness(..)
93+
| ty::UnsafeBinder(_)
9394
| ty::Never
9495
| ty::Tuple(_)
9596
| 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
@@ -767,6 +767,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
767767
// Nothing to check.
768768
interp_ok(true)
769769
}
770+
ty::UnsafeBinder(_) => todo!("FIXME(unsafe_binder)"),
770771
// The above should be all the primitive types. The rest is compound, we
771772
// check them by visiting their fields/variants.
772773
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
@@ -179,7 +179,8 @@ impl<'tcx> InherentCollect<'tcx> {
179179
| ty::Ref(..)
180180
| ty::Never
181181
| ty::FnPtr(..)
182-
| ty::Tuple(..) => self.check_primitive_impl(id, self_ty),
182+
| ty::Tuple(..)
183+
| ty::UnsafeBinder(_) => self.check_primitive_impl(id, self_ty),
183184
ty::Alias(ty::Projection | ty::Inherent | ty::Opaque, _) | ty::Param(_) => {
184185
Err(self.tcx.dcx().emit_err(errors::InherentNominal { span: item_span }))
185186
}

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 & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,13 +2319,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
23192319
self.lower_fn_ty(hir_ty.hir_id, bf.safety, bf.abi, bf.decl, None, Some(hir_ty)),
23202320
)
23212321
}
2322-
hir::TyKind::UnsafeBinder(_binder) => {
2323-
let guar = self
2324-
.dcx()
2325-
.struct_span_err(hir_ty.span, "unsafe binders are not yet implemented")
2326-
.emit();
2327-
Ty::new_error(tcx, guar)
2328-
}
2322+
hir::TyKind::UnsafeBinder(binder) => Ty::new_unsafe_binder(
2323+
tcx,
2324+
ty::Binder::bind_with_vars(
2325+
self.lower_ty(binder.inner_ty),
2326+
tcx.late_bound_vars(hir_ty.hir_id),
2327+
),
2328+
),
23292329
hir::TyKind::TraitObject(bounds, lifetime, repr) => {
23302330
if let Some(guar) = self.prohibit_or_lint_bare_trait_object_ty(hir_ty) {
23312331
// Don't continue with type analysis if the `dyn` keyword is missing

0 commit comments

Comments
 (0)