Rollup merge of #91887 - LegionMammal978:less-inband-const_eval, r=oli-obk
Remove `in_band_lifetimes` from `rustc_const_eval` See #91867 for more information.
This commit is contained in:
commit
3a42dc8be1
17 changed files with 123 additions and 83 deletions
|
@ -423,14 +423,14 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn stack(
|
fn stack<'a>(
|
||||||
ecx: &'a InterpCx<'mir, 'tcx, Self>,
|
ecx: &'a InterpCx<'mir, 'tcx, Self>,
|
||||||
) -> &'a [Frame<'mir, 'tcx, Self::PointerTag, Self::FrameExtra>] {
|
) -> &'a [Frame<'mir, 'tcx, Self::PointerTag, Self::FrameExtra>] {
|
||||||
&ecx.machine.stack
|
&ecx.machine.stack
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn stack_mut(
|
fn stack_mut<'a>(
|
||||||
ecx: &'a mut InterpCx<'mir, 'tcx, Self>,
|
ecx: &'a mut InterpCx<'mir, 'tcx, Self>,
|
||||||
) -> &'a mut Vec<Frame<'mir, 'tcx, Self::PointerTag, Self::FrameExtra>> {
|
) -> &'a mut Vec<Frame<'mir, 'tcx, Self::PointerTag, Self::FrameExtra>> {
|
||||||
&mut ecx.machine.stack
|
&mut ecx.machine.stack
|
||||||
|
|
|
@ -25,9 +25,9 @@ pub use fn_queries::*;
|
||||||
pub use machine::*;
|
pub use machine::*;
|
||||||
|
|
||||||
pub(crate) fn const_caller_location(
|
pub(crate) fn const_caller_location(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'_>,
|
||||||
(file, line, col): (Symbol, u32, u32),
|
(file, line, col): (Symbol, u32, u32),
|
||||||
) -> ConstValue<'tcx> {
|
) -> ConstValue<'_> {
|
||||||
trace!("const_caller_location: {}:{}:{}", file, line, col);
|
trace!("const_caller_location: {}:{}:{}", file, line, col);
|
||||||
let mut ecx = mk_eval_cx(tcx, DUMMY_SP, ty::ParamEnv::reveal_all(), false);
|
let mut ecx = mk_eval_cx(tcx, DUMMY_SP, ty::ParamEnv::reveal_all(), false);
|
||||||
|
|
||||||
|
|
|
@ -935,7 +935,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn dump_place(&'a self, place: Place<M::PointerTag>) -> PlacePrinter<'a, 'mir, 'tcx, M> {
|
pub fn dump_place(&self, place: Place<M::PointerTag>) -> PlacePrinter<'_, 'mir, 'tcx, M> {
|
||||||
PlacePrinter { ecx: self, place }
|
PlacePrinter { ecx: self, place }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -292,14 +292,15 @@ pub enum InternKind {
|
||||||
/// Any errors here would anyway be turned into `const_err` lints, whereas validation failures
|
/// Any errors here would anyway be turned into `const_err` lints, whereas validation failures
|
||||||
/// are hard errors.
|
/// are hard errors.
|
||||||
#[tracing::instrument(level = "debug", skip(ecx))]
|
#[tracing::instrument(level = "debug", skip(ecx))]
|
||||||
pub fn intern_const_alloc_recursive<M: CompileTimeMachine<'mir, 'tcx, const_eval::MemoryKind>>(
|
pub fn intern_const_alloc_recursive<
|
||||||
|
'mir,
|
||||||
|
'tcx: 'mir,
|
||||||
|
M: CompileTimeMachine<'mir, 'tcx, const_eval::MemoryKind>,
|
||||||
|
>(
|
||||||
ecx: &mut InterpCx<'mir, 'tcx, M>,
|
ecx: &mut InterpCx<'mir, 'tcx, M>,
|
||||||
intern_kind: InternKind,
|
intern_kind: InternKind,
|
||||||
ret: &MPlaceTy<'tcx>,
|
ret: &MPlaceTy<'tcx>,
|
||||||
) -> Result<(), ErrorReported>
|
) -> Result<(), ErrorReported> {
|
||||||
where
|
|
||||||
'tcx: 'mir,
|
|
||||||
{
|
|
||||||
let tcx = ecx.tcx;
|
let tcx = ecx.tcx;
|
||||||
let base_intern_mode = match intern_kind {
|
let base_intern_mode = match intern_kind {
|
||||||
InternKind::Static(mutbl) => InternMode::Static(mutbl),
|
InternKind::Static(mutbl) => InternMode::Static(mutbl),
|
||||||
|
|
|
@ -148,7 +148,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PrettyPrinter<'tcx> for AbsolutePathPrinter<'tcx> {
|
impl<'tcx> PrettyPrinter<'tcx> for AbsolutePathPrinter<'tcx> {
|
||||||
fn region_should_not_be_omitted(&self, _region: ty::Region<'_>) -> bool {
|
fn region_should_not_be_omitted(&self, _region: ty::Region<'_>) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,12 +374,12 @@ pub trait Machine<'mir, 'tcx>: Sized {
|
||||||
) -> InterpResult<'tcx, Frame<'mir, 'tcx, Self::PointerTag, Self::FrameExtra>>;
|
) -> InterpResult<'tcx, Frame<'mir, 'tcx, Self::PointerTag, Self::FrameExtra>>;
|
||||||
|
|
||||||
/// Borrow the current thread's stack.
|
/// Borrow the current thread's stack.
|
||||||
fn stack(
|
fn stack<'a>(
|
||||||
ecx: &'a InterpCx<'mir, 'tcx, Self>,
|
ecx: &'a InterpCx<'mir, 'tcx, Self>,
|
||||||
) -> &'a [Frame<'mir, 'tcx, Self::PointerTag, Self::FrameExtra>];
|
) -> &'a [Frame<'mir, 'tcx, Self::PointerTag, Self::FrameExtra>];
|
||||||
|
|
||||||
/// Mutably borrow the current thread's stack.
|
/// Mutably borrow the current thread's stack.
|
||||||
fn stack_mut(
|
fn stack_mut<'a>(
|
||||||
ecx: &'a mut InterpCx<'mir, 'tcx, Self>,
|
ecx: &'a mut InterpCx<'mir, 'tcx, Self>,
|
||||||
) -> &'a mut Vec<Frame<'mir, 'tcx, Self::PointerTag, Self::FrameExtra>>;
|
) -> &'a mut Vec<Frame<'mir, 'tcx, Self::PointerTag, Self::FrameExtra>>;
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ pub struct ImmTy<'tcx, Tag: Provenance = AllocId> {
|
||||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||||
rustc_data_structures::static_assert_size!(ImmTy<'_>, 72);
|
rustc_data_structures::static_assert_size!(ImmTy<'_>, 72);
|
||||||
|
|
||||||
impl<Tag: Provenance> std::fmt::Display for ImmTy<'tcx, Tag> {
|
impl<Tag: Provenance> std::fmt::Display for ImmTy<'_, Tag> {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
/// Helper function for printing a scalar to a FmtPrinter
|
/// Helper function for printing a scalar to a FmtPrinter
|
||||||
fn p<'a, 'tcx, F: std::fmt::Write, Tag: Provenance>(
|
fn p<'a, 'tcx, F: std::fmt::Write, Tag: Provenance>(
|
||||||
|
|
|
@ -150,7 +150,7 @@ impl<Tag: Provenance> MemPlace<Tag> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn offset(
|
pub fn offset<'tcx>(
|
||||||
self,
|
self,
|
||||||
offset: Size,
|
offset: Size,
|
||||||
meta: MemPlaceMeta<Tag>,
|
meta: MemPlaceMeta<Tag>,
|
||||||
|
@ -420,7 +420,7 @@ where
|
||||||
|
|
||||||
// Iterates over all fields of an array. Much more efficient than doing the
|
// Iterates over all fields of an array. Much more efficient than doing the
|
||||||
// same by repeatedly calling `mplace_array`.
|
// same by repeatedly calling `mplace_array`.
|
||||||
pub(super) fn mplace_array_fields(
|
pub(super) fn mplace_array_fields<'a>(
|
||||||
&self,
|
&self,
|
||||||
base: &'a MPlaceTy<'tcx, Tag>,
|
base: &'a MPlaceTy<'tcx, Tag>,
|
||||||
) -> InterpResult<'tcx, impl Iterator<Item = InterpResult<'tcx, MPlaceTy<'tcx, Tag>>> + 'a>
|
) -> InterpResult<'tcx, impl Iterator<Item = InterpResult<'tcx, MPlaceTy<'tcx, Tag>>> + 'a>
|
||||||
|
|
|
@ -11,7 +11,6 @@ Rust MIR: a lowered representation of Rust.
|
||||||
#![feature(crate_visibility_modifier)]
|
#![feature(crate_visibility_modifier)]
|
||||||
#![feature(decl_macro)]
|
#![feature(decl_macro)]
|
||||||
#![feature(exact_size_is_empty)]
|
#![feature(exact_size_is_empty)]
|
||||||
#![feature(in_band_lifetimes)]
|
|
||||||
#![feature(iter_zip)]
|
#![feature(iter_zip)]
|
||||||
#![feature(let_else)]
|
#![feature(let_else)]
|
||||||
#![feature(map_try_insert)]
|
#![feature(map_try_insert)]
|
||||||
|
|
|
@ -35,7 +35,7 @@ pub struct Qualifs<'mir, 'tcx> {
|
||||||
needs_non_const_drop: Option<QualifResults<'mir, 'tcx, NeedsNonConstDrop>>,
|
needs_non_const_drop: Option<QualifResults<'mir, 'tcx, NeedsNonConstDrop>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Qualifs<'mir, 'tcx> {
|
impl<'mir, 'tcx> Qualifs<'mir, 'tcx> {
|
||||||
/// Returns `true` if `local` is `NeedsDrop` at the given `Location`.
|
/// Returns `true` if `local` is `NeedsDrop` at the given `Location`.
|
||||||
///
|
///
|
||||||
/// Only updates the cursor if absolutely necessary
|
/// Only updates the cursor if absolutely necessary
|
||||||
|
@ -185,7 +185,7 @@ pub struct Checker<'mir, 'tcx> {
|
||||||
secondary_errors: Vec<Diagnostic>,
|
secondary_errors: Vec<Diagnostic>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for Checker<'mir, 'tcx> {
|
impl<'mir, 'tcx> Deref for Checker<'mir, 'tcx> {
|
||||||
type Target = ConstCx<'mir, 'tcx>;
|
type Target = ConstCx<'mir, 'tcx>;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
|
@ -193,7 +193,7 @@ impl Deref for Checker<'mir, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Checker<'mir, 'tcx> {
|
impl<'mir, 'tcx> Checker<'mir, 'tcx> {
|
||||||
pub fn new(ccx: &'mir ConstCx<'mir, 'tcx>) -> Self {
|
pub fn new(ccx: &'mir ConstCx<'mir, 'tcx>) -> Self {
|
||||||
Checker {
|
Checker {
|
||||||
span: ccx.body.span,
|
span: ccx.body.span,
|
||||||
|
@ -273,7 +273,7 @@ impl Checker<'mir, 'tcx> {
|
||||||
struct StorageDeads {
|
struct StorageDeads {
|
||||||
locals: BitSet<Local>,
|
locals: BitSet<Local>,
|
||||||
}
|
}
|
||||||
impl Visitor<'tcx> for StorageDeads {
|
impl<'tcx> Visitor<'tcx> for StorageDeads {
|
||||||
fn visit_statement(&mut self, stmt: &Statement<'tcx>, _: Location) {
|
fn visit_statement(&mut self, stmt: &Statement<'tcx>, _: Location) {
|
||||||
if let StatementKind::StorageDead(l) = stmt.kind {
|
if let StatementKind::StorageDead(l) = stmt.kind {
|
||||||
self.locals.insert(l);
|
self.locals.insert(l);
|
||||||
|
@ -460,7 +460,7 @@ impl Checker<'mir, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Visitor<'tcx> for Checker<'mir, 'tcx> {
|
impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
|
||||||
fn visit_basic_block_data(&mut self, bb: BasicBlock, block: &BasicBlockData<'tcx>) {
|
fn visit_basic_block_data(&mut self, bb: BasicBlock, block: &BasicBlockData<'tcx>) {
|
||||||
trace!("visit_basic_block_data: bb={:?} is_cleanup={:?}", bb, block.is_cleanup);
|
trace!("visit_basic_block_data: bb={:?} is_cleanup={:?}", bb, block.is_cleanup);
|
||||||
|
|
||||||
|
@ -1042,7 +1042,7 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn place_as_reborrow(
|
fn place_as_reborrow<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
body: &Body<'tcx>,
|
body: &Body<'tcx>,
|
||||||
place: Place<'tcx>,
|
place: Place<'tcx>,
|
||||||
|
|
|
@ -28,7 +28,7 @@ pub struct ConstCx<'mir, 'tcx> {
|
||||||
pub const_kind: Option<hir::ConstContext>,
|
pub const_kind: Option<hir::ConstContext>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConstCx<'mir, 'tcx> {
|
impl<'mir, 'tcx> ConstCx<'mir, 'tcx> {
|
||||||
pub fn new(tcx: TyCtxt<'tcx>, body: &'mir mir::Body<'tcx>) -> Self {
|
pub fn new(tcx: TyCtxt<'tcx>, body: &'mir mir::Body<'tcx>) -> Self {
|
||||||
let def_id = body.source.def_id().expect_local();
|
let def_id = body.source.def_id().expect_local();
|
||||||
let param_env = tcx.param_env(def_id);
|
let param_env = tcx.param_env(def_id);
|
||||||
|
@ -72,11 +72,7 @@ impl ConstCx<'mir, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rustc_allow_const_fn_unstable(
|
pub fn rustc_allow_const_fn_unstable(tcx: TyCtxt<'_>, def_id: DefId, feature_gate: Symbol) -> bool {
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
def_id: DefId,
|
|
||||||
feature_gate: Symbol,
|
|
||||||
) -> bool {
|
|
||||||
let attrs = tcx.get_attrs(def_id);
|
let attrs = tcx.get_attrs(def_id);
|
||||||
attr::rustc_allow_const_fn_unstable(&tcx.sess, attrs).any(|name| name == feature_gate)
|
attr::rustc_allow_const_fn_unstable(&tcx.sess, attrs).any(|name| name == feature_gate)
|
||||||
}
|
}
|
||||||
|
@ -89,7 +85,7 @@ pub fn rustc_allow_const_fn_unstable(
|
||||||
// functions can be called in a const-context by users of the stable compiler. "const-stable"
|
// functions can be called in a const-context by users of the stable compiler. "const-stable"
|
||||||
// functions are subject to more stringent restrictions than "const-unstable" functions: They
|
// functions are subject to more stringent restrictions than "const-unstable" functions: They
|
||||||
// cannot use unstable features and can only call other "const-stable" functions.
|
// cannot use unstable features and can only call other "const-stable" functions.
|
||||||
pub fn is_const_stable_const_fn(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool {
|
pub fn is_const_stable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
||||||
use attr::{ConstStability, Stability, StabilityLevel};
|
use attr::{ConstStability, Stability, StabilityLevel};
|
||||||
|
|
||||||
// A default body marked const is not const-stable because const
|
// A default body marked const is not const-stable because const
|
||||||
|
|
|
@ -39,7 +39,7 @@ pub trait NonConstOp: std::fmt::Debug {
|
||||||
DiagnosticImportance::Primary
|
DiagnosticImportance::Primary
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx>;
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -53,7 +53,7 @@ impl NonConstOp for FloatingPointOp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
feature_err(
|
feature_err(
|
||||||
&ccx.tcx.sess.parse_sess,
|
&ccx.tcx.sess.parse_sess,
|
||||||
sym::const_fn_floating_point_arithmetic,
|
sym::const_fn_floating_point_arithmetic,
|
||||||
|
@ -67,7 +67,7 @@ impl NonConstOp for FloatingPointOp {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FnCallIndirect;
|
pub struct FnCallIndirect;
|
||||||
impl NonConstOp for FnCallIndirect {
|
impl NonConstOp for FnCallIndirect {
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
ccx.tcx.sess.struct_span_err(span, "function pointers are not allowed in const fn")
|
ccx.tcx.sess.struct_span_err(span, "function pointers are not allowed in const fn")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ impl NonConstOp for FnCallIndirect {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FnCallNonConst<'tcx>(pub Option<(DefId, SubstsRef<'tcx>)>);
|
pub struct FnCallNonConst<'tcx>(pub Option<(DefId, SubstsRef<'tcx>)>);
|
||||||
impl<'a> NonConstOp for FnCallNonConst<'a> {
|
impl<'a> NonConstOp for FnCallNonConst<'a> {
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_err!(
|
||||||
ccx.tcx.sess,
|
ccx.tcx.sess,
|
||||||
span,
|
span,
|
||||||
|
@ -149,7 +149,7 @@ impl<'a> NonConstOp for FnCallNonConst<'a> {
|
||||||
pub struct FnCallUnstable(pub DefId, pub Option<Symbol>);
|
pub struct FnCallUnstable(pub DefId, pub Option<Symbol>);
|
||||||
|
|
||||||
impl NonConstOp for FnCallUnstable {
|
impl NonConstOp for FnCallUnstable {
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
let FnCallUnstable(def_id, feature) = *self;
|
let FnCallUnstable(def_id, feature) = *self;
|
||||||
|
|
||||||
let mut err = ccx.tcx.sess.struct_span_err(
|
let mut err = ccx.tcx.sess.struct_span_err(
|
||||||
|
@ -183,7 +183,7 @@ impl NonConstOp for FnPtrCast {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
feature_err(
|
feature_err(
|
||||||
&ccx.tcx.sess.parse_sess,
|
&ccx.tcx.sess.parse_sess,
|
||||||
sym::const_fn_fn_ptr_basics,
|
sym::const_fn_fn_ptr_basics,
|
||||||
|
@ -204,7 +204,7 @@ impl NonConstOp for Generator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
let msg = format!("{}s are not allowed in {}s", self.0, ccx.const_kind());
|
let msg = format!("{}s are not allowed in {}s", self.0, ccx.const_kind());
|
||||||
if let hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Block) = self.0 {
|
if let hir::GeneratorKind::Async(hir::AsyncGeneratorKind::Block) = self.0 {
|
||||||
feature_err(&ccx.tcx.sess.parse_sess, sym::const_async_blocks, span, &msg)
|
feature_err(&ccx.tcx.sess.parse_sess, sym::const_async_blocks, span, &msg)
|
||||||
|
@ -217,7 +217,7 @@ impl NonConstOp for Generator {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct HeapAllocation;
|
pub struct HeapAllocation;
|
||||||
impl NonConstOp for HeapAllocation {
|
impl NonConstOp for HeapAllocation {
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_err!(
|
||||||
ccx.tcx.sess,
|
ccx.tcx.sess,
|
||||||
span,
|
span,
|
||||||
|
@ -241,7 +241,7 @@ impl NonConstOp for HeapAllocation {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct InlineAsm;
|
pub struct InlineAsm;
|
||||||
impl NonConstOp for InlineAsm {
|
impl NonConstOp for InlineAsm {
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
struct_span_err!(
|
struct_span_err!(
|
||||||
ccx.tcx.sess,
|
ccx.tcx.sess,
|
||||||
span,
|
span,
|
||||||
|
@ -257,7 +257,7 @@ pub struct LiveDrop {
|
||||||
pub dropped_at: Option<Span>,
|
pub dropped_at: Option<Span>,
|
||||||
}
|
}
|
||||||
impl NonConstOp for LiveDrop {
|
impl NonConstOp for LiveDrop {
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_err!(
|
||||||
ccx.tcx.sess,
|
ccx.tcx.sess,
|
||||||
span,
|
span,
|
||||||
|
@ -285,7 +285,7 @@ impl NonConstOp for TransientCellBorrow {
|
||||||
// not additionally emit a feature gate error if activating the feature gate won't work.
|
// not additionally emit a feature gate error if activating the feature gate won't work.
|
||||||
DiagnosticImportance::Secondary
|
DiagnosticImportance::Secondary
|
||||||
}
|
}
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
feature_err(
|
feature_err(
|
||||||
&ccx.tcx.sess.parse_sess,
|
&ccx.tcx.sess.parse_sess,
|
||||||
sym::const_refs_to_cell,
|
sym::const_refs_to_cell,
|
||||||
|
@ -301,7 +301,7 @@ impl NonConstOp for TransientCellBorrow {
|
||||||
/// it in the future for static items.
|
/// it in the future for static items.
|
||||||
pub struct CellBorrow;
|
pub struct CellBorrow;
|
||||||
impl NonConstOp for CellBorrow {
|
impl NonConstOp for CellBorrow {
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_err!(
|
||||||
ccx.tcx.sess,
|
ccx.tcx.sess,
|
||||||
span,
|
span,
|
||||||
|
@ -348,7 +348,7 @@ impl NonConstOp for MutBorrow {
|
||||||
DiagnosticImportance::Secondary
|
DiagnosticImportance::Secondary
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
let raw = match self.0 {
|
let raw = match self.0 {
|
||||||
hir::BorrowKind::Raw => "raw ",
|
hir::BorrowKind::Raw => "raw ",
|
||||||
hir::BorrowKind::Ref => "",
|
hir::BorrowKind::Ref => "",
|
||||||
|
@ -387,7 +387,7 @@ impl NonConstOp for TransientMutBorrow {
|
||||||
Status::Unstable(sym::const_mut_refs)
|
Status::Unstable(sym::const_mut_refs)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
let raw = match self.0 {
|
let raw = match self.0 {
|
||||||
hir::BorrowKind::Raw => "raw ",
|
hir::BorrowKind::Raw => "raw ",
|
||||||
hir::BorrowKind::Ref => "",
|
hir::BorrowKind::Ref => "",
|
||||||
|
@ -414,7 +414,7 @@ impl NonConstOp for MutDeref {
|
||||||
DiagnosticImportance::Secondary
|
DiagnosticImportance::Secondary
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
feature_err(
|
feature_err(
|
||||||
&ccx.tcx.sess.parse_sess,
|
&ccx.tcx.sess.parse_sess,
|
||||||
sym::const_mut_refs,
|
sym::const_mut_refs,
|
||||||
|
@ -428,7 +428,7 @@ impl NonConstOp for MutDeref {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PanicNonStr;
|
pub struct PanicNonStr;
|
||||||
impl NonConstOp for PanicNonStr {
|
impl NonConstOp for PanicNonStr {
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
ccx.tcx.sess.struct_span_err(
|
ccx.tcx.sess.struct_span_err(
|
||||||
span,
|
span,
|
||||||
"argument to `panic!()` in a const context must have type `&str`",
|
"argument to `panic!()` in a const context must have type `&str`",
|
||||||
|
@ -442,7 +442,7 @@ impl NonConstOp for PanicNonStr {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct RawPtrComparison;
|
pub struct RawPtrComparison;
|
||||||
impl NonConstOp for RawPtrComparison {
|
impl NonConstOp for RawPtrComparison {
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
let mut err = ccx
|
let mut err = ccx
|
||||||
.tcx
|
.tcx
|
||||||
.sess
|
.sess
|
||||||
|
@ -462,7 +462,7 @@ impl NonConstOp for RawMutPtrDeref {
|
||||||
Status::Unstable(sym::const_mut_refs)
|
Status::Unstable(sym::const_mut_refs)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
feature_err(
|
feature_err(
|
||||||
&ccx.tcx.sess.parse_sess,
|
&ccx.tcx.sess.parse_sess,
|
||||||
sym::const_mut_refs,
|
sym::const_mut_refs,
|
||||||
|
@ -478,7 +478,7 @@ impl NonConstOp for RawMutPtrDeref {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct RawPtrToIntCast;
|
pub struct RawPtrToIntCast;
|
||||||
impl NonConstOp for RawPtrToIntCast {
|
impl NonConstOp for RawPtrToIntCast {
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
let mut err = ccx
|
let mut err = ccx
|
||||||
.tcx
|
.tcx
|
||||||
.sess
|
.sess
|
||||||
|
@ -503,7 +503,7 @@ impl NonConstOp for StaticAccess {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
let mut err = struct_span_err!(
|
let mut err = struct_span_err!(
|
||||||
ccx.tcx.sess,
|
ccx.tcx.sess,
|
||||||
span,
|
span,
|
||||||
|
@ -529,7 +529,7 @@ impl NonConstOp for StaticAccess {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ThreadLocalAccess;
|
pub struct ThreadLocalAccess;
|
||||||
impl NonConstOp for ThreadLocalAccess {
|
impl NonConstOp for ThreadLocalAccess {
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
||||||
struct_span_err!(
|
struct_span_err!(
|
||||||
ccx.tcx.sess,
|
ccx.tcx.sess,
|
||||||
span,
|
span,
|
||||||
|
@ -560,7 +560,11 @@ pub mod ty {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(
|
||||||
|
&self,
|
||||||
|
ccx: &ConstCx<'_, 'tcx>,
|
||||||
|
span: Span,
|
||||||
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
feature_err(
|
feature_err(
|
||||||
&ccx.tcx.sess.parse_sess,
|
&ccx.tcx.sess.parse_sess,
|
||||||
sym::const_mut_refs,
|
sym::const_mut_refs,
|
||||||
|
@ -590,7 +594,11 @@ pub mod ty {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(
|
||||||
|
&self,
|
||||||
|
ccx: &ConstCx<'_, 'tcx>,
|
||||||
|
span: Span,
|
||||||
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
feature_err(
|
feature_err(
|
||||||
&ccx.tcx.sess.parse_sess,
|
&ccx.tcx.sess.parse_sess,
|
||||||
sym::const_fn_fn_ptr_basics,
|
sym::const_fn_fn_ptr_basics,
|
||||||
|
@ -607,7 +615,11 @@ pub mod ty {
|
||||||
Status::Unstable(sym::const_impl_trait)
|
Status::Unstable(sym::const_impl_trait)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(
|
||||||
|
&self,
|
||||||
|
ccx: &ConstCx<'_, 'tcx>,
|
||||||
|
span: Span,
|
||||||
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
feature_err(
|
feature_err(
|
||||||
&ccx.tcx.sess.parse_sess,
|
&ccx.tcx.sess.parse_sess,
|
||||||
sym::const_impl_trait,
|
sym::const_impl_trait,
|
||||||
|
@ -637,7 +649,11 @@ pub mod ty {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(
|
||||||
|
&self,
|
||||||
|
ccx: &ConstCx<'_, 'tcx>,
|
||||||
|
span: Span,
|
||||||
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
let mut err = feature_err(
|
let mut err = feature_err(
|
||||||
&ccx.tcx.sess.parse_sess,
|
&ccx.tcx.sess.parse_sess,
|
||||||
sym::const_fn_trait_bound,
|
sym::const_fn_trait_bound,
|
||||||
|
@ -676,7 +692,11 @@ pub mod ty {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(
|
||||||
|
&self,
|
||||||
|
ccx: &ConstCx<'_, 'tcx>,
|
||||||
|
span: Span,
|
||||||
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
let mut err = feature_err(
|
let mut err = feature_err(
|
||||||
&ccx.tcx.sess.parse_sess,
|
&ccx.tcx.sess.parse_sess,
|
||||||
sym::const_fn_trait_bound,
|
sym::const_fn_trait_bound,
|
||||||
|
@ -703,7 +723,11 @@ pub mod ty {
|
||||||
Status::Unstable(sym::const_trait_bound_opt_out)
|
Status::Unstable(sym::const_trait_bound_opt_out)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_error(&self, ccx: &ConstCx<'_, 'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
|
fn build_error<'tcx>(
|
||||||
|
&self,
|
||||||
|
ccx: &ConstCx<'_, 'tcx>,
|
||||||
|
span: Span,
|
||||||
|
) -> DiagnosticBuilder<'tcx> {
|
||||||
feature_err(
|
feature_err(
|
||||||
&ccx.tcx.sess.parse_sess,
|
&ccx.tcx.sess.parse_sess,
|
||||||
sym::const_trait_bound_opt_out,
|
sym::const_trait_bound_opt_out,
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub fn checking_enabled(ccx: &ConstCx<'_, '_>) -> bool {
|
||||||
///
|
///
|
||||||
/// This is separate from the rest of the const checking logic because it must run after drop
|
/// This is separate from the rest of the const checking logic because it must run after drop
|
||||||
/// elaboration.
|
/// elaboration.
|
||||||
pub fn check_live_drops(tcx: TyCtxt<'tcx>, body: &mir::Body<'tcx>) {
|
pub fn check_live_drops<'tcx>(tcx: TyCtxt<'tcx>, body: &mir::Body<'tcx>) {
|
||||||
let def_id = body.source.def_id().expect_local();
|
let def_id = body.source.def_id().expect_local();
|
||||||
let const_kind = tcx.hir().body_const_context(def_id);
|
let const_kind = tcx.hir().body_const_context(def_id);
|
||||||
if const_kind.is_none() {
|
if const_kind.is_none() {
|
||||||
|
@ -50,7 +50,7 @@ struct CheckLiveDrops<'mir, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// So we can access `body` and `tcx`.
|
// So we can access `body` and `tcx`.
|
||||||
impl std::ops::Deref for CheckLiveDrops<'mir, 'tcx> {
|
impl<'mir, 'tcx> std::ops::Deref for CheckLiveDrops<'mir, 'tcx> {
|
||||||
type Target = ConstCx<'mir, 'tcx>;
|
type Target = ConstCx<'mir, 'tcx>;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
|
@ -58,13 +58,13 @@ impl std::ops::Deref for CheckLiveDrops<'mir, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CheckLiveDrops<'mir, 'tcx> {
|
impl CheckLiveDrops<'_, '_> {
|
||||||
fn check_live_drop(&self, span: Span) {
|
fn check_live_drop(&self, span: Span) {
|
||||||
ops::LiveDrop { dropped_at: None }.build_error(self.ccx, span).emit();
|
ops::LiveDrop { dropped_at: None }.build_error(self.ccx, span).emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Visitor<'tcx> for CheckLiveDrops<'mir, 'tcx> {
|
impl<'tcx> Visitor<'tcx> for CheckLiveDrops<'_, 'tcx> {
|
||||||
fn visit_basic_block_data(&mut self, bb: BasicBlock, block: &mir::BasicBlockData<'tcx>) {
|
fn visit_basic_block_data(&mut self, bb: BasicBlock, block: &mir::BasicBlockData<'tcx>) {
|
||||||
trace!("visit_basic_block_data: bb={:?} is_cleanup={:?}", bb, block.is_cleanup);
|
trace!("visit_basic_block_data: bb={:?} is_cleanup={:?}", bb, block.is_cleanup);
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ use rustc_trait_selection::traits::{
|
||||||
|
|
||||||
use super::ConstCx;
|
use super::ConstCx;
|
||||||
|
|
||||||
pub fn in_any_value_of_ty(
|
pub fn in_any_value_of_ty<'tcx>(
|
||||||
cx: &ConstCx<'_, 'tcx>,
|
cx: &ConstCx<'_, 'tcx>,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
error_occured: Option<ErrorReported>,
|
error_occured: Option<ErrorReported>,
|
||||||
|
@ -58,7 +58,7 @@ pub trait Qualif {
|
||||||
/// from a call to another function.
|
/// from a call to another function.
|
||||||
///
|
///
|
||||||
/// It also determines the `Qualif`s for primitive types.
|
/// It also determines the `Qualif`s for primitive types.
|
||||||
fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool;
|
fn in_any_value_of_ty<'tcx>(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool;
|
||||||
|
|
||||||
/// Returns `true` if this `Qualif` is inherent to the given struct or enum.
|
/// Returns `true` if this `Qualif` is inherent to the given struct or enum.
|
||||||
///
|
///
|
||||||
|
@ -68,7 +68,7 @@ pub trait Qualif {
|
||||||
/// with a custom `Drop` impl is inherently `NeedsDrop`.
|
/// with a custom `Drop` impl is inherently `NeedsDrop`.
|
||||||
///
|
///
|
||||||
/// Returning `true` for `in_adt_inherently` but `false` for `in_any_value_of_ty` is unsound.
|
/// Returning `true` for `in_adt_inherently` but `false` for `in_any_value_of_ty` is unsound.
|
||||||
fn in_adt_inherently(
|
fn in_adt_inherently<'tcx>(
|
||||||
cx: &ConstCx<'_, 'tcx>,
|
cx: &ConstCx<'_, 'tcx>,
|
||||||
adt: &'tcx AdtDef,
|
adt: &'tcx AdtDef,
|
||||||
substs: SubstsRef<'tcx>,
|
substs: SubstsRef<'tcx>,
|
||||||
|
@ -89,11 +89,15 @@ impl Qualif for HasMutInterior {
|
||||||
qualifs.has_mut_interior
|
qualifs.has_mut_interior
|
||||||
}
|
}
|
||||||
|
|
||||||
fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
|
fn in_any_value_of_ty<'tcx>(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
|
||||||
!ty.is_freeze(cx.tcx.at(DUMMY_SP), cx.param_env)
|
!ty.is_freeze(cx.tcx.at(DUMMY_SP), cx.param_env)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn in_adt_inherently(cx: &ConstCx<'_, 'tcx>, adt: &'tcx AdtDef, _: SubstsRef<'tcx>) -> bool {
|
fn in_adt_inherently<'tcx>(
|
||||||
|
cx: &ConstCx<'_, 'tcx>,
|
||||||
|
adt: &'tcx AdtDef,
|
||||||
|
_: SubstsRef<'tcx>,
|
||||||
|
) -> bool {
|
||||||
// Exactly one type, `UnsafeCell`, has the `HasMutInterior` qualif inherently.
|
// Exactly one type, `UnsafeCell`, has the `HasMutInterior` qualif inherently.
|
||||||
// It arises structurally for all other types.
|
// It arises structurally for all other types.
|
||||||
Some(adt.did) == cx.tcx.lang_items().unsafe_cell_type()
|
Some(adt.did) == cx.tcx.lang_items().unsafe_cell_type()
|
||||||
|
@ -115,11 +119,15 @@ impl Qualif for NeedsDrop {
|
||||||
qualifs.needs_drop
|
qualifs.needs_drop
|
||||||
}
|
}
|
||||||
|
|
||||||
fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
|
fn in_any_value_of_ty<'tcx>(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
|
||||||
ty.needs_drop(cx.tcx, cx.param_env)
|
ty.needs_drop(cx.tcx, cx.param_env)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn in_adt_inherently(cx: &ConstCx<'_, 'tcx>, adt: &'tcx AdtDef, _: SubstsRef<'tcx>) -> bool {
|
fn in_adt_inherently<'tcx>(
|
||||||
|
cx: &ConstCx<'_, 'tcx>,
|
||||||
|
adt: &'tcx AdtDef,
|
||||||
|
_: SubstsRef<'tcx>,
|
||||||
|
) -> bool {
|
||||||
adt.has_dtor(cx.tcx)
|
adt.has_dtor(cx.tcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,7 +145,7 @@ impl Qualif for NeedsNonConstDrop {
|
||||||
qualifs.needs_non_const_drop
|
qualifs.needs_non_const_drop
|
||||||
}
|
}
|
||||||
|
|
||||||
fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, mut ty: Ty<'tcx>) -> bool {
|
fn in_any_value_of_ty<'tcx>(cx: &ConstCx<'_, 'tcx>, mut ty: Ty<'tcx>) -> bool {
|
||||||
// Avoid selecting for simple cases.
|
// Avoid selecting for simple cases.
|
||||||
match ty::util::needs_drop_components(ty, &cx.tcx.data_layout).as_deref() {
|
match ty::util::needs_drop_components(ty, &cx.tcx.data_layout).as_deref() {
|
||||||
Ok([]) => return false,
|
Ok([]) => return false,
|
||||||
|
@ -177,7 +185,11 @@ impl Qualif for NeedsNonConstDrop {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn in_adt_inherently(cx: &ConstCx<'_, 'tcx>, adt: &'tcx AdtDef, _: SubstsRef<'tcx>) -> bool {
|
fn in_adt_inherently<'tcx>(
|
||||||
|
cx: &ConstCx<'_, 'tcx>,
|
||||||
|
adt: &'tcx AdtDef,
|
||||||
|
_: SubstsRef<'tcx>,
|
||||||
|
) -> bool {
|
||||||
adt.has_non_const_dtor(cx.tcx)
|
adt.has_non_const_dtor(cx.tcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,7 +204,7 @@ impl Qualif for CustomEq {
|
||||||
qualifs.custom_eq
|
qualifs.custom_eq
|
||||||
}
|
}
|
||||||
|
|
||||||
fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
|
fn in_any_value_of_ty<'tcx>(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
|
||||||
// If *any* component of a composite data type does not implement `Structural{Partial,}Eq`,
|
// If *any* component of a composite data type does not implement `Structural{Partial,}Eq`,
|
||||||
// we know that at least some values of that type are not structural-match. I say "some"
|
// we know that at least some values of that type are not structural-match. I say "some"
|
||||||
// because that component may be part of an enum variant (e.g.,
|
// because that component may be part of an enum variant (e.g.,
|
||||||
|
@ -202,7 +214,7 @@ impl Qualif for CustomEq {
|
||||||
traits::search_for_structural_match_violation(id, cx.body.span, cx.tcx, ty).is_some()
|
traits::search_for_structural_match_violation(id, cx.body.span, cx.tcx, ty).is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn in_adt_inherently(
|
fn in_adt_inherently<'tcx>(
|
||||||
cx: &ConstCx<'_, 'tcx>,
|
cx: &ConstCx<'_, 'tcx>,
|
||||||
adt: &'tcx AdtDef,
|
adt: &'tcx AdtDef,
|
||||||
substs: SubstsRef<'tcx>,
|
substs: SubstsRef<'tcx>,
|
||||||
|
@ -215,7 +227,11 @@ impl Qualif for CustomEq {
|
||||||
// FIXME: Use `mir::visit::Visitor` for the `in_*` functions if/when it supports early return.
|
// FIXME: Use `mir::visit::Visitor` for the `in_*` functions if/when it supports early return.
|
||||||
|
|
||||||
/// Returns `true` if this `Rvalue` contains qualif `Q`.
|
/// Returns `true` if this `Rvalue` contains qualif `Q`.
|
||||||
pub fn in_rvalue<Q, F>(cx: &ConstCx<'_, 'tcx>, in_local: &mut F, rvalue: &Rvalue<'tcx>) -> bool
|
pub fn in_rvalue<'tcx, Q, F>(
|
||||||
|
cx: &ConstCx<'_, 'tcx>,
|
||||||
|
in_local: &mut F,
|
||||||
|
rvalue: &Rvalue<'tcx>,
|
||||||
|
) -> bool
|
||||||
where
|
where
|
||||||
Q: Qualif,
|
Q: Qualif,
|
||||||
F: FnMut(Local) -> bool,
|
F: FnMut(Local) -> bool,
|
||||||
|
@ -270,7 +286,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if this `Place` contains qualif `Q`.
|
/// Returns `true` if this `Place` contains qualif `Q`.
|
||||||
pub fn in_place<Q, F>(cx: &ConstCx<'_, 'tcx>, in_local: &mut F, place: PlaceRef<'tcx>) -> bool
|
pub fn in_place<'tcx, Q, F>(cx: &ConstCx<'_, 'tcx>, in_local: &mut F, place: PlaceRef<'tcx>) -> bool
|
||||||
where
|
where
|
||||||
Q: Qualif,
|
Q: Qualif,
|
||||||
F: FnMut(Local) -> bool,
|
F: FnMut(Local) -> bool,
|
||||||
|
@ -302,7 +318,11 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if this `Operand` contains qualif `Q`.
|
/// Returns `true` if this `Operand` contains qualif `Q`.
|
||||||
pub fn in_operand<Q, F>(cx: &ConstCx<'_, 'tcx>, in_local: &mut F, operand: &Operand<'tcx>) -> bool
|
pub fn in_operand<'tcx, Q, F>(
|
||||||
|
cx: &ConstCx<'_, 'tcx>,
|
||||||
|
in_local: &mut F,
|
||||||
|
operand: &Operand<'tcx>,
|
||||||
|
) -> bool
|
||||||
where
|
where
|
||||||
Q: Qualif,
|
Q: Qualif,
|
||||||
F: FnMut(Local) -> bool,
|
F: FnMut(Local) -> bool,
|
||||||
|
|
|
@ -28,7 +28,7 @@ struct TransferFunction<'a, 'mir, 'tcx, Q> {
|
||||||
_qualif: PhantomData<Q>,
|
_qualif: PhantomData<Q>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Q> TransferFunction<'a, 'mir, 'tcx, Q>
|
impl<'a, 'mir, 'tcx, Q> TransferFunction<'a, 'mir, 'tcx, Q>
|
||||||
where
|
where
|
||||||
Q: Qualif,
|
Q: Qualif,
|
||||||
{
|
{
|
||||||
|
@ -127,7 +127,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Q> Visitor<'tcx> for TransferFunction<'_, '_, 'tcx, Q>
|
impl<'tcx, Q> Visitor<'tcx> for TransferFunction<'_, '_, 'tcx, Q>
|
||||||
where
|
where
|
||||||
Q: Qualif,
|
Q: Qualif,
|
||||||
{
|
{
|
||||||
|
@ -330,7 +330,7 @@ impl JoinSemiLattice for State {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Q> AnalysisDomain<'tcx> for FlowSensitiveAnalysis<'_, '_, 'tcx, Q>
|
impl<'tcx, Q> AnalysisDomain<'tcx> for FlowSensitiveAnalysis<'_, '_, 'tcx, Q>
|
||||||
where
|
where
|
||||||
Q: Qualif,
|
Q: Qualif,
|
||||||
{
|
{
|
||||||
|
@ -350,7 +350,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Q> Analysis<'tcx> for FlowSensitiveAnalysis<'_, '_, 'tcx, Q>
|
impl<'tcx, Q> Analysis<'tcx> for FlowSensitiveAnalysis<'_, '_, 'tcx, Q>
|
||||||
where
|
where
|
||||||
Q: Qualif,
|
Q: Qualif,
|
||||||
{
|
{
|
||||||
|
|
|
@ -168,8 +168,8 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn collect_temps_and_candidates(
|
pub fn collect_temps_and_candidates<'tcx>(
|
||||||
ccx: &ConstCx<'mir, 'tcx>,
|
ccx: &ConstCx<'_, 'tcx>,
|
||||||
rpo: &mut ReversePostorder<'_, 'tcx>,
|
rpo: &mut ReversePostorder<'_, 'tcx>,
|
||||||
) -> (IndexVec<Local, TempState>, Vec<Candidate>) {
|
) -> (IndexVec<Local, TempState>, Vec<Candidate>) {
|
||||||
let mut collector = Collector {
|
let mut collector = Collector {
|
||||||
|
@ -191,7 +191,7 @@ struct Validator<'a, 'tcx> {
|
||||||
temps: &'a IndexVec<Local, TempState>,
|
temps: &'a IndexVec<Local, TempState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::ops::Deref for Validator<'a, 'tcx> {
|
impl<'a, 'tcx> std::ops::Deref for Validator<'a, 'tcx> {
|
||||||
type Target = ConstCx<'a, 'tcx>;
|
type Target = ConstCx<'a, 'tcx>;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
|
|
|
@ -66,7 +66,7 @@ impl<'tcx> MirPass<'tcx> for Validator {
|
||||||
///
|
///
|
||||||
/// The point of this function is to approximate "equal up to subtyping". However,
|
/// The point of this function is to approximate "equal up to subtyping". However,
|
||||||
/// the approximation is incorrect as variance is ignored.
|
/// the approximation is incorrect as variance is ignored.
|
||||||
pub fn equal_up_to_regions(
|
pub fn equal_up_to_regions<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
param_env: ParamEnv<'tcx>,
|
param_env: ParamEnv<'tcx>,
|
||||||
src: Ty<'tcx>,
|
src: Ty<'tcx>,
|
||||||
|
|
Loading…
Reference in a new issue