-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Start using pattern types in libcore #136006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -27,7 +27,7 @@ use rustc_middle::mir::interpret::ErrorHandled; | |||||
| use rustc_middle::mono::{CodegenUnit, CodegenUnitNameBuilder, MonoItem, MonoItemPartitions}; | ||||||
| use rustc_middle::query::Providers; | ||||||
| use rustc_middle::ty::layout::{HasTyCtxt, HasTypingEnv, LayoutOf, TyAndLayout}; | ||||||
| use rustc_middle::ty::{self, Instance, Ty, TyCtxt}; | ||||||
| use rustc_middle::ty::{self, Instance, PatternKind, Ty, TyCtxt}; | ||||||
| use rustc_middle::{bug, span_bug}; | ||||||
| use rustc_session::Session; | ||||||
| use rustc_session::config::{self, CrateType, EntryFnType}; | ||||||
|
|
@@ -273,6 +273,13 @@ pub(crate) fn coerce_unsized_into<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( | |||||
| let src_ty = src.layout.ty; | ||||||
| let dst_ty = dst.layout.ty; | ||||||
| match (src_ty.kind(), dst_ty.kind()) { | ||||||
| (&ty::Pat(s, sp), &ty::Pat(d, dp)) | ||||||
| if let (PatternKind::NotNull, PatternKind::NotNull) = (*sp, *dp) => | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unsure: does the specific kind of pattern really matter here? Would just
Suggested change
be ok?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, if we ever end up with anything but a |
||||||
| { | ||||||
| let src = src.project_type(bx, s); | ||||||
| let dst = dst.project_type(bx, d); | ||||||
| coerce_unsized_into(bx, src, dst) | ||||||
| } | ||||||
| (&ty::Ref(..), &ty::Ref(..) | &ty::RawPtr(..)) | (&ty::RawPtr(..), &ty::RawPtr(..)) => { | ||||||
| let (base, info) = match bx.load_operand(src).val { | ||||||
| OperandValue::Pair(base, info) => unsize_ptr(bx, base, src_ty, dst_ty, Some(info)), | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ use rustc_abi::FieldIdx; | |
| use rustc_middle::mir::visit::MutVisitor; | ||
| use rustc_middle::mir::*; | ||
| use rustc_middle::span_bug; | ||
| use rustc_middle::ty::{self, Ty, TyCtxt}; | ||
| use rustc_middle::ty::{self, PatternKind, Ty, TyCtxt}; | ||
|
|
||
| use crate::patch::MirPatch; | ||
|
|
||
|
|
@@ -137,8 +137,10 @@ impl<'tcx> crate::MirPass<'tcx> for ElaborateBoxDerefs { | |
| build_ptr_tys(tcx, boxed_ty, unique_def, nonnull_def); | ||
|
|
||
| new_projections.extend_from_slice(&build_projection(unique_ty, nonnull_ty)); | ||
| // While we can't project into `NonNull<_>` in a basic block | ||
| // due to MCP#807, this is debug info where it's fine. | ||
| // While we can't project into a pattern type in a basic block, | ||
| // this is debug info where it's fine. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "it's fine" because the pattern type is erased in the debug info?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, because debug info has no UB, we can just do whatever works instead of having to worry about soundness
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's less about soundness and more that debug info doesn't need to worry about losing the validity restriction information. We don't want to load an |
||
| let pat_ty = Ty::new_pat(tcx, ptr_ty, tcx.mk_pat(PatternKind::NotNull)); | ||
| new_projections.push(PlaceElem::Field(FieldIdx::ZERO, pat_ty)); | ||
| new_projections.push(PlaceElem::Field(FieldIdx::ZERO, ptr_ty)); | ||
| new_projections.push(PlaceElem::Deref); | ||
| } else if let Some(new_projections) = new_projections.as_mut() { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.