Skip to content

Commit 9a1c5eb

Browse files
Begin to implement type system layer of unsafe binders
1 parent b22856d commit 9a1c5eb

File tree

79 files changed

+536
-305
lines changed

Some content is hidden

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

79 files changed

+536
-305
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
263263
&self,
264264
negative_impls,
265265
span.to(of_trait.as_ref().map_or(span, |t| t.path.span)),
266-
"negative trait bounds are not yet fully implemented; \
266+
"negative trait bounds are not fully implemented; \
267267
use marker types for now"
268268
);
269269
}

compiler/rustc_borrowck/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
16131613
| ty::CoroutineWitness(..)
16141614
| ty::Never
16151615
| ty::Tuple(_)
1616+
| ty::UnsafeBinder(_)
16161617
| ty::Alias(_, _)
16171618
| ty::Param(_)
16181619
| ty::Bound(_, _)
@@ -1654,6 +1655,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
16541655
| ty::Dynamic(_, _, _)
16551656
| ty::CoroutineWitness(..)
16561657
| ty::Never
1658+
| ty::UnsafeBinder(_)
16571659
| ty::Alias(_, _)
16581660
| ty::Param(_)
16591661
| ty::Bound(_, _)

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(ty) => is_very_trivially_sized(ty.skip_binder()),
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
@@ -768,6 +768,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
768768
// Nothing to check.
769769
interp_ok(true)
770770
}
771+
ty::UnsafeBinder(_) => todo!("FIXME(unsafe_binder)"),
771772
// The above should be all the primitive types. The rest is compound, we
772773
// check them by visiting their fields/variants.
773774
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
@@ -178,7 +178,8 @@ impl<'tcx> InherentCollect<'tcx> {
178178
| ty::Ref(..)
179179
| ty::Never
180180
| ty::FnPtr(..)
181-
| ty::Tuple(..) => self.check_primitive_impl(id, self_ty),
181+
| ty::Tuple(..)
182+
| ty::UnsafeBinder(_) => self.check_primitive_impl(id, self_ty),
182183
ty::Alias(ty::Projection | ty::Inherent | ty::Opaque, _) | ty::Param(_) => {
183184
Err(self.tcx.dcx().emit_err(errors::InherentNominal { span: item_span }))
184185
}

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(..)

0 commit comments

Comments
 (0)