Auto merge of #137248 - matthiaskrgr:rollup-s18zjau, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #136936 (Use 'yes' instead of 'while-echo' in tests/ui/process/process-sigpipe.rs except 'nto') - #137026 (Stabilize (and const-stabilize) `integer_sign_cast`) - #137059 (fix: Alloc new errorcode E0803 for E0495) - #137177 (Update `minifier-rs` version to `0.3.5`) - #137210 (compiler: Stop reexporting stuff in cg_llvm::abi) - #137213 (Remove `rustc_middle::mir::tcx` module.) - #137216 (eval_outlives: bail out early if both regions are in the same SCC) - #137228 (Fix typo in hidden internal docs of `TrustedRandomAccess`) - #137242 (Add reference annotations for the `do_not_recommend` attribute) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
5986ff05d8
64 changed files with 585 additions and 546 deletions
|
|
@ -2211,9 +2211,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "minifier"
|
||||
version = "0.3.4"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1cf47565b1430f5fe6c81d3afcb4b835271348d7eb35294a4d592e38dd09ea22"
|
||||
checksum = "9bfdc64e2f805f3d12965f10522000bae36e88d2cfea44112331f467d4f4bf68"
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
|
|
|
|||
|
|
@ -18,12 +18,11 @@ use rustc_hir::intravisit::{Visitor, walk_block, walk_expr};
|
|||
use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, LangItem, PatField};
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::hir::nested_filter::OnlyBodies;
|
||||
use rustc_middle::mir::tcx::PlaceTy;
|
||||
use rustc_middle::mir::{
|
||||
self, AggregateKind, BindingForm, BorrowKind, ClearCrossCrate, ConstraintCategory,
|
||||
FakeBorrowKind, FakeReadCause, LocalDecl, LocalInfo, LocalKind, Location, MutBorrowKind,
|
||||
Operand, Place, PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, Terminator,
|
||||
TerminatorKind, VarBindingForm, VarDebugInfoContents,
|
||||
Operand, Place, PlaceRef, PlaceTy, ProjectionElem, Rvalue, Statement, StatementKind,
|
||||
Terminator, TerminatorKind, VarBindingForm, VarDebugInfoContents,
|
||||
};
|
||||
use rustc_middle::ty::print::PrintTraitRefExt as _;
|
||||
use rustc_middle::ty::{
|
||||
|
|
|
|||
|
|
@ -13,10 +13,9 @@ use rustc_infer::infer::{
|
|||
};
|
||||
use rustc_infer::traits::SelectionError;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::mir::tcx::PlaceTy;
|
||||
use rustc_middle::mir::{
|
||||
AggregateKind, CallSource, ConstOperand, ConstraintCategory, FakeReadCause, Local, LocalInfo,
|
||||
LocalKind, Location, Operand, Place, PlaceRef, ProjectionElem, Rvalue, Statement,
|
||||
LocalKind, Location, Operand, Place, PlaceRef, PlaceTy, ProjectionElem, Rvalue, Statement,
|
||||
StatementKind, Terminator, TerminatorKind, find_self_call,
|
||||
};
|
||||
use rustc_middle::ty::print::Print;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ use rustc_index::{IndexSlice, IndexVec};
|
|||
use rustc_infer::infer::{
|
||||
InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin, TyCtxtInferExt,
|
||||
};
|
||||
use rustc_middle::mir::tcx::PlaceTy;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::query::Providers;
|
||||
use rustc_middle::ty::fold::fold_regions;
|
||||
|
|
|
|||
|
|
@ -1267,6 +1267,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
let sub_region_scc = self.constraint_sccs.scc(sub_region);
|
||||
let sup_region_scc = self.constraint_sccs.scc(sup_region);
|
||||
|
||||
if sub_region_scc == sup_region_scc {
|
||||
debug!("{sup_region:?}: {sub_region:?} holds trivially; they are in the same SCC");
|
||||
return true;
|
||||
}
|
||||
|
||||
// If we are checking that `'sup: 'sub`, and `'sub` contains
|
||||
// some placeholder that `'sup` cannot name, then this is only
|
||||
// true if `'sup` outlives static.
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ use rustc_infer::infer::{
|
|||
BoundRegion, BoundRegionConversionTime, InferCtxt, NllRegionVariableOrigin,
|
||||
};
|
||||
use rustc_infer::traits::PredicateObligations;
|
||||
use rustc_middle::mir::tcx::PlaceTy;
|
||||
use rustc_middle::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::traits::query::NoSolution;
|
||||
|
|
|
|||
|
|
@ -2,19 +2,18 @@ use std::borrow::Borrow;
|
|||
use std::cmp;
|
||||
|
||||
use libc::c_uint;
|
||||
use rustc_abi as abi;
|
||||
pub(crate) use rustc_abi::ExternAbi;
|
||||
use rustc_abi::{HasDataLayout, Primitive, Reg, RegKind, Size};
|
||||
use rustc_abi::{BackendRepr, HasDataLayout, Primitive, Reg, RegKind, Size};
|
||||
use rustc_codegen_ssa::MemFlags;
|
||||
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
|
||||
use rustc_codegen_ssa::mir::place::{PlaceRef, PlaceValue};
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_middle::ty::layout::LayoutOf;
|
||||
pub(crate) use rustc_middle::ty::layout::{WIDE_PTR_ADDR, WIDE_PTR_EXTRA};
|
||||
use rustc_middle::{bug, ty};
|
||||
use rustc_session::config;
|
||||
pub(crate) use rustc_target::callconv::*;
|
||||
use rustc_target::callconv::{
|
||||
ArgAbi, ArgAttribute, ArgAttributes, ArgExtension, CastTarget, Conv, FnAbi, PassMode,
|
||||
};
|
||||
use rustc_target::spec::SanitizerSet;
|
||||
use smallvec::SmallVec;
|
||||
|
||||
|
|
@ -458,7 +457,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
|
|||
match &self.ret.mode {
|
||||
PassMode::Direct(attrs) => {
|
||||
attrs.apply_attrs_to_llfn(llvm::AttributePlace::ReturnValue, cx, llfn);
|
||||
if let abi::BackendRepr::Scalar(scalar) = self.ret.layout.backend_repr {
|
||||
if let BackendRepr::Scalar(scalar) = self.ret.layout.backend_repr {
|
||||
apply_range_attr(llvm::AttributePlace::ReturnValue, scalar);
|
||||
}
|
||||
}
|
||||
|
|
@ -499,7 +498,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
|
|||
}
|
||||
PassMode::Direct(attrs) => {
|
||||
let i = apply(attrs);
|
||||
if let abi::BackendRepr::Scalar(scalar) = arg.layout.backend_repr {
|
||||
if let BackendRepr::Scalar(scalar) = arg.layout.backend_repr {
|
||||
apply_range_attr(llvm::AttributePlace::Argument(i), scalar);
|
||||
}
|
||||
}
|
||||
|
|
@ -514,9 +513,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
|
|||
PassMode::Pair(a, b) => {
|
||||
let i = apply(a);
|
||||
let ii = apply(b);
|
||||
if let abi::BackendRepr::ScalarPair(scalar_a, scalar_b) =
|
||||
arg.layout.backend_repr
|
||||
{
|
||||
if let BackendRepr::ScalarPair(scalar_a, scalar_b) = arg.layout.backend_repr {
|
||||
apply_range_attr(llvm::AttributePlace::Argument(i), scalar_a);
|
||||
apply_range_attr(llvm::AttributePlace::Argument(ii), scalar_b);
|
||||
}
|
||||
|
|
@ -576,7 +573,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
|
|||
}
|
||||
if bx.cx.sess().opts.optimize != config::OptLevel::No
|
||||
&& llvm_util::get_version() < (19, 0, 0)
|
||||
&& let abi::BackendRepr::Scalar(scalar) = self.ret.layout.backend_repr
|
||||
&& let BackendRepr::Scalar(scalar) = self.ret.layout.backend_repr
|
||||
&& matches!(scalar.primitive(), Primitive::Int(..))
|
||||
// If the value is a boolean, the range is 0..2 and that ultimately
|
||||
// become 0..0 when the type becomes i1, which would be rejected
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ use rustc_codegen_ssa::traits::*;
|
|||
use rustc_hir::def::{CtorKind, DefKind};
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::ty::layout::{HasTypingEnv, LayoutOf, TyAndLayout};
|
||||
use rustc_middle::ty::layout::{
|
||||
HasTypingEnv, LayoutOf, TyAndLayout, WIDE_PTR_ADDR, WIDE_PTR_EXTRA,
|
||||
};
|
||||
use rustc_middle::ty::{
|
||||
self, AdtKind, CoroutineArgsExt, ExistentialTraitRef, Instance, Ty, TyCtxt, Visibility,
|
||||
};
|
||||
|
|
@ -34,12 +36,12 @@ use crate::common::{AsCCharPtr, CodegenCx};
|
|||
use crate::debuginfo::dwarf_const;
|
||||
use crate::debuginfo::metadata::type_map::build_type_with_children;
|
||||
use crate::debuginfo::utils::{WidePtrKind, wide_pointer_kind};
|
||||
use crate::llvm;
|
||||
use crate::llvm::debuginfo::{
|
||||
DIDescriptor, DIFile, DIFlags, DILexicalBlock, DIScope, DIType, DebugEmissionKind,
|
||||
DebugNameTableKind,
|
||||
};
|
||||
use crate::value::Value;
|
||||
use crate::{abi, llvm};
|
||||
|
||||
impl PartialEq for llvm::Metadata {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
|
|
@ -211,16 +213,16 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
|
|||
};
|
||||
|
||||
let layout = cx.layout_of(layout_type);
|
||||
let addr_field = layout.field(cx, abi::WIDE_PTR_ADDR);
|
||||
let extra_field = layout.field(cx, abi::WIDE_PTR_EXTRA);
|
||||
let addr_field = layout.field(cx, WIDE_PTR_ADDR);
|
||||
let extra_field = layout.field(cx, WIDE_PTR_EXTRA);
|
||||
|
||||
let (addr_field_name, extra_field_name) = match wide_pointer_kind {
|
||||
WidePtrKind::Dyn => ("pointer", "vtable"),
|
||||
WidePtrKind::Slice => ("data_ptr", "length"),
|
||||
};
|
||||
|
||||
assert_eq!(abi::WIDE_PTR_ADDR, 0);
|
||||
assert_eq!(abi::WIDE_PTR_EXTRA, 1);
|
||||
assert_eq!(WIDE_PTR_ADDR, 0);
|
||||
assert_eq!(WIDE_PTR_EXTRA, 1);
|
||||
|
||||
// The data pointer type is a regular, thin pointer, regardless of whether this
|
||||
// is a slice or a trait object.
|
||||
|
|
@ -242,7 +244,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
|
|||
owner,
|
||||
addr_field_name,
|
||||
(addr_field.size, addr_field.align.abi),
|
||||
layout.fields.offset(abi::WIDE_PTR_ADDR),
|
||||
layout.fields.offset(WIDE_PTR_ADDR),
|
||||
DIFlags::FlagZero,
|
||||
data_ptr_type_di_node,
|
||||
None,
|
||||
|
|
@ -252,7 +254,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
|
|||
owner,
|
||||
extra_field_name,
|
||||
(extra_field.size, extra_field.align.abi),
|
||||
layout.fields.offset(abi::WIDE_PTR_EXTRA),
|
||||
layout.fields.offset(WIDE_PTR_EXTRA),
|
||||
DIFlags::FlagZero,
|
||||
type_di_node(cx, extra_field.ty),
|
||||
None,
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ use rustc_session::config::{self, DebugInfo};
|
|||
use rustc_span::{
|
||||
BytePos, Pos, SourceFile, SourceFileAndLine, SourceFileHash, Span, StableSourceFileId, Symbol,
|
||||
};
|
||||
use rustc_target::callconv::FnAbi;
|
||||
use rustc_target::spec::DebuginfoKind;
|
||||
use smallvec::SmallVec;
|
||||
use tracing::debug;
|
||||
|
|
@ -29,7 +30,6 @@ use tracing::debug;
|
|||
use self::metadata::{UNKNOWN_COLUMN_NUMBER, UNKNOWN_LINE_NUMBER, file_metadata, type_di_node};
|
||||
use self::namespace::mangled_name_of_instance;
|
||||
use self::utils::{DIB, create_DIArray, is_node_local_to_unit};
|
||||
use crate::abi::FnAbi;
|
||||
use crate::builder::Builder;
|
||||
use crate::common::{AsCCharPtr, CodegenCx};
|
||||
use crate::llvm;
|
||||
|
|
|
|||
|
|
@ -16,10 +16,11 @@ use rustc_codegen_ssa::traits::TypeMembershipCodegenMethods;
|
|||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_middle::ty::{Instance, Ty};
|
||||
use rustc_sanitizers::{cfi, kcfi};
|
||||
use rustc_target::callconv::FnAbi;
|
||||
use smallvec::SmallVec;
|
||||
use tracing::debug;
|
||||
|
||||
use crate::abi::{FnAbi, FnAbiLlvmExt};
|
||||
use crate::abi::FnAbiLlvmExt;
|
||||
use crate::common::AsCCharPtr;
|
||||
use crate::context::{CodegenCx, SimpleCx};
|
||||
use crate::llvm::AttributePlace::Function;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::assert_matches::assert_matches;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use rustc_abi::{self as abi, Align, Float, HasDataLayout, Primitive, Size};
|
||||
use rustc_abi::{Align, BackendRepr, ExternAbi, Float, HasDataLayout, Primitive, Size};
|
||||
use rustc_codegen_ssa::base::{compare_simd_types, wants_msvc_seh, wants_wasm_eh};
|
||||
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
|
||||
use rustc_codegen_ssa::errors::{ExpectedPointerMutability, InvalidMonomorphization};
|
||||
|
|
@ -14,10 +14,11 @@ use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, HasTypingEnv, LayoutOf};
|
|||
use rustc_middle::ty::{self, GenericArgsRef, Ty};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_span::{Span, Symbol, sym};
|
||||
use rustc_target::callconv::{FnAbi, PassMode};
|
||||
use rustc_target::spec::{HasTargetSpec, PanicStrategy};
|
||||
use tracing::debug;
|
||||
|
||||
use crate::abi::{ExternAbi, FnAbi, FnAbiLlvmExt, LlvmType, PassMode};
|
||||
use crate::abi::{FnAbiLlvmExt, LlvmType};
|
||||
use crate::builder::Builder;
|
||||
use crate::context::CodegenCx;
|
||||
use crate::llvm::{self, Metadata};
|
||||
|
|
@ -257,7 +258,7 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
|
|||
}
|
||||
sym::va_arg => {
|
||||
match fn_abi.ret.layout.backend_repr {
|
||||
abi::BackendRepr::Scalar(scalar) => {
|
||||
BackendRepr::Scalar(scalar) => {
|
||||
match scalar.primitive() {
|
||||
Primitive::Int(..) => {
|
||||
if self.cx().size_of(ret_ty).bytes() < 4 {
|
||||
|
|
@ -470,7 +471,7 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
|
|||
}
|
||||
|
||||
sym::raw_eq => {
|
||||
use abi::BackendRepr::*;
|
||||
use BackendRepr::*;
|
||||
let tp_ty = fn_args.type_at(0);
|
||||
let layout = self.layout_of(tp_ty).layout;
|
||||
let use_integer_compare = match layout.backend_repr() {
|
||||
|
|
@ -582,8 +583,7 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
|
|||
}
|
||||
|
||||
let llret_ty = if ret_ty.is_simd()
|
||||
&& let abi::BackendRepr::Memory { .. } =
|
||||
self.layout_of(ret_ty).layout.backend_repr
|
||||
&& let BackendRepr::Memory { .. } = self.layout_of(ret_ty).layout.backend_repr
|
||||
{
|
||||
let (size, elem_ty) = ret_ty.simd_size_and_type(self.tcx());
|
||||
let elem_ll_ty = match elem_ty.kind() {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use rustc_abi::Primitive::{Int, Pointer};
|
||||
use rustc_abi::{Align, BackendRepr, FieldsShape, Size, TagEncoding, VariantIdx, Variants};
|
||||
use rustc_middle::mir::PlaceTy;
|
||||
use rustc_middle::mir::interpret::Scalar;
|
||||
use rustc_middle::mir::tcx::PlaceTy;
|
||||
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_middle::{bug, mir};
|
||||
|
|
|
|||
46
compiler/rustc_error_codes/src/error_codes/E0803.md
Normal file
46
compiler/rustc_error_codes/src/error_codes/E0803.md
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
A trait implementation returns a reference without an
|
||||
explicit lifetime linking it to `self`.
|
||||
It commonly arises in generic trait implementations
|
||||
requiring explicit lifetime bounds.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0803
|
||||
trait DataAccess<T> {
|
||||
fn get_ref(&self) -> T;
|
||||
}
|
||||
|
||||
struct Container<'a> {
|
||||
value: &'a f64,
|
||||
}
|
||||
|
||||
// Attempting to implement reference return
|
||||
impl<'a> DataAccess<&f64> for Container<'a> {
|
||||
fn get_ref(&self) -> &f64 { // Error: Lifetime mismatch
|
||||
self.value
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The trait method returns &f64 requiring an independent lifetime
|
||||
The struct Container<'a> carries lifetime parameter 'a
|
||||
The compiler cannot verify if the returned reference satisfies 'a constraints
|
||||
Solution
|
||||
Explicitly bind lifetimes to clarify constraints:
|
||||
```
|
||||
// Modified trait with explicit lifetime binding
|
||||
trait DataAccess<'a, T> {
|
||||
fn get_ref(&'a self) -> T;
|
||||
}
|
||||
|
||||
struct Container<'a> {
|
||||
value: &'a f64,
|
||||
}
|
||||
|
||||
// Correct implementation (bound lifetimes)
|
||||
impl<'a> DataAccess<'a, &'a f64> for Container<'a> {
|
||||
fn get_ref(&'a self) -> &'a f64 {
|
||||
self.value
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
@ -546,6 +546,7 @@ E0799: 0799,
|
|||
E0800: 0800,
|
||||
E0801: 0801,
|
||||
E0802: 0802,
|
||||
E0803: 0803,
|
||||
);
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ pub mod pretty;
|
|||
mod query;
|
||||
mod statement;
|
||||
mod syntax;
|
||||
pub mod tcx;
|
||||
mod terminator;
|
||||
|
||||
pub mod traversal;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
//! Functionality for statements, operands, places, and things that appear in them.
|
||||
|
||||
use tracing::{debug, instrument};
|
||||
|
||||
use super::interpret::GlobalAlloc;
|
||||
use super::*;
|
||||
use crate::ty::CoroutineArgsExt;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Statements
|
||||
|
|
@ -40,6 +43,162 @@ impl<'tcx> StatementKind<'tcx> {
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// Places
|
||||
|
||||
#[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable)]
|
||||
pub struct PlaceTy<'tcx> {
|
||||
pub ty: Ty<'tcx>,
|
||||
/// Downcast to a particular variant of an enum or a coroutine, if included.
|
||||
pub variant_index: Option<VariantIdx>,
|
||||
}
|
||||
|
||||
// At least on 64 bit systems, `PlaceTy` should not be larger than two or three pointers.
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
rustc_data_structures::static_assert_size!(PlaceTy<'_>, 16);
|
||||
|
||||
impl<'tcx> PlaceTy<'tcx> {
|
||||
#[inline]
|
||||
pub fn from_ty(ty: Ty<'tcx>) -> PlaceTy<'tcx> {
|
||||
PlaceTy { ty, variant_index: None }
|
||||
}
|
||||
|
||||
/// `place_ty.field_ty(tcx, f)` computes the type of a given field.
|
||||
///
|
||||
/// Most clients of `PlaceTy` can instead just extract the relevant type
|
||||
/// directly from their `PlaceElem`, but some instances of `ProjectionElem<V, T>`
|
||||
/// do not carry a `Ty` for `T`.
|
||||
///
|
||||
/// Note that the resulting type has not been normalized.
|
||||
#[instrument(level = "debug", skip(tcx), ret)]
|
||||
pub fn field_ty(self, tcx: TyCtxt<'tcx>, f: FieldIdx) -> Ty<'tcx> {
|
||||
if let Some(variant_index) = self.variant_index {
|
||||
match *self.ty.kind() {
|
||||
ty::Adt(adt_def, args) if adt_def.is_enum() => {
|
||||
adt_def.variant(variant_index).fields[f].ty(tcx, args)
|
||||
}
|
||||
ty::Coroutine(def_id, args) => {
|
||||
let mut variants = args.as_coroutine().state_tys(def_id, tcx);
|
||||
let Some(mut variant) = variants.nth(variant_index.into()) else {
|
||||
bug!("variant {variant_index:?} of coroutine out of range: {self:?}");
|
||||
};
|
||||
|
||||
variant
|
||||
.nth(f.index())
|
||||
.unwrap_or_else(|| bug!("field {f:?} out of range: {self:?}"))
|
||||
}
|
||||
_ => bug!("can't downcast non-adt non-coroutine type: {self:?}"),
|
||||
}
|
||||
} else {
|
||||
match self.ty.kind() {
|
||||
ty::Adt(adt_def, args) if !adt_def.is_enum() => {
|
||||
adt_def.non_enum_variant().fields[f].ty(tcx, args)
|
||||
}
|
||||
ty::Closure(_, args) => args
|
||||
.as_closure()
|
||||
.upvar_tys()
|
||||
.get(f.index())
|
||||
.copied()
|
||||
.unwrap_or_else(|| bug!("field {f:?} out of range: {self:?}")),
|
||||
ty::CoroutineClosure(_, args) => args
|
||||
.as_coroutine_closure()
|
||||
.upvar_tys()
|
||||
.get(f.index())
|
||||
.copied()
|
||||
.unwrap_or_else(|| bug!("field {f:?} out of range: {self:?}")),
|
||||
// Only prefix fields (upvars and current state) are
|
||||
// accessible without a variant index.
|
||||
ty::Coroutine(_, args) => args
|
||||
.as_coroutine()
|
||||
.prefix_tys()
|
||||
.get(f.index())
|
||||
.copied()
|
||||
.unwrap_or_else(|| bug!("field {f:?} out of range: {self:?}")),
|
||||
ty::Tuple(tys) => tys
|
||||
.get(f.index())
|
||||
.copied()
|
||||
.unwrap_or_else(|| bug!("field {f:?} out of range: {self:?}")),
|
||||
_ => bug!("can't project out of {self:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn multi_projection_ty(
|
||||
self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
elems: &[PlaceElem<'tcx>],
|
||||
) -> PlaceTy<'tcx> {
|
||||
elems.iter().fold(self, |place_ty, &elem| place_ty.projection_ty(tcx, elem))
|
||||
}
|
||||
|
||||
/// Convenience wrapper around `projection_ty_core` for
|
||||
/// `PlaceElem`, where we can just use the `Ty` that is already
|
||||
/// stored inline on field projection elems.
|
||||
pub fn projection_ty(self, tcx: TyCtxt<'tcx>, elem: PlaceElem<'tcx>) -> PlaceTy<'tcx> {
|
||||
self.projection_ty_core(tcx, &elem, |_, _, ty| ty, |_, ty| ty)
|
||||
}
|
||||
|
||||
/// `place_ty.projection_ty_core(tcx, elem, |...| { ... })`
|
||||
/// projects `place_ty` onto `elem`, returning the appropriate
|
||||
/// `Ty` or downcast variant corresponding to that projection.
|
||||
/// The `handle_field` callback must map a `FieldIdx` to its `Ty`,
|
||||
/// (which should be trivial when `T` = `Ty`).
|
||||
pub fn projection_ty_core<V, T>(
|
||||
self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
elem: &ProjectionElem<V, T>,
|
||||
mut handle_field: impl FnMut(&Self, FieldIdx, T) -> Ty<'tcx>,
|
||||
mut handle_opaque_cast_and_subtype: impl FnMut(&Self, T) -> Ty<'tcx>,
|
||||
) -> PlaceTy<'tcx>
|
||||
where
|
||||
V: ::std::fmt::Debug,
|
||||
T: ::std::fmt::Debug + Copy,
|
||||
{
|
||||
if self.variant_index.is_some() && !matches!(elem, ProjectionElem::Field(..)) {
|
||||
bug!("cannot use non field projection on downcasted place")
|
||||
}
|
||||
let answer = match *elem {
|
||||
ProjectionElem::Deref => {
|
||||
let ty = self.ty.builtin_deref(true).unwrap_or_else(|| {
|
||||
bug!("deref projection of non-dereferenceable ty {:?}", self)
|
||||
});
|
||||
PlaceTy::from_ty(ty)
|
||||
}
|
||||
ProjectionElem::Index(_) | ProjectionElem::ConstantIndex { .. } => {
|
||||
PlaceTy::from_ty(self.ty.builtin_index().unwrap())
|
||||
}
|
||||
ProjectionElem::Subslice { from, to, from_end } => {
|
||||
PlaceTy::from_ty(match self.ty.kind() {
|
||||
ty::Slice(..) => self.ty,
|
||||
ty::Array(inner, _) if !from_end => Ty::new_array(tcx, *inner, to - from),
|
||||
ty::Array(inner, size) if from_end => {
|
||||
let size = size
|
||||
.try_to_target_usize(tcx)
|
||||
.expect("expected subslice projection on fixed-size array");
|
||||
let len = size - from - to;
|
||||
Ty::new_array(tcx, *inner, len)
|
||||
}
|
||||
_ => bug!("cannot subslice non-array type: `{:?}`", self),
|
||||
})
|
||||
}
|
||||
ProjectionElem::Downcast(_name, index) => {
|
||||
PlaceTy { ty: self.ty, variant_index: Some(index) }
|
||||
}
|
||||
ProjectionElem::Field(f, fty) => PlaceTy::from_ty(handle_field(&self, f, fty)),
|
||||
ProjectionElem::OpaqueCast(ty) => {
|
||||
PlaceTy::from_ty(handle_opaque_cast_and_subtype(&self, ty))
|
||||
}
|
||||
ProjectionElem::Subtype(ty) => {
|
||||
PlaceTy::from_ty(handle_opaque_cast_and_subtype(&self, ty))
|
||||
}
|
||||
|
||||
// FIXME(unsafe_binders): Rename `handle_opaque_cast_and_subtype` to be more general.
|
||||
ProjectionElem::UnwrapUnsafeBinder(ty) => {
|
||||
PlaceTy::from_ty(handle_opaque_cast_and_subtype(&self, ty))
|
||||
}
|
||||
};
|
||||
debug!("projection_ty self: {:?} elem: {:?} yields: {:?}", self, elem, answer);
|
||||
answer
|
||||
}
|
||||
}
|
||||
|
||||
impl<V, T> ProjectionElem<V, T> {
|
||||
/// Returns `true` if the target of this projection may refer to a different region of memory
|
||||
/// than the base.
|
||||
|
|
@ -183,6 +342,25 @@ impl<'tcx> Place<'tcx> {
|
|||
|
||||
self.as_ref().project_deeper(more_projections, tcx)
|
||||
}
|
||||
|
||||
pub fn ty_from<D: ?Sized>(
|
||||
local: Local,
|
||||
projection: &[PlaceElem<'tcx>],
|
||||
local_decls: &D,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> PlaceTy<'tcx>
|
||||
where
|
||||
D: HasLocalDecls<'tcx>,
|
||||
{
|
||||
PlaceTy::from_ty(local_decls.local_decls()[local].ty).multi_projection_ty(tcx, projection)
|
||||
}
|
||||
|
||||
pub fn ty<D: ?Sized>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx>
|
||||
where
|
||||
D: HasLocalDecls<'tcx>,
|
||||
{
|
||||
Place::ty_from(self.local, self.projection, local_decls, tcx)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Local> for Place<'_> {
|
||||
|
|
@ -285,6 +463,13 @@ impl<'tcx> PlaceRef<'tcx> {
|
|||
|
||||
Place { local: self.local, projection: tcx.mk_place_elems(new_projections) }
|
||||
}
|
||||
|
||||
pub fn ty<D: ?Sized>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx>
|
||||
where
|
||||
D: HasLocalDecls<'tcx>,
|
||||
{
|
||||
Place::ty_from(self.local, self.projection, local_decls, tcx)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Local> for PlaceRef<'_> {
|
||||
|
|
@ -379,6 +564,28 @@ impl<'tcx> Operand<'tcx> {
|
|||
let const_ty = self.constant()?.const_.ty();
|
||||
if let ty::FnDef(def_id, args) = *const_ty.kind() { Some((def_id, args)) } else { None }
|
||||
}
|
||||
|
||||
pub fn ty<D: ?Sized>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
|
||||
where
|
||||
D: HasLocalDecls<'tcx>,
|
||||
{
|
||||
match self {
|
||||
&Operand::Copy(ref l) | &Operand::Move(ref l) => l.ty(local_decls, tcx).ty,
|
||||
Operand::Constant(c) => c.const_.ty(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn span<D: ?Sized>(&self, local_decls: &D) -> Span
|
||||
where
|
||||
D: HasLocalDecls<'tcx>,
|
||||
{
|
||||
match self {
|
||||
&Operand::Copy(ref l) | &Operand::Move(ref l) => {
|
||||
local_decls.local_decls()[l.local].source_info.span
|
||||
}
|
||||
Operand::Constant(c) => c.span,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ConstOperand<'tcx> {
|
||||
|
|
@ -404,6 +611,11 @@ impl<'tcx> ConstOperand<'tcx> {
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
/// Rvalues
|
||||
|
||||
pub enum RvalueInitializationState {
|
||||
Shallow,
|
||||
Deep,
|
||||
}
|
||||
|
||||
impl<'tcx> Rvalue<'tcx> {
|
||||
/// Returns true if rvalue can be safely removed when the result is unused.
|
||||
#[inline]
|
||||
|
|
@ -443,6 +655,70 @@ impl<'tcx> Rvalue<'tcx> {
|
|||
| Rvalue::WrapUnsafeBinder(_, _) => true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ty<D: ?Sized>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
|
||||
where
|
||||
D: HasLocalDecls<'tcx>,
|
||||
{
|
||||
match *self {
|
||||
Rvalue::Use(ref operand) => operand.ty(local_decls, tcx),
|
||||
Rvalue::Repeat(ref operand, count) => {
|
||||
Ty::new_array_with_const_len(tcx, operand.ty(local_decls, tcx), count)
|
||||
}
|
||||
Rvalue::ThreadLocalRef(did) => tcx.thread_local_ptr_ty(did),
|
||||
Rvalue::Ref(reg, bk, ref place) => {
|
||||
let place_ty = place.ty(local_decls, tcx).ty;
|
||||
Ty::new_ref(tcx, reg, place_ty, bk.to_mutbl_lossy())
|
||||
}
|
||||
Rvalue::RawPtr(kind, ref place) => {
|
||||
let place_ty = place.ty(local_decls, tcx).ty;
|
||||
Ty::new_ptr(tcx, place_ty, kind.to_mutbl_lossy())
|
||||
}
|
||||
Rvalue::Len(..) => tcx.types.usize,
|
||||
Rvalue::Cast(.., ty) => ty,
|
||||
Rvalue::BinaryOp(op, box (ref lhs, ref rhs)) => {
|
||||
let lhs_ty = lhs.ty(local_decls, tcx);
|
||||
let rhs_ty = rhs.ty(local_decls, tcx);
|
||||
op.ty(tcx, lhs_ty, rhs_ty)
|
||||
}
|
||||
Rvalue::UnaryOp(op, ref operand) => {
|
||||
let arg_ty = operand.ty(local_decls, tcx);
|
||||
op.ty(tcx, arg_ty)
|
||||
}
|
||||
Rvalue::Discriminant(ref place) => place.ty(local_decls, tcx).ty.discriminant_ty(tcx),
|
||||
Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf | NullOp::OffsetOf(..), _) => {
|
||||
tcx.types.usize
|
||||
}
|
||||
Rvalue::NullaryOp(NullOp::ContractChecks, _)
|
||||
| Rvalue::NullaryOp(NullOp::UbChecks, _) => tcx.types.bool,
|
||||
Rvalue::Aggregate(ref ak, ref ops) => match **ak {
|
||||
AggregateKind::Array(ty) => Ty::new_array(tcx, ty, ops.len() as u64),
|
||||
AggregateKind::Tuple => {
|
||||
Ty::new_tup_from_iter(tcx, ops.iter().map(|op| op.ty(local_decls, tcx)))
|
||||
}
|
||||
AggregateKind::Adt(did, _, args, _, _) => tcx.type_of(did).instantiate(tcx, args),
|
||||
AggregateKind::Closure(did, args) => Ty::new_closure(tcx, did, args),
|
||||
AggregateKind::Coroutine(did, args) => Ty::new_coroutine(tcx, did, args),
|
||||
AggregateKind::CoroutineClosure(did, args) => {
|
||||
Ty::new_coroutine_closure(tcx, did, args)
|
||||
}
|
||||
AggregateKind::RawPtr(ty, mutability) => Ty::new_ptr(tcx, ty, mutability),
|
||||
},
|
||||
Rvalue::ShallowInitBox(_, ty) => Ty::new_box(tcx, ty),
|
||||
Rvalue::CopyForDeref(ref place) => place.ty(local_decls, tcx).ty,
|
||||
Rvalue::WrapUnsafeBinder(_, ty) => ty,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
/// Returns `true` if this rvalue is deeply initialized (most rvalues) or
|
||||
/// whether its only shallowly initialized (`Rvalue::Box`).
|
||||
pub fn initialization_state(&self) -> RvalueInitializationState {
|
||||
match *self {
|
||||
Rvalue::ShallowInitBox(_, _) => RvalueInitializationState::Shallow,
|
||||
_ => RvalueInitializationState::Deep,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BorrowKind {
|
||||
|
|
@ -465,4 +741,124 @@ impl BorrowKind {
|
|||
BorrowKind::Mut { kind: MutBorrowKind::TwoPhaseBorrow } => true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_mutbl_lossy(self) -> hir::Mutability {
|
||||
match self {
|
||||
BorrowKind::Mut { .. } => hir::Mutability::Mut,
|
||||
BorrowKind::Shared => hir::Mutability::Not,
|
||||
|
||||
// We have no type corresponding to a shallow borrow, so use
|
||||
// `&` as an approximation.
|
||||
BorrowKind::Fake(_) => hir::Mutability::Not,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> UnOp {
|
||||
pub fn ty(&self, tcx: TyCtxt<'tcx>, arg_ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match self {
|
||||
UnOp::Not | UnOp::Neg => arg_ty,
|
||||
UnOp::PtrMetadata => arg_ty.pointee_metadata_ty_or_projection(tcx),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> BinOp {
|
||||
pub fn ty(&self, tcx: TyCtxt<'tcx>, lhs_ty: Ty<'tcx>, rhs_ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
// FIXME: handle SIMD correctly
|
||||
match self {
|
||||
&BinOp::Add
|
||||
| &BinOp::AddUnchecked
|
||||
| &BinOp::Sub
|
||||
| &BinOp::SubUnchecked
|
||||
| &BinOp::Mul
|
||||
| &BinOp::MulUnchecked
|
||||
| &BinOp::Div
|
||||
| &BinOp::Rem
|
||||
| &BinOp::BitXor
|
||||
| &BinOp::BitAnd
|
||||
| &BinOp::BitOr => {
|
||||
// these should be integers or floats of the same size.
|
||||
assert_eq!(lhs_ty, rhs_ty);
|
||||
lhs_ty
|
||||
}
|
||||
&BinOp::AddWithOverflow | &BinOp::SubWithOverflow | &BinOp::MulWithOverflow => {
|
||||
// these should be integers of the same size.
|
||||
assert_eq!(lhs_ty, rhs_ty);
|
||||
Ty::new_tup(tcx, &[lhs_ty, tcx.types.bool])
|
||||
}
|
||||
&BinOp::Shl
|
||||
| &BinOp::ShlUnchecked
|
||||
| &BinOp::Shr
|
||||
| &BinOp::ShrUnchecked
|
||||
| &BinOp::Offset => {
|
||||
lhs_ty // lhs_ty can be != rhs_ty
|
||||
}
|
||||
&BinOp::Eq | &BinOp::Lt | &BinOp::Le | &BinOp::Ne | &BinOp::Ge | &BinOp::Gt => {
|
||||
tcx.types.bool
|
||||
}
|
||||
&BinOp::Cmp => {
|
||||
// these should be integer-like types of the same size.
|
||||
assert_eq!(lhs_ty, rhs_ty);
|
||||
tcx.ty_ordering_enum(None)
|
||||
}
|
||||
}
|
||||
}
|
||||
pub(crate) fn to_hir_binop(self) -> hir::BinOpKind {
|
||||
match self {
|
||||
// HIR `+`/`-`/`*` can map to either of these MIR BinOp, depending
|
||||
// on whether overflow checks are enabled or not.
|
||||
BinOp::Add | BinOp::AddWithOverflow => hir::BinOpKind::Add,
|
||||
BinOp::Sub | BinOp::SubWithOverflow => hir::BinOpKind::Sub,
|
||||
BinOp::Mul | BinOp::MulWithOverflow => hir::BinOpKind::Mul,
|
||||
BinOp::Div => hir::BinOpKind::Div,
|
||||
BinOp::Rem => hir::BinOpKind::Rem,
|
||||
BinOp::BitXor => hir::BinOpKind::BitXor,
|
||||
BinOp::BitAnd => hir::BinOpKind::BitAnd,
|
||||
BinOp::BitOr => hir::BinOpKind::BitOr,
|
||||
BinOp::Shl => hir::BinOpKind::Shl,
|
||||
BinOp::Shr => hir::BinOpKind::Shr,
|
||||
BinOp::Eq => hir::BinOpKind::Eq,
|
||||
BinOp::Ne => hir::BinOpKind::Ne,
|
||||
BinOp::Lt => hir::BinOpKind::Lt,
|
||||
BinOp::Gt => hir::BinOpKind::Gt,
|
||||
BinOp::Le => hir::BinOpKind::Le,
|
||||
BinOp::Ge => hir::BinOpKind::Ge,
|
||||
// We don't have HIR syntax for these.
|
||||
BinOp::Cmp
|
||||
| BinOp::AddUnchecked
|
||||
| BinOp::SubUnchecked
|
||||
| BinOp::MulUnchecked
|
||||
| BinOp::ShlUnchecked
|
||||
| BinOp::ShrUnchecked
|
||||
| BinOp::Offset => {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// If this is a `FooWithOverflow`, return `Some(Foo)`.
|
||||
pub fn overflowing_to_wrapping(self) -> Option<BinOp> {
|
||||
Some(match self {
|
||||
BinOp::AddWithOverflow => BinOp::Add,
|
||||
BinOp::SubWithOverflow => BinOp::Sub,
|
||||
BinOp::MulWithOverflow => BinOp::Mul,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns whether this is a `FooWithOverflow`
|
||||
pub fn is_overflowing(self) -> bool {
|
||||
self.overflowing_to_wrapping().is_some()
|
||||
}
|
||||
|
||||
/// If this is a `Foo`, return `Some(FooWithOverflow)`.
|
||||
pub fn wrapping_to_overflowing(self) -> Option<BinOp> {
|
||||
Some(match self {
|
||||
BinOp::Add => BinOp::AddWithOverflow,
|
||||
BinOp::Sub => BinOp::SubWithOverflow,
|
||||
BinOp::Mul => BinOp::MulWithOverflow,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1133,7 +1133,7 @@ pub type AssertMessage<'tcx> = AssertKind<Operand<'tcx>>;
|
|||
///
|
||||
/// 1. The address in memory that the place refers to.
|
||||
/// 2. The provenance with which the place is being accessed.
|
||||
/// 3. The type of the place and an optional variant index. See [`PlaceTy`][super::tcx::PlaceTy].
|
||||
/// 3. The type of the place and an optional variant index. See [`PlaceTy`][super::PlaceTy].
|
||||
/// 4. Optionally, some metadata. This exists if and only if the type of the place is not `Sized`.
|
||||
///
|
||||
/// We'll give a description below of how all pieces of the place except for the provenance are
|
||||
|
|
|
|||
|
|
@ -1,416 +0,0 @@
|
|||
/*!
|
||||
* Methods for the various MIR types. These are intended for use after
|
||||
* building is complete.
|
||||
*/
|
||||
|
||||
use rustc_hir as hir;
|
||||
use tracing::{debug, instrument};
|
||||
use ty::CoroutineArgsExt;
|
||||
|
||||
use crate::mir::*;
|
||||
|
||||
#[derive(Copy, Clone, Debug, TypeFoldable, TypeVisitable)]
|
||||
pub struct PlaceTy<'tcx> {
|
||||
pub ty: Ty<'tcx>,
|
||||
/// Downcast to a particular variant of an enum or a coroutine, if included.
|
||||
pub variant_index: Option<VariantIdx>,
|
||||
}
|
||||
|
||||
// At least on 64 bit systems, `PlaceTy` should not be larger than two or three pointers.
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
rustc_data_structures::static_assert_size!(PlaceTy<'_>, 16);
|
||||
|
||||
impl<'tcx> PlaceTy<'tcx> {
|
||||
#[inline]
|
||||
pub fn from_ty(ty: Ty<'tcx>) -> PlaceTy<'tcx> {
|
||||
PlaceTy { ty, variant_index: None }
|
||||
}
|
||||
|
||||
/// `place_ty.field_ty(tcx, f)` computes the type of a given field.
|
||||
///
|
||||
/// Most clients of `PlaceTy` can instead just extract the relevant type
|
||||
/// directly from their `PlaceElem`, but some instances of `ProjectionElem<V, T>`
|
||||
/// do not carry a `Ty` for `T`.
|
||||
///
|
||||
/// Note that the resulting type has not been normalized.
|
||||
#[instrument(level = "debug", skip(tcx), ret)]
|
||||
pub fn field_ty(self, tcx: TyCtxt<'tcx>, f: FieldIdx) -> Ty<'tcx> {
|
||||
if let Some(variant_index) = self.variant_index {
|
||||
match *self.ty.kind() {
|
||||
ty::Adt(adt_def, args) if adt_def.is_enum() => {
|
||||
adt_def.variant(variant_index).fields[f].ty(tcx, args)
|
||||
}
|
||||
ty::Coroutine(def_id, args) => {
|
||||
let mut variants = args.as_coroutine().state_tys(def_id, tcx);
|
||||
let Some(mut variant) = variants.nth(variant_index.into()) else {
|
||||
bug!("variant {variant_index:?} of coroutine out of range: {self:?}");
|
||||
};
|
||||
|
||||
variant
|
||||
.nth(f.index())
|
||||
.unwrap_or_else(|| bug!("field {f:?} out of range: {self:?}"))
|
||||
}
|
||||
_ => bug!("can't downcast non-adt non-coroutine type: {self:?}"),
|
||||
}
|
||||
} else {
|
||||
match self.ty.kind() {
|
||||
ty::Adt(adt_def, args) if !adt_def.is_enum() => {
|
||||
adt_def.non_enum_variant().fields[f].ty(tcx, args)
|
||||
}
|
||||
ty::Closure(_, args) => args
|
||||
.as_closure()
|
||||
.upvar_tys()
|
||||
.get(f.index())
|
||||
.copied()
|
||||
.unwrap_or_else(|| bug!("field {f:?} out of range: {self:?}")),
|
||||
ty::CoroutineClosure(_, args) => args
|
||||
.as_coroutine_closure()
|
||||
.upvar_tys()
|
||||
.get(f.index())
|
||||
.copied()
|
||||
.unwrap_or_else(|| bug!("field {f:?} out of range: {self:?}")),
|
||||
// Only prefix fields (upvars and current state) are
|
||||
// accessible without a variant index.
|
||||
ty::Coroutine(_, args) => args
|
||||
.as_coroutine()
|
||||
.prefix_tys()
|
||||
.get(f.index())
|
||||
.copied()
|
||||
.unwrap_or_else(|| bug!("field {f:?} out of range: {self:?}")),
|
||||
ty::Tuple(tys) => tys
|
||||
.get(f.index())
|
||||
.copied()
|
||||
.unwrap_or_else(|| bug!("field {f:?} out of range: {self:?}")),
|
||||
_ => bug!("can't project out of {self:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn multi_projection_ty(
|
||||
self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
elems: &[PlaceElem<'tcx>],
|
||||
) -> PlaceTy<'tcx> {
|
||||
elems.iter().fold(self, |place_ty, &elem| place_ty.projection_ty(tcx, elem))
|
||||
}
|
||||
|
||||
/// Convenience wrapper around `projection_ty_core` for
|
||||
/// `PlaceElem`, where we can just use the `Ty` that is already
|
||||
/// stored inline on field projection elems.
|
||||
pub fn projection_ty(self, tcx: TyCtxt<'tcx>, elem: PlaceElem<'tcx>) -> PlaceTy<'tcx> {
|
||||
self.projection_ty_core(tcx, &elem, |_, _, ty| ty, |_, ty| ty)
|
||||
}
|
||||
|
||||
/// `place_ty.projection_ty_core(tcx, elem, |...| { ... })`
|
||||
/// projects `place_ty` onto `elem`, returning the appropriate
|
||||
/// `Ty` or downcast variant corresponding to that projection.
|
||||
/// The `handle_field` callback must map a `FieldIdx` to its `Ty`,
|
||||
/// (which should be trivial when `T` = `Ty`).
|
||||
pub fn projection_ty_core<V, T>(
|
||||
self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
elem: &ProjectionElem<V, T>,
|
||||
mut handle_field: impl FnMut(&Self, FieldIdx, T) -> Ty<'tcx>,
|
||||
mut handle_opaque_cast_and_subtype: impl FnMut(&Self, T) -> Ty<'tcx>,
|
||||
) -> PlaceTy<'tcx>
|
||||
where
|
||||
V: ::std::fmt::Debug,
|
||||
T: ::std::fmt::Debug + Copy,
|
||||
{
|
||||
if self.variant_index.is_some() && !matches!(elem, ProjectionElem::Field(..)) {
|
||||
bug!("cannot use non field projection on downcasted place")
|
||||
}
|
||||
let answer = match *elem {
|
||||
ProjectionElem::Deref => {
|
||||
let ty = self.ty.builtin_deref(true).unwrap_or_else(|| {
|
||||
bug!("deref projection of non-dereferenceable ty {:?}", self)
|
||||
});
|
||||
PlaceTy::from_ty(ty)
|
||||
}
|
||||
ProjectionElem::Index(_) | ProjectionElem::ConstantIndex { .. } => {
|
||||
PlaceTy::from_ty(self.ty.builtin_index().unwrap())
|
||||
}
|
||||
ProjectionElem::Subslice { from, to, from_end } => {
|
||||
PlaceTy::from_ty(match self.ty.kind() {
|
||||
ty::Slice(..) => self.ty,
|
||||
ty::Array(inner, _) if !from_end => Ty::new_array(tcx, *inner, to - from),
|
||||
ty::Array(inner, size) if from_end => {
|
||||
let size = size
|
||||
.try_to_target_usize(tcx)
|
||||
.expect("expected subslice projection on fixed-size array");
|
||||
let len = size - from - to;
|
||||
Ty::new_array(tcx, *inner, len)
|
||||
}
|
||||
_ => bug!("cannot subslice non-array type: `{:?}`", self),
|
||||
})
|
||||
}
|
||||
ProjectionElem::Downcast(_name, index) => {
|
||||
PlaceTy { ty: self.ty, variant_index: Some(index) }
|
||||
}
|
||||
ProjectionElem::Field(f, fty) => PlaceTy::from_ty(handle_field(&self, f, fty)),
|
||||
ProjectionElem::OpaqueCast(ty) => {
|
||||
PlaceTy::from_ty(handle_opaque_cast_and_subtype(&self, ty))
|
||||
}
|
||||
ProjectionElem::Subtype(ty) => {
|
||||
PlaceTy::from_ty(handle_opaque_cast_and_subtype(&self, ty))
|
||||
}
|
||||
|
||||
// FIXME(unsafe_binders): Rename `handle_opaque_cast_and_subtype` to be more general.
|
||||
ProjectionElem::UnwrapUnsafeBinder(ty) => {
|
||||
PlaceTy::from_ty(handle_opaque_cast_and_subtype(&self, ty))
|
||||
}
|
||||
};
|
||||
debug!("projection_ty self: {:?} elem: {:?} yields: {:?}", self, elem, answer);
|
||||
answer
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Place<'tcx> {
|
||||
pub fn ty_from<D: ?Sized>(
|
||||
local: Local,
|
||||
projection: &[PlaceElem<'tcx>],
|
||||
local_decls: &D,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> PlaceTy<'tcx>
|
||||
where
|
||||
D: HasLocalDecls<'tcx>,
|
||||
{
|
||||
PlaceTy::from_ty(local_decls.local_decls()[local].ty).multi_projection_ty(tcx, projection)
|
||||
}
|
||||
|
||||
pub fn ty<D: ?Sized>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx>
|
||||
where
|
||||
D: HasLocalDecls<'tcx>,
|
||||
{
|
||||
Place::ty_from(self.local, self.projection, local_decls, tcx)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> PlaceRef<'tcx> {
|
||||
pub fn ty<D: ?Sized>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> PlaceTy<'tcx>
|
||||
where
|
||||
D: HasLocalDecls<'tcx>,
|
||||
{
|
||||
Place::ty_from(self.local, self.projection, local_decls, tcx)
|
||||
}
|
||||
}
|
||||
|
||||
pub enum RvalueInitializationState {
|
||||
Shallow,
|
||||
Deep,
|
||||
}
|
||||
|
||||
impl<'tcx> Rvalue<'tcx> {
|
||||
pub fn ty<D: ?Sized>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
|
||||
where
|
||||
D: HasLocalDecls<'tcx>,
|
||||
{
|
||||
match *self {
|
||||
Rvalue::Use(ref operand) => operand.ty(local_decls, tcx),
|
||||
Rvalue::Repeat(ref operand, count) => {
|
||||
Ty::new_array_with_const_len(tcx, operand.ty(local_decls, tcx), count)
|
||||
}
|
||||
Rvalue::ThreadLocalRef(did) => tcx.thread_local_ptr_ty(did),
|
||||
Rvalue::Ref(reg, bk, ref place) => {
|
||||
let place_ty = place.ty(local_decls, tcx).ty;
|
||||
Ty::new_ref(tcx, reg, place_ty, bk.to_mutbl_lossy())
|
||||
}
|
||||
Rvalue::RawPtr(kind, ref place) => {
|
||||
let place_ty = place.ty(local_decls, tcx).ty;
|
||||
Ty::new_ptr(tcx, place_ty, kind.to_mutbl_lossy())
|
||||
}
|
||||
Rvalue::Len(..) => tcx.types.usize,
|
||||
Rvalue::Cast(.., ty) => ty,
|
||||
Rvalue::BinaryOp(op, box (ref lhs, ref rhs)) => {
|
||||
let lhs_ty = lhs.ty(local_decls, tcx);
|
||||
let rhs_ty = rhs.ty(local_decls, tcx);
|
||||
op.ty(tcx, lhs_ty, rhs_ty)
|
||||
}
|
||||
Rvalue::UnaryOp(op, ref operand) => {
|
||||
let arg_ty = operand.ty(local_decls, tcx);
|
||||
op.ty(tcx, arg_ty)
|
||||
}
|
||||
Rvalue::Discriminant(ref place) => place.ty(local_decls, tcx).ty.discriminant_ty(tcx),
|
||||
Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf | NullOp::OffsetOf(..), _) => {
|
||||
tcx.types.usize
|
||||
}
|
||||
Rvalue::NullaryOp(NullOp::ContractChecks, _)
|
||||
| Rvalue::NullaryOp(NullOp::UbChecks, _) => tcx.types.bool,
|
||||
Rvalue::Aggregate(ref ak, ref ops) => match **ak {
|
||||
AggregateKind::Array(ty) => Ty::new_array(tcx, ty, ops.len() as u64),
|
||||
AggregateKind::Tuple => {
|
||||
Ty::new_tup_from_iter(tcx, ops.iter().map(|op| op.ty(local_decls, tcx)))
|
||||
}
|
||||
AggregateKind::Adt(did, _, args, _, _) => tcx.type_of(did).instantiate(tcx, args),
|
||||
AggregateKind::Closure(did, args) => Ty::new_closure(tcx, did, args),
|
||||
AggregateKind::Coroutine(did, args) => Ty::new_coroutine(tcx, did, args),
|
||||
AggregateKind::CoroutineClosure(did, args) => {
|
||||
Ty::new_coroutine_closure(tcx, did, args)
|
||||
}
|
||||
AggregateKind::RawPtr(ty, mutability) => Ty::new_ptr(tcx, ty, mutability),
|
||||
},
|
||||
Rvalue::ShallowInitBox(_, ty) => Ty::new_box(tcx, ty),
|
||||
Rvalue::CopyForDeref(ref place) => place.ty(local_decls, tcx).ty,
|
||||
Rvalue::WrapUnsafeBinder(_, ty) => ty,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
/// Returns `true` if this rvalue is deeply initialized (most rvalues) or
|
||||
/// whether its only shallowly initialized (`Rvalue::Box`).
|
||||
pub fn initialization_state(&self) -> RvalueInitializationState {
|
||||
match *self {
|
||||
Rvalue::ShallowInitBox(_, _) => RvalueInitializationState::Shallow,
|
||||
_ => RvalueInitializationState::Deep,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Operand<'tcx> {
|
||||
pub fn ty<D: ?Sized>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
|
||||
where
|
||||
D: HasLocalDecls<'tcx>,
|
||||
{
|
||||
match self {
|
||||
&Operand::Copy(ref l) | &Operand::Move(ref l) => l.ty(local_decls, tcx).ty,
|
||||
Operand::Constant(c) => c.const_.ty(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn span<D: ?Sized>(&self, local_decls: &D) -> Span
|
||||
where
|
||||
D: HasLocalDecls<'tcx>,
|
||||
{
|
||||
match self {
|
||||
&Operand::Copy(ref l) | &Operand::Move(ref l) => {
|
||||
local_decls.local_decls()[l.local].source_info.span
|
||||
}
|
||||
Operand::Constant(c) => c.span,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> BinOp {
|
||||
pub fn ty(&self, tcx: TyCtxt<'tcx>, lhs_ty: Ty<'tcx>, rhs_ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
// FIXME: handle SIMD correctly
|
||||
match self {
|
||||
&BinOp::Add
|
||||
| &BinOp::AddUnchecked
|
||||
| &BinOp::Sub
|
||||
| &BinOp::SubUnchecked
|
||||
| &BinOp::Mul
|
||||
| &BinOp::MulUnchecked
|
||||
| &BinOp::Div
|
||||
| &BinOp::Rem
|
||||
| &BinOp::BitXor
|
||||
| &BinOp::BitAnd
|
||||
| &BinOp::BitOr => {
|
||||
// these should be integers or floats of the same size.
|
||||
assert_eq!(lhs_ty, rhs_ty);
|
||||
lhs_ty
|
||||
}
|
||||
&BinOp::AddWithOverflow | &BinOp::SubWithOverflow | &BinOp::MulWithOverflow => {
|
||||
// these should be integers of the same size.
|
||||
assert_eq!(lhs_ty, rhs_ty);
|
||||
Ty::new_tup(tcx, &[lhs_ty, tcx.types.bool])
|
||||
}
|
||||
&BinOp::Shl
|
||||
| &BinOp::ShlUnchecked
|
||||
| &BinOp::Shr
|
||||
| &BinOp::ShrUnchecked
|
||||
| &BinOp::Offset => {
|
||||
lhs_ty // lhs_ty can be != rhs_ty
|
||||
}
|
||||
&BinOp::Eq | &BinOp::Lt | &BinOp::Le | &BinOp::Ne | &BinOp::Ge | &BinOp::Gt => {
|
||||
tcx.types.bool
|
||||
}
|
||||
&BinOp::Cmp => {
|
||||
// these should be integer-like types of the same size.
|
||||
assert_eq!(lhs_ty, rhs_ty);
|
||||
tcx.ty_ordering_enum(None)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> UnOp {
|
||||
pub fn ty(&self, tcx: TyCtxt<'tcx>, arg_ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
match self {
|
||||
UnOp::Not | UnOp::Neg => arg_ty,
|
||||
UnOp::PtrMetadata => arg_ty.pointee_metadata_ty_or_projection(tcx),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BorrowKind {
|
||||
pub fn to_mutbl_lossy(self) -> hir::Mutability {
|
||||
match self {
|
||||
BorrowKind::Mut { .. } => hir::Mutability::Mut,
|
||||
BorrowKind::Shared => hir::Mutability::Not,
|
||||
|
||||
// We have no type corresponding to a shallow borrow, so use
|
||||
// `&` as an approximation.
|
||||
BorrowKind::Fake(_) => hir::Mutability::Not,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BinOp {
|
||||
pub(crate) fn to_hir_binop(self) -> hir::BinOpKind {
|
||||
match self {
|
||||
// HIR `+`/`-`/`*` can map to either of these MIR BinOp, depending
|
||||
// on whether overflow checks are enabled or not.
|
||||
BinOp::Add | BinOp::AddWithOverflow => hir::BinOpKind::Add,
|
||||
BinOp::Sub | BinOp::SubWithOverflow => hir::BinOpKind::Sub,
|
||||
BinOp::Mul | BinOp::MulWithOverflow => hir::BinOpKind::Mul,
|
||||
BinOp::Div => hir::BinOpKind::Div,
|
||||
BinOp::Rem => hir::BinOpKind::Rem,
|
||||
BinOp::BitXor => hir::BinOpKind::BitXor,
|
||||
BinOp::BitAnd => hir::BinOpKind::BitAnd,
|
||||
BinOp::BitOr => hir::BinOpKind::BitOr,
|
||||
BinOp::Shl => hir::BinOpKind::Shl,
|
||||
BinOp::Shr => hir::BinOpKind::Shr,
|
||||
BinOp::Eq => hir::BinOpKind::Eq,
|
||||
BinOp::Ne => hir::BinOpKind::Ne,
|
||||
BinOp::Lt => hir::BinOpKind::Lt,
|
||||
BinOp::Gt => hir::BinOpKind::Gt,
|
||||
BinOp::Le => hir::BinOpKind::Le,
|
||||
BinOp::Ge => hir::BinOpKind::Ge,
|
||||
// We don't have HIR syntax for these.
|
||||
BinOp::Cmp
|
||||
| BinOp::AddUnchecked
|
||||
| BinOp::SubUnchecked
|
||||
| BinOp::MulUnchecked
|
||||
| BinOp::ShlUnchecked
|
||||
| BinOp::ShrUnchecked
|
||||
| BinOp::Offset => {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// If this is a `FooWithOverflow`, return `Some(Foo)`.
|
||||
pub fn overflowing_to_wrapping(self) -> Option<BinOp> {
|
||||
Some(match self {
|
||||
BinOp::AddWithOverflow => BinOp::Add,
|
||||
BinOp::SubWithOverflow => BinOp::Sub,
|
||||
BinOp::MulWithOverflow => BinOp::Mul,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns whether this is a `FooWithOverflow`
|
||||
pub fn is_overflowing(self) -> bool {
|
||||
self.overflowing_to_wrapping().is_some()
|
||||
}
|
||||
|
||||
/// If this is a `Foo`, return `Some(FooWithOverflow)`.
|
||||
pub fn wrapping_to_overflowing(self) -> Option<BinOp> {
|
||||
Some(match self {
|
||||
BinOp::Add => BinOp::AddWithOverflow,
|
||||
BinOp::Sub => BinOp::SubWithOverflow,
|
||||
BinOp::Mul => BinOp::MulWithOverflow,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
use rustc_abi::{FieldIdx, VariantIdx};
|
||||
use rustc_middle::mir::interpret::Scalar;
|
||||
use rustc_middle::mir::tcx::PlaceTy;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::thir::*;
|
||||
use rustc_middle::ty;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use std::mem;
|
||||
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_middle::mir::tcx::{PlaceTy, RvalueInitializationState};
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexSet, StdEntry};
|
|||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_index::bit_set::DenseBitSet;
|
||||
use rustc_middle::mir::tcx::PlaceTy;
|
||||
use rustc_middle::mir::visit::{MutatingUseContext, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ where
|
|||
place.ty(self.elaborator.body(), self.tcx()).ty
|
||||
} else {
|
||||
// We don't have a slice with all the locals, since some are in the patch.
|
||||
tcx::PlaceTy::from_ty(self.elaborator.patch_ref().local_ty(place.local))
|
||||
PlaceTy::from_ty(self.elaborator.patch_ref().local_ty(place.local))
|
||||
.multi_projection_ty(self.elaborator.tcx(), place.projection)
|
||||
.ty
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::iter;
|
|||
|
||||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_errors::{
|
||||
Applicability, Diag, E0309, E0310, E0311, E0495, Subdiagnostic, struct_span_code_err,
|
||||
Applicability, Diag, E0309, E0310, E0311, E0803, Subdiagnostic, struct_span_code_err,
|
||||
};
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
|
|
@ -1032,7 +1032,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
struct_span_code_err!(
|
||||
self.dcx(),
|
||||
var_origin.span(),
|
||||
E0495,
|
||||
E0803,
|
||||
"cannot infer an appropriate lifetime{} due to conflicting requirements",
|
||||
var_description
|
||||
)
|
||||
|
|
|
|||
|
|
@ -556,13 +556,13 @@ impl<A: Debug + TrustedRandomAccessNoCoerce, B: Debug + TrustedRandomAccessNoCoe
|
|||
/// * `std::iter::ExactSizeIterator::len`
|
||||
/// * `std::iter::Iterator::__iterator_get_unchecked`
|
||||
/// * `std::iter::TrustedRandomAccessNoCoerce::size`
|
||||
/// 5. If `T` is a subtype of `Self`, then `self` is allowed to be coerced
|
||||
/// 5. If `Self` is a subtype of `T`, then `self` is allowed to be coerced
|
||||
/// to `T`. If `self` is coerced to `T` after `self.__iterator_get_unchecked(idx)` has already
|
||||
/// been called, then no methods except for the ones listed under 4. are allowed to be called
|
||||
/// on the resulting value of type `T`, either. Multiple such coercion steps are allowed.
|
||||
/// Regarding 2. and 3., the number of times `__iterator_get_unchecked(idx)` or `next_back()` is
|
||||
/// called on `self` and the resulting value of type `T` (and on further coercion results with
|
||||
/// sub-subtypes) are added together and their sums must not exceed the specified bounds.
|
||||
/// super-supertypes) are added together and their sums must not exceed the specified bounds.
|
||||
///
|
||||
/// Further, given that these conditions are met, it must guarantee that:
|
||||
///
|
||||
|
|
@ -570,7 +570,7 @@ impl<A: Debug + TrustedRandomAccessNoCoerce, B: Debug + TrustedRandomAccessNoCoe
|
|||
/// * It must be safe to call the methods listed above on `self` after calling
|
||||
/// `self.__iterator_get_unchecked(idx)`, assuming that the required traits are implemented.
|
||||
/// * It must also be safe to drop `self` after calling `self.__iterator_get_unchecked(idx)`.
|
||||
/// * If `T` is a subtype of `Self`, then it must be safe to coerce `self` to `T`.
|
||||
/// * If `Self` is a subtype of `T`, then it must be safe to coerce `self` to `T`.
|
||||
//
|
||||
// FIXME: Clarify interaction with SourceIter/InPlaceIterable. Calling `SourceIter::as_inner`
|
||||
// after `__iterator_get_unchecked` is supposed to be allowed.
|
||||
|
|
@ -580,7 +580,7 @@ impl<A: Debug + TrustedRandomAccessNoCoerce, B: Debug + TrustedRandomAccessNoCoe
|
|||
pub unsafe trait TrustedRandomAccess: TrustedRandomAccessNoCoerce {}
|
||||
|
||||
/// Like [`TrustedRandomAccess`] but without any of the requirements / guarantees around
|
||||
/// coercions to subtypes after `__iterator_get_unchecked` (they aren’t allowed here!), and
|
||||
/// coercions to supertypes after `__iterator_get_unchecked` (they aren’t allowed here!), and
|
||||
/// without the requirement that subtypes / supertypes implement `TrustedRandomAccessNoCoerce`.
|
||||
///
|
||||
/// This trait was created in PR #85874 to fix soundness issue #85873 without performance regressions.
|
||||
|
|
|
|||
|
|
@ -193,13 +193,13 @@ macro_rules! int_impl {
|
|||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(integer_sign_cast)]
|
||||
///
|
||||
#[doc = concat!("let n = -1", stringify!($SelfT), ";")]
|
||||
///
|
||||
#[doc = concat!("assert_eq!(n.cast_unsigned(), ", stringify!($UnsignedT), "::MAX);")]
|
||||
/// ```
|
||||
#[unstable(feature = "integer_sign_cast", issue = "125882")]
|
||||
#[stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
|
|
|
|||
|
|
@ -1633,14 +1633,14 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
|
|||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(integer_sign_cast)]
|
||||
/// # use std::num::NonZero;
|
||||
///
|
||||
#[doc = concat!("let n = NonZero::<", stringify!($Int), ">::MAX;")]
|
||||
///
|
||||
#[doc = concat!("assert_eq!(n.cast_signed(), NonZero::new(-1", stringify!($Sint), ").unwrap());")]
|
||||
/// ```
|
||||
#[unstable(feature = "integer_sign_cast", issue = "125882")]
|
||||
#[stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
|
|
@ -2072,14 +2072,14 @@ macro_rules! nonzero_integer_signedness_dependent_methods {
|
|||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(integer_sign_cast)]
|
||||
/// # use std::num::NonZero;
|
||||
///
|
||||
#[doc = concat!("let n = NonZero::new(-1", stringify!($Int), ").unwrap();")]
|
||||
///
|
||||
#[doc = concat!("assert_eq!(n.cast_unsigned(), NonZero::<", stringify!($Uint), ">::MAX);")]
|
||||
/// ```
|
||||
#[unstable(feature = "integer_sign_cast", issue = "125882")]
|
||||
#[stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
|
|
|
|||
|
|
@ -223,13 +223,12 @@ macro_rules! uint_impl {
|
|||
/// Basic usage:
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(integer_sign_cast)]
|
||||
///
|
||||
#[doc = concat!("let n = ", stringify!($SelfT), "::MAX;")]
|
||||
///
|
||||
#[doc = concat!("assert_eq!(n.cast_signed(), -1", stringify!($SignedT), ");")]
|
||||
/// ```
|
||||
#[unstable(feature = "integer_sign_cast", issue = "125882")]
|
||||
#[stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[must_use = "this returns the result of the operation, \
|
||||
without modifying the original"]
|
||||
#[inline(always)]
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ rinja = { version = "0.3", default-features = false, features = ["config"] }
|
|||
base64 = "0.21.7"
|
||||
itertools = "0.12"
|
||||
indexmap = "2"
|
||||
minifier = { version = "0.3.4", default-features = false }
|
||||
minifier = { version = "0.3.5", default-features = false }
|
||||
pulldown-cmark-old = { version = "0.9.6", package = "pulldown-cmark", default-features = false }
|
||||
regex = "1"
|
||||
rustdoc-json-types = { path = "../rustdoc-json-types" }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0277]: the trait bound `&str: AsExpression<Integer>` is not satisfied
|
||||
--> $DIR/as_expression.rs:55:15
|
||||
--> $DIR/as_expression.rs:56:15
|
||||
|
|
||||
LL | SelectInt.check("bar");
|
||||
| ^^^^^ the trait `AsExpression<Integer>` is not implemented for `&str`
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0277]: the trait bound `&str: AsExpression<<SelectInt as Expression>::SqlType>` is not satisfied
|
||||
--> $DIR/as_expression.rs:55:21
|
||||
--> $DIR/as_expression.rs:56:21
|
||||
|
|
||||
LL | SelectInt.check("bar");
|
||||
| ----- ^^^^^ the trait `AsExpression<<SelectInt as Expression>::SqlType>` is not implemented for `&str`
|
||||
|
|
@ -8,7 +8,7 @@ LL | SelectInt.check("bar");
|
|||
|
|
||||
= help: the trait `AsExpression<Text>` is implemented for `&str`
|
||||
note: required by a bound in `Foo::check`
|
||||
--> $DIR/as_expression.rs:46:12
|
||||
--> $DIR/as_expression.rs:47:12
|
||||
|
|
||||
LL | fn check<T>(&self, _: T) -> <T as AsExpression<<Self as Expression>::SqlType>>::Expression
|
||||
| ----- required by a bound in this associated function
|
||||
|
|
@ -17,7 +17,7 @@ LL | T: AsExpression<Self::SqlType>,
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo::check`
|
||||
|
||||
error[E0271]: type mismatch resolving `<SelectInt as Expression>::SqlType == Text`
|
||||
--> $DIR/as_expression.rs:55:5
|
||||
--> $DIR/as_expression.rs:56:5
|
||||
|
|
||||
LL | SelectInt.check("bar");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ expected `Text`, found `Integer`
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ reference: attributes.diagnostic.do_not_recommend.intro
|
||||
|
||||
pub trait Expression {
|
||||
type SqlType;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
|
||||
--> $DIR/does_not_acccept_args.rs:10:1
|
||||
--> $DIR/does_not_acccept_args.rs:11:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend(not_accepted)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -7,13 +7,13 @@ LL | #[diagnostic::do_not_recommend(not_accepted)]
|
|||
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
|
||||
--> $DIR/does_not_acccept_args.rs:14:1
|
||||
--> $DIR/does_not_acccept_args.rs:15:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend(not_accepted = "foo")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
|
||||
--> $DIR/does_not_acccept_args.rs:18:1
|
||||
--> $DIR/does_not_acccept_args.rs:19:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend(not_accepted(42))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
|
||||
--> $DIR/does_not_acccept_args.rs:10:1
|
||||
--> $DIR/does_not_acccept_args.rs:11:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend(not_accepted)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -7,13 +7,13 @@ LL | #[diagnostic::do_not_recommend(not_accepted)]
|
|||
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
|
||||
--> $DIR/does_not_acccept_args.rs:14:1
|
||||
--> $DIR/does_not_acccept_args.rs:15:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend(not_accepted = "foo")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
|
||||
--> $DIR/does_not_acccept_args.rs:18:1
|
||||
--> $DIR/does_not_acccept_args.rs:19:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend(not_accepted(42))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ reference: attributes.diagnostic.do_not_recommend.syntax
|
||||
|
||||
trait Foo {}
|
||||
trait Bar {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:6:1
|
||||
--> $DIR/incorrect-locations.rs:7:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -7,49 +7,49 @@ LL | #[diagnostic::do_not_recommend]
|
|||
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:10:1
|
||||
--> $DIR/incorrect-locations.rs:11:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:14:1
|
||||
--> $DIR/incorrect-locations.rs:15:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:18:1
|
||||
--> $DIR/incorrect-locations.rs:19:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:22:1
|
||||
--> $DIR/incorrect-locations.rs:23:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:26:1
|
||||
--> $DIR/incorrect-locations.rs:27:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:30:1
|
||||
--> $DIR/incorrect-locations.rs:31:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:34:1
|
||||
--> $DIR/incorrect-locations.rs:35:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:38:1
|
||||
--> $DIR/incorrect-locations.rs:39:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:6:1
|
||||
--> $DIR/incorrect-locations.rs:7:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -7,49 +7,49 @@ LL | #[diagnostic::do_not_recommend]
|
|||
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:10:1
|
||||
--> $DIR/incorrect-locations.rs:11:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:14:1
|
||||
--> $DIR/incorrect-locations.rs:15:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:18:1
|
||||
--> $DIR/incorrect-locations.rs:19:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:22:1
|
||||
--> $DIR/incorrect-locations.rs:23:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:26:1
|
||||
--> $DIR/incorrect-locations.rs:27:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:30:1
|
||||
--> $DIR/incorrect-locations.rs:31:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:34:1
|
||||
--> $DIR/incorrect-locations.rs:35:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: `#[diagnostic::do_not_recommend]` can only be placed on trait implementations
|
||||
--> $DIR/incorrect-locations.rs:38:1
|
||||
--> $DIR/incorrect-locations.rs:39:1
|
||||
|
|
||||
LL | #[diagnostic::do_not_recommend]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ reference: attributes.diagnostic.do_not_recommend.allowed-positions
|
||||
|
||||
#[diagnostic::do_not_recommend]
|
||||
//~^WARN `#[diagnostic::do_not_recommend]` can only be placed
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error[E0277]: the trait bound `(): Root` is not satisfied
|
||||
--> $DIR/nested.rs:21:18
|
||||
--> $DIR/nested.rs:22:18
|
||||
|
|
||||
LL | needs_root::<()>();
|
||||
| ^^ the trait `Root` is not implemented for `()`
|
||||
|
|
||||
note: required by a bound in `needs_root`
|
||||
--> $DIR/nested.rs:18:18
|
||||
--> $DIR/nested.rs:19:18
|
||||
|
|
||||
LL | fn needs_root<T: Root>() {}
|
||||
| ^^^^ required by this bound in `needs_root`
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error[E0277]: the trait bound `(): Root` is not satisfied
|
||||
--> $DIR/nested.rs:21:18
|
||||
--> $DIR/nested.rs:22:18
|
||||
|
|
||||
LL | needs_root::<()>();
|
||||
| ^^ the trait `Root` is not implemented for `()`
|
||||
|
|
||||
note: required by a bound in `needs_root`
|
||||
--> $DIR/nested.rs:18:18
|
||||
--> $DIR/nested.rs:19:18
|
||||
|
|
||||
LL | fn needs_root<T: Root>() {}
|
||||
| ^^^^ required by this bound in `needs_root`
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ reference: attributes.diagnostic.do_not_recommend.intro
|
||||
|
||||
trait Root {}
|
||||
trait DontRecommend {}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error[E0277]: the trait bound `*mut (): Foo` is not satisfied
|
||||
--> $DIR/simple.rs:15:17
|
||||
--> $DIR/simple.rs:16:17
|
||||
|
|
||||
LL | needs_foo::<*mut ()>();
|
||||
| ^^^^^^^ the trait `Foo` is not implemented for `*mut ()`
|
||||
|
|
||||
note: required by a bound in `needs_foo`
|
||||
--> $DIR/simple.rs:10:17
|
||||
--> $DIR/simple.rs:11:17
|
||||
|
|
||||
LL | fn needs_foo<T: Foo>() {}
|
||||
| ^^^ required by this bound in `needs_foo`
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error[E0277]: the trait bound `*mut (): Foo` is not satisfied
|
||||
--> $DIR/simple.rs:15:17
|
||||
--> $DIR/simple.rs:16:17
|
||||
|
|
||||
LL | needs_foo::<*mut ()>();
|
||||
| ^^^^^^^ the trait `Foo` is not implemented for `*mut ()`
|
||||
|
|
||||
note: required by a bound in `needs_foo`
|
||||
--> $DIR/simple.rs:10:17
|
||||
--> $DIR/simple.rs:11:17
|
||||
|
|
||||
LL | fn needs_foo<T: Foo>() {}
|
||||
| ^^^ required by this bound in `needs_foo`
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ reference: attributes.diagnostic.do_not_recommend.intro
|
||||
|
||||
trait Foo {}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error[E0277]: the trait bound `(): Root` is not satisfied
|
||||
--> $DIR/stacked.rs:17:18
|
||||
--> $DIR/stacked.rs:18:18
|
||||
|
|
||||
LL | needs_root::<()>();
|
||||
| ^^ the trait `Root` is not implemented for `()`
|
||||
|
|
||||
note: required by a bound in `needs_root`
|
||||
--> $DIR/stacked.rs:14:18
|
||||
--> $DIR/stacked.rs:15:18
|
||||
|
|
||||
LL | fn needs_root<T: Root>() {}
|
||||
| ^^^^ required by this bound in `needs_root`
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error[E0277]: the trait bound `(): Root` is not satisfied
|
||||
--> $DIR/stacked.rs:17:18
|
||||
--> $DIR/stacked.rs:18:18
|
||||
|
|
||||
LL | needs_root::<()>();
|
||||
| ^^ the trait `Root` is not implemented for `()`
|
||||
|
|
||||
note: required by a bound in `needs_root`
|
||||
--> $DIR/stacked.rs:14:18
|
||||
--> $DIR/stacked.rs:15:18
|
||||
|
|
||||
LL | fn needs_root<T: Root>() {}
|
||||
| ^^^^ required by this bound in `needs_root`
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ reference: attributes.diagnostic.do_not_recommend.intro
|
||||
|
||||
trait Root {}
|
||||
trait DontRecommend {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0277]: the trait bound `(): Foo` is not satisfied
|
||||
--> $DIR/supress_suggestions_in_help.rs:21:11
|
||||
--> $DIR/supress_suggestions_in_help.rs:22:11
|
||||
|
|
||||
LL | check(());
|
||||
| ----- ^^ the trait `Foo` is not implemented for `()`
|
||||
|
|
@ -8,7 +8,7 @@ LL | check(());
|
|||
|
|
||||
= help: the trait `Foo` is implemented for `i32`
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/supress_suggestions_in_help.rs:18:18
|
||||
--> $DIR/supress_suggestions_in_help.rs:19:18
|
||||
|
|
||||
LL | fn check(a: impl Foo) {}
|
||||
| ^^^ required by this bound in `check`
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0277]: the trait bound `(): Foo` is not satisfied
|
||||
--> $DIR/supress_suggestions_in_help.rs:21:11
|
||||
--> $DIR/supress_suggestions_in_help.rs:22:11
|
||||
|
|
||||
LL | check(());
|
||||
| ----- ^^ the trait `Foo` is not implemented for `()`
|
||||
|
|
@ -8,7 +8,7 @@ LL | check(());
|
|||
|
|
||||
= help: the trait `Foo` is implemented for `i32`
|
||||
note: required by a bound in `check`
|
||||
--> $DIR/supress_suggestions_in_help.rs:18:18
|
||||
--> $DIR/supress_suggestions_in_help.rs:19:18
|
||||
|
|
||||
LL | fn check(a: impl Foo) {}
|
||||
| ^^^ required by this bound in `check`
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ reference: attributes.diagnostic.do_not_recommend.intro
|
||||
|
||||
trait Foo {}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error[E0277]: Very important message!
|
||||
--> $DIR/type_mismatch.rs:23:14
|
||||
--> $DIR/type_mismatch.rs:24:14
|
||||
|
|
||||
LL | verify::<u8>();
|
||||
| ^^ the trait `TheImportantOne` is not implemented for `u8`
|
||||
|
|
||||
note: required by a bound in `verify`
|
||||
--> $DIR/type_mismatch.rs:20:14
|
||||
--> $DIR/type_mismatch.rs:21:14
|
||||
|
|
||||
LL | fn verify<T: TheImportantOne>() {}
|
||||
| ^^^^^^^^^^^^^^^ required by this bound in `verify`
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error[E0277]: Very important message!
|
||||
--> $DIR/type_mismatch.rs:23:14
|
||||
--> $DIR/type_mismatch.rs:24:14
|
||||
|
|
||||
LL | verify::<u8>();
|
||||
| ^^ the trait `TheImportantOne` is not implemented for `u8`
|
||||
|
|
||||
note: required by a bound in `verify`
|
||||
--> $DIR/type_mismatch.rs:20:14
|
||||
--> $DIR/type_mismatch.rs:21:14
|
||||
|
|
||||
LL | fn verify<T: TheImportantOne>() {}
|
||||
| ^^^^^^^^^^^^^^^ required by this bound in `verify`
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ reference: attributes.diagnostic.do_not_recommend.intro
|
||||
|
||||
#[diagnostic::on_unimplemented(message = "Very important message!")]
|
||||
trait TheImportantOne {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/with_lifetime.rs:17:5
|
||||
--> $DIR/with_lifetime.rs:18:5
|
||||
|
|
||||
LL | fn foo<'a>(a: &'a ()) {
|
||||
| -- lifetime `'a` defined here
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/with_lifetime.rs:17:5
|
||||
--> $DIR/with_lifetime.rs:18:5
|
||||
|
|
||||
LL | fn foo<'a>(a: &'a ()) {
|
||||
| -- lifetime `'a` defined here
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
//@ reference: attributes.diagnostic.do_not_recommend.intro
|
||||
|
||||
trait Root {}
|
||||
trait DontRecommend {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter 's in generic type due to conflicting requirements
|
||||
error[E0803]: cannot infer an appropriate lifetime for lifetime parameter 's in generic type due to conflicting requirements
|
||||
--> $DIR/impl-implied-bounds-compatibility-unnormalized.rs:11:5
|
||||
|
|
||||
LL | fn get<'s>(s: &'s str, _: <&'static &'s () as Project>::Ty) -> &'static str {
|
||||
|
|
@ -25,4 +25,4 @@ LL | fn get<'s>(s: &'s str, _: <&'static &'s () as Project>::Ty) -> &'static
|
|||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0495`.
|
||||
For more information about this error, try `rustc --explain E0803`.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
|
||||
error[E0803]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
|
||||
--> $DIR/issue-20831-debruijn.rs:28:33
|
||||
|
|
||||
LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher>::Output> + 'a>) {
|
||||
|
|
@ -48,4 +48,4 @@ LL | fn subscribe(&mut self, t : Box<dyn Subscriber<Input=<Self as Publisher
|
|||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0495`.
|
||||
For more information about this error, try `rustc --explain E0803`.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'d` due to conflicting requirements
|
||||
error[E0803]: cannot infer an appropriate lifetime for lifetime parameter `'d` due to conflicting requirements
|
||||
--> $DIR/normalization-bounds-error.rs:12:31
|
||||
|
|
||||
LL | fn visit_seq<'d, 'a: 'd>() -> <&'a () as Visitor<'d>>::Value {}
|
||||
|
|
@ -36,4 +36,4 @@ LL | fn visit_seq<'d, 'a: 'd>() -> <&'a () as Visitor<'d>>::Value {}
|
|||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0495`.
|
||||
For more information about this error, try `rustc --explain E0803`.
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@
|
|||
// Make sure that these behaviors don't get inherited to children
|
||||
// spawned via std::process, since they're needed for traditional UNIX
|
||||
// filter behavior.
|
||||
// This test checks that `while echo y ; do : ; done | head` terminates
|
||||
// (instead of running forever), and that it does not print an error
|
||||
// message about a broken pipe.
|
||||
// This test checks that `yes` or `while echo y ; do : ; done | head`
|
||||
// terminates (instead of running forever), and that it does not print an
|
||||
// error message about a broken pipe.
|
||||
|
||||
//@ ignore-vxworks no 'sh'
|
||||
//@ ignore-fuchsia no 'sh'
|
||||
|
|
@ -22,14 +22,21 @@ use std::process;
|
|||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
// Just in case `yes` doesn't check for EPIPE...
|
||||
// Just in case `yes` or `while-echo` doesn't check for EPIPE...
|
||||
thread::spawn(|| {
|
||||
thread::sleep_ms(5000);
|
||||
process::exit(1);
|
||||
});
|
||||
// QNX Neutrino does not have `yes`. Therefore, use `while-echo` for `nto`
|
||||
// and `yes` for other platforms.
|
||||
let command = if cfg!(target_os = "nto") {
|
||||
"while echo y ; do : ; done | head"
|
||||
} else {
|
||||
"yes | head"
|
||||
};
|
||||
let output = process::Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg("while echo y ; do : ; done | head")
|
||||
.arg(command)
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(output.status.success());
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
|
||||
error[E0803]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
|
||||
--> $DIR/regions-normalize-in-where-clause-list.rs:24:4
|
||||
|
|
||||
LL | fn bar<'a, 'b>()
|
||||
|
|
@ -24,4 +24,4 @@ LL | fn bar<'a, 'b>()
|
|||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0495`.
|
||||
For more information about this error, try `rustc --explain E0803`.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter '_ in generic type due to conflicting requirements
|
||||
error[E0803]: cannot infer an appropriate lifetime for lifetime parameter '_ in generic type due to conflicting requirements
|
||||
--> $DIR/resolve-re-error-ice.rs:12:5
|
||||
|
|
||||
LL | fn key_set(&self) -> Subject<'a, Keys<K, V>, (), R> {
|
||||
|
|
@ -34,4 +34,4 @@ LL | struct Subject<'a, T, V, R>(PhantomData<(&'a T, V, R)>);
|
|||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0495`.
|
||||
For more information about this error, try `rustc --explain E0803`.
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ LL | impl<'a, A: Clone> Arbitrary for ::std::borrow::Cow<'a, A> {}
|
|||
| ^^
|
||||
= note: but lifetime parameter must outlive the static lifetime
|
||||
|
||||
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
|
||||
error[E0803]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
|
||||
--> $DIR/static-lifetime.rs:3:34
|
||||
|
|
||||
LL | impl<'a, A: Clone> Arbitrary for ::std::borrow::Cow<'a, A> {}
|
||||
|
|
@ -38,5 +38,5 @@ LL | impl<'a, A: Clone> Arbitrary for ::std::borrow::Cow<'a, A> {}
|
|||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0478, E0495.
|
||||
Some errors have detailed explanations: E0478, E0803.
|
||||
For more information about an error, try `rustc --explain E0478`.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements
|
||||
error[E0803]: cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting requirements
|
||||
--> $DIR/impl-of-supertrait-has-wrong-lifetime-parameters.rs:24:28
|
||||
|
|
||||
LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
|
||||
|
|
@ -24,4 +24,4 @@ LL | impl<'a,'b> T2<'a, 'b> for S<'a, 'b> {
|
|||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0495`.
|
||||
For more information about this error, try `rustc --explain E0803`.
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ note: but lifetime parameter must outlive the lifetime `'b` as defined here
|
|||
LL | type Opaque<'a, 'b> = impl Sized + 'a + 'b;
|
||||
| ^^
|
||||
|
||||
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
|
||||
error[E0803]: cannot infer an appropriate lifetime due to conflicting requirements
|
||||
--> $DIR/closure_wf_outlives.rs:34:9
|
||||
|
|
||||
LL | || {}
|
||||
|
|
@ -63,5 +63,5 @@ LL | type Opaque<T: 'static> = impl Sized;
|
|||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0310, E0478, E0495.
|
||||
Some errors have detailed explanations: E0310, E0478, E0803.
|
||||
For more information about an error, try `rustc --explain E0310`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue