Rollup merge of #142219 - Kivooeo:tf11, r=wesleywiser
`tests/ui`: A New Order [11/N]
Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895.
r? `@jieyouxu`
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 81fb39c..841bc39 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -11,6 +11,10 @@
on:
push:
branches:
+ # CI on master only serves for caching citool builds for the `calculate_matrix` job.
+ # In order to use GHA cache on PR CI (and auto/try) jobs, we need to write to it
+ # from the default branch.
+ - master
- auto
- try
- try-perf
@@ -60,12 +64,18 @@
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
with:
workspaces: src/ci/citool
+ - name: Test citool
+ # Only test citool on the auto branch, to reduce latency of the calculate matrix job
+ # on PR/try builds.
+ if: ${{ github.ref == 'refs/heads/auto' }}
+ run: |
+ cd src/ci/citool
+ CARGO_INCREMENTAL=0 cargo test
- name: Calculate the CI job matrix
env:
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: |
cd src/ci/citool
- CARGO_INCREMENTAL=0 cargo test
CARGO_INCREMENTAL=0 cargo run calculate-job-matrix >> $GITHUB_OUTPUT
id: jobs
job:
diff --git a/Cargo.lock b/Cargo.lock
index 164617c..93abab8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -162,7 +162,7 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01667f6f40216b9a0b2945e05fed5f1ad0ab6470e69cb9378001e37b1c0668e4"
dependencies = [
- "object",
+ "object 0.36.7",
]
[[package]]
@@ -235,7 +235,7 @@
"cfg-if",
"libc",
"miniz_oxide",
- "object",
+ "object 0.36.7",
"rustc-demangle",
"windows-targets 0.52.6",
]
@@ -2326,7 +2326,6 @@
"tempfile",
"tikv-jemalloc-sys",
"ui_test",
- "windows-sys 0.59.0",
]
[[package]]
@@ -2509,7 +2508,19 @@
"indexmap",
"memchr",
"ruzstd",
- "wasmparser 0.222.1",
+]
+
+[[package]]
+name = "object"
+version = "0.37.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6273adb7096cf9ab4335f258e627d8230e69d40d45567d678f552dcec6245215"
+dependencies = [
+ "crc32fast",
+ "hashbrown",
+ "indexmap",
+ "memchr",
+ "wasmparser 0.232.0",
]
[[package]]
@@ -3109,7 +3120,7 @@
"build_helper",
"gimli",
"libc",
- "object",
+ "object 0.36.7",
"regex",
"serde_json",
"similar",
@@ -3118,11 +3129,12 @@
[[package]]
name = "rustc-build-sysroot"
-version = "0.5.7"
+version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "10edc2e4393515193bd766e2f6c050b0536a68e56f2b6d56c07ababfdc114ff0"
+checksum = "16d115ad7e26e0d1337f64ae6598f758194696afc2e9f34c8a6f24582529c3dc"
dependencies = [
"anyhow",
+ "regex",
"rustc_version",
"tempfile",
"walkdir",
@@ -3422,7 +3434,7 @@
"itertools",
"libc",
"measureme",
- "object",
+ "object 0.37.0",
"rustc-demangle",
"rustc_abi",
"rustc_ast",
@@ -3463,7 +3475,7 @@
"either",
"itertools",
"libc",
- "object",
+ "object 0.37.0",
"pathdiff",
"regex",
"rustc_abi",
@@ -3640,6 +3652,7 @@
"rustc_macros",
"rustc_serialize",
"rustc_span",
+ "smallvec",
"tracing",
"unic-langid",
]
@@ -3786,6 +3799,7 @@
"rustc_middle",
"rustc_session",
"rustc_span",
+ "rustc_target",
"rustc_trait_selection",
"smallvec",
"tracing",
@@ -4495,7 +4509,7 @@
version = "0.0.0"
dependencies = [
"bitflags",
- "object",
+ "object 0.37.0",
"rustc_abi",
"rustc_data_structures",
"rustc_fs_util",
@@ -5247,7 +5261,7 @@
dependencies = [
"gimli",
"hashbrown",
- "object",
+ "object 0.36.7",
"tracing",
]
@@ -5910,15 +5924,6 @@
[[package]]
name = "wasmparser"
-version = "0.222.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fa210fd1788e6b37a1d1930f3389c48e1d6ebd1a013d34fa4b7f9e3e3bf03146"
-dependencies = [
- "bitflags",
-]
-
-[[package]]
-name = "wasmparser"
version = "0.229.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0cc3b1f053f5d41aa55640a1fa9b6d1b8a9e4418d118ce308d20e24ff3575a8c"
@@ -5942,6 +5947,15 @@
]
[[package]]
+name = "wasmparser"
+version = "0.232.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "917739b33bb1eb0e9a49bcd2637a351931be4578d0cc4d37b908d7a797784fbb"
+dependencies = [
+ "bitflags",
+]
+
+[[package]]
name = "wast"
version = "230.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs
index 21fd6be..58a7fca 100644
--- a/compiler/rustc_abi/src/layout.rs
+++ b/compiler/rustc_abi/src/layout.rs
@@ -8,7 +8,7 @@
use tracing::debug;
use crate::{
- AbiAndPrefAlign, Align, BackendRepr, FieldsShape, HasDataLayout, IndexSlice, IndexVec, Integer,
+ AbiAlign, Align, BackendRepr, FieldsShape, HasDataLayout, IndexSlice, IndexVec, Integer,
LayoutData, Niche, NonZeroUsize, Primitive, ReprOptions, Scalar, Size, StructKind, TagEncoding,
Variants, WrappingRange,
};
@@ -173,13 +173,7 @@ pub fn simd_type<
// Non-power-of-two vectors have padding up to the next power-of-two.
// If we're a packed repr, remove the padding while keeping the alignment as close
// to a vector as possible.
- (
- BackendRepr::Memory { sized: true },
- AbiAndPrefAlign {
- abi: Align::max_aligned_factor(size),
- pref: dl.llvmlike_vector_align(size).pref,
- },
- )
+ (BackendRepr::Memory { sized: true }, AbiAlign { abi: Align::max_aligned_factor(size) })
} else {
(BackendRepr::SimdVector { element: e_repr, count }, dl.llvmlike_vector_align(size))
};
@@ -435,13 +429,13 @@ pub fn layout_of_union<
}
if let Some(pack) = repr.pack {
- align = align.min(AbiAndPrefAlign::new(pack));
+ align = align.min(AbiAlign::new(pack));
}
// The unadjusted ABI alignment does not include repr(align), but does include repr(pack).
// See documentation on `LayoutS::unadjusted_abi_align`.
let unadjusted_abi_align = align.abi;
if let Some(repr_align) = repr.align {
- align = align.max(AbiAndPrefAlign::new(repr_align));
+ align = align.max(AbiAlign::new(repr_align));
}
// `align` must not be modified after this, or `unadjusted_abi_align` could be inaccurate.
let align = align;
@@ -1289,7 +1283,7 @@ fn univariant_biased<
if let StructKind::Prefixed(prefix_size, prefix_align) = kind {
let prefix_align =
if let Some(pack) = pack { prefix_align.min(pack) } else { prefix_align };
- align = align.max(AbiAndPrefAlign::new(prefix_align));
+ align = align.max(AbiAlign::new(prefix_align));
offset = prefix_size.align_to(prefix_align);
}
for &i in &inverse_memory_index {
@@ -1308,7 +1302,7 @@ fn univariant_biased<
// Invariant: offset < dl.obj_size_bound() <= 1<<61
let field_align = if let Some(pack) = pack {
- field.align.min(AbiAndPrefAlign::new(pack))
+ field.align.min(AbiAlign::new(pack))
} else {
field.align
};
@@ -1342,7 +1336,7 @@ fn univariant_biased<
// See documentation on `LayoutS::unadjusted_abi_align`.
let unadjusted_abi_align = align.abi;
if let Some(repr_align) = repr.align {
- align = align.max(AbiAndPrefAlign::new(repr_align));
+ align = align.max(AbiAlign::new(repr_align));
}
// `align` must not be modified after this point, or `unadjusted_abi_align` could be inaccurate.
let align = align;
diff --git a/compiler/rustc_abi/src/layout/ty.rs b/compiler/rustc_abi/src/layout/ty.rs
index b5f9335..bb880a5 100644
--- a/compiler/rustc_abi/src/layout/ty.rs
+++ b/compiler/rustc_abi/src/layout/ty.rs
@@ -5,7 +5,7 @@
use rustc_macros::HashStable_Generic;
use crate::{
- AbiAndPrefAlign, Align, BackendRepr, FieldsShape, Float, HasDataLayout, LayoutData, Niche,
+ AbiAlign, Align, BackendRepr, FieldsShape, Float, HasDataLayout, LayoutData, Niche,
PointeeInfo, Primitive, Scalar, Size, TargetDataLayout, Variants,
};
@@ -100,7 +100,7 @@ pub fn largest_niche(self) -> Option<Niche> {
self.0.0.largest_niche
}
- pub fn align(self) -> AbiAndPrefAlign {
+ pub fn align(self) -> AbiAlign {
self.0.0.align
}
diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs
index 46b7a0c..4268e68 100644
--- a/compiler/rustc_abi/src/lib.rs
+++ b/compiler/rustc_abi/src/lib.rs
@@ -43,7 +43,7 @@
#[cfg(feature = "nightly")]
use std::iter::Step;
use std::num::{NonZeroUsize, ParseIntError};
-use std::ops::{Add, AddAssign, Mul, RangeInclusive, Sub};
+use std::ops::{Add, AddAssign, Deref, Mul, RangeInclusive, Sub};
use std::str::FromStr;
use bitflags::bitflags;
@@ -226,22 +226,22 @@ pub fn inhibits_union_abi_opt(&self) -> bool {
#[derive(Debug, PartialEq, Eq)]
pub struct TargetDataLayout {
pub endian: Endian,
- pub i1_align: AbiAndPrefAlign,
- pub i8_align: AbiAndPrefAlign,
- pub i16_align: AbiAndPrefAlign,
- pub i32_align: AbiAndPrefAlign,
- pub i64_align: AbiAndPrefAlign,
- pub i128_align: AbiAndPrefAlign,
- pub f16_align: AbiAndPrefAlign,
- pub f32_align: AbiAndPrefAlign,
- pub f64_align: AbiAndPrefAlign,
- pub f128_align: AbiAndPrefAlign,
+ pub i1_align: AbiAlign,
+ pub i8_align: AbiAlign,
+ pub i16_align: AbiAlign,
+ pub i32_align: AbiAlign,
+ pub i64_align: AbiAlign,
+ pub i128_align: AbiAlign,
+ pub f16_align: AbiAlign,
+ pub f32_align: AbiAlign,
+ pub f64_align: AbiAlign,
+ pub f128_align: AbiAlign,
pub pointer_size: Size,
- pub pointer_align: AbiAndPrefAlign,
- pub aggregate_align: AbiAndPrefAlign,
+ pub pointer_align: AbiAlign,
+ pub aggregate_align: AbiAlign,
/// Alignments for vector types.
- pub vector_align: Vec<(Size, AbiAndPrefAlign)>,
+ pub vector_align: Vec<(Size, AbiAlign)>,
pub instruction_address_space: AddressSpace,
@@ -257,22 +257,22 @@ fn default() -> TargetDataLayout {
let align = |bits| Align::from_bits(bits).unwrap();
TargetDataLayout {
endian: Endian::Big,
- i1_align: AbiAndPrefAlign::new(align(8)),
- i8_align: AbiAndPrefAlign::new(align(8)),
- i16_align: AbiAndPrefAlign::new(align(16)),
- i32_align: AbiAndPrefAlign::new(align(32)),
- i64_align: AbiAndPrefAlign { abi: align(32), pref: align(64) },
- i128_align: AbiAndPrefAlign { abi: align(32), pref: align(64) },
- f16_align: AbiAndPrefAlign::new(align(16)),
- f32_align: AbiAndPrefAlign::new(align(32)),
- f64_align: AbiAndPrefAlign::new(align(64)),
- f128_align: AbiAndPrefAlign::new(align(128)),
+ i1_align: AbiAlign::new(align(8)),
+ i8_align: AbiAlign::new(align(8)),
+ i16_align: AbiAlign::new(align(16)),
+ i32_align: AbiAlign::new(align(32)),
+ i64_align: AbiAlign::new(align(32)),
+ i128_align: AbiAlign::new(align(32)),
+ f16_align: AbiAlign::new(align(16)),
+ f32_align: AbiAlign::new(align(32)),
+ f64_align: AbiAlign::new(align(64)),
+ f128_align: AbiAlign::new(align(128)),
pointer_size: Size::from_bits(64),
- pointer_align: AbiAndPrefAlign::new(align(64)),
- aggregate_align: AbiAndPrefAlign { abi: align(0), pref: align(64) },
+ pointer_align: AbiAlign::new(align(64)),
+ aggregate_align: AbiAlign { abi: align(8) },
vector_align: vec![
- (Size::from_bits(64), AbiAndPrefAlign::new(align(64))),
- (Size::from_bits(128), AbiAndPrefAlign::new(align(128))),
+ (Size::from_bits(64), AbiAlign::new(align(64))),
+ (Size::from_bits(128), AbiAlign::new(align(128))),
],
instruction_address_space: AddressSpace::DATA,
c_enum_min_size: Integer::I32,
@@ -330,8 +330,7 @@ pub fn parse_from_llvm_datalayout_string<'a>(
.map_err(|err| TargetDataLayoutErrors::InvalidAlignment { cause, err })
};
let abi = parse_bits(s[0], "alignment", cause)?;
- let pref = s.get(1).map_or(Ok(abi), |pref| parse_bits(pref, "alignment", cause))?;
- Ok(AbiAndPrefAlign { abi: align_from_bits(abi)?, pref: align_from_bits(pref)? })
+ Ok(AbiAlign::new(align_from_bits(abi)?))
};
let mut dl = TargetDataLayout::default();
@@ -426,7 +425,7 @@ pub fn ptr_sized_integer(&self) -> Integer {
/// psABI-mandated alignment for a vector type, if any
#[inline]
- fn cabi_vector_align(&self, vec_size: Size) -> Option<AbiAndPrefAlign> {
+ fn cabi_vector_align(&self, vec_size: Size) -> Option<AbiAlign> {
self.vector_align
.iter()
.find(|(size, _align)| *size == vec_size)
@@ -435,8 +434,8 @@ fn cabi_vector_align(&self, vec_size: Size) -> Option<AbiAndPrefAlign> {
/// an alignment resembling the one LLVM would pick for a vector
#[inline]
- pub fn llvmlike_vector_align(&self, vec_size: Size) -> AbiAndPrefAlign {
- self.cabi_vector_align(vec_size).unwrap_or(AbiAndPrefAlign::new(
+ pub fn llvmlike_vector_align(&self, vec_size: Size) -> AbiAlign {
+ self.cabi_vector_align(vec_size).unwrap_or(AbiAlign::new(
Align::from_bytes(vec_size.bytes().next_power_of_two()).unwrap(),
))
}
@@ -864,25 +863,32 @@ pub fn restrict_for_offset(self, size: Size) -> Align {
/// It is of effectively no consequence for layout in structs and on the stack.
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
-pub struct AbiAndPrefAlign {
+pub struct AbiAlign {
pub abi: Align,
- pub pref: Align,
}
-impl AbiAndPrefAlign {
+impl AbiAlign {
#[inline]
- pub fn new(align: Align) -> AbiAndPrefAlign {
- AbiAndPrefAlign { abi: align, pref: align }
+ pub fn new(align: Align) -> AbiAlign {
+ AbiAlign { abi: align }
}
#[inline]
- pub fn min(self, other: AbiAndPrefAlign) -> AbiAndPrefAlign {
- AbiAndPrefAlign { abi: self.abi.min(other.abi), pref: self.pref.min(other.pref) }
+ pub fn min(self, other: AbiAlign) -> AbiAlign {
+ AbiAlign { abi: self.abi.min(other.abi) }
}
#[inline]
- pub fn max(self, other: AbiAndPrefAlign) -> AbiAndPrefAlign {
- AbiAndPrefAlign { abi: self.abi.max(other.abi), pref: self.pref.max(other.pref) }
+ pub fn max(self, other: AbiAlign) -> AbiAlign {
+ AbiAlign { abi: self.abi.max(other.abi) }
+ }
+}
+
+impl Deref for AbiAlign {
+ type Target = Align;
+
+ fn deref(&self) -> &Self::Target {
+ &self.abi
}
}
@@ -945,7 +951,7 @@ pub fn from_attr<C: HasDataLayout>(cx: &C, ity: IntegerType) -> Integer {
}
}
- pub fn align<C: HasDataLayout>(self, cx: &C) -> AbiAndPrefAlign {
+ pub fn align<C: HasDataLayout>(self, cx: &C) -> AbiAlign {
use Integer::*;
let dl = cx.data_layout();
@@ -1058,7 +1064,7 @@ pub fn size(self) -> Size {
}
}
- pub fn align<C: HasDataLayout>(self, cx: &C) -> AbiAndPrefAlign {
+ pub fn align<C: HasDataLayout>(self, cx: &C) -> AbiAlign {
use Float::*;
let dl = cx.data_layout();
@@ -1102,7 +1108,7 @@ pub fn size<C: HasDataLayout>(self, cx: &C) -> Size {
}
}
- pub fn align<C: HasDataLayout>(self, cx: &C) -> AbiAndPrefAlign {
+ pub fn align<C: HasDataLayout>(self, cx: &C) -> AbiAlign {
use Primitive::*;
let dl = cx.data_layout();
@@ -1225,7 +1231,7 @@ pub fn primitive(&self) -> Primitive {
}
}
- pub fn align(self, cx: &impl HasDataLayout) -> AbiAndPrefAlign {
+ pub fn align(self, cx: &impl HasDataLayout) -> AbiAlign {
self.primitive().align(cx)
}
@@ -1731,7 +1737,7 @@ pub struct LayoutData<FieldIdx: Idx, VariantIdx: Idx> {
/// especially in the case of by-pointer struct returns, which allocate stack even when unused.
pub uninhabited: bool,
- pub align: AbiAndPrefAlign,
+ pub align: AbiAlign,
pub size: Size,
/// The largest alignment explicitly requested with `repr(align)` on this type or any field.
diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs
index 77cbdde..71a47dc 100644
--- a/compiler/rustc_ast/src/mut_visit.rs
+++ b/compiler/rustc_ast/src/mut_visit.rs
@@ -11,7 +11,7 @@
use std::panic;
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
-use rustc_data_structures::stack::ensure_sufficient_stack;
+use rustc_span::source_map::Spanned;
use rustc_span::{Ident, Span};
use smallvec::{Array, SmallVec, smallvec};
use thin_vec::ThinVec;
@@ -19,7 +19,7 @@
use crate::ast::*;
use crate::ptr::P;
use crate::tokenstream::*;
-use crate::visit::{AssocCtxt, BoundKind, FnCtxt, try_visit, visit_opt, walk_list};
+use crate::visit::{AssocCtxt, BoundKind, FnCtxt, VisitorResult, try_visit, visit_opt, walk_list};
pub trait ExpectOne<A: Array> {
fn expect_one(self, err: &'static str) -> A::Item;
@@ -32,7 +32,22 @@ fn expect_one(self, err: &'static str) -> A::Item {
}
}
-pub trait MutVisitor: Sized {
+mod sealed {
+ use rustc_ast_ir::visit::VisitorResult;
+
+ /// This is for compatibility with the regular `Visitor`.
+ pub trait MutVisitorResult {
+ type Result: VisitorResult;
+ }
+
+ impl<T> MutVisitorResult for T {
+ type Result = ();
+ }
+}
+
+use sealed::MutVisitorResult;
+
+pub trait MutVisitor: Sized + MutVisitorResult<Result = ()> {
// Methods in this trait have one of three forms:
//
// fn visit_t(&mut self, t: &mut T); // common
@@ -227,14 +242,6 @@ fn visit_generic_args(&mut self, p: &mut GenericArgs) {
walk_generic_args(self, p);
}
- fn visit_angle_bracketed_parameter_data(&mut self, p: &mut AngleBracketedArgs) {
- walk_angle_bracketed_parameter_data(self, p);
- }
-
- fn visit_parenthesized_parameter_data(&mut self, p: &mut ParenthesizedArgs) {
- walk_parenthesized_parameter_data(self, p);
- }
-
fn visit_local(&mut self, l: &mut Local) {
walk_local(self, l);
}
@@ -303,10 +310,6 @@ fn visit_expr_field(&mut self, f: &mut ExprField) {
walk_flat_map_expr_field(self, f)
}
- fn visit_where_clause(&mut self, where_clause: &mut WhereClause) {
- walk_where_clause(self, where_clause);
- }
-
fn flat_map_where_predicate(
&mut self,
where_predicate: WherePredicate,
@@ -385,19 +388,14 @@ fn $name<V: MutVisitor>(
visit_generic_params, GenericParam, flat_map_generic_param;
visit_stmts, Stmt, flat_map_stmt;
visit_exprs, P<Expr>, filter_map_expr;
+ visit_expr_fields, ExprField, flat_map_expr_field;
visit_pat_fields, PatField, flat_map_pat_field;
visit_variants, Variant, flat_map_variant;
visit_assoc_items, P<AssocItem>, flat_map_assoc_item, ctxt: AssocCtxt;
-}
-
-#[inline]
-fn visit_vec<T, F>(elems: &mut Vec<T>, mut visit_elem: F)
-where
- F: FnMut(&mut T),
-{
- for elem in elems {
- visit_elem(elem);
- }
+ visit_where_predicates, WherePredicate, flat_map_where_predicate;
+ visit_params, Param, flat_map_param;
+ visit_field_defs, FieldDef, flat_map_field_def;
+ visit_arms, Arm, flat_map_arm;
}
#[inline]
@@ -410,40 +408,12 @@ fn visit_thin_vec<T, F>(elems: &mut ThinVec<T>, mut visit_elem: F)
}
}
-#[inline]
-fn visit_opt<T, F>(opt: &mut Option<T>, mut visit_elem: F)
-where
- F: FnMut(&mut T),
-{
- if let Some(elem) = opt {
- visit_elem(elem);
- }
-}
-
fn visit_attrs<T: MutVisitor>(vis: &mut T, attrs: &mut AttrVec) {
for attr in attrs.iter_mut() {
vis.visit_attribute(attr);
}
}
-fn visit_attr_args<T: MutVisitor>(vis: &mut T, args: &mut AttrArgs) {
- match args {
- AttrArgs::Empty => {}
- AttrArgs::Delimited(args) => visit_delim_args(vis, args),
- AttrArgs::Eq { eq_span, expr } => {
- vis.visit_expr(expr);
- vis.visit_span(eq_span);
- }
- }
-}
-
-fn visit_delim_args<T: MutVisitor>(vis: &mut T, args: &mut DelimArgs) {
- let DelimArgs { dspan, delim: _, tokens: _ } = args;
- let DelimSpan { open, close } = dspan;
- vis.visit_span(open);
- vis.visit_span(close);
-}
-
pub fn walk_flat_map_pat_field<T: MutVisitor>(
vis: &mut T,
mut fp: PatField,
@@ -461,40 +431,11 @@ fn visit_nested_use_tree<V: MutVisitor>(
vis.visit_use_tree(nested_tree);
}
-pub fn walk_arm<T: MutVisitor>(vis: &mut T, arm: &mut Arm) {
- let Arm { attrs, pat, guard, body, span, id, is_placeholder: _ } = arm;
- vis.visit_id(id);
- visit_attrs(vis, attrs);
- vis.visit_pat(pat);
- visit_opt(guard, |guard| vis.visit_expr(guard));
- visit_opt(body, |body| vis.visit_expr(body));
- vis.visit_span(span);
-}
-
pub fn walk_flat_map_arm<T: MutVisitor>(vis: &mut T, mut arm: Arm) -> SmallVec<[Arm; 1]> {
vis.visit_arm(&mut arm);
smallvec![arm]
}
-fn walk_assoc_item_constraint<T: MutVisitor>(
- vis: &mut T,
- AssocItemConstraint { id, ident, gen_args, kind, span }: &mut AssocItemConstraint,
-) {
- vis.visit_id(id);
- vis.visit_ident(ident);
- if let Some(gen_args) = gen_args {
- vis.visit_generic_args(gen_args);
- }
- match kind {
- AssocItemConstraintKind::Equality { term } => match term {
- Term::Ty(ty) => vis.visit_ty(ty),
- Term::Const(c) => vis.visit_anon_const(c),
- },
- AssocItemConstraintKind::Bound { bounds } => visit_bounds(vis, bounds, BoundKind::Bound),
- }
- vis.visit_span(span);
-}
-
pub fn walk_flat_map_variant<T: MutVisitor>(
vis: &mut T,
mut variant: Variant,
@@ -503,64 +444,6 @@ pub fn walk_flat_map_variant<T: MutVisitor>(
smallvec![variant]
}
-fn walk_generic_args<T: MutVisitor>(vis: &mut T, generic_args: &mut GenericArgs) {
- match generic_args {
- GenericArgs::AngleBracketed(data) => vis.visit_angle_bracketed_parameter_data(data),
- GenericArgs::Parenthesized(data) => vis.visit_parenthesized_parameter_data(data),
- GenericArgs::ParenthesizedElided(span) => vis.visit_span(span),
- }
-}
-
-fn walk_generic_arg<T: MutVisitor>(vis: &mut T, arg: &mut GenericArg) {
- match arg {
- GenericArg::Lifetime(lt) => vis.visit_lifetime(lt),
- GenericArg::Type(ty) => vis.visit_ty(ty),
- GenericArg::Const(ct) => vis.visit_anon_const(ct),
- }
-}
-
-fn walk_angle_bracketed_parameter_data<T: MutVisitor>(vis: &mut T, data: &mut AngleBracketedArgs) {
- let AngleBracketedArgs { args, span } = data;
- visit_thin_vec(args, |arg| match arg {
- AngleBracketedArg::Arg(arg) => vis.visit_generic_arg(arg),
- AngleBracketedArg::Constraint(constraint) => vis.visit_assoc_item_constraint(constraint),
- });
- vis.visit_span(span);
-}
-
-fn walk_parenthesized_parameter_data<T: MutVisitor>(vis: &mut T, args: &mut ParenthesizedArgs) {
- let ParenthesizedArgs { inputs, output, span, inputs_span } = args;
- visit_thin_vec(inputs, |input| vis.visit_ty(input));
- vis.visit_fn_ret_ty(output);
- vis.visit_span(span);
- vis.visit_span(inputs_span);
-}
-
-fn walk_attribute<T: MutVisitor>(vis: &mut T, attr: &mut Attribute) {
- let Attribute { kind, id: _, style: _, span } = attr;
- match kind {
- AttrKind::Normal(normal) => {
- let NormalAttr { item: AttrItem { unsafety: _, path, args, tokens: _ }, tokens: _ } =
- &mut **normal;
- vis.visit_path(path);
- visit_attr_args(vis, args);
- }
- AttrKind::DocComment(_kind, _sym) => {}
- }
- vis.visit_span(span);
-}
-
-fn walk_mac<T: MutVisitor>(vis: &mut T, mac: &mut MacCall) {
- let MacCall { path, args } = mac;
- vis.visit_path(path);
- visit_delim_args(vis, args);
-}
-
-fn walk_macro_def<T: MutVisitor>(vis: &mut T, macro_def: &mut MacroDef) {
- let MacroDef { body, macro_rules: _ } = macro_def;
- visit_delim_args(vis, body);
-}
-
fn walk_meta_list_item<T: MutVisitor>(vis: &mut T, li: &mut MetaItemInner) {
match li {
MetaItemInner::MetaItem(mi) => vis.visit_meta_item(mi),
@@ -578,138 +461,11 @@ fn walk_meta_item<T: MutVisitor>(vis: &mut T, mi: &mut MetaItem) {
vis.visit_span(span);
}
-pub fn walk_param<T: MutVisitor>(vis: &mut T, param: &mut Param) {
- let Param { attrs, id, pat, span, ty, is_placeholder: _ } = param;
- vis.visit_id(id);
- visit_attrs(vis, attrs);
- vis.visit_pat(pat);
- vis.visit_ty(ty);
- vis.visit_span(span);
-}
-
pub fn walk_flat_map_param<T: MutVisitor>(vis: &mut T, mut param: Param) -> SmallVec<[Param; 1]> {
vis.visit_param(&mut param);
smallvec![param]
}
-fn walk_closure_binder<T: MutVisitor>(vis: &mut T, binder: &mut ClosureBinder) {
- match binder {
- ClosureBinder::NotPresent => {}
- ClosureBinder::For { span: _, generic_params } => {
- generic_params.flat_map_in_place(|param| vis.flat_map_generic_param(param));
- }
- }
-}
-
-fn walk_fn<T: MutVisitor>(vis: &mut T, kind: FnKind<'_>) {
- match kind {
- FnKind::Fn(
- _ctxt,
- _vis,
- Fn {
- defaultness,
- ident,
- generics,
- contract,
- body,
- sig: FnSig { header, decl, span },
- define_opaque,
- },
- ) => {
- // Visibility is visited as a part of the item.
- visit_defaultness(vis, defaultness);
- vis.visit_ident(ident);
- vis.visit_fn_header(header);
- vis.visit_generics(generics);
- vis.visit_fn_decl(decl);
- if let Some(contract) = contract {
- vis.visit_contract(contract);
- }
- if let Some(body) = body {
- vis.visit_block(body);
- }
- vis.visit_span(span);
-
- walk_define_opaques(vis, define_opaque);
- }
- FnKind::Closure(binder, coroutine_kind, decl, body) => {
- vis.visit_closure_binder(binder);
- coroutine_kind.as_mut().map(|coroutine_kind| vis.visit_coroutine_kind(coroutine_kind));
- vis.visit_fn_decl(decl);
- vis.visit_expr(body);
- }
- }
-}
-
-fn walk_contract<T: MutVisitor>(vis: &mut T, contract: &mut FnContract) {
- let FnContract { requires, ensures } = contract;
- if let Some(pred) = requires {
- vis.visit_expr(pred);
- }
- if let Some(pred) = ensures {
- vis.visit_expr(pred);
- }
-}
-
-fn walk_fn_decl<T: MutVisitor>(vis: &mut T, decl: &mut FnDecl) {
- let FnDecl { inputs, output } = decl;
- inputs.flat_map_in_place(|param| vis.flat_map_param(param));
- vis.visit_fn_ret_ty(output);
-}
-
-fn walk_fn_ret_ty<T: MutVisitor>(vis: &mut T, fn_ret_ty: &mut FnRetTy) {
- match fn_ret_ty {
- FnRetTy::Default(span) => vis.visit_span(span),
- FnRetTy::Ty(ty) => vis.visit_ty(ty),
- }
-}
-
-fn walk_param_bound<T: MutVisitor>(vis: &mut T, pb: &mut GenericBound) {
- match pb {
- GenericBound::Trait(trait_ref) => vis.visit_poly_trait_ref(trait_ref),
- GenericBound::Outlives(lifetime) => walk_lifetime(vis, lifetime),
- GenericBound::Use(args, span) => {
- for arg in args {
- vis.visit_precise_capturing_arg(arg);
- }
- vis.visit_span(span);
- }
- }
-}
-
-fn walk_precise_capturing_arg<T: MutVisitor>(vis: &mut T, arg: &mut PreciseCapturingArg) {
- match arg {
- PreciseCapturingArg::Lifetime(lt) => {
- vis.visit_lifetime(lt);
- }
- PreciseCapturingArg::Arg(path, id) => {
- vis.visit_id(id);
- vis.visit_path(path);
- }
- }
-}
-
-pub fn walk_generic_param<T: MutVisitor>(vis: &mut T, param: &mut GenericParam) {
- let GenericParam { id, ident, attrs, bounds, kind, colon_span, is_placeholder: _ } = param;
- vis.visit_id(id);
- visit_attrs(vis, attrs);
- vis.visit_ident(ident);
- visit_vec(bounds, |bound| vis.visit_param_bound(bound, BoundKind::Bound));
- match kind {
- GenericParamKind::Lifetime => {}
- GenericParamKind::Type { default } => {
- visit_opt(default, |default| vis.visit_ty(default));
- }
- GenericParamKind::Const { ty, kw_span: _, default } => {
- vis.visit_ty(ty);
- visit_opt(default, |default| vis.visit_anon_const(default));
- }
- }
- if let Some(colon_span) = colon_span {
- vis.visit_span(colon_span);
- }
-}
-
pub fn walk_flat_map_generic_param<T: MutVisitor>(
vis: &mut T,
mut param: GenericParam,
@@ -718,13 +474,6 @@ pub fn walk_flat_map_generic_param<T: MutVisitor>(
smallvec![param]
}
-fn walk_generics<T: MutVisitor>(vis: &mut T, generics: &mut Generics) {
- let Generics { params, where_clause, span } = generics;
- params.flat_map_in_place(|param| vis.flat_map_generic_param(param));
- vis.visit_where_clause(where_clause);
- vis.visit_span(span);
-}
-
fn walk_ty_alias_where_clauses<T: MutVisitor>(vis: &mut T, tawcs: &mut TyAliasWhereClauses) {
let TyAliasWhereClauses { before, after, split: _ } = tawcs;
let TyAliasWhereClause { has_where_token: _, span: span_before } = before;
@@ -733,70 +482,14 @@ fn walk_ty_alias_where_clauses<T: MutVisitor>(vis: &mut T, tawcs: &mut TyAliasWh
vis.visit_span(span_after);
}
-fn walk_where_clause<T: MutVisitor>(vis: &mut T, wc: &mut WhereClause) {
- let WhereClause { has_where_token: _, predicates, span } = wc;
- predicates.flat_map_in_place(|predicate| vis.flat_map_where_predicate(predicate));
- vis.visit_span(span);
-}
-
pub fn walk_flat_map_where_predicate<T: MutVisitor>(
vis: &mut T,
mut pred: WherePredicate,
) -> SmallVec<[WherePredicate; 1]> {
- let WherePredicate { attrs, kind, id, span, is_placeholder: _ } = &mut pred;
- vis.visit_id(id);
- visit_attrs(vis, attrs);
- vis.visit_where_predicate_kind(kind);
- vis.visit_span(span);
+ walk_where_predicate(vis, &mut pred);
smallvec![pred]
}
-pub fn walk_where_predicate_kind<T: MutVisitor>(vis: &mut T, kind: &mut WherePredicateKind) {
- match kind {
- WherePredicateKind::BoundPredicate(bp) => {
- let WhereBoundPredicate { bound_generic_params, bounded_ty, bounds } = bp;
- bound_generic_params.flat_map_in_place(|param| vis.flat_map_generic_param(param));
- vis.visit_ty(bounded_ty);
- visit_vec(bounds, |bound| vis.visit_param_bound(bound, BoundKind::Bound));
- }
- WherePredicateKind::RegionPredicate(rp) => {
- let WhereRegionPredicate { lifetime, bounds } = rp;
- vis.visit_lifetime(lifetime);
- visit_vec(bounds, |bound| vis.visit_param_bound(bound, BoundKind::Bound));
- }
- WherePredicateKind::EqPredicate(ep) => {
- let WhereEqPredicate { lhs_ty, rhs_ty } = ep;
- vis.visit_ty(lhs_ty);
- vis.visit_ty(rhs_ty);
- }
- }
-}
-
-fn walk_variant_data<T: MutVisitor>(vis: &mut T, vdata: &mut VariantData) {
- match vdata {
- VariantData::Struct { fields, recovered: _ } => {
- fields.flat_map_in_place(|field| vis.flat_map_field_def(field));
- }
- VariantData::Tuple(fields, id) => {
- vis.visit_id(id);
- fields.flat_map_in_place(|field| vis.flat_map_field_def(field));
- }
- VariantData::Unit(id) => vis.visit_id(id),
- }
-}
-
-pub fn walk_field_def<T: MutVisitor>(visitor: &mut T, fd: &mut FieldDef) {
- let FieldDef { span, ident, vis, id, ty, attrs, is_placeholder: _, safety, default } = fd;
- visitor.visit_id(id);
- visit_attrs(visitor, attrs);
- visitor.visit_vis(vis);
- visit_safety(visitor, safety);
- visit_opt(ident, |ident| visitor.visit_ident(ident));
- visitor.visit_ty(ty);
- visit_opt(default, |default| visitor.visit_anon_const(default));
- visitor.visit_span(span);
-}
-
pub fn walk_flat_map_field_def<T: MutVisitor>(
vis: &mut T,
mut fd: FieldDef,
@@ -846,255 +539,6 @@ pub fn walk_flat_map_assoc_item(
smallvec![item]
}
-fn walk_inline_asm<T: MutVisitor>(vis: &mut T, asm: &mut InlineAsm) {
- // FIXME: Visit spans inside all this currently ignored stuff.
- let InlineAsm {
- asm_macro: _,
- template: _,
- template_strs: _,
- operands,
- clobber_abis: _,
- options: _,
- line_spans: _,
- } = asm;
- for (op, span) in operands {
- match op {
- InlineAsmOperand::In { expr, reg: _ }
- | InlineAsmOperand::Out { expr: Some(expr), reg: _, late: _ }
- | InlineAsmOperand::InOut { expr, reg: _, late: _ } => vis.visit_expr(expr),
- InlineAsmOperand::Out { expr: None, reg: _, late: _ } => {}
- InlineAsmOperand::SplitInOut { in_expr, out_expr, reg: _, late: _ } => {
- vis.visit_expr(in_expr);
- if let Some(out_expr) = out_expr {
- vis.visit_expr(out_expr);
- }
- }
- InlineAsmOperand::Const { anon_const } => vis.visit_anon_const(anon_const),
- InlineAsmOperand::Sym { sym } => vis.visit_inline_asm_sym(sym),
- InlineAsmOperand::Label { block } => vis.visit_block(block),
- }
- vis.visit_span(span);
- }
-}
-
-fn walk_inline_asm_sym<T: MutVisitor>(
- vis: &mut T,
- InlineAsmSym { id, qself, path }: &mut InlineAsmSym,
-) {
- vis.visit_id(id);
- vis.visit_qself(qself);
- vis.visit_path(path);
-}
-
-fn walk_format_args<T: MutVisitor>(vis: &mut T, fmt: &mut FormatArgs) {
- // FIXME: visit the template exhaustively.
- let FormatArgs { span, template: _, arguments, uncooked_fmt_str: _ } = fmt;
- for FormatArgument { kind, expr } in arguments.all_args_mut() {
- match kind {
- FormatArgumentKind::Named(ident) | FormatArgumentKind::Captured(ident) => {
- vis.visit_ident(ident)
- }
- FormatArgumentKind::Normal => {}
- }
- vis.visit_expr(expr);
- }
- vis.visit_span(span);
-}
-
-pub fn walk_expr<T: MutVisitor>(vis: &mut T, Expr { kind, id, span, attrs, tokens: _ }: &mut Expr) {
- vis.visit_id(id);
- visit_attrs(vis, attrs);
- match kind {
- ExprKind::Array(exprs) => visit_exprs(vis, exprs),
- ExprKind::ConstBlock(anon_const) => {
- vis.visit_anon_const(anon_const);
- }
- ExprKind::Repeat(expr, count) => {
- vis.visit_expr(expr);
- vis.visit_anon_const(count);
- }
- ExprKind::Tup(exprs) => visit_exprs(vis, exprs),
- ExprKind::Call(f, args) => {
- vis.visit_expr(f);
- visit_exprs(vis, args);
- }
- ExprKind::MethodCall(box MethodCall {
- seg: PathSegment { ident, id, args: seg_args },
- receiver,
- args: call_args,
- span,
- }) => {
- vis.visit_method_receiver_expr(receiver);
- vis.visit_id(id);
- vis.visit_ident(ident);
- visit_opt(seg_args, |args| vis.visit_generic_args(args));
- visit_exprs(vis, call_args);
- vis.visit_span(span);
- }
- ExprKind::Binary(binop, lhs, rhs) => {
- vis.visit_expr(lhs);
- vis.visit_expr(rhs);
- vis.visit_span(&mut binop.span);
- }
- ExprKind::Unary(_unop, ohs) => vis.visit_expr(ohs),
- ExprKind::Cast(expr, ty) => {
- vis.visit_expr(expr);
- vis.visit_ty(ty);
- }
- ExprKind::Type(expr, ty) => {
- vis.visit_expr(expr);
- vis.visit_ty(ty);
- }
- ExprKind::AddrOf(_kind, _mut, ohs) => vis.visit_expr(ohs),
- ExprKind::Let(pat, scrutinee, span, _recovered) => {
- vis.visit_pat(pat);
- vis.visit_expr(scrutinee);
- vis.visit_span(span);
- }
- ExprKind::If(cond, tr, fl) => {
- vis.visit_expr(cond);
- vis.visit_block(tr);
- visit_opt(fl, |fl| ensure_sufficient_stack(|| vis.visit_expr(fl)));
- }
- ExprKind::While(cond, body, label) => {
- visit_opt(label, |label| vis.visit_label(label));
- vis.visit_expr(cond);
- vis.visit_block(body);
- }
- ExprKind::ForLoop { pat, iter, body, label, kind: _ } => {
- visit_opt(label, |label| vis.visit_label(label));
- vis.visit_pat(pat);
- vis.visit_expr(iter);
- vis.visit_block(body);
- }
- ExprKind::Loop(body, label, span) => {
- visit_opt(label, |label| vis.visit_label(label));
- vis.visit_block(body);
- vis.visit_span(span);
- }
- ExprKind::Match(expr, arms, _kind) => {
- vis.visit_expr(expr);
- arms.flat_map_in_place(|arm| vis.flat_map_arm(arm));
- }
- ExprKind::Closure(box Closure {
- binder,
- capture_clause,
- constness,
- coroutine_kind,
- movability: _,
- fn_decl,
- body,
- fn_decl_span,
- fn_arg_span,
- }) => {
- visit_constness(vis, constness);
- vis.visit_capture_by(capture_clause);
- vis.visit_fn(FnKind::Closure(binder, coroutine_kind, fn_decl, body), *span, *id);
- vis.visit_span(fn_decl_span);
- vis.visit_span(fn_arg_span);
- }
- ExprKind::Block(blk, label) => {
- visit_opt(label, |label| vis.visit_label(label));
- vis.visit_block(blk);
- }
- ExprKind::Gen(_capture_by, body, _kind, decl_span) => {
- vis.visit_block(body);
- vis.visit_span(decl_span);
- }
- ExprKind::Await(expr, await_kw_span) => {
- vis.visit_expr(expr);
- vis.visit_span(await_kw_span);
- }
- ExprKind::Use(expr, use_kw_span) => {
- vis.visit_expr(expr);
- vis.visit_span(use_kw_span);
- }
- ExprKind::Assign(el, er, span) => {
- vis.visit_expr(el);
- vis.visit_expr(er);
- vis.visit_span(span);
- }
- ExprKind::AssignOp(_op, el, er) => {
- vis.visit_expr(el);
- vis.visit_expr(er);
- }
- ExprKind::Field(el, ident) => {
- vis.visit_expr(el);
- vis.visit_ident(ident);
- }
- ExprKind::Index(el, er, brackets_span) => {
- vis.visit_expr(el);
- vis.visit_expr(er);
- vis.visit_span(brackets_span);
- }
- ExprKind::Range(e1, e2, _lim) => {
- visit_opt(e1, |e1| vis.visit_expr(e1));
- visit_opt(e2, |e2| vis.visit_expr(e2));
- }
- ExprKind::Underscore => {}
- ExprKind::Path(qself, path) => {
- vis.visit_qself(qself);
- vis.visit_path(path);
- }
- ExprKind::Break(label, expr) => {
- visit_opt(label, |label| vis.visit_label(label));
- visit_opt(expr, |expr| vis.visit_expr(expr));
- }
- ExprKind::Continue(label) => {
- visit_opt(label, |label| vis.visit_label(label));
- }
- ExprKind::Ret(expr) => {
- visit_opt(expr, |expr| vis.visit_expr(expr));
- }
- ExprKind::Yeet(expr) => {
- visit_opt(expr, |expr| vis.visit_expr(expr));
- }
- ExprKind::Become(expr) => vis.visit_expr(expr),
- ExprKind::InlineAsm(asm) => vis.visit_inline_asm(asm),
- ExprKind::FormatArgs(fmt) => vis.visit_format_args(fmt),
- ExprKind::OffsetOf(container, fields) => {
- vis.visit_ty(container);
- for field in fields.iter_mut() {
- vis.visit_ident(field);
- }
- }
- ExprKind::MacCall(mac) => vis.visit_mac_call(mac),
- ExprKind::Struct(se) => {
- let StructExpr { qself, path, fields, rest } = se.deref_mut();
- vis.visit_qself(qself);
- vis.visit_path(path);
- fields.flat_map_in_place(|field| vis.flat_map_expr_field(field));
- match rest {
- StructRest::Base(expr) => vis.visit_expr(expr),
- StructRest::Rest(_span) => {}
- StructRest::None => {}
- }
- }
- ExprKind::Paren(expr) => {
- vis.visit_expr(expr);
- }
- ExprKind::Yield(kind) => {
- let expr = kind.expr_mut();
- if let Some(expr) = expr {
- vis.visit_expr(expr);
- }
- }
- ExprKind::Try(expr) => vis.visit_expr(expr),
- ExprKind::TryBlock(body) => vis.visit_block(body),
- ExprKind::Lit(_token) => {}
- ExprKind::IncludedBytes(_bytes) => {}
- ExprKind::UnsafeBinderCast(_kind, expr, ty) => {
- vis.visit_expr(expr);
- if let Some(ty) = ty {
- vis.visit_ty(ty);
- }
- }
- ExprKind::Err(_guar) => {}
- ExprKind::Dummy => {}
- }
- vis.visit_span(span);
-}
-
pub fn walk_filter_map_expr<T: MutVisitor>(vis: &mut T, mut e: P<Expr>) -> Option<P<Expr>> {
vis.visit_expr(&mut e);
Some(e)
@@ -1139,18 +583,6 @@ pub fn walk_flat_map_stmt<T: MutVisitor>(
}
}
-fn walk_vis<T: MutVisitor>(vis: &mut T, visibility: &mut Visibility) {
- let Visibility { kind, span, tokens: _ } = visibility;
- match kind {
- VisibilityKind::Public | VisibilityKind::Inherited => {}
- VisibilityKind::Restricted { path, id, shorthand: _ } => {
- vis.visit_id(id);
- vis.visit_path(path);
- }
- }
- vis.visit_span(span);
-}
-
fn walk_capture_by<T: MutVisitor>(vis: &mut T, capture_by: &mut CaptureBy) {
match capture_by {
CaptureBy::Ref => {}
diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs
index d2f22b0..c88aa5c 100644
--- a/compiler/rustc_ast/src/visit.rs
+++ b/compiler/rustc_ast/src/visit.rs
@@ -15,11 +15,13 @@
pub use rustc_ast_ir::visit::VisitorResult;
pub use rustc_ast_ir::{try_visit, visit_opt, walk_list, walk_visitable_list};
+use rustc_span::source_map::Spanned;
use rustc_span::{Ident, Span};
use thin_vec::ThinVec;
use crate::ast::*;
use crate::ptr::P;
+use crate::tokenstream::DelimSpan;
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum AssocCtxt {
@@ -237,8 +239,8 @@ fn visit_mac_call(&mut self, mac: &'ast MacCall) -> Self::Result {
fn visit_id(&mut self, _id: NodeId) -> Self::Result {
Self::Result::output()
}
- fn visit_macro_def(&mut self, _mac: &'ast MacroDef) -> Self::Result {
- Self::Result::output()
+ fn visit_macro_def(&mut self, macro_def: &'ast MacroDef) -> Self::Result {
+ walk_macro_def(self, macro_def)
}
fn visit_path(&mut self, path: &'ast Path) -> Self::Result {
walk_path(self, path)
@@ -320,8 +322,8 @@ fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
id: NodeId,
visibility: &$($lt)? $($mut)? Visibility,
ctxt: Self::Ctxt,
- visitor: &mut V,
- ) $(-> <V as Visitor<$lt>>::Result)?;
+ vis: &mut V,
+ ) -> V::Result;
}
// this is only used by the MutVisitor. We include this symmetry here to make writing other functions easier
@@ -329,12 +331,12 @@ fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
#[expect(unused, rustc::pass_by_value)]
#[inline]
)?
- fn visit_span<$($lt,)? V: $Visitor$(<$lt>)?>(visitor: &mut V, span: &$($lt)? $($mut)? Span) $(-> <V as Visitor<$lt>>::Result)? {
+ fn visit_span<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, span: &$($lt)? $($mut)? Span) -> V::Result {
$(
${ignore($mut)}
- visitor.visit_span(span);
+ vis.visit_span(span);
)?
- $(${ignore($lt)}V::Result::output())?
+ V::Result::output()
}
/// helper since `Visitor` wants `NodeId` but `MutVisitor` wants `&mut NodeId`
@@ -342,34 +344,34 @@ fn visit_span<$($lt,)? V: $Visitor$(<$lt>)?>(visitor: &mut V, span: &$($lt)? $($
#[expect(rustc::pass_by_value)]
)?
#[inline]
- fn visit_id<$($lt,)? V: $Visitor$(<$lt>)?>(visitor: &mut V, id: &$($lt)? $($mut)? NodeId) $(-> <V as Visitor<$lt>>::Result)? {
+ fn visit_id<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, id: &$($lt)? $($mut)? NodeId) -> V::Result {
// deref `&NodeId` into `NodeId` only for `Visitor`
- visitor.visit_id( $(${ignore($lt)} * )? id)
+ vis.visit_id( $(${ignore($lt)} * )? id)
}
// this is only used by the MutVisitor. We include this symmetry here to make writing other functions easier
- fn visit_safety<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, safety: &$($lt)? $($mut)? Safety) $(-> <V as Visitor<$lt>>::Result)? {
+ fn visit_safety<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, safety: &$($lt)? $($mut)? Safety) -> V::Result {
match safety {
Safety::Unsafe(span) => visit_span(vis, span),
Safety::Safe(span) => visit_span(vis, span),
- Safety::Default => { $(${ignore($lt)}V::Result::output())? }
+ Safety::Default => { V::Result::output() }
}
}
- fn visit_constness<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, constness: &$($lt)? $($mut)? Const) $(-> <V as Visitor<$lt>>::Result)? {
+ fn visit_constness<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, constness: &$($lt)? $($mut)? Const) -> V::Result {
match constness {
Const::Yes(span) => visit_span(vis, span),
Const::No => {
- $(<V as Visitor<$lt>>::Result::output())?
+ V::Result::output()
}
}
}
- fn visit_defaultness<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, defaultness: &$($lt)? $($mut)? Defaultness) $(-> <V as Visitor<$lt>>::Result)? {
+ fn visit_defaultness<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, defaultness: &$($lt)? $($mut)? Defaultness) -> V::Result {
match defaultness {
Defaultness::Default(span) => visit_span(vis, span),
Defaultness::Final => {
- $(<V as Visitor<$lt>>::Result::output())?
+ V::Result::output()
}
}
}
@@ -377,9 +379,9 @@ fn visit_defaultness<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, defaultness: &$
fn visit_polarity<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V,
polarity: &$($lt)? $($mut)? ImplPolarity,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
match polarity {
- ImplPolarity::Positive => { $(<V as Visitor<$lt>>::Result::output())? }
+ ImplPolarity::Positive => { V::Result::output() }
ImplPolarity::Negative(span) => visit_span(vis, span),
}
}
@@ -390,7 +392,7 @@ fn visit_polarity<$($lt,)? V: $Visitor$(<$lt>)?>(
fn visit_modifiers<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V,
m: &$($lt)? $($mut)? TraitBoundModifiers
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
let TraitBoundModifiers { constness, asyncness, polarity } = m;
match constness {
BoundConstness::Never => {}
@@ -404,26 +406,26 @@ fn visit_modifiers<$($lt,)? V: $Visitor$(<$lt>)?>(
BoundPolarity::Positive => {}
BoundPolarity::Negative(span) | BoundPolarity::Maybe(span) => try_visit!(visit_span(vis, span)),
}
- $(<V as Visitor<$lt>>::Result::output())?
+ V::Result::output()
}
- fn visit_bounds<$($lt,)? V: $Visitor$(<$lt>)?>(visitor: &mut V, bounds: &$($lt)? $($mut)? GenericBounds, ctxt: BoundKind) $(-> <V as Visitor<$lt>>::Result)? {
+ fn visit_bounds<$($lt,)? V: $Visitor$(<$lt>)?>(visitor: &mut V, bounds: &$($lt)? $($mut)? GenericBounds, ctxt: BoundKind) -> V::Result {
walk_list!(visitor, visit_param_bound, bounds, ctxt);
- $(<V as Visitor<$lt>>::Result::output())?
+ V::Result::output()
}
- pub fn walk_label<$($lt,)? V: $Visitor$(<$lt>)?>(visitor: &mut V, Label { ident }: &$($lt)? $($mut)? Label) $(-> <V as Visitor<$lt>>::Result)? {
+ pub fn walk_label<$($lt,)? V: $Visitor$(<$lt>)?>(visitor: &mut V, Label { ident }: &$($lt)? $($mut)? Label) -> V::Result {
visitor.visit_ident(ident)
}
- pub fn walk_fn_header<$($lt,)? V: $Visitor$(<$lt>)?>(visitor: &mut V, header: &$($lt)? $($mut)? FnHeader) $(-> <V as Visitor<$lt>>::Result)? {
+ pub fn walk_fn_header<$($lt,)? V: $Visitor$(<$lt>)?>(visitor: &mut V, header: &$($lt)? $($mut)? FnHeader) -> V::Result {
let FnHeader { safety, coroutine_kind, constness, ext: _ } = header;
try_visit!(visit_constness(visitor, constness));
visit_opt!(visitor, visit_coroutine_kind, coroutine_kind);
visit_safety(visitor, safety)
}
- pub fn walk_lifetime<$($lt,)? V: $Visitor$(<$lt>)?>(visitor: &mut V, Lifetime { id, ident }: &$($lt)? $($mut)? Lifetime) $(-> <V as Visitor<$lt>>::Result)? {
+ pub fn walk_lifetime<$($lt,)? V: $Visitor$(<$lt>)?>(visitor: &mut V, Lifetime { id, ident }: &$($lt)? $($mut)? Lifetime) -> V::Result {
try_visit!(visit_id(visitor, id));
visitor.visit_ident(ident)
}
@@ -432,7 +434,7 @@ fn walk_item_ctxt<$($lt,)? V: $Visitor$(<$lt>)?, K: WalkItemKind>(
visitor: &mut V,
item: &$($mut)? $($lt)? Item<K>,
ctxt: K::Ctxt,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
let Item { attrs, id, kind, vis, span, tokens: _ } = item;
try_visit!(visit_id(visitor, id));
walk_list!(visitor, visit_attribute, attrs);
@@ -444,7 +446,7 @@ fn walk_item_ctxt<$($lt,)? V: $Visitor$(<$lt>)?, K: WalkItemKind>(
pub fn walk_item<$($lt,)? V: $Visitor$(<$lt>)?, K: WalkItemKind<Ctxt = ()>>(
visitor: &mut V,
item: &$($mut)? $($lt)? Item<K>,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
walk_item_ctxt(visitor, item, ())
}
@@ -452,7 +454,7 @@ pub fn walk_assoc_item<$($lt,)? V: $Visitor$(<$lt>)?>(
visitor: &mut V,
item: &$($mut)? $($lt)? AssocItem,
ctxt: AssocCtxt,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
walk_item_ctxt(visitor, item, ctxt)
}
@@ -465,7 +467,7 @@ fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
visibility: &$($lt)? $($mut)? Visibility,
_ctxt: Self::Ctxt,
vis: &mut V,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
match self {
ItemKind::ExternCrate(_orig_name, ident) => vis.visit_ident(ident),
ItemKind::Use(use_tree) => vis.visit_use_tree(use_tree),
@@ -505,7 +507,7 @@ fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
}
ModKind::Unloaded => {}
}
- $(<V as Visitor<$lt>>::Result::output())?
+ V::Result::output()
}
ItemKind::ForeignMod(nm) => vis.visit_foreign_mod(nm),
ItemKind::GlobalAsm(asm) => vis.visit_inline_asm(asm),
@@ -526,7 +528,7 @@ fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
$(${ignore($mut)}
walk_ty_alias_where_clauses(vis, where_clauses);
)?
- $(<V as Visitor<$lt>>::Result::output())?
+ V::Result::output()
}
ItemKind::Enum(ident, generics, enum_definition) => {
try_visit!(vis.visit_ident(ident));
@@ -590,7 +592,7 @@ fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
try_visit!(vis.visit_ident(ident));
visit_opt!(vis, visit_ident, rename);
visit_opt!(vis, visit_block, body);
- $(<V as Visitor<$lt>>::Result::output())?
+ V::Result::output()
}
ItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
try_visit!(vis.visit_qself(qself));
@@ -602,7 +604,7 @@ fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
}
}
visit_opt!(vis, visit_block, body);
- $(<V as Visitor<$lt>>::Result::output())?
+ V::Result::output()
}
}
}
@@ -611,7 +613,7 @@ fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
fn walk_const_item<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V,
item: &$($lt)? $($mut)? ConstItem,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
let ConstItem { defaultness, ident, generics, ty, expr, define_opaque } = item;
try_visit!(visit_defaultness(vis, defaultness));
try_visit!(vis.visit_ident(ident));
@@ -621,7 +623,7 @@ fn walk_const_item<$($lt,)? V: $Visitor$(<$lt>)?>(
walk_define_opaques(vis, define_opaque)
}
- fn walk_foreign_mod<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, foreign_mod: &$($lt)? $($mut)? ForeignMod) $(-> <V as Visitor<$lt>>::Result)? {
+ fn walk_foreign_mod<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, foreign_mod: &$($lt)? $($mut)? ForeignMod) -> V::Result {
let ForeignMod { extern_span: _, safety, abi: _, items } = foreign_mod;
try_visit!(visit_safety(vis, safety));
visit_foreign_items(vis, items)
@@ -630,14 +632,14 @@ fn walk_foreign_mod<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, foreign_mod: &$(
fn walk_define_opaques<$($lt,)? V: $Visitor$(<$lt>)?>(
visitor: &mut V,
define_opaque: &$($lt)? $($mut)? Option<ThinVec<(NodeId, Path)>>,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
if let Some(define_opaque) = define_opaque {
for (id, path) in define_opaque {
try_visit!(visit_id(visitor, id));
try_visit!(visitor.visit_path(path));
}
}
- $(<V as Visitor<$lt>>::Result::output())?
+ V::Result::output()
}
impl WalkItemKind for AssocItemKind {
@@ -649,7 +651,7 @@ fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
visibility: &$($lt)? $($mut)? Visibility,
ctxt: Self::Ctxt,
vis: &mut V,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
match self {
AssocItemKind::Const(item) => {
walk_const_item(vis, item)
@@ -674,7 +676,7 @@ fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
$(${ignore($mut)}
walk_ty_alias_where_clauses(vis, where_clauses);
)?
- $(<V as Visitor<$lt>>::Result::output())?
+ V::Result::output()
}
AssocItemKind::MacCall(mac) => {
vis.visit_mac_call(mac)
@@ -694,7 +696,7 @@ fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
try_visit!(vis.visit_ident(ident));
visit_opt!(vis, visit_ident, rename);
visit_opt!(vis, visit_block, body);
- $(<V as Visitor<$lt>>::Result::output())?
+ V::Result::output()
}
AssocItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
try_visit!(vis.visit_qself(qself));
@@ -706,7 +708,7 @@ fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
}
}
visit_opt!(vis, visit_block, body);
- $(<V as Visitor<$lt>>::Result::output())?
+ V::Result::output()
}
}
}
@@ -721,7 +723,7 @@ fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
visibility: &$($lt)? $($mut)? Visibility,
_ctxt: Self::Ctxt,
vis: &mut V,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
match self {
ForeignItemKind::Static(box StaticItem {
ident,
@@ -756,7 +758,7 @@ fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
$(${ignore($mut)}
walk_ty_alias_where_clauses(vis, where_clauses);
)?
- $(<V as Visitor<$lt>>::Result::output())?
+ V::Result::output()
}
ForeignItemKind::MacCall(mac) => {
vis.visit_mac_call(mac)
@@ -768,7 +770,7 @@ fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
fn walk_coroutine_kind<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V,
coroutine_kind: &$($lt)? $($mut)? CoroutineKind,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
let (CoroutineKind::Async { span, closure_id, return_impl_trait_id }
| CoroutineKind::Gen { span, closure_id, return_impl_trait_id }
| CoroutineKind::AsyncGen { span, closure_id, return_impl_trait_id })
@@ -781,7 +783,7 @@ fn walk_coroutine_kind<$($lt,)? V: $Visitor$(<$lt>)?>(
pub fn walk_pat<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V,
pattern: &$($lt)? $($mut)? Pat
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
let Pat { id, kind, span, tokens: _ } = pattern;
try_visit!(visit_id(vis, id));
match kind {
@@ -832,7 +834,7 @@ pub fn walk_pat<$($lt,)? V: $Visitor$(<$lt>)?>(
pub fn walk_anon_const<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V,
constant: &$($lt)? $($mut)? AnonConst,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
let AnonConst { id, value } = constant;
try_visit!(visit_id(vis, id));
vis.visit_expr(value)
@@ -841,18 +843,18 @@ pub fn walk_anon_const<$($lt,)? V: $Visitor$(<$lt>)?>(
pub fn walk_path_segment<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V,
segment: &$($lt)? $($mut)? PathSegment,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
let PathSegment { ident, id, args } = segment;
try_visit!(visit_id(vis, id));
try_visit!(vis.visit_ident(ident));
visit_opt!(vis, visit_generic_args, args);
- $(<V as Visitor<$lt>>::Result::output())?
+ V::Result::output()
}
pub fn walk_block<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V,
block: &$($lt)? $($mut)? Block
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
let Block { stmts, id, rules: _, span, tokens: _ } = block;
try_visit!(visit_id(vis, id));
try_visit!(visit_stmts(vis, stmts));
@@ -862,7 +864,7 @@ pub fn walk_block<$($lt,)? V: $Visitor$(<$lt>)?>(
pub fn walk_ty<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V, ty: &$($lt)? $($mut)? Ty
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
let Ty { id, kind, span, tokens: _ } = ty;
try_visit!(visit_id(vis, id));
match kind {
@@ -920,7 +922,7 @@ pub fn walk_ty<$($lt,)? V: $Visitor$(<$lt>)?>(
pub fn walk_crate<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V,
krate: &$($lt)? $($mut)? Crate,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
let Crate { attrs, items, spans, id, is_placeholder: _ } = krate;
try_visit!(visit_id(vis, id));
walk_list!(vis, visit_attribute, attrs);
@@ -933,7 +935,7 @@ pub fn walk_crate<$($lt,)? V: $Visitor$(<$lt>)?>(
pub fn walk_local<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V,
local: &$($lt)? $($mut)? Local,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
let Local { id, super_, pat, ty, kind, span, colon_sp, attrs, tokens: _ } = local;
if let Some(sp) = super_ {
try_visit!(visit_span(vis, sp));
@@ -961,7 +963,7 @@ pub fn walk_local<$($lt,)? V: $Visitor$(<$lt>)?>(
pub fn walk_poly_trait_ref<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V,
p: &$($lt)? $($mut)? PolyTraitRef,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
let PolyTraitRef { bound_generic_params, modifiers, trait_ref, span } = p;
try_visit!(visit_modifiers(vis, modifiers));
try_visit!(visit_generic_params(vis, bound_generic_params));
@@ -972,7 +974,7 @@ pub fn walk_poly_trait_ref<$($lt,)? V: $Visitor$(<$lt>)?>(
pub fn walk_trait_ref<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V,
TraitRef { path, ref_id }: &$($lt)? $($mut)? TraitRef,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
try_visit!(vis.visit_path(path));
visit_id(vis, ref_id)
}
@@ -980,7 +982,7 @@ pub fn walk_trait_ref<$($lt,)? V: $Visitor$(<$lt>)?>(
pub fn walk_variant<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V,
variant: &$($lt)? $($mut)? Variant,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
let Variant { attrs, id, span, vis: visibility, ident, data, disr_expr, is_placeholder: _ } = variant;
try_visit!(visit_id(vis, id));
walk_list!(vis, visit_attribute, attrs);
@@ -995,7 +997,7 @@ pub fn walk_variant<$($lt,)? V: $Visitor$(<$lt>)?>(
pub fn walk_expr_field<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V,
f: &$($lt)? $($mut)? ExprField,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
let ExprField { attrs, id, span, ident, expr, is_shorthand: _, is_placeholder: _ } = f;
try_visit!(visit_id(vis, id));
walk_list!(vis, visit_attribute, attrs);
@@ -1007,7 +1009,7 @@ pub fn walk_expr_field<$($lt,)? V: $Visitor$(<$lt>)?>(
pub fn walk_pat_field<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V,
fp: &$($lt)? $($mut)? PatField,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
let PatField { ident, pat, is_shorthand: _, attrs, id, span, is_placeholder: _ } = fp;
try_visit!(visit_id(vis, id));
walk_list!(vis, visit_attribute, attrs);
@@ -1019,7 +1021,7 @@ pub fn walk_pat_field<$($lt,)? V: $Visitor$(<$lt>)?>(
pub fn walk_ty_pat<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V,
tp: &$($lt)? $($mut)? TyPat,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
let TyPat { id, kind, span, tokens: _ } = tp;
try_visit!(visit_id(vis, id));
match kind {
@@ -1036,19 +1038,19 @@ pub fn walk_ty_pat<$($lt,)? V: $Visitor$(<$lt>)?>(
fn walk_qself<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V,
qself: &$($lt)? $($mut)? Option<P<QSelf>>,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
if let Some(qself) = qself {
let QSelf { ty, path_span, position: _ } = &$($mut)? **qself;
try_visit!(vis.visit_ty(ty));
try_visit!(visit_span(vis, path_span));
}
- $(<V as Visitor<$lt>>::Result::output())?
+ V::Result::output()
}
pub fn walk_path<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V,
path: &$($lt)? $($mut)? Path,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
let Path { span, segments, tokens: _ } = path;
walk_list!(vis, visit_path_segment, segments);
visit_span(vis, span)
@@ -1057,7 +1059,7 @@ pub fn walk_path<$($lt,)? V: $Visitor$(<$lt>)?>(
pub fn walk_use_tree<$($lt,)? V: $Visitor$(<$lt>)?>(
vis: &mut V,
use_tree: &$($lt)? $($mut)? UseTree,
- ) $(-> <V as Visitor<$lt>>::Result)? {
+ ) -> V::Result {
let UseTree { prefix, kind, span } = use_tree;
try_visit!(vis.visit_path(prefix));
match kind {
@@ -1075,6 +1077,581 @@ pub fn walk_use_tree<$($lt,)? V: $Visitor$(<$lt>)?>(
}
visit_span(vis, span)
}
+
+ pub fn walk_generic_args<$($lt,)? V: $Visitor$(<$lt>)?>(
+ vis: &mut V,
+ generic_args: &$($lt)? $($mut)? GenericArgs
+ ) -> V::Result {
+ match generic_args {
+ GenericArgs::AngleBracketed(AngleBracketedArgs { span, args }) => {
+ for arg in args {
+ match arg {
+ AngleBracketedArg::Arg(a) => try_visit!(vis.visit_generic_arg(a)),
+ AngleBracketedArg::Constraint(c) => {
+ try_visit!(vis.visit_assoc_item_constraint(c))
+ }
+ }
+ }
+ visit_span(vis, span)
+ }
+ GenericArgs::Parenthesized(data) => {
+ let ParenthesizedArgs { span, inputs, inputs_span, output } = data;
+ walk_list!(vis, visit_ty, inputs);
+ try_visit!(vis.visit_fn_ret_ty(output));
+ try_visit!(visit_span(vis, span));
+ visit_span(vis, inputs_span)
+ }
+ GenericArgs::ParenthesizedElided(span) => visit_span(vis, span)
+ }
+ }
+
+ pub fn walk_generic_arg<$($lt,)? V: $Visitor$(<$lt>)?>(
+ vis: &mut V,
+ generic_arg: &$($lt)? $($mut)? GenericArg,
+ ) -> V::Result {
+ match generic_arg {
+ GenericArg::Lifetime(lt) => vis.visit_lifetime(lt, $(${ignore($lt)} LifetimeCtxt::GenericArg)? ),
+ GenericArg::Type(ty) => vis.visit_ty(ty),
+ GenericArg::Const(ct) => vis.visit_anon_const(ct),
+ }
+ }
+
+ pub fn walk_assoc_item_constraint<$($lt,)? V: $Visitor$(<$lt>)?>(
+ vis: &mut V,
+ constraint: &$($lt)? $($mut)? AssocItemConstraint,
+ ) -> V::Result {
+ let AssocItemConstraint { id, ident, gen_args, kind, span } = constraint;
+ try_visit!(visit_id(vis, id));
+ try_visit!(vis.visit_ident(ident));
+ visit_opt!(vis, visit_generic_args, gen_args);
+ match kind {
+ AssocItemConstraintKind::Equality { term } => match term {
+ Term::Ty(ty) => try_visit!(vis.visit_ty(ty)),
+ Term::Const(c) => try_visit!(vis.visit_anon_const(c)),
+ },
+ AssocItemConstraintKind::Bound { bounds } => {
+ try_visit!(visit_bounds(vis, bounds, BoundKind::Bound));
+ }
+ }
+ visit_span(vis, span)
+ }
+
+ pub fn walk_param_bound<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, bound: &$($lt)? $($mut)? GenericBound) -> V::Result {
+ match bound {
+ GenericBound::Trait(trait_ref) => vis.visit_poly_trait_ref(trait_ref),
+ GenericBound::Outlives(lifetime) => vis.visit_lifetime(lifetime, $(${ignore($lt)} LifetimeCtxt::Bound)?),
+ GenericBound::Use(args, span) => {
+ walk_list!(vis, visit_precise_capturing_arg, args);
+ visit_span(vis, span)
+ }
+ }
+ }
+
+ pub fn walk_precise_capturing_arg<$($lt,)? V: $Visitor$(<$lt>)?>(
+ vis: &mut V,
+ arg: &$($lt)? $($mut)? PreciseCapturingArg,
+ ) -> V::Result {
+ match arg {
+ PreciseCapturingArg::Lifetime(lt) => vis.visit_lifetime(lt, $(${ignore($lt)} LifetimeCtxt::GenericArg)?),
+ PreciseCapturingArg::Arg(path, id) => {
+ try_visit!(visit_id(vis, id));
+ vis.visit_path(path)
+ }
+ }
+ }
+
+ pub fn walk_generic_param<$($lt,)? V: $Visitor$(<$lt>)?>(
+ vis: &mut V,
+ param: &$($lt)? $($mut)? GenericParam,
+ ) -> V::Result {
+ let GenericParam { id, ident, attrs, bounds, is_placeholder: _, kind, colon_span } =
+ param;
+ try_visit!(visit_id(vis, id));
+ walk_list!(vis, visit_attribute, attrs);
+ try_visit!(vis.visit_ident(ident));
+ walk_list!(vis, visit_param_bound, bounds, BoundKind::Bound);
+ match kind {
+ GenericParamKind::Lifetime => (),
+ GenericParamKind::Type { default } => visit_opt!(vis, visit_ty, default),
+ GenericParamKind::Const { ty, default, kw_span: _ } => {
+ try_visit!(vis.visit_ty(ty));
+ visit_opt!(vis, visit_anon_const, default);
+ }
+ }
+ if let Some(sp) = colon_span {
+ try_visit!(visit_span(vis, sp))
+ }
+ V::Result::output()
+ }
+
+ pub fn walk_generics<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, generics: &$($lt)? $($mut)? Generics) -> V::Result {
+ let Generics { params, where_clause, span } = generics;
+ let WhereClause { has_where_token: _, predicates, span: where_clause_span } = where_clause;
+ try_visit!(visit_generic_params(vis, params));
+ try_visit!(visit_where_predicates(vis, predicates));
+ try_visit!(visit_span(vis, span));
+ visit_span(vis, where_clause_span)
+ }
+
+ pub fn walk_contract<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, c: &$($lt)? $($mut)? FnContract) -> V::Result {
+ let FnContract { requires, ensures } = c;
+ visit_opt!(vis, visit_expr, requires);
+ visit_opt!(vis, visit_expr, ensures);
+ V::Result::output()
+ }
+
+ pub fn walk_where_predicate<$($lt,)? V: $Visitor$(<$lt>)?>(
+ vis: &mut V,
+ predicate: &$($lt)? $($mut)? WherePredicate,
+ ) -> V::Result {
+ let WherePredicate { attrs, kind, id, span, is_placeholder: _ } = predicate;
+ try_visit!(visit_id(vis, id));
+ walk_list!(vis, visit_attribute, attrs);
+ try_visit!(visit_span(vis, span));
+ vis.visit_where_predicate_kind(kind)
+ }
+
+ pub fn walk_closure_binder<$($lt,)? V: $Visitor$(<$lt>)?>(
+ vis: &mut V,
+ binder: &$($lt)? $($mut)? ClosureBinder,
+ ) -> V::Result {
+ match binder {
+ ClosureBinder::NotPresent => {}
+ ClosureBinder::For { generic_params, span } => {
+ try_visit!(visit_generic_params(vis, generic_params));
+ try_visit!(visit_span(vis, span));
+ }
+ }
+ V::Result::output()
+ }
+
+ pub fn walk_where_predicate_kind<$($lt,)? V: $Visitor$(<$lt>)?>(
+ vis: &mut V,
+ kind: &$($lt)? $($mut)? WherePredicateKind,
+ ) -> V::Result {
+ match kind {
+ WherePredicateKind::BoundPredicate(WhereBoundPredicate {
+ bounded_ty,
+ bounds,
+ bound_generic_params,
+ }) => {
+ visit_generic_params(vis, bound_generic_params);
+ try_visit!(vis.visit_ty(bounded_ty));
+ walk_list!(vis, visit_param_bound, bounds, BoundKind::Bound);
+ }
+ WherePredicateKind::RegionPredicate(WhereRegionPredicate { lifetime, bounds }) => {
+ try_visit!(vis.visit_lifetime(lifetime, $(${ignore($lt)} LifetimeCtxt::Bound )?));
+ walk_list!(vis, visit_param_bound, bounds, BoundKind::Bound);
+ }
+ WherePredicateKind::EqPredicate(WhereEqPredicate { lhs_ty, rhs_ty }) => {
+ try_visit!(vis.visit_ty(lhs_ty));
+ try_visit!(vis.visit_ty(rhs_ty));
+ }
+ }
+ V::Result::output()
+ }
+
+ pub fn walk_fn_decl<$($lt,)? V: $Visitor$(<$lt>)?>(
+ vis: &mut V,
+ FnDecl { inputs, output }: &$($lt)? $($mut)? FnDecl,
+ ) -> V::Result {
+ try_visit!(visit_params(vis, inputs));
+ vis.visit_fn_ret_ty(output)
+ }
+
+ pub fn walk_fn_ret_ty<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, ret_ty: &$($lt)? $($mut)? FnRetTy) -> V::Result {
+ match ret_ty {
+ FnRetTy::Default(span) => visit_span(vis, span),
+ FnRetTy::Ty(output_ty) => vis.visit_ty(output_ty),
+ }
+ }
+
+ pub fn walk_fn<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, kind: FnKind<$($lt)? $(${ignore($mut)} '_)?>) -> V::Result {
+ match kind {
+ FnKind::Fn(
+ _ctxt,
+ _vis,
+ Fn {
+ defaultness,
+ ident,
+ sig: FnSig { header, decl, span },
+ generics,
+ contract,
+ body,
+ define_opaque,
+ },
+ ) => {
+ // Visibility is visited as a part of the item.
+ try_visit!(visit_defaultness(vis, defaultness));
+ try_visit!(vis.visit_ident(ident));
+ try_visit!(vis.visit_fn_header(header));
+ try_visit!(vis.visit_generics(generics));
+ try_visit!(vis.visit_fn_decl(decl));
+ visit_opt!(vis, visit_contract, contract);
+ visit_opt!(vis, visit_block, body);
+ try_visit!(visit_span(vis, span));
+ walk_define_opaques(vis, define_opaque)
+ }
+ FnKind::Closure(binder, coroutine_kind, decl, body) => {
+ try_visit!(vis.visit_closure_binder(binder));
+ visit_opt!(vis, visit_coroutine_kind, coroutine_kind);
+ try_visit!(vis.visit_fn_decl(decl));
+ vis.visit_expr(body)
+ }
+ }
+ }
+
+ pub fn walk_variant_data<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, data: &$($lt)? $($mut)? VariantData) -> V::Result {
+ match data {
+ VariantData::Struct { fields, recovered: _ } => {
+ visit_field_defs(vis, fields)
+ }
+ VariantData::Tuple(fields, id) => {
+ try_visit!(visit_id(vis, id));
+ visit_field_defs(vis, fields)
+ }
+ VariantData::Unit(id) => visit_id(vis, id),
+ }
+ }
+
+ pub fn walk_field_def<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, field: &$($lt)? $($mut)? FieldDef) -> V::Result {
+ let FieldDef { attrs, id, span, vis: visibility, ident, ty, is_placeholder: _, safety: _, default } =
+ field;
+ try_visit!(visit_id(vis, id));
+ walk_list!(vis, visit_attribute, attrs);
+ try_visit!(vis.visit_vis(visibility));
+ visit_opt!(vis, visit_ident, ident);
+ try_visit!(vis.visit_ty(ty));
+ visit_opt!(vis, visit_anon_const, default);
+ visit_span(vis, span)
+ }
+
+ fn visit_delim_args<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, args: &$($lt)? $($mut)? DelimArgs) -> V::Result {
+ let DelimArgs { dspan, delim: _, tokens: _ } = args;
+ let DelimSpan { open, close } = dspan;
+ try_visit!(visit_span(vis, open));
+ visit_span(vis, close)
+ }
+
+ pub fn walk_mac<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, mac: &$($lt)? $($mut)? MacCall) -> V::Result {
+ let MacCall { path, args } = mac;
+ try_visit!(vis.visit_path(path));
+ visit_delim_args(vis, args)
+ }
+
+ fn walk_macro_def<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, macro_def: &$($lt)? $($mut)? MacroDef) -> V::Result {
+ let MacroDef { body, macro_rules: _ } = macro_def;
+ visit_delim_args(vis, body)
+ }
+
+ pub fn walk_inline_asm<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, asm: &$($lt)? $($mut)? InlineAsm) -> V::Result {
+ // FIXME: Visit spans inside all this currently ignored stuff.
+ let InlineAsm {
+ asm_macro: _,
+ template: _,
+ template_strs: _,
+ operands,
+ clobber_abis: _,
+ options: _,
+ line_spans: _,
+ } = asm;
+ for (op, span) in operands {
+ match op {
+ InlineAsmOperand::In { expr, reg: _ }
+ | InlineAsmOperand::Out { expr: Some(expr), reg: _, late: _ }
+ | InlineAsmOperand::InOut { expr, reg: _, late: _ } => {
+ try_visit!(vis.visit_expr(expr))
+ }
+ InlineAsmOperand::Out { expr: None, reg: _, late: _ } => {}
+ InlineAsmOperand::SplitInOut { in_expr, out_expr, reg: _, late: _ } => {
+ try_visit!(vis.visit_expr(in_expr));
+ visit_opt!(vis, visit_expr, out_expr);
+ }
+ InlineAsmOperand::Const { anon_const } => {
+ try_visit!(vis.visit_anon_const(anon_const))
+ }
+ InlineAsmOperand::Sym { sym } => try_visit!(vis.visit_inline_asm_sym(sym)),
+ InlineAsmOperand::Label { block } => try_visit!(vis.visit_block(block)),
+ }
+ try_visit!(visit_span(vis, span));
+ }
+ V::Result::output()
+ }
+
+ pub fn walk_inline_asm_sym<$($lt,)? V: $Visitor$(<$lt>)?>(
+ vis: &mut V,
+ InlineAsmSym { id, qself, path }: &$($lt)? $($mut)? InlineAsmSym,
+ ) -> V::Result {
+ try_visit!(visit_id(vis, id));
+ try_visit!(vis.visit_qself(qself));
+ vis.visit_path(path)
+ }
+
+ // FIXME: visit the template exhaustively.
+ pub fn walk_format_args<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, fmt: &$($lt)? $($mut)? FormatArgs) -> V::Result {
+ let FormatArgs { span, template: _, arguments, uncooked_fmt_str: _ } = fmt;
+ let args = $(${ignore($mut)} arguments.all_args_mut())? $(${ignore($lt)} arguments.all_args())? ;
+ for FormatArgument { kind, expr } in args {
+ match kind {
+ FormatArgumentKind::Named(ident) | FormatArgumentKind::Captured(ident) => {
+ try_visit!(vis.visit_ident(ident))
+ }
+ FormatArgumentKind::Normal => {}
+ }
+ try_visit!(vis.visit_expr(expr));
+ }
+ visit_span(vis, span)
+ }
+
+ pub fn walk_expr<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, expression: &$($lt)? $($mut)? Expr) -> V::Result {
+ let Expr { id, kind, span, attrs, tokens: _ } = expression;
+ try_visit!(visit_id(vis, id));
+ walk_list!(vis, visit_attribute, attrs);
+ match kind {
+ ExprKind::Array(exprs) => {
+ try_visit!(visit_exprs(vis, exprs));
+ }
+ ExprKind::ConstBlock(anon_const) => try_visit!(vis.visit_anon_const(anon_const)),
+ ExprKind::Repeat(element, count) => {
+ try_visit!(vis.visit_expr(element));
+ try_visit!(vis.visit_anon_const(count));
+ }
+ ExprKind::Struct(se) => {
+ let StructExpr { qself, path, fields, rest } = &$($mut)?**se;
+ try_visit!(vis.visit_qself(qself));
+ try_visit!(vis.visit_path(path));
+ visit_expr_fields(vis, fields);
+ match rest {
+ StructRest::Base(expr) => try_visit!(vis.visit_expr(expr)),
+ StructRest::Rest(_span) => {}
+ StructRest::None => {}
+ }
+ }
+ ExprKind::Tup(exprs) => {
+ try_visit!(visit_exprs(vis, exprs));
+ }
+ ExprKind::Call(callee_expression, arguments) => {
+ try_visit!(vis.visit_expr(callee_expression));
+ try_visit!(visit_exprs(vis, arguments));
+ }
+ ExprKind::MethodCall(box MethodCall { seg, receiver, args, span }) => {
+ try_visit!(vis.visit_method_receiver_expr(receiver));
+ try_visit!(vis.visit_path_segment(seg));
+ try_visit!(visit_exprs(vis, args));
+ try_visit!(visit_span(vis, span));
+ }
+ ExprKind::Binary(Spanned { span, node: _ }, left_expression, right_expression) => {
+ try_visit!(vis.visit_expr(left_expression));
+ try_visit!(vis.visit_expr(right_expression));
+ try_visit!(visit_span(vis, span))
+ }
+ ExprKind::AddrOf(_kind, _mutbl, subexpression) => {
+ try_visit!(vis.visit_expr(subexpression));
+ }
+ ExprKind::Unary(_op, subexpression) => {
+ try_visit!(vis.visit_expr(subexpression));
+ }
+ ExprKind::Cast(subexpression, typ) | ExprKind::Type(subexpression, typ) => {
+ try_visit!(vis.visit_expr(subexpression));
+ try_visit!(vis.visit_ty(typ));
+ }
+ ExprKind::Let(pat, expr, span, _recovered) => {
+ try_visit!(vis.visit_pat(pat));
+ try_visit!(vis.visit_expr(expr));
+ try_visit!(visit_span(vis, span))
+ }
+ ExprKind::If(head_expression, if_block, optional_else) => {
+ try_visit!(vis.visit_expr(head_expression));
+ try_visit!(vis.visit_block(if_block));
+ visit_opt!(vis, visit_expr, optional_else);
+ }
+ ExprKind::While(subexpression, block, opt_label) => {
+ visit_opt!(vis, visit_label, opt_label);
+ try_visit!(vis.visit_expr(subexpression));
+ try_visit!(vis.visit_block(block));
+ }
+ ExprKind::ForLoop { pat, iter, body, label, kind: _ } => {
+ visit_opt!(vis, visit_label, label);
+ try_visit!(vis.visit_pat(pat));
+ try_visit!(vis.visit_expr(iter));
+ try_visit!(vis.visit_block(body));
+ }
+ ExprKind::Loop(block, opt_label, span) => {
+ visit_opt!(vis, visit_label, opt_label);
+ try_visit!(vis.visit_block(block));
+ try_visit!(visit_span(vis, span))
+ }
+ ExprKind::Match(subexpression, arms, _kind) => {
+ try_visit!(vis.visit_expr(subexpression));
+ try_visit!(visit_arms(vis, arms));
+ }
+ ExprKind::Closure(box Closure {
+ binder,
+ capture_clause,
+ coroutine_kind,
+ constness,
+ movability: _,
+ fn_decl,
+ body,
+ fn_decl_span,
+ fn_arg_span,
+ }) => {
+ try_visit!(visit_constness(vis, constness));
+ try_visit!(vis.visit_capture_by(capture_clause));
+ try_visit!(vis.visit_fn(
+ FnKind::Closure(binder, coroutine_kind, fn_decl, body),
+ *span,
+ *id
+ ));
+ try_visit!(visit_span(vis, fn_decl_span));
+ try_visit!(visit_span(vis, fn_arg_span));
+ }
+ ExprKind::Block(block, opt_label) => {
+ visit_opt!(vis, visit_label, opt_label);
+ try_visit!(vis.visit_block(block));
+ }
+ ExprKind::Gen(_capt, body, _kind, decl_span) => {
+ try_visit!(vis.visit_block(body));
+ try_visit!(visit_span(vis, decl_span));
+ }
+ ExprKind::Await(expr, span) => {
+ try_visit!(vis.visit_expr(expr));
+ try_visit!(visit_span(vis, span));
+ }
+ ExprKind::Use(expr, span) => {
+ try_visit!(vis.visit_expr(expr));
+ try_visit!(visit_span(vis, span));
+ }
+ ExprKind::Assign(lhs, rhs, span) => {
+ try_visit!(vis.visit_expr(lhs));
+ try_visit!(vis.visit_expr(rhs));
+ try_visit!(visit_span(vis, span));
+ }
+ ExprKind::AssignOp(_op, left_expression, right_expression) => {
+ try_visit!(vis.visit_expr(left_expression));
+ try_visit!(vis.visit_expr(right_expression));
+ }
+ ExprKind::Field(subexpression, ident) => {
+ try_visit!(vis.visit_expr(subexpression));
+ try_visit!(vis.visit_ident(ident));
+ }
+ ExprKind::Index(main_expression, index_expression, span) => {
+ try_visit!(vis.visit_expr(main_expression));
+ try_visit!(vis.visit_expr(index_expression));
+ try_visit!(visit_span(vis, span));
+ }
+ ExprKind::Range(start, end, _limit) => {
+ visit_opt!(vis, visit_expr, start);
+ visit_opt!(vis, visit_expr, end);
+ }
+ ExprKind::Underscore => {}
+ ExprKind::Path(maybe_qself, path) => {
+ try_visit!(vis.visit_qself(maybe_qself));
+ try_visit!(vis.visit_path(path));
+ }
+ ExprKind::Break(opt_label, opt_expr) => {
+ visit_opt!(vis, visit_label, opt_label);
+ visit_opt!(vis, visit_expr, opt_expr);
+ }
+ ExprKind::Continue(opt_label) => {
+ visit_opt!(vis, visit_label, opt_label);
+ }
+ ExprKind::Ret(optional_expression) => {
+ visit_opt!(vis, visit_expr, optional_expression);
+ }
+ ExprKind::Yeet(optional_expression) => {
+ visit_opt!(vis, visit_expr, optional_expression);
+ }
+ ExprKind::Become(expr) => try_visit!(vis.visit_expr(expr)),
+ ExprKind::MacCall(mac) => try_visit!(vis.visit_mac_call(mac)),
+ ExprKind::Paren(subexpression) => try_visit!(vis.visit_expr(subexpression)),
+ ExprKind::InlineAsm(asm) => try_visit!(vis.visit_inline_asm(asm)),
+ ExprKind::FormatArgs(f) => try_visit!(vis.visit_format_args(f)),
+ ExprKind::OffsetOf(container, fields) => {
+ try_visit!(vis.visit_ty(container));
+ walk_list!(vis, visit_ident, fields);
+ }
+ ExprKind::Yield(kind) => {
+ match kind {
+ YieldKind::Postfix(expr) => {
+ try_visit!(vis.visit_expr(expr));
+ }
+ YieldKind::Prefix(expr) => {
+ visit_opt!(vis, visit_expr, expr);
+ }
+ }
+ }
+ ExprKind::Try(subexpression) => try_visit!(vis.visit_expr(subexpression)),
+ ExprKind::TryBlock(body) => try_visit!(vis.visit_block(body)),
+ ExprKind::Lit(_token) => {}
+ ExprKind::IncludedBytes(_bytes) => {}
+ ExprKind::UnsafeBinderCast(_kind, expr, ty) => {
+ try_visit!(vis.visit_expr(expr));
+ visit_opt!(vis, visit_ty, ty);
+ }
+ ExprKind::Err(_guar) => {}
+ ExprKind::Dummy => {}
+ }
+
+ visit_span(vis, span)
+ }
+
+ pub fn walk_param<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, param: &$($lt)? $($mut)? Param) -> V::Result {
+ let Param { attrs, ty, pat, id, span, is_placeholder: _ } = param;
+ try_visit!(visit_id(vis, id));
+ walk_list!(vis, visit_attribute, attrs);
+ try_visit!(vis.visit_pat(pat));
+ try_visit!(vis.visit_ty(ty));
+ visit_span(vis, span)
+ }
+
+ pub fn walk_arm<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, arm: &$($lt)? $($mut)? Arm) -> V::Result {
+ let Arm { attrs, pat, guard, body, span, id, is_placeholder: _ } = arm;
+ try_visit!(visit_id(vis, id));
+ walk_list!(vis, visit_attribute, attrs);
+ try_visit!(vis.visit_pat(pat));
+ visit_opt!(vis, visit_expr, guard);
+ visit_opt!(vis, visit_expr, body);
+ visit_span(vis, span)
+ }
+
+ pub fn walk_vis<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, visibility: &$($lt)? $($mut)? Visibility) -> V::Result {
+ let Visibility { kind, span, tokens: _ } = visibility;
+ match kind {
+ VisibilityKind::Restricted { path, id, shorthand: _ } => {
+ try_visit!(visit_id(vis, id));
+ try_visit!(vis.visit_path(path));
+ }
+ VisibilityKind::Public | VisibilityKind::Inherited => {}
+ }
+ visit_span(vis, span)
+ }
+
+ pub fn walk_attribute<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, attr: &$($lt)? $($mut)? Attribute) -> V::Result {
+ let Attribute { kind, id: _, style: _, span } = attr;
+ match kind {
+ AttrKind::Normal(normal) => {
+ let NormalAttr { item, tokens: _ } = &$($mut)?**normal;
+ let AttrItem { unsafety: _, path, args, tokens: _ } = item;
+ try_visit!(vis.visit_path(path));
+ try_visit!(walk_attr_args(vis, args));
+ }
+ AttrKind::DocComment(_kind, _sym) => {}
+ }
+ visit_span(vis, span)
+ }
+
+ pub fn walk_attr_args<$($lt,)? V: $Visitor$(<$lt>)?>(vis: &mut V, args: &$($lt)? $($mut)? AttrArgs) -> V::Result {
+ match args {
+ AttrArgs::Empty => {}
+ AttrArgs::Delimited(args) => try_visit!(visit_delim_args(vis, args)),
+ AttrArgs::Eq { eq_span, expr } => {
+ try_visit!(vis.visit_expr(expr));
+ try_visit!(visit_span(vis, eq_span));
+ }
+ }
+ V::Result::output()
+ }
};
}
@@ -1102,9 +1679,15 @@ fn $name<'a, V: Visitor<'a>>(
visit_foreign_items, P<ForeignItem>, visit_foreign_item;
visit_generic_params, GenericParam, visit_generic_param;
visit_stmts, Stmt, visit_stmt;
+ visit_exprs, P<Expr>, visit_expr;
+ visit_expr_fields, ExprField, visit_expr_field;
visit_pat_fields, PatField, visit_pat_field;
visit_variants, Variant, visit_variant;
visit_assoc_items, P<AssocItem>, visit_assoc_item, ctxt: AssocCtxt;
+ visit_where_predicates, WherePredicate, visit_where_predicate;
+ visit_params, Param, visit_param;
+ visit_field_defs, FieldDef, visit_field_def;
+ visit_arms, Arm, visit_arm;
}
#[expect(rustc::pass_by_value)] // needed for symmetry with mut_visit
@@ -1116,239 +1699,6 @@ fn visit_nested_use_tree<'a, V: Visitor<'a>>(
vis.visit_nested_use_tree(nested_tree, nested_id)
}
-pub fn walk_generic_args<'a, V>(visitor: &mut V, generic_args: &'a GenericArgs) -> V::Result
-where
- V: Visitor<'a>,
-{
- match generic_args {
- GenericArgs::AngleBracketed(AngleBracketedArgs { span: _, args }) => {
- for arg in args {
- match arg {
- AngleBracketedArg::Arg(a) => try_visit!(visitor.visit_generic_arg(a)),
- AngleBracketedArg::Constraint(c) => {
- try_visit!(visitor.visit_assoc_item_constraint(c))
- }
- }
- }
- }
- GenericArgs::Parenthesized(data) => {
- let ParenthesizedArgs { span: _, inputs, inputs_span: _, output } = data;
- walk_list!(visitor, visit_ty, inputs);
- try_visit!(visitor.visit_fn_ret_ty(output));
- }
- GenericArgs::ParenthesizedElided(_span) => {}
- }
- V::Result::output()
-}
-
-pub fn walk_generic_arg<'a, V>(visitor: &mut V, generic_arg: &'a GenericArg) -> V::Result
-where
- V: Visitor<'a>,
-{
- match generic_arg {
- GenericArg::Lifetime(lt) => visitor.visit_lifetime(lt, LifetimeCtxt::GenericArg),
- GenericArg::Type(ty) => visitor.visit_ty(ty),
- GenericArg::Const(ct) => visitor.visit_anon_const(ct),
- }
-}
-
-pub fn walk_assoc_item_constraint<'a, V: Visitor<'a>>(
- visitor: &mut V,
- constraint: &'a AssocItemConstraint,
-) -> V::Result {
- let AssocItemConstraint { id: _, ident, gen_args, kind, span: _ } = constraint;
- try_visit!(visitor.visit_ident(ident));
- visit_opt!(visitor, visit_generic_args, gen_args);
- match kind {
- AssocItemConstraintKind::Equality { term } => match term {
- Term::Ty(ty) => try_visit!(visitor.visit_ty(ty)),
- Term::Const(c) => try_visit!(visitor.visit_anon_const(c)),
- },
- AssocItemConstraintKind::Bound { bounds } => {
- walk_list!(visitor, visit_param_bound, bounds, BoundKind::Bound);
- }
- }
- V::Result::output()
-}
-
-pub fn walk_param_bound<'a, V: Visitor<'a>>(visitor: &mut V, bound: &'a GenericBound) -> V::Result {
- match bound {
- GenericBound::Trait(trait_ref) => visitor.visit_poly_trait_ref(trait_ref),
- GenericBound::Outlives(lifetime) => visitor.visit_lifetime(lifetime, LifetimeCtxt::Bound),
- GenericBound::Use(args, _span) => {
- walk_list!(visitor, visit_precise_capturing_arg, args);
- V::Result::output()
- }
- }
-}
-
-pub fn walk_precise_capturing_arg<'a, V: Visitor<'a>>(
- visitor: &mut V,
- arg: &'a PreciseCapturingArg,
-) -> V::Result {
- match arg {
- PreciseCapturingArg::Lifetime(lt) => visitor.visit_lifetime(lt, LifetimeCtxt::GenericArg),
- PreciseCapturingArg::Arg(path, id) => {
- try_visit!(visitor.visit_id(*id));
- visitor.visit_path(path)
- }
- }
-}
-
-pub fn walk_generic_param<'a, V: Visitor<'a>>(
- visitor: &mut V,
- param: &'a GenericParam,
-) -> V::Result {
- let GenericParam { id: _, ident, attrs, bounds, is_placeholder: _, kind, colon_span: _ } =
- param;
- walk_list!(visitor, visit_attribute, attrs);
- try_visit!(visitor.visit_ident(ident));
- walk_list!(visitor, visit_param_bound, bounds, BoundKind::Bound);
- match kind {
- GenericParamKind::Lifetime => (),
- GenericParamKind::Type { default } => visit_opt!(visitor, visit_ty, default),
- GenericParamKind::Const { ty, default, kw_span: _ } => {
- try_visit!(visitor.visit_ty(ty));
- visit_opt!(visitor, visit_anon_const, default);
- }
- }
- V::Result::output()
-}
-
-pub fn walk_generics<'a, V: Visitor<'a>>(visitor: &mut V, generics: &'a Generics) -> V::Result {
- let Generics { params, where_clause, span: _ } = generics;
- let WhereClause { has_where_token: _, predicates, span: _ } = where_clause;
- walk_list!(visitor, visit_generic_param, params);
- walk_list!(visitor, visit_where_predicate, predicates);
- V::Result::output()
-}
-
-pub fn walk_closure_binder<'a, V: Visitor<'a>>(
- visitor: &mut V,
- binder: &'a ClosureBinder,
-) -> V::Result {
- match binder {
- ClosureBinder::NotPresent => {}
- ClosureBinder::For { generic_params, span: _ } => {
- walk_list!(visitor, visit_generic_param, generic_params)
- }
- }
- V::Result::output()
-}
-
-pub fn walk_contract<'a, V: Visitor<'a>>(visitor: &mut V, c: &'a FnContract) -> V::Result {
- let FnContract { requires, ensures } = c;
- if let Some(pred) = requires {
- visitor.visit_expr(pred);
- }
- if let Some(pred) = ensures {
- visitor.visit_expr(pred);
- }
- V::Result::output()
-}
-
-pub fn walk_where_predicate<'a, V: Visitor<'a>>(
- visitor: &mut V,
- predicate: &'a WherePredicate,
-) -> V::Result {
- let WherePredicate { attrs, kind, id: _, span: _, is_placeholder: _ } = predicate;
- walk_list!(visitor, visit_attribute, attrs);
- visitor.visit_where_predicate_kind(kind)
-}
-
-pub fn walk_where_predicate_kind<'a, V: Visitor<'a>>(
- visitor: &mut V,
- kind: &'a WherePredicateKind,
-) -> V::Result {
- match kind {
- WherePredicateKind::BoundPredicate(WhereBoundPredicate {
- bounded_ty,
- bounds,
- bound_generic_params,
- }) => {
- walk_list!(visitor, visit_generic_param, bound_generic_params);
- try_visit!(visitor.visit_ty(bounded_ty));
- walk_list!(visitor, visit_param_bound, bounds, BoundKind::Bound);
- }
- WherePredicateKind::RegionPredicate(WhereRegionPredicate { lifetime, bounds }) => {
- try_visit!(visitor.visit_lifetime(lifetime, LifetimeCtxt::Bound));
- walk_list!(visitor, visit_param_bound, bounds, BoundKind::Bound);
- }
- WherePredicateKind::EqPredicate(WhereEqPredicate { lhs_ty, rhs_ty }) => {
- try_visit!(visitor.visit_ty(lhs_ty));
- try_visit!(visitor.visit_ty(rhs_ty));
- }
- }
- V::Result::output()
-}
-
-pub fn walk_fn_ret_ty<'a, V: Visitor<'a>>(visitor: &mut V, ret_ty: &'a FnRetTy) -> V::Result {
- match ret_ty {
- FnRetTy::Default(_span) => {}
- FnRetTy::Ty(output_ty) => try_visit!(visitor.visit_ty(output_ty)),
- }
- V::Result::output()
-}
-
-pub fn walk_fn_decl<'a, V: Visitor<'a>>(
- visitor: &mut V,
- FnDecl { inputs, output }: &'a FnDecl,
-) -> V::Result {
- walk_list!(visitor, visit_param, inputs);
- visitor.visit_fn_ret_ty(output)
-}
-
-pub fn walk_fn<'a, V: Visitor<'a>>(visitor: &mut V, kind: FnKind<'a>) -> V::Result {
- match kind {
- FnKind::Fn(
- _ctxt,
- _vis,
- Fn {
- defaultness: _,
- ident,
- sig: FnSig { header, decl, span: _ },
- generics,
- contract,
- body,
- define_opaque,
- },
- ) => {
- // Visibility is visited as a part of the item.
- try_visit!(visitor.visit_ident(ident));
- try_visit!(visitor.visit_fn_header(header));
- try_visit!(visitor.visit_generics(generics));
- try_visit!(visitor.visit_fn_decl(decl));
- visit_opt!(visitor, visit_contract, contract);
- visit_opt!(visitor, visit_block, body);
- try_visit!(walk_define_opaques(visitor, define_opaque));
- }
- FnKind::Closure(binder, coroutine_kind, decl, body) => {
- try_visit!(visitor.visit_closure_binder(binder));
- visit_opt!(visitor, visit_coroutine_kind, coroutine_kind.as_ref());
- try_visit!(visitor.visit_fn_decl(decl));
- try_visit!(visitor.visit_expr(body));
- }
- }
- V::Result::output()
-}
-
-pub fn walk_variant_data<'a, V: Visitor<'a>>(visitor: &mut V, data: &'a VariantData) -> V::Result {
- visit_opt!(visitor, visit_id, data.ctor_node_id());
- walk_list!(visitor, visit_field_def, data.fields());
- V::Result::output()
-}
-
-pub fn walk_field_def<'a, V: Visitor<'a>>(visitor: &mut V, field: &'a FieldDef) -> V::Result {
- let FieldDef { attrs, id: _, span: _, vis, ident, ty, is_placeholder: _, safety: _, default } =
- field;
- walk_list!(visitor, visit_attribute, attrs);
- try_visit!(visitor.visit_vis(vis));
- visit_opt!(visitor, visit_ident, ident);
- try_visit!(visitor.visit_ty(ty));
- visit_opt!(visitor, visit_anon_const, &*default);
- V::Result::output()
-}
-
pub fn walk_stmt<'a, V: Visitor<'a>>(visitor: &mut V, statement: &'a Stmt) -> V::Result {
let Stmt { id: _, kind, span: _ } = statement;
match kind {
@@ -1364,284 +1714,3 @@ pub fn walk_stmt<'a, V: Visitor<'a>>(visitor: &mut V, statement: &'a Stmt) -> V:
}
V::Result::output()
}
-
-pub fn walk_mac<'a, V: Visitor<'a>>(visitor: &mut V, mac: &'a MacCall) -> V::Result {
- let MacCall { path, args: _ } = mac;
- visitor.visit_path(path)
-}
-
-pub fn walk_inline_asm<'a, V: Visitor<'a>>(visitor: &mut V, asm: &'a InlineAsm) -> V::Result {
- let InlineAsm {
- asm_macro: _,
- template: _,
- template_strs: _,
- operands,
- clobber_abis: _,
- options: _,
- line_spans: _,
- } = asm;
- for (op, _span) in operands {
- match op {
- InlineAsmOperand::In { expr, reg: _ }
- | InlineAsmOperand::Out { expr: Some(expr), reg: _, late: _ }
- | InlineAsmOperand::InOut { expr, reg: _, late: _ } => {
- try_visit!(visitor.visit_expr(expr))
- }
- InlineAsmOperand::Out { expr: None, reg: _, late: _ } => {}
- InlineAsmOperand::SplitInOut { in_expr, out_expr, reg: _, late: _ } => {
- try_visit!(visitor.visit_expr(in_expr));
- visit_opt!(visitor, visit_expr, out_expr);
- }
- InlineAsmOperand::Const { anon_const } => {
- try_visit!(visitor.visit_anon_const(anon_const))
- }
- InlineAsmOperand::Sym { sym } => try_visit!(visitor.visit_inline_asm_sym(sym)),
- InlineAsmOperand::Label { block } => try_visit!(visitor.visit_block(block)),
- }
- }
- V::Result::output()
-}
-
-pub fn walk_inline_asm_sym<'a, V: Visitor<'a>>(
- visitor: &mut V,
- InlineAsmSym { id, qself, path }: &'a InlineAsmSym,
-) -> V::Result {
- try_visit!(visitor.visit_qself(qself));
- try_visit!(visitor.visit_id(*id));
- visitor.visit_path(path)
-}
-
-pub fn walk_format_args<'a, V: Visitor<'a>>(visitor: &mut V, fmt: &'a FormatArgs) -> V::Result {
- let FormatArgs { span: _, template: _, arguments, uncooked_fmt_str: _ } = fmt;
- for FormatArgument { kind, expr } in arguments.all_args() {
- match kind {
- FormatArgumentKind::Named(ident) | FormatArgumentKind::Captured(ident) => {
- try_visit!(visitor.visit_ident(ident))
- }
- FormatArgumentKind::Normal => {}
- }
- try_visit!(visitor.visit_expr(expr));
- }
- V::Result::output()
-}
-
-pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) -> V::Result {
- let Expr { id, kind, span, attrs, tokens: _ } = expression;
- walk_list!(visitor, visit_attribute, attrs);
- match kind {
- ExprKind::Array(subexpressions) => {
- walk_list!(visitor, visit_expr, subexpressions);
- }
- ExprKind::ConstBlock(anon_const) => try_visit!(visitor.visit_anon_const(anon_const)),
- ExprKind::Repeat(element, count) => {
- try_visit!(visitor.visit_expr(element));
- try_visit!(visitor.visit_anon_const(count));
- }
- ExprKind::Struct(se) => {
- let StructExpr { qself, path, fields, rest } = &**se;
- try_visit!(visitor.visit_qself(qself));
- try_visit!(visitor.visit_id(*id));
- try_visit!(visitor.visit_path(path));
- walk_list!(visitor, visit_expr_field, fields);
- match rest {
- StructRest::Base(expr) => try_visit!(visitor.visit_expr(expr)),
- StructRest::Rest(_span) => {}
- StructRest::None => {}
- }
- }
- ExprKind::Tup(subexpressions) => {
- walk_list!(visitor, visit_expr, subexpressions);
- }
- ExprKind::Call(callee_expression, arguments) => {
- try_visit!(visitor.visit_expr(callee_expression));
- walk_list!(visitor, visit_expr, arguments);
- }
- ExprKind::MethodCall(box MethodCall { seg, receiver, args, span: _ }) => {
- try_visit!(visitor.visit_expr(receiver));
- try_visit!(visitor.visit_path_segment(seg));
- walk_list!(visitor, visit_expr, args);
- }
- ExprKind::Binary(_op, left_expression, right_expression) => {
- try_visit!(visitor.visit_expr(left_expression));
- try_visit!(visitor.visit_expr(right_expression));
- }
- ExprKind::AddrOf(_kind, _mutbl, subexpression) => {
- try_visit!(visitor.visit_expr(subexpression));
- }
- ExprKind::Unary(_op, subexpression) => {
- try_visit!(visitor.visit_expr(subexpression));
- }
- ExprKind::Cast(subexpression, typ) | ExprKind::Type(subexpression, typ) => {
- try_visit!(visitor.visit_expr(subexpression));
- try_visit!(visitor.visit_ty(typ));
- }
- ExprKind::Let(pat, expr, _span, _recovered) => {
- try_visit!(visitor.visit_pat(pat));
- try_visit!(visitor.visit_expr(expr));
- }
- ExprKind::If(head_expression, if_block, optional_else) => {
- try_visit!(visitor.visit_expr(head_expression));
- try_visit!(visitor.visit_block(if_block));
- visit_opt!(visitor, visit_expr, optional_else);
- }
- ExprKind::While(subexpression, block, opt_label) => {
- visit_opt!(visitor, visit_label, opt_label);
- try_visit!(visitor.visit_expr(subexpression));
- try_visit!(visitor.visit_block(block));
- }
- ExprKind::ForLoop { pat, iter, body, label, kind: _ } => {
- visit_opt!(visitor, visit_label, label);
- try_visit!(visitor.visit_pat(pat));
- try_visit!(visitor.visit_expr(iter));
- try_visit!(visitor.visit_block(body));
- }
- ExprKind::Loop(block, opt_label, _span) => {
- visit_opt!(visitor, visit_label, opt_label);
- try_visit!(visitor.visit_block(block));
- }
- ExprKind::Match(subexpression, arms, _kind) => {
- try_visit!(visitor.visit_expr(subexpression));
- walk_list!(visitor, visit_arm, arms);
- }
- ExprKind::Closure(box Closure {
- binder,
- capture_clause,
- coroutine_kind,
- constness: _,
- movability: _,
- fn_decl,
- body,
- fn_decl_span: _,
- fn_arg_span: _,
- }) => {
- try_visit!(visitor.visit_capture_by(capture_clause));
- try_visit!(visitor.visit_fn(
- FnKind::Closure(binder, coroutine_kind, fn_decl, body),
- *span,
- *id
- ));
- }
- ExprKind::Block(block, opt_label) => {
- visit_opt!(visitor, visit_label, opt_label);
- try_visit!(visitor.visit_block(block));
- }
- ExprKind::Gen(_capt, body, _kind, _decl_span) => try_visit!(visitor.visit_block(body)),
- ExprKind::Await(expr, _span) => try_visit!(visitor.visit_expr(expr)),
- ExprKind::Use(expr, _span) => try_visit!(visitor.visit_expr(expr)),
- ExprKind::Assign(lhs, rhs, _span) => {
- try_visit!(visitor.visit_expr(lhs));
- try_visit!(visitor.visit_expr(rhs));
- }
- ExprKind::AssignOp(_op, left_expression, right_expression) => {
- try_visit!(visitor.visit_expr(left_expression));
- try_visit!(visitor.visit_expr(right_expression));
- }
- ExprKind::Field(subexpression, ident) => {
- try_visit!(visitor.visit_expr(subexpression));
- try_visit!(visitor.visit_ident(ident));
- }
- ExprKind::Index(main_expression, index_expression, _span) => {
- try_visit!(visitor.visit_expr(main_expression));
- try_visit!(visitor.visit_expr(index_expression));
- }
- ExprKind::Range(start, end, _limit) => {
- visit_opt!(visitor, visit_expr, start);
- visit_opt!(visitor, visit_expr, end);
- }
- ExprKind::Underscore => {}
- ExprKind::Path(maybe_qself, path) => {
- try_visit!(visitor.visit_qself(maybe_qself));
- try_visit!(visitor.visit_id(*id));
- try_visit!(visitor.visit_path(path));
- }
- ExprKind::Break(opt_label, opt_expr) => {
- visit_opt!(visitor, visit_label, opt_label);
- visit_opt!(visitor, visit_expr, opt_expr);
- }
- ExprKind::Continue(opt_label) => {
- visit_opt!(visitor, visit_label, opt_label);
- }
- ExprKind::Ret(optional_expression) => {
- visit_opt!(visitor, visit_expr, optional_expression);
- }
- ExprKind::Yeet(optional_expression) => {
- visit_opt!(visitor, visit_expr, optional_expression);
- }
- ExprKind::Become(expr) => try_visit!(visitor.visit_expr(expr)),
- ExprKind::MacCall(mac) => try_visit!(visitor.visit_mac_call(mac)),
- ExprKind::Paren(subexpression) => try_visit!(visitor.visit_expr(subexpression)),
- ExprKind::InlineAsm(asm) => try_visit!(visitor.visit_inline_asm(asm)),
- ExprKind::FormatArgs(f) => try_visit!(visitor.visit_format_args(f)),
- ExprKind::OffsetOf(container, fields) => {
- try_visit!(visitor.visit_ty(container));
- walk_list!(visitor, visit_ident, fields.iter());
- }
- ExprKind::Yield(kind) => {
- visit_opt!(visitor, visit_expr, kind.expr());
- }
- ExprKind::Try(subexpression) => try_visit!(visitor.visit_expr(subexpression)),
- ExprKind::TryBlock(body) => try_visit!(visitor.visit_block(body)),
- ExprKind::Lit(_token) => {}
- ExprKind::IncludedBytes(_bytes) => {}
- ExprKind::UnsafeBinderCast(_kind, expr, ty) => {
- try_visit!(visitor.visit_expr(expr));
- visit_opt!(visitor, visit_ty, ty);
- }
- ExprKind::Err(_guar) => {}
- ExprKind::Dummy => {}
- }
-
- V::Result::output()
-}
-
-pub fn walk_param<'a, V: Visitor<'a>>(visitor: &mut V, param: &'a Param) -> V::Result {
- let Param { attrs, ty, pat, id: _, span: _, is_placeholder: _ } = param;
- walk_list!(visitor, visit_attribute, attrs);
- try_visit!(visitor.visit_pat(pat));
- try_visit!(visitor.visit_ty(ty));
- V::Result::output()
-}
-
-pub fn walk_arm<'a, V: Visitor<'a>>(visitor: &mut V, arm: &'a Arm) -> V::Result {
- let Arm { attrs, pat, guard, body, span: _, id: _, is_placeholder: _ } = arm;
- walk_list!(visitor, visit_attribute, attrs);
- try_visit!(visitor.visit_pat(pat));
- visit_opt!(visitor, visit_expr, guard);
- visit_opt!(visitor, visit_expr, body);
- V::Result::output()
-}
-
-pub fn walk_vis<'a, V: Visitor<'a>>(visitor: &mut V, vis: &'a Visibility) -> V::Result {
- let Visibility { kind, span: _, tokens: _ } = vis;
- match kind {
- VisibilityKind::Restricted { path, id, shorthand: _ } => {
- try_visit!(visitor.visit_id(*id));
- try_visit!(visitor.visit_path(path));
- }
- VisibilityKind::Public | VisibilityKind::Inherited => {}
- }
- V::Result::output()
-}
-
-pub fn walk_attribute<'a, V: Visitor<'a>>(visitor: &mut V, attr: &'a Attribute) -> V::Result {
- let Attribute { kind, id: _, style: _, span: _ } = attr;
- match kind {
- AttrKind::Normal(normal) => {
- let NormalAttr { item, tokens: _ } = &**normal;
- let AttrItem { unsafety: _, path, args, tokens: _ } = item;
- try_visit!(visitor.visit_path(path));
- try_visit!(walk_attr_args(visitor, args));
- }
- AttrKind::DocComment(_kind, _sym) => {}
- }
- V::Result::output()
-}
-
-pub fn walk_attr_args<'a, V: Visitor<'a>>(visitor: &mut V, args: &'a AttrArgs) -> V::Result {
- match args {
- AttrArgs::Empty => {}
- AttrArgs::Delimited(_args) => {}
- AttrArgs::Eq { expr, .. } => try_visit!(visitor.visit_expr(expr)),
- }
- V::Result::output()
-}
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs
index 3004be4..b99df8b 100644
--- a/compiler/rustc_ast_lowering/src/lib.rs
+++ b/compiler/rustc_ast_lowering/src/lib.rs
@@ -33,9 +33,7 @@
// tidy-alphabetical-start
#![allow(internal_features)]
#![doc(rust_logo)]
-#![feature(assert_matches)]
#![feature(box_patterns)]
-#![feature(exact_size_is_empty)]
#![feature(if_let_guard)]
#![feature(rustdoc_internals)]
// tidy-alphabetical-end
diff --git a/compiler/rustc_attr_data_structures/src/attributes.rs b/compiler/rustc_attr_data_structures/src/attributes.rs
index d2d1285..845e4d5 100644
--- a/compiler/rustc_attr_data_structures/src/attributes.rs
+++ b/compiler/rustc_attr_data_structures/src/attributes.rs
@@ -57,14 +57,6 @@ pub fn do_not_optimize(&self) -> bool {
}
}
-#[derive(Clone, Debug, Encodable, Decodable, HashStable_Generic, PrintAttribute)]
-pub enum DiagnosticAttribute {
- // tidy-alphabetical-start
- DoNotRecommend,
- OnUnimplemented,
- // tidy-alphabetical-end
-}
-
#[derive(PartialEq, Debug, Encodable, Decodable, Copy, Clone, HashStable_Generic, PrintAttribute)]
pub enum ReprAttr {
ReprInt(IntType),
@@ -160,40 +152,52 @@ pub fn is_since_rustc_version(&self) -> bool {
#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
pub enum AttributeKind {
// tidy-alphabetical-start
+ /// Represents `#[rustc_allow_const_fn_unstable]`.
AllowConstFnUnstable(ThinVec<Symbol>),
+
+ /// Represents `#[allow_internal_unstable]`.
AllowInternalUnstable(ThinVec<(Symbol, Span)>),
+
+ /// Represents `#[rustc_default_body_unstable]`.
BodyStability {
stability: DefaultBodyStability,
/// Span of the `#[rustc_default_body_unstable(...)]` attribute
span: Span,
},
+
+ /// Represents `#[rustc_confusables]`.
Confusables {
symbols: ThinVec<Symbol>,
// FIXME(jdonszelmann): remove when target validation code is moved
first_span: Span,
},
+
+ /// Represents `#[rustc_const_stable]` and `#[rustc_const_unstable]`.
ConstStability {
stability: PartialConstStability,
/// Span of the `#[rustc_const_stable(...)]` or `#[rustc_const_unstable(...)]` attribute
span: Span,
},
+
+ /// Represents `#[rustc_const_stable_indirect]`.
ConstStabilityIndirect,
- Deprecation {
- deprecation: Deprecation,
- span: Span,
- },
- Diagnostic(DiagnosticAttribute),
- DocComment {
- style: AttrStyle,
- kind: CommentKind,
- span: Span,
- comment: Symbol,
- },
+
+ /// Represents [`#[deprecated]`](https://doc.rust-lang.org/stable/reference/attributes/diagnostics.html#the-deprecated-attribute).
+ Deprecation { deprecation: Deprecation, span: Span },
+
+ /// Represents [`#[doc]`](https://doc.rust-lang.org/stable/rustdoc/write-documentation/the-doc-attribute.html).
+ DocComment { style: AttrStyle, kind: CommentKind, span: Span, comment: Symbol },
+
+ /// Represents `#[rustc_macro_transparency]`.
MacroTransparency(Transparency),
+
+ /// Represents [`#[repr]`](https://doc.rust-lang.org/stable/reference/type-layout.html#representations).
Repr(ThinVec<(ReprAttr, Span)>),
+
+ /// Represents `#[stable]`, `#[unstable]` and `#[rustc_allowed_through_unstable_modules]`.
Stability {
stability: Stability,
- /// Span of the `#[stable(...)]` or `#[unstable(...)]` attribute
+ /// Span of the attribute.
span: Span,
},
// tidy-alphabetical-end
diff --git a/compiler/rustc_attr_parsing/src/attributes/mod.rs b/compiler/rustc_attr_parsing/src/attributes/mod.rs
index bf18e10..7cceca3 100644
--- a/compiler/rustc_attr_parsing/src/attributes/mod.rs
+++ b/compiler/rustc_attr_parsing/src/attributes/mod.rs
@@ -12,7 +12,7 @@
//! - [`CombineAttributeParser`]: makes it easy to implement an attribute which should combine the
//! contents of attributes, if an attribute appear multiple times in a list
//!
-//! Attributes should be added to [`ATTRIBUTE_MAPPING`](crate::context::ATTRIBUTE_MAPPING) to be parsed.
+//! Attributes should be added to [`ATTRIBUTE_PARSERS`](crate::context::ATTRIBUTE_PARSERS) to be parsed.
use std::marker::PhantomData;
@@ -51,6 +51,9 @@
/// whether it has seen the attribute it has been looking for.
///
/// The state machine is automatically reset to parse attributes on the next item.
+///
+/// For a simpler attribute parsing interface, consider using [`SingleAttributeParser`]
+/// or [`CombineAttributeParser`] instead.
pub(crate) trait AttributeParser: Default + 'static {
/// The symbols for the attributes that this parser is interested in.
///
@@ -59,6 +62,12 @@ pub(crate) trait AttributeParser: Default + 'static {
/// The parser has gotten a chance to accept the attributes on an item,
/// here it can produce an attribute.
+ ///
+ /// All finalize methods of all parsers are unconditionally called.
+ /// This means you can't unconditionally return `Some` here,
+ /// that'd be equivalent to unconditionally applying an attribute to
+ /// every single syntax item that could have attributes applied to it.
+ /// Your accept mappings should determine whether this returns something.
fn finalize(self, cx: &FinalizeContext<'_>) -> Option<AttributeKind>;
}
diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs
index c02760d..35fb768 100644
--- a/compiler/rustc_attr_parsing/src/context.rs
+++ b/compiler/rustc_attr_parsing/src/context.rs
@@ -22,7 +22,7 @@
use crate::attributes::{AttributeParser as _, Combine, Single};
use crate::parser::{ArgParser, MetaItemParser};
-macro_rules! attribute_groups {
+macro_rules! attribute_parsers {
(
pub(crate) static $name: ident = [$($names: ty),* $(,)?];
) => {
@@ -63,8 +63,8 @@ macro_rules! attribute_groups {
};
}
-attribute_groups!(
- pub(crate) static ATTRIBUTE_MAPPING = [
+attribute_parsers!(
+ pub(crate) static ATTRIBUTE_PARSERS = [
// tidy-alphabetical-start
BodyStabilityParser,
ConfusablesParser,
@@ -90,7 +90,7 @@ macro_rules! attribute_groups {
///
/// Gives [`AttributeParser`]s enough information to create errors, for example.
pub(crate) struct AcceptContext<'a> {
- pub(crate) group_cx: &'a FinalizeContext<'a>,
+ pub(crate) finalize_cx: &'a FinalizeContext<'a>,
/// The span of the attribute currently being parsed
pub(crate) attr_span: Span,
}
@@ -109,7 +109,7 @@ impl<'a> Deref for AcceptContext<'a> {
type Target = FinalizeContext<'a>;
fn deref(&self) -> &Self::Target {
- &self.group_cx
+ &self.finalize_cx
}
}
@@ -219,7 +219,7 @@ pub fn parse_attribute_list<'a>(
) -> Vec<Attribute> {
let mut attributes = Vec::new();
- let group_cx = FinalizeContext { cx: self, target_span };
+ let finalize_cx = FinalizeContext { cx: self, target_span };
for attr in attrs {
// If we're only looking for a single attribute, skip all the ones we don't care about.
@@ -268,9 +268,11 @@ pub fn parse_attribute_list<'a>(
let args = parser.args();
let parts = path.segments().map(|i| i.name).collect::<Vec<_>>();
- if let Some(accept) = ATTRIBUTE_MAPPING.0.get(parts.as_slice()) {
- let cx =
- AcceptContext { group_cx: &group_cx, attr_span: lower_span(attr.span) };
+ if let Some(accept) = ATTRIBUTE_PARSERS.0.get(parts.as_slice()) {
+ let cx = AcceptContext {
+ finalize_cx: &finalize_cx,
+ attr_span: lower_span(attr.span),
+ };
accept(&cx, &args)
} else {
@@ -302,8 +304,8 @@ pub fn parse_attribute_list<'a>(
}
let mut parsed_attributes = Vec::new();
- for f in &ATTRIBUTE_MAPPING.1 {
- if let Some(attr) = f(&group_cx) {
+ for f in &ATTRIBUTE_PARSERS.1 {
+ if let Some(attr) = f(&finalize_cx) {
parsed_attributes.push(Attribute::Parsed(attr));
}
}
diff --git a/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs b/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs
index a1c7467..0a11446 100644
--- a/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs
+++ b/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs
@@ -141,8 +141,11 @@ fn convert(
}
if !tcx.recursion_limit().value_within_limit(iteration) {
+ // This may actually be reachable. If so, we should convert
+ // this to a proper error/consider whether we should detect
+ // this somewhere else.
bug!(
- "FIXME(-Znext-solver): Overflowed when processing region obligations: {outlives_predicates:#?}"
+ "unexpected overflowed when processing region obligations: {outlives_predicates:#?}"
);
}
diff --git a/compiler/rustc_builtin_macros/src/lib.rs b/compiler/rustc_builtin_macros/src/lib.rs
index aa52c3b..9e7d0ec 100644
--- a/compiler/rustc_builtin_macros/src/lib.rs
+++ b/compiler/rustc_builtin_macros/src/lib.rs
@@ -15,7 +15,6 @@
#![feature(proc_macro_internals)]
#![feature(proc_macro_quote)]
#![feature(rustdoc_internals)]
-#![feature(string_from_utf8_lossy_owned)]
#![feature(try_blocks)]
#![recursion_limit = "256"]
// tidy-alphabetical-end
diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
index 27a5df8..1d1cf88 100644
--- a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
+++ b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
@@ -812,11 +812,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
dest.write_cvalue(fx, val);
}
- sym::pref_align_of
- | sym::needs_drop
- | sym::type_id
- | sym::type_name
- | sym::variant_count => {
+ sym::needs_drop | sym::type_id | sym::type_name | sym::variant_count => {
intrinsic_args!(fx, args => (); intrinsic);
let const_val = fx
@@ -875,7 +871,6 @@ fn codegen_regular_intrinsic_call<'tcx>(
let ptr = ptr.load_scalar(fx);
let ty = generic_args.type_at(0);
- let _ord = generic_args.const_at(1).to_value(); // FIXME: forward this to cranelift once they support that
match ty.kind() {
ty::Uint(UintTy::U128) | ty::Int(IntTy::I128) => {
// FIXME implement 128bit atomics
@@ -906,7 +901,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
let val = CValue::by_val(val, fx.layout_of(ty));
ret.write_cvalue(fx, val);
}
- _ if intrinsic.as_str().starts_with("atomic_store") => {
+ sym::atomic_store => {
intrinsic_args!(fx, args => (ptr, val); intrinsic);
let ptr = ptr.load_scalar(fx);
@@ -939,7 +934,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
fx.bcx.ins().atomic_store(MemFlags::trusted(), val, ptr);
}
- _ if intrinsic.as_str().starts_with("atomic_xchg") => {
+ sym::atomic_xchg => {
intrinsic_args!(fx, args => (ptr, new); intrinsic);
let ptr = ptr.load_scalar(fx);
@@ -960,8 +955,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
let old = CValue::by_val(old, layout);
ret.write_cvalue(fx, old);
}
- _ if intrinsic.as_str().starts_with("atomic_cxchg") => {
- // both atomic_cxchg_* and atomic_cxchgweak_*
+ sym::atomic_cxchg | sym::atomic_cxchgweak => {
intrinsic_args!(fx, args => (ptr, test_old, new); intrinsic);
let ptr = ptr.load_scalar(fx);
@@ -984,7 +978,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
ret.write_cvalue(fx, ret_val)
}
- _ if intrinsic.as_str().starts_with("atomic_xadd") => {
+ sym::atomic_xadd => {
intrinsic_args!(fx, args => (ptr, amount); intrinsic);
let ptr = ptr.load_scalar(fx);
@@ -1006,7 +1000,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
let old = CValue::by_val(old, layout);
ret.write_cvalue(fx, old);
}
- _ if intrinsic.as_str().starts_with("atomic_xsub") => {
+ sym::atomic_xsub => {
intrinsic_args!(fx, args => (ptr, amount); intrinsic);
let ptr = ptr.load_scalar(fx);
@@ -1028,7 +1022,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
let old = CValue::by_val(old, layout);
ret.write_cvalue(fx, old);
}
- _ if intrinsic.as_str().starts_with("atomic_and") => {
+ sym::atomic_and => {
intrinsic_args!(fx, args => (ptr, src); intrinsic);
let ptr = ptr.load_scalar(fx);
@@ -1049,7 +1043,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
let old = CValue::by_val(old, layout);
ret.write_cvalue(fx, old);
}
- _ if intrinsic.as_str().starts_with("atomic_or") => {
+ sym::atomic_or => {
intrinsic_args!(fx, args => (ptr, src); intrinsic);
let ptr = ptr.load_scalar(fx);
@@ -1070,7 +1064,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
let old = CValue::by_val(old, layout);
ret.write_cvalue(fx, old);
}
- _ if intrinsic.as_str().starts_with("atomic_xor") => {
+ sym::atomic_xor => {
intrinsic_args!(fx, args => (ptr, src); intrinsic);
let ptr = ptr.load_scalar(fx);
@@ -1091,7 +1085,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
let old = CValue::by_val(old, layout);
ret.write_cvalue(fx, old);
}
- _ if intrinsic.as_str().starts_with("atomic_nand") => {
+ sym::atomic_nand => {
intrinsic_args!(fx, args => (ptr, src); intrinsic);
let ptr = ptr.load_scalar(fx);
@@ -1112,7 +1106,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
let old = CValue::by_val(old, layout);
ret.write_cvalue(fx, old);
}
- _ if intrinsic.as_str().starts_with("atomic_max") => {
+ sym::atomic_max => {
intrinsic_args!(fx, args => (ptr, src); intrinsic);
let ptr = ptr.load_scalar(fx);
@@ -1133,7 +1127,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
let old = CValue::by_val(old, layout);
ret.write_cvalue(fx, old);
}
- _ if intrinsic.as_str().starts_with("atomic_umax") => {
+ sym::atomic_umax => {
intrinsic_args!(fx, args => (ptr, src); intrinsic);
let ptr = ptr.load_scalar(fx);
@@ -1154,7 +1148,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
let old = CValue::by_val(old, layout);
ret.write_cvalue(fx, old);
}
- _ if intrinsic.as_str().starts_with("atomic_min") => {
+ sym::atomic_min => {
intrinsic_args!(fx, args => (ptr, src); intrinsic);
let ptr = ptr.load_scalar(fx);
@@ -1175,7 +1169,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
let old = CValue::by_val(old, layout);
ret.write_cvalue(fx, old);
}
- _ if intrinsic.as_str().starts_with("atomic_umin") => {
+ sym::atomic_umin => {
intrinsic_args!(fx, args => (ptr, src); intrinsic);
let ptr = ptr.load_scalar(fx);
diff --git a/compiler/rustc_codegen_gcc/build_system/build_sysroot/Cargo.toml b/compiler/rustc_codegen_gcc/build_system/build_sysroot/Cargo.toml
index 2415207..931f609 100644
--- a/compiler/rustc_codegen_gcc/build_system/build_sysroot/Cargo.toml
+++ b/compiler/rustc_codegen_gcc/build_system/build_sysroot/Cargo.toml
@@ -6,7 +6,6 @@
[dependencies]
core = { path = "./sysroot_src/library/core" }
-compiler_builtins = "0.1"
alloc = { path = "./sysroot_src/library/alloc" }
std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] }
test = { path = "./sysroot_src/library/test" }
@@ -16,6 +15,7 @@
rustc-std-workspace-core = { path = "./sysroot_src/library/rustc-std-workspace-core" }
rustc-std-workspace-alloc = { path = "./sysroot_src/library/rustc-std-workspace-alloc" }
rustc-std-workspace-std = { path = "./sysroot_src/library/rustc-std-workspace-std" }
+compiler_builtins = { path = "./sysroot_src/library/compiler-builtins/compiler-builtins" }
# For compiler-builtins we always use a high number of codegen units.
# The goal here is to place every single intrinsic into its own object
diff --git a/compiler/rustc_codegen_gcc/example/alloc_system.rs b/compiler/rustc_codegen_gcc/example/alloc_system.rs
index 945d340..4d70122 100644
--- a/compiler/rustc_codegen_gcc/example/alloc_system.rs
+++ b/compiler/rustc_codegen_gcc/example/alloc_system.rs
@@ -8,6 +8,7 @@
// add fast paths for low alignment values.
#[cfg(any(target_arch = "x86",
target_arch = "arm",
+ target_arch = "loongarch32",
target_arch = "m68k",
target_arch = "mips",
target_arch = "mips32r6",
diff --git a/compiler/rustc_codegen_gcc/messages.ftl b/compiler/rustc_codegen_gcc/messages.ftl
index 882fff8..546bfc8 100644
--- a/compiler/rustc_codegen_gcc/messages.ftl
+++ b/compiler/rustc_codegen_gcc/messages.ftl
@@ -2,9 +2,6 @@
unknown feature specified for `-Ctarget-feature`: `{$feature}`
.note = features must begin with a `+` to enable or `-` to disable it
-codegen_gcc_invalid_minimum_alignment =
- invalid minimum global alignment: {$err}
-
codegen_gcc_forbidden_ctarget_feature =
target feature `{$feature}` cannot be toggled with `-Ctarget-feature`: {$reason}
diff --git a/compiler/rustc_codegen_gcc/src/consts.rs b/compiler/rustc_codegen_gcc/src/consts.rs
index deb13dd..1690641 100644
--- a/compiler/rustc_codegen_gcc/src/consts.rs
+++ b/compiler/rustc_codegen_gcc/src/consts.rs
@@ -18,7 +18,6 @@
use crate::base;
use crate::context::CodegenCx;
-use crate::errors::InvalidMinimumAlignment;
use crate::type_of::LayoutGccExt;
fn set_global_alignment<'gcc, 'tcx>(
@@ -29,13 +28,8 @@ fn set_global_alignment<'gcc, 'tcx>(
// The target may require greater alignment for globals than the type does.
// Note: GCC and Clang also allow `__attribute__((aligned))` on variables,
// which can force it to be smaller. Rust doesn't support this yet.
- if let Some(min) = cx.sess().target.min_global_align {
- match Align::from_bits(min) {
- Ok(min) => align = align.max(min),
- Err(err) => {
- cx.sess().dcx().emit_err(InvalidMinimumAlignment { err: err.to_string() });
- }
- }
+ if let Some(min_global) = cx.sess().target.min_global_align {
+ align = Ord::max(align, min_global);
}
gv.set_alignment(align.bytes() as i32);
}
diff --git a/compiler/rustc_codegen_gcc/src/errors.rs b/compiler/rustc_codegen_gcc/src/errors.rs
index 1b59b9a..ccd9abe 100644
--- a/compiler/rustc_codegen_gcc/src/errors.rs
+++ b/compiler/rustc_codegen_gcc/src/errors.rs
@@ -48,12 +48,6 @@ pub(crate) struct UnwindingInlineAsm {
}
#[derive(Diagnostic)]
-#[diag(codegen_gcc_invalid_minimum_alignment)]
-pub(crate) struct InvalidMinimumAlignment {
- pub err: String,
-}
-
-#[derive(Diagnostic)]
#[diag(codegen_gcc_copy_bitcode)]
pub(crate) struct CopyBitcode {
pub err: std::io::Error,
diff --git a/compiler/rustc_codegen_gcc/src/lib.rs b/compiler/rustc_codegen_gcc/src/lib.rs
index f79ba2d..0591ffa 100644
--- a/compiler/rustc_codegen_gcc/src/lib.rs
+++ b/compiler/rustc_codegen_gcc/src/lib.rs
@@ -16,7 +16,7 @@
#![allow(internal_features)]
#![doc(rust_logo)]
#![feature(rustdoc_internals)]
-#![feature(rustc_private, decl_macro, never_type, trusted_len)]
+#![feature(rustc_private)]
#![allow(broken_intra_doc_links)]
#![recursion_limit = "256"]
#![warn(rust_2018_idioms)]
diff --git a/compiler/rustc_codegen_llvm/Cargo.toml b/compiler/rustc_codegen_llvm/Cargo.toml
index bf8ec8c..88efc8a 100644
--- a/compiler/rustc_codegen_llvm/Cargo.toml
+++ b/compiler/rustc_codegen_llvm/Cargo.toml
@@ -15,7 +15,7 @@
itertools = "0.12"
libc = "0.2"
measureme = "12.0.1"
-object = { version = "0.36.3", default-features = false, features = ["std", "read"] }
+object = { version = "0.37.0", default-features = false, features = ["std", "read"] }
rustc-demangle = "0.1.21"
rustc_abi = { path = "../rustc_abi" }
rustc_ast = { path = "../rustc_ast" }
diff --git a/compiler/rustc_codegen_llvm/messages.ftl b/compiler/rustc_codegen_llvm/messages.ftl
index 41391b0..bda121c 100644
--- a/compiler/rustc_codegen_llvm/messages.ftl
+++ b/compiler/rustc_codegen_llvm/messages.ftl
@@ -19,12 +19,6 @@
codegen_llvm_from_llvm_optimization_diag = {$filename}:{$line}:{$column} {$pass_name} ({$kind}): {$message}
-codegen_llvm_invalid_minimum_alignment_not_power_of_two =
- invalid minimum global alignment: {$align} is not power of 2
-
-codegen_llvm_invalid_minimum_alignment_too_large =
- invalid minimum global alignment: {$align} is too large
-
codegen_llvm_load_bitcode = failed to load bitcode of module "{$name}"
codegen_llvm_load_bitcode_with_llvm_err = failed to load bitcode of module "{$name}": {$llvm_err}
diff --git a/compiler/rustc_codegen_llvm/src/asm.rs b/compiler/rustc_codegen_llvm/src/asm.rs
index 9e3893d..4185aef 100644
--- a/compiler/rustc_codegen_llvm/src/asm.rs
+++ b/compiler/rustc_codegen_llvm/src/asm.rs
@@ -251,7 +251,7 @@ fn codegen_inline_asm(
InlineAsmArch::Nvptx64 => {}
InlineAsmArch::PowerPC | InlineAsmArch::PowerPC64 => {}
InlineAsmArch::Hexagon => {}
- InlineAsmArch::LoongArch64 => {
+ InlineAsmArch::LoongArch32 | InlineAsmArch::LoongArch64 => {
constraints.extend_from_slice(&[
"~{$fcc0}".to_string(),
"~{$fcc1}".to_string(),
diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs
index 443c2ea..27fd097 100644
--- a/compiler/rustc_codegen_llvm/src/attributes.rs
+++ b/compiler/rustc_codegen_llvm/src/attributes.rs
@@ -5,6 +5,7 @@
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, PatchableFunctionEntry};
use rustc_middle::ty::{self, TyCtxt};
use rustc_session::config::{BranchProtection, FunctionReturn, OptLevel, PAuthKey, PacRet};
+use rustc_symbol_mangling::mangle_internal_symbol;
use rustc_target::spec::{FramePointer, SanitizerSet, StackProbeType, StackProtector};
use smallvec::SmallVec;
@@ -256,11 +257,11 @@ fn probestack_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
StackProbeType::Inline => "inline-asm",
// Flag our internal `__rust_probestack` function as the stack probe symbol.
// This is defined in the `compiler-builtins` crate for each architecture.
- StackProbeType::Call => "__rust_probestack",
+ StackProbeType::Call => &mangle_internal_symbol(cx.tcx, "__rust_probestack"),
// Pick from the two above based on the LLVM version.
StackProbeType::InlineOrCall { min_llvm_version_for_inline } => {
if llvm_util::get_version() < min_llvm_version_for_inline {
- "__rust_probestack"
+ &mangle_internal_symbol(cx.tcx, "__rust_probestack")
} else {
"inline-asm"
}
diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs
index 73def27..a4492d7 100644
--- a/compiler/rustc_codegen_llvm/src/consts.rs
+++ b/compiler/rustc_codegen_llvm/src/consts.rs
@@ -1,8 +1,6 @@
use std::ops::Range;
-use rustc_abi::{
- Align, AlignFromBytesError, HasDataLayout, Primitive, Scalar, Size, WrappingRange,
-};
+use rustc_abi::{Align, HasDataLayout, Primitive, Scalar, Size, WrappingRange};
use rustc_codegen_ssa::common;
use rustc_codegen_ssa::traits::*;
use rustc_hir::LangItem;
@@ -20,9 +18,7 @@
use tracing::{debug, instrument, trace};
use crate::common::{AsCCharPtr, CodegenCx};
-use crate::errors::{
- InvalidMinimumAlignmentNotPowerOfTwo, InvalidMinimumAlignmentTooLarge, SymbolAlreadyDefined,
-};
+use crate::errors::SymbolAlreadyDefined;
use crate::llvm::{self, True};
use crate::type_::Type;
use crate::type_of::LayoutLlvmExt;
@@ -149,22 +145,10 @@ fn set_global_alignment<'ll>(cx: &CodegenCx<'ll, '_>, gv: &'ll Value, mut align:
// The target may require greater alignment for globals than the type does.
// Note: GCC and Clang also allow `__attribute__((aligned))` on variables,
// which can force it to be smaller. Rust doesn't support this yet.
- if let Some(min) = cx.sess().target.min_global_align {
- match Align::from_bits(min) {
- Ok(min) => align = align.max(min),
- Err(err) => match err {
- AlignFromBytesError::NotPowerOfTwo(align) => {
- cx.sess().dcx().emit_err(InvalidMinimumAlignmentNotPowerOfTwo { align });
- }
- AlignFromBytesError::TooLarge(align) => {
- cx.sess().dcx().emit_err(InvalidMinimumAlignmentTooLarge { align });
- }
- },
- }
+ if let Some(min_global) = cx.sess().target.min_global_align {
+ align = Ord::max(align, min_global);
}
- unsafe {
- llvm::LLVMSetAlignment(gv, align.bytes() as u32);
- }
+ llvm::set_alignment(gv, align);
}
fn check_and_apply_linkage<'ll, 'tcx>(
diff --git a/compiler/rustc_codegen_llvm/src/errors.rs b/compiler/rustc_codegen_llvm/src/errors.rs
index ecf108f..eaafc68 100644
--- a/compiler/rustc_codegen_llvm/src/errors.rs
+++ b/compiler/rustc_codegen_llvm/src/errors.rs
@@ -58,18 +58,6 @@ pub(crate) struct SymbolAlreadyDefined<'a> {
}
#[derive(Diagnostic)]
-#[diag(codegen_llvm_invalid_minimum_alignment_not_power_of_two)]
-pub(crate) struct InvalidMinimumAlignmentNotPowerOfTwo {
- pub align: u64,
-}
-
-#[derive(Diagnostic)]
-#[diag(codegen_llvm_invalid_minimum_alignment_too_large)]
-pub(crate) struct InvalidMinimumAlignmentTooLarge {
- pub align: u64,
-}
-
-#[derive(Diagnostic)]
#[diag(codegen_llvm_sanitizer_memtag_requires_mte)]
pub(crate) struct SanitizerMemtagRequiresMte;
diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs
index fd376ea..6890923 100644
--- a/compiler/rustc_codegen_llvm/src/lib.rs
+++ b/compiler/rustc_codegen_llvm/src/lib.rs
@@ -9,7 +9,6 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![doc(rust_logo)]
#![feature(assert_matches)]
-#![feature(exact_size_is_empty)]
#![feature(extern_types)]
#![feature(file_buffered)]
#![feature(if_let_guard)]
diff --git a/compiler/rustc_codegen_ssa/Cargo.toml b/compiler/rustc_codegen_ssa/Cargo.toml
index 337c694..e9c4c25 100644
--- a/compiler/rustc_codegen_ssa/Cargo.toml
+++ b/compiler/rustc_codegen_ssa/Cargo.toml
@@ -54,7 +54,7 @@
# tidy-alphabetical-end
[dependencies.object]
-version = "0.36.2"
+version = "0.37.0"
default-features = false
features = ["read_core", "elf", "macho", "pe", "xcoff", "unaligned", "archive", "write", "wasm"]
diff --git a/compiler/rustc_codegen_ssa/messages.ftl b/compiler/rustc_codegen_ssa/messages.ftl
index acb4cba..91f6af7 100644
--- a/compiler/rustc_codegen_ssa/messages.ftl
+++ b/compiler/rustc_codegen_ssa/messages.ftl
@@ -8,8 +8,6 @@
codegen_ssa_archive_build_failure = failed to build archive at `{$path}`: {$error}
-codegen_ssa_atomic_compare_exchange = Atomic compare-exchange intrinsic missing failure memory ordering
-
codegen_ssa_autodiff_without_lto = using the autodiff feature requires using fat-lto
codegen_ssa_bare_instruction_set = `#[instruction_set]` requires an argument
@@ -206,8 +204,6 @@
codegen_ssa_missing_features = add the missing features in a `target_feature` attribute
-codegen_ssa_missing_memory_ordering = Atomic intrinsic missing memory ordering
-
codegen_ssa_missing_query_depgraph =
found CGU-reuse attribute but `-Zquery-dep-graph` was not specified
@@ -374,10 +370,6 @@
codegen_ssa_unknown_archive_kind =
Don't know how to build archive of type: {$kind}
-codegen_ssa_unknown_atomic_operation = unknown atomic operation
-
-codegen_ssa_unknown_atomic_ordering = unknown ordering in atomic intrinsic
-
codegen_ssa_unknown_reuse_kind = unknown cgu-reuse-kind `{$kind}` specified
codegen_ssa_unsupported_instruction_set = target does not support `#[instruction_set]`
diff --git a/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs b/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs
index 2c24378..74f3902 100644
--- a/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs
@@ -287,6 +287,7 @@ fn create_elf_raw_dylib_stub(sess: &Session, soname: &str, symbols: &[DllImport]
(Architecture::X86_64, None) => elf::EM_X86_64,
(Architecture::X86_64_X32, None) => elf::EM_X86_64,
(Architecture::Hexagon, None) => elf::EM_HEXAGON,
+ (Architecture::LoongArch32, None) => elf::EM_LOONGARCH,
(Architecture::LoongArch64, None) => elf::EM_LOONGARCH,
(Architecture::M68k, None) => elf::EM_68K,
(Architecture::Mips, None) => elf::EM_MIPS,
diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs
index ec46c71..a16862c 100644
--- a/compiler/rustc_codegen_ssa/src/back/metadata.rs
+++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs
@@ -348,7 +348,7 @@ pub(super) fn elf_e_flags(architecture: Architecture, sess: &Session) -> u32 {
e_flags
}
- Architecture::LoongArch64 => {
+ Architecture::LoongArch32 | Architecture::LoongArch64 => {
// Source: https://github.com/loongson/la-abi-specs/blob/release/laelf.adoc#e_flags-identifies-abi-type-and-version
let mut e_flags: u32 = elf::EF_LARCH_OBJABI_V1;
diff --git a/compiler/rustc_codegen_ssa/src/errors.rs b/compiler/rustc_codegen_ssa/src/errors.rs
index 572d7b1..f843347 100644
--- a/compiler/rustc_codegen_ssa/src/errors.rs
+++ b/compiler/rustc_codegen_ssa/src/errors.rs
@@ -797,22 +797,6 @@ pub(crate) struct ShuffleIndicesEvaluation {
}
#[derive(Diagnostic)]
-#[diag(codegen_ssa_missing_memory_ordering)]
-pub(crate) struct MissingMemoryOrdering;
-
-#[derive(Diagnostic)]
-#[diag(codegen_ssa_unknown_atomic_ordering)]
-pub(crate) struct UnknownAtomicOrdering;
-
-#[derive(Diagnostic)]
-#[diag(codegen_ssa_atomic_compare_exchange)]
-pub(crate) struct AtomicCompareExchange;
-
-#[derive(Diagnostic)]
-#[diag(codegen_ssa_unknown_atomic_operation)]
-pub(crate) struct UnknownAtomicOperation;
-
-#[derive(Diagnostic)]
pub enum InvalidMonomorphization<'tcx> {
#[diag(codegen_ssa_invalid_monomorphization_basic_integer_type, code = E0511)]
BasicIntegerType {
diff --git a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs
index 8c6f520..e217c09 100644
--- a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs
@@ -8,9 +8,10 @@
use super::FunctionCx;
use super::operand::OperandRef;
use super::place::PlaceRef;
+use crate::common::{AtomicRmwBinOp, SynchronizationScope};
use crate::errors::InvalidMonomorphization;
use crate::traits::*;
-use crate::{MemFlags, errors, meth, size_of_val};
+use crate::{MemFlags, meth, size_of_val};
fn copy_intrinsic<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
@@ -62,7 +63,6 @@ pub fn codegen_intrinsic_call(
let span = source_info.span;
let name = bx.tcx().item_name(instance.def_id());
- let name_str = name.as_str();
let fn_args = instance.args;
// If we're swapping something that's *not* an `OperandValue::Ref`,
@@ -89,14 +89,13 @@ pub fn codegen_intrinsic_call(
}
}
- let ret_llval = |bx: &mut Bx, llval| {
- if result.layout.ty.is_bool() {
- let val = bx.from_immediate(llval);
- bx.store_to_place(val, result.val);
- } else if !result.layout.ty.is_unit() {
- bx.store_to_place(llval, result.val);
- }
- Ok(())
+ let invalid_monomorphization_int_type = |ty| {
+ bx.tcx().dcx().emit_err(InvalidMonomorphization::BasicIntegerType { span, name, ty });
+ };
+
+ let parse_atomic_ordering = |ord: ty::Value<'tcx>| {
+ let discr = ord.valtree.unwrap_branch()[0].unwrap_leaf();
+ discr.to_atomic_ordering()
};
let llval = match name {
@@ -151,11 +150,7 @@ pub fn codegen_intrinsic_call(
}
value
}
- sym::pref_align_of
- | sym::needs_drop
- | sym::type_id
- | sym::type_name
- | sym::variant_count => {
+ sym::needs_drop | sym::type_id | sym::type_name | sym::variant_count => {
let value = bx.tcx().const_eval_instance(bx.typing_env(), instance, span).unwrap();
OperandRef::from_const(bx, value, result.layout.ty).immediate_or_packed_pair(bx)
}
@@ -336,183 +331,144 @@ pub fn codegen_intrinsic_call(
}
}
- // This requires that atomic intrinsics follow a specific naming pattern:
- // "atomic_<operation>[_<ordering>]"
- name if let Some(atomic) = name_str.strip_prefix("atomic_") => {
- use rustc_middle::ty::AtomicOrdering::*;
-
- use crate::common::{AtomicRmwBinOp, SynchronizationScope};
-
- let invalid_monomorphization = |ty| {
- bx.tcx().dcx().emit_err(InvalidMonomorphization::BasicIntegerType {
- span,
- name,
- ty,
- });
- };
-
- let parse_const_generic_ordering = |ord: ty::Value<'tcx>| {
- let discr = ord.valtree.unwrap_branch()[0].unwrap_leaf();
- discr.to_atomic_ordering()
- };
-
- // Some intrinsics have the ordering already converted to a const generic parameter, we handle those first.
- match name {
- sym::atomic_load => {
- let ty = fn_args.type_at(0);
- let ordering = fn_args.const_at(1).to_value();
- if !(int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr()) {
- invalid_monomorphization(ty);
- return Ok(());
- }
- let layout = bx.layout_of(ty);
- let source = args[0].immediate();
- let llval = bx.atomic_load(
- bx.backend_type(layout),
- source,
- parse_const_generic_ordering(ordering),
- layout.size,
- );
-
- return ret_llval(bx, llval);
- }
-
- // The rest falls back to below.
- _ => {}
+ sym::atomic_load => {
+ let ty = fn_args.type_at(0);
+ if !(int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr()) {
+ invalid_monomorphization_int_type(ty);
+ return Ok(());
}
-
- let Some((instruction, ordering)) = atomic.split_once('_') else {
- bx.sess().dcx().emit_fatal(errors::MissingMemoryOrdering);
- };
-
- let parse_ordering = |bx: &Bx, s| match s {
- "relaxed" => Relaxed,
- "acquire" => Acquire,
- "release" => Release,
- "acqrel" => AcqRel,
- "seqcst" => SeqCst,
- _ => bx.sess().dcx().emit_fatal(errors::UnknownAtomicOrdering),
- };
-
- match instruction {
- "cxchg" | "cxchgweak" => {
- let Some((success, failure)) = ordering.split_once('_') else {
- bx.sess().dcx().emit_fatal(errors::AtomicCompareExchange);
- };
- let ty = fn_args.type_at(0);
- if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr() {
- let weak = instruction == "cxchgweak";
- let dst = args[0].immediate();
- let cmp = args[1].immediate();
- let src = args[2].immediate();
- let (val, success) = bx.atomic_cmpxchg(
- dst,
- cmp,
- src,
- parse_ordering(bx, success),
- parse_ordering(bx, failure),
- weak,
- );
- let val = bx.from_immediate(val);
- let success = bx.from_immediate(success);
-
- let dest = result.project_field(bx, 0);
- bx.store_to_place(val, dest.val);
- let dest = result.project_field(bx, 1);
- bx.store_to_place(success, dest.val);
- } else {
- invalid_monomorphization(ty);
- }
- return Ok(());
- }
-
- "store" => {
- let ty = fn_args.type_at(0);
- if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr() {
- let size = bx.layout_of(ty).size;
- let val = args[1].immediate();
- let ptr = args[0].immediate();
- bx.atomic_store(val, ptr, parse_ordering(bx, ordering), size);
- } else {
- invalid_monomorphization(ty);
- }
- return Ok(());
- }
-
- "fence" => {
- bx.atomic_fence(
- parse_ordering(bx, ordering),
- SynchronizationScope::CrossThread,
- );
- return Ok(());
- }
-
- "singlethreadfence" => {
- bx.atomic_fence(
- parse_ordering(bx, ordering),
- SynchronizationScope::SingleThread,
- );
- return Ok(());
- }
-
- // These are all AtomicRMW ops
- "max" | "min" => {
- let atom_op = if instruction == "max" {
- AtomicRmwBinOp::AtomicMax
- } else {
- AtomicRmwBinOp::AtomicMin
- };
-
- let ty = fn_args.type_at(0);
- if matches!(ty.kind(), ty::Int(_)) {
- let ptr = args[0].immediate();
- let val = args[1].immediate();
- bx.atomic_rmw(atom_op, ptr, val, parse_ordering(bx, ordering))
- } else {
- invalid_monomorphization(ty);
- return Ok(());
- }
- }
- "umax" | "umin" => {
- let atom_op = if instruction == "umax" {
- AtomicRmwBinOp::AtomicUMax
- } else {
- AtomicRmwBinOp::AtomicUMin
- };
-
- let ty = fn_args.type_at(0);
- if matches!(ty.kind(), ty::Uint(_)) {
- let ptr = args[0].immediate();
- let val = args[1].immediate();
- bx.atomic_rmw(atom_op, ptr, val, parse_ordering(bx, ordering))
- } else {
- invalid_monomorphization(ty);
- return Ok(());
- }
- }
- op => {
- let atom_op = match op {
- "xchg" => AtomicRmwBinOp::AtomicXchg,
- "xadd" => AtomicRmwBinOp::AtomicAdd,
- "xsub" => AtomicRmwBinOp::AtomicSub,
- "and" => AtomicRmwBinOp::AtomicAnd,
- "nand" => AtomicRmwBinOp::AtomicNand,
- "or" => AtomicRmwBinOp::AtomicOr,
- "xor" => AtomicRmwBinOp::AtomicXor,
- _ => bx.sess().dcx().emit_fatal(errors::UnknownAtomicOperation),
- };
-
- let ty = fn_args.type_at(0);
- if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr() {
- let ptr = args[0].immediate();
- let val = args[1].immediate();
- bx.atomic_rmw(atom_op, ptr, val, parse_ordering(bx, ordering))
- } else {
- invalid_monomorphization(ty);
- return Ok(());
- }
- }
+ let ordering = fn_args.const_at(1).to_value();
+ let layout = bx.layout_of(ty);
+ let source = args[0].immediate();
+ bx.atomic_load(
+ bx.backend_type(layout),
+ source,
+ parse_atomic_ordering(ordering),
+ layout.size,
+ )
+ }
+ sym::atomic_store => {
+ let ty = fn_args.type_at(0);
+ if !(int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr()) {
+ invalid_monomorphization_int_type(ty);
+ return Ok(());
}
+ let ordering = fn_args.const_at(1).to_value();
+ let size = bx.layout_of(ty).size;
+ let val = args[1].immediate();
+ let ptr = args[0].immediate();
+ bx.atomic_store(val, ptr, parse_atomic_ordering(ordering), size);
+ return Ok(());
+ }
+ sym::atomic_cxchg | sym::atomic_cxchgweak => {
+ let ty = fn_args.type_at(0);
+ if !(int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr()) {
+ invalid_monomorphization_int_type(ty);
+ return Ok(());
+ }
+ let succ_ordering = fn_args.const_at(1).to_value();
+ let fail_ordering = fn_args.const_at(2).to_value();
+ let weak = name == sym::atomic_cxchgweak;
+ let dst = args[0].immediate();
+ let cmp = args[1].immediate();
+ let src = args[2].immediate();
+ let (val, success) = bx.atomic_cmpxchg(
+ dst,
+ cmp,
+ src,
+ parse_atomic_ordering(succ_ordering),
+ parse_atomic_ordering(fail_ordering),
+ weak,
+ );
+ let val = bx.from_immediate(val);
+ let success = bx.from_immediate(success);
+
+ let dest = result.project_field(bx, 0);
+ bx.store_to_place(val, dest.val);
+ let dest = result.project_field(bx, 1);
+ bx.store_to_place(success, dest.val);
+
+ return Ok(());
+ }
+ // These are all AtomicRMW ops
+ sym::atomic_max | sym::atomic_min => {
+ let atom_op = if name == sym::atomic_max {
+ AtomicRmwBinOp::AtomicMax
+ } else {
+ AtomicRmwBinOp::AtomicMin
+ };
+
+ let ty = fn_args.type_at(0);
+ if matches!(ty.kind(), ty::Int(_)) {
+ let ordering = fn_args.const_at(1).to_value();
+ let ptr = args[0].immediate();
+ let val = args[1].immediate();
+ bx.atomic_rmw(atom_op, ptr, val, parse_atomic_ordering(ordering))
+ } else {
+ invalid_monomorphization_int_type(ty);
+ return Ok(());
+ }
+ }
+ sym::atomic_umax | sym::atomic_umin => {
+ let atom_op = if name == sym::atomic_umax {
+ AtomicRmwBinOp::AtomicUMax
+ } else {
+ AtomicRmwBinOp::AtomicUMin
+ };
+
+ let ty = fn_args.type_at(0);
+ if matches!(ty.kind(), ty::Uint(_)) {
+ let ordering = fn_args.const_at(1).to_value();
+ let ptr = args[0].immediate();
+ let val = args[1].immediate();
+ bx.atomic_rmw(atom_op, ptr, val, parse_atomic_ordering(ordering))
+ } else {
+ invalid_monomorphization_int_type(ty);
+ return Ok(());
+ }
+ }
+ sym::atomic_xchg
+ | sym::atomic_xadd
+ | sym::atomic_xsub
+ | sym::atomic_and
+ | sym::atomic_nand
+ | sym::atomic_or
+ | sym::atomic_xor => {
+ let atom_op = match name {
+ sym::atomic_xchg => AtomicRmwBinOp::AtomicXchg,
+ sym::atomic_xadd => AtomicRmwBinOp::AtomicAdd,
+ sym::atomic_xsub => AtomicRmwBinOp::AtomicSub,
+ sym::atomic_and => AtomicRmwBinOp::AtomicAnd,
+ sym::atomic_nand => AtomicRmwBinOp::AtomicNand,
+ sym::atomic_or => AtomicRmwBinOp::AtomicOr,
+ sym::atomic_xor => AtomicRmwBinOp::AtomicXor,
+ _ => unreachable!(),
+ };
+
+ let ty = fn_args.type_at(0);
+ if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_raw_ptr() {
+ let ordering = fn_args.const_at(1).to_value();
+ let ptr = args[0].immediate();
+ let val = args[1].immediate();
+ bx.atomic_rmw(atom_op, ptr, val, parse_atomic_ordering(ordering))
+ } else {
+ invalid_monomorphization_int_type(ty);
+ return Ok(());
+ }
+ }
+ sym::atomic_fence => {
+ let ordering = fn_args.const_at(0).to_value();
+ bx.atomic_fence(parse_atomic_ordering(ordering), SynchronizationScope::CrossThread);
+ return Ok(());
+ }
+
+ sym::atomic_singlethreadfence => {
+ let ordering = fn_args.const_at(0).to_value();
+ bx.atomic_fence(
+ parse_atomic_ordering(ordering),
+ SynchronizationScope::SingleThread,
+ );
+ return Ok(());
}
sym::nontemporal_store => {
@@ -556,7 +512,13 @@ pub fn codegen_intrinsic_call(
}
};
- ret_llval(bx, llval)
+ if result.layout.ty.is_bool() {
+ let val = bx.from_immediate(llval);
+ bx.store_to_place(val, result.val);
+ } else if !result.layout.ty.is_unit() {
+ bx.store_to_place(llval, result.val);
+ }
+ Ok(())
}
}
diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs
index 5c14fe5..b62ac89 100644
--- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs
@@ -278,7 +278,7 @@ pub(crate) fn codegen_transmute_operand(
{
let from_backend_ty = bx.backend_type(operand.layout);
let to_backend_ty = bx.backend_type(cast);
- Some(OperandValue::Immediate(self.transmute_immediate(
+ Some(OperandValue::Immediate(transmute_immediate(
bx,
imm,
from_scalar,
@@ -303,8 +303,8 @@ pub(crate) fn codegen_transmute_operand(
let out_a_ibty = bx.scalar_pair_element_backend_type(cast, 0, false);
let out_b_ibty = bx.scalar_pair_element_backend_type(cast, 1, false);
Some(OperandValue::Pair(
- self.transmute_immediate(bx, imm_a, in_a, in_a_ibty, out_a, out_a_ibty),
- self.transmute_immediate(bx, imm_b, in_b, in_b_ibty, out_b, out_b_ibty),
+ transmute_immediate(bx, imm_a, in_a, in_a_ibty, out_a, out_a_ibty),
+ transmute_immediate(bx, imm_b, in_b, in_b_ibty, out_b, out_b_ibty),
))
} else {
None
@@ -332,7 +332,7 @@ fn cast_immediate(
// valid ranges. For example, `char`s are passed as just `i32`, with no
// way for LLVM to know that they're 0x10FFFF at most. Thus we assume
// the range of the input value too, not just the output range.
- self.assume_scalar_range(bx, imm, from_scalar, from_backend_ty);
+ assume_scalar_range(bx, imm, from_scalar, from_backend_ty);
imm = match (from_scalar.primitive(), to_scalar.primitive()) {
(Int(_, is_signed), Int(..)) => bx.intcast(imm, to_backend_ty, is_signed),
@@ -365,98 +365,6 @@ fn cast_immediate(
Some(imm)
}
- /// Transmutes one of the immediates from an [`OperandValue::Immediate`]
- /// or an [`OperandValue::Pair`] to an immediate of the target type.
- ///
- /// `to_backend_ty` must be the *non*-immediate backend type (so it will be
- /// `i8`, not `i1`, for `bool`-like types.)
- fn transmute_immediate(
- &self,
- bx: &mut Bx,
- mut imm: Bx::Value,
- from_scalar: abi::Scalar,
- from_backend_ty: Bx::Type,
- to_scalar: abi::Scalar,
- to_backend_ty: Bx::Type,
- ) -> Bx::Value {
- assert_eq!(from_scalar.size(self.cx), to_scalar.size(self.cx));
-
- // While optimizations will remove no-op transmutes, they might still be
- // there in debug or things that aren't no-op in MIR because they change
- // the Rust type but not the underlying layout/niche.
- if from_scalar == to_scalar && from_backend_ty == to_backend_ty {
- return imm;
- }
-
- use abi::Primitive::*;
- imm = bx.from_immediate(imm);
-
- // If we have a scalar, we must already know its range. Either
- //
- // 1) It's a parameter with `range` parameter metadata,
- // 2) It's something we `load`ed with `!range` metadata, or
- // 3) After a transmute we `assume`d the range (see below).
- //
- // That said, last time we tried removing this, it didn't actually help
- // the rustc-perf results, so might as well keep doing it
- // <https://github.com/rust-lang/rust/pull/135610#issuecomment-2599275182>
- self.assume_scalar_range(bx, imm, from_scalar, from_backend_ty);
-
- imm = match (from_scalar.primitive(), to_scalar.primitive()) {
- (Int(..) | Float(_), Int(..) | Float(_)) => bx.bitcast(imm, to_backend_ty),
- (Pointer(..), Pointer(..)) => bx.pointercast(imm, to_backend_ty),
- (Int(..), Pointer(..)) => bx.ptradd(bx.const_null(bx.type_ptr()), imm),
- (Pointer(..), Int(..)) => {
- // FIXME: this exposes the provenance, which shouldn't be necessary.
- bx.ptrtoint(imm, to_backend_ty)
- }
- (Float(_), Pointer(..)) => {
- let int_imm = bx.bitcast(imm, bx.cx().type_isize());
- bx.ptradd(bx.const_null(bx.type_ptr()), int_imm)
- }
- (Pointer(..), Float(_)) => {
- // FIXME: this exposes the provenance, which shouldn't be necessary.
- let int_imm = bx.ptrtoint(imm, bx.cx().type_isize());
- bx.bitcast(int_imm, to_backend_ty)
- }
- };
-
- // This `assume` remains important for cases like (a conceptual)
- // transmute::<u32, NonZeroU32>(x) == 0
- // since it's never passed to something with parameter metadata (especially
- // after MIR inlining) so the only way to tell the backend about the
- // constraint that the `transmute` introduced is to `assume` it.
- self.assume_scalar_range(bx, imm, to_scalar, to_backend_ty);
-
- imm = bx.to_immediate_scalar(imm, to_scalar);
- imm
- }
-
- fn assume_scalar_range(
- &self,
- bx: &mut Bx,
- imm: Bx::Value,
- scalar: abi::Scalar,
- backend_ty: Bx::Type,
- ) {
- if matches!(self.cx.sess().opts.optimize, OptLevel::No) || scalar.is_always_valid(self.cx) {
- return;
- }
-
- match scalar.primitive() {
- abi::Primitive::Int(..) => {
- let range = scalar.valid_range(self.cx);
- bx.assume_integer_range(imm, backend_ty, range);
- }
- abi::Primitive::Pointer(abi::AddressSpace::DATA)
- if !scalar.valid_range(self.cx).contains(0) =>
- {
- bx.assume_nonnull(imm);
- }
- abi::Primitive::Pointer(..) | abi::Primitive::Float(..) => {}
- }
- }
-
pub(crate) fn codegen_rvalue_unsized(
&mut self,
bx: &mut Bx,
@@ -1231,3 +1139,93 @@ fn scalars(self) -> Option<ArrayVec<abi::Scalar, 2>> {
})
}
}
+
+/// Transmutes one of the immediates from an [`OperandValue::Immediate`]
+/// or an [`OperandValue::Pair`] to an immediate of the target type.
+///
+/// `to_backend_ty` must be the *non*-immediate backend type (so it will be
+/// `i8`, not `i1`, for `bool`-like types.)
+fn transmute_immediate<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
+ bx: &mut Bx,
+ mut imm: Bx::Value,
+ from_scalar: abi::Scalar,
+ from_backend_ty: Bx::Type,
+ to_scalar: abi::Scalar,
+ to_backend_ty: Bx::Type,
+) -> Bx::Value {
+ assert_eq!(from_scalar.size(bx.cx()), to_scalar.size(bx.cx()));
+
+ // While optimizations will remove no-op transmutes, they might still be
+ // there in debug or things that aren't no-op in MIR because they change
+ // the Rust type but not the underlying layout/niche.
+ if from_scalar == to_scalar && from_backend_ty == to_backend_ty {
+ return imm;
+ }
+
+ use abi::Primitive::*;
+ imm = bx.from_immediate(imm);
+
+ // If we have a scalar, we must already know its range. Either
+ //
+ // 1) It's a parameter with `range` parameter metadata,
+ // 2) It's something we `load`ed with `!range` metadata, or
+ // 3) After a transmute we `assume`d the range (see below).
+ //
+ // That said, last time we tried removing this, it didn't actually help
+ // the rustc-perf results, so might as well keep doing it
+ // <https://github.com/rust-lang/rust/pull/135610#issuecomment-2599275182>
+ assume_scalar_range(bx, imm, from_scalar, from_backend_ty);
+
+ imm = match (from_scalar.primitive(), to_scalar.primitive()) {
+ (Int(..) | Float(_), Int(..) | Float(_)) => bx.bitcast(imm, to_backend_ty),
+ (Pointer(..), Pointer(..)) => bx.pointercast(imm, to_backend_ty),
+ (Int(..), Pointer(..)) => bx.ptradd(bx.const_null(bx.type_ptr()), imm),
+ (Pointer(..), Int(..)) => {
+ // FIXME: this exposes the provenance, which shouldn't be necessary.
+ bx.ptrtoint(imm, to_backend_ty)
+ }
+ (Float(_), Pointer(..)) => {
+ let int_imm = bx.bitcast(imm, bx.cx().type_isize());
+ bx.ptradd(bx.const_null(bx.type_ptr()), int_imm)
+ }
+ (Pointer(..), Float(_)) => {
+ // FIXME: this exposes the provenance, which shouldn't be necessary.
+ let int_imm = bx.ptrtoint(imm, bx.cx().type_isize());
+ bx.bitcast(int_imm, to_backend_ty)
+ }
+ };
+
+ // This `assume` remains important for cases like (a conceptual)
+ // transmute::<u32, NonZeroU32>(x) == 0
+ // since it's never passed to something with parameter metadata (especially
+ // after MIR inlining) so the only way to tell the backend about the
+ // constraint that the `transmute` introduced is to `assume` it.
+ assume_scalar_range(bx, imm, to_scalar, to_backend_ty);
+
+ imm = bx.to_immediate_scalar(imm, to_scalar);
+ imm
+}
+
+fn assume_scalar_range<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
+ bx: &mut Bx,
+ imm: Bx::Value,
+ scalar: abi::Scalar,
+ backend_ty: Bx::Type,
+) {
+ if matches!(bx.cx().sess().opts.optimize, OptLevel::No) || scalar.is_always_valid(bx.cx()) {
+ return;
+ }
+
+ match scalar.primitive() {
+ abi::Primitive::Int(..) => {
+ let range = scalar.valid_range(bx.cx());
+ bx.assume_integer_range(imm, backend_ty, range);
+ }
+ abi::Primitive::Pointer(abi::AddressSpace::DATA)
+ if !scalar.valid_range(bx.cx()).contains(0) =>
+ {
+ bx.assume_nonnull(imm);
+ }
+ abi::Primitive::Pointer(..) | abi::Primitive::Float(..) => {}
+ }
+}
diff --git a/compiler/rustc_const_eval/messages.ftl b/compiler/rustc_const_eval/messages.ftl
index 5bce6fb..7f9abe8 100644
--- a/compiler/rustc_const_eval/messages.ftl
+++ b/compiler/rustc_const_eval/messages.ftl
@@ -88,11 +88,9 @@
const_eval_dyn_call_not_a_method =
`dyn` call trying to call something that is not a method
-const_eval_error = {$error_kind ->
- [static] evaluation of static initializer failed here
- [const] evaluation of constant value failed here
- [const_with_path] evaluation of `{$instance}` failed here
- *[other] {""}
+const_eval_error = evaluation of `{$instance}` failed {$num_frames ->
+ [0] here
+ *[other] inside this call
}
const_eval_exact_div_has_remainder =
diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs
index 6167f8c..4f252f3 100644
--- a/compiler/rustc_const_eval/src/check_consts/check.rs
+++ b/compiler/rustc_const_eval/src/check_consts/check.rs
@@ -356,10 +356,7 @@ fn place_may_escape(&mut self, place: &Place<'_>) -> bool {
hir::ConstContext::ConstFn => true,
_ => {
// For indirect places, we are not creating a new permanent borrow, it's just as
- // transient as the already existing one. For reborrowing references this is handled
- // at the top of `visit_rvalue`, but for raw pointers we handle it here.
- // Pointers/references to `static mut` and cases where the `*` is not the first
- // projection also end up here.
+ // transient as the already existing one.
// Locals with StorageDead do not live beyond the evaluation and can
// thus safely be borrowed without being able to be leaked to the final
// value of the constant.
@@ -395,7 +392,7 @@ fn revalidate_conditional_constness(
}
let (infcx, param_env) = tcx.infer_ctxt().build_with_typing_env(self.body.typing_env(tcx));
- let ocx = ObligationCtxt::new_with_diagnostics(&infcx);
+ let ocx = ObligationCtxt::new(&infcx);
let body_id = self.body.source.def_id().expect_local();
let host_polarity = match self.const_kind() {
diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs
index 2556e57..be84019 100644
--- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs
+++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs
@@ -430,20 +430,7 @@ fn report_eval_error<'tcx>(
let (error, backtrace) = error.into_parts();
backtrace.print_backtrace();
- let (kind, instance) = if ecx.tcx.is_static(cid.instance.def_id()) {
- ("static", String::new())
- } else {
- // If the current item has generics, we'd like to enrich the message with the
- // instance and its args: to show the actual compile-time values, in addition to
- // the expression, leading to the const eval error.
- let instance = &cid.instance;
- if !instance.args.is_empty() {
- let instance = with_no_trimmed_paths!(instance.to_string());
- ("const_with_path", instance)
- } else {
- ("const", String::new())
- }
- };
+ let instance = with_no_trimmed_paths!(cid.instance.to_string());
super::report(
*ecx.tcx,
@@ -451,6 +438,7 @@ fn report_eval_error<'tcx>(
DUMMY_SP,
|| super::get_span_and_frames(ecx.tcx, ecx.stack()),
|diag, span, frames| {
+ let num_frames = frames.len();
// FIXME(oli-obk): figure out how to use structured diagnostics again.
diag.code(E0080);
diag.span_label(span, crate::fluent_generated::const_eval_error);
@@ -459,7 +447,7 @@ fn report_eval_error<'tcx>(
}
// Add after the frame rendering above, as it adds its own `instance` args.
diag.arg("instance", instance);
- diag.arg("error_kind", kind);
+ diag.arg("num_frames", num_frames);
},
)
}
diff --git a/compiler/rustc_const_eval/src/interpret/intern.rs b/compiler/rustc_const_eval/src/interpret/intern.rs
index 1dd9629..f0f958d 100644
--- a/compiler/rustc_const_eval/src/interpret/intern.rs
+++ b/compiler/rustc_const_eval/src/interpret/intern.rs
@@ -227,12 +227,11 @@ pub fn intern_const_alloc_recursive<'tcx, M: CompileTimeMachine<'tcx, const_eval
// Keep interning as long as there are things to intern.
// We show errors if there are dangling pointers, or mutable pointers in immutable contexts
- // (i.e., everything except for `static mut`). When these errors affect references, it is
- // unfortunate that we show these errors here and not during validation, since validation can
- // show much nicer errors. However, we do need these checks to be run on all pointers, including
- // raw pointers, so we cannot rely on validation to catch them -- and since interning runs
- // before validation, and interning doesn't know the type of anything, this means we can't show
- // better errors. Maybe we should consider doing validation before interning in the future.
+ // (i.e., everything except for `static mut`). We only return these errors as a `Result`
+ // so that the caller can run validation, and subsequently only report interning errors
+ // if validation fails. Validation has the better error messages so we prefer those, but
+ // interning has better coverage since it "sees" *all* pointers, including raw pointers and
+ // references stored in unions.
while let Some(prov) = todo.pop() {
trace!(?prov);
let alloc_id = prov.alloc_id();
@@ -279,12 +278,12 @@ pub fn intern_const_alloc_recursive<'tcx, M: CompileTimeMachine<'tcx, const_eval
// when there is memory there that someone might expect to be mutable, but we make it immutable.
let dangling = !is_already_global && !ecx.memory.alloc_map.contains_key(&alloc_id);
if !dangling {
- // Found a mutable reference inside a const where inner allocations should be
+ // Found a mutable pointer inside a const where inner allocations should be
// immutable.
if !ecx.tcx.sess.opts.unstable_opts.unleash_the_miri_inside_of_you {
span_bug!(
ecx.tcx.span,
- "the static const safety checks accepted mutable references they should not have accepted"
+ "the static const safety checks accepted a mutable pointer they should not have accepted"
);
}
// Prefer dangling pointer errors over mutable pointer errors
diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs
index 64467a9..ab27182 100644
--- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs
+++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs
@@ -50,13 +50,6 @@ pub(crate) fn eval_nullary_intrinsic<'tcx>(
ensure_monomorphic_enough(tcx, tp_ty)?;
ConstValue::from_bool(tp_ty.needs_drop(tcx, typing_env))
}
- sym::pref_align_of => {
- // Correctly handles non-monomorphic calls, so there is no need for ensure_monomorphic_enough.
- let layout = tcx
- .layout_of(typing_env.as_query_input(tp_ty))
- .map_err(|e| err_inval!(Layout(*e)))?;
- ConstValue::from_target_usize(layout.align.pref.bytes(), &tcx)
- }
sym::type_id => {
ensure_monomorphic_enough(tcx, tp_ty)?;
ConstValue::from_u128(tcx.type_id_hash(tp_ty).as_u128())
@@ -144,14 +137,10 @@ pub fn eval_intrinsic(
self.write_scalar(Scalar::from_target_usize(result, self), dest)?;
}
- sym::pref_align_of
- | sym::needs_drop
- | sym::type_id
- | sym::type_name
- | sym::variant_count => {
+ sym::needs_drop | sym::type_id | sym::type_name | sym::variant_count => {
let gid = GlobalId { instance, promoted: None };
let ty = match intrinsic_name {
- sym::pref_align_of | sym::variant_count => self.tcx.types.usize,
+ sym::variant_count => self.tcx.types.usize,
sym::needs_drop => self.tcx.types.bool,
sym::type_id => self.tcx.types.u128,
sym::type_name => Ty::new_static_str(self.tcx.tcx),
diff --git a/compiler/rustc_const_eval/src/interpret/util.rs b/compiler/rustc_const_eval/src/interpret/util.rs
index 83a1709..99add01 100644
--- a/compiler/rustc_const_eval/src/interpret/util.rs
+++ b/compiler/rustc_const_eval/src/interpret/util.rs
@@ -58,9 +58,9 @@ pub enum MaybeEnteredSpan {
macro_rules! enter_trace_span {
($machine:ident, $($tt:tt)*) => {
if $machine::TRACING_ENABLED {
- $crate::interpret::tracing_utils::MaybeEnteredSpan::Some(tracing::info_span!($($tt)*).entered())
+ $crate::interpret::util::MaybeEnteredSpan::Some(tracing::info_span!($($tt)*).entered())
} else {
- $crate::interpret::tracing_utils::MaybeEnteredSpan::None
+ $crate::interpret::util::MaybeEnteredSpan::None
}
}
}
diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs
index b7447e2..eb3817a 100644
--- a/compiler/rustc_data_structures/src/lib.rs
+++ b/compiler/rustc_data_structures/src/lib.rs
@@ -25,7 +25,6 @@
#![feature(dropck_eyepatch)]
#![feature(extend_one)]
#![feature(file_buffered)]
-#![feature(macro_metavar_expr)]
#![feature(map_try_insert)]
#![feature(min_specialization)]
#![feature(negative_impls)]
diff --git a/compiler/rustc_data_structures/src/vec_cache.rs b/compiler/rustc_data_structures/src/vec_cache.rs
index 2ff60ab..3b448c0 100644
--- a/compiler/rustc_data_structures/src/vec_cache.rs
+++ b/compiler/rustc_data_structures/src/vec_cache.rs
@@ -68,22 +68,22 @@ impl SlotIndex {
// slots (see `slot_index_exhaustive` in tests).
#[inline]
const fn from_index(idx: u32) -> Self {
- let mut bucket = match idx.checked_ilog2() {
- Some(x) => x as usize,
- None => 0,
- };
- let entries;
- let running_sum;
- if bucket <= 11 {
- entries = 1 << 12;
- running_sum = 0;
- bucket = 0;
- } else {
- entries = 1 << bucket;
- running_sum = entries;
- bucket = bucket - 11;
+ const FIRST_BUCKET_SHIFT: usize = 12;
+ if idx < (1 << FIRST_BUCKET_SHIFT) {
+ return SlotIndex {
+ bucket_idx: 0,
+ entries: 1 << FIRST_BUCKET_SHIFT,
+ index_in_bucket: idx as usize,
+ };
}
- SlotIndex { bucket_idx: bucket, entries, index_in_bucket: idx as usize - running_sum }
+ // SAFETY: We already ruled out idx 0, so `checked_ilog2` can't return `None`.
+ let bucket = unsafe { idx.checked_ilog2().unwrap_unchecked() as usize };
+ let entries = 1 << bucket;
+ SlotIndex {
+ bucket_idx: bucket - FIRST_BUCKET_SHIFT + 1,
+ entries,
+ index_in_bucket: idx as usize - entries,
+ }
}
// SAFETY: Buckets must be managed solely by functions here (i.e., get/put on SlotIndex) and
diff --git a/compiler/rustc_data_structures/src/vec_cache/tests.rs b/compiler/rustc_data_structures/src/vec_cache/tests.rs
index 3b65c14..9b60913 100644
--- a/compiler/rustc_data_structures/src/vec_cache/tests.rs
+++ b/compiler/rustc_data_structures/src/vec_cache/tests.rs
@@ -75,24 +75,21 @@ fn slot_index_exhaustive() {
for idx in 0..=u32::MAX {
buckets[SlotIndex::from_index(idx).bucket_idx] += 1;
}
- let mut prev = None::<SlotIndex>;
- for idx in 0..=u32::MAX {
+ let slot_idx = SlotIndex::from_index(0);
+ assert_eq!(slot_idx.index_in_bucket, 0);
+ assert_eq!(slot_idx.bucket_idx, 0);
+ let mut prev = slot_idx;
+ for idx in 1..=u32::MAX {
let slot_idx = SlotIndex::from_index(idx);
- if let Some(p) = prev {
- if p.bucket_idx == slot_idx.bucket_idx {
- assert_eq!(p.index_in_bucket + 1, slot_idx.index_in_bucket);
- } else {
- assert_eq!(slot_idx.index_in_bucket, 0);
- }
+ if prev.bucket_idx == slot_idx.bucket_idx {
+ assert_eq!(prev.index_in_bucket + 1, slot_idx.index_in_bucket);
} else {
- assert_eq!(idx, 0);
assert_eq!(slot_idx.index_in_bucket, 0);
- assert_eq!(slot_idx.bucket_idx, 0);
}
assert_eq!(buckets[slot_idx.bucket_idx], slot_idx.entries as u32);
assert_eq!(ENTRIES_BY_BUCKET[slot_idx.bucket_idx], slot_idx.entries, "{}", idx);
- prev = Some(slot_idx);
+ prev = slot_idx;
}
}
diff --git a/compiler/rustc_error_codes/src/error_codes/E0092.md b/compiler/rustc_error_codes/src/error_codes/E0092.md
index be459d0..9c63798 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0092.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0092.md
@@ -1,8 +1,10 @@
+#### Note: this error code is no longer emitted by the compiler.
+
An undefined atomic operation function was declared.
Erroneous code example:
-```compile_fail,E0092
+```ignore (no longer emitted)
#![feature(intrinsics)]
#![allow(internal_features)]
@@ -12,13 +14,4 @@
```
Please check you didn't make a mistake in the function's name. All intrinsic
-functions are defined in `compiler/rustc_codegen_llvm/src/intrinsic.rs` and in
-`library/core/src/intrinsics.rs` in the Rust source code. Example:
-
-```
-#![feature(intrinsics)]
-#![allow(internal_features)]
-
-#[rustc_intrinsic]
-unsafe fn atomic_fence_seqcst(); // ok!
-```
+functions are defined in `library/core/src/intrinsics` in the Rust source code.
diff --git a/compiler/rustc_error_codes/src/error_codes/E0093.md b/compiler/rustc_error_codes/src/error_codes/E0093.md
index 9929a06..3552c2d 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0093.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0093.md
@@ -17,19 +17,4 @@
```
Please check you didn't make a mistake in the function's name. All intrinsic
-functions are defined in `compiler/rustc_codegen_llvm/src/intrinsic.rs` and in
-`library/core/src/intrinsics.rs` in the Rust source code. Example:
-
-```
-#![feature(intrinsics)]
-#![allow(internal_features)]
-
-#[rustc_intrinsic]
-unsafe fn atomic_fence_seqcst(); // ok!
-
-fn main() {
- unsafe {
- atomic_fence_seqcst();
- }
-}
-```
+functions are defined in `library/core/src/intrinsics` in the Rust source code.
diff --git a/compiler/rustc_error_codes/src/error_codes/E0622.md b/compiler/rustc_error_codes/src/error_codes/E0622.md
index 9b8131a..cc66e06 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0622.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0622.md
@@ -4,7 +4,7 @@
Erroneous code example:
-```no_run
+```ignore (no longer emitted)
#![feature(intrinsics)]
#![allow(internal_features)]
@@ -21,7 +21,7 @@
whose implementation is handled specially by the compiler. In order to fix this
error, just declare a function. Example:
-```no_run
+```ignore (no longer emitted)
#![feature(intrinsics)]
#![allow(internal_features)]
diff --git a/compiler/rustc_error_messages/Cargo.toml b/compiler/rustc_error_messages/Cargo.toml
index 0951859..5dc582b 100644
--- a/compiler/rustc_error_messages/Cargo.toml
+++ b/compiler/rustc_error_messages/Cargo.toml
@@ -16,6 +16,7 @@
rustc_macros = { path = "../rustc_macros" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_span = { path = "../rustc_span" }
+smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
tracing = "0.1"
unic-langid = { version = "0.9.0", features = ["macros"] }
# tidy-alphabetical-end
diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs
index 3c6df14..1d3b5b2 100644
--- a/compiler/rustc_error_messages/src/lib.rs
+++ b/compiler/rustc_error_messages/src/lib.rs
@@ -21,6 +21,7 @@
use rustc_data_structures::sync::IntoDynSyncSend;
use rustc_macros::{Decodable, Encodable};
use rustc_span::Span;
+use smallvec::SmallVec;
use tracing::{instrument, trace};
pub use unic_langid::{LanguageIdentifier, langid};
@@ -106,8 +107,7 @@ fn from(mut errs: Vec<FluentError>) -> Self {
/// (overriding any conflicting messages).
#[instrument(level = "trace")]
pub fn fluent_bundle(
- sysroot: PathBuf,
- sysroot_candidates: Vec<PathBuf>,
+ sysroot_candidates: SmallVec<[PathBuf; 2]>,
requested_locale: Option<LanguageIdentifier>,
additional_ftl_path: Option<&Path>,
with_directionality_markers: bool,
@@ -141,7 +141,7 @@ pub fn fluent_bundle(
// If the user requests the default locale then don't try to load anything.
if let Some(requested_locale) = requested_locale {
let mut found_resources = false;
- for mut sysroot in Some(sysroot).into_iter().chain(sysroot_candidates.into_iter()) {
+ for mut sysroot in sysroot_candidates {
sysroot.push("share");
sysroot.push("locale");
sysroot.push(requested_locale.to_string());
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs
index 6f0090a..133bd36 100644
--- a/compiler/rustc_errors/src/lib.rs
+++ b/compiler/rustc_errors/src/lib.rs
@@ -15,12 +15,10 @@
#![feature(box_patterns)]
#![feature(default_field_values)]
#![feature(error_reporter)]
-#![feature(if_let_guard)]
#![feature(negative_impls)]
#![feature(never_type)]
#![feature(rustc_attrs)]
#![feature(rustdoc_internals)]
-#![feature(trait_alias)]
#![feature(try_blocks)]
#![feature(yeet_expr)]
// tidy-alphabetical-end
diff --git a/compiler/rustc_expand/messages.ftl b/compiler/rustc_expand/messages.ftl
index f26c7c1..08b7a36 100644
--- a/compiler/rustc_expand/messages.ftl
+++ b/compiler/rustc_expand/messages.ftl
@@ -62,6 +62,7 @@
expand_feature_removed =
feature has been removed
.label = feature has been removed
+ .note = removed in {$removed_rustc_version} (you are using {$current_rustc_version}){$pull_note}
.reason = {$reason}
expand_glob_delegation_outside_impls =
diff --git a/compiler/rustc_expand/src/config.rs b/compiler/rustc_expand/src/config.rs
index c50ab59..9a359e9 100644
--- a/compiler/rustc_expand/src/config.rs
+++ b/compiler/rustc_expand/src/config.rs
@@ -80,9 +80,20 @@ fn feature_list(attr: &Attribute) -> ThinVec<ast::MetaItemInner> {
// If the enabled feature has been removed, issue an error.
if let Some(f) = REMOVED_LANG_FEATURES.iter().find(|f| name == f.feature.name) {
+ let pull_note = if let Some(pull) = f.pull {
+ format!(
+ "; see <https://github.com/rust-lang/rust/pull/{}> for more information",
+ pull
+ )
+ } else {
+ "".to_owned()
+ };
sess.dcx().emit_err(FeatureRemoved {
span: mi.span(),
reason: f.reason.map(|reason| FeatureRemovedReason { reason }),
+ removed_rustc_version: f.feature.since,
+ current_rustc_version: sess.cfg_version,
+ pull_note,
});
continue;
}
diff --git a/compiler/rustc_expand/src/errors.rs b/compiler/rustc_expand/src/errors.rs
index 89bdc7b..ec0af67 100644
--- a/compiler/rustc_expand/src/errors.rs
+++ b/compiler/rustc_expand/src/errors.rs
@@ -154,12 +154,16 @@ pub(crate) struct HelperAttributeNameInvalid {
#[derive(Diagnostic)]
#[diag(expand_feature_removed, code = E0557)]
+#[note]
pub(crate) struct FeatureRemoved<'a> {
#[primary_span]
#[label]
pub span: Span,
#[subdiagnostic]
pub reason: Option<FeatureRemovedReason<'a>>,
+ pub removed_rustc_version: &'a str,
+ pub current_rustc_version: &'a str,
+ pub pull_note: String,
}
#[derive(Subdiagnostic)]
diff --git a/compiler/rustc_expand/src/lib.rs b/compiler/rustc_expand/src/lib.rs
index 35b38d9..515d822 100644
--- a/compiler/rustc_expand/src/lib.rs
+++ b/compiler/rustc_expand/src/lib.rs
@@ -6,7 +6,6 @@
#![feature(associated_type_defaults)]
#![feature(if_let_guard)]
#![feature(macro_metavar_expr)]
-#![feature(map_try_insert)]
#![feature(proc_macro_diagnostic)]
#![feature(proc_macro_internals)]
#![feature(rustdoc_internals)]
diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs
index ffa6ffb4..b1c1852 100644
--- a/compiler/rustc_feature/src/accepted.rs
+++ b/compiler/rustc_feature/src/accepted.rs
@@ -259,6 +259,8 @@ macro_rules! declare_features {
/// Allows some increased flexibility in the name resolution rules,
/// especially around globs and shadowing (RFC 1560).
(accepted, item_like_imports, "1.15.0", Some(35120)),
+ // Allows using the `kl` and `widekl` target features and the associated intrinsics
+ (accepted, keylocker_x86, "CURRENT_RUSTC_VERSION", Some(134813)),
/// Allows `'a: { break 'a; }`.
(accepted, label_break_value, "1.65.0", Some(48594)),
/// Allows `let...else` statements.
@@ -382,6 +384,8 @@ macro_rules! declare_features {
(accepted, self_in_typedefs, "1.32.0", Some(49303)),
/// Allows `Self` struct constructor (RFC 2302).
(accepted, self_struct_ctor, "1.32.0", Some(51994)),
+ /// Allows use of x86 SHA512, SM3 and SM4 target-features and intrinsics
+ (accepted, sha512_sm_x86, "CURRENT_RUSTC_VERSION", Some(126624)),
/// Shortern the tail expression lifetime
(accepted, shorter_tail_lifetimes, "1.84.0", Some(123739)),
/// Allows using subslice patterns, `[a, .., b]` and `[a, xs @ .., b]`.
diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs
index 687d859..9738f16 100644
--- a/compiler/rustc_feature/src/removed.rs
+++ b/compiler/rustc_feature/src/removed.rs
@@ -1,5 +1,7 @@
//! List of the removed feature gates.
+use std::num::{NonZero, NonZeroU32};
+
use rustc_span::sym;
use super::{Feature, to_nonzero};
@@ -7,11 +9,21 @@
pub struct RemovedFeature {
pub feature: Feature,
pub reason: Option<&'static str>,
+ pub pull: Option<NonZero<u32>>,
+}
+
+macro_rules! opt_nonzero_u32 {
+ () => {
+ None
+ };
+ ($val:expr) => {
+ Some(NonZeroU32::new($val).unwrap())
+ };
}
macro_rules! declare_features {
($(
- $(#[doc = $doc:tt])* (removed, $feature:ident, $ver:expr, $issue:expr, $reason:expr),
+ $(#[doc = $doc:tt])* (removed, $feature:ident, $ver:expr, $issue:expr, $reason:expr $(, $pull:expr)?),
)+) => {
/// Formerly unstable features that have now been removed.
pub static REMOVED_LANG_FEATURES: &[RemovedFeature] = &[
@@ -21,7 +33,8 @@ macro_rules! declare_features {
since: $ver,
issue: to_nonzero($issue),
},
- reason: $reason
+ reason: $reason,
+ pull: opt_nonzero_u32!($($pull)?),
}),+
];
};
@@ -40,64 +53,64 @@ macro_rules! declare_features {
// version they got originally added in.)
/// Allows using the `amdgpu-kernel` ABI.
- (removed, abi_amdgpu_kernel, "1.77.0", Some(51575), None),
- (removed, advanced_slice_patterns, "1.0.0", Some(62254),
- Some("merged into `#![feature(slice_patterns)]`")),
+ (removed, abi_amdgpu_kernel, "1.77.0", Some(51575), None, 120495),
+ (removed, advanced_slice_patterns, "1.42.0", Some(62254),
+ Some("merged into `#![feature(slice_patterns)]`"), 67712),
(removed, allocator, "1.0.0", None, None),
/// Allows a test to fail without failing the whole suite.
- (removed, allow_fail, "1.19.0", Some(46488), Some("removed due to no clear use cases")),
+ (removed, allow_fail, "1.60.0", Some(46488), Some("removed due to no clear use cases"), 93416),
(removed, await_macro, "1.38.0", Some(50547),
- Some("subsumed by `.await` syntax")),
+ Some("subsumed by `.await` syntax"), 62293),
/// Allows using the `box $expr` syntax.
- (removed, box_syntax, "1.70.0", Some(49733), Some("replaced with `#[rustc_box]`")),
+ (removed, box_syntax, "1.70.0", Some(49733), Some("replaced with `#[rustc_box]`"), 108471),
/// Allows capturing disjoint fields in a closure/coroutine (RFC 2229).
- (removed, capture_disjoint_fields, "1.49.0", Some(53488), Some("stabilized in Rust 2021")),
+ (removed, capture_disjoint_fields, "1.69.0", Some(53488), Some("stabilized in Rust 2021"), 108550),
/// Allows comparing raw pointers during const eval.
(removed, const_compare_raw_pointers, "1.46.0", Some(53020),
- Some("cannot be allowed in const eval in any meaningful way")),
+ Some("cannot be allowed in const eval in any meaningful way"), 73398),
/// Allows limiting the evaluation steps of const expressions
- (removed, const_eval_limit, "1.43.0", Some(67217), Some("removed the limit entirely")),
+ (removed, const_eval_limit, "1.72.0", Some(67217), Some("removed the limit entirely"), 103877),
/// Allows non-trivial generic constants which have to be manually propagated upwards.
- (removed, const_evaluatable_checked, "1.48.0", Some(76560), Some("renamed to `generic_const_exprs`")),
+ (removed, const_evaluatable_checked, "1.56.0", Some(76560), Some("renamed to `generic_const_exprs`"), 88369),
/// Allows the definition of `const` functions with some advanced features.
(removed, const_fn, "1.54.0", Some(57563),
- Some("split into finer-grained feature gates")),
+ Some("split into finer-grained feature gates"), 85109),
/// Allows const generic types (e.g. `struct Foo<const N: usize>(...);`).
- (removed, const_generics, "1.34.0", Some(44580),
- Some("removed in favor of `#![feature(adt_const_params)]` and `#![feature(generic_const_exprs)]`")),
+ (removed, const_generics, "1.56.0", Some(44580),
+ Some("removed in favor of `#![feature(adt_const_params)]` and `#![feature(generic_const_exprs)]`"), 88369),
/// Allows `[x; N]` where `x` is a constant (RFC 2203).
- (removed, const_in_array_repeat_expressions, "1.37.0", Some(49147),
- Some("removed due to causing promotable bugs")),
+ (removed, const_in_array_repeat_expressions, "1.51.0", Some(49147),
+ Some("removed due to causing promotable bugs"), 80404),
/// Allows casting raw pointers to `usize` during const eval.
(removed, const_raw_ptr_to_usize_cast, "1.55.0", Some(51910),
- Some("at compile-time, pointers do not have an integer value, so these casts cannot be properly supported")),
+ Some("at compile-time, pointers do not have an integer value, so these casts cannot be properly supported"), 87020),
/// Allows `T: ?const Trait` syntax in bounds.
- (removed, const_trait_bound_opt_out, "1.42.0", Some(67794),
- Some("Removed in favor of `~const` bound in #![feature(const_trait_impl)]")),
+ (removed, const_trait_bound_opt_out, "1.56.0", Some(67794),
+ Some("Removed in favor of `~const` bound in #![feature(const_trait_impl)]"), 88328),
/// Allows using `crate` as visibility modifier, synonymous with `pub(crate)`.
- (removed, crate_visibility_modifier, "1.63.0", Some(53120), Some("removed in favor of `pub(crate)`")),
+ (removed, crate_visibility_modifier, "1.63.0", Some(53120), Some("removed in favor of `pub(crate)`"), 97254),
/// Allows using custom attributes (RFC 572).
(removed, custom_attribute, "1.0.0", Some(29642),
- Some("removed in favor of `#![register_tool]` and `#![register_attr]`")),
+ Some("removed in favor of `#![register_tool]` and `#![register_attr]`"), 66070),
/// Allows the use of `#[derive(Anything)]` as sugar for `#[derive_Anything]`.
(removed, custom_derive, "1.32.0", Some(29644),
Some("subsumed by `#[proc_macro_derive]`")),
/// Allows default type parameters to influence type inference.
(removed, default_type_parameter_fallback, "1.82.0", Some(27336),
- Some("never properly implemented; requires significant design work")),
+ Some("never properly implemented; requires significant design work"), 127655),
/// Allows deriving traits as per `SmartPointer` specification
- (removed, derive_smart_pointer, "1.79.0", Some(123430), Some("replaced by `CoercePointee`")),
+ (removed, derive_smart_pointer, "1.84.0", Some(123430), Some("replaced by `CoercePointee`"), 131284),
/// Allows using `#[doc(keyword = "...")]`.
- (removed, doc_keyword, "1.28.0", Some(51315),
- Some("merged into `#![feature(rustdoc_internals)]`")),
+ (removed, doc_keyword, "1.58.0", Some(51315),
+ Some("merged into `#![feature(rustdoc_internals)]`"), 90420),
/// Allows using `doc(primitive)` without a future-incompat warning.
- (removed, doc_primitive, "1.56.0", Some(88070),
- Some("merged into `#![feature(rustdoc_internals)]`")),
+ (removed, doc_primitive, "1.58.0", Some(88070),
+ Some("merged into `#![feature(rustdoc_internals)]`"), 90420),
/// Allows `#[doc(spotlight)]`.
/// The attribute was renamed to `#[doc(notable_trait)]`
/// and the feature to `doc_notable_trait`.
- (removed, doc_spotlight, "1.22.0", Some(45040),
- Some("renamed to `doc_notable_trait`")),
+ (removed, doc_spotlight, "1.53.0", Some(45040),
+ Some("renamed to `doc_notable_trait`"), 80965),
/// Allows using `#[unsafe_destructor_blind_to_params]` (RFC 1238).
(removed, dropck_parametricity, "1.38.0", Some(28498), None),
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn compatible[^1].
@@ -107,159 +120,162 @@ macro_rules! declare_features {
/// Renamed from `object_safe_for_dispatch`.
///
/// [^1]: Formerly known as "object safe".
- (removed, dyn_compatible_for_dispatch, "1.83.0", Some(43561),
- Some("removed, not used heavily and represented additional complexity in dyn compatibility")),
+ (removed, dyn_compatible_for_dispatch, "1.87.0", Some(43561),
+ Some("removed, not used heavily and represented additional complexity in dyn compatibility"), 136522),
/// Uses generic effect parameters for ~const bounds
(removed, effects, "1.84.0", Some(102090),
- Some("removed, redundant with `#![feature(const_trait_impl)]`")),
+ Some("removed, redundant with `#![feature(const_trait_impl)]`"), 132479),
/// Allows defining `existential type`s.
(removed, existential_type, "1.38.0", Some(63063),
Some("removed in favor of `#![feature(type_alias_impl_trait)]`")),
/// Paths of the form: `extern::foo::bar`
(removed, extern_in_paths, "1.33.0", Some(55600),
- Some("subsumed by `::foo::bar` paths")),
+ Some("subsumed by `::foo::bar` paths"), 57572),
/// Allows `#[doc(include = "some-file")]`.
(removed, external_doc, "1.54.0", Some(44732),
- Some("use #[doc = include_str!(\"filename\")] instead, which handles macro invocations")),
+ Some("use #[doc = include_str!(\"filename\")] instead, which handles macro invocations"), 85457),
/// Allows using `#[ffi_returns_twice]` on foreign functions.
(removed, ffi_returns_twice, "1.78.0", Some(58314),
- Some("being investigated by the ffi-unwind project group")),
+ Some("being investigated by the ffi-unwind project group"), 120502),
/// Allows generators to be cloned.
- (removed, generator_clone, "1.65.0", Some(95360), Some("renamed to `coroutine_clone`")),
+ (removed, generator_clone, "1.75.0", Some(95360), Some("renamed to `coroutine_clone`"), 116958),
/// Allows defining generators.
- (removed, generators, "1.21.0", Some(43122), Some("renamed to `coroutines`")),
+ (removed, generators, "1.75.0", Some(43122), Some("renamed to `coroutines`"), 116958),
/// An extension to the `generic_associated_types` feature, allowing incomplete features.
(removed, generic_associated_types_extended, "1.85.0", Some(95451),
Some(
"feature needs overhaul and reimplementation pending \
better implied higher-ranked implied bounds support"
- )
+ ),
+ 133768
),
(removed, import_shadowing, "1.0.0", None, None),
/// Allows in-band quantification of lifetime bindings (e.g., `fn foo(x: &'a u8) -> &'a u8`).
- (removed, in_band_lifetimes, "1.23.0", Some(44524),
- Some("removed due to unsolved ergonomic questions and added lifetime resolution complexity")),
+ (removed, in_band_lifetimes, "1.61.0", Some(44524),
+ Some("removed due to unsolved ergonomic questions and added lifetime resolution complexity"), 93845),
/// Allows inferring `'static` outlives requirements (RFC 2093).
(removed, infer_static_outlives_requirements, "1.63.0", Some(54185),
- Some("removed as it caused some confusion and discussion was inactive for years")),
+ Some("removed as it caused some confusion and discussion was inactive for years"), 97875),
/// Allow anonymous constants from an inline `const` block in pattern position
(removed, inline_const_pat, "1.88.0", Some(76001),
- Some("removed due to implementation concerns as it requires significant refactorings")),
+ Some("removed due to implementation concerns as it requires significant refactorings"), 138492),
/// Lazily evaluate constants. This allows constants to depend on type parameters.
- (removed, lazy_normalization_consts, "1.46.0", Some(72219), Some("superseded by `generic_const_exprs`")),
+ (removed, lazy_normalization_consts, "1.56.0", Some(72219), Some("superseded by `generic_const_exprs`"), 88369),
/// Changes `impl Trait` to capture all lifetimes in scope.
- (removed, lifetime_capture_rules_2024, "1.76.0", None, Some("unnecessary -- use edition 2024 instead")),
+ (removed, lifetime_capture_rules_2024, "1.87.0", None, Some("unnecessary -- use edition 2024 instead"), 136787),
/// Allows using the `#[link_args]` attribute.
(removed, link_args, "1.53.0", Some(29596),
Some("removed in favor of using `-C link-arg=ARG` on command line, \
- which is available from cargo build scripts with `cargo:rustc-link-arg` now")),
+ which is available from cargo build scripts with `cargo:rustc-link-arg` now"), 83820),
(removed, macro_reexport, "1.0.0", Some(29638),
- Some("subsumed by `pub use`")),
+ Some("subsumed by `pub use`"), 49982),
/// Allows using `#[main]` to replace the entrypoint `#[lang = "start"]` calls.
- (removed, main, "1.53.0", Some(29634), None),
+ (removed, main, "1.53.0", Some(29634), None, 84217),
(removed, managed_boxes, "1.0.0", None, None),
/// Allows the use of type alias impl trait in function return positions
(removed, min_type_alias_impl_trait, "1.56.0", Some(63063),
- Some("removed in favor of full type_alias_impl_trait")),
+ Some("removed in favor of full type_alias_impl_trait"), 87564),
/// Make `mut` not reset the binding mode on edition >= 2024.
- (removed, mut_preserve_binding_mode_2024, "1.79.0", Some(123076), Some("superseded by `ref_pat_eat_one_layer_2024`")),
+ (removed, mut_preserve_binding_mode_2024, "1.80.0", Some(123076), Some("superseded by `ref_pat_eat_one_layer_2024`"), 125168),
(removed, needs_allocator, "1.4.0", Some(27389),
Some("subsumed by `#![feature(allocator_internals)]`")),
/// Allows use of unary negate on unsigned integers, e.g., -e for e: u8
(removed, negate_unsigned, "1.0.0", Some(29645), None),
/// Allows `#[no_coverage]` on functions.
/// The feature was renamed to `coverage_attribute` and the attribute to `#[coverage(on|off)]`
- (removed, no_coverage, "1.74.0", Some(84605), Some("renamed to `coverage_attribute`")),
+ (removed, no_coverage, "1.74.0", Some(84605), Some("renamed to `coverage_attribute`"), 114656),
/// Allows `#[no_debug]`.
- (removed, no_debug, "1.43.0", Some(29721), Some("removed due to lack of demand")),
+ (removed, no_debug, "1.43.0", Some(29721), Some("removed due to lack of demand"), 69667),
/// Note: this feature was previously recorded in a separate
/// `STABLE_REMOVED` list because it, uniquely, was once stable but was
/// then removed. But there was no utility storing it separately, so now
/// it's in this list.
- (removed, no_stack_check, "1.0.0", None, None),
+ (removed, no_stack_check, "1.0.0", None, None, 40110),
/// Allows making `dyn Trait` well-formed even if `Trait` is not dyn compatible (object safe).
/// Renamed to `dyn_compatible_for_dispatch`.
(removed, object_safe_for_dispatch, "1.83.0", Some(43561),
- Some("renamed to `dyn_compatible_for_dispatch`")),
+ Some("renamed to `dyn_compatible_for_dispatch`"), 131511),
/// Allows using `#[on_unimplemented(..)]` on traits.
/// (Moved to `rustc_attrs`.)
- (removed, on_unimplemented, "1.40.0", None, None),
+ (removed, on_unimplemented, "1.40.0", None, None, 65794),
/// A way to temporarily opt out of opt-in copy. This will *never* be accepted.
- (removed, opt_out_copy, "1.0.0", None, None),
+ (removed, opt_out_copy, "1.0.0", None, None, 20740),
/// Allows features specific to OIBIT (now called auto traits).
/// Renamed to `auto_traits`.
- (removed, optin_builtin_traits, "1.0.0", Some(13231),
- Some("renamed to `auto_traits`")),
+ (removed, optin_builtin_traits, "1.50.0", Some(13231),
+ Some("renamed to `auto_traits`"), 79336),
/// Allows overlapping impls of marker traits.
(removed, overlapping_marker_traits, "1.42.0", Some(29864),
- Some("removed in favor of `#![feature(marker_trait_attr)]`")),
+ Some("removed in favor of `#![feature(marker_trait_attr)]`"), 68544),
(removed, panic_implementation, "1.28.0", Some(44489),
- Some("subsumed by `#[panic_handler]`")),
+ Some("subsumed by `#[panic_handler]`"), 53619),
/// Allows `extern "platform-intrinsic" { ... }`.
- (removed, platform_intrinsics, "1.4.0", Some(27731),
- Some("SIMD intrinsics use the regular intrinsics ABI now")),
+ (removed, platform_intrinsics, "1.78.0", Some(27731),
+ Some("SIMD intrinsics use the regular intrinsics ABI now"), 121516),
/// Allows using `#![plugin(myplugin)]`.
(removed, plugin, "1.75.0", Some(29597),
- Some("plugins are no longer supported")),
+ Some("plugins are no longer supported"), 116412),
/// Allows using `#[plugin_registrar]` on functions.
- (removed, plugin_registrar, "1.54.0", Some(29597),
- Some("plugins are no longer supported")),
+ (removed, plugin_registrar, "1.75.0", Some(29597),
+ Some("plugins are no longer supported"), 116412),
/// Allows exhaustive integer pattern matching with `usize::MAX`/`isize::MIN`/`isize::MAX`.
- (removed, precise_pointer_size_matching, "1.32.0", Some(56354),
- Some("removed in favor of half-open ranges")),
+ (removed, precise_pointer_size_matching, "1.76.0", Some(56354),
+ Some("removed in favor of half-open ranges"), 118598),
+ (removed, pref_align_of, "CURRENT_RUSTC_VERSION", Some(91971),
+ Some("removed due to marginal use and inducing compiler complications")),
(removed, proc_macro_expr, "1.27.0", Some(54727),
- Some("subsumed by `#![feature(proc_macro_hygiene)]`")),
+ Some("subsumed by `#![feature(proc_macro_hygiene)]`"), 52121),
(removed, proc_macro_gen, "1.27.0", Some(54727),
- Some("subsumed by `#![feature(proc_macro_hygiene)]`")),
+ Some("subsumed by `#![feature(proc_macro_hygiene)]`"), 52121),
(removed, proc_macro_mod, "1.27.0", Some(54727),
- Some("subsumed by `#![feature(proc_macro_hygiene)]`")),
+ Some("subsumed by `#![feature(proc_macro_hygiene)]`"), 52121),
(removed, proc_macro_non_items, "1.27.0", Some(54727),
- Some("subsumed by `#![feature(proc_macro_hygiene)]`")),
+ Some("subsumed by `#![feature(proc_macro_hygiene)]`"), 52121),
(removed, pub_macro_rules, "1.53.0", Some(78855),
Some("removed due to being incomplete, in particular it does not work across crates")),
(removed, pushpop_unsafe, "1.2.0", None, None),
(removed, quad_precision_float, "1.0.0", None, None),
(removed, quote, "1.33.0", Some(29601), None),
- (removed, ref_pat_everywhere, "1.79.0", Some(123076), Some("superseded by `ref_pat_eat_one_layer_2024")),
+ (removed, ref_pat_everywhere, "1.80.0", Some(123076), Some("superseded by `ref_pat_eat_one_layer_2024"), 125168),
(removed, reflect, "1.0.0", Some(27749), None),
/// Allows using the `#[register_attr]` attribute.
(removed, register_attr, "1.65.0", Some(66080),
- Some("removed in favor of `#![register_tool]`")),
+ Some("removed in favor of `#![register_tool]`"), 66070),
(removed, rust_2018_preview, "1.76.0", None,
Some("2018 Edition preview is no longer relevant")),
/// Allows using the macros:
/// + `__diagnostic_used`
/// + `__register_diagnostic`
/// +`__build_diagnostic_array`
- (removed, rustc_diagnostic_macros, "1.38.0", None, None),
+ (removed, rustc_diagnostic_macros, "1.38.0", None, None, 64139),
/// Allows identifying crates that contain sanitizer runtimes.
- (removed, sanitizer_runtime, "1.17.0", None, None),
+ (removed, sanitizer_runtime, "1.17.0", None, None, 65241),
(removed, simd, "1.0.0", Some(27731), Some("removed in favor of `#[repr(simd)]`")),
/// Allows using `#[start]` on a function indicating that it is the program entrypoint.
- (removed, start, "1.0.0", Some(29633), Some("not portable enough and never RFC'd")),
+ (removed, start, "1.86.0", Some(29633), Some("not portable enough and never RFC'd"), 134299),
/// Allows `#[link(kind = "static-nobundle", ...)]`.
- (removed, static_nobundle, "1.16.0", Some(37403),
- Some(r#"subsumed by `#[link(kind = "static", modifiers = "-bundle", ...)]`"#)),
+ (removed, static_nobundle, "1.63.0", Some(37403),
+ Some(r#"subsumed by `#[link(kind = "static", modifiers = "-bundle", ...)]`"#), 95818),
(removed, struct_inherit, "1.0.0", None, None),
(removed, test_removed_feature, "1.0.0", None, None),
/// Allows using items which are missing stability attributes
(removed, unmarked_api, "1.0.0", None, None),
/// Allows unnamed fields of struct and union type
- (removed, unnamed_fields, "1.83.0", Some(49804), Some("feature needs redesign")),
+ (removed, unnamed_fields, "1.83.0", Some(49804), Some("feature needs redesign"), 131045),
(removed, unsafe_no_drop_flag, "1.0.0", None, None),
(removed, unsized_tuple_coercion, "1.87.0", Some(42877),
- Some("The feature restricts possible layouts for tuples, and this restriction is not worth it.")),
+ Some("The feature restricts possible layouts for tuples, and this restriction is not worth it."), 137728),
/// Allows `union` fields that don't implement `Copy` as long as they don't have any drop glue.
- (removed, untagged_unions, "1.13.0", Some(55149),
- Some("unions with `Copy` and `ManuallyDrop` fields are stable; there is no intent to stabilize more")),
+ (removed, untagged_unions, "1.64.0", Some(55149),
+ Some("unions with `Copy` and `ManuallyDrop` fields are stable; there is no intent to stabilize more"), 97995),
/// Allows `#[unwind(..)]`.
///
/// Permits specifying whether a function should permit unwinding or abort on unwind.
- (removed, unwind_attributes, "1.56.0", Some(58760), Some("use the C-unwind ABI instead")),
+ (removed, unwind_attributes, "1.56.0", Some(58760), Some("use the C-unwind ABI instead"), 86155),
(removed, visible_private_types, "1.0.0", None, None),
/// Allows `extern "wasm" fn`
(removed, wasm_abi, "1.81.0", Some(83788),
- Some("non-standard wasm ABI is no longer supported")),
+ Some("non-standard wasm ABI is no longer supported"), 127605),
// !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!!
// Features are listed in alphabetical order. Tidy will fail if you don't keep it this way.
// !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!!
diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs
index b46eac6..594021d 100644
--- a/compiler/rustc_feature/src/unstable.rs
+++ b/compiler/rustc_feature/src/unstable.rs
@@ -546,8 +546,6 @@ pub fn internal(&self, feature: Symbol) -> bool {
(incomplete, inherent_associated_types, "1.52.0", Some(8995)),
/// Allows using `pointer` and `reference` in intra-doc links
(unstable, intra_doc_pointers, "1.51.0", Some(80896)),
- // Allows using the `kl` and `widekl` target features and the associated intrinsics
- (unstable, keylocker_x86, "1.86.0", Some(134813)),
// Allows setting the threshold for the `large_assignments` lint.
(unstable, large_assignments, "1.52.0", Some(83518)),
/// Allow to have type alias types for inter-crate use.
@@ -627,8 +625,6 @@ pub fn internal(&self, feature: Symbol) -> bool {
(unstable, return_type_notation, "1.70.0", Some(109417)),
/// Allows `extern "rust-cold"`.
(unstable, rust_cold_cc, "1.63.0", Some(97544)),
- /// Allows use of x86 SHA512, SM3 and SM4 target-features and intrinsics
- (unstable, sha512_sm_x86, "1.82.0", Some(126624)),
/// Allows the use of SIMD types in functions declared in `extern` blocks.
(unstable, simd_ffi, "1.0.0", Some(27731)),
/// Allows specialization of implementations (RFC 1210).
diff --git a/compiler/rustc_fluent_macro/src/lib.rs b/compiler/rustc_fluent_macro/src/lib.rs
index c6e0484..6f85e05 100644
--- a/compiler/rustc_fluent_macro/src/lib.rs
+++ b/compiler/rustc_fluent_macro/src/lib.rs
@@ -4,7 +4,6 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![doc(rust_logo)]
#![feature(proc_macro_diagnostic)]
-#![feature(proc_macro_span)]
#![feature(rustdoc_internals)]
#![feature(track_path)]
// tidy-alphabetical-end
diff --git a/compiler/rustc_hir/src/lib.rs b/compiler/rustc_hir/src/lib.rs
index 7a5ff89..c6fe475 100644
--- a/compiler/rustc_hir/src/lib.rs
+++ b/compiler/rustc_hir/src/lib.rs
@@ -5,7 +5,6 @@
// tidy-alphabetical-start
#![allow(internal_features)]
#![feature(associated_type_defaults)]
-#![feature(box_patterns)]
#![feature(closure_track_caller)]
#![feature(debug_closure_helpers)]
#![feature(exhaustive_patterns)]
diff --git a/compiler/rustc_hir_analysis/Cargo.toml b/compiler/rustc_hir_analysis/Cargo.toml
index f2b82c6..899370b 100644
--- a/compiler/rustc_hir_analysis/Cargo.toml
+++ b/compiler/rustc_hir_analysis/Cargo.toml
@@ -26,6 +26,7 @@
rustc_middle = { path = "../rustc_middle" }
rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
+rustc_target = { path = "../rustc_target" }
rustc_trait_selection = { path = "../rustc_trait_selection" }
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
tracing = "0.1"
diff --git a/compiler/rustc_hir_analysis/messages.ftl b/compiler/rustc_hir_analysis/messages.ftl
index a3a0e27..4fcd9f8 100644
--- a/compiler/rustc_hir_analysis/messages.ftl
+++ b/compiler/rustc_hir_analysis/messages.ftl
@@ -565,10 +565,6 @@
hir_analysis_unconstrained_opaque_type = unconstrained opaque type
.note = `{$name}` must be used in combination with a concrete type within the same {$what}
-hir_analysis_unrecognized_atomic_operation =
- unrecognized atomic operation function: `{$op}`
- .label = unrecognized atomic operation
-
hir_analysis_unrecognized_intrinsic_function =
unrecognized intrinsic function: `{$name}`
.label = unrecognized intrinsic
diff --git a/compiler/rustc_hir_analysis/src/autoderef.rs b/compiler/rustc_hir_analysis/src/autoderef.rs
index 99e495d..c88c534 100644
--- a/compiler/rustc_hir_analysis/src/autoderef.rs
+++ b/compiler/rustc_hir_analysis/src/autoderef.rs
@@ -160,7 +160,7 @@ fn overloaded_deref_ty(&mut self, ty: Ty<'tcx>) -> Option<Ty<'tcx>> {
self.param_env,
ty::Binder::dummy(trait_ref),
);
- if !self.infcx.predicate_may_hold(&obligation) {
+ if !self.infcx.next_trait_solver() && !self.infcx.predicate_may_hold(&obligation) {
debug!("overloaded_deref_ty: cannot match obligation");
return None;
}
@@ -184,17 +184,17 @@ pub fn structurally_normalize_ty(
self.param_env,
ty,
) else {
- // We shouldn't have errors here, except for evaluate/fulfill mismatches,
- // but that's not a reason for an ICE (`predicate_may_hold` is conservative
- // by design).
- // FIXME(-Znext-solver): This *actually* shouldn't happen then.
+ // We shouldn't have errors here in the old solver, except for
+ // evaluate/fulfill mismatches, but that's not a reason for an ICE.
return None;
};
let errors = ocx.select_where_possible();
if !errors.is_empty() {
- // This shouldn't happen, except for evaluate/fulfill mismatches,
- // but that's not a reason for an ICE (`predicate_may_hold` is conservative
- // by design).
+ if self.infcx.next_trait_solver() {
+ unreachable!();
+ }
+ // We shouldn't have errors here in the old solver, except for
+ // evaluate/fulfill mismatches, but that's not a reason for an ICE.
debug!(?errors, "encountered errors while fulfilling");
return None;
}
diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs
index 8c52f5d..60ca0155b 100644
--- a/compiler/rustc_hir_analysis/src/check/check.rs
+++ b/compiler/rustc_hir_analysis/src/check/check.rs
@@ -4,14 +4,15 @@
use rustc_abi::FieldIdx;
use rustc_attr_data_structures::ReprAttr::ReprPacked;
use rustc_data_structures::unord::{UnordMap, UnordSet};
-use rustc_errors::MultiSpan;
use rustc_errors::codes::*;
+use rustc_errors::{EmissionGuarantee, MultiSpan};
use rustc_hir::def::{CtorKind, DefKind};
use rustc_hir::{LangItem, Node, intravisit};
use rustc_infer::infer::{RegionVariableOrigin, TyCtxtInferExt};
use rustc_infer::traits::{Obligation, ObligationCauseCode};
use rustc_lint_defs::builtin::{
- REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS, UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS,
+ REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS, UNSUPPORTED_CALLING_CONVENTIONS,
+ UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS,
};
use rustc_middle::hir::nested_filter;
use rustc_middle::middle::resolve_bound_vars::ResolvedArg;
@@ -24,6 +25,7 @@
TypeVisitable, TypeVisitableExt, fold_regions,
};
use rustc_session::lint::builtin::UNINHABITED_STATIC;
+use rustc_target::spec::{AbiMap, AbiMapping};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::error_reporting::traits::on_unimplemented::OnUnimplementedDirective;
use rustc_trait_selection::traits;
@@ -35,25 +37,66 @@
use super::compare_impl_item::check_type_bounds;
use super::*;
-pub fn check_abi(tcx: TyCtxt<'_>, span: Span, abi: ExternAbi) {
- if !tcx.sess.target.is_abi_supported(abi) {
- struct_span_code_err!(
- tcx.dcx(),
- span,
- E0570,
- "`{abi}` is not a supported ABI for the current target",
- )
- .emit();
+fn add_abi_diag_help<T: EmissionGuarantee>(abi: ExternAbi, diag: &mut Diag<'_, T>) {
+ if let ExternAbi::Cdecl { unwind } = abi {
+ let c_abi = ExternAbi::C { unwind };
+ diag.help(format!("use `extern {c_abi}` instead",));
+ } else if let ExternAbi::Stdcall { unwind } = abi {
+ let c_abi = ExternAbi::C { unwind };
+ let system_abi = ExternAbi::System { unwind };
+ diag.help(format!(
+ "if you need `extern {abi}` on win32 and `extern {c_abi}` everywhere else, \
+ use `extern {system_abi}`"
+ ));
+ }
+}
+
+pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: ExternAbi) {
+ // FIXME: this should be checked earlier, e.g. in `rustc_ast_lowering`, to fix
+ // things like #86232.
+
+ match AbiMap::from_target(&tcx.sess.target).canonize_abi(abi, false) {
+ AbiMapping::Direct(..) => (),
+ AbiMapping::Invalid => {
+ let mut err = struct_span_code_err!(
+ tcx.dcx(),
+ span,
+ E0570,
+ "`{abi}` is not a supported ABI for the current target",
+ );
+ add_abi_diag_help(abi, &mut err);
+ err.emit();
+ }
+ AbiMapping::Deprecated(..) => {
+ tcx.node_span_lint(UNSUPPORTED_CALLING_CONVENTIONS, hir_id, span, |lint| {
+ lint.primary_message("use of calling convention not supported on this target");
+ add_abi_diag_help(abi, lint);
+ });
+ }
}
}
pub fn check_abi_fn_ptr(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: ExternAbi) {
- if !tcx.sess.target.is_abi_supported(abi) {
- tcx.node_span_lint(UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS, hir_id, span, |lint| {
- lint.primary_message(format!(
- "the calling convention {abi} is not supported on this target"
- ));
- });
+ // This is always an FCW, even for `AbiMapping::Invalid`, since we started linting later than
+ // in `check_abi` above.
+ match AbiMap::from_target(&tcx.sess.target).canonize_abi(abi, false) {
+ AbiMapping::Direct(..) => (),
+ // This is not a redundant match arm: these ABIs started linting after introducing
+ // UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS already existed and we want to
+ // avoid expanding the scope of that lint so it can move to a hard error sooner.
+ AbiMapping::Deprecated(..) => {
+ tcx.node_span_lint(UNSUPPORTED_CALLING_CONVENTIONS, hir_id, span, |lint| {
+ lint.primary_message("use of calling convention not supported on this target");
+ add_abi_diag_help(abi, lint);
+ });
+ }
+ AbiMapping::Invalid => {
+ tcx.node_span_lint(UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS, hir_id, span, |lint| {
+ lint.primary_message(format!(
+ "the calling convention {abi} is not supported on this target"
+ ));
+ });
+ }
}
}
@@ -812,7 +855,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
let hir::ItemKind::ForeignMod { abi, items } = it.kind else {
return;
};
- check_abi(tcx, it.span, abi);
+ check_abi(tcx, it.hir_id(), it.span, abi);
for item in items {
let def_id = item.id.owner_id.def_id;
diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs
index 234520c..481cdaa 100644
--- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs
+++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs
@@ -9,10 +9,7 @@
use rustc_span::{Span, Symbol, sym};
use crate::check::check_function_signature;
-use crate::errors::{
- UnrecognizedAtomicOperation, UnrecognizedIntrinsicFunction,
- WrongNumberOfGenericArgumentsToIntrinsic,
-};
+use crate::errors::{UnrecognizedIntrinsicFunction, WrongNumberOfGenericArgumentsToIntrinsic};
fn equate_intrinsic_type<'tcx>(
tcx: TyCtxt<'tcx>,
@@ -172,7 +169,6 @@ pub(crate) fn check_intrinsic_type(
Ty::new_error_with_message(tcx, span, "expected param")
}
};
- let name_str = intrinsic_name.as_str();
let bound_vars = tcx.mk_bound_variable_kinds(&[
ty::BoundVariableKind::Region(ty::BoundRegionKind::Anon),
@@ -198,508 +194,471 @@ pub(crate) fn check_intrinsic_type(
(Ty::new_ref(tcx, env_region, va_list_ty, mutbl), va_list_ty)
};
- let (n_tps, n_lts, n_cts, inputs, output, safety) = if name_str.starts_with("atomic_") {
- let split: Vec<&str> = name_str.split('_').collect();
- assert!(split.len() >= 2, "Atomic intrinsic in an incorrect format");
+ let safety = intrinsic_operation_unsafety(tcx, intrinsic_id);
+ let n_lts = 0;
+ let (n_tps, n_cts, inputs, output) = match intrinsic_name {
+ sym::abort => (0, 0, vec![], tcx.types.never),
+ sym::unreachable => (0, 0, vec![], tcx.types.never),
+ sym::breakpoint => (0, 0, vec![], tcx.types.unit),
+ sym::size_of | sym::pref_align_of | sym::min_align_of | sym::variant_count => {
+ (1, 0, vec![], tcx.types.usize)
+ }
+ sym::size_of_val | sym::min_align_of_val => {
+ (1, 0, vec![Ty::new_imm_ptr(tcx, param(0))], tcx.types.usize)
+ }
+ sym::rustc_peek => (1, 0, vec![param(0)], param(0)),
+ sym::caller_location => (0, 0, vec![], tcx.caller_location_ty()),
+ sym::assert_inhabited | sym::assert_zero_valid | sym::assert_mem_uninitialized_valid => {
+ (1, 0, vec![], tcx.types.unit)
+ }
+ sym::forget => (1, 0, vec![param(0)], tcx.types.unit),
+ sym::transmute | sym::transmute_unchecked => (2, 0, vec![param(0)], param(1)),
+ sym::prefetch_read_data
+ | sym::prefetch_write_data
+ | sym::prefetch_read_instruction
+ | sym::prefetch_write_instruction => {
+ (1, 0, vec![Ty::new_imm_ptr(tcx, param(0)), tcx.types.i32], tcx.types.unit)
+ }
+ sym::needs_drop => (1, 0, vec![], tcx.types.bool),
- // Each atomic op has variants with different suffixes (`_seq_cst`, `_acquire`, etc.). Use
- // string ops to strip the suffixes, because the variants all get the same treatment here.
- let (n_tps, n_cts, inputs, output) = match split[1] {
- "cxchg" | "cxchgweak" => (
+ sym::type_name => (1, 0, vec![], Ty::new_static_str(tcx)),
+ sym::type_id => (1, 0, vec![], tcx.types.u128),
+ sym::offset => (2, 0, vec![param(0), param(1)], param(0)),
+ sym::arith_offset => (
+ 1,
+ 0,
+ vec![Ty::new_imm_ptr(tcx, param(0)), tcx.types.isize],
+ Ty::new_imm_ptr(tcx, param(0)),
+ ),
+ sym::slice_get_unchecked => (3, 0, vec![param(1), tcx.types.usize], param(0)),
+ sym::ptr_mask => (
+ 1,
+ 0,
+ vec![Ty::new_imm_ptr(tcx, param(0)), tcx.types.usize],
+ Ty::new_imm_ptr(tcx, param(0)),
+ ),
+
+ sym::copy | sym::copy_nonoverlapping => (
+ 1,
+ 0,
+ vec![Ty::new_imm_ptr(tcx, param(0)), Ty::new_mut_ptr(tcx, param(0)), tcx.types.usize],
+ tcx.types.unit,
+ ),
+ sym::volatile_copy_memory | sym::volatile_copy_nonoverlapping_memory => (
+ 1,
+ 0,
+ vec![Ty::new_mut_ptr(tcx, param(0)), Ty::new_imm_ptr(tcx, param(0)), tcx.types.usize],
+ tcx.types.unit,
+ ),
+ sym::compare_bytes => {
+ let byte_ptr = Ty::new_imm_ptr(tcx, tcx.types.u8);
+ (0, 0, vec![byte_ptr, byte_ptr, tcx.types.usize], tcx.types.i32)
+ }
+ sym::write_bytes | sym::volatile_set_memory => (
+ 1,
+ 0,
+ vec![Ty::new_mut_ptr(tcx, param(0)), tcx.types.u8, tcx.types.usize],
+ tcx.types.unit,
+ ),
+
+ sym::sqrtf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
+ sym::sqrtf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
+ sym::sqrtf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
+ sym::sqrtf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
+
+ sym::powif16 => (0, 0, vec![tcx.types.f16, tcx.types.i32], tcx.types.f16),
+ sym::powif32 => (0, 0, vec![tcx.types.f32, tcx.types.i32], tcx.types.f32),
+ sym::powif64 => (0, 0, vec![tcx.types.f64, tcx.types.i32], tcx.types.f64),
+ sym::powif128 => (0, 0, vec![tcx.types.f128, tcx.types.i32], tcx.types.f128),
+
+ sym::sinf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
+ sym::sinf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
+ sym::sinf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
+ sym::sinf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
+
+ sym::cosf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
+ sym::cosf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
+ sym::cosf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
+ sym::cosf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
+
+ sym::powf16 => (0, 0, vec![tcx.types.f16, tcx.types.f16], tcx.types.f16),
+ sym::powf32 => (0, 0, vec![tcx.types.f32, tcx.types.f32], tcx.types.f32),
+ sym::powf64 => (0, 0, vec![tcx.types.f64, tcx.types.f64], tcx.types.f64),
+ sym::powf128 => (0, 0, vec![tcx.types.f128, tcx.types.f128], tcx.types.f128),
+
+ sym::expf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
+ sym::expf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
+ sym::expf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
+ sym::expf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
+
+ sym::exp2f16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
+ sym::exp2f32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
+ sym::exp2f64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
+ sym::exp2f128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
+
+ sym::logf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
+ sym::logf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
+ sym::logf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
+ sym::logf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
+
+ sym::log10f16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
+ sym::log10f32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
+ sym::log10f64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
+ sym::log10f128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
+
+ sym::log2f16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
+ sym::log2f32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
+ sym::log2f64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
+ sym::log2f128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
+
+ sym::fmaf16 => (0, 0, vec![tcx.types.f16, tcx.types.f16, tcx.types.f16], tcx.types.f16),
+ sym::fmaf32 => (0, 0, vec![tcx.types.f32, tcx.types.f32, tcx.types.f32], tcx.types.f32),
+ sym::fmaf64 => (0, 0, vec![tcx.types.f64, tcx.types.f64, tcx.types.f64], tcx.types.f64),
+ sym::fmaf128 => {
+ (0, 0, vec![tcx.types.f128, tcx.types.f128, tcx.types.f128], tcx.types.f128)
+ }
+
+ sym::fmuladdf16 => (0, 0, vec![tcx.types.f16, tcx.types.f16, tcx.types.f16], tcx.types.f16),
+ sym::fmuladdf32 => (0, 0, vec![tcx.types.f32, tcx.types.f32, tcx.types.f32], tcx.types.f32),
+ sym::fmuladdf64 => (0, 0, vec![tcx.types.f64, tcx.types.f64, tcx.types.f64], tcx.types.f64),
+ sym::fmuladdf128 => {
+ (0, 0, vec![tcx.types.f128, tcx.types.f128, tcx.types.f128], tcx.types.f128)
+ }
+
+ sym::fabsf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
+ sym::fabsf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
+ sym::fabsf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
+ sym::fabsf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
+
+ sym::minnumf16 => (0, 0, vec![tcx.types.f16, tcx.types.f16], tcx.types.f16),
+ sym::minnumf32 => (0, 0, vec![tcx.types.f32, tcx.types.f32], tcx.types.f32),
+ sym::minnumf64 => (0, 0, vec![tcx.types.f64, tcx.types.f64], tcx.types.f64),
+ sym::minnumf128 => (0, 0, vec![tcx.types.f128, tcx.types.f128], tcx.types.f128),
+
+ sym::minimumf16 => (0, 0, vec![tcx.types.f16, tcx.types.f16], tcx.types.f16),
+ sym::minimumf32 => (0, 0, vec![tcx.types.f32, tcx.types.f32], tcx.types.f32),
+ sym::minimumf64 => (0, 0, vec![tcx.types.f64, tcx.types.f64], tcx.types.f64),
+ sym::minimumf128 => (0, 0, vec![tcx.types.f128, tcx.types.f128], tcx.types.f128),
+
+ sym::maxnumf16 => (0, 0, vec![tcx.types.f16, tcx.types.f16], tcx.types.f16),
+ sym::maxnumf32 => (0, 0, vec![tcx.types.f32, tcx.types.f32], tcx.types.f32),
+ sym::maxnumf64 => (0, 0, vec![tcx.types.f64, tcx.types.f64], tcx.types.f64),
+ sym::maxnumf128 => (0, 0, vec![tcx.types.f128, tcx.types.f128], tcx.types.f128),
+
+ sym::maximumf16 => (0, 0, vec![tcx.types.f16, tcx.types.f16], tcx.types.f16),
+ sym::maximumf32 => (0, 0, vec![tcx.types.f32, tcx.types.f32], tcx.types.f32),
+ sym::maximumf64 => (0, 0, vec![tcx.types.f64, tcx.types.f64], tcx.types.f64),
+ sym::maximumf128 => (0, 0, vec![tcx.types.f128, tcx.types.f128], tcx.types.f128),
+
+ sym::copysignf16 => (0, 0, vec![tcx.types.f16, tcx.types.f16], tcx.types.f16),
+ sym::copysignf32 => (0, 0, vec![tcx.types.f32, tcx.types.f32], tcx.types.f32),
+ sym::copysignf64 => (0, 0, vec![tcx.types.f64, tcx.types.f64], tcx.types.f64),
+ sym::copysignf128 => (0, 0, vec![tcx.types.f128, tcx.types.f128], tcx.types.f128),
+
+ sym::floorf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
+ sym::floorf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
+ sym::floorf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
+ sym::floorf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
+
+ sym::ceilf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
+ sym::ceilf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
+ sym::ceilf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
+ sym::ceilf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
+
+ sym::truncf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
+ sym::truncf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
+ sym::truncf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
+ sym::truncf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
+
+ sym::round_ties_even_f16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
+ sym::round_ties_even_f32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
+ sym::round_ties_even_f64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
+ sym::round_ties_even_f128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
+
+ sym::roundf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
+ sym::roundf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
+ sym::roundf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
+ sym::roundf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
+
+ sym::volatile_load | sym::unaligned_volatile_load => {
+ (1, 0, vec![Ty::new_imm_ptr(tcx, param(0))], param(0))
+ }
+ sym::volatile_store | sym::unaligned_volatile_store => {
+ (1, 0, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], tcx.types.unit)
+ }
+
+ sym::ctpop | sym::ctlz | sym::ctlz_nonzero | sym::cttz | sym::cttz_nonzero => {
+ (1, 0, vec![param(0)], tcx.types.u32)
+ }
+
+ sym::bswap | sym::bitreverse => (1, 0, vec![param(0)], param(0)),
+
+ sym::three_way_compare => (1, 0, vec![param(0), param(0)], tcx.ty_ordering_enum(span)),
+
+ sym::add_with_overflow | sym::sub_with_overflow | sym::mul_with_overflow => {
+ (1, 0, vec![param(0), param(0)], Ty::new_tup(tcx, &[param(0), tcx.types.bool]))
+ }
+
+ sym::carrying_mul_add => (2, 0, vec![param(0); 4], Ty::new_tup(tcx, &[param(1), param(0)])),
+
+ sym::ptr_guaranteed_cmp => (
+ 1,
+ 0,
+ vec![Ty::new_imm_ptr(tcx, param(0)), Ty::new_imm_ptr(tcx, param(0))],
+ tcx.types.u8,
+ ),
+
+ sym::const_allocate => {
+ (0, 0, vec![tcx.types.usize, tcx.types.usize], Ty::new_mut_ptr(tcx, tcx.types.u8))
+ }
+ sym::const_deallocate => (
+ 0,
+ 0,
+ vec![Ty::new_mut_ptr(tcx, tcx.types.u8), tcx.types.usize, tcx.types.usize],
+ tcx.types.unit,
+ ),
+
+ sym::ptr_offset_from => (
+ 1,
+ 0,
+ vec![Ty::new_imm_ptr(tcx, param(0)), Ty::new_imm_ptr(tcx, param(0))],
+ tcx.types.isize,
+ ),
+ sym::ptr_offset_from_unsigned => (
+ 1,
+ 0,
+ vec![Ty::new_imm_ptr(tcx, param(0)), Ty::new_imm_ptr(tcx, param(0))],
+ tcx.types.usize,
+ ),
+ sym::unchecked_div | sym::unchecked_rem | sym::exact_div | sym::disjoint_bitor => {
+ (1, 0, vec![param(0), param(0)], param(0))
+ }
+ sym::unchecked_shl | sym::unchecked_shr => (2, 0, vec![param(0), param(1)], param(0)),
+ sym::rotate_left | sym::rotate_right => (1, 0, vec![param(0), tcx.types.u32], param(0)),
+ sym::unchecked_add | sym::unchecked_sub | sym::unchecked_mul => {
+ (1, 0, vec![param(0), param(0)], param(0))
+ }
+ sym::wrapping_add | sym::wrapping_sub | sym::wrapping_mul => {
+ (1, 0, vec![param(0), param(0)], param(0))
+ }
+ sym::saturating_add | sym::saturating_sub => (1, 0, vec![param(0), param(0)], param(0)),
+ sym::fadd_fast | sym::fsub_fast | sym::fmul_fast | sym::fdiv_fast | sym::frem_fast => {
+ (1, 0, vec![param(0), param(0)], param(0))
+ }
+ sym::fadd_algebraic
+ | sym::fsub_algebraic
+ | sym::fmul_algebraic
+ | sym::fdiv_algebraic
+ | sym::frem_algebraic => (1, 0, vec![param(0), param(0)], param(0)),
+ sym::float_to_int_unchecked => (2, 0, vec![param(0)], param(1)),
+
+ sym::assume => (0, 0, vec![tcx.types.bool], tcx.types.unit),
+ sym::select_unpredictable => (1, 0, vec![tcx.types.bool, param(0), param(0)], param(0)),
+ sym::cold_path => (0, 0, vec![], tcx.types.unit),
+
+ sym::read_via_copy => (1, 0, vec![Ty::new_imm_ptr(tcx, param(0))], param(0)),
+ sym::write_via_move => {
+ (1, 0, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], tcx.types.unit)
+ }
+
+ sym::typed_swap_nonoverlapping => {
+ (1, 0, vec![Ty::new_mut_ptr(tcx, param(0)); 2], tcx.types.unit)
+ }
+
+ sym::discriminant_value => {
+ let assoc_items = tcx.associated_item_def_ids(
+ tcx.require_lang_item(hir::LangItem::DiscriminantKind, span),
+ );
+ let discriminant_def_id = assoc_items[0];
+
+ let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BoundRegionKind::Anon };
+ (
1,
0,
- vec![Ty::new_mut_ptr(tcx, param(0)), param(0), param(0)],
- Ty::new_tup(tcx, &[param(0), tcx.types.bool]),
- ),
- "load" => (1, 1, vec![Ty::new_imm_ptr(tcx, param(0))], param(0)),
- "store" => (1, 0, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], tcx.types.unit),
+ vec![Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0))],
+ Ty::new_projection_from_args(
+ tcx,
+ discriminant_def_id,
+ tcx.mk_args(&[param(0).into()]),
+ ),
+ )
+ }
- "xchg" | "xadd" | "xsub" | "and" | "nand" | "or" | "xor" | "max" | "min" | "umax"
- | "umin" => (1, 0, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], param(0)),
- "fence" | "singlethreadfence" => (0, 0, Vec::new(), tcx.types.unit),
- op => {
- tcx.dcx().emit_err(UnrecognizedAtomicOperation { span, op });
- return;
- }
- };
- (n_tps, 0, n_cts, inputs, output, hir::Safety::Unsafe)
- } else if intrinsic_name == sym::contract_check_ensures {
- // contract_check_ensures::<Ret, C>(Ret, C) -> Ret
- // where C: for<'a> Fn(&'a Ret) -> bool,
- //
- // so: two type params, 0 lifetime param, 0 const params, two inputs, no return
- (2, 0, 0, vec![param(0), param(1)], param(1), hir::Safety::Safe)
- } else {
- let safety = intrinsic_operation_unsafety(tcx, intrinsic_id);
- let (n_tps, n_cts, inputs, output) = match intrinsic_name {
- sym::abort => (0, 0, vec![], tcx.types.never),
- sym::unreachable => (0, 0, vec![], tcx.types.never),
- sym::breakpoint => (0, 0, vec![], tcx.types.unit),
- sym::size_of | sym::pref_align_of | sym::min_align_of | sym::variant_count => {
- (1, 0, vec![], tcx.types.usize)
- }
- sym::size_of_val | sym::min_align_of_val => {
- (1, 0, vec![Ty::new_imm_ptr(tcx, param(0))], tcx.types.usize)
- }
- sym::rustc_peek => (1, 0, vec![param(0)], param(0)),
- sym::caller_location => (0, 0, vec![], tcx.caller_location_ty()),
- sym::assert_inhabited
- | sym::assert_zero_valid
- | sym::assert_mem_uninitialized_valid => (1, 0, vec![], tcx.types.unit),
- sym::forget => (1, 0, vec![param(0)], tcx.types.unit),
- sym::transmute | sym::transmute_unchecked => (2, 0, vec![param(0)], param(1)),
- sym::prefetch_read_data
- | sym::prefetch_write_data
- | sym::prefetch_read_instruction
- | sym::prefetch_write_instruction => {
- (1, 0, vec![Ty::new_imm_ptr(tcx, param(0)), tcx.types.i32], tcx.types.unit)
- }
- sym::needs_drop => (1, 0, vec![], tcx.types.bool),
-
- sym::type_name => (1, 0, vec![], Ty::new_static_str(tcx)),
- sym::type_id => (1, 0, vec![], tcx.types.u128),
- sym::offset => (2, 0, vec![param(0), param(1)], param(0)),
- sym::arith_offset => (
- 1,
- 0,
- vec![Ty::new_imm_ptr(tcx, param(0)), tcx.types.isize],
- Ty::new_imm_ptr(tcx, param(0)),
- ),
- sym::slice_get_unchecked => (3, 0, vec![param(1), tcx.types.usize], param(0)),
- sym::ptr_mask => (
- 1,
- 0,
- vec![Ty::new_imm_ptr(tcx, param(0)), tcx.types.usize],
- Ty::new_imm_ptr(tcx, param(0)),
- ),
-
- sym::copy | sym::copy_nonoverlapping => (
- 1,
- 0,
- vec![
- Ty::new_imm_ptr(tcx, param(0)),
- Ty::new_mut_ptr(tcx, param(0)),
- tcx.types.usize,
- ],
+ sym::catch_unwind => {
+ let mut_u8 = Ty::new_mut_ptr(tcx, tcx.types.u8);
+ let try_fn_ty = ty::Binder::dummy(tcx.mk_fn_sig(
+ [mut_u8],
tcx.types.unit,
- ),
- sym::volatile_copy_memory | sym::volatile_copy_nonoverlapping_memory => (
- 1,
- 0,
- vec![
- Ty::new_mut_ptr(tcx, param(0)),
- Ty::new_imm_ptr(tcx, param(0)),
- tcx.types.usize,
- ],
+ false,
+ hir::Safety::Safe,
+ ExternAbi::Rust,
+ ));
+ let catch_fn_ty = ty::Binder::dummy(tcx.mk_fn_sig(
+ [mut_u8, mut_u8],
tcx.types.unit,
- ),
- sym::compare_bytes => {
- let byte_ptr = Ty::new_imm_ptr(tcx, tcx.types.u8);
- (0, 0, vec![byte_ptr, byte_ptr, tcx.types.usize], tcx.types.i32)
- }
- sym::write_bytes | sym::volatile_set_memory => (
- 1,
- 0,
- vec![Ty::new_mut_ptr(tcx, param(0)), tcx.types.u8, tcx.types.usize],
- tcx.types.unit,
- ),
-
- sym::sqrtf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
- sym::sqrtf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
- sym::sqrtf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
- sym::sqrtf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
-
- sym::powif16 => (0, 0, vec![tcx.types.f16, tcx.types.i32], tcx.types.f16),
- sym::powif32 => (0, 0, vec![tcx.types.f32, tcx.types.i32], tcx.types.f32),
- sym::powif64 => (0, 0, vec![tcx.types.f64, tcx.types.i32], tcx.types.f64),
- sym::powif128 => (0, 0, vec![tcx.types.f128, tcx.types.i32], tcx.types.f128),
-
- sym::sinf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
- sym::sinf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
- sym::sinf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
- sym::sinf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
-
- sym::cosf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
- sym::cosf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
- sym::cosf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
- sym::cosf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
-
- sym::powf16 => (0, 0, vec![tcx.types.f16, tcx.types.f16], tcx.types.f16),
- sym::powf32 => (0, 0, vec![tcx.types.f32, tcx.types.f32], tcx.types.f32),
- sym::powf64 => (0, 0, vec![tcx.types.f64, tcx.types.f64], tcx.types.f64),
- sym::powf128 => (0, 0, vec![tcx.types.f128, tcx.types.f128], tcx.types.f128),
-
- sym::expf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
- sym::expf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
- sym::expf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
- sym::expf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
-
- sym::exp2f16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
- sym::exp2f32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
- sym::exp2f64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
- sym::exp2f128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
-
- sym::logf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
- sym::logf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
- sym::logf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
- sym::logf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
-
- sym::log10f16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
- sym::log10f32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
- sym::log10f64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
- sym::log10f128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
-
- sym::log2f16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
- sym::log2f32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
- sym::log2f64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
- sym::log2f128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
-
- sym::fmaf16 => (0, 0, vec![tcx.types.f16, tcx.types.f16, tcx.types.f16], tcx.types.f16),
- sym::fmaf32 => (0, 0, vec![tcx.types.f32, tcx.types.f32, tcx.types.f32], tcx.types.f32),
- sym::fmaf64 => (0, 0, vec![tcx.types.f64, tcx.types.f64, tcx.types.f64], tcx.types.f64),
- sym::fmaf128 => {
- (0, 0, vec![tcx.types.f128, tcx.types.f128, tcx.types.f128], tcx.types.f128)
- }
-
- sym::fmuladdf16 => {
- (0, 0, vec![tcx.types.f16, tcx.types.f16, tcx.types.f16], tcx.types.f16)
- }
- sym::fmuladdf32 => {
- (0, 0, vec![tcx.types.f32, tcx.types.f32, tcx.types.f32], tcx.types.f32)
- }
- sym::fmuladdf64 => {
- (0, 0, vec![tcx.types.f64, tcx.types.f64, tcx.types.f64], tcx.types.f64)
- }
- sym::fmuladdf128 => {
- (0, 0, vec![tcx.types.f128, tcx.types.f128, tcx.types.f128], tcx.types.f128)
- }
-
- sym::fabsf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
- sym::fabsf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
- sym::fabsf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
- sym::fabsf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
-
- sym::minnumf16 => (0, 0, vec![tcx.types.f16, tcx.types.f16], tcx.types.f16),
- sym::minnumf32 => (0, 0, vec![tcx.types.f32, tcx.types.f32], tcx.types.f32),
- sym::minnumf64 => (0, 0, vec![tcx.types.f64, tcx.types.f64], tcx.types.f64),
- sym::minnumf128 => (0, 0, vec![tcx.types.f128, tcx.types.f128], tcx.types.f128),
-
- sym::minimumf16 => (0, 0, vec![tcx.types.f16, tcx.types.f16], tcx.types.f16),
- sym::minimumf32 => (0, 0, vec![tcx.types.f32, tcx.types.f32], tcx.types.f32),
- sym::minimumf64 => (0, 0, vec![tcx.types.f64, tcx.types.f64], tcx.types.f64),
- sym::minimumf128 => (0, 0, vec![tcx.types.f128, tcx.types.f128], tcx.types.f128),
-
- sym::maxnumf16 => (0, 0, vec![tcx.types.f16, tcx.types.f16], tcx.types.f16),
- sym::maxnumf32 => (0, 0, vec![tcx.types.f32, tcx.types.f32], tcx.types.f32),
- sym::maxnumf64 => (0, 0, vec![tcx.types.f64, tcx.types.f64], tcx.types.f64),
- sym::maxnumf128 => (0, 0, vec![tcx.types.f128, tcx.types.f128], tcx.types.f128),
-
- sym::maximumf16 => (0, 0, vec![tcx.types.f16, tcx.types.f16], tcx.types.f16),
- sym::maximumf32 => (0, 0, vec![tcx.types.f32, tcx.types.f32], tcx.types.f32),
- sym::maximumf64 => (0, 0, vec![tcx.types.f64, tcx.types.f64], tcx.types.f64),
- sym::maximumf128 => (0, 0, vec![tcx.types.f128, tcx.types.f128], tcx.types.f128),
-
- sym::copysignf16 => (0, 0, vec![tcx.types.f16, tcx.types.f16], tcx.types.f16),
- sym::copysignf32 => (0, 0, vec![tcx.types.f32, tcx.types.f32], tcx.types.f32),
- sym::copysignf64 => (0, 0, vec![tcx.types.f64, tcx.types.f64], tcx.types.f64),
- sym::copysignf128 => (0, 0, vec![tcx.types.f128, tcx.types.f128], tcx.types.f128),
-
- sym::floorf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
- sym::floorf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
- sym::floorf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
- sym::floorf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
-
- sym::ceilf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
- sym::ceilf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
- sym::ceilf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
- sym::ceilf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
-
- sym::truncf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
- sym::truncf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
- sym::truncf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
- sym::truncf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
-
- sym::round_ties_even_f16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
- sym::round_ties_even_f32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
- sym::round_ties_even_f64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
- sym::round_ties_even_f128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
-
- sym::roundf16 => (0, 0, vec![tcx.types.f16], tcx.types.f16),
- sym::roundf32 => (0, 0, vec![tcx.types.f32], tcx.types.f32),
- sym::roundf64 => (0, 0, vec![tcx.types.f64], tcx.types.f64),
- sym::roundf128 => (0, 0, vec![tcx.types.f128], tcx.types.f128),
-
- sym::volatile_load | sym::unaligned_volatile_load => {
- (1, 0, vec![Ty::new_imm_ptr(tcx, param(0))], param(0))
- }
- sym::volatile_store | sym::unaligned_volatile_store => {
- (1, 0, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], tcx.types.unit)
- }
-
- sym::ctpop | sym::ctlz | sym::ctlz_nonzero | sym::cttz | sym::cttz_nonzero => {
- (1, 0, vec![param(0)], tcx.types.u32)
- }
-
- sym::bswap | sym::bitreverse => (1, 0, vec![param(0)], param(0)),
-
- sym::three_way_compare => (1, 0, vec![param(0), param(0)], tcx.ty_ordering_enum(span)),
-
- sym::add_with_overflow | sym::sub_with_overflow | sym::mul_with_overflow => {
- (1, 0, vec![param(0), param(0)], Ty::new_tup(tcx, &[param(0), tcx.types.bool]))
- }
-
- sym::carrying_mul_add => {
- (2, 0, vec![param(0); 4], Ty::new_tup(tcx, &[param(1), param(0)]))
- }
-
- sym::ptr_guaranteed_cmp => (
- 1,
- 0,
- vec![Ty::new_imm_ptr(tcx, param(0)), Ty::new_imm_ptr(tcx, param(0))],
- tcx.types.u8,
- ),
-
- sym::const_allocate => {
- (0, 0, vec![tcx.types.usize, tcx.types.usize], Ty::new_mut_ptr(tcx, tcx.types.u8))
- }
- sym::const_deallocate => (
+ false,
+ hir::Safety::Safe,
+ ExternAbi::Rust,
+ ));
+ (
0,
0,
- vec![Ty::new_mut_ptr(tcx, tcx.types.u8), tcx.types.usize, tcx.types.usize],
- tcx.types.unit,
- ),
+ vec![Ty::new_fn_ptr(tcx, try_fn_ty), mut_u8, Ty::new_fn_ptr(tcx, catch_fn_ty)],
+ tcx.types.i32,
+ )
+ }
- sym::ptr_offset_from => (
- 1,
- 0,
- vec![Ty::new_imm_ptr(tcx, param(0)), Ty::new_imm_ptr(tcx, param(0))],
- tcx.types.isize,
- ),
- sym::ptr_offset_from_unsigned => (
- 1,
- 0,
- vec![Ty::new_imm_ptr(tcx, param(0)), Ty::new_imm_ptr(tcx, param(0))],
- tcx.types.usize,
- ),
- sym::unchecked_div | sym::unchecked_rem | sym::exact_div | sym::disjoint_bitor => {
- (1, 0, vec![param(0), param(0)], param(0))
- }
- sym::unchecked_shl | sym::unchecked_shr => (2, 0, vec![param(0), param(1)], param(0)),
- sym::rotate_left | sym::rotate_right => (1, 0, vec![param(0), tcx.types.u32], param(0)),
- sym::unchecked_add | sym::unchecked_sub | sym::unchecked_mul => {
- (1, 0, vec![param(0), param(0)], param(0))
- }
- sym::wrapping_add | sym::wrapping_sub | sym::wrapping_mul => {
- (1, 0, vec![param(0), param(0)], param(0))
- }
- sym::saturating_add | sym::saturating_sub => (1, 0, vec![param(0), param(0)], param(0)),
- sym::fadd_fast | sym::fsub_fast | sym::fmul_fast | sym::fdiv_fast | sym::frem_fast => {
- (1, 0, vec![param(0), param(0)], param(0))
- }
- sym::fadd_algebraic
- | sym::fsub_algebraic
- | sym::fmul_algebraic
- | sym::fdiv_algebraic
- | sym::frem_algebraic => (1, 0, vec![param(0), param(0)], param(0)),
- sym::float_to_int_unchecked => (2, 0, vec![param(0)], param(1)),
+ sym::va_start | sym::va_end => {
+ (0, 0, vec![mk_va_list_ty(hir::Mutability::Mut).0], tcx.types.unit)
+ }
- sym::assume => (0, 0, vec![tcx.types.bool], tcx.types.unit),
- sym::select_unpredictable => (1, 0, vec![tcx.types.bool, param(0), param(0)], param(0)),
- sym::cold_path => (0, 0, vec![], tcx.types.unit),
+ sym::va_copy => {
+ let (va_list_ref_ty, va_list_ty) = mk_va_list_ty(hir::Mutability::Not);
+ let va_list_ptr_ty = Ty::new_mut_ptr(tcx, va_list_ty);
+ (0, 0, vec![va_list_ptr_ty, va_list_ref_ty], tcx.types.unit)
+ }
- sym::read_via_copy => (1, 0, vec![Ty::new_imm_ptr(tcx, param(0))], param(0)),
- sym::write_via_move => {
- (1, 0, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], tcx.types.unit)
- }
+ sym::va_arg => (1, 0, vec![mk_va_list_ty(hir::Mutability::Mut).0], param(0)),
- sym::typed_swap_nonoverlapping => {
- (1, 0, vec![Ty::new_mut_ptr(tcx, param(0)); 2], tcx.types.unit)
- }
+ sym::nontemporal_store => {
+ (1, 0, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], tcx.types.unit)
+ }
- sym::discriminant_value => {
- let assoc_items = tcx.associated_item_def_ids(
- tcx.require_lang_item(hir::LangItem::DiscriminantKind, span),
- );
- let discriminant_def_id = assoc_items[0];
+ sym::raw_eq => {
+ let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BoundRegionKind::Anon };
+ let param_ty_lhs =
+ Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0));
+ let br =
+ ty::BoundRegion { var: ty::BoundVar::from_u32(1), kind: ty::BoundRegionKind::Anon };
+ let param_ty_rhs =
+ Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0));
+ (1, 0, vec![param_ty_lhs, param_ty_rhs], tcx.types.bool)
+ }
- let br =
- ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BoundRegionKind::Anon };
- (
- 1,
- 0,
- vec![Ty::new_imm_ref(
- tcx,
- ty::Region::new_bound(tcx, ty::INNERMOST, br),
- param(0),
- )],
- Ty::new_projection_from_args(
- tcx,
- discriminant_def_id,
- tcx.mk_args(&[param(0).into()]),
- ),
- )
- }
+ sym::black_box => (1, 0, vec![param(0)], param(0)),
- sym::catch_unwind => {
- let mut_u8 = Ty::new_mut_ptr(tcx, tcx.types.u8);
- let try_fn_ty = ty::Binder::dummy(tcx.mk_fn_sig(
- [mut_u8],
- tcx.types.unit,
- false,
- hir::Safety::Safe,
- ExternAbi::Rust,
- ));
- let catch_fn_ty = ty::Binder::dummy(tcx.mk_fn_sig(
- [mut_u8, mut_u8],
- tcx.types.unit,
- false,
- hir::Safety::Safe,
- ExternAbi::Rust,
- ));
- (
- 0,
- 0,
- vec![Ty::new_fn_ptr(tcx, try_fn_ty), mut_u8, Ty::new_fn_ptr(tcx, catch_fn_ty)],
- tcx.types.i32,
- )
- }
+ sym::is_val_statically_known => (1, 0, vec![param(0)], tcx.types.bool),
- sym::va_start | sym::va_end => {
- (0, 0, vec![mk_va_list_ty(hir::Mutability::Mut).0], tcx.types.unit)
- }
+ sym::const_eval_select => (4, 0, vec![param(0), param(1), param(2)], param(3)),
- sym::va_copy => {
- let (va_list_ref_ty, va_list_ty) = mk_va_list_ty(hir::Mutability::Not);
- let va_list_ptr_ty = Ty::new_mut_ptr(tcx, va_list_ty);
- (0, 0, vec![va_list_ptr_ty, va_list_ref_ty], tcx.types.unit)
- }
+ sym::vtable_size | sym::vtable_align => {
+ (0, 0, vec![Ty::new_imm_ptr(tcx, tcx.types.unit)], tcx.types.usize)
+ }
- sym::va_arg => (1, 0, vec![mk_va_list_ty(hir::Mutability::Mut).0], param(0)),
+ // This type check is not particularly useful, but the `where` bounds
+ // on the definition in `core` do the heavy lifting for checking it.
+ sym::aggregate_raw_ptr => (3, 0, vec![param(1), param(2)], param(0)),
+ sym::ptr_metadata => (2, 0, vec![Ty::new_imm_ptr(tcx, param(0))], param(1)),
- sym::nontemporal_store => {
- (1, 0, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], tcx.types.unit)
- }
+ sym::ub_checks => (0, 0, Vec::new(), tcx.types.bool),
- sym::raw_eq => {
- let br =
- ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BoundRegionKind::Anon };
- let param_ty_lhs =
- Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0));
- let br = ty::BoundRegion {
- var: ty::BoundVar::from_u32(1),
- kind: ty::BoundRegionKind::Anon,
- };
- let param_ty_rhs =
- Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0));
- (1, 0, vec![param_ty_lhs, param_ty_rhs], tcx.types.bool)
- }
+ sym::box_new => (1, 0, vec![param(0)], Ty::new_box(tcx, param(0))),
- sym::black_box => (1, 0, vec![param(0)], param(0)),
+ // contract_checks() -> bool
+ sym::contract_checks => (0, 0, Vec::new(), tcx.types.bool),
+ // contract_check_requires::<C>(C) -> bool, where C: impl Fn() -> bool
+ sym::contract_check_requires => (1, 0, vec![param(0)], tcx.types.unit),
+ sym::contract_check_ensures => (2, 0, vec![param(0), param(1)], param(1)),
- sym::is_val_statically_known => (1, 0, vec![param(0)], tcx.types.bool),
+ sym::simd_eq | sym::simd_ne | sym::simd_lt | sym::simd_le | sym::simd_gt | sym::simd_ge => {
+ (2, 0, vec![param(0), param(0)], param(1))
+ }
+ sym::simd_add
+ | sym::simd_sub
+ | sym::simd_mul
+ | sym::simd_rem
+ | sym::simd_div
+ | sym::simd_shl
+ | sym::simd_shr
+ | sym::simd_and
+ | sym::simd_or
+ | sym::simd_xor
+ | sym::simd_fmin
+ | sym::simd_fmax
+ | sym::simd_saturating_add
+ | sym::simd_saturating_sub => (1, 0, vec![param(0), param(0)], param(0)),
+ sym::simd_arith_offset => (2, 0, vec![param(0), param(1)], param(0)),
+ sym::simd_neg
+ | sym::simd_bswap
+ | sym::simd_bitreverse
+ | sym::simd_ctlz
+ | sym::simd_cttz
+ | sym::simd_ctpop
+ | sym::simd_fsqrt
+ | sym::simd_fsin
+ | sym::simd_fcos
+ | sym::simd_fexp
+ | sym::simd_fexp2
+ | sym::simd_flog2
+ | sym::simd_flog10
+ | sym::simd_flog
+ | sym::simd_fabs
+ | sym::simd_ceil
+ | sym::simd_floor
+ | sym::simd_round
+ | sym::simd_trunc => (1, 0, vec![param(0)], param(0)),
+ sym::simd_fma | sym::simd_relaxed_fma => {
+ (1, 0, vec![param(0), param(0), param(0)], param(0))
+ }
+ sym::simd_gather => (3, 0, vec![param(0), param(1), param(2)], param(0)),
+ sym::simd_masked_load => (3, 0, vec![param(0), param(1), param(2)], param(2)),
+ sym::simd_masked_store => (3, 0, vec![param(0), param(1), param(2)], tcx.types.unit),
+ sym::simd_scatter => (3, 0, vec![param(0), param(1), param(2)], tcx.types.unit),
+ sym::simd_insert | sym::simd_insert_dyn => {
+ (2, 0, vec![param(0), tcx.types.u32, param(1)], param(0))
+ }
+ sym::simd_extract | sym::simd_extract_dyn => {
+ (2, 0, vec![param(0), tcx.types.u32], param(1))
+ }
+ sym::simd_cast
+ | sym::simd_as
+ | sym::simd_cast_ptr
+ | sym::simd_expose_provenance
+ | sym::simd_with_exposed_provenance => (2, 0, vec![param(0)], param(1)),
+ sym::simd_bitmask => (2, 0, vec![param(0)], param(1)),
+ sym::simd_select | sym::simd_select_bitmask => {
+ (2, 0, vec![param(0), param(1), param(1)], param(1))
+ }
+ sym::simd_reduce_all | sym::simd_reduce_any => (1, 0, vec![param(0)], tcx.types.bool),
+ sym::simd_reduce_add_ordered | sym::simd_reduce_mul_ordered => {
+ (2, 0, vec![param(0), param(1)], param(1))
+ }
+ sym::simd_reduce_add_unordered
+ | sym::simd_reduce_mul_unordered
+ | sym::simd_reduce_and
+ | sym::simd_reduce_or
+ | sym::simd_reduce_xor
+ | sym::simd_reduce_min
+ | sym::simd_reduce_max => (2, 0, vec![param(0)], param(1)),
+ sym::simd_shuffle => (3, 0, vec![param(0), param(0), param(1)], param(2)),
+ sym::simd_shuffle_const_generic => (2, 1, vec![param(0), param(0)], param(1)),
- sym::const_eval_select => (4, 0, vec![param(0), param(1), param(2)], param(3)),
+ sym::atomic_cxchg | sym::atomic_cxchgweak => (
+ 1,
+ 2,
+ vec![Ty::new_mut_ptr(tcx, param(0)), param(0), param(0)],
+ Ty::new_tup(tcx, &[param(0), tcx.types.bool]),
+ ),
+ sym::atomic_load => (1, 1, vec![Ty::new_imm_ptr(tcx, param(0))], param(0)),
+ sym::atomic_store => (1, 1, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], tcx.types.unit),
- sym::vtable_size | sym::vtable_align => {
- (0, 0, vec![Ty::new_imm_ptr(tcx, tcx.types.unit)], tcx.types.usize)
- }
+ sym::atomic_xchg
+ | sym::atomic_xadd
+ | sym::atomic_xsub
+ | sym::atomic_and
+ | sym::atomic_nand
+ | sym::atomic_or
+ | sym::atomic_xor
+ | sym::atomic_max
+ | sym::atomic_min
+ | sym::atomic_umax
+ | sym::atomic_umin => (1, 1, vec![Ty::new_mut_ptr(tcx, param(0)), param(0)], param(0)),
+ sym::atomic_fence | sym::atomic_singlethreadfence => (0, 1, Vec::new(), tcx.types.unit),
- // This type check is not particularly useful, but the `where` bounds
- // on the definition in `core` do the heavy lifting for checking it.
- sym::aggregate_raw_ptr => (3, 0, vec![param(1), param(2)], param(0)),
- sym::ptr_metadata => (2, 0, vec![Ty::new_imm_ptr(tcx, param(0))], param(1)),
-
- sym::ub_checks => (0, 0, Vec::new(), tcx.types.bool),
-
- sym::box_new => (1, 0, vec![param(0)], Ty::new_box(tcx, param(0))),
-
- // contract_checks() -> bool
- sym::contract_checks => (0, 0, Vec::new(), tcx.types.bool),
- // contract_check_requires::<C>(C) -> bool, where C: impl Fn() -> bool
- sym::contract_check_requires => (1, 0, vec![param(0)], tcx.types.unit),
-
- sym::simd_eq
- | sym::simd_ne
- | sym::simd_lt
- | sym::simd_le
- | sym::simd_gt
- | sym::simd_ge => (2, 0, vec![param(0), param(0)], param(1)),
- sym::simd_add
- | sym::simd_sub
- | sym::simd_mul
- | sym::simd_rem
- | sym::simd_div
- | sym::simd_shl
- | sym::simd_shr
- | sym::simd_and
- | sym::simd_or
- | sym::simd_xor
- | sym::simd_fmin
- | sym::simd_fmax
- | sym::simd_saturating_add
- | sym::simd_saturating_sub => (1, 0, vec![param(0), param(0)], param(0)),
- sym::simd_arith_offset => (2, 0, vec![param(0), param(1)], param(0)),
- sym::simd_neg
- | sym::simd_bswap
- | sym::simd_bitreverse
- | sym::simd_ctlz
- | sym::simd_cttz
- | sym::simd_ctpop
- | sym::simd_fsqrt
- | sym::simd_fsin
- | sym::simd_fcos
- | sym::simd_fexp
- | sym::simd_fexp2
- | sym::simd_flog2
- | sym::simd_flog10
- | sym::simd_flog
- | sym::simd_fabs
- | sym::simd_ceil
- | sym::simd_floor
- | sym::simd_round
- | sym::simd_trunc => (1, 0, vec![param(0)], param(0)),
- sym::simd_fma | sym::simd_relaxed_fma => {
- (1, 0, vec![param(0), param(0), param(0)], param(0))
- }
- sym::simd_gather => (3, 0, vec![param(0), param(1), param(2)], param(0)),
- sym::simd_masked_load => (3, 0, vec![param(0), param(1), param(2)], param(2)),
- sym::simd_masked_store => (3, 0, vec![param(0), param(1), param(2)], tcx.types.unit),
- sym::simd_scatter => (3, 0, vec![param(0), param(1), param(2)], tcx.types.unit),
- sym::simd_insert | sym::simd_insert_dyn => {
- (2, 0, vec![param(0), tcx.types.u32, param(1)], param(0))
- }
- sym::simd_extract | sym::simd_extract_dyn => {
- (2, 0, vec![param(0), tcx.types.u32], param(1))
- }
- sym::simd_cast
- | sym::simd_as
- | sym::simd_cast_ptr
- | sym::simd_expose_provenance
- | sym::simd_with_exposed_provenance => (2, 0, vec![param(0)], param(1)),
- sym::simd_bitmask => (2, 0, vec![param(0)], param(1)),
- sym::simd_select | sym::simd_select_bitmask => {
- (2, 0, vec![param(0), param(1), param(1)], param(1))
- }
- sym::simd_reduce_all | sym::simd_reduce_any => (1, 0, vec![param(0)], tcx.types.bool),
- sym::simd_reduce_add_ordered | sym::simd_reduce_mul_ordered => {
- (2, 0, vec![param(0), param(1)], param(1))
- }
- sym::simd_reduce_add_unordered
- | sym::simd_reduce_mul_unordered
- | sym::simd_reduce_and
- | sym::simd_reduce_or
- | sym::simd_reduce_xor
- | sym::simd_reduce_min
- | sym::simd_reduce_max => (2, 0, vec![param(0)], param(1)),
- sym::simd_shuffle => (3, 0, vec![param(0), param(0), param(1)], param(2)),
- sym::simd_shuffle_const_generic => (2, 1, vec![param(0), param(0)], param(1)),
-
- other => {
- tcx.dcx().emit_err(UnrecognizedIntrinsicFunction { span, name: other });
- return;
- }
- };
- (n_tps, 0, n_cts, inputs, output, safety)
+ other => {
+ tcx.dcx().emit_err(UnrecognizedIntrinsicFunction { span, name: other });
+ return;
+ }
};
let sig = tcx.mk_fn_sig(inputs, output, false, safety, ExternAbi::Rust);
let sig = ty::Binder::bind_with_vars(sig, bound_vars);
diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs
index 152714b..a27d1ed 100644
--- a/compiler/rustc_hir_analysis/src/errors.rs
+++ b/compiler/rustc_hir_analysis/src/errors.rs
@@ -162,15 +162,6 @@ pub(crate) enum AssocItemNotFoundSugg<'a> {
}
#[derive(Diagnostic)]
-#[diag(hir_analysis_unrecognized_atomic_operation, code = E0092)]
-pub(crate) struct UnrecognizedAtomicOperation<'a> {
- #[primary_span]
- #[label]
- pub span: Span,
- pub op: &'a str,
-}
-
-#[derive(Diagnostic)]
#[diag(hir_analysis_wrong_number_of_generic_arguments_to_intrinsic, code = E0094)]
pub(crate) struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
#[primary_span]
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
index 4c65d0d..4deb47d 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
@@ -805,7 +805,11 @@ pub(crate) fn lower_poly_trait_ref(
ty::ClauseKind::Trait(ty::TraitPredicate { trait_ref, polarity })
});
let bound = (bound.upcast(tcx), span);
- // FIXME(-Znext-solver): We can likely remove this hack once the new trait solver lands.
+ // FIXME(-Znext-solver): We can likely remove this hack once the
+ // new trait solver lands. This fixed an overflow in the old solver.
+ // This may have performance implications, so please check perf when
+ // removing it.
+ // This was added in <https://github.com/rust-lang/rust/pull/123302>.
if tcx.is_lang_item(trait_def_id, rustc_hir::LangItem::Sized) {
bounds.insert(0, bound);
} else {
diff --git a/compiler/rustc_hir_typeck/messages.ftl b/compiler/rustc_hir_typeck/messages.ftl
index 6c33dfb..3bdd1b4 100644
--- a/compiler/rustc_hir_typeck/messages.ftl
+++ b/compiler/rustc_hir_typeck/messages.ftl
@@ -17,6 +17,24 @@
add `#![feature(default_field_values)]` to the crate attributes to enable default values on `struct` fields
hir_typeck_base_expression_double_dot_remove = remove the `..` as all the fields are already present
+hir_typeck_break_inside_closure =
+ `{$name}` inside of a closure
+ .label = cannot `{$name}` inside of a closure
+ .closure_label = enclosing closure
+
+hir_typeck_break_inside_coroutine =
+ `{$name}` inside `{$kind}` {$source}
+ .label = cannot `{$name}` inside `{$kind}` {$source}
+ .coroutine_label = enclosing `{$kind}` {$source}
+
+hir_typeck_break_non_loop =
+ `break` with value from a `{$kind}` loop
+ .label = can only break with a value inside `loop` or breakable block
+ .label2 = you can't `break` with a value in a `{$kind}` loop
+ .suggestion = use `break` on its own without a value inside this `{$kind}` loop
+ .break_expr_suggestion = alternatively, you might have meant to use the available loop label
+
+
hir_typeck_candidate_trait_note = `{$trait_name}` defines an item `{$item_name}`{$action_or_ty ->
[NONE] {""}
[implement] , perhaps you need to implement it
@@ -64,6 +82,12 @@
.note = expected a function item, found {$ty}
.help = consult the documentation on `const_eval_select` for more information
+hir_typeck_continue_labeled_block =
+ `continue` pointing to a labeled block
+ .label = labeled blocks cannot be `continue`'d
+ .block_label = labeled block the `continue` points to
+
+
hir_typeck_convert_to_str = try converting the passed type into a `&str`
hir_typeck_convert_using_method = try using `{$sugg}` to convert `{$found}` to `{$expected}`
@@ -182,6 +206,19 @@
hir_typeck_option_result_cloned = use `{$def_path}::cloned` to clone the value inside the `{$def_path}`
hir_typeck_option_result_copied = use `{$def_path}::copied` to copy the value inside the `{$def_path}`
+hir_typeck_outside_loop =
+ `{$name}` outside of a loop{$is_break ->
+ [true] {" or labeled block"}
+ *[false] {""}
+ }
+ .label = cannot `{$name}` outside of a loop{$is_break ->
+ [true] {" or labeled block"}
+ *[false] {""}
+ }
+
+hir_typeck_outside_loop_suggestion = consider labeling this block to be able to break within it
+
+
hir_typeck_params_not_allowed =
referencing function parameters is not allowed in naked functions
.help = follow the calling convention in asm block to use parameters
@@ -254,6 +291,13 @@
hir_typeck_union_pat_multiple_fields = union patterns should have exactly one field
+hir_typeck_unlabeled_cf_in_while_condition =
+ `break` or `continue` with no label in the condition of a `while` loop
+ .label = unlabeled `{$cf_type}` in the condition of a `while` loop
+
+hir_typeck_unlabeled_in_labeled_block =
+ unlabeled `{$cf_type}` inside of a labeled block
+ .label = `{$cf_type}` statements that would diverge to or through a labeled block need to bear a label
hir_typeck_use_is_empty =
consider using the `is_empty` method on `{$expr_ty}` to determine if it contains anything
diff --git a/compiler/rustc_hir_typeck/src/_match.rs b/compiler/rustc_hir_typeck/src/_match.rs
index 61dd8c5..4ac260c 100644
--- a/compiler/rustc_hir_typeck/src/_match.rs
+++ b/compiler/rustc_hir_typeck/src/_match.rs
@@ -600,7 +600,7 @@ pub(crate) fn return_position_impl_trait_from_match_expectation(
let (def_id, args) = match *expected_ty.kind() {
// FIXME: Could also check that the RPIT is not defined
ty::Alias(ty::Opaque, alias_ty) => (alias_ty.def_id.as_local()?, alias_ty.args),
- // FIXME(-Znext-solver): Remove this branch once `replace_opaque_types_with_infer` is gone.
+ // FIXME(-Znext-solver=no): Remove this branch once `replace_opaque_types_with_infer` is gone.
ty::Infer(ty::TyVar(_)) => self
.inner
.borrow_mut()
diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs
index 152c88a..5b55fbe 100644
--- a/compiler/rustc_hir_typeck/src/demand.rs
+++ b/compiler/rustc_hir_typeck/src/demand.rs
@@ -260,7 +260,11 @@ pub(crate) fn demand_coerce_diag(
mut expected_ty_expr: Option<&'tcx hir::Expr<'tcx>>,
allow_two_phase: AllowTwoPhase,
) -> Result<Ty<'tcx>, Diag<'a>> {
- let expected = self.resolve_vars_with_obligations(expected);
+ let expected = if self.next_trait_solver() {
+ expected
+ } else {
+ self.resolve_vars_with_obligations(expected)
+ };
let e = match self.coerce(expr, checked_ty, expected, allow_two_phase, None) {
Ok(ty) => return Ok(ty),
diff --git a/compiler/rustc_hir_typeck/src/errors.rs b/compiler/rustc_hir_typeck/src/errors.rs
index 97a9054..7748150 100644
--- a/compiler/rustc_hir_typeck/src/errors.rs
+++ b/compiler/rustc_hir_typeck/src/errors.rs
@@ -2,11 +2,14 @@
use std::borrow::Cow;
+use rustc_ast::Label;
use rustc_errors::codes::*;
use rustc_errors::{
Applicability, Diag, DiagArgValue, DiagCtxtHandle, DiagSymbolList, Diagnostic,
EmissionGuarantee, IntoDiagArg, Level, MultiSpan, Subdiagnostic,
};
+use rustc_hir as hir;
+use rustc_hir::ExprKind;
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::{self, Ty};
use rustc_span::edition::{Edition, LATEST_STABLE_EDITION};
@@ -721,6 +724,131 @@ pub(crate) struct TrivialCast<'tcx> {
pub cast_ty: Ty<'tcx>,
}
+pub(crate) struct BreakNonLoop<'a> {
+ pub span: Span,
+ pub head: Option<Span>,
+ pub kind: &'a str,
+ pub suggestion: String,
+ pub loop_label: Option<Label>,
+ pub break_label: Option<Label>,
+ pub break_expr_kind: &'a ExprKind<'a>,
+ pub break_expr_span: Span,
+}
+
+impl<'a, G: EmissionGuarantee> Diagnostic<'_, G> for BreakNonLoop<'a> {
+ #[track_caller]
+ fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
+ let mut diag = Diag::new(dcx, level, fluent::hir_typeck_break_non_loop);
+ diag.span(self.span);
+ diag.code(E0571);
+ diag.arg("kind", self.kind);
+ diag.span_label(self.span, fluent::hir_typeck_label);
+ if let Some(head) = self.head {
+ diag.span_label(head, fluent::hir_typeck_label2);
+ }
+ diag.span_suggestion(
+ self.span,
+ fluent::hir_typeck_suggestion,
+ self.suggestion,
+ Applicability::MaybeIncorrect,
+ );
+ if let (Some(label), None) = (self.loop_label, self.break_label) {
+ match self.break_expr_kind {
+ ExprKind::Path(hir::QPath::Resolved(
+ None,
+ hir::Path { segments: [segment], res: hir::def::Res::Err, .. },
+ )) if label.ident.to_string() == format!("'{}", segment.ident) => {
+ // This error is redundant, we will have already emitted a
+ // suggestion to use the label when `segment` wasn't found
+ // (hence the `Res::Err` check).
+ diag.downgrade_to_delayed_bug();
+ }
+ _ => {
+ diag.span_suggestion(
+ self.break_expr_span,
+ fluent::hir_typeck_break_expr_suggestion,
+ label.ident,
+ Applicability::MaybeIncorrect,
+ );
+ }
+ }
+ }
+ diag
+ }
+}
+
+#[derive(Diagnostic)]
+#[diag(hir_typeck_continue_labeled_block, code = E0696)]
+pub(crate) struct ContinueLabeledBlock {
+ #[primary_span]
+ #[label]
+ pub span: Span,
+ #[label(hir_typeck_block_label)]
+ pub block_span: Span,
+}
+
+#[derive(Diagnostic)]
+#[diag(hir_typeck_break_inside_closure, code = E0267)]
+pub(crate) struct BreakInsideClosure<'a> {
+ #[primary_span]
+ #[label]
+ pub span: Span,
+ #[label(hir_typeck_closure_label)]
+ pub closure_span: Span,
+ pub name: &'a str,
+}
+
+#[derive(Diagnostic)]
+#[diag(hir_typeck_break_inside_coroutine, code = E0267)]
+pub(crate) struct BreakInsideCoroutine<'a> {
+ #[primary_span]
+ #[label]
+ pub span: Span,
+ #[label(hir_typeck_coroutine_label)]
+ pub coroutine_span: Span,
+ pub name: &'a str,
+ pub kind: &'a str,
+ pub source: &'a str,
+}
+
+#[derive(Diagnostic)]
+#[diag(hir_typeck_outside_loop, code = E0268)]
+pub(crate) struct OutsideLoop<'a> {
+ #[primary_span]
+ #[label]
+ pub spans: Vec<Span>,
+ pub name: &'a str,
+ pub is_break: bool,
+ #[subdiagnostic]
+ pub suggestion: Option<OutsideLoopSuggestion>,
+}
+#[derive(Subdiagnostic)]
+#[multipart_suggestion(hir_typeck_outside_loop_suggestion, applicability = "maybe-incorrect")]
+pub(crate) struct OutsideLoopSuggestion {
+ #[suggestion_part(code = "'block: ")]
+ pub block_span: Span,
+ #[suggestion_part(code = " 'block")]
+ pub break_spans: Vec<Span>,
+}
+
+#[derive(Diagnostic)]
+#[diag(hir_typeck_unlabeled_in_labeled_block, code = E0695)]
+pub(crate) struct UnlabeledInLabeledBlock<'a> {
+ #[primary_span]
+ #[label]
+ pub span: Span,
+ pub cf_type: &'a str,
+}
+
+#[derive(Diagnostic)]
+#[diag(hir_typeck_unlabeled_cf_in_while_condition, code = E0590)]
+pub(crate) struct UnlabeledCfInWhileCondition<'a> {
+ #[primary_span]
+ #[label]
+ pub span: Span,
+ pub cf_type: &'a str,
+}
+
#[derive(Diagnostic)]
#[diag(hir_typeck_no_associated_item, code = E0599)]
pub(crate) struct NoAssociatedItem {
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
index 8a90e76..a43449a 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
@@ -1436,8 +1436,6 @@ fn add_required_obligations_with_code(
/// in this case.
#[instrument(level = "debug", skip(self, sp), ret)]
pub(crate) fn try_structurally_resolve_type(&self, sp: Span, ty: Ty<'tcx>) -> Ty<'tcx> {
- let ty = self.resolve_vars_with_obligations(ty);
-
if self.next_trait_solver()
&& let ty::Alias(..) = ty.kind()
{
@@ -1455,7 +1453,7 @@ pub(crate) fn try_structurally_resolve_type(&self, sp: Span, ty: Ty<'tcx>) -> Ty
}
}
} else {
- ty
+ self.resolve_vars_with_obligations(ty)
}
}
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
index a5c0829..3935569 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
@@ -412,9 +412,10 @@ pub(crate) struct LoweredTy<'tcx> {
impl<'tcx> LoweredTy<'tcx> {
fn from_raw(fcx: &FnCtxt<'_, 'tcx>, span: Span, raw: Ty<'tcx>) -> LoweredTy<'tcx> {
- // FIXME(-Znext-solver): We're still figuring out how to best handle
- // normalization and this doesn't feel too great. We should look at this
- // code again before stabilizing it.
+ // FIXME(-Znext-solver=no): This is easier than requiring all uses of `LoweredTy`
+ // to call `try_structurally_resolve_type` instead. This seems like a lot of
+ // effort, especially as we're still supporting the old solver. We may revisit
+ // this in the future.
let normalized = if fcx.next_trait_solver() {
fcx.try_structurally_resolve_type(span, raw)
} else {
diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs
index b0346f8..a45a771 100644
--- a/compiler/rustc_hir_typeck/src/lib.rs
+++ b/compiler/rustc_hir_typeck/src/lib.rs
@@ -1,13 +1,11 @@
// tidy-alphabetical-start
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
-#![feature(array_windows)]
#![feature(assert_matches)]
#![feature(box_patterns)]
#![feature(if_let_guard)]
#![feature(iter_intersperse)]
#![feature(never_type)]
-#![feature(try_blocks)]
// tidy-alphabetical-end
mod _match;
@@ -30,6 +28,7 @@
mod fn_ctxt;
mod gather_locals;
mod intrinsicck;
+mod loops;
mod method;
mod naked_functions;
mod op;
@@ -150,7 +149,8 @@ fn typeck_with_inspect<'tcx>(
tcx.fn_sig(def_id).instantiate_identity()
};
- check_abi(tcx, span, fn_sig.abi());
+ check_abi(tcx, id, span, fn_sig.abi());
+ loops::check(tcx, def_id, body);
// Compute the function signature from point of view of inside the fn.
let mut fn_sig = tcx.liberate_late_bound_regions(def_id.to_def_id(), fn_sig);
@@ -191,6 +191,8 @@ fn typeck_with_inspect<'tcx>(
tcx.type_of(def_id).instantiate_identity()
};
+ loops::check(tcx, def_id, body);
+
let expected_type = fcx.normalize(body.value.span, expected_type);
let wf_code = ObligationCauseCode::WellFormed(Some(WellFormedLoc::Ty(def_id)));
diff --git a/compiler/rustc_passes/src/loops.rs b/compiler/rustc_hir_typeck/src/loops.rs
similarity index 92%
rename from compiler/rustc_passes/src/loops.rs
rename to compiler/rustc_hir_typeck/src/loops.rs
index b06f16c..b06e070 100644
--- a/compiler/rustc_passes/src/loops.rs
+++ b/compiler/rustc_hir_typeck/src/loops.rs
@@ -3,11 +3,11 @@
use Context::*;
use rustc_hir as hir;
-use rustc_hir::def_id::{LocalDefId, LocalModDefId};
+use rustc_hir::def::DefKind;
+use rustc_hir::def_id::LocalDefId;
use rustc_hir::intravisit::{self, Visitor};
use rustc_hir::{Destination, Node};
use rustc_middle::hir::nested_filter;
-use rustc_middle::query::Providers;
use rustc_middle::span_bug;
use rustc_middle::ty::TyCtxt;
use rustc_span::hygiene::DesugaringKind;
@@ -73,17 +73,17 @@ struct CheckLoopVisitor<'tcx> {
block_breaks: BTreeMap<Span, BlockInfo>,
}
-fn check_mod_loops(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) {
+pub(crate) fn check<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, body: &'tcx hir::Body<'tcx>) {
let mut check =
CheckLoopVisitor { tcx, cx_stack: vec![Normal], block_breaks: Default::default() };
- tcx.hir_visit_item_likes_in_module(module_def_id, &mut check);
+ let cx = match tcx.def_kind(def_id) {
+ DefKind::AnonConst => AnonConst,
+ _ => Fn,
+ };
+ check.with_context(cx, |v| v.visit_body(body));
check.report_outside_loop_error();
}
-pub(crate) fn provide(providers: &mut Providers) {
- *providers = Providers { check_mod_loops, ..*providers };
-}
-
impl<'hir> Visitor<'hir> for CheckLoopVisitor<'hir> {
type NestedFilter = nested_filter::OnlyBodies;
@@ -91,33 +91,14 @@ fn maybe_tcx(&mut self) -> Self::MaybeTyCtxt {
self.tcx
}
- fn visit_anon_const(&mut self, c: &'hir hir::AnonConst) {
- self.with_context(AnonConst, |v| intravisit::walk_anon_const(v, c));
+ fn visit_anon_const(&mut self, _: &'hir hir::AnonConst) {
+ // Typecked on its own.
}
fn visit_inline_const(&mut self, c: &'hir hir::ConstBlock) {
self.with_context(ConstBlock, |v| intravisit::walk_inline_const(v, c));
}
- fn visit_fn(
- &mut self,
- fk: hir::intravisit::FnKind<'hir>,
- fd: &'hir hir::FnDecl<'hir>,
- b: hir::BodyId,
- _: Span,
- id: LocalDefId,
- ) {
- self.with_context(Fn, |v| intravisit::walk_fn(v, fk, fd, b, id));
- }
-
- fn visit_trait_item(&mut self, trait_item: &'hir hir::TraitItem<'hir>) {
- self.with_context(Fn, |v| intravisit::walk_trait_item(v, trait_item));
- }
-
- fn visit_impl_item(&mut self, impl_item: &'hir hir::ImplItem<'hir>) {
- self.with_context(Fn, |v| intravisit::walk_impl_item(v, impl_item));
- }
-
fn visit_expr(&mut self, e: &'hir hir::Expr<'hir>) {
match e.kind {
hir::ExprKind::If(cond, then, else_opt) => {
diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs
index 725240b..a3fdf20 100644
--- a/compiler/rustc_hir_typeck/src/method/probe.rs
+++ b/compiler/rustc_hir_typeck/src/method/probe.rs
@@ -1913,8 +1913,7 @@ fn consider_probe(
ty::Binder::dummy(trait_ref),
);
- // FIXME(-Znext-solver): We only need this hack to deal with fatal
- // overflow in the old solver.
+ // We only need this hack to deal with fatal overflow in the old solver.
if self.infcx.next_trait_solver() || self.infcx.predicate_may_hold(&obligation)
{
ocx.register_obligation(obligation);
@@ -1955,17 +1954,17 @@ fn consider_probe(
}
}
- // FIXME(-Znext-solver): See the linked issue below.
- // <https://github.com/rust-lang/trait-system-refactor-initiative/issues/134>
+ // See <https://github.com/rust-lang/trait-system-refactor-initiative/issues/134>.
//
// In the new solver, check the well-formedness of the return type.
// This emulates, in a way, the predicates that fall out of
// normalizing the return type in the old solver.
//
- // We alternatively could check the predicates of the method itself hold,
- // but we intentionally do not do this in the old solver b/c of cycles,
- // and doing it in the new solver would be stronger. This should be fixed
- // in the future, since it likely leads to much better method winnowing.
+ // FIXME(-Znext-solver): We alternatively could check the predicates of
+ // the method itself hold, but we intentionally do not do this in the old
+ // solver b/c of cycles, and doing it in the new solver would be stronger.
+ // This should be fixed in the future, since it likely leads to much better
+ // method winnowing.
if let Some(xform_ret_ty) = xform_ret_ty
&& self.infcx.next_trait_solver()
{
diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs
index 3eae95d..2fac13b 100644
--- a/compiler/rustc_hir_typeck/src/method/suggest.rs
+++ b/compiler/rustc_hir_typeck/src/method/suggest.rs
@@ -3494,7 +3494,7 @@ fn suggest_traits_to_import(
continue;
}
trait_in_other_version_found = self
- .detect_and_explain_multiple_crate_versions(
+ .detect_and_explain_multiple_crate_versions_of_trait_item(
err,
pick.item.def_id,
rcvr.hir_id,
@@ -3701,12 +3701,13 @@ fn suggest_traits_to_import(
// same crate.
let rcvr_ty = self.node_ty_opt(ty.hir_id);
- trait_in_other_version_found = self.detect_and_explain_multiple_crate_versions(
- err,
- assoc.def_id,
- ty.hir_id,
- rcvr_ty,
- );
+ trait_in_other_version_found = self
+ .detect_and_explain_multiple_crate_versions_of_trait_item(
+ err,
+ assoc.def_id,
+ ty.hir_id,
+ rcvr_ty,
+ );
}
if !trait_in_other_version_found
&& self.suggest_valid_traits(err, item_name, valid_out_of_scope_traits, true)
@@ -4098,7 +4099,7 @@ enum Introducer {
}
}
- fn detect_and_explain_multiple_crate_versions(
+ fn detect_and_explain_multiple_crate_versions_of_trait_item(
&self,
err: &mut Diag<'_>,
item_def_id: DefId,
@@ -4111,6 +4112,9 @@ fn detect_and_explain_multiple_crate_versions(
return false;
}
let trait_def_id = self.tcx.parent(item_def_id);
+ if !self.tcx.is_trait(trait_def_id) {
+ return false;
+ }
let krate = self.tcx.crate_name(trait_def_id.krate);
let name = self.tcx.item_name(trait_def_id);
let candidates: Vec<_> = traits
diff --git a/compiler/rustc_infer/src/infer/outlives/obligations.rs b/compiler/rustc_infer/src/infer/outlives/obligations.rs
index 10827c9..db937b3 100644
--- a/compiler/rustc_infer/src/infer/outlives/obligations.rs
+++ b/compiler/rustc_infer/src/infer/outlives/obligations.rs
@@ -198,8 +198,11 @@ pub fn process_registered_region_obligations(
}
if !self.tcx.recursion_limit().value_within_limit(iteration) {
+ // This may actually be reachable. If so, we should convert
+ // this to a proper error/consider whether we should detect
+ // this somewhere else.
bug!(
- "FIXME(-Znext-solver): Overflowed when processing region obligations: {my_region_obligations:#?}"
+ "unexpected overflowed when processing region obligations: {my_region_obligations:#?}"
);
}
diff --git a/compiler/rustc_infer/src/infer/type_variable.rs b/compiler/rustc_infer/src/infer/type_variable.rs
index 2086483..6f67918 100644
--- a/compiler/rustc_infer/src/infer/type_variable.rs
+++ b/compiler/rustc_infer/src/infer/type_variable.rs
@@ -238,6 +238,9 @@ fn from_index(i: u32) -> Self {
fn tag() -> &'static str {
"TyVidEqKey"
}
+ fn order_roots(a: Self, _: &Self::Value, b: Self, _: &Self::Value) -> Option<(Self, Self)> {
+ if a.vid.as_u32() < b.vid.as_u32() { Some((a, b)) } else { Some((b, a)) }
+ }
}
impl<'tcx> ut::UnifyValue for TypeVariableValue<'tcx> {
diff --git a/compiler/rustc_infer/src/infer/unify_key.rs b/compiler/rustc_infer/src/infer/unify_key.rs
index 3ba8aea..5e5d0e0 100644
--- a/compiler/rustc_infer/src/infer/unify_key.rs
+++ b/compiler/rustc_infer/src/infer/unify_key.rs
@@ -137,6 +137,9 @@ fn from_index(i: u32) -> Self {
fn tag() -> &'static str {
"ConstVidKey"
}
+ fn order_roots(a: Self, _: &Self::Value, b: Self, _: &Self::Value) -> Option<(Self, Self)> {
+ if a.vid.as_u32() < b.vid.as_u32() { Some((a, b)) } else { Some((b, a)) }
+ }
}
impl<'tcx> UnifyValue for ConstVariableValue<'tcx> {
diff --git a/compiler/rustc_infer/src/lib.rs b/compiler/rustc_infer/src/lib.rs
index ab7b706..550707e 100644
--- a/compiler/rustc_infer/src/lib.rs
+++ b/compiler/rustc_infer/src/lib.rs
@@ -20,7 +20,6 @@
#![doc(rust_logo)]
#![feature(assert_matches)]
#![feature(extend_one)]
-#![feature(iterator_try_collect)]
#![feature(rustdoc_internals)]
#![recursion_limit = "512"] // For rustdoc
// tidy-alphabetical-end
diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs
index cf494f8..e824e9d 100644
--- a/compiler/rustc_interface/src/interface.rs
+++ b/compiler/rustc_interface/src/interface.rs
@@ -18,7 +18,7 @@
use rustc_query_impl::QueryCtxt;
use rustc_query_system::query::print_query_stack;
use rustc_session::config::{self, Cfg, CheckCfg, ExpectedValues, Input, OutFileName};
-use rustc_session::filesearch::sysroot_candidates;
+use rustc_session::filesearch::sysroot_with_fallback;
use rustc_session::parse::ParseSess;
use rustc_session::{CompilerIO, EarlyDiagCtxt, Session, lint};
use rustc_span::source_map::{FileLoader, RealFileLoader, SourceMapInputs};
@@ -442,8 +442,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
let temps_dir = config.opts.unstable_opts.temps_dir.as_deref().map(PathBuf::from);
let bundle = match rustc_errors::fluent_bundle(
- config.opts.sysroot.clone(),
- sysroot_candidates().to_vec(),
+ sysroot_with_fallback(&config.opts.sysroot),
config.opts.unstable_opts.translate_lang.clone(),
config.opts.unstable_opts.translate_additional_ftl.as_deref(),
config.opts.unstable_opts.translate_directionality_markers,
diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs
index 2643e5c..99520a3 100644
--- a/compiler/rustc_interface/src/passes.rs
+++ b/compiler/rustc_interface/src/passes.rs
@@ -954,7 +954,6 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
tcx.ensure_ok().exportable_items(LOCAL_CRATE);
tcx.ensure_ok().stable_order_of_exportable_impls(LOCAL_CRATE);
tcx.par_hir_for_each_module(|module| {
- tcx.ensure_ok().check_mod_loops(module);
tcx.ensure_ok().check_mod_attrs(module);
tcx.ensure_ok().check_mod_unstable_api_usage(module);
});
diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs
index 087b11f..8bdc24d 100644
--- a/compiler/rustc_interface/src/util.rs
+++ b/compiler/rustc_interface/src/util.rs
@@ -2,7 +2,7 @@
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, OnceLock};
-use std::{env, iter, thread};
+use std::{env, thread};
use rustc_ast as ast;
use rustc_codegen_ssa::traits::CodegenBackend;
@@ -12,7 +12,6 @@
use rustc_middle::ty::CurrentGcx;
use rustc_parse::validate_attr;
use rustc_session::config::{Cfg, OutFileName, OutputFilenames, OutputTypes, host_tuple};
-use rustc_session::filesearch::sysroot_candidates;
use rustc_session::lint::{self, BuiltinLintDiag, LintBuffer};
use rustc_session::output::{CRATE_TYPES, categorize_crate_type};
use rustc_session::{EarlyDiagCtxt, Session, filesearch};
@@ -346,14 +345,10 @@ pub fn rustc_path<'a>() -> Option<&'a Path> {
}
fn get_rustc_path_inner(bin_path: &str) -> Option<PathBuf> {
- sysroot_candidates().iter().find_map(|sysroot| {
- let candidate = sysroot.join(bin_path).join(if cfg!(target_os = "windows") {
- "rustc.exe"
- } else {
- "rustc"
- });
- candidate.exists().then_some(candidate)
- })
+ let candidate = filesearch::get_or_default_sysroot()
+ .join(bin_path)
+ .join(if cfg!(target_os = "windows") { "rustc.exe" } else { "rustc" });
+ candidate.exists().then_some(candidate)
}
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
@@ -374,10 +369,10 @@ fn get_codegen_sysroot(
);
let target = host_tuple();
- let sysroot_candidates = sysroot_candidates();
+ let sysroot_candidates = filesearch::sysroot_with_fallback(&sysroot);
- let sysroot = iter::once(sysroot)
- .chain(sysroot_candidates.iter().map(<_>::as_ref))
+ let sysroot = sysroot_candidates
+ .iter()
.map(|sysroot| {
filesearch::make_target_lib_path(sysroot, target).with_file_name("codegen-backends")
})
diff --git a/compiler/rustc_lint/src/early.rs b/compiler/rustc_lint/src/early.rs
index 4978f29..12666d3 100644
--- a/compiler/rustc_lint/src/early.rs
+++ b/compiler/rustc_lint/src/early.rs
@@ -136,7 +136,6 @@ fn visit_stmt(&mut self, s: &'ast ast::Stmt) {
// the AST struct that they wrap (e.g. an item)
self.with_lint_attrs(s.id, s.attrs(), |cx| {
lint_callback!(cx, check_stmt, s);
- cx.check_id(s.id);
});
// The visitor for the AST struct wrapped
// by the statement (e.g. `Item`) will call
@@ -147,7 +146,6 @@ fn visit_stmt(&mut self, s: &'ast ast::Stmt) {
fn visit_fn(&mut self, fk: ast_visit::FnKind<'ast>, span: Span, id: ast::NodeId) {
lint_callback!(self, check_fn, fk, span, id);
- self.check_id(id);
ast_visit::walk_fn(self, fk);
}
diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs
index c86f66c..72bfead 100644
--- a/compiler/rustc_lint/src/lib.rs
+++ b/compiler/rustc_lint/src/lib.rs
@@ -599,7 +599,6 @@ macro_rules! add_lint_group {
"converted into hard error, see PR #125380 \
<https://github.com/rust-lang/rust/pull/125380> for more information",
);
- store.register_removed("unsupported_calling_conventions", "converted into hard error");
store.register_removed(
"cenum_impl_drop_cast",
"converted into hard error, \
diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs
index 843d577..777118e 100644
--- a/compiler/rustc_lint_defs/src/builtin.rs
+++ b/compiler/rustc_lint_defs/src/builtin.rs
@@ -3622,6 +3622,54 @@
}
declare_lint! {
+ /// The `unsupported_calling_conventions` lint is output whenever there is a use of the
+ /// `stdcall`, `fastcall`, and `cdecl` calling conventions (or their unwind
+ /// variants) on targets that cannot meaningfully be supported for the requested target.
+ ///
+ /// For example `stdcall` does not make much sense for a x86_64 or, more apparently, powerpc
+ /// code, because this calling convention was never specified for those targets.
+ ///
+ /// Historically MSVC toolchains have fallen back to the regular C calling convention for
+ /// targets other than x86, but Rust doesn't really see a similar need to introduce a similar
+ /// hack across many more targets.
+ ///
+ /// ### Example
+ ///
+ /// ```rust,ignore (needs specific targets)
+ /// extern "stdcall" fn stdcall() {}
+ /// ```
+ ///
+ /// This will produce:
+ ///
+ /// ```text
+ /// warning: use of calling convention not supported on this target
+ /// --> $DIR/unsupported.rs:39:1
+ /// |
+ /// LL | extern "stdcall" fn stdcall() {}
+ /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ /// |
+ /// = note: `#[warn(unsupported_calling_conventions)]` on by default
+ /// = warning: this was previously accepted by the compiler but is being phased out;
+ /// it will become a hard error in a future release!
+ /// = note: for more information, see issue ...
+ /// ```
+ ///
+ /// ### Explanation
+ ///
+ /// On most of the targets the behaviour of `stdcall` and similar calling conventions is not
+ /// defined at all, but was previously accepted due to a bug in the implementation of the
+ /// compiler.
+ pub UNSUPPORTED_CALLING_CONVENTIONS,
+ Warn,
+ "use of unsupported calling convention",
+ @future_incompatible = FutureIncompatibleInfo {
+ reason: FutureIncompatibilityReason::FutureReleaseError,
+ report_in_deps: true,
+ reference: "issue #137018 <https://github.com/rust-lang/rust/issues/137018>",
+ };
+}
+
+declare_lint! {
/// The `unsupported_fn_ptr_calling_conventions` lint is output whenever there is a use of
/// a target dependent calling convention on a target that does not support this calling
/// convention on a function pointer.
diff --git a/compiler/rustc_macros/src/lib.rs b/compiler/rustc_macros/src/lib.rs
index 8181701..42d006e 100644
--- a/compiler/rustc_macros/src/lib.rs
+++ b/compiler/rustc_macros/src/lib.rs
@@ -3,7 +3,6 @@
#![feature(if_let_guard)]
#![feature(never_type)]
#![feature(proc_macro_diagnostic)]
-#![feature(proc_macro_span)]
#![feature(proc_macro_tracked_env)]
// tidy-alphabetical-end
diff --git a/compiler/rustc_metadata/messages.ftl b/compiler/rustc_metadata/messages.ftl
index bccffe3..3bef5ca 100644
--- a/compiler/rustc_metadata/messages.ftl
+++ b/compiler/rustc_metadata/messages.ftl
@@ -272,6 +272,9 @@
metadata_raw_dylib_only_windows =
link kind `raw-dylib` is only supported on Windows targets
+metadata_raw_dylib_unsupported_abi =
+ ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture
+
metadata_renaming_no_link =
renaming of the library `{$lib_name}` was specified, however this crate contains no `#[link(...)]` attributes referencing this library
@@ -319,12 +322,6 @@
metadata_unknown_target_modifier_unsafe_allowed = unknown target modifier `{$flag_name}`, requested by `-Cunsafe-allow-abi-mismatch={$flag_name}`
-metadata_unsupported_abi =
- ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture
-
-metadata_unsupported_abi_i686 =
- ABI not supported by `#[link(kind = "raw-dylib")]` on i686
-
metadata_wasm_c_abi =
older versions of the `wasm-bindgen` crate are incompatible with current versions of Rust; please update to `wasm-bindgen` v0.2.88
diff --git a/compiler/rustc_metadata/src/errors.rs b/compiler/rustc_metadata/src/errors.rs
index 16f5979..71da429 100644
--- a/compiler/rustc_metadata/src/errors.rs
+++ b/compiler/rustc_metadata/src/errors.rs
@@ -300,15 +300,8 @@ pub struct NoLinkModOverride {
}
#[derive(Diagnostic)]
-#[diag(metadata_unsupported_abi_i686)]
-pub struct UnsupportedAbiI686 {
- #[primary_span]
- pub span: Span,
-}
-
-#[derive(Diagnostic)]
-#[diag(metadata_unsupported_abi)]
-pub struct UnsupportedAbi {
+#[diag(metadata_raw_dylib_unsupported_abi)]
+pub struct RawDylibUnsupportedAbi {
#[primary_span]
pub span: Span,
}
diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs
index cee9cff..5cdeb89 100644
--- a/compiler/rustc_metadata/src/native_libs.rs
+++ b/compiler/rustc_metadata/src/native_libs.rs
@@ -652,7 +652,13 @@ fn build_dll_import(
) -> DllImport {
let span = self.tcx.def_span(item);
- // this logic is similar to `Target::adjust_abi` (in rustc_target/src/spec/mod.rs) but errors on unsupported inputs
+ // This `extern` block should have been checked for general ABI support before, but let's
+ // double-check that.
+ assert!(self.tcx.sess.target.is_abi_supported(abi));
+
+ // This logic is similar to `AbiMap::canonize_abi` (in rustc_target/src/spec/abi_map.rs) but
+ // we need more detail than those adjustments, and we can't support all ABIs that are
+ // generally supported.
let calling_convention = if self.tcx.sess.target.arch == "x86" {
match abi {
ExternAbi::C { .. } | ExternAbi::Cdecl { .. } => DllCallingConvention::C,
@@ -679,7 +685,7 @@ fn build_dll_import(
DllCallingConvention::Vectorcall(self.i686_arg_list_size(item))
}
_ => {
- self.tcx.dcx().emit_fatal(errors::UnsupportedAbiI686 { span });
+ self.tcx.dcx().emit_fatal(errors::RawDylibUnsupportedAbi { span });
}
}
} else {
@@ -688,7 +694,7 @@ fn build_dll_import(
DllCallingConvention::C
}
_ => {
- self.tcx.dcx().emit_fatal(errors::UnsupportedAbi { span });
+ self.tcx.dcx().emit_fatal(errors::RawDylibUnsupportedAbi { span });
}
}
};
diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs
index 7135b8f..667361b 100644
--- a/compiler/rustc_middle/src/lib.rs
+++ b/compiler/rustc_middle/src/lib.rs
@@ -54,7 +54,6 @@
#![feature(round_char_boundary)]
#![feature(rustc_attrs)]
#![feature(rustdoc_internals)]
-#![feature(trusted_len)]
#![feature(try_blocks)]
#![feature(try_trait_v2)]
#![feature(try_trait_v2_yeet)]
diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs
index bb068f3..f2f975a 100644
--- a/compiler/rustc_middle/src/mir/syntax.rs
+++ b/compiler/rustc_middle/src/mir/syntax.rs
@@ -1531,8 +1531,6 @@ pub enum CastKind {
///
/// MIR is well-formed if the input and output types have different sizes,
/// but running a transmute between differently-sized types is UB.
- ///
- /// Allowed only in [`MirPhase::Runtime`]; Earlier it's a [`TerminatorKind::Call`].
Transmute,
}
diff --git a/compiler/rustc_middle/src/query/erase.rs b/compiler/rustc_middle/src/query/erase.rs
index 6035056..7c99876 100644
--- a/compiler/rustc_middle/src/query/erase.rs
+++ b/compiler/rustc_middle/src/query/erase.rs
@@ -389,6 +389,7 @@ impl<'tcx> EraseType for $($fake_path)::+<'tcx> {
rustc_middle::ty::layout::FnAbiError,
rustc_middle::ty::layout::LayoutError,
rustc_middle::ty::ParamEnv,
+ rustc_middle::ty::TypingEnv,
rustc_middle::ty::Predicate,
rustc_middle::ty::SymbolName,
rustc_middle::ty::TraitRef,
diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs
index d03f01b..d8c927e 100644
--- a/compiler/rustc_middle/src/query/mod.rs
+++ b/compiler/rustc_middle/src/query/mod.rs
@@ -1115,11 +1115,6 @@
desc { |tcx| "checking for unstable API usage in {}", describe_as_module(key, tcx) }
}
- /// Checks the loops in the module.
- query check_mod_loops(key: LocalModDefId) {
- desc { |tcx| "checking loops in {}", describe_as_module(key, tcx) }
- }
-
query check_mod_privacy(key: LocalModDefId) {
desc { |tcx| "checking privacy in {}", describe_as_module(key.to_local_def_id(), tcx) }
}
@@ -1571,7 +1566,7 @@
/// Like `param_env`, but returns the `ParamEnv` after all opaque types have been
/// replaced with their hidden type. This is used in the old trait solver
/// when in `PostAnalysis` mode and should not be called directly.
- query param_env_normalized_for_post_analysis(def_id: DefId) -> ty::ParamEnv<'tcx> {
+ query typing_env_normalized_for_post_analysis(def_id: DefId) -> ty::TypingEnv<'tcx> {
desc { |tcx| "computing revealed normalized predicates of `{}`", tcx.def_path_str(def_id) }
}
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index 0b1e985..cb132ae 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -86,6 +86,10 @@
#[allow(rustc::usage_of_ty_tykind)]
impl<'tcx> Interner for TyCtxt<'tcx> {
+ fn next_trait_solver_globally(self) -> bool {
+ self.next_trait_solver_globally()
+ }
+
type DefId = DefId;
type LocalDefId = LocalDefId;
type Span = Span;
@@ -179,6 +183,17 @@ fn with_global_cache<R>(self, f: impl FnOnce(&mut search_graph::GlobalCache<Self
f(&mut *self.new_solver_evaluation_cache.lock())
}
+ fn canonical_param_env_cache_get_or_insert<R>(
+ self,
+ param_env: ty::ParamEnv<'tcx>,
+ f: impl FnOnce() -> ty::CanonicalParamEnvCacheEntry<Self>,
+ from_entry: impl FnOnce(&ty::CanonicalParamEnvCacheEntry<Self>) -> R,
+ ) -> R {
+ let mut cache = self.new_solver_canonical_param_env_cache.lock();
+ let entry = cache.entry(param_env).or_insert_with(f);
+ from_entry(entry)
+ }
+
fn evaluation_is_concurrent(&self) -> bool {
self.sess.threads() > 1
}
@@ -1444,6 +1459,8 @@ pub struct GlobalCtxt<'tcx> {
/// Caches the results of goal evaluation in the new solver.
pub new_solver_evaluation_cache: Lock<search_graph::GlobalCache<TyCtxt<'tcx>>>,
+ pub new_solver_canonical_param_env_cache:
+ Lock<FxHashMap<ty::ParamEnv<'tcx>, ty::CanonicalParamEnvCacheEntry<TyCtxt<'tcx>>>>,
pub canonical_param_env_cache: CanonicalParamEnvCache<'tcx>,
@@ -1692,6 +1709,7 @@ pub fn create_global_ctxt<T>(
selection_cache: Default::default(),
evaluation_cache: Default::default(),
new_solver_evaluation_cache: Default::default(),
+ new_solver_canonical_param_env_cache: Default::default(),
canonical_param_env_cache: Default::default(),
data_layout,
alloc_map: interpret::AllocMap::new(),
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs
index af31f7e..dc3f284 100644
--- a/compiler/rustc_middle/src/ty/mod.rs
+++ b/compiler/rustc_middle/src/ty/mod.rs
@@ -1116,10 +1116,7 @@ pub fn non_body_analysis(
}
pub fn post_analysis(tcx: TyCtxt<'tcx>, def_id: impl IntoQueryParam<DefId>) -> TypingEnv<'tcx> {
- TypingEnv {
- typing_mode: TypingMode::PostAnalysis,
- param_env: tcx.param_env_normalized_for_post_analysis(def_id),
- }
+ tcx.typing_env_normalized_for_post_analysis(def_id)
}
/// Modify the `typing_mode` to `PostAnalysis` and eagerly reveal all
@@ -1133,7 +1130,7 @@ pub fn with_post_analysis_normalized(self, tcx: TyCtxt<'tcx>) -> TypingEnv<'tcx>
// No need to reveal opaques with the new solver enabled,
// since we have lazy norm.
let param_env = if tcx.next_trait_solver_globally() {
- ParamEnv::new(param_env.caller_bounds())
+ param_env
} else {
ParamEnv::new(tcx.reveal_opaque_types_in_bounds(param_env.caller_bounds()))
};
diff --git a/compiler/rustc_mir_transform/src/early_otherwise_branch.rs b/compiler/rustc_mir_transform/src/early_otherwise_branch.rs
index c7feb9e..da88e5c 100644
--- a/compiler/rustc_mir_transform/src/early_otherwise_branch.rs
+++ b/compiler/rustc_mir_transform/src/early_otherwise_branch.rs
@@ -128,28 +128,20 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
let mut patch = MirPatch::new(body);
- let (second_discriminant_temp, second_operand) = if opt_data.need_hoist_discriminant {
+ let second_operand = if opt_data.need_hoist_discriminant {
// create temp to store second discriminant in, `_s` in example above
let second_discriminant_temp =
patch.new_temp(opt_data.child_ty, opt_data.child_source.span);
- patch.add_statement(
- parent_end,
- StatementKind::StorageLive(second_discriminant_temp),
- );
-
// create assignment of discriminant
patch.add_assign(
parent_end,
Place::from(second_discriminant_temp),
Rvalue::Discriminant(opt_data.child_place),
);
- (
- Some(second_discriminant_temp),
- Operand::Move(Place::from(second_discriminant_temp)),
- )
+ Operand::Move(Place::from(second_discriminant_temp))
} else {
- (None, Operand::Copy(opt_data.child_place))
+ Operand::Copy(opt_data.child_place)
};
// create temp to store inequality comparison between the two discriminants, `_t` in
@@ -157,7 +149,6 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
let nequal = BinOp::Ne;
let comp_res_type = nequal.ty(tcx, parent_ty, opt_data.child_ty);
let comp_temp = patch.new_temp(comp_res_type, opt_data.child_source.span);
- patch.add_statement(parent_end, StatementKind::StorageLive(comp_temp));
// create inequality comparison
let comp_rvalue =
@@ -200,23 +191,6 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
TerminatorKind::if_(Operand::Move(Place::from(comp_temp)), true_case, false_case),
);
- if let Some(second_discriminant_temp) = second_discriminant_temp {
- // generate StorageDead for the second_discriminant_temp not in use anymore
- patch.add_statement(
- parent_end,
- StatementKind::StorageDead(second_discriminant_temp),
- );
- }
-
- // Generate a StorageDead for comp_temp in each of the targets, since we moved it into
- // the switch
- for bb in [false_case, true_case].iter() {
- patch.add_statement(
- Location { block: *bb, statement_index: 0 },
- StatementKind::StorageDead(comp_temp),
- );
- }
-
patch.apply(body);
}
diff --git a/compiler/rustc_mir_transform/src/inline/cycle.rs b/compiler/rustc_mir_transform/src/inline/cycle.rs
index 2922788..a944960 100644
--- a/compiler/rustc_mir_transform/src/inline/cycle.rs
+++ b/compiler/rustc_mir_transform/src/inline/cycle.rs
@@ -138,7 +138,7 @@ fn process<'tcx>(
}
false
}
- // FIXME(-Znext-solver): Remove this hack when trait solver overflow can return an error.
+ // FIXME(-Znext-solver=no): Remove this hack when trait solver overflow can return an error.
// In code like that pointed out in #128887, the type complexity we ask the solver to deal with
// grows as we recurse into the call graph. If we use the same recursion limit here and in the
// solver, the solver hits the limit first and emits a fatal error. But if we use a reduced
diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs
index d26e446..572ad58 100644
--- a/compiler/rustc_mir_transform/src/lib.rs
+++ b/compiler/rustc_mir_transform/src/lib.rs
@@ -7,10 +7,7 @@
#![feature(file_buffered)]
#![feature(if_let_guard)]
#![feature(impl_trait_in_assoc_type)]
-#![feature(map_try_insert)]
-#![feature(never_type)]
#![feature(try_blocks)]
-#![feature(vec_deque_pop_if)]
#![feature(yeet_expr)]
// tidy-alphabetical-end
diff --git a/compiler/rustc_mir_transform/src/validate.rs b/compiler/rustc_mir_transform/src/validate.rs
index fd91508..7dcdd79 100644
--- a/compiler/rustc_mir_transform/src/validate.rs
+++ b/compiler/rustc_mir_transform/src/validate.rs
@@ -1308,37 +1308,27 @@ macro_rules! check_kinds {
}
}
CastKind::Transmute => {
- if let MirPhase::Runtime(..) = self.body.phase {
- // Unlike `mem::transmute`, a MIR `Transmute` is well-formed
- // for any two `Sized` types, just potentially UB to run.
+ // Unlike `mem::transmute`, a MIR `Transmute` is well-formed
+ // for any two `Sized` types, just potentially UB to run.
- if !self
- .tcx
- .normalize_erasing_regions(self.typing_env, op_ty)
- .is_sized(self.tcx, self.typing_env)
- {
- self.fail(
- location,
- format!("Cannot transmute from non-`Sized` type {op_ty}"),
- );
- }
- if !self
- .tcx
- .normalize_erasing_regions(self.typing_env, *target_type)
- .is_sized(self.tcx, self.typing_env)
- {
- self.fail(
- location,
- format!("Cannot transmute to non-`Sized` type {target_type:?}"),
- );
- }
- } else {
+ if !self
+ .tcx
+ .normalize_erasing_regions(self.typing_env, op_ty)
+ .is_sized(self.tcx, self.typing_env)
+ {
self.fail(
location,
- format!(
- "Transmute is not supported in non-runtime phase {:?}.",
- self.body.phase
- ),
+ format!("Cannot transmute from non-`Sized` type {op_ty}"),
+ );
+ }
+ if !self
+ .tcx
+ .normalize_erasing_regions(self.typing_env, *target_type)
+ .is_sized(self.tcx, self.typing_env)
+ {
+ self.fail(
+ location,
+ format!("Cannot transmute to non-`Sized` type {target_type:?}"),
);
}
}
diff --git a/compiler/rustc_next_trait_solver/src/canonicalizer.rs b/compiler/rustc_next_trait_solver/src/canonicalizer.rs
index a87ae52..cea7753 100644
--- a/compiler/rustc_next_trait_solver/src/canonicalizer.rs
+++ b/compiler/rustc_next_trait_solver/src/canonicalizer.rs
@@ -4,8 +4,9 @@
use rustc_type_ir::inherent::*;
use rustc_type_ir::solve::{Goal, QueryInput};
use rustc_type_ir::{
- self as ty, Canonical, CanonicalTyVarKind, CanonicalVarKind, Flags, InferCtxtLike, Interner,
- TypeFlags, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt,
+ self as ty, Canonical, CanonicalParamEnvCacheEntry, CanonicalTyVarKind, CanonicalVarKind,
+ Flags, InferCtxtLike, Interner, TypeFlags, TypeFoldable, TypeFolder, TypeSuperFoldable,
+ TypeVisitableExt,
};
use crate::delegate::SolverDelegate;
@@ -100,6 +101,76 @@ pub fn canonicalize_response<T: TypeFoldable<I>>(
Canonical { max_universe, variables, value }
}
+ fn canonicalize_param_env(
+ delegate: &'a D,
+ variables: &'a mut Vec<I::GenericArg>,
+ param_env: I::ParamEnv,
+ ) -> (I::ParamEnv, HashMap<I::GenericArg, usize>, Vec<CanonicalVarKind<I>>) {
+ if !param_env.has_type_flags(NEEDS_CANONICAL) {
+ return (param_env, Default::default(), Vec::new());
+ }
+
+ // Check whether we can use the global cache for this param_env. As we only use
+ // the `param_env` itself as the cache key, considering any additional information
+ // durnig its canonicalization would be incorrect. We always canonicalize region
+ // inference variables in a separate universe, so these are fine. However, we do
+ // track the universe of type and const inference variables so these must not be
+ // globally cached. We don't rely on any additional information when canonicalizing
+ // placeholders.
+ if !param_env.has_non_region_infer() {
+ delegate.cx().canonical_param_env_cache_get_or_insert(
+ param_env,
+ || {
+ let mut variables = Vec::new();
+ let mut env_canonicalizer = Canonicalizer {
+ delegate,
+ canonicalize_mode: CanonicalizeMode::Input { keep_static: true },
+
+ variables: &mut variables,
+ variable_lookup_table: Default::default(),
+ var_kinds: Vec::new(),
+ binder_index: ty::INNERMOST,
+
+ cache: Default::default(),
+ };
+ let param_env = param_env.fold_with(&mut env_canonicalizer);
+ debug_assert_eq!(env_canonicalizer.binder_index, ty::INNERMOST);
+ CanonicalParamEnvCacheEntry {
+ param_env,
+ variable_lookup_table: env_canonicalizer.variable_lookup_table,
+ var_kinds: env_canonicalizer.var_kinds,
+ variables,
+ }
+ },
+ |&CanonicalParamEnvCacheEntry {
+ param_env,
+ variables: ref cache_variables,
+ ref variable_lookup_table,
+ ref var_kinds,
+ }| {
+ debug_assert!(variables.is_empty());
+ variables.extend(cache_variables.iter().copied());
+ (param_env, variable_lookup_table.clone(), var_kinds.clone())
+ },
+ )
+ } else {
+ let mut env_canonicalizer = Canonicalizer {
+ delegate,
+ canonicalize_mode: CanonicalizeMode::Input { keep_static: true },
+
+ variables,
+ variable_lookup_table: Default::default(),
+ var_kinds: Vec::new(),
+ binder_index: ty::INNERMOST,
+
+ cache: Default::default(),
+ };
+ let param_env = param_env.fold_with(&mut env_canonicalizer);
+ debug_assert_eq!(env_canonicalizer.binder_index, ty::INNERMOST);
+ (param_env, env_canonicalizer.variable_lookup_table, env_canonicalizer.var_kinds)
+ }
+ }
+
/// When canonicalizing query inputs, we keep `'static` in the `param_env`
/// but erase it everywhere else. We generally don't want to depend on region
/// identity, so while it should not matter whether `'static` is kept in the
@@ -114,37 +185,17 @@ pub fn canonicalize_input<P: TypeFoldable<I>>(
input: QueryInput<I, P>,
) -> ty::Canonical<I, QueryInput<I, P>> {
// First canonicalize the `param_env` while keeping `'static`
- let mut env_canonicalizer = Canonicalizer {
- delegate,
- canonicalize_mode: CanonicalizeMode::Input { keep_static: true },
-
- variables,
- variable_lookup_table: Default::default(),
- var_kinds: Vec::new(),
- binder_index: ty::INNERMOST,
-
- cache: Default::default(),
- };
-
- let param_env = input.goal.param_env;
- let param_env = if param_env.has_type_flags(NEEDS_CANONICAL) {
- param_env.fold_with(&mut env_canonicalizer)
- } else {
- param_env
- };
-
- debug_assert_eq!(env_canonicalizer.binder_index, ty::INNERMOST);
+ let (param_env, variable_lookup_table, var_kinds) =
+ Canonicalizer::canonicalize_param_env(delegate, variables, input.goal.param_env);
// Then canonicalize the rest of the input without keeping `'static`
// while *mostly* reusing the canonicalizer from above.
let mut rest_canonicalizer = Canonicalizer {
delegate,
canonicalize_mode: CanonicalizeMode::Input { keep_static: false },
- variables: env_canonicalizer.variables,
- // We're able to reuse the `variable_lookup_table` as whether or not
- // it already contains an entry for `'static` does not matter.
- variable_lookup_table: env_canonicalizer.variable_lookup_table,
- var_kinds: env_canonicalizer.var_kinds,
+ variables,
+ variable_lookup_table,
+ var_kinds,
binder_index: ty::INNERMOST,
// We do not reuse the cache as it may contain entries whose canonicalized
diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
index 38d7ff5..345ece2 100644
--- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
@@ -544,8 +544,19 @@ pub(super) fn evaluate_goal_raw(
// to recompute this goal.
HasChanged::Yes => None,
HasChanged::No => {
- // Remove the unconstrained RHS arg, which is expected to have changed.
let mut stalled_vars = orig_values;
+
+ // Remove the canonicalized universal vars, since we only care about stalled existentials.
+ stalled_vars.retain(|arg| match arg.kind() {
+ ty::GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Infer(_)),
+ ty::GenericArgKind::Const(ct) => {
+ matches!(ct.kind(), ty::ConstKind::Infer(_))
+ }
+ // Lifetimes can never stall goals.
+ ty::GenericArgKind::Lifetime(_) => false,
+ });
+
+ // Remove the unconstrained RHS arg, which is expected to have changed.
if let Some(normalizes_to) = goal.predicate.as_normalizes_to() {
let normalizes_to = normalizes_to.skip_binder();
let rhs_arg: I::GenericArg = normalizes_to.term.into();
diff --git a/compiler/rustc_next_trait_solver/src/solve/mod.rs b/compiler/rustc_next_trait_solver/src/solve/mod.rs
index a7a9841..e4e0aba 100644
--- a/compiler/rustc_next_trait_solver/src/solve/mod.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/mod.rs
@@ -237,8 +237,8 @@ fn try_merge_responses(
return None;
}
- // FIXME(-Znext-solver): We should instead try to find a `Certainty::Yes` response with
- // a subset of the constraints that all the other responses have.
+ // FIXME(-Znext-solver): Add support to merge region constraints in
+ // responses to deal with trait-system-refactor-initiative#27.
let one = responses[0];
if responses[1..].iter().all(|&resp| resp == one) {
return Some(one);
diff --git a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/inherent.rs b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/inherent.rs
index 2640238..26443c5 100644
--- a/compiler/rustc_next_trait_solver/src/solve/normalizes_to/inherent.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/normalizes_to/inherent.rs
@@ -41,6 +41,9 @@ pub(super) fn normalize_inherent_associated_term(
// and we tag the impl bounds with `GoalSource::ImplWhereBound`?
// Right now this includes both the impl and the assoc item where bounds,
// and I don't think the assoc item where-bounds are allowed to be coinductive.
+ //
+ // Projecting to the IAT also "steps out the impl contructor", so we would have
+ // to be very careful when changing the impl where-clauses to be productive.
self.add_goals(
GoalSource::Misc,
cx.predicates_of(inherent.def_id)
diff --git a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs
index 7c4e1dc..110c67a 100644
--- a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs
+++ b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs
@@ -235,7 +235,11 @@ fn consider_trait_alias_candidate(
.predicates_of(goal.predicate.def_id())
.iter_instantiated(cx, goal.predicate.trait_ref.args)
.map(|p| goal.with(cx, p));
- // FIXME(-Znext-solver=coinductive): Should this be `GoalSource::ImplWhereBound`?
+ // While you could think of trait aliases to have a single builtin impl
+ // which uses its implied trait bounds as where-clauses, using
+ // `GoalSource::ImplWhereClause` here would be incorrect, as we also
+ // impl them, which means we're "stepping out of the impl constructor"
+ // again. To handle this, we treat these cycles as ambiguous for now.
ecx.add_goals(GoalSource::Misc, nested_obligations);
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
})
diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs
index 3ab726d..8ea5355 100644
--- a/compiler/rustc_parse/src/lib.rs
+++ b/compiler/rustc_parse/src/lib.rs
@@ -9,7 +9,6 @@
#![feature(debug_closure_helpers)]
#![feature(if_let_guard)]
#![feature(iter_intersperse)]
-#![feature(string_from_utf8_lossy_owned)]
#![recursion_limit = "256"]
// tidy-alphabetical-end
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs
index a298c4d..93489aa 100644
--- a/compiler/rustc_parse/src/parser/expr.rs
+++ b/compiler/rustc_parse/src/parser/expr.rs
@@ -1520,22 +1520,20 @@ fn parse_expr_bottom(&mut self) -> PResult<'a, P<Expr>> {
Ok(this.mk_expr(this.prev_token.span, ExprKind::Underscore))
} else if this.token_uninterpolated_span().at_least_rust_2018() {
// `Span::at_least_rust_2018()` is somewhat expensive; don't get it repeatedly.
+ let at_async = this.check_keyword(exp!(Async));
+ // check for `gen {}` and `gen move {}`
+ // or `async gen {}` and `async gen move {}`
+ // FIXME: (async) gen closures aren't yet parsed.
+ // FIXME(gen_blocks): Parse `gen async` and suggest swap
if this.token_uninterpolated_span().at_least_rust_2024()
- // check for `gen {}` and `gen move {}`
- // or `async gen {}` and `async gen move {}`
- && (this.is_gen_block(kw::Gen, 0)
- || (this.check_keyword(exp!(Async)) && this.is_gen_block(kw::Gen, 1)))
+ && this.is_gen_block(kw::Gen, at_async as usize)
{
- // FIXME: (async) gen closures aren't yet parsed.
this.parse_gen_block()
- } else if this.check_keyword(exp!(Async)) {
- // FIXME(gen_blocks): Parse `gen async` and suggest swap
- if this.is_gen_block(kw::Async, 0) {
- // Check for `async {` and `async move {`,
- this.parse_gen_block()
- } else {
- this.parse_expr_closure()
- }
+ // Check for `async {` and `async move {`,
+ } else if this.is_gen_block(kw::Async, 0) {
+ this.parse_gen_block()
+ } else if at_async {
+ this.parse_expr_closure()
} else if this.eat_keyword_noexpect(kw::Await) {
this.recover_incorrect_await_syntax(lo)
} else {
@@ -2407,6 +2405,14 @@ fn parse_expr_closure(&mut self) -> PResult<'a, P<Expr>> {
None
};
+ if let ClosureBinder::NotPresent = binder
+ && coroutine_kind.is_some()
+ {
+ // coroutine closures and generators can have the same qualifiers, so we might end up
+ // in here if there is a missing `|` but also no `{`. Adjust the expectations in that case.
+ self.expected_token_types.insert(TokenType::OpenBrace);
+ }
+
let capture_clause = self.parse_capture_clause()?;
let (fn_decl, fn_arg_span) = self.parse_fn_block_decl()?;
let decl_hi = self.prev_token.span;
diff --git a/compiler/rustc_passes/messages.ftl b/compiler/rustc_passes/messages.ftl
index 983e562..a4ef065 100644
--- a/compiler/rustc_passes/messages.ftl
+++ b/compiler/rustc_passes/messages.ftl
@@ -56,23 +56,6 @@
passes_both_ffi_const_and_pure =
`#[ffi_const]` function cannot be `#[ffi_pure]`
-passes_break_inside_closure =
- `{$name}` inside of a closure
- .label = cannot `{$name}` inside of a closure
- .closure_label = enclosing closure
-
-passes_break_inside_coroutine =
- `{$name}` inside `{$kind}` {$source}
- .label = cannot `{$name}` inside `{$kind}` {$source}
- .coroutine_label = enclosing `{$kind}` {$source}
-
-passes_break_non_loop =
- `break` with value from a `{$kind}` loop
- .label = can only break with a value inside `loop` or breakable block
- .label2 = you can't `break` with a value in a `{$kind}` loop
- .suggestion = use `break` on its own without a value inside this `{$kind}` loop
- .break_expr_suggestion = alternatively, you might have meant to use the available loop label
-
passes_cannot_stabilize_deprecated =
an API can't be stabilized after it is deprecated
.label = invalid version
@@ -103,10 +86,6 @@
attribute `#[rustc_const_stable]` can only be applied to functions that are declared `#[stable]`
.label = attribute specified here
-passes_continue_labeled_block =
- `continue` pointing to a labeled block
- .label = labeled blocks cannot be `continue`'d
- .block_label = labeled block the `continue` points to
passes_coroutine_on_non_closure =
attribute should be applied to closures
@@ -574,17 +553,6 @@
passes_outer_crate_level_attr =
crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-passes_outside_loop =
- `{$name}` outside of a loop{$is_break ->
- [true] {" or labeled block"}
- *[false] {""}
- }
- .label = cannot `{$name}` outside of a loop{$is_break ->
- [true] {" or labeled block"}
- *[false] {""}
- }
-
-passes_outside_loop_suggestion = consider labeling this block to be able to break within it
passes_panic_unwind_without_std =
unwinding panics are not supported without std
@@ -752,14 +720,6 @@
definition of an unknown lang item: `{$name}`
.label = definition of unknown lang item `{$name}`
-passes_unlabeled_cf_in_while_condition =
- `break` or `continue` with no label in the condition of a `while` loop
- .label = unlabeled `{$cf_type}` in the condition of a `while` loop
-
-passes_unlabeled_in_labeled_block =
- unlabeled `{$cf_type}` inside of a labeled block
- .label = `{$cf_type}` statements that would diverge to or through a labeled block need to bear a label
-
passes_unnecessary_partial_stable_feature = the feature `{$feature}` has been partially stabilized since {$since} and is succeeded by the feature `{$implies}`
.suggestion = if you are using features which are still unstable, change to using `{$implies}`
.suggestion_remove = if you are using features which are now stable, remove this line
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs
index dc29b03..4e2be8f 100644
--- a/compiler/rustc_passes/src/check_attr.rs
+++ b/compiler/rustc_passes/src/check_attr.rs
@@ -132,7 +132,22 @@ fn check_attributes(
target,
attrs,
),
- _ => {
+ Attribute::Parsed(AttributeKind::AllowConstFnUnstable { .. }) => {
+ self.check_rustc_allow_const_fn_unstable(hir_id, attr, span, target)
+ }
+ Attribute::Parsed(AttributeKind::Deprecation { .. }) => {
+ self.check_deprecated(hir_id, attr, span, target)
+ }
+ Attribute::Parsed(AttributeKind::DocComment { .. }) => { /* `#[doc]` is actually a lot more than just doc comments, so is checked below*/
+ }
+ Attribute::Parsed(AttributeKind::Repr(_)) => { /* handled below this loop and elsewhere */
+ }
+ Attribute::Parsed(
+ AttributeKind::BodyStability { .. }
+ | AttributeKind::ConstStabilityIndirect
+ | AttributeKind::MacroTransparency(_),
+ ) => { /* do nothing */ }
+ Attribute::Unparsed(_) => {
match attr.path().as_slice() {
[sym::diagnostic, sym::do_not_recommend, ..] => {
self.check_do_not_recommend(attr.span(), hir_id, target, attr, item)
@@ -169,9 +184,6 @@ fn check_attributes(
self.check_rustc_layout_scalar_valid_range(attr, span, target)
}
[sym::debugger_visualizer, ..] => self.check_debugger_visualizer(attr, target),
- [sym::rustc_allow_const_fn_unstable, ..] => {
- self.check_rustc_allow_const_fn_unstable(hir_id, attr, span, target)
- }
[sym::rustc_std_internal_symbol, ..] => {
self.check_rustc_std_internal_symbol(attr, span, target)
}
@@ -229,7 +241,6 @@ fn check_attributes(
[sym::link_name, ..] => self.check_link_name(hir_id, attr, span, target),
[sym::link_section, ..] => self.check_link_section(hir_id, attr, span, target),
[sym::no_mangle, ..] => self.check_no_mangle(hir_id, attr, span, target),
- [sym::deprecated, ..] => self.check_deprecated(hir_id, attr, span, target),
[sym::macro_use, ..] | [sym::macro_escape, ..] => {
self.check_macro_use(hir_id, attr, target)
}
@@ -283,7 +294,6 @@ fn check_attributes(
| sym::pointee // FIXME(derive_coerce_pointee)
| sym::omit_gdb_pretty_printer_section // FIXME(omit_gdb_pretty_printer_section)
| sym::used // handled elsewhere to restrict to static items
- | sym::repr // handled elsewhere to restrict to type decls items
| sym::instruction_set // broken on stable!!!
| sym::windows_subsystem // broken on stable!!!
| sym::patchable_function_entry // FIXME(patchable_function_entry)
diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs
index 6b82252..e597c81 100644
--- a/compiler/rustc_passes/src/dead.rs
+++ b/compiler/rustc_passes/src/dead.rs
@@ -22,7 +22,7 @@
use rustc_middle::{bug, span_bug};
use rustc_session::lint::builtin::DEAD_CODE;
use rustc_session::lint::{self, LintExpectationId};
-use rustc_span::{Symbol, sym};
+use rustc_span::{Symbol, kw, sym};
use crate::errors::{
ChangeFields, IgnoredDerivedImpls, MultipleDeadCodes, ParentInfo, UselessAssignment,
@@ -793,6 +793,17 @@ fn check_item<'tcx>(
// global_asm! is always live.
worklist.push((id.owner_id.def_id, ComesFromAllowExpect::No));
}
+ DefKind::Const => {
+ let item = tcx.hir_item(id);
+ if let hir::ItemKind::Const(ident, ..) = item.kind
+ && ident.name == kw::Underscore
+ {
+ // `const _` is always live, as that syntax only exists for the side effects
+ // of type checking and evaluating the constant expression, and marking them
+ // as dead code would defeat that purpose.
+ worklist.push((id.owner_id.def_id, ComesFromAllowExpect::No));
+ }
+ }
_ => {}
}
}
diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs
index b995781..74ce926 100644
--- a/compiler/rustc_passes/src/errors.rs
+++ b/compiler/rustc_passes/src/errors.rs
@@ -1,13 +1,12 @@
use std::io::Error;
use std::path::{Path, PathBuf};
-use rustc_ast::Label;
use rustc_errors::codes::*;
use rustc_errors::{
Applicability, Diag, DiagCtxtHandle, DiagSymbolList, Diagnostic, EmissionGuarantee, Level,
MultiSpan, Subdiagnostic,
};
-use rustc_hir::{self as hir, ExprKind, Target};
+use rustc_hir::Target;
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::{MainDefinition, Ty};
use rustc_span::{DUMMY_SP, Span, Symbol};
@@ -1071,131 +1070,6 @@ pub(crate) struct FeaturePreviouslyDeclared<'a> {
pub prev_declared: &'a str,
}
-pub(crate) struct BreakNonLoop<'a> {
- pub span: Span,
- pub head: Option<Span>,
- pub kind: &'a str,
- pub suggestion: String,
- pub loop_label: Option<Label>,
- pub break_label: Option<Label>,
- pub break_expr_kind: &'a ExprKind<'a>,
- pub break_expr_span: Span,
-}
-
-impl<'a, G: EmissionGuarantee> Diagnostic<'_, G> for BreakNonLoop<'a> {
- #[track_caller]
- fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> {
- let mut diag = Diag::new(dcx, level, fluent::passes_break_non_loop);
- diag.span(self.span);
- diag.code(E0571);
- diag.arg("kind", self.kind);
- diag.span_label(self.span, fluent::passes_label);
- if let Some(head) = self.head {
- diag.span_label(head, fluent::passes_label2);
- }
- diag.span_suggestion(
- self.span,
- fluent::passes_suggestion,
- self.suggestion,
- Applicability::MaybeIncorrect,
- );
- if let (Some(label), None) = (self.loop_label, self.break_label) {
- match self.break_expr_kind {
- ExprKind::Path(hir::QPath::Resolved(
- None,
- hir::Path { segments: [segment], res: hir::def::Res::Err, .. },
- )) if label.ident.to_string() == format!("'{}", segment.ident) => {
- // This error is redundant, we will have already emitted a
- // suggestion to use the label when `segment` wasn't found
- // (hence the `Res::Err` check).
- diag.downgrade_to_delayed_bug();
- }
- _ => {
- diag.span_suggestion(
- self.break_expr_span,
- fluent::passes_break_expr_suggestion,
- label.ident,
- Applicability::MaybeIncorrect,
- );
- }
- }
- }
- diag
- }
-}
-
-#[derive(Diagnostic)]
-#[diag(passes_continue_labeled_block, code = E0696)]
-pub(crate) struct ContinueLabeledBlock {
- #[primary_span]
- #[label]
- pub span: Span,
- #[label(passes_block_label)]
- pub block_span: Span,
-}
-
-#[derive(Diagnostic)]
-#[diag(passes_break_inside_closure, code = E0267)]
-pub(crate) struct BreakInsideClosure<'a> {
- #[primary_span]
- #[label]
- pub span: Span,
- #[label(passes_closure_label)]
- pub closure_span: Span,
- pub name: &'a str,
-}
-
-#[derive(Diagnostic)]
-#[diag(passes_break_inside_coroutine, code = E0267)]
-pub(crate) struct BreakInsideCoroutine<'a> {
- #[primary_span]
- #[label]
- pub span: Span,
- #[label(passes_coroutine_label)]
- pub coroutine_span: Span,
- pub name: &'a str,
- pub kind: &'a str,
- pub source: &'a str,
-}
-
-#[derive(Diagnostic)]
-#[diag(passes_outside_loop, code = E0268)]
-pub(crate) struct OutsideLoop<'a> {
- #[primary_span]
- #[label]
- pub spans: Vec<Span>,
- pub name: &'a str,
- pub is_break: bool,
- #[subdiagnostic]
- pub suggestion: Option<OutsideLoopSuggestion>,
-}
-#[derive(Subdiagnostic)]
-#[multipart_suggestion(passes_outside_loop_suggestion, applicability = "maybe-incorrect")]
-pub(crate) struct OutsideLoopSuggestion {
- #[suggestion_part(code = "'block: ")]
- pub block_span: Span,
- #[suggestion_part(code = " 'block")]
- pub break_spans: Vec<Span>,
-}
-
-#[derive(Diagnostic)]
-#[diag(passes_unlabeled_in_labeled_block, code = E0695)]
-pub(crate) struct UnlabeledInLabeledBlock<'a> {
- #[primary_span]
- #[label]
- pub span: Span,
- pub cf_type: &'a str,
-}
-
-#[derive(Diagnostic)]
-#[diag(passes_unlabeled_cf_in_while_condition, code = E0590)]
-pub(crate) struct UnlabeledCfInWhileCondition<'a> {
- #[primary_span]
- #[label]
- pub span: Span,
- pub cf_type: &'a str,
-}
-
#[derive(Diagnostic)]
#[diag(passes_naked_functions_incompatible_attribute, code = E0736)]
pub(crate) struct NakedFunctionIncompatibleAttribute {
diff --git a/compiler/rustc_passes/src/lib.rs b/compiler/rustc_passes/src/lib.rs
index 639ca68..af7ecf0 100644
--- a/compiler/rustc_passes/src/lib.rs
+++ b/compiler/rustc_passes/src/lib.rs
@@ -8,10 +8,8 @@
#![allow(internal_features)]
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![doc(rust_logo)]
-#![feature(box_patterns)]
#![feature(map_try_insert)]
#![feature(rustdoc_internals)]
-#![feature(try_blocks)]
// tidy-alphabetical-end
use rustc_middle::util::Providers;
@@ -31,7 +29,6 @@
pub mod layout_test;
mod lib_features;
mod liveness;
-pub mod loops;
mod reachable;
pub mod stability;
mod upvars;
@@ -47,7 +44,6 @@ pub fn provide(providers: &mut Providers) {
entry::provide(providers);
lang_items::provide(providers);
lib_features::provide(providers);
- loops::provide(providers);
liveness::provide(providers);
reachable::provide(providers);
stability::provide(providers);
diff --git a/compiler/rustc_query_system/src/lib.rs b/compiler/rustc_query_system/src/lib.rs
index d36cb6f..7fa643d 100644
--- a/compiler/rustc_query_system/src/lib.rs
+++ b/compiler/rustc_query_system/src/lib.rs
@@ -2,7 +2,6 @@
#![allow(internal_features)]
#![feature(assert_matches)]
#![feature(core_intrinsics)]
-#![feature(dropck_eyepatch)]
#![feature(min_specialization)]
// tidy-alphabetical-end
diff --git a/compiler/rustc_resolve/messages.ftl b/compiler/rustc_resolve/messages.ftl
index 38cdfa7..5894247 100644
--- a/compiler/rustc_resolve/messages.ftl
+++ b/compiler/rustc_resolve/messages.ftl
@@ -119,7 +119,7 @@
const parameters may not be used in enum discriminant values
resolve_const_param_in_non_trivial_anon_const =
- const parameters may only be used as standalone arguments, i.e. `{$name}`
+ const parameters may only be used as standalone arguments here, i.e. `{$name}`
resolve_constructor_private_if_any_field_private =
a constructor is private if any of the fields is private
diff --git a/compiler/rustc_session/src/filesearch.rs b/compiler/rustc_session/src/filesearch.rs
index 0e71189..def2cc9 100644
--- a/compiler/rustc_session/src/filesearch.rs
+++ b/compiler/rustc_session/src/filesearch.rs
@@ -3,7 +3,7 @@
use std::path::{Path, PathBuf};
use std::{env, fs};
-use rustc_fs_util::{fix_windows_verbatim_for_gcc, try_canonicalize};
+use rustc_fs_util::try_canonicalize;
use rustc_target::spec::Target;
use smallvec::{SmallVec, smallvec};
@@ -87,7 +87,7 @@ fn current_dll_path() -> Result<PathBuf, String> {
};
let bytes = CStr::from_ptr(fname_ptr).to_bytes();
let os = OsStr::from_bytes(bytes);
- Ok(PathBuf::from(os))
+ try_canonicalize(Path::new(os)).map_err(|e| e.to_string())
}
#[cfg(target_os = "aix")]
@@ -122,7 +122,7 @@ fn current_dll_path() -> Result<PathBuf, String> {
if (data_base..data_end).contains(&addr) {
let bytes = CStr::from_ptr(&(*current).ldinfo_filename[0]).to_bytes();
let os = OsStr::from_bytes(bytes);
- return Ok(PathBuf::from(os));
+ return try_canonicalize(Path::new(os)).map_err(|e| e.to_string());
}
if (*current).ldinfo_next == 0 {
break;
@@ -169,7 +169,12 @@ fn current_dll_path() -> Result<PathBuf, String> {
filename.truncate(n);
- Ok(OsString::from_wide(&filename).into())
+ let path = try_canonicalize(OsString::from_wide(&filename)).map_err(|e| e.to_string())?;
+
+ // See comments on this target function, but the gist is that
+ // gcc chokes on verbatim paths which fs::canonicalize generates
+ // so we try to avoid those kinds of paths.
+ Ok(rustc_fs_util::fix_windows_verbatim_for_gcc(&path))
}
#[cfg(target_os = "wasi")]
@@ -177,37 +182,13 @@ fn current_dll_path() -> Result<PathBuf, String> {
Err("current_dll_path is not supported on WASI".to_string())
}
-pub fn sysroot_candidates() -> SmallVec<[PathBuf; 2]> {
- let target = crate::config::host_tuple();
- let mut sysroot_candidates: SmallVec<[PathBuf; 2]> = smallvec![get_or_default_sysroot()];
- let path = current_dll_path().and_then(|s| try_canonicalize(s).map_err(|e| e.to_string()));
- if let Ok(dll) = path {
- // use `parent` twice to chop off the file name and then also the
- // directory containing the dll which should be either `lib` or `bin`.
- if let Some(path) = dll.parent().and_then(|p| p.parent()) {
- // The original `path` pointed at the `rustc_driver` crate's dll.
- // Now that dll should only be in one of two locations. The first is
- // in the compiler's libdir, for example `$sysroot/lib/*.dll`. The
- // other is the target's libdir, for example
- // `$sysroot/lib/rustlib/$target/lib/*.dll`.
- //
- // We don't know which, so let's assume that if our `path` above
- // ends in `$target` we *could* be in the target libdir, and always
- // assume that we may be in the main libdir.
- sysroot_candidates.push(path.to_owned());
-
- if path.ends_with(target) {
- sysroot_candidates.extend(
- path.parent() // chop off `$target`
- .and_then(|p| p.parent()) // chop off `rustlib`
- .and_then(|p| p.parent()) // chop off `lib`
- .map(|s| s.to_owned()),
- );
- }
- }
+pub fn sysroot_with_fallback(sysroot: &Path) -> SmallVec<[PathBuf; 2]> {
+ let mut candidates = smallvec![sysroot.to_owned()];
+ let default_sysroot = get_or_default_sysroot();
+ if default_sysroot != sysroot {
+ candidates.push(default_sysroot);
}
-
- sysroot_candidates
+ candidates
}
/// Returns the provided sysroot or calls [`get_or_default_sysroot`] if it's none.
@@ -219,17 +200,8 @@ pub fn materialize_sysroot(maybe_sysroot: Option<PathBuf>) -> PathBuf {
/// This function checks if sysroot is found using env::args().next(), and if it
/// is not found, finds sysroot from current rustc_driver dll.
pub fn get_or_default_sysroot() -> PathBuf {
- // Follow symlinks. If the resolved path is relative, make it absolute.
- fn canonicalize(path: PathBuf) -> PathBuf {
- let path = try_canonicalize(&path).unwrap_or(path);
- // See comments on this target function, but the gist is that
- // gcc chokes on verbatim paths which fs::canonicalize generates
- // so we try to avoid those kinds of paths.
- fix_windows_verbatim_for_gcc(&path)
- }
-
fn default_from_rustc_driver_dll() -> Result<PathBuf, String> {
- let dll = current_dll_path().map(|s| canonicalize(s))?;
+ let dll = current_dll_path()?;
// `dll` will be in one of the following two:
// - compiler's libdir: $sysroot/lib/*.dll
@@ -242,7 +214,7 @@ fn default_from_rustc_driver_dll() -> Result<PathBuf, String> {
dll.display()
))?;
- // if `dir` points target's dir, move up to the sysroot
+ // if `dir` points to target's dir, move up to the sysroot
let mut sysroot_dir = if dir.ends_with(crate::config::host_tuple()) {
dir.parent() // chop off `$target`
.and_then(|p| p.parent()) // chop off `rustlib`
diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs
index 010ae42..6b85e0a 100644
--- a/compiler/rustc_session/src/session.rs
+++ b/compiler/rustc_session/src/session.rs
@@ -458,13 +458,9 @@ pub fn host_filesearch(&self) -> &filesearch::FileSearch {
/// directories are also returned, for example if `--sysroot` is used but tools are missing
/// (#125246): we also add the bin directories to the sysroot where rustc is located.
pub fn get_tools_search_paths(&self, self_contained: bool) -> Vec<PathBuf> {
- let bin_path = filesearch::make_target_bin_path(&self.sysroot, config::host_tuple());
- let fallback_sysroot_paths = filesearch::sysroot_candidates()
+ let search_paths = filesearch::sysroot_with_fallback(&self.sysroot)
.into_iter()
- // Ignore sysroot candidate if it was the same as the sysroot path we just used.
- .filter(|sysroot| *sysroot != self.sysroot)
.map(|sysroot| filesearch::make_target_bin_path(&sysroot, config::host_tuple()));
- let search_paths = std::iter::once(bin_path).chain(fallback_sysroot_paths);
if self_contained {
// The self-contained tools are expected to be e.g. in `bin/self-contained` in the
diff --git a/compiler/rustc_smir/src/rustc_smir/context.rs b/compiler/rustc_smir/src/rustc_smir/context.rs
index bac5c90..ef8c883 100644
--- a/compiler/rustc_smir/src/rustc_smir/context.rs
+++ b/compiler/rustc_smir/src/rustc_smir/context.rs
@@ -16,7 +16,7 @@
};
use rustc_middle::{mir, ty};
use rustc_span::def_id::LOCAL_CRATE;
-use stable_mir::abi::{FnAbi, Layout, LayoutShape};
+use stable_mir::abi::{FnAbi, Layout, LayoutShape, ReprOptions};
use stable_mir::mir::alloc::GlobalAlloc;
use stable_mir::mir::mono::{InstanceDef, StaticDef};
use stable_mir::mir::{BinOp, Body, Place, UnOp};
@@ -397,6 +397,13 @@ pub fn adt_is_cstr(&self, def: AdtDef) -> bool {
tables.tcx.is_lang_item(def_id, LangItem::CStr)
}
+ /// Returns the representation options for this ADT
+ pub fn adt_repr(&self, def: AdtDef) -> ReprOptions {
+ let mut tables = self.0.borrow_mut();
+ let tcx = tables.tcx;
+ def.internal(&mut *tables, tcx).repr().stable(&mut *tables)
+ }
+
/// Retrieve the function signature for the given generic arguments.
pub fn fn_sig(&self, def: FnDef, args: &GenericArgs) -> PolyFnSig {
let mut tables = self.0.borrow_mut();
diff --git a/compiler/rustc_smir/src/rustc_smir/convert/abi.rs b/compiler/rustc_smir/src/rustc_smir/convert/abi.rs
index 64901ee..46f1ca6 100644
--- a/compiler/rustc_smir/src/rustc_smir/convert/abi.rs
+++ b/compiler/rustc_smir/src/rustc_smir/convert/abi.rs
@@ -6,9 +6,9 @@
use rustc_middle::ty;
use rustc_target::callconv;
use stable_mir::abi::{
- AddressSpace, ArgAbi, CallConvention, FieldsShape, FloatLength, FnAbi, IntegerLength, Layout,
- LayoutShape, PassMode, Primitive, Scalar, TagEncoding, TyAndLayout, ValueAbi, VariantsShape,
- WrappingRange,
+ AddressSpace, ArgAbi, CallConvention, FieldsShape, FloatLength, FnAbi, IntegerLength,
+ IntegerType, Layout, LayoutShape, PassMode, Primitive, ReprFlags, ReprOptions, Scalar,
+ TagEncoding, TyAndLayout, ValueAbi, VariantsShape, WrappingRange,
};
use stable_mir::opaque;
use stable_mir::target::MachineSize as Size;
@@ -310,3 +310,42 @@ fn stable(&self, _tables: &mut Tables<'_>) -> Self::T {
WrappingRange { start: self.start, end: self.end }
}
}
+
+impl<'tcx> Stable<'tcx> for rustc_abi::ReprFlags {
+ type T = ReprFlags;
+
+ fn stable(&self, _tables: &mut Tables<'_>) -> Self::T {
+ ReprFlags {
+ is_simd: self.intersects(Self::IS_SIMD),
+ is_c: self.intersects(Self::IS_C),
+ is_transparent: self.intersects(Self::IS_TRANSPARENT),
+ is_linear: self.intersects(Self::IS_LINEAR),
+ }
+ }
+}
+
+impl<'tcx> Stable<'tcx> for rustc_abi::IntegerType {
+ type T = IntegerType;
+
+ fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
+ match self {
+ rustc_abi::IntegerType::Pointer(signed) => IntegerType::Pointer { is_signed: *signed },
+ rustc_abi::IntegerType::Fixed(integer, signed) => {
+ IntegerType::Fixed { length: integer.stable(tables), is_signed: *signed }
+ }
+ }
+ }
+}
+
+impl<'tcx> Stable<'tcx> for rustc_abi::ReprOptions {
+ type T = ReprOptions;
+
+ fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
+ ReprOptions {
+ int: self.int.map(|int| int.stable(tables)),
+ align: self.align.map(|align| align.stable(tables)),
+ pack: self.pack.map(|pack| pack.stable(tables)),
+ flags: self.flags.stable(tables),
+ }
+ }
+}
diff --git a/compiler/rustc_smir/src/stable_mir/abi.rs b/compiler/rustc_smir/src/stable_mir/abi.rs
index 3842cb7..347c6ed 100644
--- a/compiler/rustc_smir/src/stable_mir/abi.rs
+++ b/compiler/rustc_smir/src/stable_mir/abi.rs
@@ -455,3 +455,38 @@ pub enum CallConvention {
RiscvInterrupt,
}
+
+#[non_exhaustive]
+#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize)]
+pub struct ReprFlags {
+ pub is_simd: bool,
+ pub is_c: bool,
+ pub is_transparent: bool,
+ pub is_linear: bool,
+}
+
+#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize)]
+pub enum IntegerType {
+ /// Pointer-sized integer type, i.e. `isize` and `usize`.
+ Pointer {
+ /// Signedness. e.g. `true` for `isize`
+ is_signed: bool,
+ },
+ /// Fixed-sized integer type, e.g. `i8`, `u32`, `i128`.
+ Fixed {
+ /// Length of this integer type. e.g. `IntegerLength::I8` for `u8`.
+ length: IntegerLength,
+ /// Signedness. e.g. `false` for `u8`
+ is_signed: bool,
+ },
+}
+
+/// Representation options provided by the user
+#[non_exhaustive]
+#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize)]
+pub struct ReprOptions {
+ pub int: Option<IntegerType>,
+ pub align: Option<Align>,
+ pub pack: Option<Align>,
+ pub flags: ReprFlags,
+}
diff --git a/compiler/rustc_smir/src/stable_mir/compiler_interface.rs b/compiler/rustc_smir/src/stable_mir/compiler_interface.rs
index bb35e23a..3967ad1 100644
--- a/compiler/rustc_smir/src/stable_mir/compiler_interface.rs
+++ b/compiler/rustc_smir/src/stable_mir/compiler_interface.rs
@@ -6,7 +6,7 @@
use std::cell::Cell;
use rustc_smir::context::SmirCtxt;
-use stable_mir::abi::{FnAbi, Layout, LayoutShape};
+use stable_mir::abi::{FnAbi, Layout, LayoutShape, ReprOptions};
use stable_mir::crate_def::Attribute;
use stable_mir::mir::alloc::{AllocId, GlobalAlloc};
use stable_mir::mir::mono::{Instance, InstanceDef, StaticDef};
@@ -200,6 +200,11 @@ pub(crate) fn adt_is_cstr(&self, def: AdtDef) -> bool {
self.cx.adt_is_cstr(def)
}
+ /// Returns the representation options for this ADT
+ pub(crate) fn adt_repr(&self, def: AdtDef) -> ReprOptions {
+ self.cx.adt_repr(def)
+ }
+
/// Retrieve the function signature for the given generic arguments.
pub(crate) fn fn_sig(&self, def: FnDef, args: &GenericArgs) -> PolyFnSig {
self.cx.fn_sig(def, args)
diff --git a/compiler/rustc_smir/src/stable_mir/ty.rs b/compiler/rustc_smir/src/stable_mir/ty.rs
index e331e59..4593685 100644
--- a/compiler/rustc_smir/src/stable_mir/ty.rs
+++ b/compiler/rustc_smir/src/stable_mir/ty.rs
@@ -9,6 +9,7 @@
use stable_mir::target::MachineInfo;
use stable_mir::{Filename, Opaque};
+use super::abi::ReprOptions;
use super::mir::{Body, Mutability, Safety};
use super::{DefId, Error, Symbol, with};
use crate::stable_mir;
@@ -742,6 +743,14 @@ fn from(def: IntrinsicDef) -> Self {
pub ClosureDef;
}
+impl ClosureDef {
+ /// Retrieves the body of the closure definition. Returns None if the body
+ /// isn't available.
+ pub fn body(&self) -> Option<Body> {
+ with(|ctx| ctx.has_body(self.0).then(|| ctx.mir_body(self.0)))
+ }
+}
+
crate_def! {
#[derive(Serialize)]
pub CoroutineDef;
@@ -818,6 +827,10 @@ pub fn variants_iter(&self) -> impl Iterator<Item = VariantDef> {
pub fn variant(&self, idx: VariantIdx) -> Option<VariantDef> {
(idx.to_index() < self.num_variants()).then_some(VariantDef { idx, adt_def: *self })
}
+
+ pub fn repr(&self) -> ReprOptions {
+ with(|cx| cx.adt_repr(*self))
+ }
}
/// Definition of a variant, which can be either a struct / union field or an enum variant.
diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs
index e950493..ed74dea 100644
--- a/compiler/rustc_span/src/lib.rs
+++ b/compiler/rustc_span/src/lib.rs
@@ -23,7 +23,6 @@
#![doc(rust_logo)]
#![feature(array_windows)]
#![feature(core_io_borrowed_buf)]
-#![feature(hash_set_entry)]
#![feature(if_let_guard)]
#![feature(map_try_insert)]
#![feature(negative_impls)]
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs
index 4e842a8..d66f988 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -515,8 +515,24 @@
async_iterator_poll_next,
async_trait_bounds,
atomic,
+ atomic_and,
+ atomic_cxchg,
+ atomic_cxchgweak,
+ atomic_fence,
atomic_load,
+ atomic_max,
+ atomic_min,
atomic_mod,
+ atomic_nand,
+ atomic_or,
+ atomic_singlethreadfence,
+ atomic_store,
+ atomic_umax,
+ atomic_umin,
+ atomic_xadd,
+ atomic_xchg,
+ atomic_xor,
+ atomic_xsub,
atomics,
att_syntax,
attr,
diff --git a/compiler/rustc_target/Cargo.toml b/compiler/rustc_target/Cargo.toml
index 189b19b..0121c75 100644
--- a/compiler/rustc_target/Cargo.toml
+++ b/compiler/rustc_target/Cargo.toml
@@ -20,5 +20,5 @@
# tidy-alphabetical-start
default-features = false
features = ["elf", "macho"]
-version = "0.36.2"
+version = "0.37.0"
# tidy-alphabetical-end
diff --git a/compiler/rustc_target/src/asm/mod.rs b/compiler/rustc_target/src/asm/mod.rs
index 9f79160..e06f881 100644
--- a/compiler/rustc_target/src/asm/mod.rs
+++ b/compiler/rustc_target/src/asm/mod.rs
@@ -226,6 +226,7 @@ pub enum InlineAsmArch {
RiscV64,
Nvptx64,
Hexagon,
+ LoongArch32,
LoongArch64,
Mips,
Mips64,
@@ -260,6 +261,7 @@ fn from_str(s: &str) -> Result<InlineAsmArch, ()> {
"powerpc" => Ok(Self::PowerPC),
"powerpc64" => Ok(Self::PowerPC64),
"hexagon" => Ok(Self::Hexagon),
+ "loongarch32" => Ok(Self::LoongArch32),
"loongarch64" => Ok(Self::LoongArch64),
"mips" | "mips32r6" => Ok(Self::Mips),
"mips64" | "mips64r6" => Ok(Self::Mips64),
@@ -365,7 +367,9 @@ pub fn parse(arch: InlineAsmArch, name: Symbol) -> Result<Self, &'static str> {
Self::PowerPC(PowerPCInlineAsmReg::parse(name)?)
}
InlineAsmArch::Hexagon => Self::Hexagon(HexagonInlineAsmReg::parse(name)?),
- InlineAsmArch::LoongArch64 => Self::LoongArch(LoongArchInlineAsmReg::parse(name)?),
+ InlineAsmArch::LoongArch32 | InlineAsmArch::LoongArch64 => {
+ Self::LoongArch(LoongArchInlineAsmReg::parse(name)?)
+ }
InlineAsmArch::Mips | InlineAsmArch::Mips64 => {
Self::Mips(MipsInlineAsmReg::parse(name)?)
}
@@ -652,7 +656,9 @@ pub fn parse(arch: InlineAsmArch, name: Symbol) -> Result<Self, &'static [rustc_
Self::PowerPC(PowerPCInlineAsmRegClass::parse(name)?)
}
InlineAsmArch::Hexagon => Self::Hexagon(HexagonInlineAsmRegClass::parse(name)?),
- InlineAsmArch::LoongArch64 => Self::LoongArch(LoongArchInlineAsmRegClass::parse(name)?),
+ InlineAsmArch::LoongArch32 | InlineAsmArch::LoongArch64 => {
+ Self::LoongArch(LoongArchInlineAsmRegClass::parse(name)?)
+ }
InlineAsmArch::Mips | InlineAsmArch::Mips64 => {
Self::Mips(MipsInlineAsmRegClass::parse(name)?)
}
@@ -860,7 +866,7 @@ pub fn allocatable_registers(
hexagon::fill_reg_map(arch, reloc_model, target_features, target, &mut map);
map
}
- InlineAsmArch::LoongArch64 => {
+ InlineAsmArch::LoongArch32 | InlineAsmArch::LoongArch64 => {
let mut map = loongarch::regclass_map();
loongarch::fill_reg_map(arch, reloc_model, target_features, target, &mut map);
map
@@ -992,7 +998,7 @@ pub fn parse(
"C" | "system" => Ok(InlineAsmClobberAbi::Avr),
_ => Err(&["C", "system"]),
},
- InlineAsmArch::LoongArch64 => match name {
+ InlineAsmArch::LoongArch32 | InlineAsmArch::LoongArch64 => match name {
"C" | "system" => Ok(InlineAsmClobberAbi::LoongArch),
_ => Err(&["C", "system"]),
},
diff --git a/compiler/rustc_target/src/callconv/mod.rs b/compiler/rustc_target/src/callconv/mod.rs
index dcb79cc..f9ecf02 100644
--- a/compiler/rustc_target/src/callconv/mod.rs
+++ b/compiler/rustc_target/src/callconv/mod.rs
@@ -648,7 +648,7 @@ pub fn adjust_for_foreign_abi<C>(&mut self, cx: &C, abi: ExternAbi)
"amdgpu" => amdgpu::compute_abi_info(cx, self),
"arm" => arm::compute_abi_info(cx, self),
"avr" => avr::compute_abi_info(self),
- "loongarch64" => loongarch::compute_abi_info(cx, self),
+ "loongarch32" | "loongarch64" => loongarch::compute_abi_info(cx, self),
"m68k" => m68k::compute_abi_info(self),
"csky" => csky::compute_abi_info(self),
"mips" | "mips32r6" => mips::compute_abi_info(cx, self),
@@ -691,7 +691,7 @@ pub fn adjust_for_rust_abi<C>(&mut self, cx: &C)
match &*spec.arch {
"x86" => x86::compute_rust_abi_info(cx, self),
"riscv32" | "riscv64" => riscv::compute_rust_abi_info(cx, self),
- "loongarch64" => loongarch::compute_rust_abi_info(cx, self),
+ "loongarch32" | "loongarch64" => loongarch::compute_rust_abi_info(cx, self),
"aarch64" => aarch64::compute_rust_abi_info(cx, self),
_ => {}
};
diff --git a/compiler/rustc_target/src/lib.rs b/compiler/rustc_target/src/lib.rs
index 566bee7..91657fe 100644
--- a/compiler/rustc_target/src/lib.rs
+++ b/compiler/rustc_target/src/lib.rs
@@ -11,10 +11,8 @@
#![allow(internal_features)]
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![doc(rust_logo)]
-#![feature(assert_matches)]
#![feature(debug_closure_helpers)]
#![feature(iter_intersperse)]
-#![feature(rustc_attrs)]
#![feature(rustdoc_internals)]
// tidy-alphabetical-end
diff --git a/compiler/rustc_target/src/spec/abi_map.rs b/compiler/rustc_target/src/spec/abi_map.rs
index d9101f7..c4978a8 100644
--- a/compiler/rustc_target/src/spec/abi_map.rs
+++ b/compiler/rustc_target/src/spec/abi_map.rs
@@ -29,6 +29,7 @@ pub fn into_option(self) -> Option<CanonAbi> {
}
}
+ #[track_caller]
pub fn unwrap(self) -> CanonAbi {
self.into_option().unwrap()
}
@@ -115,9 +116,6 @@ pub fn canonize_abi(&self, extern_abi: ExternAbi, has_c_varargs: bool) -> AbiMap
(ExternAbi::Vectorcall { .. }, Arch::X86 | Arch::X86_64) => {
CanonAbi::X86(X86Call::Vectorcall)
}
- (ExternAbi::Vectorcall { .. }, _) if os == OsKind::Windows => {
- return AbiMapping::Deprecated(CanonAbi::C);
- }
(ExternAbi::Vectorcall { .. }, _) => return AbiMapping::Invalid,
(ExternAbi::SysV64 { .. }, Arch::X86_64) => CanonAbi::X86(X86Call::SysV64),
diff --git a/compiler/rustc_target/src/spec/json.rs b/compiler/rustc_target/src/spec/json.rs
index 54b06d9..039056a 100644
--- a/compiler/rustc_target/src/spec/json.rs
+++ b/compiler/rustc_target/src/spec/json.rs
@@ -2,7 +2,7 @@
use std::collections::BTreeMap;
use std::str::FromStr;
-use rustc_abi::ExternAbi;
+use rustc_abi::{Align, AlignFromBytesError, ExternAbi};
use serde_json::Value;
use super::{Target, TargetKind, TargetOptions, TargetWarnings};
@@ -57,6 +57,14 @@ pub fn from_json(obj: Json) -> Result<(Target, TargetWarnings), String> {
base.metadata.std = metadata.remove("std").and_then(|host| host.as_bool());
}
+ let alignment_error = |field_name: &str, error: AlignFromBytesError| -> String {
+ let msg = match error {
+ AlignFromBytesError::NotPowerOfTwo(_) => "not a power of 2 number of bytes",
+ AlignFromBytesError::TooLarge(_) => "too large",
+ };
+ format!("`{}` bits is not a valid value for {field_name}: {msg}", error.align() * 8)
+ };
+
let mut incorrect_type = vec![];
macro_rules! key {
@@ -111,6 +119,15 @@ macro_rules! key {
base.$key_name = Some(s.into());
}
} );
+ ($key_name:ident, Option<Align>) => ( {
+ let name = (stringify!($key_name)).replace("_", "-");
+ if let Some(b) = obj.remove(&name).and_then(|b| b.as_u64()) {
+ match Align::from_bits(b) {
+ Ok(align) => base.$key_name = Some(align),
+ Err(e) => return Err(alignment_error(&name, e)),
+ }
+ }
+ } );
($key_name:ident, BinaryFormat) => ( {
let name = (stringify!($key_name)).replace("_", "-");
obj.remove(&name).and_then(|f| f.as_str().and_then(|s| {
@@ -617,7 +634,7 @@ macro_rules! key {
key!(crt_static_default, bool);
key!(crt_static_respected, bool);
key!(stack_probes, StackProbeType)?;
- key!(min_global_align, Option<u64>);
+ key!(min_global_align, Option<Align>);
key!(default_codegen_units, Option<u64>);
key!(default_codegen_backend, Option<StaticCow<str>>);
key!(trap_unreachable, bool);
diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs
index 6529c2d..6ceb5e8 100644
--- a/compiler/rustc_target/src/spec/mod.rs
+++ b/compiler/rustc_target/src/spec/mod.rs
@@ -62,7 +62,7 @@
mod base;
mod json;
-pub use abi_map::AbiMap;
+pub use abi_map::{AbiMap, AbiMapping};
pub use base::apple;
pub use base::avr::ef_avr_arch;
@@ -1697,6 +1697,12 @@ fn to_json(&self) -> Json {
}
}
+impl ToJson for Align {
+ fn to_json(&self) -> Json {
+ self.bits().to_json()
+ }
+}
+
macro_rules! supported_targets {
( $(($tuple:literal, $module:ident),)+ ) => {
mod targets {
@@ -1981,6 +1987,8 @@ fn $module() {
("sparc-unknown-none-elf", sparc_unknown_none_elf),
+ ("loongarch32-unknown-none", loongarch32_unknown_none),
+ ("loongarch32-unknown-none-softfloat", loongarch32_unknown_none_softfloat),
("loongarch64-unknown-none", loongarch64_unknown_none),
("loongarch64-unknown-none-softfloat", loongarch64_unknown_none_softfloat),
@@ -2513,7 +2521,7 @@ pub struct TargetOptions {
pub stack_probes: StackProbeType,
/// The minimum alignment for global symbols.
- pub min_global_align: Option<u64>,
+ pub min_global_align: Option<Align>,
/// Default number of codegen units to use in debug mode
pub default_codegen_units: Option<u64>,
@@ -3502,6 +3510,7 @@ pub fn object_architecture(
"msp430" => (Architecture::Msp430, None),
"hexagon" => (Architecture::Hexagon, None),
"bpf" => (Architecture::Bpf, None),
+ "loongarch32" => (Architecture::LoongArch32, None),
"loongarch64" => (Architecture::LoongArch64, None),
"csky" => (Architecture::Csky, None),
"arm64ec" => (Architecture::Aarch64, Some(object::SubArchitecture::Arm64EC)),
diff --git a/compiler/rustc_target/src/spec/targets/loongarch32_unknown_none.rs b/compiler/rustc_target/src/spec/targets/loongarch32_unknown_none.rs
new file mode 100644
index 0000000..fb4963b
--- /dev/null
+++ b/compiler/rustc_target/src/spec/targets/loongarch32_unknown_none.rs
@@ -0,0 +1,29 @@
+use crate::spec::{
+ Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions,
+};
+
+pub(crate) fn target() -> Target {
+ Target {
+ llvm_target: "loongarch32-unknown-none".into(),
+ metadata: TargetMetadata {
+ description: Some("Freestanding/bare-metal LoongArch32".into()),
+ tier: Some(3),
+ host_tools: Some(false),
+ std: Some(false),
+ },
+ pointer_width: 32,
+ data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(),
+ arch: "loongarch32".into(),
+ options: TargetOptions {
+ cpu: "generic".into(),
+ features: "+f,+d".into(),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
+ linker: Some("rust-lld".into()),
+ llvm_abiname: "ilp32d".into(),
+ max_atomic_width: Some(32),
+ relocation_model: RelocModel::Static,
+ panic_strategy: PanicStrategy::Abort,
+ ..Default::default()
+ },
+ }
+}
diff --git a/compiler/rustc_target/src/spec/targets/loongarch32_unknown_none_softfloat.rs b/compiler/rustc_target/src/spec/targets/loongarch32_unknown_none_softfloat.rs
new file mode 100644
index 0000000..0e65f83
--- /dev/null
+++ b/compiler/rustc_target/src/spec/targets/loongarch32_unknown_none_softfloat.rs
@@ -0,0 +1,30 @@
+use crate::spec::{
+ Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetMetadata, TargetOptions,
+};
+
+pub(crate) fn target() -> Target {
+ Target {
+ llvm_target: "loongarch32-unknown-none".into(),
+ metadata: TargetMetadata {
+ description: Some("Freestanding/bare-metal LoongArch32 softfloat".into()),
+ tier: Some(3),
+ host_tools: Some(false),
+ std: Some(false),
+ },
+ pointer_width: 32,
+ data_layout: "e-m:e-p:32:32-i64:64-n32-S128".into(),
+ arch: "loongarch32".into(),
+ options: TargetOptions {
+ cpu: "generic".into(),
+ features: "-f,-d".into(),
+ abi: "softfloat".into(),
+ linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
+ linker: Some("rust-lld".into()),
+ llvm_abiname: "ilp32s".into(),
+ max_atomic_width: Some(32),
+ relocation_model: RelocModel::Static,
+ panic_strategy: PanicStrategy::Abort,
+ ..Default::default()
+ },
+ }
+}
diff --git a/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs
index e0d16a7..cdcf7d6 100644
--- a/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs
+++ b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs
@@ -1,4 +1,4 @@
-use rustc_abi::Endian;
+use rustc_abi::{Align, Endian};
use crate::spec::{SanitizerSet, StackProbeType, Target, TargetMetadata, base};
@@ -8,7 +8,7 @@ pub(crate) fn target() -> Target {
// z10 is the oldest CPU supported by LLVM
base.cpu = "z10".into();
base.max_atomic_width = Some(128);
- base.min_global_align = Some(16);
+ base.min_global_align = Some(Align::from_bits(16).unwrap());
base.stack_probes = StackProbeType::Inline;
base.supported_sanitizers =
SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::MEMORY | SanitizerSet::THREAD;
diff --git a/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs
index 47050c1..e9522ac 100644
--- a/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs
+++ b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs
@@ -1,4 +1,4 @@
-use rustc_abi::Endian;
+use rustc_abi::{Align, Endian};
use crate::spec::{SanitizerSet, StackProbeType, Target, TargetMetadata, base};
@@ -8,7 +8,7 @@ pub(crate) fn target() -> Target {
// z10 is the oldest CPU supported by LLVM
base.cpu = "z10".into();
base.max_atomic_width = Some(128);
- base.min_global_align = Some(16);
+ base.min_global_align = Some(Align::from_bits(16).unwrap());
base.static_position_independent_executables = true;
base.stack_probes = StackProbeType::Inline;
base.supported_sanitizers =
diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs
index 682c4c5..5d1182f 100644
--- a/compiler/rustc_target/src/target_features.rs
+++ b/compiler/rustc_target/src/target_features.rs
@@ -443,7 +443,7 @@ pub fn toggle_allowed(&self) -> Result<(), &'static str> {
("fma", Stable, &["avx"]),
("fxsr", Stable, &[]),
("gfni", Stable, &["sse2"]),
- ("kl", Unstable(sym::keylocker_x86), &["sse2"]),
+ ("kl", Stable, &["sse2"]),
("lahfsahf", Unstable(sym::lahfsahf_target_feature), &[]),
("lzcnt", Stable, &[]),
("movbe", Stable, &[]),
@@ -455,9 +455,9 @@ pub fn toggle_allowed(&self) -> Result<(), &'static str> {
("rdseed", Stable, &[]),
("rtm", Unstable(sym::rtm_target_feature), &[]),
("sha", Stable, &["sse2"]),
- ("sha512", Unstable(sym::sha512_sm_x86), &["avx2"]),
- ("sm3", Unstable(sym::sha512_sm_x86), &["avx"]),
- ("sm4", Unstable(sym::sha512_sm_x86), &["avx2"]),
+ ("sha512", Stable, &["avx2"]),
+ ("sm3", Stable, &["avx"]),
+ ("sm4", Stable, &["avx2"]),
// This cannot actually be toggled, the ABI always fixes it, so it'd make little sense to
// stabilize. It must be in this list for the ABI check to be able to use it.
("soft-float", Stability::Unstable(sym::x87_target_feature), &[]),
@@ -471,7 +471,7 @@ pub fn toggle_allowed(&self) -> Result<(), &'static str> {
("tbm", Unstable(sym::tbm_target_feature), &[]),
("vaes", Stable, &["avx2", "aes"]),
("vpclmulqdq", Stable, &["avx", "pclmulqdq"]),
- ("widekl", Unstable(sym::keylocker_x86), &["kl"]),
+ ("widekl", Stable, &["kl"]),
("x87", Unstable(sym::x87_target_feature), &[]),
("xop", Unstable(sym::xop_target_feature), &[/*"fma4", */ "avx", "sse4a"]),
("xsave", Stable, &[]),
@@ -846,7 +846,7 @@ pub fn rust_target_features(&self) -> &'static [(&'static str, Stability, Implie
"wasm32" | "wasm64" => WASM_FEATURES,
"bpf" => BPF_FEATURES,
"csky" => CSKY_FEATURES,
- "loongarch64" => LOONGARCH_FEATURES,
+ "loongarch32" | "loongarch64" => LOONGARCH_FEATURES,
"s390x" => IBMZ_FEATURES,
"sparc" | "sparc64" => SPARC_FEATURES,
"m68k" => M68K_FEATURES,
@@ -860,7 +860,7 @@ pub fn features_for_correct_vector_abi(&self) -> &'static [(u64, &'static str)]
"aarch64" | "arm64ec" => AARCH64_FEATURES_FOR_CORRECT_VECTOR_ABI,
"arm" => ARM_FEATURES_FOR_CORRECT_VECTOR_ABI,
"powerpc" | "powerpc64" => POWERPC_FEATURES_FOR_CORRECT_VECTOR_ABI,
- "loongarch64" => LOONGARCH_FEATURES_FOR_CORRECT_VECTOR_ABI,
+ "loongarch32" | "loongarch64" => LOONGARCH_FEATURES_FOR_CORRECT_VECTOR_ABI,
"riscv32" | "riscv64" => RISCV_FEATURES_FOR_CORRECT_VECTOR_ABI,
"wasm32" | "wasm64" => WASM_FEATURES_FOR_CORRECT_VECTOR_ABI,
"s390x" => S390X_FEATURES_FOR_CORRECT_VECTOR_ABI,
@@ -1034,7 +1034,7 @@ pub fn abi_required_features(&self) -> FeatureConstraints {
_ => unreachable!(),
}
}
- "loongarch64" => {
+ "loongarch32" | "loongarch64" => {
// LoongArch handles ABI in a very sane way, being fully explicit via `llvm_abiname`
// about what the intended ABI is.
match &*self.llvm_abiname {
diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
index fc5be11..0c88bd3 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
@@ -2558,32 +2558,31 @@ fn get_safe_transmute_error_and_reason(
rustc_transmute::Reason::SrcIsNotYetSupported => {
format!("analyzing the transmutability of `{src}` is not yet supported")
}
-
rustc_transmute::Reason::DstIsNotYetSupported => {
format!("analyzing the transmutability of `{dst}` is not yet supported")
}
-
rustc_transmute::Reason::DstIsBitIncompatible => {
format!(
"at least one value of `{src}` isn't a bit-valid value of `{dst}`"
)
}
-
rustc_transmute::Reason::DstUninhabited => {
format!("`{dst}` is uninhabited")
}
-
rustc_transmute::Reason::DstMayHaveSafetyInvariants => {
format!("`{dst}` may carry safety invariants")
}
rustc_transmute::Reason::DstIsTooBig => {
format!("the size of `{src}` is smaller than the size of `{dst}`")
}
- rustc_transmute::Reason::DstRefIsTooBig { src, dst } => {
- let src_size = src.size;
- let dst_size = dst.size;
+ rustc_transmute::Reason::DstRefIsTooBig {
+ src,
+ src_size,
+ dst,
+ dst_size,
+ } => {
format!(
- "the referent size of `{src}` ({src_size} bytes) \
+ "the size of `{src}` ({src_size} bytes) \
is smaller than that of `{dst}` ({dst_size} bytes)"
)
}
diff --git a/compiler/rustc_trait_selection/src/errors.rs b/compiler/rustc_trait_selection/src/errors.rs
index 06f81ac..7bf4905 100644
--- a/compiler/rustc_trait_selection/src/errors.rs
+++ b/compiler/rustc_trait_selection/src/errors.rs
@@ -759,7 +759,8 @@ pub enum ExplicitLifetimeRequired<'a> {
#[suggestion(
trait_selection_explicit_lifetime_required_sugg_with_ident,
code = "{new_ty}",
- applicability = "unspecified"
+ applicability = "unspecified",
+ style = "verbose"
)]
new_ty_span: Span,
#[skip_arg]
@@ -774,7 +775,8 @@ pub enum ExplicitLifetimeRequired<'a> {
#[suggestion(
trait_selection_explicit_lifetime_required_sugg_with_param_type,
code = "{new_ty}",
- applicability = "unspecified"
+ applicability = "unspecified",
+ style = "verbose"
)]
new_ty_span: Span,
#[skip_arg]
@@ -1462,7 +1464,8 @@ pub enum SuggestAccessingField<'a> {
#[suggestion(
trait_selection_suggest_accessing_field,
code = "{snippet}.{name}",
- applicability = "maybe-incorrect"
+ applicability = "maybe-incorrect",
+ style = "verbose"
)]
Safe {
#[primary_span]
@@ -1474,7 +1477,8 @@ pub enum SuggestAccessingField<'a> {
#[suggestion(
trait_selection_suggest_accessing_field,
code = "unsafe {{ {snippet}.{name} }}",
- applicability = "maybe-incorrect"
+ applicability = "maybe-incorrect",
+ style = "verbose"
)]
Unsafe {
#[primary_span]
diff --git a/compiler/rustc_trait_selection/src/lib.rs b/compiler/rustc_trait_selection/src/lib.rs
index 67328de..e2b22f7 100644
--- a/compiler/rustc_trait_selection/src/lib.rs
+++ b/compiler/rustc_trait_selection/src/lib.rs
@@ -19,14 +19,12 @@
#![feature(assert_matches)]
#![feature(associated_type_defaults)]
#![feature(box_patterns)]
-#![feature(cfg_version)]
#![feature(if_let_guard)]
#![feature(iter_intersperse)]
#![feature(iterator_try_reduce)]
#![feature(never_type)]
#![feature(rustdoc_internals)]
#![feature(try_blocks)]
-#![feature(type_alias_impl_trait)]
#![feature(unwrap_infallible)]
#![feature(yeet_expr)]
#![recursion_limit = "512"] // For rustdoc
diff --git a/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs b/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs
index 1c9d69d..36a8ae6 100644
--- a/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs
+++ b/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs
@@ -120,13 +120,15 @@ pub(super) fn fulfillment_error_for_stalled<'tcx>(
false,
),
Ok(GoalEvaluation { certainty: Certainty::Yes, .. }) => {
- bug!(
+ span_bug!(
+ root_obligation.cause.span,
"did not expect successful goal when collecting ambiguity errors for `{:?}`",
infcx.resolve_vars_if_possible(root_obligation.predicate),
)
}
Err(_) => {
- bug!(
+ span_bug!(
+ root_obligation.cause.span,
"did not expect selection error when collecting ambiguity errors for `{:?}`",
infcx.resolve_vars_if_possible(root_obligation.predicate),
)
diff --git a/compiler/rustc_trait_selection/src/traits/normalize.rs b/compiler/rustc_trait_selection/src/traits/normalize.rs
index eb6d5c8..35a43b2 100644
--- a/compiler/rustc_trait_selection/src/traits/normalize.rs
+++ b/compiler/rustc_trait_selection/src/traits/normalize.rs
@@ -47,7 +47,7 @@ fn normalize<T: TypeFoldable<TyCtxt<'tcx>>>(&self, value: T) -> InferOk<'tcx, T>
/// same goals in both a temporary and the shared context which negatively impacts
/// performance as these don't share caching.
///
- /// FIXME(-Znext-solver): For performance reasons, we currently reuse an existing
+ /// FIXME(-Znext-solver=no): For performance reasons, we currently reuse an existing
/// fulfillment context in the old solver. Once we have removed the old solver, we
/// can remove the `fulfill_cx` parameter on this function.
fn deeply_normalize<T, E>(
diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs
index 7acf0f9..786afd7 100644
--- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs
@@ -9,13 +9,12 @@
use std::ops::ControlFlow;
-use rustc_ast::Mutability;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_hir::lang_items::LangItem;
use rustc_infer::infer::{DefineOpaqueTypes, HigherRankedType, InferOk};
use rustc_infer::traits::ObligationCauseCode;
use rustc_middle::traits::{BuiltinImplSource, SignatureMismatchData};
-use rustc_middle::ty::{self, GenericArgsRef, Ty, TyCtxt, Upcast, elaborate};
+use rustc_middle::ty::{self, GenericArgsRef, Region, Ty, TyCtxt, Upcast, elaborate};
use rustc_middle::{bug, span_bug};
use rustc_span::def_id::DefId;
use thin_vec::thin_vec;
@@ -286,99 +285,12 @@ fn confirm_transmutability_candidate(
) -> Result<PredicateObligations<'tcx>, SelectionError<'tcx>> {
use rustc_transmute::{Answer, Assume, Condition};
- /// Generate sub-obligations for reference-to-reference transmutations.
- fn reference_obligations<'tcx>(
- tcx: TyCtxt<'tcx>,
- obligation: &PolyTraitObligation<'tcx>,
- (src_lifetime, src_ty, src_mut): (ty::Region<'tcx>, Ty<'tcx>, Mutability),
- (dst_lifetime, dst_ty, dst_mut): (ty::Region<'tcx>, Ty<'tcx>, Mutability),
- assume: Assume,
- ) -> PredicateObligations<'tcx> {
- let make_transmute_obl = |src, dst| {
- let transmute_trait = obligation.predicate.def_id();
- let assume = obligation.predicate.skip_binder().trait_ref.args.const_at(2);
- let trait_ref = ty::TraitRef::new(
- tcx,
- transmute_trait,
- [
- ty::GenericArg::from(dst),
- ty::GenericArg::from(src),
- ty::GenericArg::from(assume),
- ],
- );
- Obligation::with_depth(
- tcx,
- obligation.cause.clone(),
- obligation.recursion_depth + 1,
- obligation.param_env,
- trait_ref,
- )
- };
-
- let make_freeze_obl = |ty| {
- let trait_ref = ty::TraitRef::new(
- tcx,
- tcx.require_lang_item(LangItem::Freeze, obligation.cause.span),
- [ty::GenericArg::from(ty)],
- );
- Obligation::with_depth(
- tcx,
- obligation.cause.clone(),
- obligation.recursion_depth + 1,
- obligation.param_env,
- trait_ref,
- )
- };
-
- let make_outlives_obl = |target, region| {
- let outlives = ty::OutlivesPredicate(target, region);
- Obligation::with_depth(
- tcx,
- obligation.cause.clone(),
- obligation.recursion_depth + 1,
- obligation.param_env,
- outlives,
- )
- };
-
- // Given a transmutation from `&'a (mut) Src` and `&'dst (mut) Dst`,
- // it is always the case that `Src` must be transmutable into `Dst`,
- // and that that `'src` must outlive `'dst`.
- let mut obls = PredicateObligations::with_capacity(1);
- obls.push(make_transmute_obl(src_ty, dst_ty));
- if !assume.lifetimes {
- obls.push(make_outlives_obl(src_lifetime, dst_lifetime));
- }
-
- // Given a transmutation from `&Src`, both `Src` and `Dst` must be
- // `Freeze`, otherwise, using the transmuted value could lead to
- // data races.
- if src_mut == Mutability::Not {
- obls.extend([make_freeze_obl(src_ty), make_freeze_obl(dst_ty)])
- }
-
- // Given a transmutation into `&'dst mut Dst`, it also must be the
- // case that `Dst` is transmutable into `Src`. For example,
- // transmuting bool -> u8 is OK as long as you can't update that u8
- // to be > 1, because you could later transmute the u8 back to a
- // bool and get undefined behavior. It also must be the case that
- // `'dst` lives exactly as long as `'src`.
- if dst_mut == Mutability::Mut {
- obls.push(make_transmute_obl(dst_ty, src_ty));
- if !assume.lifetimes {
- obls.push(make_outlives_obl(dst_lifetime, src_lifetime));
- }
- }
-
- obls
- }
-
/// Flatten the `Condition` tree into a conjunction of obligations.
#[instrument(level = "debug", skip(tcx, obligation))]
fn flatten_answer_tree<'tcx>(
tcx: TyCtxt<'tcx>,
obligation: &PolyTraitObligation<'tcx>,
- cond: Condition<rustc_transmute::layout::rustc::Ref<'tcx>>,
+ cond: Condition<Region<'tcx>, Ty<'tcx>>,
assume: Assume,
) -> PredicateObligations<'tcx> {
match cond {
@@ -388,13 +300,50 @@ fn flatten_answer_tree<'tcx>(
.into_iter()
.flat_map(|cond| flatten_answer_tree(tcx, obligation, cond, assume))
.collect(),
- Condition::IfTransmutable { src, dst } => reference_obligations(
- tcx,
- obligation,
- (src.lifetime, src.ty, src.mutability),
- (dst.lifetime, dst.ty, dst.mutability),
- assume,
- ),
+ Condition::Immutable { ty } => {
+ let trait_ref = ty::TraitRef::new(
+ tcx,
+ tcx.require_lang_item(LangItem::Freeze, obligation.cause.span),
+ [ty::GenericArg::from(ty)],
+ );
+ thin_vec![Obligation::with_depth(
+ tcx,
+ obligation.cause.clone(),
+ obligation.recursion_depth + 1,
+ obligation.param_env,
+ trait_ref,
+ )]
+ }
+ Condition::Outlives { long, short } => {
+ let outlives = ty::OutlivesPredicate(long, short);
+ thin_vec![Obligation::with_depth(
+ tcx,
+ obligation.cause.clone(),
+ obligation.recursion_depth + 1,
+ obligation.param_env,
+ outlives,
+ )]
+ }
+ Condition::Transmutable { src, dst } => {
+ let transmute_trait = obligation.predicate.def_id();
+ let assume = obligation.predicate.skip_binder().trait_ref.args.const_at(2);
+ let trait_ref = ty::TraitRef::new(
+ tcx,
+ transmute_trait,
+ [
+ ty::GenericArg::from(dst),
+ ty::GenericArg::from(src),
+ ty::GenericArg::from(assume),
+ ],
+ );
+ thin_vec![Obligation::with_depth(
+ tcx,
+ obligation.cause.clone(),
+ obligation.recursion_depth + 1,
+ obligation.param_env,
+ trait_ref,
+ )]
+ }
}
}
diff --git a/compiler/rustc_traits/src/codegen.rs b/compiler/rustc_traits/src/codegen.rs
index 88f02d1..a0a1d45 100644
--- a/compiler/rustc_traits/src/codegen.rs
+++ b/compiler/rustc_traits/src/codegen.rs
@@ -58,7 +58,6 @@ pub(crate) fn codegen_select_candidate<'tcx>(
// Currently, we use a fulfillment context to completely resolve
// all nested obligations. This is because they can inform the
// inference of the impl's type parameters.
- // FIXME(-Znext-solver): Doesn't need diagnostics if new solver.
let ocx = ObligationCtxt::new(&infcx);
let impl_source = selection.map(|obligation| {
ocx.register_obligation(obligation);
diff --git a/compiler/rustc_transmute/src/layout/dfa.rs b/compiler/rustc_transmute/src/layout/dfa.rs
index 6d072c3..6fc40ce 100644
--- a/compiler/rustc_transmute/src/layout/dfa.rs
+++ b/compiler/rustc_transmute/src/layout/dfa.rs
@@ -2,32 +2,35 @@
use std::iter::Peekable;
use std::sync::atomic::{AtomicU32, Ordering};
-use super::{Byte, Ref, Tree, Uninhabited};
+use super::{Byte, Reference, Region, Tree, Type, Uninhabited};
use crate::{Map, Set};
#[derive(PartialEq)]
#[cfg_attr(test, derive(Clone))]
-pub(crate) struct Dfa<R>
+pub(crate) struct Dfa<R, T>
where
- R: Ref,
+ R: Region,
+ T: Type,
{
- pub(crate) transitions: Map<State, Transitions<R>>,
+ pub(crate) transitions: Map<State, Transitions<R, T>>,
pub(crate) start: State,
pub(crate) accept: State,
}
#[derive(PartialEq, Clone, Debug)]
-pub(crate) struct Transitions<R>
+pub(crate) struct Transitions<R, T>
where
- R: Ref,
+ R: Region,
+ T: Type,
{
byte_transitions: EdgeSet<State>,
- ref_transitions: Map<R, State>,
+ ref_transitions: Map<Reference<R, T>, State>,
}
-impl<R> Default for Transitions<R>
+impl<R, T> Default for Transitions<R, T>
where
- R: Ref,
+ R: Region,
+ T: Type,
{
fn default() -> Self {
Self { byte_transitions: EdgeSet::empty(), ref_transitions: Map::default() }
@@ -51,9 +54,10 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
-impl<R> Dfa<R>
+impl<R, T> Dfa<R, T>
where
- R: Ref,
+ R: Region,
+ T: Type,
{
#[cfg(test)]
pub(crate) fn bool() -> Self {
@@ -64,7 +68,7 @@ pub(crate) fn bool() -> Self {
}
pub(crate) fn unit() -> Self {
- let transitions: Map<State, Transitions<R>> = Map::default();
+ let transitions: Map<State, Transitions<R, T>> = Map::default();
let start = State::new();
let accept = start;
@@ -78,21 +82,21 @@ pub(crate) fn from_byte(byte: Byte) -> Self {
})
}
- pub(crate) fn from_ref(r: R) -> Self {
+ pub(crate) fn from_ref(r: Reference<R, T>) -> Self {
Self::from_transitions(|accept| Transitions {
byte_transitions: EdgeSet::empty(),
ref_transitions: [(r, accept)].into_iter().collect(),
})
}
- fn from_transitions(f: impl FnOnce(State) -> Transitions<R>) -> Self {
+ fn from_transitions(f: impl FnOnce(State) -> Transitions<R, T>) -> Self {
let start = State::new();
let accept = State::new();
Self { transitions: [(start, f(accept))].into_iter().collect(), start, accept }
}
- pub(crate) fn from_tree(tree: Tree<!, R>) -> Result<Self, Uninhabited> {
+ pub(crate) fn from_tree(tree: Tree<!, R, T>) -> Result<Self, Uninhabited> {
Ok(match tree {
Tree::Byte(b) => Self::from_byte(b),
Tree::Ref(r) => Self::from_ref(r),
@@ -125,7 +129,7 @@ pub(crate) fn concat(self, other: Self) -> Self {
let start = self.start;
let accept = other.accept;
- let mut transitions: Map<State, Transitions<R>> = self.transitions;
+ let mut transitions: Map<State, Transitions<R, T>> = self.transitions;
for (source, transition) in other.transitions {
let fix_state = |state| if state == other.start { self.accept } else { state };
@@ -169,7 +173,7 @@ pub(crate) fn union(self, other: Self, mut new_state: impl FnMut() -> State) ->
};
let start = mapped((Some(a.start), Some(b.start)));
- let mut transitions: Map<State, Transitions<R>> = Map::default();
+ let mut transitions: Map<State, Transitions<R, T>> = Map::default();
let empty_transitions = Transitions::default();
struct WorkQueue {
@@ -257,7 +261,7 @@ pub(crate) fn bytes_from(&self, start: State) -> impl Iterator<Item = (Byte, Sta
.flat_map(|transitions| transitions.byte_transitions.iter())
}
- pub(crate) fn refs_from(&self, start: State) -> impl Iterator<Item = (R, State)> {
+ pub(crate) fn refs_from(&self, start: State) -> impl Iterator<Item = (Reference<R, T>, State)> {
self.transitions
.get(&start)
.into_iter()
@@ -297,9 +301,10 @@ pub(crate) fn from_edges<B: Clone + Into<Byte>>(
}
/// Serialize the DFA using the Graphviz DOT format.
-impl<R> fmt::Debug for Dfa<R>
+impl<R, T> fmt::Debug for Dfa<R, T>
where
- R: Ref,
+ R: Region,
+ T: Type,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "digraph {{")?;
diff --git a/compiler/rustc_transmute/src/layout/mod.rs b/compiler/rustc_transmute/src/layout/mod.rs
index c08bf44..acbce25 100644
--- a/compiler/rustc_transmute/src/layout/mod.rs
+++ b/compiler/rustc_transmute/src/layout/mod.rs
@@ -78,16 +78,41 @@ fn from(src: u8) -> Self {
}
}
+/// A reference, i.e., `&'region T` or `&'region mut T`.
+#[derive(Debug, Hash, Eq, PartialEq, Ord, PartialOrd, Clone, Copy)]
+pub(crate) struct Reference<R, T>
+where
+ R: Region,
+ T: Type,
+{
+ pub(crate) region: R,
+ pub(crate) is_mut: bool,
+ pub(crate) referent: T,
+ pub(crate) referent_size: usize,
+ pub(crate) referent_align: usize,
+}
+
+impl<R, T> fmt::Display for Reference<R, T>
+where
+ R: Region,
+ T: Type,
+{
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ f.write_str("&")?;
+ if self.is_mut {
+ f.write_str("mut ")?;
+ }
+ self.referent.fmt(f)
+ }
+}
+
pub(crate) trait Def: Debug + Hash + Eq + PartialEq + Copy + Clone {
fn has_safety_invariants(&self) -> bool;
}
-pub trait Ref: Debug + Hash + Eq + PartialEq + Copy + Clone {
- fn min_align(&self) -> usize;
- fn size(&self) -> usize;
+pub(crate) trait Region: Debug + Hash + Eq + PartialEq + Copy + Clone {}
- fn is_mutable(&self) -> bool;
-}
+pub(crate) trait Type: Debug + Hash + Eq + PartialEq + Copy + Clone {}
impl Def for ! {
fn has_safety_invariants(&self) -> bool {
@@ -95,79 +120,21 @@ fn has_safety_invariants(&self) -> bool {
}
}
-impl Ref for ! {
- fn min_align(&self) -> usize {
- unreachable!()
- }
- fn size(&self) -> usize {
- unreachable!()
- }
- fn is_mutable(&self) -> bool {
- unreachable!()
- }
-}
+impl Region for ! {}
+
+impl Type for ! {}
#[cfg(test)]
-impl<const N: usize> Ref for [(); N] {
- fn min_align(&self) -> usize {
- N
- }
+impl Region for usize {}
- fn size(&self) -> usize {
- N
- }
-
- fn is_mutable(&self) -> bool {
- false
- }
-}
+#[cfg(test)]
+impl Type for () {}
#[cfg(feature = "rustc")]
pub mod rustc {
- use std::fmt::{self, Write};
-
use rustc_abi::Layout;
- use rustc_middle::mir::Mutability;
use rustc_middle::ty::layout::{HasTyCtxt, LayoutCx, LayoutError};
- use rustc_middle::ty::{self, Ty};
-
- /// A reference in the layout.
- #[derive(Debug, Hash, Eq, PartialEq, Clone, Copy)]
- pub struct Ref<'tcx> {
- pub lifetime: ty::Region<'tcx>,
- pub ty: Ty<'tcx>,
- pub mutability: Mutability,
- pub align: usize,
- pub size: usize,
- }
-
- impl<'tcx> super::Ref for Ref<'tcx> {
- fn min_align(&self) -> usize {
- self.align
- }
-
- fn size(&self) -> usize {
- self.size
- }
-
- fn is_mutable(&self) -> bool {
- match self.mutability {
- Mutability::Mut => true,
- Mutability::Not => false,
- }
- }
- }
- impl<'tcx> Ref<'tcx> {}
-
- impl<'tcx> fmt::Display for Ref<'tcx> {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- f.write_char('&')?;
- if self.mutability == Mutability::Mut {
- f.write_str("mut ")?;
- }
- self.ty.fmt(f)
- }
- }
+ use rustc_middle::ty::{self, Region, Ty};
/// A visibility node in the layout.
#[derive(Debug, Hash, Eq, PartialEq, Clone, Copy)]
@@ -187,6 +154,10 @@ fn has_safety_invariants(&self) -> bool {
}
}
+ impl<'tcx> super::Region for Region<'tcx> {}
+
+ impl<'tcx> super::Type for Ty<'tcx> {}
+
pub(crate) fn layout_of<'tcx>(
cx: LayoutCx<'tcx>,
ty: Ty<'tcx>,
diff --git a/compiler/rustc_transmute/src/layout/tree.rs b/compiler/rustc_transmute/src/layout/tree.rs
index ff66569..372b4f5 100644
--- a/compiler/rustc_transmute/src/layout/tree.rs
+++ b/compiler/rustc_transmute/src/layout/tree.rs
@@ -1,6 +1,6 @@
use std::ops::{ControlFlow, RangeInclusive};
-use super::{Byte, Def, Ref};
+use super::{Byte, Def, Reference, Region, Type};
#[cfg(test)]
mod tests;
@@ -15,10 +15,11 @@
/// 2. A `Seq` is never directly nested beneath another `Seq`.
/// 3. `Seq`s and `Alt`s with a single member do not exist.
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
-pub(crate) enum Tree<D, R>
+pub(crate) enum Tree<D, R, T>
where
D: Def,
- R: Ref,
+ R: Region,
+ T: Type,
{
/// A sequence of successive layouts.
Seq(Vec<Self>),
@@ -27,7 +28,7 @@ pub(crate) enum Tree<D, R>
/// A definition node.
Def(D),
/// A reference node.
- Ref(R),
+ Ref(Reference<R, T>),
/// A byte node.
Byte(Byte),
}
@@ -48,10 +49,11 @@ fn from(order: rustc_abi::Endian) -> Endian {
}
}
-impl<D, R> Tree<D, R>
+impl<D, R, T> Tree<D, R, T>
where
D: Def,
- R: Ref,
+ R: Region,
+ T: Type,
{
/// A `Tree` consisting only of a definition node.
pub(crate) fn def(def: D) -> Self {
@@ -138,7 +140,7 @@ pub(crate) fn padding(width_in_bytes: usize) -> Self {
/// Remove all `Def` nodes, and all branches of the layout for which `f`
/// produces `true`.
- pub(crate) fn prune<F>(self, f: &F) -> Tree<!, R>
+ pub(crate) fn prune<F>(self, f: &F) -> Tree<!, R, T>
where
F: Fn(D) -> bool,
{
@@ -198,13 +200,13 @@ pub(crate) fn from_big_endian<const N: usize, B: Into<Byte>>(
/// Produces a `Tree` where each of the trees in `trees` are sequenced one
/// after another.
- pub(crate) fn seq<const N: usize>(trees: [Tree<D, R>; N]) -> Self {
+ pub(crate) fn seq<const N: usize>(trees: [Tree<D, R, T>; N]) -> Self {
trees.into_iter().fold(Tree::unit(), Self::then)
}
/// Produces a `Tree` where each of the trees in `trees` are accepted as
/// alternative layouts.
- pub(crate) fn alt<const N: usize>(trees: [Tree<D, R>; N]) -> Self {
+ pub(crate) fn alt<const N: usize>(trees: [Tree<D, R, T>; N]) -> Self {
trees.into_iter().fold(Tree::uninhabited(), Self::or)
}
@@ -251,11 +253,14 @@ pub(crate) mod rustc {
FieldIdx, FieldsShape, Layout, Size, TagEncoding, TyAndLayout, VariantIdx, Variants,
};
use rustc_middle::ty::layout::{HasTyCtxt, LayoutCx, LayoutError};
- use rustc_middle::ty::{self, AdtDef, AdtKind, List, ScalarInt, Ty, TyCtxt, TypeVisitableExt};
+ use rustc_middle::ty::{
+ self, AdtDef, AdtKind, List, Region, ScalarInt, Ty, TyCtxt, TypeVisitableExt,
+ };
use rustc_span::ErrorGuaranteed;
use super::Tree;
- use crate::layout::rustc::{Def, Ref, layout_of};
+ use crate::layout::Reference;
+ use crate::layout::rustc::{Def, layout_of};
#[derive(Debug, Copy, Clone)]
pub(crate) enum Err {
@@ -281,7 +286,7 @@ fn from(err: &LayoutError<'tcx>) -> Self {
}
}
- impl<'tcx> Tree<Def<'tcx>, Ref<'tcx>> {
+ impl<'tcx> Tree<Def<'tcx>, Region<'tcx>, Ty<'tcx>> {
pub(crate) fn from_ty(ty: Ty<'tcx>, cx: LayoutCx<'tcx>) -> Result<Self, Err> {
use rustc_abi::HasDataLayout;
let layout = layout_of(cx, ty)?;
@@ -353,16 +358,17 @@ pub(crate) fn from_ty(ty: Ty<'tcx>, cx: LayoutCx<'tcx>) -> Result<Self, Err> {
}
}
- ty::Ref(lifetime, ty, mutability) => {
+ ty::Ref(region, ty, mutability) => {
let layout = layout_of(cx, *ty)?;
- let align = layout.align.abi.bytes_usize();
- let size = layout.size.bytes_usize();
- Ok(Tree::Ref(Ref {
- lifetime: *lifetime,
- ty: *ty,
- mutability: *mutability,
- align,
- size,
+ let referent_align = layout.align.abi.bytes_usize();
+ let referent_size = layout.size.bytes_usize();
+
+ Ok(Tree::Ref(Reference {
+ region: *region,
+ is_mut: mutability.is_mut(),
+ referent: *ty,
+ referent_align,
+ referent_size,
}))
}
diff --git a/compiler/rustc_transmute/src/layout/tree/tests.rs b/compiler/rustc_transmute/src/layout/tree/tests.rs
index 8c3dbbe..bc47b19 100644
--- a/compiler/rustc_transmute/src/layout/tree/tests.rs
+++ b/compiler/rustc_transmute/src/layout/tree/tests.rs
@@ -20,13 +20,13 @@ mod should_simplify {
#[test]
fn seq_1() {
- let layout: Tree<Def, !> = Tree::def(Def::NoSafetyInvariants).then(Tree::byte(0x00));
+ let layout: Tree<Def, !, !> = Tree::def(Def::NoSafetyInvariants).then(Tree::byte(0x00));
assert_eq!(layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)), Tree::byte(0x00));
}
#[test]
fn seq_2() {
- let layout: Tree<Def, !> =
+ let layout: Tree<Def, !, !> =
Tree::byte(0x00).then(Tree::def(Def::NoSafetyInvariants)).then(Tree::byte(0x01));
assert_eq!(
@@ -41,7 +41,7 @@ mod should_reject {
#[test]
fn invisible_def() {
- let layout: Tree<Def, !> = Tree::def(Def::HasSafetyInvariants);
+ let layout: Tree<Def, !, !> = Tree::def(Def::HasSafetyInvariants);
assert_eq!(
layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)),
Tree::uninhabited()
@@ -50,7 +50,7 @@ fn invisible_def() {
#[test]
fn invisible_def_in_seq_len_2() {
- let layout: Tree<Def, !> =
+ let layout: Tree<Def, !, !> =
Tree::def(Def::NoSafetyInvariants).then(Tree::def(Def::HasSafetyInvariants));
assert_eq!(
layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)),
@@ -60,7 +60,7 @@ fn invisible_def_in_seq_len_2() {
#[test]
fn invisible_def_in_seq_len_3() {
- let layout: Tree<Def, !> = Tree::def(Def::NoSafetyInvariants)
+ let layout: Tree<Def, !, !> = Tree::def(Def::NoSafetyInvariants)
.then(Tree::byte(0x00))
.then(Tree::def(Def::HasSafetyInvariants));
assert_eq!(
@@ -75,20 +75,20 @@ mod should_accept {
#[test]
fn visible_def() {
- let layout: Tree<Def, !> = Tree::def(Def::NoSafetyInvariants);
+ let layout: Tree<Def, !, !> = Tree::def(Def::NoSafetyInvariants);
assert_eq!(layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)), Tree::unit());
}
#[test]
fn visible_def_in_seq_len_2() {
- let layout: Tree<Def, !> =
+ let layout: Tree<Def, !, !> =
Tree::def(Def::NoSafetyInvariants).then(Tree::def(Def::NoSafetyInvariants));
assert_eq!(layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)), Tree::unit());
}
#[test]
fn visible_def_in_seq_len_3() {
- let layout: Tree<Def, !> = Tree::def(Def::NoSafetyInvariants)
+ let layout: Tree<Def, !, !> = Tree::def(Def::NoSafetyInvariants)
.then(Tree::byte(0x00))
.then(Tree::def(Def::NoSafetyInvariants));
assert_eq!(layout.prune(&|d| matches!(d, Def::HasSafetyInvariants)), Tree::byte(0x00));
diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs
index ce18dad..36281ff 100644
--- a/compiler/rustc_transmute/src/lib.rs
+++ b/compiler/rustc_transmute/src/lib.rs
@@ -19,23 +19,29 @@ pub struct Assume {
/// Either transmutation is allowed, we have an error, or we have an optional
/// Condition that must hold.
#[derive(Debug, Hash, Eq, PartialEq, Clone)]
-pub enum Answer<R> {
+pub enum Answer<R, T> {
Yes,
- No(Reason<R>),
- If(Condition<R>),
+ No(Reason<T>),
+ If(Condition<R, T>),
}
/// A condition which must hold for safe transmutation to be possible.
#[derive(Debug, Hash, Eq, PartialEq, Clone)]
-pub enum Condition<R> {
+pub enum Condition<R, T> {
/// `Src` is transmutable into `Dst`, if `src` is transmutable into `dst`.
- IfTransmutable { src: R, dst: R },
+ Transmutable { src: T, dst: T },
+
+ /// The region `long` must outlive `short`.
+ Outlives { long: R, short: R },
+
+ /// The `ty` is immutable.
+ Immutable { ty: T },
/// `Src` is transmutable into `Dst`, if all of the enclosed requirements are met.
- IfAll(Vec<Condition<R>>),
+ IfAll(Vec<Condition<R, T>>),
/// `Src` is transmutable into `Dst` if any of the enclosed requirements are met.
- IfAny(Vec<Condition<R>>),
+ IfAny(Vec<Condition<R, T>>),
}
/// Answers "why wasn't the source type transmutable into the destination type?"
@@ -53,12 +59,16 @@ pub enum Reason<T> {
DstMayHaveSafetyInvariants,
/// `Dst` is larger than `Src`, and the excess bytes were not exclusively uninitialized.
DstIsTooBig,
- /// A referent of `Dst` is larger than a referent in `Src`.
+ /// `Dst` is larger `Src`.
DstRefIsTooBig {
/// The referent of the source type.
src: T,
+ /// The size of the source type's referent.
+ src_size: usize,
/// The too-large referent of the destination type.
dst: T,
+ /// The size of the destination type's referent.
+ dst_size: usize,
},
/// Src should have a stricter alignment than Dst, but it does not.
DstHasStricterAlignment { src_min_align: usize, dst_min_align: usize },
@@ -79,7 +89,7 @@ pub enum Reason<T> {
#[cfg(feature = "rustc")]
mod rustc {
use rustc_hir::lang_items::LangItem;
- use rustc_middle::ty::{Const, Ty, TyCtxt};
+ use rustc_middle::ty::{Const, Region, Ty, TyCtxt};
use super::*;
@@ -105,7 +115,7 @@ pub fn is_transmutable(
&mut self,
types: Types<'tcx>,
assume: crate::Assume,
- ) -> crate::Answer<crate::layout::rustc::Ref<'tcx>> {
+ ) -> crate::Answer<Region<'tcx>, Ty<'tcx>> {
crate::maybe_transmutable::MaybeTransmutableQuery::new(
types.src, types.dst, assume, self.tcx,
)
diff --git a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs
index f76abe5..062de4b 100644
--- a/compiler/rustc_transmute/src/maybe_transmutable/mod.rs
+++ b/compiler/rustc_transmute/src/maybe_transmutable/mod.rs
@@ -5,7 +5,7 @@
#[cfg(test)]
mod tests;
-use crate::layout::{self, Def, Dfa, Ref, Tree, dfa, union};
+use crate::layout::{self, Def, Dfa, Reference, Tree, dfa, union};
use crate::maybe_transmutable::query_context::QueryContext;
use crate::{Answer, Condition, Map, Reason};
@@ -41,7 +41,10 @@ impl<'tcx> MaybeTransmutableQuery<Ty<'tcx>, TyCtxt<'tcx>> {
/// This method begins by converting `src` and `dst` from `Ty`s to `Tree`s,
/// then computes an answer using those trees.
#[instrument(level = "debug", skip(self), fields(src = ?self.src, dst = ?self.dst))]
- pub(crate) fn answer(self) -> Answer<<TyCtxt<'tcx> as QueryContext>::Ref> {
+ pub(crate) fn answer(
+ self,
+ ) -> Answer<<TyCtxt<'tcx> as QueryContext>::Region, <TyCtxt<'tcx> as QueryContext>::Type>
+ {
let Self { src, dst, assume, context } = self;
let layout_cx = LayoutCx::new(context, TypingEnv::fully_monomorphized());
@@ -67,7 +70,11 @@ pub(crate) fn answer(self) -> Answer<<TyCtxt<'tcx> as QueryContext>::Ref> {
}
}
-impl<C> MaybeTransmutableQuery<Tree<<C as QueryContext>::Def, <C as QueryContext>::Ref>, C>
+impl<C>
+ MaybeTransmutableQuery<
+ Tree<<C as QueryContext>::Def, <C as QueryContext>::Region, <C as QueryContext>::Type>,
+ C,
+ >
where
C: QueryContext,
{
@@ -77,7 +84,7 @@ impl<C> MaybeTransmutableQuery<Tree<<C as QueryContext>::Def, <C as QueryContext
/// then converts `src` and `dst` to `Dfa`s, and computes an answer using those DFAs.
#[inline(always)]
#[instrument(level = "debug", skip(self), fields(src = ?self.src, dst = ?self.dst))]
- pub(crate) fn answer(self) -> Answer<<C as QueryContext>::Ref> {
+ pub(crate) fn answer(self) -> Answer<<C as QueryContext>::Region, <C as QueryContext>::Type> {
let Self { src, dst, assume, context } = self;
// Unconditionally remove all `Def` nodes from `src`, without pruning away the
@@ -130,12 +137,12 @@ pub(crate) fn answer(self) -> Answer<<C as QueryContext>::Ref> {
}
}
-impl<C> MaybeTransmutableQuery<Dfa<<C as QueryContext>::Ref>, C>
+impl<C> MaybeTransmutableQuery<Dfa<<C as QueryContext>::Region, <C as QueryContext>::Type>, C>
where
C: QueryContext,
{
/// Answers whether a `Dfa` is transmutable into another `Dfa`.
- pub(crate) fn answer(self) -> Answer<<C as QueryContext>::Ref> {
+ pub(crate) fn answer(self) -> Answer<<C as QueryContext>::Region, <C as QueryContext>::Type> {
self.answer_memo(&mut Map::default(), self.src.start, self.dst.start)
}
@@ -143,10 +150,13 @@ pub(crate) fn answer(self) -> Answer<<C as QueryContext>::Ref> {
#[instrument(level = "debug", skip(self))]
fn answer_memo(
&self,
- cache: &mut Map<(dfa::State, dfa::State), Answer<<C as QueryContext>::Ref>>,
+ cache: &mut Map<
+ (dfa::State, dfa::State),
+ Answer<<C as QueryContext>::Region, <C as QueryContext>::Type>,
+ >,
src_state: dfa::State,
dst_state: dfa::State,
- ) -> Answer<<C as QueryContext>::Ref> {
+ ) -> Answer<<C as QueryContext>::Region, <C as QueryContext>::Type> {
if let Some(answer) = cache.get(&(src_state, dst_state)) {
answer.clone()
} else {
@@ -160,10 +170,13 @@ fn answer_memo(
fn answer_impl(
&self,
- cache: &mut Map<(dfa::State, dfa::State), Answer<<C as QueryContext>::Ref>>,
+ cache: &mut Map<
+ (dfa::State, dfa::State),
+ Answer<<C as QueryContext>::Region, <C as QueryContext>::Type>,
+ >,
src_state: dfa::State,
dst_state: dfa::State,
- ) -> Answer<<C as QueryContext>::Ref> {
+ ) -> Answer<<C as QueryContext>::Region, <C as QueryContext>::Type> {
debug!(?src_state, ?dst_state);
debug!(src = ?self.src);
debug!(dst = ?self.dst);
@@ -247,27 +260,51 @@ fn answer_impl(
// ...there exists a reference transition out of `dst_state`...
Quantifier::ThereExists.apply(self.dst.refs_from(dst_state).map(
|(dst_ref, dst_state_prime)| {
- if !src_ref.is_mutable() && dst_ref.is_mutable() {
+ if !src_ref.is_mut && dst_ref.is_mut {
Answer::No(Reason::DstIsMoreUnique)
} else if !self.assume.alignment
- && src_ref.min_align() < dst_ref.min_align()
+ && src_ref.referent_align < dst_ref.referent_align
{
Answer::No(Reason::DstHasStricterAlignment {
- src_min_align: src_ref.min_align(),
- dst_min_align: dst_ref.min_align(),
+ src_min_align: src_ref.referent_align,
+ dst_min_align: dst_ref.referent_align,
})
- } else if dst_ref.size() > src_ref.size() {
- Answer::No(Reason::DstRefIsTooBig { src: src_ref, dst: dst_ref })
+ } else if dst_ref.referent_size > src_ref.referent_size {
+ Answer::No(Reason::DstRefIsTooBig {
+ src: src_ref.referent,
+ src_size: src_ref.referent_size,
+ dst: dst_ref.referent,
+ dst_size: dst_ref.referent_size,
+ })
} else {
- // ...such that `src` is transmutable into `dst`, if
- // `src_ref` is transmutability into `dst_ref`.
- and(
- Answer::If(Condition::IfTransmutable {
- src: src_ref,
- dst: dst_ref,
- }),
- self.answer_memo(cache, src_state_prime, dst_state_prime),
- )
+ let mut conditions = Vec::with_capacity(4);
+ let mut is_transmutable =
+ |src: Reference<_, _>, dst: Reference<_, _>| {
+ conditions.push(Condition::Transmutable {
+ src: src.referent,
+ dst: dst.referent,
+ });
+ if !self.assume.lifetimes {
+ conditions.push(Condition::Outlives {
+ long: src.region,
+ short: dst.region,
+ });
+ }
+ };
+
+ is_transmutable(src_ref, dst_ref);
+
+ if dst_ref.is_mut {
+ is_transmutable(dst_ref, src_ref);
+ } else {
+ conditions.push(Condition::Immutable { ty: dst_ref.referent });
+ }
+
+ Answer::If(Condition::IfAll(conditions)).and(self.answer_memo(
+ cache,
+ src_state_prime,
+ dst_state_prime,
+ ))
}
},
))
@@ -275,67 +312,65 @@ fn answer_impl(
);
if self.assume.validity {
- or(bytes_answer, refs_answer)
+ bytes_answer.or(refs_answer)
} else {
- and(bytes_answer, refs_answer)
+ bytes_answer.and(refs_answer)
}
}
}
}
-fn and<R>(lhs: Answer<R>, rhs: Answer<R>) -> Answer<R>
-where
- R: PartialEq,
-{
- match (lhs, rhs) {
- // If both are errors, then we should return the more specific one
- (Answer::No(Reason::DstIsBitIncompatible), Answer::No(reason))
- | (Answer::No(reason), Answer::No(_))
- // If either is an error, return it
- | (Answer::No(reason), _) | (_, Answer::No(reason)) => Answer::No(reason),
- // If only one side has a condition, pass it along
- | (Answer::Yes, other) | (other, Answer::Yes) => other,
- // If both sides have IfAll conditions, merge them
- (Answer::If(Condition::IfAll(mut lhs)), Answer::If(Condition::IfAll(ref mut rhs))) => {
- lhs.append(rhs);
- Answer::If(Condition::IfAll(lhs))
+impl<R, T> Answer<R, T> {
+ fn and(self, rhs: Answer<R, T>) -> Answer<R, T> {
+ let lhs = self;
+ match (lhs, rhs) {
+ // If both are errors, then we should return the more specific one
+ (Answer::No(Reason::DstIsBitIncompatible), Answer::No(reason))
+ | (Answer::No(reason), Answer::No(_))
+ // If either is an error, return it
+ | (Answer::No(reason), _) | (_, Answer::No(reason)) => Answer::No(reason),
+ // If only one side has a condition, pass it along
+ | (Answer::Yes, other) | (other, Answer::Yes) => other,
+ // If both sides have IfAll conditions, merge them
+ (Answer::If(Condition::IfAll(mut lhs)), Answer::If(Condition::IfAll(ref mut rhs))) => {
+ lhs.append(rhs);
+ Answer::If(Condition::IfAll(lhs))
+ }
+ // If only one side is an IfAll, add the other Condition to it
+ (Answer::If(cond), Answer::If(Condition::IfAll(mut conds)))
+ | (Answer::If(Condition::IfAll(mut conds)), Answer::If(cond)) => {
+ conds.push(cond);
+ Answer::If(Condition::IfAll(conds))
+ }
+ // Otherwise, both lhs and rhs conditions can be combined in a parent IfAll
+ (Answer::If(lhs), Answer::If(rhs)) => Answer::If(Condition::IfAll(vec![lhs, rhs])),
}
- // If only one side is an IfAll, add the other Condition to it
- (Answer::If(cond), Answer::If(Condition::IfAll(mut conds)))
- | (Answer::If(Condition::IfAll(mut conds)), Answer::If(cond)) => {
- conds.push(cond);
- Answer::If(Condition::IfAll(conds))
- }
- // Otherwise, both lhs and rhs conditions can be combined in a parent IfAll
- (Answer::If(lhs), Answer::If(rhs)) => Answer::If(Condition::IfAll(vec![lhs, rhs])),
}
-}
-fn or<R>(lhs: Answer<R>, rhs: Answer<R>) -> Answer<R>
-where
- R: PartialEq,
-{
- match (lhs, rhs) {
- // If both are errors, then we should return the more specific one
- (Answer::No(Reason::DstIsBitIncompatible), Answer::No(reason))
- | (Answer::No(reason), Answer::No(_)) => Answer::No(reason),
- // Otherwise, errors can be ignored for the rest of the pattern matching
- (Answer::No(_), other) | (other, Answer::No(_)) => or(other, Answer::Yes),
- // If only one side has a condition, pass it along
- (Answer::Yes, other) | (other, Answer::Yes) => other,
- // If both sides have IfAny conditions, merge them
- (Answer::If(Condition::IfAny(mut lhs)), Answer::If(Condition::IfAny(ref mut rhs))) => {
- lhs.append(rhs);
- Answer::If(Condition::IfAny(lhs))
+ fn or(self, rhs: Answer<R, T>) -> Answer<R, T> {
+ let lhs = self;
+ match (lhs, rhs) {
+ // If both are errors, then we should return the more specific one
+ (Answer::No(Reason::DstIsBitIncompatible), Answer::No(reason))
+ | (Answer::No(reason), Answer::No(_)) => Answer::No(reason),
+ // Otherwise, errors can be ignored for the rest of the pattern matching
+ (Answer::No(_), other) | (other, Answer::No(_)) => other.or(Answer::Yes),
+ // If only one side has a condition, pass it along
+ (Answer::Yes, other) | (other, Answer::Yes) => other,
+ // If both sides have IfAny conditions, merge them
+ (Answer::If(Condition::IfAny(mut lhs)), Answer::If(Condition::IfAny(ref mut rhs))) => {
+ lhs.append(rhs);
+ Answer::If(Condition::IfAny(lhs))
+ }
+ // If only one side is an IfAny, add the other Condition to it
+ (Answer::If(cond), Answer::If(Condition::IfAny(mut conds)))
+ | (Answer::If(Condition::IfAny(mut conds)), Answer::If(cond)) => {
+ conds.push(cond);
+ Answer::If(Condition::IfAny(conds))
+ }
+ // Otherwise, both lhs and rhs conditions can be combined in a parent IfAny
+ (Answer::If(lhs), Answer::If(rhs)) => Answer::If(Condition::IfAny(vec![lhs, rhs])),
}
- // If only one side is an IfAny, add the other Condition to it
- (Answer::If(cond), Answer::If(Condition::IfAny(mut conds)))
- | (Answer::If(Condition::IfAny(mut conds)), Answer::If(cond)) => {
- conds.push(cond);
- Answer::If(Condition::IfAny(conds))
- }
- // Otherwise, both lhs and rhs conditions can be combined in a parent IfAny
- (Answer::If(lhs), Answer::If(rhs)) => Answer::If(Condition::IfAny(vec![lhs, rhs])),
}
}
@@ -345,24 +380,25 @@ enum Quantifier {
}
impl Quantifier {
- fn apply<R, I>(&self, iter: I) -> Answer<R>
+ fn apply<R, T, I>(&self, iter: I) -> Answer<R, T>
where
- R: layout::Ref,
- I: IntoIterator<Item = Answer<R>>,
+ R: layout::Region,
+ T: layout::Type,
+ I: IntoIterator<Item = Answer<R, T>>,
{
use std::ops::ControlFlow::{Break, Continue};
let (init, try_fold_f): (_, fn(_, _) -> _) = match self {
Self::ThereExists => {
- (Answer::No(Reason::DstIsBitIncompatible), |accum: Answer<R>, next| {
- match or(accum, next) {
- Answer::Yes => Break(Answer::Yes),
- maybe => Continue(maybe),
- }
+ (Answer::No(Reason::DstIsBitIncompatible), |accum: Answer<R, T>, next| match accum
+ .or(next)
+ {
+ Answer::Yes => Break(Answer::Yes),
+ maybe => Continue(maybe),
})
}
- Self::ForAll => (Answer::Yes, |accum: Answer<R>, next| {
- let answer = and(accum, next);
+ Self::ForAll => (Answer::Yes, |accum: Answer<R, T>, next| {
+ let answer = accum.and(next);
match answer {
Answer::No(_) => Break(answer),
maybe => Continue(maybe),
diff --git a/compiler/rustc_transmute/src/maybe_transmutable/query_context.rs b/compiler/rustc_transmute/src/maybe_transmutable/query_context.rs
index 214da10..6be0cb1 100644
--- a/compiler/rustc_transmute/src/maybe_transmutable/query_context.rs
+++ b/compiler/rustc_transmute/src/maybe_transmutable/query_context.rs
@@ -3,7 +3,8 @@
/// Context necessary to answer the question "Are these types transmutable?".
pub(crate) trait QueryContext {
type Def: layout::Def;
- type Ref: layout::Ref;
+ type Region: layout::Region;
+ type Type: layout::Type;
}
#[cfg(test)]
@@ -12,9 +13,9 @@ pub(crate) mod test {
use super::QueryContext;
- pub(crate) struct UltraMinimal<R = !>(PhantomData<R>);
+ pub(crate) struct UltraMinimal<R = !, T = !>(PhantomData<(R, T)>);
- impl<R> Default for UltraMinimal<R> {
+ impl<R, T> Default for UltraMinimal<R, T> {
fn default() -> Self {
Self(PhantomData)
}
@@ -32,20 +33,26 @@ fn has_safety_invariants(&self) -> bool {
}
}
- impl<R: crate::layout::Ref> QueryContext for UltraMinimal<R> {
+ impl<R, T> QueryContext for UltraMinimal<R, T>
+ where
+ R: crate::layout::Region,
+ T: crate::layout::Type,
+ {
type Def = Def;
- type Ref = R;
+ type Region = R;
+ type Type = T;
}
}
#[cfg(feature = "rustc")]
mod rustc {
- use rustc_middle::ty::TyCtxt;
+ use rustc_middle::ty::{Region, Ty, TyCtxt};
use super::*;
impl<'tcx> super::QueryContext for TyCtxt<'tcx> {
type Def = layout::rustc::Def<'tcx>;
- type Ref = layout::rustc::Ref<'tcx>;
+ type Region = Region<'tcx>;
+ type Type = Ty<'tcx>;
}
}
diff --git a/compiler/rustc_transmute/src/maybe_transmutable/tests.rs b/compiler/rustc_transmute/src/maybe_transmutable/tests.rs
index 0227ad7..8440ace 100644
--- a/compiler/rustc_transmute/src/maybe_transmutable/tests.rs
+++ b/compiler/rustc_transmute/src/maybe_transmutable/tests.rs
@@ -3,17 +3,17 @@
use itertools::Itertools;
use super::query_context::test::{Def, UltraMinimal};
-use crate::{Answer, Assume, Reason, layout};
+use crate::{Answer, Assume, Condition, Reason, layout};
-type Tree = layout::Tree<Def, !>;
-type Dfa = layout::Dfa<!>;
+type Tree = layout::Tree<Def, !, !>;
+type Dfa = layout::Dfa<!, !>;
trait Representation {
- fn is_transmutable(src: Self, dst: Self, assume: Assume) -> Answer<!>;
+ fn is_transmutable(src: Self, dst: Self, assume: Assume) -> Answer<!, !>;
}
impl Representation for Tree {
- fn is_transmutable(src: Self, dst: Self, assume: Assume) -> Answer<!> {
+ fn is_transmutable(src: Self, dst: Self, assume: Assume) -> Answer<!, !> {
crate::maybe_transmutable::MaybeTransmutableQuery::new(
src,
dst,
@@ -25,7 +25,7 @@ fn is_transmutable(src: Self, dst: Self, assume: Assume) -> Answer<!> {
}
impl Representation for Dfa {
- fn is_transmutable(src: Self, dst: Self, assume: Assume) -> Answer<!> {
+ fn is_transmutable(src: Self, dst: Self, assume: Assume) -> Answer<!, !> {
crate::maybe_transmutable::MaybeTransmutableQuery::new(
src,
dst,
@@ -40,7 +40,7 @@ fn is_transmutable<R: Representation + Clone>(
src: &R,
dst: &R,
assume: Assume,
-) -> crate::Answer<!> {
+) -> crate::Answer<!, !> {
let src = src.clone();
let dst = dst.clone();
// The only dimension of the transmutability analysis we want to test
@@ -53,7 +53,7 @@ mod safety {
use super::*;
use crate::Answer;
- const DST_HAS_SAFETY_INVARIANTS: Answer<!> =
+ const DST_HAS_SAFETY_INVARIANTS: Answer<!, !> =
Answer::No(crate::Reason::DstMayHaveSafetyInvariants);
#[test]
@@ -177,14 +177,15 @@ fn transmute_u8() {
#[test]
fn should_permit_validity_expansion_and_reject_contraction() {
- let b0 = layout::Tree::<Def, !>::byte(0);
- let b1 = layout::Tree::<Def, !>::byte(1);
- let b2 = layout::Tree::<Def, !>::byte(2);
+ let b0 = layout::Tree::<Def, !, !>::byte(0);
+ let b1 = layout::Tree::<Def, !, !>::byte(1);
+ let b2 = layout::Tree::<Def, !, !>::byte(2);
let alts = [b0, b1, b2];
let into_layout = |alts: Vec<_>| {
- alts.into_iter().fold(layout::Tree::<Def, !>::uninhabited(), layout::Tree::<Def, !>::or)
+ alts.into_iter()
+ .fold(layout::Tree::<Def, !, !>::uninhabited(), layout::Tree::<Def, !, !>::or)
};
let into_set = |alts: Vec<_>| {
@@ -277,7 +278,7 @@ mod alt {
#[test]
fn should_permit_identity_transmutation() {
- type Tree = layout::Tree<Def, !>;
+ type Tree = layout::Tree<Def, !, !>;
let x = Tree::Seq(vec![Tree::byte(0), Tree::byte(0)]);
let y = Tree::Seq(vec![Tree::bool(), Tree::byte(1)]);
@@ -331,7 +332,7 @@ mod char {
fn should_permit_valid_transmutation() {
for order in [Endian::Big, Endian::Little] {
use Answer::*;
- let char_layout = layout::Tree::<Def, !>::char(order);
+ let char_layout = layout::Tree::<Def, !, !>::char(order);
// `char`s can be in the following ranges:
// - [0, 0xD7FF]
@@ -353,7 +354,7 @@ fn should_permit_valid_transmutation() {
(0xFFFFFFFF, no),
] {
let src_layout =
- layout::tree::Tree::<Def, !>::from_big_endian(order, src.to_be_bytes());
+ layout::tree::Tree::<Def, !, !>::from_big_endian(order, src.to_be_bytes());
let a = is_transmutable(&src_layout, &char_layout, Assume::default());
assert_eq!(a, answer, "endian:{order:?},\nsrc:{src:x}");
@@ -371,7 +372,7 @@ mod nonzero {
#[test]
fn should_permit_identity_transmutation() {
for width in NONZERO_BYTE_WIDTHS {
- let layout = layout::Tree::<Def, !>::nonzero(width);
+ let layout = layout::Tree::<Def, !, !>::nonzero(width);
assert_eq!(is_transmutable(&layout, &layout, Assume::default()), Answer::Yes);
}
}
@@ -381,8 +382,8 @@ fn should_permit_valid_transmutation() {
for width in NONZERO_BYTE_WIDTHS {
use Answer::*;
- let num = layout::Tree::<Def, !>::number(width);
- let nz = layout::Tree::<Def, !>::nonzero(width);
+ let num = layout::Tree::<Def, !, !>::number(width);
+ let nz = layout::Tree::<Def, !, !>::nonzero(width);
let a = is_transmutable(&num, &nz, Assume::default());
assert_eq!(a, No(Reason::DstIsBitIncompatible), "width:{width}");
@@ -395,13 +396,23 @@ fn should_permit_valid_transmutation() {
mod r#ref {
use super::*;
+ use crate::layout::Reference;
#[test]
fn should_permit_identity_transmutation() {
- type Tree = crate::layout::Tree<Def, [(); 1]>;
+ type Tree = crate::layout::Tree<Def, usize, ()>;
for validity in [false, true] {
- let layout = Tree::Seq(vec![Tree::byte(0x00), Tree::Ref([()])]);
+ let layout = Tree::Seq(vec![
+ Tree::byte(0x00),
+ Tree::Ref(Reference {
+ region: 42,
+ is_mut: false,
+ referent: (),
+ referent_size: 0,
+ referent_align: 1,
+ }),
+ ]);
let assume = Assume { validity, ..Assume::default() };
@@ -414,7 +425,11 @@ fn should_permit_identity_transmutation() {
.answer();
assert_eq!(
answer,
- Answer::If(crate::Condition::IfTransmutable { src: [()], dst: [()] })
+ Answer::If(Condition::IfAll(vec![
+ Condition::Transmutable { src: (), dst: () },
+ Condition::Outlives { long: 42, short: 42 },
+ Condition::Immutable { ty: () },
+ ]))
);
}
}
diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs
index e39fd6b..79ac622 100644
--- a/compiler/rustc_ty_utils/src/ty.rs
+++ b/compiler/rustc_ty_utils/src/ty.rs
@@ -255,10 +255,8 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) {
}
}
-fn param_env_normalized_for_post_analysis(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
- // This is a bit ugly but the easiest way to avoid code duplication.
- let typing_env = ty::TypingEnv::non_body_analysis(tcx, def_id);
- typing_env.with_post_analysis_normalized(tcx).param_env
+fn typing_env_normalized_for_post_analysis(tcx: TyCtxt<'_>, def_id: DefId) -> ty::TypingEnv<'_> {
+ ty::TypingEnv::non_body_analysis(tcx, def_id).with_post_analysis_normalized(tcx)
}
/// Check if a function is async.
@@ -319,7 +317,7 @@ fn impl_self_is_guaranteed_unsized<'tcx>(tcx: TyCtxt<'tcx>, impl_def_id: DefId)
let infcx = tcx.infer_ctxt().ignoring_regions().build(ty::TypingMode::non_body_analysis());
- let ocx = traits::ObligationCtxt::new_with_diagnostics(&infcx);
+ let ocx = traits::ObligationCtxt::new(&infcx);
let cause = traits::ObligationCause::dummy();
let param_env = tcx.param_env(impl_def_id);
@@ -374,7 +372,7 @@ pub(crate) fn provide(providers: &mut Providers) {
asyncness,
adt_sized_constraint,
param_env,
- param_env_normalized_for_post_analysis,
+ typing_env_normalized_for_post_analysis,
defaultness,
unsizing_params_for_adt,
impl_self_is_guaranteed_unsized,
diff --git a/compiler/rustc_type_ir/src/canonical.rs b/compiler/rustc_type_ir/src/canonical.rs
index 2b1b061..c66a836 100644
--- a/compiler/rustc_type_ir/src/canonical.rs
+++ b/compiler/rustc_type_ir/src/canonical.rs
@@ -7,6 +7,7 @@
use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic};
+use crate::data_structures::HashMap;
use crate::inherent::*;
use crate::{self as ty, Interner, TypingMode, UniverseIndex};
@@ -333,3 +334,11 @@ fn index(&self, value: ty::BoundVar) -> &I::GenericArg {
&self.var_values.as_slice()[value.as_usize()]
}
}
+
+#[derive_where(Clone, Debug; I: Interner)]
+pub struct CanonicalParamEnvCacheEntry<I: Interner> {
+ pub param_env: I::ParamEnv,
+ pub variables: Vec<I::GenericArg>,
+ pub variable_lookup_table: HashMap<I::GenericArg, usize>,
+ pub var_kinds: Vec<CanonicalVarKind<I>>,
+}
diff --git a/compiler/rustc_type_ir/src/fast_reject.rs b/compiler/rustc_type_ir/src/fast_reject.rs
index 34502f4..615d077 100644
--- a/compiler/rustc_type_ir/src/fast_reject.rs
+++ b/compiler/rustc_type_ir/src/fast_reject.rs
@@ -84,6 +84,9 @@ pub enum TreatParams {
///
/// This also treats projections with inference variables as infer vars
/// since they could be further normalized.
+ // FIXME(@lcnr): This treats aliases as rigid. This is only correct if the
+ // type has been structurally normalized. We should reflect this requirement
+ // in the variant name. It is currently incorrectly used in diagnostics.
AsRigid,
}
@@ -151,9 +154,11 @@ pub fn simplify_type<I: Interner>(
ty::Alias(..) => match treat_params {
// When treating `ty::Param` as a placeholder, projections also
// don't unify with anything else as long as they are fully normalized.
- // FIXME(-Znext-solver): Can remove this `if` and always simplify to `Placeholder`
- // when the new solver is enabled by default.
- TreatParams::AsRigid if !ty.has_non_region_infer() => Some(SimplifiedType::Placeholder),
+ TreatParams::AsRigid
+ if !ty.has_non_region_infer() || cx.next_trait_solver_globally() =>
+ {
+ Some(SimplifiedType::Placeholder)
+ }
TreatParams::AsRigid | TreatParams::InstantiateWithInfer => None,
},
ty::Foreign(def_id) => Some(SimplifiedType::Foreign(def_id)),
diff --git a/compiler/rustc_type_ir/src/interner.rs b/compiler/rustc_type_ir/src/interner.rs
index 05ca6f1..cc0925b 100644
--- a/compiler/rustc_type_ir/src/interner.rs
+++ b/compiler/rustc_type_ir/src/interner.rs
@@ -12,7 +12,7 @@
use crate::relate::Relate;
use crate::solve::{CanonicalInput, ExternalConstraintsData, PredefinedOpaquesData, QueryResult};
use crate::visit::{Flags, TypeVisitable};
-use crate::{self as ty, search_graph};
+use crate::{self as ty, CanonicalParamEnvCacheEntry, search_graph};
#[cfg_attr(feature = "nightly", rustc_diagnostic_item = "type_ir_interner")]
pub trait Interner:
@@ -32,6 +32,10 @@ pub trait Interner:
+ IrPrint<ty::FnSig<Self>>
+ IrPrint<ty::PatternKind<Self>>
{
+ fn next_trait_solver_globally(self) -> bool {
+ true
+ }
+
type DefId: DefId<Self>;
type LocalDefId: Copy + Debug + Hash + Eq + Into<Self::DefId> + TypeFoldable<Self>;
type Span: Span<Self>;
@@ -149,6 +153,13 @@ fn mk_tracked<T: Debug + Clone>(
fn with_global_cache<R>(self, f: impl FnOnce(&mut search_graph::GlobalCache<Self>) -> R) -> R;
+ fn canonical_param_env_cache_get_or_insert<R>(
+ self,
+ param_env: Self::ParamEnv,
+ f: impl FnOnce() -> CanonicalParamEnvCacheEntry<Self>,
+ from_entry: impl FnOnce(&CanonicalParamEnvCacheEntry<Self>) -> R,
+ ) -> R;
+
fn evaluation_is_concurrent(&self) -> bool;
fn expand_abstract_consts<T: TypeFoldable<Self>>(self, t: T) -> T;
diff --git a/compiler/rustc_type_ir/src/ty_kind.rs b/compiler/rustc_type_ir/src/ty_kind.rs
index 0cd98b5..9669772 100644
--- a/compiler/rustc_type_ir/src/ty_kind.rs
+++ b/compiler/rustc_type_ir/src/ty_kind.rs
@@ -771,23 +771,6 @@ pub enum InferTy {
FreshFloatTy(u32),
}
-/// Raw `TyVid` are used as the unification key for `sub_relations`;
-/// they carry no values.
-impl UnifyKey for TyVid {
- type Value = ();
- #[inline]
- fn index(&self) -> u32 {
- self.as_u32()
- }
- #[inline]
- fn from_index(i: u32) -> TyVid {
- TyVid::from_u32(i)
- }
- fn tag() -> &'static str {
- "TyVid"
- }
-}
-
impl UnifyValue for IntVarValue {
type Error = NoError;
diff --git a/library/Cargo.lock b/library/Cargo.lock
index 0c75977..966ae72 100644
--- a/library/Cargo.lock
+++ b/library/Cargo.lock
@@ -62,11 +62,9 @@
[[package]]
name = "compiler_builtins"
version = "0.1.160"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6376049cfa92c0aa8b9ac95fae22184b981c658208d4ed8a1dc553cd83612895"
dependencies = [
"cc",
- "rustc-std-workspace-core",
+ "core",
]
[[package]]
@@ -304,6 +302,7 @@
name = "rustc-std-workspace-core"
version = "1.99.0"
dependencies = [
+ "compiler_builtins",
"core",
]
diff --git a/library/Cargo.toml b/library/Cargo.toml
index 026ba14..35480b9 100644
--- a/library/Cargo.toml
+++ b/library/Cargo.toml
@@ -50,3 +50,4 @@
rustc-std-workspace-core = { path = 'rustc-std-workspace-core' }
rustc-std-workspace-alloc = { path = 'rustc-std-workspace-alloc' }
rustc-std-workspace-std = { path = 'rustc-std-workspace-std' }
+compiler_builtins = { path = "compiler-builtins/compiler-builtins" }
diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml
index 31b6014..017c790 100644
--- a/library/alloc/Cargo.toml
+++ b/library/alloc/Cargo.toml
@@ -16,7 +16,7 @@
[dependencies]
core = { path = "../core", public = true }
-compiler_builtins = { version = "=0.1.160", features = ['rustc-dep-of-std'] }
+compiler_builtins = { path = "../compiler-builtins/compiler-builtins", features = ["rustc-dep-of-std"] }
[features]
compiler-builtins-mem = ['compiler_builtins/mem']
diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs
index 30540f4..f416732 100644
--- a/library/alloc/src/lib.rs
+++ b/library/alloc/src/lib.rs
@@ -131,7 +131,6 @@
#![feature(local_waker)]
#![feature(maybe_uninit_slice)]
#![feature(maybe_uninit_uninit_array_transpose)]
-#![feature(nonnull_provenance)]
#![feature(panic_internals)]
#![feature(pattern)]
#![feature(pin_coerce_unsized_trait)]
diff --git a/library/alloctests/lib.rs b/library/alloctests/lib.rs
index 56e60ed..3241b4b 100644
--- a/library/alloctests/lib.rs
+++ b/library/alloctests/lib.rs
@@ -28,7 +28,6 @@
#![feature(iter_next_chunk)]
#![feature(maybe_uninit_slice)]
#![feature(maybe_uninit_uninit_array_transpose)]
-#![feature(nonnull_provenance)]
#![feature(ptr_alignment_type)]
#![feature(ptr_internals)]
#![feature(sized_type_properties)]
diff --git a/library/compiler-builtins/compiler-builtins/Cargo.toml b/library/compiler-builtins/compiler-builtins/Cargo.toml
index 11ee919..df8e964 100644
--- a/library/compiler-builtins/compiler-builtins/Cargo.toml
+++ b/library/compiler-builtins/compiler-builtins/Cargo.toml
@@ -17,9 +17,7 @@
test = false
[dependencies]
-# For more information on this dependency see
-# https://github.com/rust-lang/rust/tree/master/library/rustc-std-workspace-core
-core = { version = "1.0.1", optional = true, package = "rustc-std-workspace-core" }
+core = { path = "../../core", optional = true }
[build-dependencies]
cc = { optional = true, version = "1.2" }
diff --git a/library/compiler-builtins/compiler-builtins/build.rs b/library/compiler-builtins/compiler-builtins/build.rs
index d37fdc5..7c8da02 100644
--- a/library/compiler-builtins/compiler-builtins/build.rs
+++ b/library/compiler-builtins/compiler-builtins/build.rs
@@ -22,6 +22,9 @@ fn main() {
println!("cargo:compiler-rt={}", cwd.join("compiler-rt").display());
+ println!("cargo::rustc-check-cfg=cfg(kernel_user_helpers)");
+ println!("cargo::rustc-check-cfg=cfg(feature, values(\"mem-unaligned\"))");
+
// Emscripten's runtime includes all the builtins
if target.os == "emscripten" {
return;
@@ -47,7 +50,6 @@ fn main() {
}
// These targets have hardware unaligned access support.
- println!("cargo::rustc-check-cfg=cfg(feature, values(\"mem-unaligned\"))");
if target.arch.contains("x86_64")
|| target.arch.contains("x86")
|| target.arch.contains("aarch64")
@@ -78,7 +80,6 @@ fn main() {
// Only emit the ARM Linux atomic emulation on pre-ARMv6 architectures. This
// includes the old androideabi. It is deprecated but it is available as a
// rustc target (arm-linux-androideabi).
- println!("cargo::rustc-check-cfg=cfg(kernel_user_helpers)");
if llvm_target[0] == "armv4t"
|| llvm_target[0] == "armv5te"
|| target.triple == "arm-linux-androideabi"
diff --git a/library/compiler-builtins/compiler-builtins/src/aarch64_linux.rs b/library/compiler-builtins/compiler-builtins/src/aarch64_linux.rs
index e238d02..2261212 100644
--- a/library/compiler-builtins/compiler-builtins/src/aarch64_linux.rs
+++ b/library/compiler-builtins/compiler-builtins/src/aarch64_linux.rs
@@ -4,7 +4,7 @@
//! To avoid breaking backwards compat, C toolchains introduced a concept of "outlined atomics",
//! where atomic operations call into the compiler runtime to dispatch between two depending on
//! which is supported on the current CPU.
-//! See https://community.arm.com/arm-community-blogs/b/tools-software-ides-blog/posts/making-the-most-of-the-arm-architecture-in-gcc-10#:~:text=out%20of%20line%20atomics for more discussion.
+//! See <https://community.arm.com/arm-community-blogs/b/tools-software-ides-blog/posts/making-the-most-of-the-arm-architecture-in-gcc-10#:~:text=out%20of%20line%20atomics> for more discussion.
//!
//! Currently we only support LL/SC, because LSE requires `getauxval` from libc in order to do runtime detection.
//! Use the `compiler-rt` intrinsics if you want LSE support.
diff --git a/library/compiler-builtins/compiler-builtins/src/arm_linux.rs b/library/compiler-builtins/compiler-builtins/src/arm_linux.rs
index 6ce67ba..ab9f868 100644
--- a/library/compiler-builtins/compiler-builtins/src/arm_linux.rs
+++ b/library/compiler-builtins/compiler-builtins/src/arm_linux.rs
@@ -4,12 +4,17 @@
// Kernel-provided user-mode helper functions:
// https://www.kernel.org/doc/Documentation/arm/kernel_user_helpers.txt
unsafe fn __kuser_cmpxchg(oldval: u32, newval: u32, ptr: *mut u32) -> bool {
- let f: extern "C" fn(u32, u32, *mut u32) -> u32 = mem::transmute(0xffff0fc0usize as *const ());
+ // FIXME(volatile): the third parameter is a volatile pointer
+ // SAFETY: kernel docs specify a known address with the given signature
+ let f = unsafe {
+ mem::transmute::<_, extern "C" fn(u32, u32, *mut u32) -> u32>(0xffff0fc0usize as *const ())
+ };
f(oldval, newval, ptr) == 0
}
unsafe fn __kuser_memory_barrier() {
- let f: extern "C" fn() = mem::transmute(0xffff0fa0usize as *const ());
+ // SAFETY: kernel docs specify a known address with the given signature
+ let f = unsafe { mem::transmute::<_, extern "C" fn()>(0xffff0fa0usize as *const ()) };
f();
}
@@ -67,8 +72,10 @@ fn insert_aligned(aligned: u32, val: u32, shift: u32, mask: u32) -> u32 {
/// - if `size_of::<T>() == 2`, `ptr` or `ptr` offset by 2 bytes must be valid for a relaxed atomic
/// read of 2 bytes.
/// - if `size_of::<T>() == 4`, `ptr` must be valid for a relaxed atomic read of 4 bytes.
+// FIXME: assert some of the preconditions in debug mode
unsafe fn atomic_load_aligned<T>(ptr: *mut u32) -> u32 {
- if mem::size_of::<T>() == 4 {
+ const { assert!(size_of::<T>() <= 4) };
+ if size_of::<T>() == 4 {
// SAFETY: As `T` has a size of 4, the caller garantees this is sound.
unsafe { AtomicU32::from_ptr(ptr).load(Ordering::Relaxed) }
} else {
@@ -100,11 +107,13 @@ unsafe fn atomic_rmw<T, F: Fn(u32) -> u32, G: Fn(u32, u32) -> u32>(ptr: *mut T,
let (shift, mask) = get_shift_mask(ptr);
loop {
- let curval_aligned = atomic_load_aligned::<T>(aligned_ptr);
+ // FIXME(safety): preconditions review needed
+ let curval_aligned = unsafe { atomic_load_aligned::<T>(aligned_ptr) };
let curval = extract_aligned(curval_aligned, shift, mask);
let newval = f(curval);
let newval_aligned = insert_aligned(curval_aligned, newval, shift, mask);
- if __kuser_cmpxchg(curval_aligned, newval_aligned, aligned_ptr) {
+ // FIXME(safety): preconditions review needed
+ if unsafe { __kuser_cmpxchg(curval_aligned, newval_aligned, aligned_ptr) } {
return g(curval, newval);
}
}
@@ -116,13 +125,15 @@ unsafe fn atomic_cmpxchg<T>(ptr: *mut T, oldval: u32, newval: u32) -> u32 {
let (shift, mask) = get_shift_mask(ptr);
loop {
- let curval_aligned = atomic_load_aligned::<T>(aligned_ptr);
+ // FIXME(safety): preconditions review needed
+ let curval_aligned = unsafe { atomic_load_aligned::<T>(aligned_ptr) };
let curval = extract_aligned(curval_aligned, shift, mask);
if curval != oldval {
return curval;
}
let newval_aligned = insert_aligned(curval_aligned, newval, shift, mask);
- if __kuser_cmpxchg(curval_aligned, newval_aligned, aligned_ptr) {
+ // FIXME(safety): preconditions review needed
+ if unsafe { __kuser_cmpxchg(curval_aligned, newval_aligned, aligned_ptr) } {
return oldval;
}
}
@@ -132,7 +143,14 @@ macro_rules! atomic_rmw {
($name:ident, $ty:ty, $op:expr, $fetch:expr) => {
intrinsics! {
pub unsafe extern "C" fn $name(ptr: *mut $ty, val: $ty) -> $ty {
- atomic_rmw(ptr, |x| $op(x as $ty, val) as u32, |old, new| $fetch(old, new)) as $ty
+ // FIXME(safety): preconditions review needed
+ unsafe {
+ atomic_rmw(
+ ptr,
+ |x| $op(x as $ty, val) as u32,
+ |old, new| $fetch(old, new)
+ ) as $ty
+ }
}
}
};
@@ -149,7 +167,8 @@ macro_rules! atomic_cmpxchg {
($name:ident, $ty:ty) => {
intrinsics! {
pub unsafe extern "C" fn $name(ptr: *mut $ty, oldval: $ty, newval: $ty) -> $ty {
- atomic_cmpxchg(ptr, oldval as u32, newval as u32) as $ty
+ // FIXME(safety): preconditions review needed
+ unsafe { atomic_cmpxchg(ptr, oldval as u32, newval as u32) as $ty }
}
}
};
@@ -285,6 +304,7 @@ macro_rules! atomic_cmpxchg {
intrinsics! {
pub unsafe extern "C" fn __sync_synchronize() {
- __kuser_memory_barrier();
+ // SAFETY: preconditions are the same as the calling function.
+ unsafe { __kuser_memory_barrier() };
}
}
diff --git a/library/compiler-builtins/compiler-builtins/src/lib.rs b/library/compiler-builtins/compiler-builtins/src/lib.rs
index 6a6b280..6549d4c 100644
--- a/library/compiler-builtins/compiler-builtins/src/lib.rs
+++ b/library/compiler-builtins/compiler-builtins/src/lib.rs
@@ -8,6 +8,7 @@
#![feature(linkage)]
#![feature(naked_functions)]
#![feature(repr_simd)]
+#![feature(rustc_attrs)]
#![cfg_attr(f16_enabled, feature(f16))]
#![cfg_attr(f128_enabled, feature(f128))]
#![no_builtins]
diff --git a/library/compiler-builtins/compiler-builtins/src/mem/x86_64.rs b/library/compiler-builtins/compiler-builtins/src/mem/x86_64.rs
index 5cbe83a..fb29eb1 100644
--- a/library/compiler-builtins/compiler-builtins/src/mem/x86_64.rs
+++ b/library/compiler-builtins/compiler-builtins/src/mem/x86_64.rs
@@ -69,7 +69,7 @@ pub unsafe fn copy_backward(dest: *mut u8, src: *const u8, count: usize) {
"rep movsb",
"sub $7, %rsi",
"sub $7, %rdi",
- "mov {qword_count}, %rcx",
+ "mov {qword_count:r}, %rcx",
"rep movsq",
"test {pre_byte_count:e}, {pre_byte_count:e}",
"add $7, %rsi",
@@ -212,7 +212,7 @@ pub unsafe fn c_string_length(mut s: *const core::ffi::c_char) -> usize {
let x = {
let r;
asm!(
- "movdqa ({addr}), {dest}",
+ "movdqa ({addr:r}), {dest}",
addr = in(reg) s,
dest = out(xmm_reg) r,
options(att_syntax, nostack),
@@ -232,7 +232,7 @@ pub unsafe fn c_string_length(mut s: *const core::ffi::c_char) -> usize {
let x = {
let r;
asm!(
- "movdqa ({addr}), {dest}",
+ "movdqa ({addr:r}), {dest}",
addr = in(reg) s,
dest = out(xmm_reg) r,
options(att_syntax, nostack),
diff --git a/library/compiler-builtins/compiler-builtins/src/probestack.rs b/library/compiler-builtins/compiler-builtins/src/probestack.rs
index c9070cf..1441fd7 100644
--- a/library/compiler-builtins/compiler-builtins/src/probestack.rs
+++ b/library/compiler-builtins/compiler-builtins/src/probestack.rs
@@ -49,304 +49,198 @@
// We only define stack probing for these architectures today.
#![cfg(any(target_arch = "x86_64", target_arch = "x86"))]
-// SAFETY: defined in this module.
-// FIXME(extern_custom): the ABI is not correct.
-unsafe extern "C" {
- pub fn __rust_probestack();
-}
-
-// A wrapper for our implementation of __rust_probestack, which allows us to
-// keep the assembly inline while controlling all CFI directives in the assembly
-// emitted for the function.
-//
-// This is the ELF version.
-#[cfg(not(any(target_vendor = "apple", target_os = "uefi")))]
-macro_rules! define_rust_probestack {
- ($body: expr) => {
- concat!(
- "
- .pushsection .text.__rust_probestack
- .globl __rust_probestack
- .type __rust_probestack, @function
- .hidden __rust_probestack
- __rust_probestack:
- ",
- $body,
- "
- .size __rust_probestack, . - __rust_probestack
- .popsection
- "
- )
- };
-}
-
-#[cfg(all(target_os = "uefi", target_arch = "x86_64"))]
-macro_rules! define_rust_probestack {
- ($body: expr) => {
- concat!(
- "
- .globl __rust_probestack
- __rust_probestack:
- ",
- $body
- )
- };
-}
-
-// Same as above, but for Mach-O. Note that the triple underscore
-// is deliberate
-#[cfg(target_vendor = "apple")]
-macro_rules! define_rust_probestack {
- ($body: expr) => {
- concat!(
- "
- .globl ___rust_probestack
- ___rust_probestack:
- ",
- $body
- )
- };
-}
-
-// In UEFI x86 arch, triple underscore is deliberate.
-#[cfg(all(target_os = "uefi", target_arch = "x86"))]
-macro_rules! define_rust_probestack {
- ($body: expr) => {
- concat!(
- "
- .globl ___rust_probestack
- ___rust_probestack:
- ",
- $body
- )
- };
-}
-
// Our goal here is to touch each page between %rsp+8 and %rsp+8-%rax,
// ensuring that if any pages are unmapped we'll make a page fault.
//
+// FIXME(abi_custom): This function is unsafe because it uses a custom ABI,
+// it does not actually match `extern "C"`.
+//
// The ABI here is that the stack frame size is located in `%rax`. Upon
// return we're not supposed to modify `%rsp` or `%rax`.
-//
-// Any changes to this function should be replicated to the SGX version below.
-#[cfg(all(
- target_arch = "x86_64",
- not(all(target_env = "sgx", target_vendor = "fortanix"))
-))]
-core::arch::global_asm!(
- define_rust_probestack!(
+#[cfg(target_arch = "x86_64")]
+#[unsafe(naked)]
+#[rustc_std_internal_symbol]
+pub unsafe extern "C" fn __rust_probestack() {
+ #[cfg(not(all(target_env = "sgx", target_vendor = "fortanix")))]
+ macro_rules! ret {
+ () => {
+ "ret"
+ };
+ }
+
+ #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))]
+ macro_rules! ret {
+ // for this target, [manually patch for LVI].
+ //
+ // [manually patch for LVI]: https://software.intel.com/security-software-guidance/insights/deep-dive-load-value-injection#specialinstructions
+ () => {
+ "
+ pop %r11
+ lfence
+ jmp *%r11
+ "
+ };
+ }
+
+ core::arch::naked_asm!(
"
- .cfi_startproc
- pushq %rbp
- .cfi_adjust_cfa_offset 8
- .cfi_offset %rbp, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register %rbp
+ .cfi_startproc
+ pushq %rbp
+ .cfi_adjust_cfa_offset 8
+ .cfi_offset %rbp, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register %rbp
- mov %rax,%r11 // duplicate %rax as we're clobbering %r11
+ mov %rax,%r11 // duplicate %rax as we're clobbering %r11
- // Main loop, taken in one page increments. We're decrementing rsp by
- // a page each time until there's less than a page remaining. We're
- // guaranteed that this function isn't called unless there's more than a
- // page needed.
- //
- // Note that we're also testing against `8(%rsp)` to account for the 8
- // bytes pushed on the stack orginally with our return address. Using
- // `8(%rsp)` simulates us testing the stack pointer in the caller's
- // context.
+ // Main loop, taken in one page increments. We're decrementing rsp by
+ // a page each time until there's less than a page remaining. We're
+ // guaranteed that this function isn't called unless there's more than a
+ // page needed.
+ //
+ // Note that we're also testing against `8(%rsp)` to account for the 8
+ // bytes pushed on the stack orginally with our return address. Using
+ // `8(%rsp)` simulates us testing the stack pointer in the caller's
+ // context.
- // It's usually called when %rax >= 0x1000, but that's not always true.
- // Dynamic stack allocation, which is needed to implement unsized
- // rvalues, triggers stackprobe even if %rax < 0x1000.
- // Thus we have to check %r11 first to avoid segfault.
- cmp $0x1000,%r11
- jna 3f
-2:
- sub $0x1000,%rsp
- test %rsp,8(%rsp)
- sub $0x1000,%r11
- cmp $0x1000,%r11
- ja 2b
+ // It's usually called when %rax >= 0x1000, but that's not always true.
+ // Dynamic stack allocation, which is needed to implement unsized
+ // rvalues, triggers stackprobe even if %rax < 0x1000.
+ // Thus we have to check %r11 first to avoid segfault.
+ cmp $0x1000,%r11
+ jna 3f
+ 2:
+ sub $0x1000,%rsp
+ test %rsp,8(%rsp)
+ sub $0x1000,%r11
+ cmp $0x1000,%r11
+ ja 2b
-3:
- // Finish up the last remaining stack space requested, getting the last
- // bits out of r11
- sub %r11,%rsp
- test %rsp,8(%rsp)
+ 3:
+ // Finish up the last remaining stack space requested, getting the last
+ // bits out of r11
+ sub %r11,%rsp
+ test %rsp,8(%rsp)
- // Restore the stack pointer to what it previously was when entering
- // this function. The caller will readjust the stack pointer after we
- // return.
- add %rax,%rsp
+ // Restore the stack pointer to what it previously was when entering
+ // this function. The caller will readjust the stack pointer after we
+ // return.
+ add %rax,%rsp
- leave
- .cfi_def_cfa_register %rsp
- .cfi_adjust_cfa_offset -8
- ret
- .cfi_endproc
- "
- ),
- options(att_syntax)
-);
-
-// This function is the same as above, except that some instructions are
-// [manually patched for LVI].
-//
-// [manually patched for LVI]: https://software.intel.com/security-software-guidance/insights/deep-dive-load-value-injection#specialinstructions
-#[cfg(all(
- target_arch = "x86_64",
- all(target_env = "sgx", target_vendor = "fortanix")
-))]
-core::arch::global_asm!(
- define_rust_probestack!(
+ leave
+ .cfi_def_cfa_register %rsp
+ .cfi_adjust_cfa_offset -8
+ ",
+ ret!(),
"
- .cfi_startproc
- pushq %rbp
- .cfi_adjust_cfa_offset 8
- .cfi_offset %rbp, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register %rbp
-
- mov %rax,%r11 // duplicate %rax as we're clobbering %r11
-
- // Main loop, taken in one page increments. We're decrementing rsp by
- // a page each time until there's less than a page remaining. We're
- // guaranteed that this function isn't called unless there's more than a
- // page needed.
- //
- // Note that we're also testing against `8(%rsp)` to account for the 8
- // bytes pushed on the stack orginally with our return address. Using
- // `8(%rsp)` simulates us testing the stack pointer in the caller's
- // context.
-
- // It's usually called when %rax >= 0x1000, but that's not always true.
- // Dynamic stack allocation, which is needed to implement unsized
- // rvalues, triggers stackprobe even if %rax < 0x1000.
- // Thus we have to check %r11 first to avoid segfault.
- cmp $0x1000,%r11
- jna 3f
-2:
- sub $0x1000,%rsp
- test %rsp,8(%rsp)
- sub $0x1000,%r11
- cmp $0x1000,%r11
- ja 2b
-
-3:
- // Finish up the last remaining stack space requested, getting the last
- // bits out of r11
- sub %r11,%rsp
- test %rsp,8(%rsp)
-
- // Restore the stack pointer to what it previously was when entering
- // this function. The caller will readjust the stack pointer after we
- // return.
- add %rax,%rsp
-
- leave
- .cfi_def_cfa_register %rsp
- .cfi_adjust_cfa_offset -8
- pop %r11
- lfence
- jmp *%r11
- .cfi_endproc
- "
- ),
- options(att_syntax)
-);
+ .cfi_endproc
+ ",
+ options(att_syntax)
+ )
+}
#[cfg(all(target_arch = "x86", not(target_os = "uefi")))]
// This is the same as x86_64 above, only translated for 32-bit sizes. Note
// that on Unix we're expected to restore everything as it was, this
// function basically can't tamper with anything.
//
+// FIXME(abi_custom): This function is unsafe because it uses a custom ABI,
+// it does not actually match `extern "C"`.
+//
// The ABI here is the same as x86_64, except everything is 32-bits large.
-core::arch::global_asm!(
- define_rust_probestack!(
+#[unsafe(naked)]
+#[rustc_std_internal_symbol]
+pub unsafe extern "C" fn __rust_probestack() {
+ core::arch::naked_asm!(
"
- .cfi_startproc
- push %ebp
- .cfi_adjust_cfa_offset 4
- .cfi_offset %ebp, -8
- mov %esp, %ebp
- .cfi_def_cfa_register %ebp
- push %ecx
- mov %eax,%ecx
+ .cfi_startproc
+ push %ebp
+ .cfi_adjust_cfa_offset 4
+ .cfi_offset %ebp, -8
+ mov %esp, %ebp
+ .cfi_def_cfa_register %ebp
+ push %ecx
+ mov %eax,%ecx
- cmp $0x1000,%ecx
- jna 3f
-2:
- sub $0x1000,%esp
- test %esp,8(%esp)
- sub $0x1000,%ecx
- cmp $0x1000,%ecx
- ja 2b
+ cmp $0x1000,%ecx
+ jna 3f
+ 2:
+ sub $0x1000,%esp
+ test %esp,8(%esp)
+ sub $0x1000,%ecx
+ cmp $0x1000,%ecx
+ ja 2b
-3:
- sub %ecx,%esp
- test %esp,8(%esp)
+ 3:
+ sub %ecx,%esp
+ test %esp,8(%esp)
- add %eax,%esp
- pop %ecx
- leave
- .cfi_def_cfa_register %esp
- .cfi_adjust_cfa_offset -4
- ret
- .cfi_endproc
- "
- ),
- options(att_syntax)
-);
+ add %eax,%esp
+ pop %ecx
+ leave
+ .cfi_def_cfa_register %esp
+ .cfi_adjust_cfa_offset -4
+ ret
+ .cfi_endproc
+ ",
+ options(att_syntax)
+ )
+}
#[cfg(all(target_arch = "x86", target_os = "uefi"))]
// UEFI target is windows like target. LLVM will do _chkstk things like windows.
// probestack function will also do things like _chkstk in MSVC.
// So we need to sub %ax %sp in probestack when arch is x86.
//
+// FIXME(abi_custom): This function is unsafe because it uses a custom ABI,
+// it does not actually match `extern "C"`.
+//
// REF: Rust commit(74e80468347)
// rust\src\llvm-project\llvm\lib\Target\X86\X86FrameLowering.cpp: 805
// Comments in LLVM:
// MSVC x32's _chkstk and cygwin/mingw's _alloca adjust %esp themselves.
// MSVC x64's __chkstk and cygwin/mingw's ___chkstk_ms do not adjust %rsp
// themselves.
-core::arch::global_asm!(
- define_rust_probestack!(
+#[unsafe(naked)]
+#[rustc_std_internal_symbol]
+pub unsafe extern "C" fn __rust_probestack() {
+ core::arch::naked_asm!(
"
- .cfi_startproc
- push %ebp
- .cfi_adjust_cfa_offset 4
- .cfi_offset %ebp, -8
- mov %esp, %ebp
- .cfi_def_cfa_register %ebp
- push %ecx
- push %edx
- mov %eax,%ecx
+ .cfi_startproc
+ push %ebp
+ .cfi_adjust_cfa_offset 4
+ .cfi_offset %ebp, -8
+ mov %esp, %ebp
+ .cfi_def_cfa_register %ebp
+ push %ecx
+ push %edx
+ mov %eax,%ecx
- cmp $0x1000,%ecx
- jna 3f
-2:
- sub $0x1000,%esp
- test %esp,8(%esp)
- sub $0x1000,%ecx
- cmp $0x1000,%ecx
- ja 2b
+ cmp $0x1000,%ecx
+ jna 3f
+ 2:
+ sub $0x1000,%esp
+ test %esp,8(%esp)
+ sub $0x1000,%ecx
+ cmp $0x1000,%ecx
+ ja 2b
-3:
- sub %ecx,%esp
- test %esp,8(%esp)
- mov 4(%ebp),%edx
- mov %edx, 12(%esp)
- add %eax,%esp
- pop %edx
- pop %ecx
- leave
+ 3:
+ sub %ecx,%esp
+ test %esp,8(%esp)
+ mov 4(%ebp),%edx
+ mov %edx, 12(%esp)
+ add %eax,%esp
+ pop %edx
+ pop %ecx
+ leave
- sub %eax, %esp
- .cfi_def_cfa_register %esp
- .cfi_adjust_cfa_offset -4
- ret
- .cfi_endproc
- "
- ),
- options(att_syntax)
-);
+ sub %eax, %esp
+ .cfi_def_cfa_register %esp
+ .cfi_adjust_cfa_offset -4
+ ret
+ .cfi_endproc
+ ",
+ options(att_syntax)
+ )
+}
diff --git a/library/core/Cargo.toml b/library/core/Cargo.toml
index f88661e..5d65b55 100644
--- a/library/core/Cargo.toml
+++ b/library/core/Cargo.toml
@@ -29,6 +29,8 @@
[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
+ # #[cfg(bootstrap)] loongarch32
+ 'cfg(target_arch, values("loongarch32"))',
'cfg(no_fp_fmt_parse)',
# core use #[path] imports to portable-simd `core_simd` crate
# and to stdarch `core_arch` crate which messes-up with Cargo list
diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs
index ed52392..a4b6efe 100644
--- a/library/core/src/cell.rs
+++ b/library/core/src/cell.rs
@@ -1914,6 +1914,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
/// [`.get()`]: `UnsafeCell::get`
/// [concurrent memory model]: ../sync/atomic/index.html#memory-model-for-atomic-accesses
///
+/// # Aliasing rules
+///
/// The precise Rust aliasing rules are somewhat in flux, but the main points are not contentious:
///
/// - If you create a safe reference with lifetime `'a` (either a `&T` or `&mut T` reference), then
@@ -2167,10 +2169,9 @@ pub const fn from_mut(value: &mut T) -> &mut UnsafeCell<T> {
/// Gets a mutable pointer to the wrapped value.
///
- /// This can be cast to a pointer of any kind.
- /// Ensure that the access is unique (no active references, mutable or not)
- /// when casting to `&mut T`, and ensure that there are no mutations
- /// or mutable aliases going on when casting to `&T`
+ /// This can be cast to a pointer of any kind. When creating references, you must uphold the
+ /// aliasing rules; see [the type-level docs][UnsafeCell#aliasing-rules] for more discussion and
+ /// caveats.
///
/// # Examples
///
@@ -2219,10 +2220,9 @@ pub const fn get_mut(&mut self) -> &mut T {
/// The difference from [`get`] is that this function accepts a raw pointer,
/// which is useful to avoid the creation of temporary references.
///
- /// The result can be cast to a pointer of any kind.
- /// Ensure that the access is unique (no active references, mutable or not)
- /// when casting to `&mut T`, and ensure that there are no mutations
- /// or mutable aliases going on when casting to `&T`.
+ /// This can be cast to a pointer of any kind. When creating references, you must uphold the
+ /// aliasing rules; see [the type-level docs][UnsafeCell#aliasing-rules] for more discussion and
+ /// caveats.
///
/// [`get`]: UnsafeCell::get()
///
diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs
index bde9046..4434ceb 100644
--- a/library/core/src/intrinsics/mod.rs
+++ b/library/core/src/intrinsics/mod.rs
@@ -84,327 +84,37 @@ pub enum AtomicOrdering {
/// `T` must be an integer or pointer type.
///
/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange` method by passing
-/// [`Ordering::Relaxed`] as both the success and failure parameters.
+/// [`atomic`] types via the `compare_exchange` method.
/// For example, [`AtomicBool::compare_exchange`].
#[rustc_intrinsic]
#[rustc_nounwind]
-pub unsafe fn atomic_cxchg_relaxed_relaxed<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange` method by passing
-/// [`Ordering::Relaxed`] and [`Ordering::Acquire`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchg_relaxed_acquire<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange` method by passing
-/// [`Ordering::Relaxed`] and [`Ordering::SeqCst`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchg_relaxed_seqcst<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange` method by passing
-/// [`Ordering::Acquire`] and [`Ordering::Relaxed`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchg_acquire_relaxed<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange` method by passing
-/// [`Ordering::Acquire`] as both the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchg_acquire_acquire<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange` method by passing
-/// [`Ordering::Acquire`] and [`Ordering::SeqCst`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchg_acquire_seqcst<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange` method by passing
-/// [`Ordering::Release`] and [`Ordering::Relaxed`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchg_release_relaxed<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange` method by passing
-/// [`Ordering::Release`] and [`Ordering::Acquire`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchg_release_acquire<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange` method by passing
-/// [`Ordering::Release`] and [`Ordering::SeqCst`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchg_release_seqcst<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange` method by passing
-/// [`Ordering::AcqRel`] and [`Ordering::Relaxed`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchg_acqrel_relaxed<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange` method by passing
-/// [`Ordering::AcqRel`] and [`Ordering::Acquire`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchg_acqrel_acquire<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange` method by passing
-/// [`Ordering::AcqRel`] and [`Ordering::SeqCst`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchg_acqrel_seqcst<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange` method by passing
-/// [`Ordering::SeqCst`] and [`Ordering::Relaxed`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchg_seqcst_relaxed<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange` method by passing
-/// [`Ordering::SeqCst`] and [`Ordering::Acquire`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchg_seqcst_acquire<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange` method by passing
-/// [`Ordering::SeqCst`] as both the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchg_seqcst_seqcst<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
+pub unsafe fn atomic_cxchg<
+ T: Copy,
+ const ORD_SUCC: AtomicOrdering,
+ const ORD_FAIL: AtomicOrdering,
+>(
+ dst: *mut T,
+ old: T,
+ src: T,
+) -> (T, bool);
/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
+/// `T` must be an integer or pointer type. The comparison may spuriously fail.
///
/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange_weak` method by passing
-/// [`Ordering::Relaxed`] as both the success and failure parameters.
+/// [`atomic`] types via the `compare_exchange_weak` method.
/// For example, [`AtomicBool::compare_exchange_weak`].
#[rustc_intrinsic]
#[rustc_nounwind]
-pub unsafe fn atomic_cxchgweak_relaxed_relaxed<T: Copy>(
+pub unsafe fn atomic_cxchgweak<
+ T: Copy,
+ const ORD_SUCC: AtomicOrdering,
+ const ORD_FAIL: AtomicOrdering,
+>(
_dst: *mut T,
_old: T,
_src: T,
) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange_weak` method by passing
-/// [`Ordering::Relaxed`] and [`Ordering::Acquire`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange_weak`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchgweak_relaxed_acquire<T: Copy>(
- _dst: *mut T,
- _old: T,
- _src: T,
-) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange_weak` method by passing
-/// [`Ordering::Relaxed`] and [`Ordering::SeqCst`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange_weak`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchgweak_relaxed_seqcst<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange_weak` method by passing
-/// [`Ordering::Acquire`] and [`Ordering::Relaxed`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange_weak`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchgweak_acquire_relaxed<T: Copy>(
- _dst: *mut T,
- _old: T,
- _src: T,
-) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange_weak` method by passing
-/// [`Ordering::Acquire`] as both the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange_weak`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchgweak_acquire_acquire<T: Copy>(
- _dst: *mut T,
- _old: T,
- _src: T,
-) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange_weak` method by passing
-/// [`Ordering::Acquire`] and [`Ordering::SeqCst`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange_weak`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchgweak_acquire_seqcst<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange_weak` method by passing
-/// [`Ordering::Release`] and [`Ordering::Relaxed`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange_weak`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchgweak_release_relaxed<T: Copy>(
- _dst: *mut T,
- _old: T,
- _src: T,
-) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange_weak` method by passing
-/// [`Ordering::Release`] and [`Ordering::Acquire`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange_weak`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchgweak_release_acquire<T: Copy>(
- _dst: *mut T,
- _old: T,
- _src: T,
-) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange_weak` method by passing
-/// [`Ordering::Release`] and [`Ordering::SeqCst`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange_weak`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchgweak_release_seqcst<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange_weak` method by passing
-/// [`Ordering::AcqRel`] and [`Ordering::Relaxed`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange_weak`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchgweak_acqrel_relaxed<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange_weak` method by passing
-/// [`Ordering::AcqRel`] and [`Ordering::Acquire`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange_weak`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchgweak_acqrel_acquire<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange_weak` method by passing
-/// [`Ordering::AcqRel`] and [`Ordering::SeqCst`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange_weak`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchgweak_acqrel_seqcst<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange_weak` method by passing
-/// [`Ordering::SeqCst`] and [`Ordering::Relaxed`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange_weak`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchgweak_seqcst_relaxed<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange_weak` method by passing
-/// [`Ordering::SeqCst`] and [`Ordering::Acquire`] as the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange_weak`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchgweak_seqcst_acquire<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
-/// Stores a value if the current value is the same as the `old` value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `compare_exchange_weak` method by passing
-/// [`Ordering::SeqCst`] as both the success and failure parameters.
-/// For example, [`AtomicBool::compare_exchange_weak`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_cxchgweak_seqcst_seqcst<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
/// Loads the current value of the pointer.
/// `T` must be an integer or pointer type.
@@ -419,75 +129,19 @@ pub unsafe fn atomic_cxchgweak_release_acquire<T: Copy>(
/// `T` must be an integer or pointer type.
///
/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `store` method by passing
-/// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::store`].
+/// [`atomic`] types via the `store` method. For example, [`AtomicBool::store`].
#[rustc_intrinsic]
#[rustc_nounwind]
-pub unsafe fn atomic_store_seqcst<T: Copy>(dst: *mut T, val: T);
-/// Stores the value at the specified memory location.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `store` method by passing
-/// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::store`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_store_release<T: Copy>(dst: *mut T, val: T);
-/// Stores the value at the specified memory location.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `store` method by passing
-/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::store`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_store_relaxed<T: Copy>(dst: *mut T, val: T);
+pub unsafe fn atomic_store<T: Copy, const ORD: AtomicOrdering>(dst: *mut T, val: T);
/// Stores the value at the specified memory location, returning the old value.
/// `T` must be an integer or pointer type.
///
/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `swap` method by passing
-/// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::swap`].
+/// [`atomic`] types via the `swap` method. For example, [`AtomicBool::swap`].
#[rustc_intrinsic]
#[rustc_nounwind]
-pub unsafe fn atomic_xchg_seqcst<T: Copy>(dst: *mut T, src: T) -> T;
-/// Stores the value at the specified memory location, returning the old value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `swap` method by passing
-/// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::swap`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_xchg_acquire<T: Copy>(dst: *mut T, src: T) -> T;
-/// Stores the value at the specified memory location, returning the old value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `swap` method by passing
-/// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::swap`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_xchg_release<T: Copy>(dst: *mut T, src: T) -> T;
-/// Stores the value at the specified memory location, returning the old value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `swap` method by passing
-/// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::swap`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_xchg_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
-/// Stores the value at the specified memory location, returning the old value.
-/// `T` must be an integer or pointer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `swap` method by passing
-/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::swap`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_xchg_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
+pub unsafe fn atomic_xchg<T: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
/// Adds to the current value, returning the previous value.
/// `T` must be an integer or pointer type.
@@ -495,55 +149,10 @@ pub unsafe fn atomic_cxchgweak_release_acquire<T: Copy>(
/// value stored at `*dst` will have the provenance of the old value stored there.
///
/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_add` method by passing
-/// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicIsize::fetch_add`].
+/// [`atomic`] types via the `fetch_add` method. For example, [`AtomicIsize::fetch_add`].
#[rustc_intrinsic]
#[rustc_nounwind]
-pub unsafe fn atomic_xadd_seqcst<T: Copy>(dst: *mut T, src: T) -> T;
-/// Adds to the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_add` method by passing
-/// [`Ordering::Acquire`] as the `order`. For example, [`AtomicIsize::fetch_add`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_xadd_acquire<T: Copy>(dst: *mut T, src: T) -> T;
-/// Adds to the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_add` method by passing
-/// [`Ordering::Release`] as the `order`. For example, [`AtomicIsize::fetch_add`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_xadd_release<T: Copy>(dst: *mut T, src: T) -> T;
-/// Adds to the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_add` method by passing
-/// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicIsize::fetch_add`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_xadd_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
-/// Adds to the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_add` method by passing
-/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicIsize::fetch_add`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_xadd_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
+pub unsafe fn atomic_xadd<T: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
/// Subtract from the current value, returning the previous value.
/// `T` must be an integer or pointer type.
@@ -551,55 +160,10 @@ pub unsafe fn atomic_cxchgweak_release_acquire<T: Copy>(
/// value stored at `*dst` will have the provenance of the old value stored there.
///
/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_sub` method by passing
-/// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicIsize::fetch_sub`].
+/// [`atomic`] types via the `fetch_sub` method. For example, [`AtomicIsize::fetch_sub`].
#[rustc_intrinsic]
#[rustc_nounwind]
-pub unsafe fn atomic_xsub_seqcst<T: Copy>(dst: *mut T, src: T) -> T;
-/// Subtract from the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_sub` method by passing
-/// [`Ordering::Acquire`] as the `order`. For example, [`AtomicIsize::fetch_sub`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_xsub_acquire<T: Copy>(dst: *mut T, src: T) -> T;
-/// Subtract from the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_sub` method by passing
-/// [`Ordering::Release`] as the `order`. For example, [`AtomicIsize::fetch_sub`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_xsub_release<T: Copy>(dst: *mut T, src: T) -> T;
-/// Subtract from the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_sub` method by passing
-/// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicIsize::fetch_sub`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_xsub_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
-/// Subtract from the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_sub` method by passing
-/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicIsize::fetch_sub`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_xsub_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
+pub unsafe fn atomic_xsub<T: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
/// Bitwise and with the current value, returning the previous value.
/// `T` must be an integer or pointer type.
@@ -607,55 +171,10 @@ pub unsafe fn atomic_cxchgweak_release_acquire<T: Copy>(
/// value stored at `*dst` will have the provenance of the old value stored there.
///
/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_and` method by passing
-/// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::fetch_and`].
+/// [`atomic`] types via the `fetch_and` method. For example, [`AtomicBool::fetch_and`].
#[rustc_intrinsic]
#[rustc_nounwind]
-pub unsafe fn atomic_and_seqcst<T: Copy>(dst: *mut T, src: T) -> T;
-/// Bitwise and with the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_and` method by passing
-/// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::fetch_and`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_and_acquire<T: Copy>(dst: *mut T, src: T) -> T;
-/// Bitwise and with the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_and` method by passing
-/// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::fetch_and`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_and_release<T: Copy>(dst: *mut T, src: T) -> T;
-/// Bitwise and with the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_and` method by passing
-/// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::fetch_and`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_and_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
-/// Bitwise and with the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_and` method by passing
-/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::fetch_and`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_and_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
+pub unsafe fn atomic_and<T: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
/// Bitwise nand with the current value, returning the previous value.
/// `T` must be an integer or pointer type.
@@ -663,55 +182,10 @@ pub unsafe fn atomic_cxchgweak_release_acquire<T: Copy>(
/// value stored at `*dst` will have the provenance of the old value stored there.
///
/// The stabilized version of this intrinsic is available on the
-/// [`AtomicBool`] type via the `fetch_nand` method by passing
-/// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::fetch_nand`].
+/// [`AtomicBool`] type via the `fetch_nand` method. For example, [`AtomicBool::fetch_nand`].
#[rustc_intrinsic]
#[rustc_nounwind]
-pub unsafe fn atomic_nand_seqcst<T: Copy>(dst: *mut T, src: T) -> T;
-/// Bitwise nand with the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`AtomicBool`] type via the `fetch_nand` method by passing
-/// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::fetch_nand`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_nand_acquire<T: Copy>(dst: *mut T, src: T) -> T;
-/// Bitwise nand with the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`AtomicBool`] type via the `fetch_nand` method by passing
-/// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::fetch_nand`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_nand_release<T: Copy>(dst: *mut T, src: T) -> T;
-/// Bitwise nand with the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`AtomicBool`] type via the `fetch_nand` method by passing
-/// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::fetch_nand`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_nand_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
-/// Bitwise nand with the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`AtomicBool`] type via the `fetch_nand` method by passing
-/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::fetch_nand`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_nand_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
+pub unsafe fn atomic_nand<T: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
/// Bitwise or with the current value, returning the previous value.
/// `T` must be an integer or pointer type.
@@ -719,55 +193,10 @@ pub unsafe fn atomic_cxchgweak_release_acquire<T: Copy>(
/// value stored at `*dst` will have the provenance of the old value stored there.
///
/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_or` method by passing
-/// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::fetch_or`].
+/// [`atomic`] types via the `fetch_or` method. For example, [`AtomicBool::fetch_or`].
#[rustc_intrinsic]
#[rustc_nounwind]
-pub unsafe fn atomic_or_seqcst<T: Copy>(dst: *mut T, src: T) -> T;
-/// Bitwise or with the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_or` method by passing
-/// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::fetch_or`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_or_acquire<T: Copy>(dst: *mut T, src: T) -> T;
-/// Bitwise or with the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_or` method by passing
-/// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::fetch_or`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_or_release<T: Copy>(dst: *mut T, src: T) -> T;
-/// Bitwise or with the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_or` method by passing
-/// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::fetch_or`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_or_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
-/// Bitwise or with the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_or` method by passing
-/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::fetch_or`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_or_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
+pub unsafe fn atomic_or<T: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
/// Bitwise xor with the current value, returning the previous value.
/// `T` must be an integer or pointer type.
@@ -775,325 +204,62 @@ pub unsafe fn atomic_cxchgweak_release_acquire<T: Copy>(
/// value stored at `*dst` will have the provenance of the old value stored there.
///
/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_xor` method by passing
-/// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::fetch_xor`].
+/// [`atomic`] types via the `fetch_xor` method. For example, [`AtomicBool::fetch_xor`].
#[rustc_intrinsic]
#[rustc_nounwind]
-pub unsafe fn atomic_xor_seqcst<T: Copy>(dst: *mut T, src: T) -> T;
-/// Bitwise xor with the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_xor` method by passing
-/// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::fetch_xor`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_xor_acquire<T: Copy>(dst: *mut T, src: T) -> T;
-/// Bitwise xor with the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_xor` method by passing
-/// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::fetch_xor`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_xor_release<T: Copy>(dst: *mut T, src: T) -> T;
-/// Bitwise xor with the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_xor` method by passing
-/// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::fetch_xor`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_xor_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
-/// Bitwise xor with the current value, returning the previous value.
-/// `T` must be an integer or pointer type.
-/// If `T` is a pointer type, the provenance of `src` is ignored: both the return value and the new
-/// value stored at `*dst` will have the provenance of the old value stored there.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] types via the `fetch_xor` method by passing
-/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::fetch_xor`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_xor_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
+pub unsafe fn atomic_xor<T: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
/// Maximum with the current value using a signed comparison.
/// `T` must be a signed integer type.
///
/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] signed integer types via the `fetch_max` method by passing
-/// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicI32::fetch_max`].
+/// [`atomic`] signed integer types via the `fetch_max` method. For example, [`AtomicI32::fetch_max`].
#[rustc_intrinsic]
#[rustc_nounwind]
-pub unsafe fn atomic_max_seqcst<T: Copy>(dst: *mut T, src: T) -> T;
-/// Maximum with the current value using a signed comparison.
-/// `T` must be a signed integer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] signed integer types via the `fetch_max` method by passing
-/// [`Ordering::Acquire`] as the `order`. For example, [`AtomicI32::fetch_max`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_max_acquire<T: Copy>(dst: *mut T, src: T) -> T;
-/// Maximum with the current value using a signed comparison.
-/// `T` must be a signed integer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] signed integer types via the `fetch_max` method by passing
-/// [`Ordering::Release`] as the `order`. For example, [`AtomicI32::fetch_max`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_max_release<T: Copy>(dst: *mut T, src: T) -> T;
-/// Maximum with the current value using a signed comparison.
-/// `T` must be a signed integer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] signed integer types via the `fetch_max` method by passing
-/// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicI32::fetch_max`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_max_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
-/// Maximum with the current value using a signed comparison.
-/// `T` must be a signed integer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] signed integer types via the `fetch_max` method by passing
-/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicI32::fetch_max`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_max_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
+pub unsafe fn atomic_max<T: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
/// Minimum with the current value using a signed comparison.
/// `T` must be a signed integer type.
///
/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] signed integer types via the `fetch_min` method by passing
-/// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicI32::fetch_min`].
+/// [`atomic`] signed integer types via the `fetch_min` method. For example, [`AtomicI32::fetch_min`].
#[rustc_intrinsic]
#[rustc_nounwind]
-pub unsafe fn atomic_min_seqcst<T: Copy>(dst: *mut T, src: T) -> T;
-/// Minimum with the current value using a signed comparison.
-/// `T` must be a signed integer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] signed integer types via the `fetch_min` method by passing
-/// [`Ordering::Acquire`] as the `order`. For example, [`AtomicI32::fetch_min`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_min_acquire<T: Copy>(dst: *mut T, src: T) -> T;
-/// Minimum with the current value using a signed comparison.
-/// `T` must be a signed integer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] signed integer types via the `fetch_min` method by passing
-/// [`Ordering::Release`] as the `order`. For example, [`AtomicI32::fetch_min`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_min_release<T: Copy>(dst: *mut T, src: T) -> T;
-/// Minimum with the current value using a signed comparison.
-/// `T` must be a signed integer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] signed integer types via the `fetch_min` method by passing
-/// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicI32::fetch_min`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_min_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
-/// Minimum with the current value using a signed comparison.
-/// `T` must be a signed integer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] signed integer types via the `fetch_min` method by passing
-/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicI32::fetch_min`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_min_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
+pub unsafe fn atomic_min<T: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
/// Minimum with the current value using an unsigned comparison.
/// `T` must be an unsigned integer type.
///
/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] unsigned integer types via the `fetch_min` method by passing
-/// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicU32::fetch_min`].
+/// [`atomic`] unsigned integer types via the `fetch_min` method. For example, [`AtomicU32::fetch_min`].
#[rustc_intrinsic]
#[rustc_nounwind]
-pub unsafe fn atomic_umin_seqcst<T: Copy>(dst: *mut T, src: T) -> T;
-/// Minimum with the current value using an unsigned comparison.
-/// `T` must be an unsigned integer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] unsigned integer types via the `fetch_min` method by passing
-/// [`Ordering::Acquire`] as the `order`. For example, [`AtomicU32::fetch_min`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_umin_acquire<T: Copy>(dst: *mut T, src: T) -> T;
-/// Minimum with the current value using an unsigned comparison.
-/// `T` must be an unsigned integer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] unsigned integer types via the `fetch_min` method by passing
-/// [`Ordering::Release`] as the `order`. For example, [`AtomicU32::fetch_min`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_umin_release<T: Copy>(dst: *mut T, src: T) -> T;
-/// Minimum with the current value using an unsigned comparison.
-/// `T` must be an unsigned integer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] unsigned integer types via the `fetch_min` method by passing
-/// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicU32::fetch_min`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_umin_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
-/// Minimum with the current value using an unsigned comparison.
-/// `T` must be an unsigned integer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] unsigned integer types via the `fetch_min` method by passing
-/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicU32::fetch_min`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_umin_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
+pub unsafe fn atomic_umin<T: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
/// Maximum with the current value using an unsigned comparison.
/// `T` must be an unsigned integer type.
///
/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] unsigned integer types via the `fetch_max` method by passing
-/// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicU32::fetch_max`].
+/// [`atomic`] unsigned integer types via the `fetch_max` method. For example, [`AtomicU32::fetch_max`].
#[rustc_intrinsic]
#[rustc_nounwind]
-pub unsafe fn atomic_umax_seqcst<T: Copy>(dst: *mut T, src: T) -> T;
-/// Maximum with the current value using an unsigned comparison.
-/// `T` must be an unsigned integer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] unsigned integer types via the `fetch_max` method by passing
-/// [`Ordering::Acquire`] as the `order`. For example, [`AtomicU32::fetch_max`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_umax_acquire<T: Copy>(dst: *mut T, src: T) -> T;
-/// Maximum with the current value using an unsigned comparison.
-/// `T` must be an unsigned integer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] unsigned integer types via the `fetch_max` method by passing
-/// [`Ordering::Release`] as the `order`. For example, [`AtomicU32::fetch_max`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_umax_release<T: Copy>(dst: *mut T, src: T) -> T;
-/// Maximum with the current value using an unsigned comparison.
-/// `T` must be an unsigned integer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] unsigned integer types via the `fetch_max` method by passing
-/// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicU32::fetch_max`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_umax_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
-/// Maximum with the current value using an unsigned comparison.
-/// `T` must be an unsigned integer type.
-///
-/// The stabilized version of this intrinsic is available on the
-/// [`atomic`] unsigned integer types via the `fetch_max` method by passing
-/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicU32::fetch_max`].
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_umax_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
+pub unsafe fn atomic_umax<T: Copy, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
/// An atomic fence.
///
/// The stabilized version of this intrinsic is available in
-/// [`atomic::fence`] by passing [`Ordering::SeqCst`]
-/// as the `order`.
+/// [`atomic::fence`].
#[rustc_intrinsic]
#[rustc_nounwind]
-pub unsafe fn atomic_fence_seqcst();
-/// An atomic fence.
-///
-/// The stabilized version of this intrinsic is available in
-/// [`atomic::fence`] by passing [`Ordering::Acquire`]
-/// as the `order`.
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_fence_acquire();
-/// An atomic fence.
-///
-/// The stabilized version of this intrinsic is available in
-/// [`atomic::fence`] by passing [`Ordering::Release`]
-/// as the `order`.
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_fence_release();
-/// An atomic fence.
-///
-/// The stabilized version of this intrinsic is available in
-/// [`atomic::fence`] by passing [`Ordering::AcqRel`]
-/// as the `order`.
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_fence_acqrel();
+pub unsafe fn atomic_fence<const ORD: AtomicOrdering>();
-/// A compiler-only memory barrier.
-///
-/// Memory accesses will never be reordered across this barrier by the
-/// compiler, but no instructions will be emitted for it. This is
-/// appropriate for operations on the same thread that may be preempted,
-/// such as when interacting with signal handlers.
+/// An atomic fence for synchronization within a single thread.
///
/// The stabilized version of this intrinsic is available in
-/// [`atomic::compiler_fence`] by passing [`Ordering::SeqCst`]
-/// as the `order`.
+/// [`atomic::compiler_fence`].
#[rustc_intrinsic]
#[rustc_nounwind]
-pub unsafe fn atomic_singlethreadfence_seqcst();
-/// A compiler-only memory barrier.
-///
-/// Memory accesses will never be reordered across this barrier by the
-/// compiler, but no instructions will be emitted for it. This is
-/// appropriate for operations on the same thread that may be preempted,
-/// such as when interacting with signal handlers.
-///
-/// The stabilized version of this intrinsic is available in
-/// [`atomic::compiler_fence`] by passing [`Ordering::Acquire`]
-/// as the `order`.
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_singlethreadfence_acquire();
-/// A compiler-only memory barrier.
-///
-/// Memory accesses will never be reordered across this barrier by the
-/// compiler, but no instructions will be emitted for it. This is
-/// appropriate for operations on the same thread that may be preempted,
-/// such as when interacting with signal handlers.
-///
-/// The stabilized version of this intrinsic is available in
-/// [`atomic::compiler_fence`] by passing [`Ordering::Release`]
-/// as the `order`.
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_singlethreadfence_release();
-/// A compiler-only memory barrier.
-///
-/// Memory accesses will never be reordered across this barrier by the
-/// compiler, but no instructions will be emitted for it. This is
-/// appropriate for operations on the same thread that may be preempted,
-/// such as when interacting with signal handlers.
-///
-/// The stabilized version of this intrinsic is available in
-/// [`atomic::compiler_fence`] by passing [`Ordering::AcqRel`]
-/// as the `order`.
-#[rustc_intrinsic]
-#[rustc_nounwind]
-pub unsafe fn atomic_singlethreadfence_acqrel();
+pub unsafe fn atomic_singlethreadfence<const ORD: AtomicOrdering>();
/// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction
/// if supported; otherwise, it is a no-op.
@@ -3485,15 +2651,6 @@ pub const fn contract_check_ensures<C: Fn(&Ret) -> bool + Copy, Ret>(cond: C, re
#[rustc_intrinsic]
pub const fn min_align_of<T>() -> usize;
-/// The preferred alignment of a type.
-///
-/// This intrinsic does not have a stable counterpart.
-/// It's "tracking issue" is [#91971](https://github.com/rust-lang/rust/issues/91971).
-#[rustc_nounwind]
-#[unstable(feature = "core_intrinsics", issue = "none")]
-#[rustc_intrinsic]
-pub const unsafe fn pref_align_of<T>() -> usize;
-
/// Returns the number of variants of the type `T` cast to a `usize`;
/// if `T` has no variants, returns `0`. Uninhabited variants will be counted.
///
diff --git a/library/core/src/iter/sources/generator.rs b/library/core/src/iter/sources/generator.rs
index 155fa93..0846974 100644
--- a/library/core/src/iter/sources/generator.rs
+++ b/library/core/src/iter/sources/generator.rs
@@ -20,7 +20,7 @@
/// ```
#[unstable(feature = "iter_macro", issue = "none", reason = "generators are unstable")]
#[allow_internal_unstable(coroutines, iter_from_coroutine)]
-#[cfg_attr(not(bootstrap), rustc_builtin_macro)]
+#[rustc_builtin_macro]
pub macro iter($($t:tt)*) {
/* compiler-builtin */
}
diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
index f2a5c40..8885583 100644
--- a/library/core/src/lib.rs
+++ b/library/core/src/lib.rs
@@ -190,14 +190,12 @@
#![feature(aarch64_unstable_target_feature)]
#![feature(arm_target_feature)]
#![feature(hexagon_target_feature)]
-#![feature(keylocker_x86)]
#![feature(loongarch_target_feature)]
#![feature(mips_target_feature)]
#![feature(powerpc_target_feature)]
#![feature(riscv_target_feature)]
#![feature(rtm_target_feature)]
#![feature(s390x_target_feature)]
-#![feature(sha512_sm_x86)]
#![feature(sse4a_target_feature)]
#![feature(tbm_target_feature)]
#![feature(wasm_target_feature)]
diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs
index d5efb03..b21845a 100644
--- a/library/core/src/macros/mod.rs
+++ b/library/core/src/macros/mod.rs
@@ -1273,6 +1273,19 @@ macro_rules! column {
/// first macro invocation leading up to the invocation of the `file!`
/// macro.
///
+ /// The file name is derived from the crate root's source path passed to the Rust compiler
+ /// and the sequence the compiler takes to get from the crate root to the
+ /// module containing `file!`, modified by any flags passed to the Rust compiler (e.g.
+ /// `--remap-path-prefix`). If the crate's source path is relative, the initial base
+ /// directory will be the working directory of the Rust compiler. For example, if the source
+ /// path passed to the compiler is `./src/lib.rs` which has a `mod foo;` with a source path of
+ /// `src/foo/mod.rs`, then calling `file!` inside `mod foo;` will return `./src/foo/mod.rs`.
+ ///
+ /// Future compiler options might make further changes to the behavior of `file!`,
+ /// including potentially making it entirely empty. Code (e.g. test libraries)
+ /// relying on `file!` producing an openable file path would be incompatible
+ /// with such options, and might wish to recommend not using those options.
+ ///
/// # Examples
///
/// ```
diff --git a/library/core/src/num/f128.rs b/library/core/src/num/f128.rs
index 58de62a..4c09c93 100644
--- a/library/core/src/num/f128.rs
+++ b/library/core/src/num/f128.rs
@@ -1422,6 +1422,7 @@ pub const fn algebraic_rem(self, rhs: f128) -> f128 {
// due to https://github.com/llvm/llvm-project/issues/44744. aarch64 linux matches this.
// #[unstable(feature = "core_float_math", issue = "137578")]
#[cfg(not(test))]
+#[doc(test(attr(feature(cfg_target_has_reliable_f16_f128), expect(internal_features))))]
impl f128 {
/// Returns the largest integer less than or equal to `self`.
///
@@ -1431,8 +1432,6 @@ impl f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -1464,8 +1463,6 @@ pub const fn floor(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -1497,8 +1494,6 @@ pub const fn ceil(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -1535,8 +1530,6 @@ pub const fn round(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -1570,8 +1563,6 @@ pub const fn round_ties_even(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -1604,8 +1595,6 @@ pub const fn trunc(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -1646,8 +1635,6 @@ pub const fn fract(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -1694,8 +1681,6 @@ pub fn mul_add(self, a: f128, b: f128) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -1739,8 +1724,6 @@ pub fn div_euclid(self, rhs: f128) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -1779,8 +1762,6 @@ pub fn rem_euclid(self, rhs: f128) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -1814,8 +1795,6 @@ pub fn powi(self, n: i32) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
diff --git a/library/core/src/num/f16.rs b/library/core/src/num/f16.rs
index 45f402d..1d98a48 100644
--- a/library/core/src/num/f16.rs
+++ b/library/core/src/num/f16.rs
@@ -1398,6 +1398,7 @@ pub const fn algebraic_rem(self, rhs: f16) -> f16 {
// Functions in this module fall into `core_float_math`
// #[unstable(feature = "core_float_math", issue = "137578")]
#[cfg(not(test))]
+#[doc(test(attr(feature(cfg_target_has_reliable_f16_f128), expect(internal_features))))]
impl f16 {
/// Returns the largest integer less than or equal to `self`.
///
@@ -1407,8 +1408,6 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -1440,8 +1439,6 @@ pub const fn floor(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -1473,8 +1470,6 @@ pub const fn ceil(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -1511,8 +1506,6 @@ pub const fn round(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -1546,8 +1539,6 @@ pub const fn round_ties_even(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -1580,8 +1571,6 @@ pub const fn trunc(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -1622,8 +1611,6 @@ pub const fn fract(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -1670,8 +1657,6 @@ pub fn mul_add(self, a: f16, b: f16) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -1715,8 +1700,6 @@ pub fn div_euclid(self, rhs: f16) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -1755,8 +1738,6 @@ pub fn rem_euclid(self, rhs: f16) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -1790,8 +1771,6 @@ pub fn powi(self, n: i32) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -1828,8 +1807,6 @@ pub fn sqrt(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs
index bf923d4..b460c7d 100644
--- a/library/core/src/num/f32.rs
+++ b/library/core/src/num/f32.rs
@@ -1879,7 +1879,7 @@ pub fn rem_euclid(x: f32, rhs: f32) -> f32 {
///
/// let x = 2.0_f32;
/// let abs_difference = (f32::math::powi(x, 2) - (x * x)).abs();
- /// assert!(abs_difference <= f32::EPSILON);
+ /// assert!(abs_difference <= 1e-5);
///
/// assert_eq!(f32::math::powi(f32::NAN, 0), 1.0);
/// ```
diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs
index be933cf..2f10e6d 100644
--- a/library/core/src/num/f64.rs
+++ b/library/core/src/num/f64.rs
@@ -1877,7 +1877,7 @@ pub fn rem_euclid(x: f64, rhs: f64) -> f64 {
///
/// let x = 2.0_f64;
/// let abs_difference = (f64::math::powi(x, 2) - (x * x)).abs();
- /// assert!(abs_difference <= f64::EPSILON);
+ /// assert!(abs_difference <= 1e-6);
///
/// assert_eq!(f64::math::powi(f64::NAN, 0), 1.0);
/// ```
diff --git a/library/core/src/num/niche_types.rs b/library/core/src/num/niche_types.rs
index 47ff425..b92561c 100644
--- a/library/core/src/num/niche_types.rs
+++ b/library/core/src/num/niche_types.rs
@@ -131,6 +131,8 @@ fn default() -> Self {
pub struct NonZeroI32Inner(i32 as u32 in 1..=0xffff_ffff);
pub struct NonZeroI64Inner(i64 as u64 in 1..=0xffffffff_ffffffff);
pub struct NonZeroI128Inner(i128 as u128 in 1..=0xffffffffffffffff_ffffffffffffffff);
+
+ pub struct NonZeroCharInner(char as u32 in 1..=0x10ffff);
}
#[cfg(target_pointer_width = "16")]
diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs
index 511807b..0fa066c 100644
--- a/library/core/src/num/nonzero.rs
+++ b/library/core/src/num/nonzero.rs
@@ -79,6 +79,7 @@ unsafe impl ZeroablePrimitive for $primitive {
NonZeroI64Inner(i64),
NonZeroI128Inner(i128),
NonZeroIsizeInner(isize),
+ NonZeroCharInner(char),
);
/// A value that is known not to equal zero.
diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs
index 5f82e6a..4ee0e73 100644
--- a/library/core/src/num/uint_macros.rs
+++ b/library/core/src/num/uint_macros.rs
@@ -213,6 +213,30 @@ pub const fn trailing_ones(self) -> u32 {
(!self).trailing_zeros()
}
+ /// Returns the minimum number of bits required to represent `self`.
+ ///
+ /// This method returns zero if `self` is zero.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(uint_bit_width)]
+ ///
+ #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".bit_width(), 0);")]
+ #[doc = concat!("assert_eq!(0b111_", stringify!($SelfT), ".bit_width(), 3);")]
+ #[doc = concat!("assert_eq!(0b1110_", stringify!($SelfT), ".bit_width(), 4);")]
+ #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.bit_width(), ", stringify!($BITS), ");")]
+ /// ```
+ #[unstable(feature = "uint_bit_width", issue = "142326")]
+ #[must_use = "this returns the result of the operation, \
+ without modifying the original"]
+ #[inline(always)]
+ pub const fn bit_width(self) -> u32 {
+ Self::BITS - self.leading_zeros()
+ }
+
/// Returns `self` with only the most significant bit set, or `0` if
/// the input is `0`.
///
diff --git a/library/core/src/pin/unsafe_pinned.rs b/library/core/src/pin/unsafe_pinned.rs
index dbcceb8..17f7bcd 100644
--- a/library/core/src/pin/unsafe_pinned.rs
+++ b/library/core/src/pin/unsafe_pinned.rs
@@ -86,13 +86,12 @@ pub const fn get_mut_unchecked(&mut self) -> *mut T {
ptr::from_mut(self) as *mut T
}
- /// Get read-only access to the contents of a shared `UnsafePinned`.
+ /// Get mutable access to the contents of a shared `UnsafePinned`.
///
- /// Note that `&UnsafePinned<T>` is read-only if `&T` is read-only. This means that if there is
- /// mutation of the `T`, future reads from the `*const T` returned here are UB! Use
- /// [`UnsafeCell`] if you also need interior mutability.
+ /// This can be cast to a pointer of any kind. When creating references, you must uphold the
+ /// aliasing rules; see [`UnsafeCell`] for more discussion and caveats.
///
- /// [`UnsafeCell`]: crate::cell::UnsafeCell
+ /// [`UnsafeCell`]: crate::cell::UnsafeCell#aliasing-rules
///
/// ```rust,no_run
/// #![feature(unsafe_pinned)]
@@ -100,16 +99,16 @@ pub const fn get_mut_unchecked(&mut self) -> *mut T {
///
/// unsafe {
/// let mut x = UnsafePinned::new(0);
- /// let ptr = x.get(); // read-only pointer, assumes immutability
+ /// let ptr = x.get();
/// x.get_mut_unchecked().write(1);
- /// ptr.read(); // UB!
+ /// assert_eq!(ptr.read(), 1);
/// }
/// ```
#[inline(always)]
#[must_use]
#[unstable(feature = "unsafe_pinned", issue = "125735")]
- pub const fn get(&self) -> *const T {
- ptr::from_ref(self) as *const T
+ pub const fn get(&self) -> *mut T {
+ self.value.get()
}
/// Gets an immutable pointer to the wrapped value.
diff --git a/library/core/src/ptr/const_ptr.rs b/library/core/src/ptr/const_ptr.rs
index a1dab23..9366cb3 100644
--- a/library/core/src/ptr/const_ptr.rs
+++ b/library/core/src/ptr/const_ptr.rs
@@ -5,24 +5,7 @@
use crate::slice::{self, SliceIndex};
impl<T: ?Sized> *const T {
- /// Returns `true` if the pointer is null.
- ///
- /// Note that unsized types have many possible null pointers, as only the
- /// raw data pointer is considered, not their length, vtable, etc.
- /// Therefore, two pointers that are null may still not compare equal to
- /// each other.
- ///
- /// # Panics during const evaluation
- ///
- /// If this method is used during const evaluation, and `self` is a pointer
- /// that is offset beyond the bounds of the memory it initially pointed to,
- /// then there might not be enough information to determine whether the
- /// pointer is null. This is because the absolute address in memory is not
- /// known at compile time. If the nullness of the pointer cannot be
- /// determined, this method will panic.
- ///
- /// In-bounds pointers are never null, so the method will never panic for
- /// such pointers.
+ #[doc = include_str!("docs/is_null.md")]
///
/// # Examples
///
@@ -1550,50 +1533,7 @@ pub unsafe fn get_unchecked<I>(self, index: I) -> *const I::Output
unsafe { index.get_unchecked(self) }
}
- /// Returns `None` if the pointer is null, or else returns a shared slice to
- /// the value wrapped in `Some`. In contrast to [`as_ref`], this does not require
- /// that the value has to be initialized.
- ///
- /// [`as_ref`]: #method.as_ref
- ///
- /// # Safety
- ///
- /// When calling this method, you have to ensure that *either* the pointer is null *or*
- /// all of the following is true:
- ///
- /// * The pointer must be [valid] for reads for `ptr.len() * size_of::<T>()` many bytes,
- /// and it must be properly aligned. This means in particular:
- ///
- /// * The entire memory range of this slice must be contained within a single [allocation]!
- /// Slices can never span across multiple allocations.
- ///
- /// * The pointer must be aligned even for zero-length slices. One
- /// reason for this is that enum layout optimizations may rely on references
- /// (including slices of any length) being aligned and non-null to distinguish
- /// them from other data. You can obtain a pointer that is usable as `data`
- /// for zero-length slices using [`NonNull::dangling()`].
- ///
- /// * The total size `ptr.len() * size_of::<T>()` of the slice must be no larger than `isize::MAX`.
- /// See the safety documentation of [`pointer::offset`].
- ///
- /// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
- /// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
- /// In particular, while this reference exists, the memory the pointer points to must
- /// not get mutated (except inside `UnsafeCell`).
- ///
- /// This applies even if the result of this method is unused!
- ///
- /// See also [`slice::from_raw_parts`][].
- ///
- /// [valid]: crate::ptr#safety
- /// [allocation]: crate::ptr#allocation
- ///
- /// # Panics during const evaluation
- ///
- /// This method will panic during const evaluation if the pointer cannot be
- /// determined to be null or not. See [`is_null`] for more information.
- ///
- /// [`is_null`]: #method.is_null
+ #[doc = include_str!("docs/as_uninit_slice.md")]
#[inline]
#[unstable(feature = "ptr_as_uninit", issue = "75402")]
pub const unsafe fn as_uninit_slice<'a>(self) -> Option<&'a [MaybeUninit<T>]> {
diff --git a/library/core/src/ptr/docs/as_uninit_slice.md b/library/core/src/ptr/docs/as_uninit_slice.md
new file mode 100644
index 0000000..c80c040
--- /dev/null
+++ b/library/core/src/ptr/docs/as_uninit_slice.md
@@ -0,0 +1,44 @@
+Returns `None` if the pointer is null, or else returns a shared slice to
+the value wrapped in `Some`. In contrast to [`as_ref`], this does not require
+that the value has to be initialized.
+
+[`as_ref`]: #method.as_ref
+
+# Safety
+
+When calling this method, you have to ensure that *either* the pointer is null *or*
+all of the following is true:
+
+* The pointer must be [valid] for reads for `ptr.len() * size_of::<T>()` many bytes,
+and it must be properly aligned. This means in particular:
+
+* The entire memory range of this slice must be contained within a single [allocation]!
+Slices can never span across multiple allocations.
+
+* The pointer must be aligned even for zero-length slices. One
+reason for this is that enum layout optimizations may rely on references
+(including slices of any length) being aligned and non-null to distinguish
+them from other data. You can obtain a pointer that is usable as `data`
+for zero-length slices using [`NonNull::dangling()`].
+
+* The total size `ptr.len() * size_of::<T>()` of the slice must be no larger than `isize::MAX`.
+See the safety documentation of [`pointer::offset`].
+
+* You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
+arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
+In particular, while this reference exists, the memory the pointer points to must
+not get mutated (except inside `UnsafeCell`).
+
+This applies even if the result of this method is unused!
+
+See also [`slice::from_raw_parts`][].
+
+[valid]: crate::ptr#safety
+[allocation]: crate::ptr#allocation
+
+# Panics during const evaluation
+
+This method will panic during const evaluation if the pointer cannot be
+determined to be null or not. See [`is_null`] for more information.
+
+[`is_null`]: #method.is_null
diff --git a/library/core/src/ptr/docs/is_null.md b/library/core/src/ptr/docs/is_null.md
new file mode 100644
index 0000000..7368ab9
--- /dev/null
+++ b/library/core/src/ptr/docs/is_null.md
@@ -0,0 +1,18 @@
+Returns `true` if the pointer is null.
+
+Note that unsized types have many possible null pointers, as only the
+raw data pointer is considered, not their length, vtable, etc.
+Therefore, two pointers that are null may still not compare equal to
+each other.
+
+# Panics during const evaluation
+
+If this method is used during const evaluation, and `self` is a pointer
+that is offset beyond the bounds of the memory it initially pointed to,
+then there might not be enough information to determine whether the
+pointer is null. This is because the absolute address in memory is not
+known at compile time. If the nullness of the pointer cannot be
+determined, this method will panic.
+
+In-bounds pointers are never null, so the method will never panic for
+such pointers.
diff --git a/library/core/src/ptr/mut_ptr.rs b/library/core/src/ptr/mut_ptr.rs
index 968f033..efe1031 100644
--- a/library/core/src/ptr/mut_ptr.rs
+++ b/library/core/src/ptr/mut_ptr.rs
@@ -5,24 +5,7 @@
use crate::slice::{self, SliceIndex};
impl<T: ?Sized> *mut T {
- /// Returns `true` if the pointer is null.
- ///
- /// Note that unsized types have many possible null pointers, as only the
- /// raw data pointer is considered, not their length, vtable, etc.
- /// Therefore, two pointers that are null may still not compare equal to
- /// each other.
- ///
- /// # Panics during const evaluation
- ///
- /// If this method is used during const evaluation, and `self` is a pointer
- /// that is offset beyond the bounds of the memory it initially pointed to,
- /// then there might not be enough information to determine whether the
- /// pointer is null. This is because the absolute address in memory is not
- /// known at compile time. If the nullness of the pointer cannot be
- /// determined, this method will panic.
- ///
- /// In-bounds pointers are never null, so the method will never panic for
- /// such pointers.
+ #[doc = include_str!("docs/is_null.md")]
///
/// # Examples
///
@@ -1906,53 +1889,10 @@ pub unsafe fn get_unchecked_mut<I>(self, index: I) -> *mut I::Output
unsafe { index.get_unchecked_mut(self) }
}
- /// Returns `None` if the pointer is null, or else returns a shared slice to
- /// the value wrapped in `Some`. In contrast to [`as_ref`], this does not require
- /// that the value has to be initialized.
+ #[doc = include_str!("docs/as_uninit_slice.md")]
///
- /// For the mutable counterpart see [`as_uninit_slice_mut`].
- ///
- /// [`as_ref`]: pointer#method.as_ref-1
- /// [`as_uninit_slice_mut`]: #method.as_uninit_slice_mut
- ///
- /// # Safety
- ///
- /// When calling this method, you have to ensure that *either* the pointer is null *or*
- /// all of the following is true:
- ///
- /// * The pointer must be [valid] for reads for `ptr.len() * size_of::<T>()` many bytes,
- /// and it must be properly aligned. This means in particular:
- ///
- /// * The entire memory range of this slice must be contained within a single [allocation]!
- /// Slices can never span across multiple allocations.
- ///
- /// * The pointer must be aligned even for zero-length slices. One
- /// reason for this is that enum layout optimizations may rely on references
- /// (including slices of any length) being aligned and non-null to distinguish
- /// them from other data. You can obtain a pointer that is usable as `data`
- /// for zero-length slices using [`NonNull::dangling()`].
- ///
- /// * The total size `ptr.len() * size_of::<T>()` of the slice must be no larger than `isize::MAX`.
- /// See the safety documentation of [`pointer::offset`].
- ///
- /// * You must enforce Rust's aliasing rules, since the returned lifetime `'a` is
- /// arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.
- /// In particular, while this reference exists, the memory the pointer points to must
- /// not get mutated (except inside `UnsafeCell`).
- ///
- /// This applies even if the result of this method is unused!
- ///
- /// See also [`slice::from_raw_parts`][].
- ///
- /// [valid]: crate::ptr#safety
- /// [allocation]: crate::ptr#allocation
- ///
- /// # Panics during const evaluation
- ///
- /// This method will panic during const evaluation if the pointer cannot be
- /// determined to be null or not. See [`is_null`] for more information.
- ///
- /// [`is_null`]: #method.is_null-1
+ /// # See Also
+ /// For the mutable counterpart see [`as_uninit_slice_mut`](pointer::as_uninit_slice_mut).
#[inline]
#[unstable(feature = "ptr_as_uninit", issue = "75402")]
pub const unsafe fn as_uninit_slice<'a>(self) -> Option<&'a [MaybeUninit<T>]> {
diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs
index 91b8d1b..1fae5b8 100644
--- a/library/core/src/ptr/non_null.rs
+++ b/library/core/src/ptr/non_null.rs
@@ -89,7 +89,8 @@ impl<T: Sized> NonNull<T> {
/// For more details, see the equivalent method on a raw pointer, [`ptr::without_provenance_mut`].
///
/// This is a [Strict Provenance][crate::ptr#strict-provenance] API.
- #[unstable(feature = "nonnull_provenance", issue = "135243")]
+ #[stable(feature = "nonnull_provenance", since = "CURRENT_RUSTC_VERSION")]
+ #[rustc_const_stable(feature = "nonnull_provenance", since = "CURRENT_RUSTC_VERSION")]
#[must_use]
#[inline]
pub const fn without_provenance(addr: NonZero<usize>) -> Self {
@@ -132,7 +133,7 @@ pub const fn dangling() -> Self {
/// For more details, see the equivalent method on a raw pointer, [`ptr::with_exposed_provenance_mut`].
///
/// This is an [Exposed Provenance][crate::ptr#exposed-provenance] API.
- #[unstable(feature = "nonnull_provenance", issue = "135243")]
+ #[stable(feature = "nonnull_provenance", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub fn with_exposed_provenance(addr: NonZero<usize>) -> Self {
// SAFETY: we know `addr` is non-zero.
@@ -329,7 +330,7 @@ pub fn addr(self) -> NonZero<usize> {
/// For more details, see the equivalent method on a raw pointer, [`pointer::expose_provenance`].
///
/// This is an [Exposed Provenance][crate::ptr#exposed-provenance] API.
- #[unstable(feature = "nonnull_provenance", issue = "135243")]
+ #[stable(feature = "nonnull_provenance", since = "CURRENT_RUSTC_VERSION")]
pub fn expose_provenance(self) -> NonZero<usize> {
// SAFETY: The pointer is guaranteed by the type to be non-null,
// meaning that the address will be non-zero.
diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs
index 4f7e144..c26bbad 100644
--- a/library/core/src/slice/mod.rs
+++ b/library/core/src/slice/mod.rs
@@ -21,6 +21,7 @@
issue = "none",
reason = "exposed from core to be reused in std; use the memchr crate"
)]
+#[doc(hidden)]
/// Pure Rust memchr implementation, taken from rust-memchr
pub mod memchr;
diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs
index ea459f6..4f9f293 100644
--- a/library/core/src/sync/atomic.rs
+++ b/library/core/src/sync/atomic.rs
@@ -178,7 +178,7 @@
//!
//! | `target_arch` | Size limit |
//! |---------------|---------|
-//! | `x86`, `arm`, `mips`, `mips32r6`, `powerpc`, `riscv32`, `sparc`, `hexagon` | 4 bytes |
+//! | `x86`, `arm`, `loongarch32`, `mips`, `mips32r6`, `powerpc`, `riscv32`, `sparc`, `hexagon` | 4 bytes |
//! | `x86_64`, `aarch64`, `loongarch64`, `mips64`, `mips64r6`, `powerpc64`, `riscv64`, `sparc64`, `s390x` | 8 bytes |
//!
//! Atomics loads that are larger than this limit as well as atomic loads with ordering other
@@ -245,6 +245,7 @@
use self::Ordering::*;
use crate::cell::UnsafeCell;
use crate::hint::spin_loop;
+use crate::intrinsics::AtomicOrdering as AO;
use crate::{fmt, intrinsics};
trait Sealed {}
@@ -349,8 +350,12 @@ unsafe impl $(<$T>)? AtomicPrimitive for $Primitive {
// This list should only contain architectures which have word-sized atomic-or/
// atomic-and instructions but don't natively support byte-sized atomics.
#[cfg(target_has_atomic = "8")]
-const EMULATE_ATOMIC_BOOL: bool =
- cfg!(any(target_arch = "riscv32", target_arch = "riscv64", target_arch = "loongarch64"));
+const EMULATE_ATOMIC_BOOL: bool = cfg!(any(
+ target_arch = "riscv32",
+ target_arch = "riscv64",
+ target_arch = "loongarch32",
+ target_arch = "loongarch64"
+));
/// A boolean type which can be safely shared between threads.
///
@@ -3811,9 +3816,9 @@ unsafe fn atomic_store<T: Copy>(dst: *mut T, val: T, order: Ordering) {
// SAFETY: the caller must uphold the safety contract for `atomic_store`.
unsafe {
match order {
- Relaxed => intrinsics::atomic_store_relaxed(dst, val),
- Release => intrinsics::atomic_store_release(dst, val),
- SeqCst => intrinsics::atomic_store_seqcst(dst, val),
+ Relaxed => intrinsics::atomic_store::<T, { AO::Relaxed }>(dst, val),
+ Release => intrinsics::atomic_store::<T, { AO::Release }>(dst, val),
+ SeqCst => intrinsics::atomic_store::<T, { AO::SeqCst }>(dst, val),
Acquire => panic!("there is no such thing as an acquire store"),
AcqRel => panic!("there is no such thing as an acquire-release store"),
}
@@ -3823,13 +3828,12 @@ unsafe fn atomic_store<T: Copy>(dst: *mut T, val: T, order: Ordering) {
#[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
unsafe fn atomic_load<T: Copy>(dst: *const T, order: Ordering) -> T {
- use intrinsics::AtomicOrdering;
// SAFETY: the caller must uphold the safety contract for `atomic_load`.
unsafe {
match order {
- Relaxed => intrinsics::atomic_load::<T, { AtomicOrdering::Relaxed }>(dst),
- Acquire => intrinsics::atomic_load::<T, { AtomicOrdering::Acquire }>(dst),
- SeqCst => intrinsics::atomic_load::<T, { AtomicOrdering::SeqCst }>(dst),
+ Relaxed => intrinsics::atomic_load::<T, { AO::Relaxed }>(dst),
+ Acquire => intrinsics::atomic_load::<T, { AO::Acquire }>(dst),
+ SeqCst => intrinsics::atomic_load::<T, { AO::SeqCst }>(dst),
Release => panic!("there is no such thing as a release load"),
AcqRel => panic!("there is no such thing as an acquire-release load"),
}
@@ -3843,11 +3847,11 @@ unsafe fn atomic_swap<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
// SAFETY: the caller must uphold the safety contract for `atomic_swap`.
unsafe {
match order {
- Relaxed => intrinsics::atomic_xchg_relaxed(dst, val),
- Acquire => intrinsics::atomic_xchg_acquire(dst, val),
- Release => intrinsics::atomic_xchg_release(dst, val),
- AcqRel => intrinsics::atomic_xchg_acqrel(dst, val),
- SeqCst => intrinsics::atomic_xchg_seqcst(dst, val),
+ Relaxed => intrinsics::atomic_xchg::<T, { AO::Relaxed }>(dst, val),
+ Acquire => intrinsics::atomic_xchg::<T, { AO::Acquire }>(dst, val),
+ Release => intrinsics::atomic_xchg::<T, { AO::Release }>(dst, val),
+ AcqRel => intrinsics::atomic_xchg::<T, { AO::AcqRel }>(dst, val),
+ SeqCst => intrinsics::atomic_xchg::<T, { AO::SeqCst }>(dst, val),
}
}
}
@@ -3860,11 +3864,11 @@ unsafe fn atomic_add<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
// SAFETY: the caller must uphold the safety contract for `atomic_add`.
unsafe {
match order {
- Relaxed => intrinsics::atomic_xadd_relaxed(dst, val),
- Acquire => intrinsics::atomic_xadd_acquire(dst, val),
- Release => intrinsics::atomic_xadd_release(dst, val),
- AcqRel => intrinsics::atomic_xadd_acqrel(dst, val),
- SeqCst => intrinsics::atomic_xadd_seqcst(dst, val),
+ Relaxed => intrinsics::atomic_xadd::<T, { AO::Relaxed }>(dst, val),
+ Acquire => intrinsics::atomic_xadd::<T, { AO::Acquire }>(dst, val),
+ Release => intrinsics::atomic_xadd::<T, { AO::Release }>(dst, val),
+ AcqRel => intrinsics::atomic_xadd::<T, { AO::AcqRel }>(dst, val),
+ SeqCst => intrinsics::atomic_xadd::<T, { AO::SeqCst }>(dst, val),
}
}
}
@@ -3877,11 +3881,11 @@ unsafe fn atomic_sub<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
// SAFETY: the caller must uphold the safety contract for `atomic_sub`.
unsafe {
match order {
- Relaxed => intrinsics::atomic_xsub_relaxed(dst, val),
- Acquire => intrinsics::atomic_xsub_acquire(dst, val),
- Release => intrinsics::atomic_xsub_release(dst, val),
- AcqRel => intrinsics::atomic_xsub_acqrel(dst, val),
- SeqCst => intrinsics::atomic_xsub_seqcst(dst, val),
+ Relaxed => intrinsics::atomic_xsub::<T, { AO::Relaxed }>(dst, val),
+ Acquire => intrinsics::atomic_xsub::<T, { AO::Acquire }>(dst, val),
+ Release => intrinsics::atomic_xsub::<T, { AO::Release }>(dst, val),
+ AcqRel => intrinsics::atomic_xsub::<T, { AO::AcqRel }>(dst, val),
+ SeqCst => intrinsics::atomic_xsub::<T, { AO::SeqCst }>(dst, val),
}
}
}
@@ -3902,21 +3906,51 @@ pub unsafe fn atomic_compare_exchange<T: Copy>(
// SAFETY: the caller must uphold the safety contract for `atomic_compare_exchange`.
let (val, ok) = unsafe {
match (success, failure) {
- (Relaxed, Relaxed) => intrinsics::atomic_cxchg_relaxed_relaxed(dst, old, new),
- (Relaxed, Acquire) => intrinsics::atomic_cxchg_relaxed_acquire(dst, old, new),
- (Relaxed, SeqCst) => intrinsics::atomic_cxchg_relaxed_seqcst(dst, old, new),
- (Acquire, Relaxed) => intrinsics::atomic_cxchg_acquire_relaxed(dst, old, new),
- (Acquire, Acquire) => intrinsics::atomic_cxchg_acquire_acquire(dst, old, new),
- (Acquire, SeqCst) => intrinsics::atomic_cxchg_acquire_seqcst(dst, old, new),
- (Release, Relaxed) => intrinsics::atomic_cxchg_release_relaxed(dst, old, new),
- (Release, Acquire) => intrinsics::atomic_cxchg_release_acquire(dst, old, new),
- (Release, SeqCst) => intrinsics::atomic_cxchg_release_seqcst(dst, old, new),
- (AcqRel, Relaxed) => intrinsics::atomic_cxchg_acqrel_relaxed(dst, old, new),
- (AcqRel, Acquire) => intrinsics::atomic_cxchg_acqrel_acquire(dst, old, new),
- (AcqRel, SeqCst) => intrinsics::atomic_cxchg_acqrel_seqcst(dst, old, new),
- (SeqCst, Relaxed) => intrinsics::atomic_cxchg_seqcst_relaxed(dst, old, new),
- (SeqCst, Acquire) => intrinsics::atomic_cxchg_seqcst_acquire(dst, old, new),
- (SeqCst, SeqCst) => intrinsics::atomic_cxchg_seqcst_seqcst(dst, old, new),
+ (Relaxed, Relaxed) => {
+ intrinsics::atomic_cxchg::<T, { AO::Relaxed }, { AO::Relaxed }>(dst, old, new)
+ }
+ (Relaxed, Acquire) => {
+ intrinsics::atomic_cxchg::<T, { AO::Relaxed }, { AO::Acquire }>(dst, old, new)
+ }
+ (Relaxed, SeqCst) => {
+ intrinsics::atomic_cxchg::<T, { AO::Relaxed }, { AO::SeqCst }>(dst, old, new)
+ }
+ (Acquire, Relaxed) => {
+ intrinsics::atomic_cxchg::<T, { AO::Acquire }, { AO::Relaxed }>(dst, old, new)
+ }
+ (Acquire, Acquire) => {
+ intrinsics::atomic_cxchg::<T, { AO::Acquire }, { AO::Acquire }>(dst, old, new)
+ }
+ (Acquire, SeqCst) => {
+ intrinsics::atomic_cxchg::<T, { AO::Acquire }, { AO::SeqCst }>(dst, old, new)
+ }
+ (Release, Relaxed) => {
+ intrinsics::atomic_cxchg::<T, { AO::Release }, { AO::Relaxed }>(dst, old, new)
+ }
+ (Release, Acquire) => {
+ intrinsics::atomic_cxchg::<T, { AO::Release }, { AO::Acquire }>(dst, old, new)
+ }
+ (Release, SeqCst) => {
+ intrinsics::atomic_cxchg::<T, { AO::Release }, { AO::SeqCst }>(dst, old, new)
+ }
+ (AcqRel, Relaxed) => {
+ intrinsics::atomic_cxchg::<T, { AO::AcqRel }, { AO::Relaxed }>(dst, old, new)
+ }
+ (AcqRel, Acquire) => {
+ intrinsics::atomic_cxchg::<T, { AO::AcqRel }, { AO::Acquire }>(dst, old, new)
+ }
+ (AcqRel, SeqCst) => {
+ intrinsics::atomic_cxchg::<T, { AO::AcqRel }, { AO::SeqCst }>(dst, old, new)
+ }
+ (SeqCst, Relaxed) => {
+ intrinsics::atomic_cxchg::<T, { AO::SeqCst }, { AO::Relaxed }>(dst, old, new)
+ }
+ (SeqCst, Acquire) => {
+ intrinsics::atomic_cxchg::<T, { AO::SeqCst }, { AO::Acquire }>(dst, old, new)
+ }
+ (SeqCst, SeqCst) => {
+ intrinsics::atomic_cxchg::<T, { AO::SeqCst }, { AO::SeqCst }>(dst, old, new)
+ }
(_, AcqRel) => panic!("there is no such thing as an acquire-release failure ordering"),
(_, Release) => panic!("there is no such thing as a release failure ordering"),
}
@@ -3937,21 +3971,51 @@ unsafe fn atomic_compare_exchange_weak<T: Copy>(
// SAFETY: the caller must uphold the safety contract for `atomic_compare_exchange_weak`.
let (val, ok) = unsafe {
match (success, failure) {
- (Relaxed, Relaxed) => intrinsics::atomic_cxchgweak_relaxed_relaxed(dst, old, new),
- (Relaxed, Acquire) => intrinsics::atomic_cxchgweak_relaxed_acquire(dst, old, new),
- (Relaxed, SeqCst) => intrinsics::atomic_cxchgweak_relaxed_seqcst(dst, old, new),
- (Acquire, Relaxed) => intrinsics::atomic_cxchgweak_acquire_relaxed(dst, old, new),
- (Acquire, Acquire) => intrinsics::atomic_cxchgweak_acquire_acquire(dst, old, new),
- (Acquire, SeqCst) => intrinsics::atomic_cxchgweak_acquire_seqcst(dst, old, new),
- (Release, Relaxed) => intrinsics::atomic_cxchgweak_release_relaxed(dst, old, new),
- (Release, Acquire) => intrinsics::atomic_cxchgweak_release_acquire(dst, old, new),
- (Release, SeqCst) => intrinsics::atomic_cxchgweak_release_seqcst(dst, old, new),
- (AcqRel, Relaxed) => intrinsics::atomic_cxchgweak_acqrel_relaxed(dst, old, new),
- (AcqRel, Acquire) => intrinsics::atomic_cxchgweak_acqrel_acquire(dst, old, new),
- (AcqRel, SeqCst) => intrinsics::atomic_cxchgweak_acqrel_seqcst(dst, old, new),
- (SeqCst, Relaxed) => intrinsics::atomic_cxchgweak_seqcst_relaxed(dst, old, new),
- (SeqCst, Acquire) => intrinsics::atomic_cxchgweak_seqcst_acquire(dst, old, new),
- (SeqCst, SeqCst) => intrinsics::atomic_cxchgweak_seqcst_seqcst(dst, old, new),
+ (Relaxed, Relaxed) => {
+ intrinsics::atomic_cxchgweak::<T, { AO::Relaxed }, { AO::Relaxed }>(dst, old, new)
+ }
+ (Relaxed, Acquire) => {
+ intrinsics::atomic_cxchgweak::<T, { AO::Relaxed }, { AO::Acquire }>(dst, old, new)
+ }
+ (Relaxed, SeqCst) => {
+ intrinsics::atomic_cxchgweak::<T, { AO::Relaxed }, { AO::SeqCst }>(dst, old, new)
+ }
+ (Acquire, Relaxed) => {
+ intrinsics::atomic_cxchgweak::<T, { AO::Acquire }, { AO::Relaxed }>(dst, old, new)
+ }
+ (Acquire, Acquire) => {
+ intrinsics::atomic_cxchgweak::<T, { AO::Acquire }, { AO::Acquire }>(dst, old, new)
+ }
+ (Acquire, SeqCst) => {
+ intrinsics::atomic_cxchgweak::<T, { AO::Acquire }, { AO::SeqCst }>(dst, old, new)
+ }
+ (Release, Relaxed) => {
+ intrinsics::atomic_cxchgweak::<T, { AO::Release }, { AO::Relaxed }>(dst, old, new)
+ }
+ (Release, Acquire) => {
+ intrinsics::atomic_cxchgweak::<T, { AO::Release }, { AO::Acquire }>(dst, old, new)
+ }
+ (Release, SeqCst) => {
+ intrinsics::atomic_cxchgweak::<T, { AO::Release }, { AO::SeqCst }>(dst, old, new)
+ }
+ (AcqRel, Relaxed) => {
+ intrinsics::atomic_cxchgweak::<T, { AO::AcqRel }, { AO::Relaxed }>(dst, old, new)
+ }
+ (AcqRel, Acquire) => {
+ intrinsics::atomic_cxchgweak::<T, { AO::AcqRel }, { AO::Acquire }>(dst, old, new)
+ }
+ (AcqRel, SeqCst) => {
+ intrinsics::atomic_cxchgweak::<T, { AO::AcqRel }, { AO::SeqCst }>(dst, old, new)
+ }
+ (SeqCst, Relaxed) => {
+ intrinsics::atomic_cxchgweak::<T, { AO::SeqCst }, { AO::Relaxed }>(dst, old, new)
+ }
+ (SeqCst, Acquire) => {
+ intrinsics::atomic_cxchgweak::<T, { AO::SeqCst }, { AO::Acquire }>(dst, old, new)
+ }
+ (SeqCst, SeqCst) => {
+ intrinsics::atomic_cxchgweak::<T, { AO::SeqCst }, { AO::SeqCst }>(dst, old, new)
+ }
(_, AcqRel) => panic!("there is no such thing as an acquire-release failure ordering"),
(_, Release) => panic!("there is no such thing as a release failure ordering"),
}
@@ -3966,11 +4030,11 @@ unsafe fn atomic_and<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
// SAFETY: the caller must uphold the safety contract for `atomic_and`
unsafe {
match order {
- Relaxed => intrinsics::atomic_and_relaxed(dst, val),
- Acquire => intrinsics::atomic_and_acquire(dst, val),
- Release => intrinsics::atomic_and_release(dst, val),
- AcqRel => intrinsics::atomic_and_acqrel(dst, val),
- SeqCst => intrinsics::atomic_and_seqcst(dst, val),
+ Relaxed => intrinsics::atomic_and::<T, { AO::Relaxed }>(dst, val),
+ Acquire => intrinsics::atomic_and::<T, { AO::Acquire }>(dst, val),
+ Release => intrinsics::atomic_and::<T, { AO::Release }>(dst, val),
+ AcqRel => intrinsics::atomic_and::<T, { AO::AcqRel }>(dst, val),
+ SeqCst => intrinsics::atomic_and::<T, { AO::SeqCst }>(dst, val),
}
}
}
@@ -3982,11 +4046,11 @@ unsafe fn atomic_nand<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
// SAFETY: the caller must uphold the safety contract for `atomic_nand`
unsafe {
match order {
- Relaxed => intrinsics::atomic_nand_relaxed(dst, val),
- Acquire => intrinsics::atomic_nand_acquire(dst, val),
- Release => intrinsics::atomic_nand_release(dst, val),
- AcqRel => intrinsics::atomic_nand_acqrel(dst, val),
- SeqCst => intrinsics::atomic_nand_seqcst(dst, val),
+ Relaxed => intrinsics::atomic_nand::<T, { AO::Relaxed }>(dst, val),
+ Acquire => intrinsics::atomic_nand::<T, { AO::Acquire }>(dst, val),
+ Release => intrinsics::atomic_nand::<T, { AO::Release }>(dst, val),
+ AcqRel => intrinsics::atomic_nand::<T, { AO::AcqRel }>(dst, val),
+ SeqCst => intrinsics::atomic_nand::<T, { AO::SeqCst }>(dst, val),
}
}
}
@@ -3998,11 +4062,11 @@ unsafe fn atomic_or<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
// SAFETY: the caller must uphold the safety contract for `atomic_or`
unsafe {
match order {
- SeqCst => intrinsics::atomic_or_seqcst(dst, val),
- Acquire => intrinsics::atomic_or_acquire(dst, val),
- Release => intrinsics::atomic_or_release(dst, val),
- AcqRel => intrinsics::atomic_or_acqrel(dst, val),
- Relaxed => intrinsics::atomic_or_relaxed(dst, val),
+ SeqCst => intrinsics::atomic_or::<T, { AO::SeqCst }>(dst, val),
+ Acquire => intrinsics::atomic_or::<T, { AO::Acquire }>(dst, val),
+ Release => intrinsics::atomic_or::<T, { AO::Release }>(dst, val),
+ AcqRel => intrinsics::atomic_or::<T, { AO::AcqRel }>(dst, val),
+ Relaxed => intrinsics::atomic_or::<T, { AO::Relaxed }>(dst, val),
}
}
}
@@ -4014,16 +4078,16 @@ unsafe fn atomic_xor<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
// SAFETY: the caller must uphold the safety contract for `atomic_xor`
unsafe {
match order {
- SeqCst => intrinsics::atomic_xor_seqcst(dst, val),
- Acquire => intrinsics::atomic_xor_acquire(dst, val),
- Release => intrinsics::atomic_xor_release(dst, val),
- AcqRel => intrinsics::atomic_xor_acqrel(dst, val),
- Relaxed => intrinsics::atomic_xor_relaxed(dst, val),
+ SeqCst => intrinsics::atomic_xor::<T, { AO::SeqCst }>(dst, val),
+ Acquire => intrinsics::atomic_xor::<T, { AO::Acquire }>(dst, val),
+ Release => intrinsics::atomic_xor::<T, { AO::Release }>(dst, val),
+ AcqRel => intrinsics::atomic_xor::<T, { AO::AcqRel }>(dst, val),
+ Relaxed => intrinsics::atomic_xor::<T, { AO::Relaxed }>(dst, val),
}
}
}
-/// returns the max value (signed comparison)
+/// Updates `*dst` to the max value of `val` and the old value (signed comparison)
#[inline]
#[cfg(target_has_atomic)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
@@ -4031,16 +4095,16 @@ unsafe fn atomic_max<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
// SAFETY: the caller must uphold the safety contract for `atomic_max`
unsafe {
match order {
- Relaxed => intrinsics::atomic_max_relaxed(dst, val),
- Acquire => intrinsics::atomic_max_acquire(dst, val),
- Release => intrinsics::atomic_max_release(dst, val),
- AcqRel => intrinsics::atomic_max_acqrel(dst, val),
- SeqCst => intrinsics::atomic_max_seqcst(dst, val),
+ Relaxed => intrinsics::atomic_max::<T, { AO::Relaxed }>(dst, val),
+ Acquire => intrinsics::atomic_max::<T, { AO::Acquire }>(dst, val),
+ Release => intrinsics::atomic_max::<T, { AO::Release }>(dst, val),
+ AcqRel => intrinsics::atomic_max::<T, { AO::AcqRel }>(dst, val),
+ SeqCst => intrinsics::atomic_max::<T, { AO::SeqCst }>(dst, val),
}
}
}
-/// returns the min value (signed comparison)
+/// Updates `*dst` to the min value of `val` and the old value (signed comparison)
#[inline]
#[cfg(target_has_atomic)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
@@ -4048,16 +4112,16 @@ unsafe fn atomic_min<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
// SAFETY: the caller must uphold the safety contract for `atomic_min`
unsafe {
match order {
- Relaxed => intrinsics::atomic_min_relaxed(dst, val),
- Acquire => intrinsics::atomic_min_acquire(dst, val),
- Release => intrinsics::atomic_min_release(dst, val),
- AcqRel => intrinsics::atomic_min_acqrel(dst, val),
- SeqCst => intrinsics::atomic_min_seqcst(dst, val),
+ Relaxed => intrinsics::atomic_min::<T, { AO::Relaxed }>(dst, val),
+ Acquire => intrinsics::atomic_min::<T, { AO::Acquire }>(dst, val),
+ Release => intrinsics::atomic_min::<T, { AO::Release }>(dst, val),
+ AcqRel => intrinsics::atomic_min::<T, { AO::AcqRel }>(dst, val),
+ SeqCst => intrinsics::atomic_min::<T, { AO::SeqCst }>(dst, val),
}
}
}
-/// returns the max value (unsigned comparison)
+/// Updates `*dst` to the max value of `val` and the old value (unsigned comparison)
#[inline]
#[cfg(target_has_atomic)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
@@ -4065,16 +4129,16 @@ unsafe fn atomic_umax<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
// SAFETY: the caller must uphold the safety contract for `atomic_umax`
unsafe {
match order {
- Relaxed => intrinsics::atomic_umax_relaxed(dst, val),
- Acquire => intrinsics::atomic_umax_acquire(dst, val),
- Release => intrinsics::atomic_umax_release(dst, val),
- AcqRel => intrinsics::atomic_umax_acqrel(dst, val),
- SeqCst => intrinsics::atomic_umax_seqcst(dst, val),
+ Relaxed => intrinsics::atomic_umax::<T, { AO::Relaxed }>(dst, val),
+ Acquire => intrinsics::atomic_umax::<T, { AO::Acquire }>(dst, val),
+ Release => intrinsics::atomic_umax::<T, { AO::Release }>(dst, val),
+ AcqRel => intrinsics::atomic_umax::<T, { AO::AcqRel }>(dst, val),
+ SeqCst => intrinsics::atomic_umax::<T, { AO::SeqCst }>(dst, val),
}
}
}
-/// returns the min value (unsigned comparison)
+/// Updates `*dst` to the min value of `val` and the old value (unsigned comparison)
#[inline]
#[cfg(target_has_atomic)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
@@ -4082,11 +4146,11 @@ unsafe fn atomic_umin<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
// SAFETY: the caller must uphold the safety contract for `atomic_umin`
unsafe {
match order {
- Relaxed => intrinsics::atomic_umin_relaxed(dst, val),
- Acquire => intrinsics::atomic_umin_acquire(dst, val),
- Release => intrinsics::atomic_umin_release(dst, val),
- AcqRel => intrinsics::atomic_umin_acqrel(dst, val),
- SeqCst => intrinsics::atomic_umin_seqcst(dst, val),
+ Relaxed => intrinsics::atomic_umin::<T, { AO::Relaxed }>(dst, val),
+ Acquire => intrinsics::atomic_umin::<T, { AO::Acquire }>(dst, val),
+ Release => intrinsics::atomic_umin::<T, { AO::Release }>(dst, val),
+ AcqRel => intrinsics::atomic_umin::<T, { AO::AcqRel }>(dst, val),
+ SeqCst => intrinsics::atomic_umin::<T, { AO::SeqCst }>(dst, val),
}
}
}
@@ -4178,10 +4242,10 @@ pub fn fence(order: Ordering) {
// SAFETY: using an atomic fence is safe.
unsafe {
match order {
- Acquire => intrinsics::atomic_fence_acquire(),
- Release => intrinsics::atomic_fence_release(),
- AcqRel => intrinsics::atomic_fence_acqrel(),
- SeqCst => intrinsics::atomic_fence_seqcst(),
+ Acquire => intrinsics::atomic_fence::<{ AO::Acquire }>(),
+ Release => intrinsics::atomic_fence::<{ AO::Release }>(),
+ AcqRel => intrinsics::atomic_fence::<{ AO::AcqRel }>(),
+ SeqCst => intrinsics::atomic_fence::<{ AO::SeqCst }>(),
Relaxed => panic!("there is no such thing as a relaxed fence"),
}
}
@@ -4256,11 +4320,11 @@ pub fn compiler_fence(order: Ordering) {
// SAFETY: using an atomic fence is safe.
unsafe {
match order {
- Acquire => intrinsics::atomic_singlethreadfence_acquire(),
- Release => intrinsics::atomic_singlethreadfence_release(),
- AcqRel => intrinsics::atomic_singlethreadfence_acqrel(),
- SeqCst => intrinsics::atomic_singlethreadfence_seqcst(),
- Relaxed => panic!("there is no such thing as a relaxed compiler fence"),
+ Acquire => intrinsics::atomic_singlethreadfence::<{ AO::Acquire }>(),
+ Release => intrinsics::atomic_singlethreadfence::<{ AO::Release }>(),
+ AcqRel => intrinsics::atomic_singlethreadfence::<{ AO::AcqRel }>(),
+ SeqCst => intrinsics::atomic_singlethreadfence::<{ AO::SeqCst }>(),
+ Relaxed => panic!("there is no such thing as a relaxed fence"),
}
}
}
diff --git a/library/coretests/tests/floats/f32.rs b/library/coretests/tests/floats/f32.rs
index 4e6509e..98e9695 100644
--- a/library/coretests/tests/floats/f32.rs
+++ b/library/coretests/tests/floats/f32.rs
@@ -23,6 +23,11 @@
/// Second pattern over the mantissa
const NAN_MASK2: u32 = 0x0055_5555;
+/// Miri adds some extra errors to float functions; make sure the tests still pass.
+/// These values are purely used as a canary to test against and are thus not a stable guarantee Rust provides.
+/// They serve as a way to get an idea of the real precision of floating point operations on different platforms.
+const APPROX_DELTA: f32 = if cfg!(miri) { 1e-4 } else { 1e-6 };
+
#[test]
fn test_num_f32() {
super::test_num(10f32, 2f32);
@@ -437,8 +442,8 @@ fn test_powi() {
let nan: f32 = f32::NAN;
let inf: f32 = f32::INFINITY;
let neg_inf: f32 = f32::NEG_INFINITY;
- assert_biteq!(1.0f32.powi(1), 1.0);
- assert_approx_eq!((-3.1f32).powi(2), 9.61);
+ assert_approx_eq!(1.0f32.powi(1), 1.0);
+ assert_approx_eq!((-3.1f32).powi(2), 9.61, APPROX_DELTA);
assert_approx_eq!(5.9f32.powi(-2), 0.028727);
assert_biteq!(8.3f32.powi(0), 1.0);
assert!(nan.powi(2).is_nan());
diff --git a/library/coretests/tests/floats/f64.rs b/library/coretests/tests/floats/f64.rs
index 74202a3..dd5b67c 100644
--- a/library/coretests/tests/floats/f64.rs
+++ b/library/coretests/tests/floats/f64.rs
@@ -422,7 +422,7 @@ fn test_powi() {
let nan: f64 = f64::NAN;
let inf: f64 = f64::INFINITY;
let neg_inf: f64 = f64::NEG_INFINITY;
- assert_biteq!(1.0f64.powi(1), 1.0);
+ assert_approx_eq!(1.0f64.powi(1), 1.0);
assert_approx_eq!((-3.1f64).powi(2), 9.61);
assert_approx_eq!(5.9f64.powi(-2), 0.028727);
assert_biteq!(8.3f64.powi(0), 1.0);
diff --git a/library/coretests/tests/lib.rs b/library/coretests/tests/lib.rs
index 92b920d..5449132 100644
--- a/library/coretests/tests/lib.rs
+++ b/library/coretests/tests/lib.rs
@@ -94,6 +94,7 @@
#![feature(try_blocks)]
#![feature(try_find)]
#![feature(try_trait_v2)]
+#![feature(uint_bit_width)]
#![feature(unsize)]
#![feature(unwrap_infallible)]
// tidy-alphabetical-end
diff --git a/library/coretests/tests/num/dec2flt/float.rs b/library/coretests/tests/num/dec2flt/float.rs
index 264de06..2407ba5 100644
--- a/library/coretests/tests/num/dec2flt/float.rs
+++ b/library/coretests/tests/num/dec2flt/float.rs
@@ -23,7 +23,8 @@ fn test_f16_integer_decode() {
fn test_f32_integer_decode() {
assert_eq!(3.14159265359f32.integer_decode(), (13176795, -22, 1));
assert_eq!((-8573.5918555f32).integer_decode(), (8779358, -10, -1));
- assert_eq!(2f32.powf(100.0).integer_decode(), (8388608, 77, 1));
+ // Set 2^100 directly instead of using powf, because it doesn't guarentee precision
+ assert_eq!(1.2676506e30_f32.integer_decode(), (8388608, 77, 1));
assert_eq!(0f32.integer_decode(), (0, -150, 1));
assert_eq!((-0f32).integer_decode(), (0, -150, -1));
assert_eq!(f32::INFINITY.integer_decode(), (8388608, 105, 1));
@@ -39,7 +40,8 @@ fn test_f32_integer_decode() {
fn test_f64_integer_decode() {
assert_eq!(3.14159265359f64.integer_decode(), (7074237752028906, -51, 1));
assert_eq!((-8573.5918555f64).integer_decode(), (4713381968463931, -39, -1));
- assert_eq!(2f64.powf(100.0).integer_decode(), (4503599627370496, 48, 1));
+ // Set 2^100 directly instead of using powf, because it doesn't guarentee precision
+ assert_eq!(1.2676506002282294e30_f64.integer_decode(), (4503599627370496, 48, 1));
assert_eq!(0f64.integer_decode(), (0, -1075, 1));
assert_eq!((-0f64).integer_decode(), (0, -1075, -1));
assert_eq!(f64::INFINITY.integer_decode(), (4503599627370496, 972, 1));
diff --git a/library/coretests/tests/num/mod.rs b/library/coretests/tests/num/mod.rs
index 6611aa5..f340926 100644
--- a/library/coretests/tests/num/mod.rs
+++ b/library/coretests/tests/num/mod.rs
@@ -22,20 +22,19 @@
mod u8;
mod bignum;
-
mod const_from;
mod dec2flt;
+mod float_iter_sum_identity;
mod flt2dec;
+mod ieee754;
mod int_log;
mod int_sqrt;
mod midpoint;
+mod nan;
+mod niche_types;
mod ops;
mod wrapping;
-mod float_iter_sum_identity;
-mod ieee754;
-mod nan;
-
/// Adds the attribute to all items in the block.
macro_rules! cfg_block {
($(#[$attr:meta]{$($it:item)*})*) => {$($(
diff --git a/library/coretests/tests/num/niche_types.rs b/library/coretests/tests/num/niche_types.rs
new file mode 100644
index 0000000..171a7f3
--- /dev/null
+++ b/library/coretests/tests/num/niche_types.rs
@@ -0,0 +1,12 @@
+use core::num::NonZero;
+
+#[test]
+fn test_new_from_zero_is_none() {
+ assert_eq!(NonZero::<char>::new(0 as char), None);
+}
+
+#[test]
+fn test_new_from_extreme_is_some() {
+ assert!(NonZero::<char>::new(1 as char).is_some());
+ assert!(NonZero::<char>::new(char::MAX).is_some());
+}
diff --git a/library/coretests/tests/num/uint_macros.rs b/library/coretests/tests/num/uint_macros.rs
index 6f3d160..7e02027 100644
--- a/library/coretests/tests/num/uint_macros.rs
+++ b/library/coretests/tests/num/uint_macros.rs
@@ -72,6 +72,14 @@ fn test_leading_trailing_ones() {
assert_eq_const_safe!(u32: X.trailing_ones(), 0);
}
+ fn test_bit_width() {
+ assert_eq_const_safe!(u32: A.bit_width(), 6);
+ assert_eq_const_safe!(u32: B.bit_width(), 6);
+ assert_eq_const_safe!(u32: C.bit_width(), 7);
+ assert_eq_const_safe!(u32: _0.bit_width(), 0);
+ assert_eq_const_safe!(u32: _1.bit_width(), $T::BITS);
+ }
+
fn test_rotate() {
assert_eq_const_safe!($T: A.rotate_left(6).rotate_right(2).rotate_right(4), A);
assert_eq_const_safe!($T: B.rotate_left(3).rotate_left(2).rotate_right(5), B);
diff --git a/library/panic_abort/Cargo.toml b/library/panic_abort/Cargo.toml
index d7d1696..e8c66f1 100644
--- a/library/panic_abort/Cargo.toml
+++ b/library/panic_abort/Cargo.toml
@@ -13,7 +13,7 @@
[dependencies]
core = { path = "../core" }
-compiler_builtins = "0.1.0"
+compiler_builtins = { path = "../compiler-builtins/compiler-builtins" }
[target.'cfg(target_os = "android")'.dependencies]
libc = { version = "0.2", default-features = false }
diff --git a/library/panic_unwind/Cargo.toml b/library/panic_unwind/Cargo.toml
index d176434..47914b9 100644
--- a/library/panic_unwind/Cargo.toml
+++ b/library/panic_unwind/Cargo.toml
@@ -15,7 +15,7 @@
alloc = { path = "../alloc" }
core = { path = "../core" }
unwind = { path = "../unwind" }
-compiler_builtins = "0.1.0"
+compiler_builtins = { path = "../compiler-builtins/compiler-builtins" }
cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
diff --git a/library/panic_unwind/src/seh.rs b/library/panic_unwind/src/seh.rs
index 3794b56..003ac4f 100644
--- a/library/panic_unwind/src/seh.rs
+++ b/library/panic_unwind/src/seh.rs
@@ -291,7 +291,7 @@ macro_rules! define_cleanup {
}
pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
- use core::intrinsics::atomic_store_seqcst;
+ use core::intrinsics::{AtomicOrdering, atomic_store};
// _CxxThrowException executes entirely on this stack frame, so there's no
// need to otherwise transfer `data` to the heap. We just pass a stack
@@ -325,23 +325,23 @@ pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
// In any case, we basically need to do something like this until we can
// express more operations in statics (and we may never be able to).
unsafe {
- atomic_store_seqcst(
+ atomic_store::<_, { AtomicOrdering::SeqCst }>(
(&raw mut THROW_INFO.pmfnUnwind).cast(),
ptr_t::new(exception_cleanup as *mut u8).raw(),
);
- atomic_store_seqcst(
+ atomic_store::<_, { AtomicOrdering::SeqCst }>(
(&raw mut THROW_INFO.pCatchableTypeArray).cast(),
ptr_t::new((&raw mut CATCHABLE_TYPE_ARRAY).cast()).raw(),
);
- atomic_store_seqcst(
+ atomic_store::<_, { AtomicOrdering::SeqCst }>(
(&raw mut CATCHABLE_TYPE_ARRAY.arrayOfCatchableTypes[0]).cast(),
ptr_t::new((&raw mut CATCHABLE_TYPE).cast()).raw(),
);
- atomic_store_seqcst(
+ atomic_store::<_, { AtomicOrdering::SeqCst }>(
(&raw mut CATCHABLE_TYPE.pType).cast(),
ptr_t::new((&raw mut TYPE_DESCRIPTOR).cast()).raw(),
);
- atomic_store_seqcst(
+ atomic_store::<_, { AtomicOrdering::SeqCst }>(
(&raw mut CATCHABLE_TYPE.copyFunction).cast(),
ptr_t::new(exception_copy as *mut u8).raw(),
);
diff --git a/library/rustc-std-workspace-core/Cargo.toml b/library/rustc-std-workspace-core/Cargo.toml
index 9315c08..bd318fc 100644
--- a/library/rustc-std-workspace-core/Cargo.toml
+++ b/library/rustc-std-workspace-core/Cargo.toml
@@ -12,3 +12,4 @@
[dependencies]
core = { path = "../core" }
+compiler_builtins = { path = "../compiler-builtins/compiler-builtins", features = ["compiler-builtins"] }
diff --git a/library/rustc-std-workspace-core/lib.rs b/library/rustc-std-workspace-core/lib.rs
index 14327852..21c047d 100644
--- a/library/rustc-std-workspace-core/lib.rs
+++ b/library/rustc-std-workspace-core/lib.rs
@@ -2,3 +2,7 @@
#![no_core]
pub use core::*;
+
+// Crate must be brought into scope so it appears in the crate graph for anything that
+// depends on `rustc-std-workspace-core`.
+use compiler_builtins as _;
diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml
index 196b904..53d78dc 100644
--- a/library/std/Cargo.toml
+++ b/library/std/Cargo.toml
@@ -18,7 +18,7 @@
panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" }
core = { path = "../core", public = true }
-compiler_builtins = { version = "=0.1.160" }
+compiler_builtins = { path = "../compiler-builtins/compiler-builtins" }
unwind = { path = "../unwind" }
hashbrown = { version = "0.15", default-features = false, features = [
'rustc-dep-of-std',
@@ -157,6 +157,8 @@
[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = [
+ # #[cfg(bootstrap)] loongarch32
+ 'cfg(target_arch, values("loongarch32"))',
# std use #[path] imports to portable-simd `std_float` crate
# and to the `backtrace` crate which messes-up with Cargo list
# of declared features, we therefor expect any feature cfg
diff --git a/library/std/src/env.rs b/library/std/src/env.rs
index ce2dc79..6d7d576 100644
--- a/library/std/src/env.rs
+++ b/library/std/src/env.rs
@@ -1046,6 +1046,7 @@ pub mod consts {
/// * `"sparc"`
/// * `"sparc64"`
/// * `"hexagon"`
+ /// * `"loongarch32"`
/// * `"loongarch64"`
///
/// </details>
diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs
index 20c82b6..a9a2468 100644
--- a/library/std/src/io/mod.rs
+++ b/library/std/src/io/mod.rs
@@ -917,6 +917,19 @@ fn is_read_vectored(&self) -> bool {
/// # }
/// ```
///
+ /// # Usage Notes
+ ///
+ /// `read_to_end` attempts to read a source until EOF, but many sources are continuous streams
+ /// that do not send EOF. In these cases, `read_to_end` will block indefinitely. Standard input
+ /// is one such stream which may be finite if piped, but is typically continuous. For example,
+ /// `cat file | my-rust-program` will correctly terminate with an `EOF` upon closure of cat.
+ /// Reading user input or running programs that remain open indefinitely will never terminate
+ /// the stream with `EOF` (e.g. `yes | my-rust-program`).
+ ///
+ /// Using `.lines()` with a [`BufReader`] or using [`read`] can provide a better solution
+ ///
+ ///[`read`]: Read::read
+ ///
/// [`Vec::try_reserve`]: crate::vec::Vec::try_reserve
#[stable(feature = "rust1", since = "1.0.0")]
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> {
@@ -960,6 +973,19 @@ fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> {
/// (See also the [`std::fs::read_to_string`] convenience function for
/// reading from a file.)
///
+ /// # Usage Notes
+ ///
+ /// `read_to_string` attempts to read a source until EOF, but many sources are continuous streams
+ /// that do not send EOF. In these cases, `read_to_string` will block indefinitely. Standard input
+ /// is one such stream which may be finite if piped, but is typically continuous. For example,
+ /// `cat file | my-rust-program` will correctly terminate with an `EOF` upon closure of cat.
+ /// Reading user input or running programs that remain open indefinitely will never terminate
+ /// the stream with `EOF` (e.g. `yes | my-rust-program`).
+ ///
+ /// Using `.lines()` with a [`BufReader`] or using [`read`] can provide a better solution
+ ///
+ ///[`read`]: Read::read
+ ///
/// [`std::fs::read_to_string`]: crate::fs::read_to_string
#[stable(feature = "rust1", since = "1.0.0")]
fn read_to_string(&mut self, buf: &mut String) -> Result<usize> {
@@ -1262,6 +1288,20 @@ fn take(self, limit: u64) -> Take<Self>
/// Ok(())
/// }
/// ```
+///
+/// # Usage Notes
+///
+/// `read_to_string` attempts to read a source until EOF, but many sources are continuous streams
+/// that do not send EOF. In these cases, `read_to_string` will block indefinitely. Standard input
+/// is one such stream which may be finite if piped, but is typically continuous. For example,
+/// `cat file | my-rust-program` will correctly terminate with an `EOF` upon closure of cat.
+/// Reading user input or running programs that remain open indefinitely will never terminate
+/// the stream with `EOF` (e.g. `yes | my-rust-program`).
+///
+/// Using `.lines()` with a [`BufReader`] or using [`read`] can provide a better solution
+///
+///[`read`]: Read::read
+///
#[stable(feature = "io_read_to_string", since = "1.65.0")]
pub fn read_to_string<R: Read>(mut reader: R) -> Result<String> {
let mut buf = String::new();
diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs
index 7c54e73..2bb7a63 100644
--- a/library/std/src/lib.rs
+++ b/library/std/src/lib.rs
@@ -351,7 +351,6 @@
#![feature(lazy_get)]
#![feature(maybe_uninit_slice)]
#![feature(maybe_uninit_write_slice)]
-#![feature(nonnull_provenance)]
#![feature(panic_can_unwind)]
#![feature(panic_internals)]
#![feature(pin_coerce_unsized_trait)]
diff --git a/library/std/src/num/f128.rs b/library/std/src/num/f128.rs
index c0190de..64e604e 100644
--- a/library/std/src/num/f128.rs
+++ b/library/std/src/num/f128.rs
@@ -5,6 +5,7 @@
//! Mathematically significant numbers are provided in the `consts` sub-module.
#![unstable(feature = "f128", issue = "116909")]
+#![doc(test(attr(feature(cfg_target_has_reliable_f16_f128), expect(internal_features))))]
#[unstable(feature = "f128", issue = "116909")]
pub use core::f128::consts;
@@ -27,8 +28,6 @@ impl f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -59,8 +58,6 @@ pub fn powf(self, n: f128) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -93,8 +90,6 @@ pub fn exp(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -127,8 +122,6 @@ pub fn exp2(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -146,8 +139,6 @@ pub fn exp2(self) -> f128 {
/// Non-positive values:
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -180,8 +171,6 @@ pub fn ln(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -197,8 +186,6 @@ pub fn ln(self) -> f128 {
/// Non-positive values:
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -227,8 +214,6 @@ pub fn log(self, base: f128) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -244,8 +229,6 @@ pub fn log(self, base: f128) -> f128 {
/// Non-positive values:
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -274,8 +257,6 @@ pub fn log2(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -291,8 +272,6 @@ pub fn log2(self) -> f128 {
/// Non-positive values:
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -323,8 +302,6 @@ pub fn log10(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -362,8 +339,6 @@ pub fn cbrt(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -395,8 +370,6 @@ pub fn hypot(self, other: f128) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -426,8 +399,6 @@ pub fn sin(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -460,8 +431,6 @@ pub fn cos(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -495,8 +464,6 @@ pub fn tan(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -533,8 +500,6 @@ pub fn asin(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -570,8 +535,6 @@ pub fn acos(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -611,8 +574,6 @@ pub fn atan(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -656,8 +617,6 @@ pub fn atan2(self, other: f128) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -694,8 +653,6 @@ pub fn sin_cos(self) -> (f128, f128) {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -733,8 +690,6 @@ pub fn exp_m1(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -751,8 +706,6 @@ pub fn exp_m1(self) -> f128 {
/// Out-of-range values:
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -783,8 +736,6 @@ pub fn ln_1p(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -821,8 +772,6 @@ pub fn sinh(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -859,8 +808,6 @@ pub fn cosh(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -894,8 +841,6 @@ pub fn tanh(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -929,8 +874,6 @@ pub fn asinh(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -966,8 +909,6 @@ pub fn acosh(self) -> f128 {
///
/// ```
/// #![feature(f128)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -1003,8 +944,6 @@ pub fn atanh(self) -> f128 {
/// ```
/// #![feature(f128)]
/// #![feature(float_gamma)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -1041,8 +980,6 @@ pub fn gamma(self) -> f128 {
/// ```
/// #![feature(f128)]
/// #![feature(float_gamma)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
///
@@ -1079,8 +1016,6 @@ pub fn ln_gamma(self) -> (f128, i32) {
/// ```
/// #![feature(f128)]
/// #![feature(float_erf)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
/// /// The error function relates what percent of a normal distribution lies
@@ -1121,8 +1056,6 @@ pub fn erf(self) -> f128 {
/// ```
/// #![feature(f128)]
/// #![feature(float_erf)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f128_math)] {
/// let x: f128 = 0.123;
diff --git a/library/std/src/num/f16.rs b/library/std/src/num/f16.rs
index 4a4a8fd..7bdefb0 100644
--- a/library/std/src/num/f16.rs
+++ b/library/std/src/num/f16.rs
@@ -5,6 +5,7 @@
//! Mathematically significant numbers are provided in the `consts` sub-module.
#![unstable(feature = "f16", issue = "116909")]
+#![doc(test(attr(feature(cfg_target_has_reliable_f16_f128), expect(internal_features))))]
#[unstable(feature = "f16", issue = "116909")]
pub use core::f16::consts;
@@ -27,8 +28,6 @@ impl f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -59,8 +58,6 @@ pub fn powf(self, n: f16) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -93,8 +90,6 @@ pub fn exp(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -127,8 +122,6 @@ pub fn exp2(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -146,8 +139,6 @@ pub fn exp2(self) -> f16 {
/// Non-positive values:
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -180,8 +171,6 @@ pub fn ln(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -197,8 +186,6 @@ pub fn ln(self) -> f16 {
/// Non-positive values:
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -227,8 +214,6 @@ pub fn log(self, base: f16) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -244,8 +229,6 @@ pub fn log(self, base: f16) -> f16 {
/// Non-positive values:
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -274,8 +257,6 @@ pub fn log2(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -291,8 +272,6 @@ pub fn log2(self) -> f16 {
/// Non-positive values:
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -325,8 +304,6 @@ pub fn log10(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -358,8 +335,6 @@ pub fn hypot(self, other: f16) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -389,8 +364,6 @@ pub fn sin(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -423,8 +396,6 @@ pub fn cos(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -458,8 +429,6 @@ pub fn tan(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -496,8 +465,6 @@ pub fn asin(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -533,8 +500,6 @@ pub fn acos(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -574,8 +539,6 @@ pub fn atan(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -619,8 +582,6 @@ pub fn atan2(self, other: f16) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -657,8 +618,6 @@ pub fn sin_cos(self) -> (f16, f16) {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -696,8 +655,6 @@ pub fn exp_m1(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -714,8 +671,6 @@ pub fn exp_m1(self) -> f16 {
/// Out-of-range values:
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -746,8 +701,6 @@ pub fn ln_1p(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -784,8 +737,6 @@ pub fn sinh(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -822,8 +773,6 @@ pub fn cosh(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -857,8 +806,6 @@ pub fn tanh(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -892,8 +839,6 @@ pub fn asinh(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -929,8 +874,6 @@ pub fn acosh(self) -> f16 {
///
/// ```
/// #![feature(f16)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -966,8 +909,6 @@ pub fn atanh(self) -> f16 {
/// ```
/// #![feature(f16)]
/// #![feature(float_gamma)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -1004,8 +945,6 @@ pub fn gamma(self) -> f16 {
/// ```
/// #![feature(f16)]
/// #![feature(float_gamma)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
///
@@ -1042,8 +981,6 @@ pub fn ln_gamma(self) -> (f16, i32) {
/// ```
/// #![feature(f16)]
/// #![feature(float_erf)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
/// /// The error function relates what percent of a normal distribution lies
@@ -1084,8 +1021,6 @@ pub fn erf(self) -> f16 {
/// ```
/// #![feature(f16)]
/// #![feature(float_erf)]
- /// # #![feature(cfg_target_has_reliable_f16_f128)]
- /// # #![expect(internal_features)]
/// # #[cfg(not(miri))]
/// # #[cfg(target_has_reliable_f16_math)] {
/// let x: f16 = 0.123;
diff --git a/library/std/src/num/f32.rs b/library/std/src/num/f32.rs
index b7f6529..e79ec2a 100644
--- a/library/std/src/num/f32.rs
+++ b/library/std/src/num/f32.rs
@@ -304,7 +304,7 @@ pub fn rem_euclid(self, rhs: f32) -> f32 {
/// ```
/// let x = 2.0_f32;
/// let abs_difference = (x.powi(2) - (x * x)).abs();
- /// assert!(abs_difference <= f32::EPSILON);
+ /// assert!(abs_difference <= 1e-5);
///
/// assert_eq!(f32::powi(f32::NAN, 0), 1.0);
/// ```
@@ -328,7 +328,7 @@ pub fn powi(self, n: i32) -> f32 {
/// ```
/// let x = 2.0_f32;
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
- /// assert!(abs_difference <= f32::EPSILON);
+ /// assert!(abs_difference <= 1e-5);
///
/// assert_eq!(f32::powf(1.0, f32::NAN), 1.0);
/// assert_eq!(f32::powf(f32::NAN, 0.0), 1.0);
@@ -388,7 +388,7 @@ pub fn sqrt(self) -> f32 {
/// // ln(e) - 1 == 0
/// let abs_difference = (e.ln() - 1.0).abs();
///
- /// assert!(abs_difference <= f32::EPSILON);
+ /// assert!(abs_difference <= 1e-6);
/// ```
#[rustc_allow_incoherent_impl]
#[must_use = "method returns a new number and does not mutate the original value"]
@@ -413,7 +413,7 @@ pub fn exp(self) -> f32 {
/// // 2^2 - 4 == 0
/// let abs_difference = (f.exp2() - 4.0).abs();
///
- /// assert!(abs_difference <= f32::EPSILON);
+ /// assert!(abs_difference <= 1e-5);
/// ```
#[rustc_allow_incoherent_impl]
#[must_use = "method returns a new number and does not mutate the original value"]
@@ -442,7 +442,7 @@ pub fn exp2(self) -> f32 {
/// // ln(e) - 1 == 0
/// let abs_difference = (e.ln() - 1.0).abs();
///
- /// assert!(abs_difference <= f32::EPSILON);
+ /// assert!(abs_difference <= 1e-6);
/// ```
///
/// Non-positive values:
@@ -479,7 +479,7 @@ pub fn ln(self) -> f32 {
/// // log5(5) - 1 == 0
/// let abs_difference = (five.log(5.0) - 1.0).abs();
///
- /// assert!(abs_difference <= f32::EPSILON);
+ /// assert!(abs_difference <= 1e-6);
/// ```
///
/// Non-positive values:
@@ -512,7 +512,7 @@ pub fn log(self, base: f32) -> f32 {
/// // log2(2) - 1 == 0
/// let abs_difference = (two.log2() - 1.0).abs();
///
- /// assert!(abs_difference <= f32::EPSILON);
+ /// assert!(abs_difference <= 1e-6);
/// ```
///
/// Non-positive values:
@@ -545,7 +545,7 @@ pub fn log2(self) -> f32 {
/// // log10(10) - 1 == 0
/// let abs_difference = (ten.log10() - 1.0).abs();
///
- /// assert!(abs_difference <= f32::EPSILON);
+ /// assert!(abs_difference <= 1e-6);
/// ```
///
/// Non-positive values:
@@ -652,7 +652,7 @@ pub fn cbrt(self) -> f32 {
/// // sqrt(x^2 + y^2)
/// let abs_difference = (x.hypot(y) - (x.powi(2) + y.powi(2)).sqrt()).abs();
///
- /// assert!(abs_difference <= f32::EPSILON);
+ /// assert!(abs_difference <= 1e-6);
/// ```
#[rustc_allow_incoherent_impl]
#[must_use = "method returns a new number and does not mutate the original value"]
@@ -676,7 +676,7 @@ pub fn hypot(self, other: f32) -> f32 {
///
/// let abs_difference = (x.sin() - 1.0).abs();
///
- /// assert!(abs_difference <= f32::EPSILON);
+ /// assert!(abs_difference <= 1e-6);
/// ```
#[rustc_allow_incoherent_impl]
#[must_use = "method returns a new number and does not mutate the original value"]
@@ -700,7 +700,7 @@ pub fn sin(self) -> f32 {
///
/// let abs_difference = (x.cos() - 1.0).abs();
///
- /// assert!(abs_difference <= f32::EPSILON);
+ /// assert!(abs_difference <= 1e-6);
/// ```
#[rustc_allow_incoherent_impl]
#[must_use = "method returns a new number and does not mutate the original value"]
@@ -754,7 +754,7 @@ pub fn tan(self) -> f32 {
/// // asin(sin(pi/2))
/// let abs_difference = (f.sin().asin() - std::f32::consts::FRAC_PI_2).abs();
///
- /// assert!(abs_difference <= f32::EPSILON);
+ /// assert!(abs_difference <= 1e-3);
/// ```
#[doc(alias = "arcsin")]
#[rustc_allow_incoherent_impl]
@@ -784,7 +784,7 @@ pub fn asin(self) -> f32 {
/// // acos(cos(pi/4))
/// let abs_difference = (f.cos().acos() - std::f32::consts::FRAC_PI_4).abs();
///
- /// assert!(abs_difference <= f32::EPSILON);
+ /// assert!(abs_difference <= 1e-6);
/// ```
#[doc(alias = "arccos")]
#[rustc_allow_incoherent_impl]
@@ -884,8 +884,8 @@ pub fn atan2(self, other: f32) -> f32 {
/// let abs_difference_0 = (f.0 - x.sin()).abs();
/// let abs_difference_1 = (f.1 - x.cos()).abs();
///
- /// assert!(abs_difference_0 <= f32::EPSILON);
- /// assert!(abs_difference_1 <= f32::EPSILON);
+ /// assert!(abs_difference_0 <= 1e-6);
+ /// assert!(abs_difference_1 <= 1e-6);
/// ```
#[doc(alias = "sincos")]
#[rustc_allow_incoherent_impl]
@@ -1067,7 +1067,7 @@ pub fn tanh(self) -> f32 {
///
/// let abs_difference = (f - x).abs();
///
- /// assert!(abs_difference <= f32::EPSILON);
+ /// assert!(abs_difference <= 1e-7);
/// ```
#[doc(alias = "arcsinh")]
#[rustc_allow_incoherent_impl]
@@ -1095,7 +1095,7 @@ pub fn asinh(self) -> f32 {
///
/// let abs_difference = (f - x).abs();
///
- /// assert!(abs_difference <= f32::EPSILON);
+ /// assert!(abs_difference <= 1e-6);
/// ```
#[doc(alias = "arccosh")]
#[rustc_allow_incoherent_impl]
diff --git a/library/std/src/num/f64.rs b/library/std/src/num/f64.rs
index 75e35a8..8534178 100644
--- a/library/std/src/num/f64.rs
+++ b/library/std/src/num/f64.rs
@@ -304,7 +304,7 @@ pub fn rem_euclid(self, rhs: f64) -> f64 {
/// ```
/// let x = 2.0_f64;
/// let abs_difference = (x.powi(2) - (x * x)).abs();
- /// assert!(abs_difference <= f64::EPSILON);
+ /// assert!(abs_difference <= 1e-14);
///
/// assert_eq!(f64::powi(f64::NAN, 0), 1.0);
/// ```
@@ -328,7 +328,7 @@ pub fn powi(self, n: i32) -> f64 {
/// ```
/// let x = 2.0_f64;
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
- /// assert!(abs_difference <= f64::EPSILON);
+ /// assert!(abs_difference <= 1e-14);
///
/// assert_eq!(f64::powf(1.0, f64::NAN), 1.0);
/// assert_eq!(f64::powf(f64::NAN, 0.0), 1.0);
@@ -754,7 +754,7 @@ pub fn tan(self) -> f64 {
/// // asin(sin(pi/2))
/// let abs_difference = (f.sin().asin() - std::f64::consts::FRAC_PI_2).abs();
///
- /// assert!(abs_difference < 1e-10);
+ /// assert!(abs_difference < 1e-7);
/// ```
#[doc(alias = "arcsin")]
#[rustc_allow_incoherent_impl]
diff --git a/library/std/src/os/android/net.rs b/library/std/src/os/android/net.rs
index 960a304..3a459ed 100644
--- a/library/std/src/os/android/net.rs
+++ b/library/std/src/os/android/net.rs
@@ -6,5 +6,5 @@
pub use crate::os::net::linux_ext::addr::SocketAddrExt;
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub use crate::os::net::linux_ext::socket::UnixSocketExt;
-#[unstable(feature = "tcp_quickack", issue = "96256")]
+#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")]
pub use crate::os::net::linux_ext::tcp::TcpStreamExt;
diff --git a/library/std/src/os/linux/net.rs b/library/std/src/os/linux/net.rs
index 1de120c..c14aba1 100644
--- a/library/std/src/os/linux/net.rs
+++ b/library/std/src/os/linux/net.rs
@@ -6,5 +6,5 @@
pub use crate::os::net::linux_ext::addr::SocketAddrExt;
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub use crate::os::net::linux_ext::socket::UnixSocketExt;
-#[unstable(feature = "tcp_quickack", issue = "96256")]
+#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")]
pub use crate::os::net::linux_ext::tcp::TcpStreamExt;
diff --git a/library/std/src/os/linux/raw.rs b/library/std/src/os/linux/raw.rs
index d53674d..6483f08 100644
--- a/library/std/src/os/linux/raw.rs
+++ b/library/std/src/os/linux/raw.rs
@@ -231,6 +231,7 @@ pub struct stat {
}
#[cfg(any(
+ target_arch = "loongarch32",
target_arch = "loongarch64",
target_arch = "mips64",
target_arch = "mips64r6",
diff --git a/library/std/src/os/net/linux_ext/mod.rs b/library/std/src/os/net/linux_ext/mod.rs
index d097964..bb9dfae 100644
--- a/library/std/src/os/net/linux_ext/mod.rs
+++ b/library/std/src/os/net/linux_ext/mod.rs
@@ -8,7 +8,7 @@
#[unstable(feature = "unix_socket_ancillary_data", issue = "76915")]
pub(crate) mod socket;
-#[unstable(feature = "tcp_quickack", issue = "96256")]
+#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")]
pub(crate) mod tcp;
#[cfg(test)]
diff --git a/library/std/src/os/net/linux_ext/tcp.rs b/library/std/src/os/net/linux_ext/tcp.rs
index 95dffb3..167cfa6 100644
--- a/library/std/src/os/net/linux_ext/tcp.rs
+++ b/library/std/src/os/net/linux_ext/tcp.rs
@@ -9,7 +9,7 @@
/// Os-specific extensions for [`TcpStream`]
///
/// [`TcpStream`]: net::TcpStream
-#[unstable(feature = "tcp_quickack", issue = "96256")]
+#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")]
pub trait TcpStreamExt: Sealed {
/// Enable or disable `TCP_QUICKACK`.
///
@@ -23,7 +23,6 @@ pub trait TcpStreamExt: Sealed {
/// # Examples
///
/// ```no_run
- /// #![feature(tcp_quickack)]
/// use std::net::TcpStream;
/// #[cfg(target_os = "linux")]
/// use std::os::linux::net::TcpStreamExt;
@@ -34,7 +33,7 @@ pub trait TcpStreamExt: Sealed {
/// .expect("Couldn't connect to the server...");
/// stream.set_quickack(true).expect("set_quickack call failed");
/// ```
- #[unstable(feature = "tcp_quickack", issue = "96256")]
+ #[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")]
fn set_quickack(&self, quickack: bool) -> io::Result<()>;
/// Gets the value of the `TCP_QUICKACK` option on this socket.
@@ -44,7 +43,6 @@ pub trait TcpStreamExt: Sealed {
/// # Examples
///
/// ```no_run
- /// #![feature(tcp_quickack)]
/// use std::net::TcpStream;
/// #[cfg(target_os = "linux")]
/// use std::os::linux::net::TcpStreamExt;
@@ -56,7 +54,7 @@ pub trait TcpStreamExt: Sealed {
/// stream.set_quickack(true).expect("set_quickack call failed");
/// assert_eq!(stream.quickack().unwrap_or(false), true);
/// ```
- #[unstable(feature = "tcp_quickack", issue = "96256")]
+ #[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")]
fn quickack(&self) -> io::Result<bool>;
/// A socket listener will be awakened solely when data arrives.
@@ -105,10 +103,10 @@ pub trait TcpStreamExt: Sealed {
fn deferaccept(&self) -> io::Result<u32>;
}
-#[unstable(feature = "tcp_quickack", issue = "96256")]
+#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")]
impl Sealed for net::TcpStream {}
-#[unstable(feature = "tcp_quickack", issue = "96256")]
+#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")]
impl TcpStreamExt for net::TcpStream {
fn set_quickack(&self, quickack: bool) -> io::Result<()> {
self.as_inner().as_inner().set_quickack(quickack)
diff --git a/library/std/src/sys/alloc/mod.rs b/library/std/src/sys/alloc/mod.rs
index 8489e17..f3af1f7 100644
--- a/library/std/src/sys/alloc/mod.rs
+++ b/library/std/src/sys/alloc/mod.rs
@@ -17,6 +17,7 @@
target_arch = "arm",
target_arch = "m68k",
target_arch = "csky",
+ target_arch = "loongarch32",
target_arch = "mips",
target_arch = "mips32r6",
target_arch = "powerpc",
diff --git a/library/std/src/sys/personality/gcc.rs b/library/std/src/sys/personality/gcc.rs
index b012e47..75e793f 100644
--- a/library/std/src/sys/personality/gcc.rs
+++ b/library/std/src/sys/personality/gcc.rs
@@ -86,7 +86,7 @@
#[cfg(any(target_arch = "riscv64", target_arch = "riscv32"))]
const UNWIND_DATA_REG: (i32, i32) = (10, 11); // x10, x11
-#[cfg(target_arch = "loongarch64")]
+#[cfg(any(target_arch = "loongarch32", target_arch = "loongarch64"))]
const UNWIND_DATA_REG: (i32, i32) = (4, 5); // a0, a1
// The following code is based on GCC's C and C++ personality routines. For reference, see:
diff --git a/library/std/tests/floats/f32.rs b/library/std/tests/floats/f32.rs
index e54f227..38c906c 100644
--- a/library/std/tests/floats/f32.rs
+++ b/library/std/tests/floats/f32.rs
@@ -1,5 +1,10 @@
use std::f32::consts;
+/// Miri adds some extra errors to float functions; make sure the tests still pass.
+/// These values are purely used as a canary to test against and are thus not a stable guarantee Rust provides.
+/// They serve as a way to get an idea of the real precision of floating point operations on different platforms.
+const APPROX_DELTA: f32 = if cfg!(miri) { 1e-3 } else { 1e-6 };
+
#[allow(unused_macros)]
macro_rules! assert_f32_biteq {
($left : expr, $right : expr) => {
@@ -17,9 +22,9 @@ fn test_powf() {
let inf: f32 = f32::INFINITY;
let neg_inf: f32 = f32::NEG_INFINITY;
assert_eq!(1.0f32.powf(1.0), 1.0);
- assert_approx_eq!(3.4f32.powf(4.5), 246.408218);
+ assert_approx_eq!(3.4f32.powf(4.5), 246.408218, APPROX_DELTA);
assert_approx_eq!(2.7f32.powf(-3.2), 0.041652);
- assert_approx_eq!((-3.1f32).powf(2.0), 9.61);
+ assert_approx_eq!((-3.1f32).powf(2.0), 9.61, APPROX_DELTA);
assert_approx_eq!(5.9f32.powf(-2.0), 0.028727);
assert_eq!(8.3f32.powf(0.0), 1.0);
assert!(nan.powf(2.0).is_nan());
@@ -30,8 +35,8 @@ fn test_powf() {
#[test]
fn test_exp() {
assert_eq!(1.0, 0.0f32.exp());
- assert_approx_eq!(2.718282, 1.0f32.exp());
- assert_approx_eq!(148.413162, 5.0f32.exp());
+ assert_approx_eq!(2.718282, 1.0f32.exp(), APPROX_DELTA);
+ assert_approx_eq!(148.413162, 5.0f32.exp(), APPROX_DELTA);
let inf: f32 = f32::INFINITY;
let neg_inf: f32 = f32::NEG_INFINITY;
@@ -43,7 +48,7 @@ fn test_exp() {
#[test]
fn test_exp2() {
- assert_eq!(32.0, 5.0f32.exp2());
+ assert_approx_eq!(32.0, 5.0f32.exp2(), APPROX_DELTA);
assert_eq!(1.0, 0.0f32.exp2());
let inf: f32 = f32::INFINITY;
@@ -66,7 +71,7 @@ fn test_ln() {
assert!((-2.3f32).ln().is_nan());
assert_eq!((-0.0f32).ln(), neg_inf);
assert_eq!(0.0f32.ln(), neg_inf);
- assert_approx_eq!(4.0f32.ln(), 1.386294);
+ assert_approx_eq!(4.0f32.ln(), 1.386294, APPROX_DELTA);
}
#[test]
@@ -74,9 +79,9 @@ fn test_log() {
let nan: f32 = f32::NAN;
let inf: f32 = f32::INFINITY;
let neg_inf: f32 = f32::NEG_INFINITY;
- assert_eq!(10.0f32.log(10.0), 1.0);
+ assert_approx_eq!(10.0f32.log(10.0), 1.0);
assert_approx_eq!(2.3f32.log(3.5), 0.664858);
- assert_eq!(1.0f32.exp().log(1.0f32.exp()), 1.0);
+ assert_approx_eq!(1.0f32.exp().log(1.0f32.exp()), 1.0, APPROX_DELTA);
assert!(1.0f32.log(1.0).is_nan());
assert!(1.0f32.log(-13.9).is_nan());
assert!(nan.log(2.3).is_nan());
@@ -92,9 +97,9 @@ fn test_log2() {
let nan: f32 = f32::NAN;
let inf: f32 = f32::INFINITY;
let neg_inf: f32 = f32::NEG_INFINITY;
- assert_approx_eq!(10.0f32.log2(), 3.321928);
+ assert_approx_eq!(10.0f32.log2(), 3.321928, APPROX_DELTA);
assert_approx_eq!(2.3f32.log2(), 1.201634);
- assert_approx_eq!(1.0f32.exp().log2(), 1.442695);
+ assert_approx_eq!(1.0f32.exp().log2(), 1.442695, APPROX_DELTA);
assert!(nan.log2().is_nan());
assert_eq!(inf.log2(), inf);
assert!(neg_inf.log2().is_nan());
@@ -108,7 +113,7 @@ fn test_log10() {
let nan: f32 = f32::NAN;
let inf: f32 = f32::INFINITY;
let neg_inf: f32 = f32::NEG_INFINITY;
- assert_eq!(10.0f32.log10(), 1.0);
+ assert_approx_eq!(10.0f32.log10(), 1.0);
assert_approx_eq!(2.3f32.log10(), 0.361728);
assert_approx_eq!(1.0f32.exp().log10(), 0.434294);
assert_eq!(1.0f32.log10(), 0.0);
@@ -158,7 +163,7 @@ fn test_acosh() {
assert_approx_eq!(3.0f32.acosh(), 1.76274717403908605046521864995958461f32);
// test for low accuracy from issue 104548
- assert_approx_eq!(60.0f32, 60.0f32.cosh().acosh());
+ assert_approx_eq!(60.0f32, 60.0f32.cosh().acosh(), APPROX_DELTA);
}
#[test]
@@ -237,7 +242,7 @@ fn test_real_consts() {
let ln_10: f32 = consts::LN_10;
assert_approx_eq!(frac_pi_2, pi / 2f32);
- assert_approx_eq!(frac_pi_3, pi / 3f32);
+ assert_approx_eq!(frac_pi_3, pi / 3f32, APPROX_DELTA);
assert_approx_eq!(frac_pi_4, pi / 4f32);
assert_approx_eq!(frac_pi_6, pi / 6f32);
assert_approx_eq!(frac_pi_8, pi / 8f32);
@@ -249,5 +254,5 @@ fn test_real_consts() {
assert_approx_eq!(log2_e, e.log2());
assert_approx_eq!(log10_e, e.log10());
assert_approx_eq!(ln_2, 2f32.ln());
- assert_approx_eq!(ln_10, 10f32.ln());
+ assert_approx_eq!(ln_10, 10f32.ln(), APPROX_DELTA);
}
diff --git a/library/std/tests/floats/f64.rs b/library/std/tests/floats/f64.rs
index 2d8dd1c..fccf200 100644
--- a/library/std/tests/floats/f64.rs
+++ b/library/std/tests/floats/f64.rs
@@ -43,7 +43,7 @@ fn test_exp() {
#[test]
fn test_exp2() {
- assert_eq!(32.0, 5.0f64.exp2());
+ assert_approx_eq!(32.0, 5.0f64.exp2());
assert_eq!(1.0, 0.0f64.exp2());
let inf: f64 = f64::INFINITY;
@@ -74,9 +74,9 @@ fn test_log() {
let nan: f64 = f64::NAN;
let inf: f64 = f64::INFINITY;
let neg_inf: f64 = f64::NEG_INFINITY;
- assert_eq!(10.0f64.log(10.0), 1.0);
+ assert_approx_eq!(10.0f64.log(10.0), 1.0);
assert_approx_eq!(2.3f64.log(3.5), 0.664858);
- assert_eq!(1.0f64.exp().log(1.0f64.exp()), 1.0);
+ assert_approx_eq!(1.0f64.exp().log(1.0f64.exp()), 1.0);
assert!(1.0f64.log(1.0).is_nan());
assert!(1.0f64.log(-13.9).is_nan());
assert!(nan.log(2.3).is_nan());
@@ -108,7 +108,7 @@ fn test_log10() {
let nan: f64 = f64::NAN;
let inf: f64 = f64::INFINITY;
let neg_inf: f64 = f64::NEG_INFINITY;
- assert_eq!(10.0f64.log10(), 1.0);
+ assert_approx_eq!(10.0f64.log10(), 1.0);
assert_approx_eq!(2.3f64.log10(), 0.361728);
assert_approx_eq!(1.0f64.exp().log10(), 0.434294);
assert_eq!(1.0f64.log10(), 0.0);
diff --git a/library/std/tests/sync/mpmc.rs b/library/std/tests/sync/mpmc.rs
index 78abcb3..594fc21 100644
--- a/library/std/tests/sync/mpmc.rs
+++ b/library/std/tests/sync/mpmc.rs
@@ -462,8 +462,8 @@ fn oneshot_single_thread_recv_timeout() {
#[test]
fn stress_recv_timeout_two_threads() {
let (tx, rx) = channel();
- let stress = stress_factor() + 100;
- let timeout = Duration::from_millis(100);
+ let stress = stress_factor() + 50;
+ let timeout = Duration::from_millis(5);
thread::spawn(move || {
for i in 0..stress {
@@ -475,18 +475,23 @@ fn stress_recv_timeout_two_threads() {
});
let mut recv_count = 0;
+ let mut got_timeout = false;
loop {
match rx.recv_timeout(timeout) {
Ok(n) => {
assert_eq!(n, 1usize);
recv_count += 1;
}
- Err(RecvTimeoutError::Timeout) => continue,
+ Err(RecvTimeoutError::Timeout) => {
+ got_timeout = true;
+ continue;
+ }
Err(RecvTimeoutError::Disconnected) => break,
}
}
assert_eq!(recv_count, stress);
+ assert!(got_timeout);
}
#[test]
diff --git a/library/std/tests/sync/mpsc.rs b/library/std/tests/sync/mpsc.rs
index 1d8edfd..9de4a71 100644
--- a/library/std/tests/sync/mpsc.rs
+++ b/library/std/tests/sync/mpsc.rs
@@ -425,8 +425,8 @@ fn oneshot_single_thread_recv_timeout() {
#[test]
fn stress_recv_timeout_two_threads() {
let (tx, rx) = channel();
- let stress = stress_factor() + 100;
- let timeout = Duration::from_millis(100);
+ let stress = stress_factor() + 50;
+ let timeout = Duration::from_millis(5);
thread::spawn(move || {
for i in 0..stress {
@@ -438,18 +438,23 @@ fn stress_recv_timeout_two_threads() {
});
let mut recv_count = 0;
+ let mut got_timeout = false;
loop {
match rx.recv_timeout(timeout) {
Ok(n) => {
assert_eq!(n, 1usize);
recv_count += 1;
}
- Err(RecvTimeoutError::Timeout) => continue,
+ Err(RecvTimeoutError::Timeout) => {
+ got_timeout = true;
+ continue;
+ }
Err(RecvTimeoutError::Disconnected) => break,
}
}
assert_eq!(recv_count, stress);
+ assert!(got_timeout);
}
#[test]
diff --git a/library/unwind/Cargo.toml b/library/unwind/Cargo.toml
index df43e6a..ad37342 100644
--- a/library/unwind/Cargo.toml
+++ b/library/unwind/Cargo.toml
@@ -15,7 +15,7 @@
[dependencies]
core = { path = "../core" }
-compiler_builtins = "0.1.0"
+compiler_builtins = { path = "../compiler-builtins/compiler-builtins" }
cfg-if = "1.0"
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
@@ -37,4 +37,4 @@
[lints.rust.unexpected_cfgs]
level = "warn"
-check-cfg = ['cfg(emscripten_wasm_eh)']
+check-cfg = ['cfg(emscripten_wasm_eh)', 'cfg(target_arch, values("loongarch32"))']
diff --git a/library/unwind/src/libunwind.rs b/library/unwind/src/libunwind.rs
index 1258256..b350003 100644
--- a/library/unwind/src/libunwind.rs
+++ b/library/unwind/src/libunwind.rs
@@ -81,7 +81,7 @@ pub enum _Unwind_Reason_Code {
#[cfg(all(target_arch = "hexagon", target_os = "linux"))]
pub const unwinder_private_data_size: usize = 35;
-#[cfg(target_arch = "loongarch64")]
+#[cfg(any(target_arch = "loongarch32", target_arch = "loongarch64"))]
pub const unwinder_private_data_size: usize = 2;
#[repr(C)]
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index c60c6b8..d8c6be7 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -394,6 +394,7 @@
"i686": "i686",
"i686-AT386": "i686",
"i786": "i686",
+ "loongarch32": "loongarch32",
"loongarch64": "loongarch64",
"m68k": "m68k",
"csky": "csky",
diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs
index 587fca8..7aa9e6c 100644
--- a/src/bootstrap/src/core/build_steps/dist.rs
+++ b/src/bootstrap/src/core/build_steps/dist.rs
@@ -1681,7 +1681,8 @@ fn filter(contents: &str, marker: &str) -> String {
cmd.run(builder);
}
- if target.is_windows() {
+ // FIXME(mati865): `gnullvm` here is temporary, remove it once it can host itself
+ if target.is_windows() && !target.contains("gnullvm") {
let exe = tmp.join("exe");
let _ = fs::remove_dir_all(&exe);
diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs
index 9861637..717accb 100644
--- a/src/bootstrap/src/core/build_steps/tool.rs
+++ b/src/bootstrap/src/core/build_steps/tool.rs
@@ -23,7 +23,6 @@
Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step, cargo_profile_var,
};
use crate::core::config::{DebuginfoLevel, RustcLto, TargetSelection};
-use crate::utils::channel::GitInfo;
use crate::utils::exec::{BootstrapCommand, command};
use crate::utils::helpers::{add_dylib_path, exe, t};
use crate::{Compiler, FileType, Kind, Mode, gha};
@@ -278,7 +277,7 @@ pub fn prepare_tool_cargo(
cargo.env("CFG_VER_DESCRIPTION", description);
}
- let info = GitInfo::new(builder.config.omit_git_hash, &dir);
+ let info = builder.config.git_info(builder.config.omit_git_hash, &dir);
if let Some(sha) = info.sha() {
cargo.env("CFG_COMMIT_HASH", sha);
}
diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs
index 1e9af68..c6cfdb6 100644
--- a/src/bootstrap/src/core/builder/cargo.rs
+++ b/src/bootstrap/src/core/builder/cargo.rs
@@ -11,7 +11,7 @@
use crate::utils::helpers::{self, LldThreads, check_cfg_arg, linker_args, linker_flags};
use crate::{
BootstrapCommand, CLang, Compiler, Config, DocTests, DryRun, EXTRA_CHECK_CFGS, GitRepo, Mode,
- TargetSelection, command, prepare_behaviour_dump_dir, t,
+ RemapScheme, TargetSelection, command, prepare_behaviour_dump_dir, t,
};
/// Represents flag values in `String` form with whitespace delimiter to pass it to the compiler
@@ -551,7 +551,7 @@ fn cargo(
let libdir = self.rustc_libdir(compiler);
let sysroot_str = sysroot.as_os_str().to_str().expect("sysroot should be UTF-8");
- if self.is_verbose() && !matches!(self.config.dry_run, DryRun::SelfCheck) {
+ if self.is_verbose() && !matches!(self.config.get_dry_run(), DryRun::SelfCheck) {
println!("using sysroot {sysroot_str}");
}
@@ -636,6 +636,15 @@ fn cargo(
for (restricted_mode, name, values) in EXTRA_CHECK_CFGS {
if restricted_mode.is_none() || *restricted_mode == Some(mode) {
rustflags.arg(&check_cfg_arg(name, *values));
+
+ if *name == "bootstrap" {
+ // Cargo doesn't pass RUSTFLAGS to proc_macros:
+ // https://github.com/rust-lang/cargo/issues/4423
+ // Thus, if we are on stage 0, we explicitly set `--cfg=bootstrap`.
+ // We also declare that the flag is expected, which we need to do to not
+ // get warnings about it being unexpected.
+ hostflags.arg(check_cfg_arg(name, *values));
+ }
}
}
@@ -645,13 +654,6 @@ fn cargo(
if stage == 0 {
hostflags.arg("--cfg=bootstrap");
}
- // Cargo doesn't pass RUSTFLAGS to proc_macros:
- // https://github.com/rust-lang/cargo/issues/4423
- // Thus, if we are on stage 0, we explicitly set `--cfg=bootstrap`.
- // We also declare that the flag is expected, which we need to do to not
- // get warnings about it being unexpected.
- hostflags.arg("-Zunstable-options");
- hostflags.arg("--check-cfg=cfg(bootstrap)");
// FIXME: It might be better to use the same value for both `RUSTFLAGS` and `RUSTDOCFLAGS`,
// but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See
@@ -920,13 +922,46 @@ fn cargo(
hostflags.arg(format!("-Ctarget-feature={sign}crt-static"));
}
- if let Some(map_to) = self.build.debuginfo_map_to(GitRepo::Rustc) {
- let map = format!("{}={}", self.build.src.display(), map_to);
- cargo.env("RUSTC_DEBUGINFO_MAP", map);
+ // `rustc` needs to know the remapping scheme, in order to know how to reverse it (unremap)
+ // later. Two env vars are set and made available to the compiler
+ //
+ // - `CFG_VIRTUAL_RUST_SOURCE_BASE_DIR`: `rust-src` remap scheme (`NonCompiler`)
+ // - `CFG_VIRTUAL_RUSTC_DEV_SOURCE_BASE_DIR`: `rustc-dev` remap scheme (`Compiler`)
+ //
+ // Keep this scheme in sync with `rustc_metadata::rmeta::decoder`'s
+ // `try_to_translate_virtual_to_real`.
+ //
+ // `RUSTC_DEBUGINFO_MAP` is used to pass through to the underlying rustc
+ // `--remap-path-prefix`.
+ match mode {
+ Mode::Rustc | Mode::Codegen => {
+ if let Some(ref map_to) =
+ self.build.debuginfo_map_to(GitRepo::Rustc, RemapScheme::NonCompiler)
+ {
+ cargo.env("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR", map_to);
+ }
- // `rustc` needs to know the virtual `/rustc/$hash` we're mapping to,
- // in order to opportunistically reverse it later.
- cargo.env("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR", map_to);
+ if let Some(ref map_to) =
+ self.build.debuginfo_map_to(GitRepo::Rustc, RemapScheme::Compiler)
+ {
+ // When building compiler sources, we want to apply the compiler remap scheme.
+ cargo.env(
+ "RUSTC_DEBUGINFO_MAP",
+ format!("{}={}", self.build.src.display(), map_to),
+ );
+ cargo.env("CFG_VIRTUAL_RUSTC_DEV_SOURCE_BASE_DIR", map_to);
+ }
+ }
+ Mode::Std | Mode::ToolBootstrap | Mode::ToolRustc | Mode::ToolStd => {
+ if let Some(ref map_to) =
+ self.build.debuginfo_map_to(GitRepo::Rustc, RemapScheme::NonCompiler)
+ {
+ cargo.env(
+ "RUSTC_DEBUGINFO_MAP",
+ format!("{}={}", self.build.src.display(), map_to),
+ );
+ }
+ }
}
if self.config.rust_remap_debuginfo {
diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs
index 19b79bf..8b1520d 100644
--- a/src/bootstrap/src/core/builder/mod.rs
+++ b/src/bootstrap/src/core/builder/mod.rs
@@ -22,6 +22,7 @@
use crate::core::config::{DryRun, TargetSelection};
use crate::utils::cache::Cache;
use crate::utils::exec::{BootstrapCommand, command};
+use crate::utils::execution_context::ExecutionContext;
use crate::utils::helpers::{self, LldThreads, add_dylib_path, exe, libdir, linker_args, t};
use crate::{Build, Crate, trace};
@@ -442,13 +443,15 @@ fn maybe_run(&self, builder: &Builder<'_>, mut pathsets: Vec<PathSet>) {
fn is_excluded(&self, builder: &Builder<'_>, pathset: &PathSet) -> bool {
if builder.config.skip.iter().any(|e| pathset.has(e, builder.kind)) {
- if !matches!(builder.config.dry_run, DryRun::SelfCheck) {
+ if !matches!(builder.config.get_dry_run(), DryRun::SelfCheck) {
println!("Skipping {pathset:?} because it is excluded");
}
return true;
}
- if !builder.config.skip.is_empty() && !matches!(builder.config.dry_run, DryRun::SelfCheck) {
+ if !builder.config.skip.is_empty()
+ && !matches!(builder.config.get_dry_run(), DryRun::SelfCheck)
+ {
builder.verbose(|| {
println!(
"{:?} not skipped for {:?} -- not in {:?}",
@@ -1633,4 +1636,14 @@ pub(crate) fn open_in_browser(&self, path: impl AsRef<Path>) {
self.info(&format!("{err}\n"));
}
}
+
+ pub fn exec_ctx(&self) -> &ExecutionContext {
+ &self.config.exec_ctx
+ }
+}
+
+impl<'a> AsRef<ExecutionContext> for Builder<'a> {
+ fn as_ref(&self) -> &ExecutionContext {
+ self.exec_ctx()
+ }
}
diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs
index baa22fc..a264d77 100644
--- a/src/bootstrap/src/core/builder/tests.rs
+++ b/src/bootstrap/src/core/builder/tests.rs
@@ -22,7 +22,7 @@ fn configure_with_args(cmd: &[String], host: &[&str], target: &[&str]) -> Config
let mut config = Config::parse(Flags::parse(cmd));
// don't save toolstates
config.save_toolstates = None;
- config.dry_run = DryRun::SelfCheck;
+ config.set_dry_run(DryRun::SelfCheck);
// Ignore most submodules, since we don't need them for a dry run, and the
// tests run much faster without them.
diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs
index a92d58e..860aa12 100644
--- a/src/bootstrap/src/core/config/config.rs
+++ b/src/bootstrap/src/core/config/config.rs
@@ -24,7 +24,7 @@
use build_helper::ci::CiEnv;
use build_helper::exit;
-use build_helper::git::{GitConfig, PathFreshness, check_path_modifications, output_result};
+use build_helper::git::{GitConfig, PathFreshness, check_path_modifications};
use serde::Deserialize;
#[cfg(feature = "tracing")]
use tracing::{instrument, span};
@@ -47,8 +47,10 @@
};
use crate::core::download::is_download_ci_available;
use crate::utils::channel;
+use crate::utils::exec::command;
+use crate::utils::execution_context::ExecutionContext;
use crate::utils::helpers::exe;
-use crate::{Command, GitInfo, OnceLock, TargetSelection, check_ci_llvm, helpers, output, t};
+use crate::{GitInfo, OnceLock, TargetSelection, check_ci_llvm, helpers, t};
/// Each path in this list is considered "allowed" in the `download-rustc="if-unchanged"` logic.
/// This means they can be modified and changes to these paths should never trigger a compiler build
@@ -129,7 +131,6 @@ pub struct Config {
pub jobs: Option<u32>,
pub cmd: Subcommand,
pub incremental: bool,
- pub dry_run: DryRun,
pub dump_bootstrap_shims: bool,
/// Arguments appearing after `--` to be forwarded to tools,
/// e.g. `--fix-broken` or test arguments.
@@ -304,6 +305,8 @@ pub struct Config {
/// This is mostly for RA as building the stage1 compiler to check the library tree
/// on each code change might be too much for some computers.
pub skip_std_check_if_no_download_rustc: bool,
+
+ pub exec_ctx: ExecutionContext,
}
impl Config {
@@ -360,6 +363,14 @@ pub fn default_opts() -> Config {
}
}
+ pub fn set_dry_run(&mut self, dry_run: DryRun) {
+ self.exec_ctx.set_dry_run(dry_run);
+ }
+
+ pub fn get_dry_run(&self) -> &DryRun {
+ self.exec_ctx.get_dry_run()
+ }
+
#[cfg_attr(
feature = "tracing",
instrument(target = "CONFIG_HANDLING", level = "trace", name = "Config::parse", skip_all)
@@ -382,6 +393,11 @@ pub(crate) fn parse_inner(
get_toml: impl Fn(&Path) -> Result<TomlConfig, toml::de::Error>,
) -> Config {
let mut config = Config::default_opts();
+ let mut exec_ctx = ExecutionContext::new();
+ exec_ctx.set_verbose(flags.verbose);
+ exec_ctx.set_fail_fast(flags.cmd.fail_fast());
+
+ config.exec_ctx = exec_ctx;
// Set flags.
config.paths = std::mem::take(&mut flags.paths);
@@ -410,7 +426,7 @@ pub(crate) fn parse_inner(
config.on_fail = flags.on_fail;
config.cmd = flags.cmd;
config.incremental = flags.incremental;
- config.dry_run = if flags.dry_run { DryRun::UserSelected } else { DryRun::Disabled };
+ config.set_dry_run(if flags.dry_run { DryRun::UserSelected } else { DryRun::Disabled });
config.dump_bootstrap_shims = flags.dump_bootstrap_shims;
config.keep_stage = flags.keep_stage;
config.keep_stage_std = flags.keep_stage_std;
@@ -440,14 +456,9 @@ pub(crate) fn parse_inner(
// has already been (kinda-cross-)compiled to Windows land, we require a normal Windows path.
cmd.arg("rev-parse").arg("--show-cdup");
// Discard stderr because we expect this to fail when building from a tarball.
- let output = cmd
- .as_command_mut()
- .stderr(std::process::Stdio::null())
- .output()
- .ok()
- .and_then(|output| if output.status.success() { Some(output) } else { None });
- if let Some(output) = output {
- let git_root_relative = String::from_utf8(output.stdout).unwrap();
+ let output = cmd.allow_failure().run_capture_stdout(&config);
+ if output.is_success() {
+ let git_root_relative = output.stdout();
// We need to canonicalize this path to make sure it uses backslashes instead of forward slashes,
// and to resolve any relative components.
let git_root = env::current_dir()
@@ -542,7 +553,7 @@ pub(crate) fn parse_inner(
build.cargo = build.cargo.take().or(std::env::var_os("CARGO").map(|p| p.into()));
}
- if GitInfo::new(false, &config.src).is_from_tarball() && toml.profile.is_none() {
+ if config.git_info(false, &config.src).is_from_tarball() && toml.profile.is_none() {
toml.profile = Some("dist".into());
}
@@ -749,7 +760,12 @@ fn get_table(option: &str) -> Result<TomlConfig, toml::de::Error> {
};
config.initial_sysroot = t!(PathBuf::from_str(
- output(Command::new(&config.initial_rustc).args(["--print", "sysroot"])).trim()
+ command(&config.initial_rustc)
+ .args(["--print", "sysroot"])
+ .run_always()
+ .run_capture_stdout(&config)
+ .stdout()
+ .trim()
));
config.initial_cargo_clippy = cargo_clippy;
@@ -845,19 +861,21 @@ fn get_table(option: &str) -> Result<TomlConfig, toml::de::Error> {
let default = config.channel == "dev";
config.omit_git_hash = toml.rust.as_ref().and_then(|r| r.omit_git_hash).unwrap_or(default);
- config.rust_info = GitInfo::new(config.omit_git_hash, &config.src);
- config.cargo_info = GitInfo::new(config.omit_git_hash, &config.src.join("src/tools/cargo"));
+ config.rust_info = config.git_info(config.omit_git_hash, &config.src);
+ config.cargo_info =
+ config.git_info(config.omit_git_hash, &config.src.join("src/tools/cargo"));
config.rust_analyzer_info =
- GitInfo::new(config.omit_git_hash, &config.src.join("src/tools/rust-analyzer"));
+ config.git_info(config.omit_git_hash, &config.src.join("src/tools/rust-analyzer"));
config.clippy_info =
- GitInfo::new(config.omit_git_hash, &config.src.join("src/tools/clippy"));
- config.miri_info = GitInfo::new(config.omit_git_hash, &config.src.join("src/tools/miri"));
+ config.git_info(config.omit_git_hash, &config.src.join("src/tools/clippy"));
+ config.miri_info =
+ config.git_info(config.omit_git_hash, &config.src.join("src/tools/miri"));
config.rustfmt_info =
- GitInfo::new(config.omit_git_hash, &config.src.join("src/tools/rustfmt"));
+ config.git_info(config.omit_git_hash, &config.src.join("src/tools/rustfmt"));
config.enzyme_info =
- GitInfo::new(config.omit_git_hash, &config.src.join("src/tools/enzyme"));
- config.in_tree_llvm_info = GitInfo::new(false, &config.src.join("src/llvm-project"));
- config.in_tree_gcc_info = GitInfo::new(false, &config.src.join("src/gcc"));
+ config.git_info(config.omit_git_hash, &config.src.join("src/tools/enzyme"));
+ config.in_tree_llvm_info = config.git_info(false, &config.src.join("src/llvm-project"));
+ config.in_tree_gcc_info = config.git_info(false, &config.src.join("src/gcc"));
config.vendor = vendor.unwrap_or(
config.rust_info.is_from_tarball()
@@ -1017,28 +1035,13 @@ fn get_table(option: &str) -> Result<TomlConfig, toml::de::Error> {
}
pub fn dry_run(&self) -> bool {
- match self.dry_run {
- DryRun::Disabled => false,
- DryRun::SelfCheck | DryRun::UserSelected => true,
- }
+ self.exec_ctx.dry_run()
}
pub fn is_explicit_stage(&self) -> bool {
self.explicit_stage_from_cli || self.explicit_stage_from_config
}
- /// Runs a command, printing out nice contextual information if it fails.
- /// Exits if the command failed to execute at all, otherwise returns its
- /// `status.success()`.
- #[deprecated = "use `Builder::try_run` instead where possible"]
- pub(crate) fn try_run(&self, cmd: &mut Command) -> Result<(), ()> {
- if self.dry_run() {
- return Ok(());
- }
- self.verbose(|| println!("running: {cmd:?}"));
- build_helper::util::try_run(cmd, self.is_verbose())
- }
-
pub(crate) fn test_args(&self) -> Vec<&str> {
let mut test_args = match self.cmd {
Subcommand::Test { ref test_args, .. }
@@ -1072,7 +1075,7 @@ pub(crate) fn read_file_by_commit(&self, file: &Path, commit: &str) -> String {
let mut git = helpers::git(Some(&self.src));
git.arg("show").arg(format!("{commit}:{}", file.to_str().unwrap()));
- output(git.as_command_mut())
+ git.run_capture_stdout(self).stdout()
}
/// Bootstrap embeds a version number into the name of shared libraries it uploads in CI.
@@ -1260,9 +1263,7 @@ pub(crate) fn download_rustc_commit(&self) -> Option<&str> {
/// Runs a function if verbosity is greater than 0
pub fn verbose(&self, f: impl Fn()) {
- if self.is_verbose() {
- f()
- }
+ self.exec_ctx.verbose(f);
}
pub fn any_sanitizers_to_build(&self) -> bool {
@@ -1324,7 +1325,7 @@ pub(crate) fn update_submodule(&self, relative_path: &str) {
// NOTE: The check for the empty directory is here because when running x.py the first time,
// the submodule won't be checked out. Check it out now so we can build it.
- if !GitInfo::new(false, &absolute_path).is_managed_git_subrepository()
+ if !self.git_info(false, &absolute_path).is_managed_git_subrepository()
&& !helpers::dir_is_empty(&absolute_path)
{
return;
@@ -1343,16 +1344,16 @@ pub(crate) fn update_submodule(&self, relative_path: &str) {
};
// Determine commit checked out in submodule.
- let checked_out_hash = output(submodule_git().args(["rev-parse", "HEAD"]).as_command_mut());
+ let checked_out_hash =
+ submodule_git().args(["rev-parse", "HEAD"]).run_capture_stdout(self).stdout();
let checked_out_hash = checked_out_hash.trim_end();
// Determine commit that the submodule *should* have.
- let recorded = output(
- helpers::git(Some(&self.src))
- .run_always()
- .args(["ls-tree", "HEAD"])
- .arg(relative_path)
- .as_command_mut(),
- );
+ let recorded = helpers::git(Some(&self.src))
+ .run_always()
+ .args(["ls-tree", "HEAD"])
+ .arg(relative_path)
+ .run_capture_stdout(self)
+ .stdout();
let actual_hash = recorded
.split_whitespace()
@@ -1376,21 +1377,20 @@ pub(crate) fn update_submodule(&self, relative_path: &str) {
let update = |progress: bool| {
// Git is buggy and will try to fetch submodules from the tracking branch for *this* repository,
// even though that has no relation to the upstream for the submodule.
- let current_branch = output_result(
- helpers::git(Some(&self.src))
- .allow_failure()
- .run_always()
- .args(["symbolic-ref", "--short", "HEAD"])
- .as_command_mut(),
- )
- .map(|b| b.trim().to_owned());
+ let current_branch = helpers::git(Some(&self.src))
+ .allow_failure()
+ .run_always()
+ .args(["symbolic-ref", "--short", "HEAD"])
+ .run_capture(self);
let mut git = helpers::git(Some(&self.src)).allow_failure();
git.run_always();
- if let Ok(branch) = current_branch {
+ if current_branch.is_success() {
// If there is a tag named after the current branch, git will try to disambiguate by prepending `heads/` to the branch name.
// This syntax isn't accepted by `branch.{branch}`. Strip it.
- let branch = branch.strip_prefix("heads/").unwrap_or(&branch);
+ let branch = current_branch.stdout();
+ let branch = branch.trim();
+ let branch = branch.strip_prefix("heads/").unwrap_or(branch);
git.arg("-c").arg(format!("branch.{branch}.remote=origin"));
}
git.args(["submodule", "update", "--init", "--recursive", "--depth=1"]);
@@ -1435,7 +1435,8 @@ pub fn check_stage0_version(&self, program_path: &Path, component_name: &'static
return;
}
- let stage0_output = output(Command::new(program_path).arg("--version"));
+ let stage0_output =
+ command(program_path).arg("--version").run_capture_stdout(self).stdout();
let mut stage0_output = stage0_output.lines().next().unwrap().split(' ');
let stage0_name = stage0_output.next().unwrap();
@@ -1741,4 +1742,18 @@ pub fn is_rust_llvm(&self, target: TargetSelection) -> bool {
_ => !self.is_system_llvm(target),
}
}
+
+ pub fn exec_ctx(&self) -> &ExecutionContext {
+ &self.exec_ctx
+ }
+
+ pub fn git_info(&self, omit_git_hash: bool, dir: &Path) -> GitInfo {
+ GitInfo::new(omit_git_hash, dir, self)
+ }
+}
+
+impl AsRef<ExecutionContext> for Config {
+ fn as_ref(&self) -> &ExecutionContext {
+ &self.exec_ctx
+ }
}
diff --git a/src/bootstrap/src/core/config/flags.rs b/src/bootstrap/src/core/config/flags.rs
index 30617f5..bc4fa73 100644
--- a/src/bootstrap/src/core/config/flags.rs
+++ b/src/bootstrap/src/core/config/flags.rs
@@ -209,7 +209,8 @@ struct HelpVerboseOnly {
HelpVerboseOnly::try_parse_from(normalize_args(args))
{
println!("NOTE: updating submodules before printing available paths");
- let config = Config::parse(Self::parse(&[String::from("build")]));
+ let flags = Self::parse(&[String::from("build")]);
+ let config = Config::parse(flags);
let build = Build::new(config);
let paths = Builder::get_help(&build, subcommand);
if let Some(s) = paths {
diff --git a/src/bootstrap/src/core/config/toml/rust.rs b/src/bootstrap/src/core/config/toml/rust.rs
index 81f95f3..bb18fa8 100644
--- a/src/bootstrap/src/core/config/toml/rust.rs
+++ b/src/bootstrap/src/core/config/toml/rust.rs
@@ -321,11 +321,11 @@ macro_rules! warn {
rpath,
channel,
description,
- incremental,
default_linker,
std_features,
// Rest of the options can simply be ignored.
+ incremental: _,
debug: _,
codegen_units: _,
codegen_units_std: _,
@@ -389,7 +389,6 @@ macro_rules! warn {
warn!(current_rust_config.channel, channel, "rust");
warn!(current_rust_config.description, description, "rust");
- warn!(current_rust_config.incremental, incremental, "rust");
Ok(())
}
diff --git a/src/bootstrap/src/core/config/toml/target.rs b/src/bootstrap/src/core/config/toml/target.rs
index 7f074d1..b8fc3e74 100644
--- a/src/bootstrap/src/core/config/toml/target.rs
+++ b/src/bootstrap/src/core/config/toml/target.rs
@@ -84,7 +84,7 @@ pub struct Target {
impl Target {
pub fn from_triple(triple: &str) -> Self {
let mut target: Self = Default::default();
- if triple.contains("-none") || triple.contains("nvptx") || triple.contains("switch") {
+ if !build_helper::targets::target_supports_std(triple) {
target.no_std = true;
}
if triple.contains("emscripten") {
diff --git a/src/bootstrap/src/core/download.rs b/src/bootstrap/src/core/download.rs
index ba00b40..f349b9a 100644
--- a/src/bootstrap/src/core/download.rs
+++ b/src/bootstrap/src/core/download.rs
@@ -3,7 +3,6 @@
use std::fs::{self, File};
use std::io::{BufRead, BufReader, BufWriter, ErrorKind, Write};
use std::path::{Path, PathBuf};
-use std::process::{Command, Stdio};
use std::sync::OnceLock;
use xz2::bufread::XzDecoder;
@@ -16,14 +15,7 @@
static SHOULD_FIX_BINS_AND_DYLIBS: OnceLock<bool> = OnceLock::new();
-/// `Config::try_run` wrapper for this module to avoid warnings on `try_run`, since we don't have access to a `builder` yet.
-fn try_run(config: &Config, cmd: &mut Command) -> Result<(), ()> {
- #[expect(deprecated)]
- config.try_run(cmd)
-}
-
-fn extract_curl_version(out: &[u8]) -> semver::Version {
- let out = String::from_utf8_lossy(out);
+fn extract_curl_version(out: String) -> semver::Version {
// The output should look like this: "curl <major>.<minor>.<patch> ..."
out.lines()
.next()
@@ -32,18 +24,21 @@ fn extract_curl_version(out: &[u8]) -> semver::Version {
.unwrap_or(semver::Version::new(1, 0, 0))
}
-fn curl_version() -> semver::Version {
- let mut curl = Command::new("curl");
+fn curl_version(config: &Config) -> semver::Version {
+ let mut curl = command("curl");
curl.arg("-V");
- let Ok(out) = curl.output() else { return semver::Version::new(1, 0, 0) };
- let out = out.stdout;
- extract_curl_version(&out)
+ let curl = curl.run_capture_stdout(config);
+ if curl.is_failure() {
+ return semver::Version::new(1, 0, 0);
+ }
+ let output = curl.stdout();
+ extract_curl_version(output)
}
/// Generic helpers that are useful anywhere in bootstrap.
impl Config {
pub fn is_verbose(&self) -> bool {
- self.verbose > 0
+ self.exec_ctx.is_verbose()
}
pub(crate) fn create<P: AsRef<Path>>(&self, path: P, s: &str) {
@@ -85,20 +80,14 @@ pub(crate) fn check_run(&self, cmd: &mut BootstrapCommand) -> bool {
/// on NixOS
fn should_fix_bins_and_dylibs(&self) -> bool {
let val = *SHOULD_FIX_BINS_AND_DYLIBS.get_or_init(|| {
- match Command::new("uname").arg("-s").stderr(Stdio::inherit()).output() {
- Err(_) => return false,
- Ok(output) if !output.status.success() => return false,
- Ok(output) => {
- let mut os_name = output.stdout;
- if os_name.last() == Some(&b'\n') {
- os_name.pop();
- }
- if os_name != b"Linux" {
- return false;
- }
- }
+ let uname = command("uname").allow_failure().arg("-s").run_capture_stdout(self);
+ if uname.is_failure() {
+ return false;
}
-
+ let output = uname.stdout();
+ if !output.starts_with("Linux") {
+ return false;
+ }
// If the user has asked binaries to be patched for Nix, then
// don't check for NixOS or `/lib`.
// NOTE: this intentionally comes after the Linux check:
@@ -173,23 +162,18 @@ fn fix_bin_or_dylib(&self, fname: &Path) {
];
}
";
- nix_build_succeeded = try_run(
- self,
- Command::new("nix-build").args([
- Path::new("-E"),
- Path::new(NIX_EXPR),
- Path::new("-o"),
- &nix_deps_dir,
- ]),
- )
- .is_ok();
+ nix_build_succeeded = command("nix-build")
+ .allow_failure()
+ .args([Path::new("-E"), Path::new(NIX_EXPR), Path::new("-o"), &nix_deps_dir])
+ .run_capture_stdout(self)
+ .is_success();
nix_deps_dir
});
if !nix_build_succeeded {
return;
}
- let mut patchelf = Command::new(nix_deps_dir.join("bin/patchelf"));
+ let mut patchelf = command(nix_deps_dir.join("bin/patchelf"));
patchelf.args(&[
OsString::from("--add-rpath"),
OsString::from(t!(fs::canonicalize(nix_deps_dir)).join("lib")),
@@ -200,8 +184,8 @@ fn fix_bin_or_dylib(&self, fname: &Path) {
let dynamic_linker = t!(fs::read_to_string(dynamic_linker_path));
patchelf.args(["--set-interpreter", dynamic_linker.trim_end()]);
}
-
- let _ = try_run(self, patchelf.arg(fname));
+ patchelf.arg(fname);
+ let _ = patchelf.allow_failure().run_capture_stdout(self);
}
fn download_file(&self, url: &str, dest_path: &Path, help_on_error: &str) {
@@ -267,7 +251,7 @@ fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error:
curl.arg("--progress-bar");
}
// --retry-all-errors was added in 7.71.0, don't use it if curl is old.
- if curl_version() >= semver::Version::new(7, 71, 0) {
+ if curl_version(self) >= semver::Version::new(7, 71, 0) {
curl.arg("--retry-all-errors");
}
curl.arg(url);
@@ -275,7 +259,7 @@ fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error:
if self.build.contains("windows-msvc") {
eprintln!("Fallback to PowerShell");
for _ in 0..3 {
- if try_run(self, Command::new("PowerShell.exe").args([
+ let powershell = command("PowerShell.exe").allow_failure().args([
"/nologo",
"-Command",
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;",
@@ -283,9 +267,12 @@ fn download_http_with_retries(&self, tempfile: &Path, url: &str, help_on_error:
"(New-Object System.Net.WebClient).DownloadFile('{}', '{}')",
url, tempfile.to_str().expect("invalid UTF-8 not supported with powershell downloads"),
),
- ])).is_err() {
+ ]).run_capture_stdout(self);
+
+ if powershell.is_failure() {
return;
}
+
eprintln!("\nspurious failure, trying again");
}
}
diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs
index af4ec67..b7bbd29 100644
--- a/src/bootstrap/src/core/sanity.rs
+++ b/src/bootstrap/src/core/sanity.rs
@@ -34,6 +34,8 @@ pub struct Finder {
// Targets can be removed from this list once they are present in the stage0 compiler (usually by updating the beta compiler of the bootstrap).
const STAGE0_MISSING_TARGETS: &[&str] = &[
// just a dummy comment so the list doesn't get onelined
+ "loongarch32-unknown-none",
+ "loongarch32-unknown-none-softfloat",
];
/// Minimum version threshold for libstdc++ required when using prebuilt LLVM
@@ -362,7 +364,7 @@ pub fn check(build: &mut Build) {
// Cygwin. The Cygwin build does not have generators for Visual
// Studio, so detect that here and error.
let out =
- command("cmake").arg("--help").run_always().run_capture_stdout(build).stdout();
+ command("cmake").arg("--help").run_always().run_capture_stdout(&build).stdout();
if !out.contains("Visual Studio") {
panic!(
"
diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs
index 07772b8..88d5d02 100644
--- a/src/bootstrap/src/lib.rs
+++ b/src/bootstrap/src/lib.rs
@@ -32,6 +32,7 @@
use termcolor::{ColorChoice, StandardStream, WriteColor};
use utils::build_stamp::BuildStamp;
use utils::channel::GitInfo;
+use utils::execution_context::ExecutionContext;
use crate::core::builder;
use crate::core::builder::Kind;
@@ -81,7 +82,10 @@
/// (Mode restriction, config name, config values (if any))
#[expect(clippy::type_complexity)] // It's fine for hard-coded list and type is explained above.
const EXTRA_CHECK_CFGS: &[(Option<Mode>, &str, Option<&[&'static str]>)] = &[
- (None, "bootstrap", None),
+ (Some(Mode::Rustc), "bootstrap", None),
+ (Some(Mode::Codegen), "bootstrap", None),
+ (Some(Mode::ToolRustc), "bootstrap", None),
+ (Some(Mode::ToolStd), "bootstrap", None),
(Some(Mode::Rustc), "llvm_enzyme", None),
(Some(Mode::Codegen), "llvm_enzyme", None),
(Some(Mode::ToolRustc), "llvm_enzyme", None),
@@ -195,7 +199,6 @@ pub struct Build {
crates: HashMap<String, Crate>,
crate_paths: HashMap<PathBuf, String>,
is_sudo: bool,
- delayed_failures: RefCell<Vec<String>>,
prerelease_version: Cell<Option<u32>>,
#[cfg(feature = "build-metrics")]
@@ -272,6 +275,16 @@ pub fn must_support_dlopen(&self) -> bool {
}
}
+/// When `rust.rust_remap_debuginfo` is requested, the compiler needs to know how to
+/// opportunistically unremap compiler vs non-compiler sources. We use two schemes,
+/// [`RemapScheme::Compiler`] and [`RemapScheme::NonCompiler`].
+pub enum RemapScheme {
+ /// The [`RemapScheme::Compiler`] scheme will remap to `/rustc-dev/{hash}`.
+ Compiler,
+ /// The [`RemapScheme::NonCompiler`] scheme will remap to `/rustc/{hash}`.
+ NonCompiler,
+}
+
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum CLang {
C,
@@ -456,7 +469,6 @@ pub fn new(mut config: Config) -> Build {
crates: HashMap::new(),
crate_paths: HashMap::new(),
is_sudo,
- delayed_failures: RefCell::new(Vec::new()),
prerelease_version: Cell::new(None),
#[cfg(feature = "build-metrics")]
@@ -616,7 +628,7 @@ pub fn update_existing_submodule(config: &Config, submodule: &str) {
return;
}
- if GitInfo::new(false, Path::new(submodule)).is_managed_git_subrepository() {
+ if config.git_info(false, Path::new(submodule)).is_managed_git_subrepository() {
config.update_submodule(submodule);
}
}
@@ -671,7 +683,7 @@ pub fn build(&mut self) {
#[cfg(feature = "tracing")]
let _sanity_check_span =
span!(tracing::Level::DEBUG, "(1) executing dry-run sanity-check").entered();
- self.config.dry_run = DryRun::SelfCheck;
+ self.config.set_dry_run(DryRun::SelfCheck);
let builder = builder::Builder::new(self);
builder.execute_cli();
}
@@ -681,7 +693,7 @@ pub fn build(&mut self) {
#[cfg(feature = "tracing")]
let _actual_run_span =
span!(tracing::Level::DEBUG, "(2) executing actual run").entered();
- self.config.dry_run = DryRun::Disabled;
+ self.config.set_dry_run(DryRun::Disabled);
let builder = builder::Builder::new(self);
builder.execute_cli();
}
@@ -697,14 +709,7 @@ pub fn build(&mut self) {
debug!("checking for postponed test failures from `test --no-fail-fast`");
// Check for postponed failures from `test --no-fail-fast`.
- let failures = self.delayed_failures.borrow();
- if !failures.is_empty() {
- eprintln!("\n{} command(s) did not execute successfully:\n", failures.len());
- for failure in failures.iter() {
- eprintln!(" - {failure}\n");
- }
- exit!(1);
- }
+ self.config.exec_ctx().report_failures_and_exit();
#[cfg(feature = "build-metrics")]
self.metrics.persist(self);
@@ -940,133 +945,6 @@ fn rustc_snapshot_sysroot(&self) -> &Path {
})
}
- /// Execute a command and return its output.
- /// Note: Ideally, you should use one of the BootstrapCommand::run* functions to
- /// execute commands. They internally call this method.
- #[track_caller]
- fn run(
- &self,
- command: &mut BootstrapCommand,
- stdout: OutputMode,
- stderr: OutputMode,
- ) -> CommandOutput {
- command.mark_as_executed();
- if self.config.dry_run() && !command.run_always {
- return CommandOutput::default();
- }
-
- #[cfg(feature = "tracing")]
- let _run_span = trace_cmd!(command);
-
- let created_at = command.get_created_location();
- let executed_at = std::panic::Location::caller();
-
- self.verbose(|| {
- println!("running: {command:?} (created at {created_at}, executed at {executed_at})")
- });
-
- let cmd = command.as_command_mut();
- cmd.stdout(stdout.stdio());
- cmd.stderr(stderr.stdio());
-
- let output = cmd.output();
-
- use std::fmt::Write;
-
- let mut message = String::new();
- let output: CommandOutput = match output {
- // Command has succeeded
- Ok(output) if output.status.success() => {
- CommandOutput::from_output(output, stdout, stderr)
- }
- // Command has started, but then it failed
- Ok(output) => {
- writeln!(
- message,
- r#"
-Command {command:?} did not execute successfully.
-Expected success, got {}
-Created at: {created_at}
-Executed at: {executed_at}"#,
- output.status,
- )
- .unwrap();
-
- let output: CommandOutput = CommandOutput::from_output(output, stdout, stderr);
-
- // If the output mode is OutputMode::Capture, we can now print the output.
- // If it is OutputMode::Print, then the output has already been printed to
- // stdout/stderr, and we thus don't have anything captured to print anyway.
- if stdout.captures() {
- writeln!(message, "\nSTDOUT ----\n{}", output.stdout().trim()).unwrap();
- }
- if stderr.captures() {
- writeln!(message, "\nSTDERR ----\n{}", output.stderr().trim()).unwrap();
- }
- output
- }
- // The command did not even start
- Err(e) => {
- writeln!(
- message,
- "\n\nCommand {command:?} did not execute successfully.\
- \nIt was not possible to execute the command: {e:?}"
- )
- .unwrap();
- CommandOutput::did_not_start(stdout, stderr)
- }
- };
-
- let fail = |message: &str, output: CommandOutput| -> ! {
- if self.is_verbose() {
- println!("{message}");
- } else {
- let (stdout, stderr) = (output.stdout_if_present(), output.stderr_if_present());
- // If the command captures output, the user would not see any indication that
- // it has failed. In this case, print a more verbose error, since to provide more
- // context.
- if stdout.is_some() || stderr.is_some() {
- if let Some(stdout) =
- output.stdout_if_present().take_if(|s| !s.trim().is_empty())
- {
- println!("STDOUT:\n{stdout}\n");
- }
- if let Some(stderr) =
- output.stderr_if_present().take_if(|s| !s.trim().is_empty())
- {
- println!("STDERR:\n{stderr}\n");
- }
- println!("Command {command:?} has failed. Rerun with -v to see more details.");
- } else {
- println!("Command has failed. Rerun with -v to see more details.");
- }
- }
- exit!(1);
- };
-
- if !output.is_success() {
- match command.failure_behavior {
- BehaviorOnFailure::DelayFail => {
- if self.fail_fast {
- fail(&message, output);
- }
-
- let mut failures = self.delayed_failures.borrow_mut();
- failures.push(message);
- }
- BehaviorOnFailure::Exit => {
- fail(&message, output);
- }
- BehaviorOnFailure::Ignore => {
- // If failures are allowed, either the error has been printed already
- // (OutputMode::Print) or the user used a capture output mode and wants to
- // handle the error output on their own.
- }
- }
- }
- output
- }
-
/// Check if verbosity is greater than the `level`
pub fn is_verbose_than(&self, level: usize) -> bool {
self.verbosity > level
@@ -1080,7 +958,7 @@ fn verbose_than(&self, level: usize, f: impl Fn()) {
}
fn info(&self, msg: &str) {
- match self.config.dry_run {
+ match self.config.get_dry_run() {
DryRun::SelfCheck => (),
DryRun::Disabled | DryRun::UserSelected => {
println!("{msg}");
@@ -1203,7 +1081,7 @@ fn msg_sysroot_tool(
#[track_caller]
fn group(&self, msg: &str) -> Option<gha::Group> {
- match self.config.dry_run {
+ match self.config.get_dry_run() {
DryRun::SelfCheck => None,
DryRun::Disabled | DryRun::UserSelected => Some(gha::group(msg)),
}
@@ -1217,7 +1095,7 @@ fn jobs(&self) -> u32 {
})
}
- fn debuginfo_map_to(&self, which: GitRepo) -> Option<String> {
+ fn debuginfo_map_to(&self, which: GitRepo, remap_scheme: RemapScheme) -> Option<String> {
if !self.config.rust_remap_debuginfo {
return None;
}
@@ -1225,7 +1103,24 @@ fn debuginfo_map_to(&self, which: GitRepo) -> Option<String> {
match which {
GitRepo::Rustc => {
let sha = self.rust_sha().unwrap_or(&self.version);
- Some(format!("/rustc/{sha}"))
+
+ match remap_scheme {
+ RemapScheme::Compiler => {
+ // For compiler sources, remap via `/rustc-dev/{sha}` to allow
+ // distinguishing between compiler sources vs library sources, since
+ // `rustc-dev` dist component places them under
+ // `$sysroot/lib/rustlib/rustc-src/rust` as opposed to `rust-src`'s
+ // `$sysroot/lib/rustlib/src/rust`.
+ //
+ // Keep this scheme in sync with `rustc_metadata::rmeta::decoder`'s
+ // `try_to_translate_virtual_to_real`.
+ Some(format!("/rustc-dev/{sha}"))
+ }
+ RemapScheme::NonCompiler => {
+ // For non-compiler sources, use `/rustc/{sha}` remapping scheme.
+ Some(format!("/rustc/{sha}"))
+ }
+ }
}
GitRepo::Llvm => Some(String::from("/rustc/llvm")),
}
@@ -1292,7 +1187,7 @@ fn cc_unhandled_cflags(
base.push("-fno-omit-frame-pointer".into());
}
- if let Some(map_to) = self.debuginfo_map_to(which) {
+ if let Some(map_to) = self.debuginfo_map_to(which, RemapScheme::NonCompiler) {
let map = format!("{}={}", self.src.display(), map_to);
let cc = self.cc(target);
if cc.ends_with("clang") || cc.ends_with("gcc") {
@@ -2015,6 +1910,16 @@ fn colored_stream_inner<R, F, C>(&self, constructor: C, is_tty: bool, f: F) -> R
stream.reset().unwrap();
result
}
+
+ pub fn exec_ctx(&self) -> &ExecutionContext {
+ &self.config.exec_ctx
+ }
+}
+
+impl AsRef<ExecutionContext> for Build {
+ fn as_ref(&self) -> &ExecutionContext {
+ &self.config.exec_ctx
+ }
}
#[cfg(unix)]
diff --git a/src/bootstrap/src/utils/channel.rs b/src/bootstrap/src/utils/channel.rs
index 4a9ecc7..38f250a 100644
--- a/src/bootstrap/src/utils/channel.rs
+++ b/src/bootstrap/src/utils/channel.rs
@@ -8,6 +8,7 @@
use std::fs;
use std::path::Path;
+use super::execution_context::ExecutionContext;
use super::helpers;
use crate::Build;
use crate::utils::helpers::{start_process, t};
@@ -34,7 +35,7 @@ pub struct Info {
}
impl GitInfo {
- pub fn new(omit_git_hash: bool, dir: &Path) -> GitInfo {
+ pub fn new(omit_git_hash: bool, dir: &Path, exec_ctx: impl AsRef<ExecutionContext>) -> GitInfo {
// See if this even begins to look like a git dir
if !dir.join(".git").exists() {
match read_commit_info_file(dir) {
@@ -43,10 +44,12 @@ pub fn new(omit_git_hash: bool, dir: &Path) -> GitInfo {
}
}
- // Make sure git commands work
- match helpers::git(Some(dir)).arg("rev-parse").as_command_mut().output() {
- Ok(ref out) if out.status.success() => {}
- _ => return GitInfo::Absent,
+ let mut git_command = helpers::git(Some(dir));
+ git_command.arg("rev-parse");
+ let output = git_command.allow_failure().run_capture(exec_ctx);
+
+ if output.is_failure() {
+ return GitInfo::Absent;
}
// If we're ignoring the git info, we don't actually need to collect it, just make sure this
diff --git a/src/bootstrap/src/utils/exec.rs b/src/bootstrap/src/utils/exec.rs
index 64e46f1..f297300 100644
--- a/src/bootstrap/src/utils/exec.rs
+++ b/src/bootstrap/src/utils/exec.rs
@@ -11,7 +11,7 @@
use build_helper::ci::CiEnv;
use build_helper::drop_bomb::DropBomb;
-use crate::Build;
+use super::execution_context::ExecutionContext;
/// What should be done when the command fails.
#[derive(Debug, Copy, Clone)]
@@ -125,7 +125,6 @@ pub fn delay_failure(self) -> Self {
Self { failure_behavior: BehaviorOnFailure::DelayFail, ..self }
}
- #[expect(dead_code)]
pub fn fail_fast(self) -> Self {
Self { failure_behavior: BehaviorOnFailure::Exit, ..self }
}
@@ -143,20 +142,20 @@ pub fn run_always(&mut self) -> &mut Self {
/// Run the command, while printing stdout and stderr.
/// Returns true if the command has succeeded.
#[track_caller]
- pub fn run(&mut self, builder: &Build) -> bool {
- builder.run(self, OutputMode::Print, OutputMode::Print).is_success()
+ pub fn run(&mut self, exec_ctx: impl AsRef<ExecutionContext>) -> bool {
+ exec_ctx.as_ref().run(self, OutputMode::Print, OutputMode::Print).is_success()
}
/// Run the command, while capturing and returning all its output.
#[track_caller]
- pub fn run_capture(&mut self, builder: &Build) -> CommandOutput {
- builder.run(self, OutputMode::Capture, OutputMode::Capture)
+ pub fn run_capture(&mut self, exec_ctx: impl AsRef<ExecutionContext>) -> CommandOutput {
+ exec_ctx.as_ref().run(self, OutputMode::Capture, OutputMode::Capture)
}
/// Run the command, while capturing and returning stdout, and printing stderr.
#[track_caller]
- pub fn run_capture_stdout(&mut self, builder: &Build) -> CommandOutput {
- builder.run(self, OutputMode::Capture, OutputMode::Print)
+ pub fn run_capture_stdout(&mut self, exec_ctx: impl AsRef<ExecutionContext>) -> CommandOutput {
+ exec_ctx.as_ref().run(self, OutputMode::Capture, OutputMode::Print)
}
/// Provides access to the stdlib Command inside.
@@ -280,7 +279,6 @@ pub fn is_failure(&self) -> bool {
!self.is_success()
}
- #[expect(dead_code)]
pub fn status(&self) -> Option<ExitStatus> {
match self.status {
CommandStatus::Finished(status) => Some(status),
diff --git a/src/bootstrap/src/utils/execution_context.rs b/src/bootstrap/src/utils/execution_context.rs
new file mode 100644
index 0000000..a5e1e9b
--- /dev/null
+++ b/src/bootstrap/src/utils/execution_context.rs
@@ -0,0 +1,204 @@
+//! Shared execution context for running bootstrap commands.
+//!
+//! This module provides the [`ExecutionContext`] type, which holds global configuration
+//! relevant during the execution of commands in bootstrap. This includes dry-run
+//! mode, verbosity level, and behavior on failure.
+use std::sync::{Arc, Mutex};
+
+use crate::core::config::DryRun;
+#[cfg(feature = "tracing")]
+use crate::trace_cmd;
+use crate::{BehaviorOnFailure, BootstrapCommand, CommandOutput, OutputMode, exit};
+
+#[derive(Clone, Default)]
+pub struct ExecutionContext {
+ dry_run: DryRun,
+ verbose: u8,
+ pub fail_fast: bool,
+ delayed_failures: Arc<Mutex<Vec<String>>>,
+}
+
+impl ExecutionContext {
+ pub fn new() -> Self {
+ ExecutionContext::default()
+ }
+
+ pub fn dry_run(&self) -> bool {
+ match self.dry_run {
+ DryRun::Disabled => false,
+ DryRun::SelfCheck | DryRun::UserSelected => true,
+ }
+ }
+
+ pub fn get_dry_run(&self) -> &DryRun {
+ &self.dry_run
+ }
+
+ pub fn verbose(&self, f: impl Fn()) {
+ if self.is_verbose() {
+ f()
+ }
+ }
+
+ pub fn is_verbose(&self) -> bool {
+ self.verbose > 0
+ }
+
+ pub fn fail_fast(&self) -> bool {
+ self.fail_fast
+ }
+
+ pub fn set_dry_run(&mut self, value: DryRun) {
+ self.dry_run = value;
+ }
+
+ pub fn set_verbose(&mut self, value: u8) {
+ self.verbose = value;
+ }
+
+ pub fn set_fail_fast(&mut self, value: bool) {
+ self.fail_fast = value;
+ }
+
+ pub fn add_to_delay_failure(&self, message: String) {
+ self.delayed_failures.lock().unwrap().push(message);
+ }
+
+ pub fn report_failures_and_exit(&self) {
+ let failures = self.delayed_failures.lock().unwrap();
+ if failures.is_empty() {
+ return;
+ }
+ eprintln!("\n{} command(s) did not execute successfully:\n", failures.len());
+ for failure in &*failures {
+ eprintln!(" - {failure}");
+ }
+ exit!(1);
+ }
+
+ /// Execute a command and return its output.
+ /// Note: Ideally, you should use one of the BootstrapCommand::run* functions to
+ /// execute commands. They internally call this method.
+ #[track_caller]
+ pub fn run(
+ &self,
+ command: &mut BootstrapCommand,
+ stdout: OutputMode,
+ stderr: OutputMode,
+ ) -> CommandOutput {
+ command.mark_as_executed();
+ if self.dry_run() && !command.run_always {
+ return CommandOutput::default();
+ }
+
+ #[cfg(feature = "tracing")]
+ let _run_span = trace_cmd!(command);
+
+ let created_at = command.get_created_location();
+ let executed_at = std::panic::Location::caller();
+
+ self.verbose(|| {
+ println!("running: {command:?} (created at {created_at}, executed at {executed_at})")
+ });
+
+ let cmd = command.as_command_mut();
+ cmd.stdout(stdout.stdio());
+ cmd.stderr(stderr.stdio());
+
+ let output = cmd.output();
+
+ use std::fmt::Write;
+
+ let mut message = String::new();
+ let output: CommandOutput = match output {
+ // Command has succeeded
+ Ok(output) if output.status.success() => {
+ CommandOutput::from_output(output, stdout, stderr)
+ }
+ // Command has started, but then it failed
+ Ok(output) => {
+ writeln!(
+ message,
+ r#"
+Command {command:?} did not execute successfully.
+Expected success, got {}
+Created at: {created_at}
+Executed at: {executed_at}"#,
+ output.status,
+ )
+ .unwrap();
+
+ let output: CommandOutput = CommandOutput::from_output(output, stdout, stderr);
+
+ // If the output mode is OutputMode::Capture, we can now print the output.
+ // If it is OutputMode::Print, then the output has already been printed to
+ // stdout/stderr, and we thus don't have anything captured to print anyway.
+ if stdout.captures() {
+ writeln!(message, "\nSTDOUT ----\n{}", output.stdout().trim()).unwrap();
+ }
+ if stderr.captures() {
+ writeln!(message, "\nSTDERR ----\n{}", output.stderr().trim()).unwrap();
+ }
+ output
+ }
+ // The command did not even start
+ Err(e) => {
+ writeln!(
+ message,
+ "\n\nCommand {command:?} did not execute successfully.\
+ \nIt was not possible to execute the command: {e:?}"
+ )
+ .unwrap();
+ CommandOutput::did_not_start(stdout, stderr)
+ }
+ };
+
+ let fail = |message: &str, output: CommandOutput| -> ! {
+ if self.is_verbose() {
+ println!("{message}");
+ } else {
+ let (stdout, stderr) = (output.stdout_if_present(), output.stderr_if_present());
+ // If the command captures output, the user would not see any indication that
+ // it has failed. In this case, print a more verbose error, since to provide more
+ // context.
+ if stdout.is_some() || stderr.is_some() {
+ if let Some(stdout) =
+ output.stdout_if_present().take_if(|s| !s.trim().is_empty())
+ {
+ println!("STDOUT:\n{stdout}\n");
+ }
+ if let Some(stderr) =
+ output.stderr_if_present().take_if(|s| !s.trim().is_empty())
+ {
+ println!("STDERR:\n{stderr}\n");
+ }
+ println!("Command {command:?} has failed. Rerun with -v to see more details.");
+ } else {
+ println!("Command has failed. Rerun with -v to see more details.");
+ }
+ }
+ exit!(1);
+ };
+
+ if !output.is_success() {
+ match command.failure_behavior {
+ BehaviorOnFailure::DelayFail => {
+ if self.fail_fast {
+ fail(&message, output);
+ }
+
+ self.add_to_delay_failure(message);
+ }
+ BehaviorOnFailure::Exit => {
+ fail(&message, output);
+ }
+ BehaviorOnFailure::Ignore => {
+ // If failures are allowed, either the error has been printed already
+ // (OutputMode::Print) or the user used a capture output mode and wants to
+ // handle the error output on their own.
+ }
+ }
+ }
+ output
+ }
+}
diff --git a/src/bootstrap/src/utils/mod.rs b/src/bootstrap/src/utils/mod.rs
index 169fcec..5a0b908 100644
--- a/src/bootstrap/src/utils/mod.rs
+++ b/src/bootstrap/src/utils/mod.rs
@@ -8,6 +8,7 @@
pub(crate) mod change_tracker;
pub(crate) mod channel;
pub(crate) mod exec;
+pub(crate) mod execution_context;
pub(crate) mod helpers;
pub(crate) mod job;
pub(crate) mod render_tests;
diff --git a/src/bootstrap/src/utils/render_tests.rs b/src/bootstrap/src/utils/render_tests.rs
index 418f3ff..77e645a 100644
--- a/src/bootstrap/src/utils/render_tests.rs
+++ b/src/bootstrap/src/utils/render_tests.rs
@@ -43,8 +43,7 @@ pub(crate) fn try_run_tests(
if builder.fail_fast {
crate::exit!(1);
} else {
- let mut failures = builder.delayed_failures.borrow_mut();
- failures.push(format!("{cmd:?}"));
+ builder.config.exec_ctx().add_to_delay_failure(format!("{cmd:?}"));
false
}
} else {
diff --git a/src/build_helper/src/lib.rs b/src/build_helper/src/lib.rs
index 1f5cf72..05de8fd 100644
--- a/src/build_helper/src/lib.rs
+++ b/src/build_helper/src/lib.rs
@@ -6,6 +6,7 @@
pub mod git;
pub mod metrics;
pub mod stage0_parser;
+pub mod targets;
pub mod util;
/// The default set of crates for opt-dist to collect LLVM profiles.
diff --git a/src/build_helper/src/targets.rs b/src/build_helper/src/targets.rs
new file mode 100644
index 0000000..cccc413
--- /dev/null
+++ b/src/build_helper/src/targets.rs
@@ -0,0 +1,11 @@
+// FIXME(#142296): this hack is because there is no reliable way (yet) to determine whether a given
+// target supports std. In the long-term, we should try to implement a way to *reliably* determine
+// target (std) metadata.
+//
+// NOTE: this is pulled out to `build_helpers` to share this hack between `bootstrap` and
+// `compiletest`.
+pub fn target_supports_std(target_tuple: &str) -> bool {
+ !(target_tuple.contains("-none")
+ || target_tuple.contains("nvptx")
+ || target_tuple.contains("switch"))
+}
diff --git a/src/ci/citool/src/jobs.rs b/src/ci/citool/src/jobs.rs
index 2884ae0..81e002e 100644
--- a/src/ci/citool/src/jobs.rs
+++ b/src/ci/citool/src/jobs.rs
@@ -161,6 +161,8 @@ pub enum RunType {
TryJob { job_patterns: Option<Vec<String>> },
/// Merge attempt workflow
AutoJob,
+ /// Fake job only used for sharing Github Actions cache.
+ MasterJob,
}
/// Maximum number of custom try jobs that can be requested in a single
@@ -210,6 +212,7 @@ fn calculate_jobs(
(jobs, "try", &db.envs.try_env)
}
RunType::AutoJob => (db.auto_jobs.clone(), "auto", &db.envs.auto_env),
+ RunType::MasterJob => return Ok(vec![]),
};
let jobs = substitute_github_vars(jobs.clone())
.context("Failed to substitute GitHub context variables in jobs")?;
@@ -262,7 +265,7 @@ pub fn calculate_job_matrix(
eprintln!("Run type: {run_type:?}");
let jobs = calculate_jobs(&run_type, &db, channel)?;
- if jobs.is_empty() {
+ if jobs.is_empty() && !matches!(run_type, RunType::MasterJob) {
return Err(anyhow::anyhow!("Computed job list is empty"));
}
@@ -270,6 +273,7 @@ pub fn calculate_job_matrix(
RunType::PullRequest => "pr",
RunType::TryJob { .. } => "try",
RunType::AutoJob => "auto",
+ RunType::MasterJob => "master",
};
eprintln!("Output");
diff --git a/src/ci/citool/src/main.rs b/src/ci/citool/src/main.rs
index bb73a5e..fe1b366 100644
--- a/src/ci/citool/src/main.rs
+++ b/src/ci/citool/src/main.rs
@@ -47,6 +47,7 @@ fn get_run_type(&self) -> Option<RunType> {
Some(RunType::TryJob { job_patterns: patterns })
}
("push", "refs/heads/auto") => Some(RunType::AutoJob),
+ ("push", "refs/heads/master") => Some(RunType::MasterJob),
_ => None,
}
}
diff --git a/src/ci/citool/tests/jobs.rs b/src/ci/citool/tests/jobs.rs
index fcdca89..83f2fc0 100644
--- a/src/ci/citool/tests/jobs.rs
+++ b/src/ci/citool/tests/jobs.rs
@@ -45,17 +45,31 @@ fn pr_jobs() {
"#);
}
+#[test]
+fn master_jobs() {
+ let stdout = get_matrix("push", "commit", "refs/heads/master");
+ insta::assert_snapshot!(stdout, @r#"
+ jobs=[]
+ run_type=master
+ "#);
+}
+
fn get_matrix(event_name: &str, commit_msg: &str, branch_ref: &str) -> String {
- let output = Command::new("cargo")
- .args(["run", "-q", "calculate-job-matrix", "--jobs-file", TEST_JOBS_YML_PATH])
+ let path = std::env::var("PATH");
+ let mut cmd = Command::new("cargo");
+ cmd.args(["run", "-q", "calculate-job-matrix", "--jobs-file", TEST_JOBS_YML_PATH])
+ .env_clear()
.env("GITHUB_EVENT_NAME", event_name)
.env("COMMIT_MESSAGE", commit_msg)
.env("GITHUB_REF", branch_ref)
.env("GITHUB_RUN_ID", "123")
.env("GITHUB_RUN_ATTEMPT", "1")
- .stdout(Stdio::piped())
- .output()
- .expect("Failed to execute command");
+ .stdout(Stdio::piped());
+ if let Ok(path) = path {
+ cmd.env("PATH", path);
+ }
+
+ let output = cmd.output().expect("Failed to execute command");
let stdout = String::from_utf8(output.stdout).unwrap();
let stderr = String::from_utf8(output.stderr).unwrap();
diff --git a/src/ci/docker/host-x86_64/mingw-check-2/Dockerfile b/src/ci/docker/host-x86_64/mingw-check-2/Dockerfile
index a1d04bd..ce18a18 100644
--- a/src/ci/docker/host-x86_64/mingw-check-2/Dockerfile
+++ b/src/ci/docker/host-x86_64/mingw-check-2/Dockerfile
@@ -36,4 +36,7 @@
RUSTDOCFLAGS=\"--document-private-items --document-hidden-items\" python3 ../x.py doc --stage 1 library && \
mkdir -p /checkout/obj/staging/doc && \
cp -r build/x86_64-unknown-linux-gnu/doc /checkout/obj/staging && \
- RUSTDOCFLAGS=\"--document-private-items --document-hidden-items\" python3 ../x.py doc --stage 1 library/test
+ RUSTDOCFLAGS=\"--document-private-items --document-hidden-items\" python3 ../x.py doc --stage 1 library/test && \
+ # The BOOTSTRAP_TRACING flag is added to verify whether the
+ # bootstrap process compiles successfully with this flag enabled.
+ BOOTSTRAP_TRACING=1 python3 ../x.py --help
diff --git a/src/ci/docker/scripts/rfl-build.sh b/src/ci/docker/scripts/rfl-build.sh
index fa18f67..c599289 100755
--- a/src/ci/docker/scripts/rfl-build.sh
+++ b/src/ci/docker/scripts/rfl-build.sh
@@ -2,8 +2,7 @@
set -euo pipefail
-# https://github.com/Rust-for-Linux/linux/issues/1163
-LINUX_VERSION=3ca02fc80cc4fdac63aaa6796642f1e07be591d6
+LINUX_VERSION=v6.16-rc1
# Build rustc, rustdoc, cargo, clippy-driver and rustfmt
../x.py build --stage 2 library rustdoc clippy rustfmt
diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml
index b6b2792..43c77d1 100644
--- a/src/ci/github-actions/jobs.yml
+++ b/src/ci/github-actions/jobs.yml
@@ -128,6 +128,11 @@
<<: *job-linux-4c
- name: mingw-check-tidy
continue_on_error: true
+ free_disk: false
+ env:
+ # This submodule is expensive to checkout, and it should not be needed for
+ # tidy. This speeds up the PR CI job by ~1 minute.
+ SKIP_SUBMODULES: src/gcc
<<: *job-linux-4c
- name: x86_64-gnu-llvm-19
env:
@@ -305,6 +310,10 @@
- name: mingw-check-2
<<: *job-linux-4c
+ - name: mingw-check-tidy
+ free_disk: false
+ <<: *job-linux-4c
+
- name: test-various
<<: *job-linux-4c
diff --git a/src/ci/run.sh b/src/ci/run.sh
index b6143af..e0c00dc 100755
--- a/src/ci/run.sh
+++ b/src/ci/run.sh
@@ -186,9 +186,11 @@
# Download GCC from CI on test builders
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set gcc.download-ci-gcc=true"
- if [ "$NO_DOWNLOAD_CI_RUSTC" = "" ]; then
- RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.download-rustc=if-unchanged"
- fi
+ # download-rustc seems to be broken on CI after the stage0 redesign
+ # Disable it until these issues are debugged and resolved
+# if [ "$NO_DOWNLOAD_CI_RUSTC" = "" ]; then
+# RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.download-rustc=if-unchanged"
+# fi
fi
if [ "$ENABLE_GCC_CODEGEN" = "1" ]; then
diff --git a/src/ci/scripts/checkout-submodules.sh b/src/ci/scripts/checkout-submodules.sh
index 5bb3432..3b64658 100755
--- a/src/ci/scripts/checkout-submodules.sh
+++ b/src/ci/scripts/checkout-submodules.sh
@@ -55,7 +55,11 @@
bg_pids[${i}]=$!
continue
else
+ # Submodule paths contained in SKIP_SUBMODULES (comma-separated list) will not be
+ # checked out.
+ if [ -z "${SKIP_SUBMODULES:-}" ] || [[ ! ",$SKIP_SUBMODULES," = *",$module,"* ]]; then
use_git="$use_git $module"
+ fi
fi
done
retry sh -c "git submodule deinit -f $use_git && \
diff --git a/src/doc/rustc-dev-guide/rust-version b/src/doc/rustc-dev-guide/rust-version
index 8b48bd5..c8721bb 100644
--- a/src/doc/rustc-dev-guide/rust-version
+++ b/src/doc/rustc-dev-guide/rust-version
@@ -1 +1 @@
-c68032fd4c442d275f4daa571ba19c076106b490
+c31cccb7b5cc098b1a8c1794ed38d7fdbec0ccb0
diff --git a/src/doc/rustc-dev-guide/src/SUMMARY.md b/src/doc/rustc-dev-guide/src/SUMMARY.md
index a7b7623..cba8eac 100644
--- a/src/doc/rustc-dev-guide/src/SUMMARY.md
+++ b/src/doc/rustc-dev-guide/src/SUMMARY.md
@@ -63,10 +63,8 @@
- [Notification groups](notification-groups/about.md)
- [Apple](notification-groups/apple.md)
- [ARM](notification-groups/arm.md)
- - [Cleanup Crew](notification-groups/cleanup-crew.md)
- [Emscripten](notification-groups/emscripten.md)
- [Fuchsia](notification-groups/fuchsia.md)
- - [LLVM](notification-groups/llvm.md)
- [RISC-V](notification-groups/risc-v.md)
- [Rust for Linux](notification-groups/rust-for-linux.md)
- [WASI](notification-groups/wasi.md)
@@ -101,6 +99,8 @@
- [Rustdoc internals](./rustdoc-internals.md)
- [Search](./rustdoc-internals/search.md)
- [The `rustdoc` test suite](./rustdoc-internals/rustdoc-test-suite.md)
+ - [The `rustdoc-gui` test suite](./rustdoc-internals/rustdoc-gui-test-suite.md)
+ - [The `rustdoc-json` test suite](./rustdoc-internals/rustdoc-json-test-suite.md)
- [Autodiff internals](./autodiff/internals.md)
- [Installation](./autodiff/installation.md)
- [How to debug](./autodiff/debugging.md)
diff --git a/src/doc/rustc-dev-guide/src/building/bootstrapping/debugging-bootstrap.md b/src/doc/rustc-dev-guide/src/building/bootstrapping/debugging-bootstrap.md
index 35d33eb..ed26785 100644
--- a/src/doc/rustc-dev-guide/src/building/bootstrapping/debugging-bootstrap.md
+++ b/src/doc/rustc-dev-guide/src/building/bootstrapping/debugging-bootstrap.md
@@ -55,7 +55,7 @@
Example basic usage[^just-trace]:
-[^just-trace]: It is not recommend to use *just* `BOOTSTRAP_TRACING=TRACE` because that will dump *everything* at `TRACE` level, including logs intentionally gated behind custom targets as they are too verbose even for `TRACE` level by default.
+[^just-trace]: It is not recommended to use *just* `BOOTSTRAP_TRACING=TRACE` because that will dump *everything* at `TRACE` level, including logs intentionally gated behind custom targets as they are too verbose even for `TRACE` level by default.
```bash
$ BOOTSTRAP_TRACING=bootstrap=TRACE ./x build library --stage 1
diff --git a/src/doc/rustc-dev-guide/src/getting-started.md b/src/doc/rustc-dev-guide/src/getting-started.md
index 435202c..d6c5c3ac 100644
--- a/src/doc/rustc-dev-guide/src/getting-started.md
+++ b/src/doc/rustc-dev-guide/src/getting-started.md
@@ -158,9 +158,6 @@
The following tasks are doable without much background knowledge but are
incredibly helpful:
-- [Cleanup crew][iceb]: find minimal reproductions of ICEs, bisect
- regressions, etc. This is a way of helping that saves a ton of time for
- others to fix an error later.
- [Writing documentation][wd]: if you are feeling a bit more intrepid, you could try
to read a part of the code and write doc comments for it. This will help you
to learn some part of the compiler while also producing a useful artifact!
@@ -179,7 +176,6 @@
[users]: https://users.rust-lang.org/
[so]: http://stackoverflow.com/questions/tagged/rust
[community-library]: https://github.com/rust-lang/rfcs/labels/A-community-library
-[iceb]: ./notification-groups/cleanup-crew.md
[wd]: ./contributing.md#writing-documentation
[wg]: https://rust-lang.github.io/compiler-team/working-groups/
[triage]: ./contributing.md#issue-triage
diff --git a/src/doc/rustc-dev-guide/src/notification-groups/about.md b/src/doc/rustc-dev-guide/src/notification-groups/about.md
index af305f0..d75891e 100644
--- a/src/doc/rustc-dev-guide/src/notification-groups/about.md
+++ b/src/doc/rustc-dev-guide/src/notification-groups/about.md
@@ -21,9 +21,7 @@
Here's the list of the notification groups:
- [Apple](./apple.md)
- [ARM](./arm.md)
-- [Cleanup Crew](./cleanup-crew.md)
- [Emscripten](./emscripten.md)
-- [LLVM Icebreakers](./llvm.md)
- [RISC-V](./risc-v.md)
- [WASI](./wasi.md)
- [WebAssembly](./wasm.md)
@@ -64,9 +62,7 @@
* [Example of adding yourself to the Apple group.](https://github.com/rust-lang/team/pull/1434)
* [Example of adding yourself to the ARM group.](https://github.com/rust-lang/team/pull/358)
-* [Example of adding yourself to the Cleanup Crew.](https://github.com/rust-lang/team/pull/221)
* [Example of adding yourself to the Emscripten group.](https://github.com/rust-lang/team/pull/1579)
-* [Example of adding yourself to the LLVM group.](https://github.com/rust-lang/team/pull/140)
* [Example of adding yourself to the RISC-V group.](https://github.com/rust-lang/team/pull/394)
* [Example of adding yourself to the WASI group.](https://github.com/rust-lang/team/pull/1580)
* [Example of adding yourself to the WebAssembly group.](https://github.com/rust-lang/team/pull/1581)
@@ -81,9 +77,7 @@
```text
@rustbot ping apple
@rustbot ping arm
-@rustbot ping cleanup-crew
@rustbot ping emscripten
-@rustbot ping icebreakers-llvm
@rustbot ping risc-v
@rustbot ping wasi
@rustbot ping wasm
@@ -92,12 +86,12 @@
To make some commands shorter and easier to remember, there are aliases,
defined in the [`triagebot.toml`] file. For example, all of these commands
-are equivalent and will ping the Cleanup Crew:
+are equivalent and will ping the Apple group:
```text
-@rustbot ping cleanup
-@rustbot ping bisect
-@rustbot ping reduce
+@rustbot ping apple
+@rustbot ping macos
+@rustbot ping ios
```
Keep in mind that these aliases are meant to make humans' life easier.
diff --git a/src/doc/rustc-dev-guide/src/notification-groups/cleanup-crew.md b/src/doc/rustc-dev-guide/src/notification-groups/cleanup-crew.md
deleted file mode 100644
index 9cf4e51..0000000
--- a/src/doc/rustc-dev-guide/src/notification-groups/cleanup-crew.md
+++ /dev/null
@@ -1,90 +0,0 @@
-# Cleanup Crew
-
-**Github Label:** [ICEBreaker-Cleanup-Crew] <br>
-**Ping command:** `@rustbot ping cleanup-crew`
-
-[ICEBreaker-Cleanup-Crew]: https://github.com/rust-lang/rust/labels/ICEBreaker-Cleanup-Crew
-
-The "Cleanup Crew" are focused on improving bug reports. Specifically,
-the goal is to try to ensure that every bug report has all the
-information that will be needed for someone to fix it:
-
-* a minimal, standalone example that shows the problem
-* links to duplicates or related bugs
-* if the bug is a regression (something that used to work, but no longer does),
- then a bisection to the PR or nightly that caused the regression
-
-This kind of cleanup is invaluable in getting bugs fixed. Better
-still, it can be done by anybody who knows Rust, without any
-particularly deep knowledge of the compiler.
-
-Let's look a bit at the workflow for doing "cleanup crew" actions.
-
-## Finding a minimal, standalone example
-
-Here the ultimate goal is to produce an example that reproduces the same
-problem but without relying on any external crates. Such a test ought to contain
-as little code as possible, as well. This will make it much easier to isolate the problem.
-
-However, even if the "ultimate minimal test" cannot be achieved, it's
-still useful to post incremental minimizations. For example, if you
-can eliminate some of the external dependencies, that is helpful, and
-so forth.
-
-It's particularly useful to reduce to an example that works
-in the [Rust playground](https://play.rust-lang.org/), rather than
-requiring people to checkout a cargo build.
-
-There are many resources for how to produce minimized test cases. Here
-are a few:
-
-* The [rust-reduce](https://github.com/jethrogb/rust-reduce) tool can try to reduce
- code automatically.
- * The [C-reduce](https://github.com/csmith-project/creduce) tool also works
- on Rust code, though it requires that you start from a single
- file. (A post explaining how to do it can be found [here](https://insaneinside.net/2017/09/12/whole-crate-bug-reduction-with-creduce.html).)
-* pnkfelix's [Rust Bug Minimization Patterns] blog post
- * This post focuses on "heavy bore" techniques, where you are
- starting with a large, complex cargo project that you wish to
- narrow down to something standalone.
-
-[Rust Bug Minimization Patterns]: http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/
-
-## Links to duplicate or related bugs
-
-If you are on the "Cleanup Crew", you will sometimes see multiple bug
-reports that seem very similar. You can link one to the other just by
-mentioning the other bug number in a Github comment. Sometimes it is
-useful to close duplicate bugs. But if you do so, you should always
-copy any test case from the bug you are closing to the other bug that
-remains open, as sometimes duplicate-looking bugs will expose
-different facets of the same problem.
-
-## Bisecting regressions
-
-For regressions (something that used to work, but no longer does), it
-is super useful if we can figure out precisely when the code stopped
-working. The gold standard is to be able to identify the precise
-**PR** that broke the code, so we can ping the author, but even
-narrowing it down to a nightly build is helpful, especially as that
-then gives us a range of PRs. (One other challenge is that we
-sometimes land "rollup" PRs, which combine multiple PRs into one.)
-
-### cargo-bisect-rustc
-
-To help in figuring out the cause of a regression we have a tool
-called [cargo-bisect-rustc]. It will automatically download and test
-various builds of rustc. For recent regressions, it is even able to
-use the builds from our CI to track down the regression to a specific
-PR; for older regressions, it will simply identify a nightly.
-
-To learn to use [cargo-bisect-rustc], check out [this blog post][learn], which
-gives a quick introduction to how it works. Additionally, there is a [Guide]
-which goes into more detail on how to use it. You can also ask questions at
-the Zulip stream [`#t-compiler/cargo-bisect-rustc`][zcbr], or help in
-improving the tool.
-
-[cargo-bisect-rustc]: https://github.com/rust-lang/cargo-bisect-rustc/
-[learn]: https://blog.rust-lang.org/inside-rust/2019/12/18/bisecting-rust-compiler.html
-[zcbr]: https://rust-lang.zulipchat.com/#narrow/stream/217417-t-compiler.2Fcargo-bisect-rustc
-[Guide]: https://rust-lang.github.io/cargo-bisect-rustc/
diff --git a/src/doc/rustc-dev-guide/src/notification-groups/llvm.md b/src/doc/rustc-dev-guide/src/notification-groups/llvm.md
deleted file mode 100644
index 9d00872..0000000
--- a/src/doc/rustc-dev-guide/src/notification-groups/llvm.md
+++ /dev/null
@@ -1,38 +0,0 @@
-# LLVM Icebreakers Notification group
-
-**Github Label:** [A-LLVM] <br>
-**Ping command:** `@rustbot ping icebreakers-llvm`
-
-[A-LLVM]: https://github.com/rust-lang/rust/labels/A-LLVM
-
-*Note*: this notification group is *not* the same as the LLVM working group
-(WG-llvm).
-
-The "LLVM Icebreakers Notification Group" are focused on bugs that center around
-LLVM. These bugs often arise because of LLVM optimizations gone awry, or as the
-result of an LLVM upgrade. The goal here is:
-
-- to determine whether the bug is a result of us generating invalid LLVM IR,
- or LLVM misoptimizing;
-- if the former, to fix our IR;
-- if the latter, to try and file a bug on LLVM (or identify an existing bug).
-
-The group may also be asked to weigh in on other sorts of LLVM-focused
-questions.
-
-## Helpful tips and options
-
-The ["Debugging LLVM"][d] section of the
-rustc-dev-guide gives a step-by-step process for how to help debug bugs
-caused by LLVM. In particular, it discusses how to emit LLVM IR, run
-the LLVM IR optimization pipelines, and so forth. You may also find
-it useful to look at the various codegen options listed under `-C help`
-and the internal options under `-Z help` -- there are a number that
-pertain to LLVM (just search for LLVM).
-
-[d]: ../backend/debugging.md
-
-## If you do narrow to an LLVM bug
-
-The ["Debugging LLVM"][d] section also describes what to do once
-you've identified the bug.
diff --git a/src/doc/rustc-dev-guide/src/rustdoc-internals.md b/src/doc/rustc-dev-guide/src/rustdoc-internals.md
index bc91c62..0234d4a 100644
--- a/src/doc/rustc-dev-guide/src/rustdoc-internals.md
+++ b/src/doc/rustc-dev-guide/src/rustdoc-internals.md
@@ -270,35 +270,6 @@
Some extra reading about `make_test` can be found
[here](https://quietmisdreavus.net/code/2018/02/23/how-the-doctests-get-made/).
-## Dotting i's And Crossing t's
-
-So that's `rustdoc`'s code in a nutshell, but there's more things in the
-compiler that deal with it. Since we have the full `compiletest` suite at hand,
-there's a set of tests in `tests/rustdoc` that make sure the final `HTML` is
-what we expect in various situations. These tests also use a supplementary
-script, `src/etc/htmldocck.py`, that allows it to look through the final `HTML`
-using `XPath` notation to get a precise look at the output. The full
-description of all the commands available to `rustdoc` tests (e.g. [`@has`] and
-[`@matches`]) is in [`htmldocck.py`].
-
-To use multiple crates in a `rustdoc` test, add `//@ aux-build:filename.rs`
-to the top of the test file. `filename.rs` should be placed in an `auxiliary`
-directory relative to the test file with the comment. If you need to build
-docs for the auxiliary file, use `//@ build-aux-docs`.
-
-In addition, there are separate tests for the search index and `rustdoc`'s
-ability to query it. The files in `tests/rustdoc-js` each contain a
-different search query and the expected results, broken out by search tab.
-These files are processed by a script in `src/tools/rustdoc-js` and the `Node.js`
-runtime. These tests don't have as thorough of a writeup, but a broad example
-that features results in all tabs can be found in `basic.js`. The basic idea is
-that you match a given `QUERY` with a set of `EXPECTED` results, complete with
-the full item path of each item.
-
-[`@has`]: https://github.com/rust-lang/rust/blob/master/src/etc/htmldocck.py#L39
-[`@matches`]: https://github.com/rust-lang/rust/blob/master/src/etc/htmldocck.py#L44
-[`htmldocck.py`]: https://github.com/rust-lang/rust/blob/master/src/etc/htmldocck.py
-
## Testing Locally
Some features of the generated `HTML` documentation might require local
diff --git a/src/doc/rustc-dev-guide/src/rustdoc-internals/rustdoc-gui-test-suite.md b/src/doc/rustc-dev-guide/src/rustdoc-internals/rustdoc-gui-test-suite.md
new file mode 100644
index 0000000..e155f960
--- /dev/null
+++ b/src/doc/rustc-dev-guide/src/rustdoc-internals/rustdoc-gui-test-suite.md
@@ -0,0 +1,14 @@
+# The `rustdoc-gui` test suite
+
+> **FIXME**: This section is a stub. Please help us flesh it out!
+
+This page is about the test suite named `rustdoc-gui` used to test the "GUI" of `rustdoc` (i.e., the HTML/JS/CSS as rendered in a browser).
+For other rustdoc-specific test suites, see [Rustdoc test suites].
+
+These use a NodeJS-based tool called [`browser-UI-test`] that uses [puppeteer] to run tests in a headless browser and check rendering and interactivity. For information on how to write this form of test, see [`tests/rustdoc-gui/README.md`][rustdoc-gui-readme] as well as [the description of the `.goml` format][goml-script]
+
+[Rustdoc test suites]: ../tests/compiletest.md#rustdoc-test-suites
+[`browser-UI-test`]: https://github.com/GuillaumeGomez/browser-UI-test/
+[puppeteer]: https://pptr.dev/
+[rustdoc-gui-readme]: https://github.com/rust-lang/rust/blob/master/tests/rustdoc-gui/README.md
+[goml-script]: https://github.com/GuillaumeGomez/browser-UI-test/blob/master/goml-script.md
diff --git a/src/doc/rustc-dev-guide/src/rustdoc-internals/rustdoc-json-test-suite.md b/src/doc/rustc-dev-guide/src/rustdoc-internals/rustdoc-json-test-suite.md
new file mode 100644
index 0000000..e08f770
--- /dev/null
+++ b/src/doc/rustc-dev-guide/src/rustdoc-internals/rustdoc-json-test-suite.md
@@ -0,0 +1,3 @@
+# The `rustdoc-json` test suite
+
+> **FIXME**: This section is a stub. It will be populated by [PR #2422](https://github.com/rust-lang/rustc-dev-guide/pull/2422/).
diff --git a/src/doc/rustc-dev-guide/src/rustdoc-internals/rustdoc-test-suite.md b/src/doc/rustc-dev-guide/src/rustdoc-internals/rustdoc-test-suite.md
index bad7ac1..b05318c 100644
--- a/src/doc/rustc-dev-guide/src/rustdoc-internals/rustdoc-test-suite.md
+++ b/src/doc/rustc-dev-guide/src/rustdoc-internals/rustdoc-test-suite.md
@@ -1,112 +1,191 @@
# The `rustdoc` test suite
-This page is specifically about the test suite named `rustdoc`.
-For other test suites used for testing rustdoc, see [Rustdoc tests](../rustdoc.md#tests).
+This page is about the test suite named `rustdoc` used to test the HTML output of `rustdoc`.
+For other rustdoc-specific test suites, see [Rustdoc test suites].
-The `rustdoc` test suite is specifically used to test the HTML output of rustdoc.
+Each test file in this test suite is simply a Rust source file `file.rs` sprinkled with
+so-called *directives* located inside normal Rust code comments.
+These come in two flavors: *Compiletest* and *HtmlDocCk*.
-This is achieved by means of `htmldocck.py`, a custom checker script that leverages [XPath].
+To learn more about the former, read [Compiletest directives].
+For the latter, continue reading.
-[XPath]: https://en.wikipedia.org/wiki/XPath
+Internally, [`compiletest`] invokes the supplementary checker script [`htmldocck.py`].
-## Directives
-Directives to htmldocck are similar to those given to `compiletest` in that they take the form of `//@` comments.
+[Rustdoc test suites]: ../tests/compiletest.md#rustdoc-test-suites
+[`compiletest`]: ../tests/compiletest.md
+[`htmldocck.py`]: https://github.com/rust-lang/rust/blob/master/src/etc/htmldocck.py
-In addition to the directives listed here,
-`rustdoc` tests also support most
-[compiletest directives](../tests/directives.html).
+## HtmlDocCk Directives
-All `PATH`s in directives are relative to the rustdoc output directory (`build/TARGET/test/rustdoc/TESTNAME`),
-so it is conventional to use a `#![crate_name = "foo"]` attribute to avoid
-having to write a long crate name multiple times.
-To avoid repetition, `-` can be used in any `PATH` argument to re-use the previous `PATH` argument.
+Directives to HtmlDocCk are assertions that place constraints on the generated HTML.
+They look similar to those given to `compiletest` in that they take the form of `//@` comments
+but ultimately, they are completey distinct and processed by different programs.
-All arguments take the form of quoted strings
-(both single and double quotes are supported),
+[XPath] is used to query parts of the HTML document tree.
+
+**Introductory example**:
+
+```rust,ignore (illustrative)
+//@ has file/type.Alias.html
+//@ has - '//*[@class="rust item-decl"]//code' 'type Alias = Option<i32>;'
+pub type Alias = Option<i32>;
+```
+
+Here, we check that documentation generated for crate `file` contains a page for the
+public type alias `Alias` where the code block that is found at the top contains the
+expected rendering of the item. The `//*[@class="rust item-decl"]//code` is an XPath
+expression.
+
+Conventionally, you place these directives directly above the thing they are meant to test.
+Technically speaking however, they don't need to be as HtmlDocCk only looks for the directives.
+
+All directives take a `PATH` argument.
+To avoid repetition, `-` can be passed to it to re-use the previous `PATH` argument.
+Since the path contains the name of the crate, it is conventional to add a
+`#![crate_name = "foo"]` attribute to the crate root to shorten the resulting path.
+
+All arguments take the form of shell-style (single or double) quoted strings,
with the exception of `COUNT` and the special `-` form of `PATH`.
-Directives are assertions that place constraints on the generated HTML.
-
-All directives (except `files`) can be negated by putting a `!` in front of their name.
+All directives (except `files`) can be *negated* by putting a `!` in front of their name.
+Before you add negated directives, please read about [their caveats](#caveats).
Similar to shell commands,
directives can extend across multiple lines if their last char is `\`.
In this case, the start of the next line should be `//`, with no `@`.
-For example, `//@ !has 'foo/struct.Bar.html'` checks that crate `foo` does not have a page for a struct named `Bar` in the crate root.
+Use the special string `{{channel}}` in XPaths, `PATTERN` arguments and [snapshot files](#snapshot)
+if you'd like to refer to the URL `https://doc.rust-lang.org/CHANNEL` where `CHANNEL` refers to the
+current release channel (e.g, `stable` or `nightly`).
+
+Listed below are all possible directives:
+
+[XPath]: https://en.wikipedia.org/wiki/XPath
### `has`
-Usage 1: `//@ has PATH`
-Usage 2: `//@ has PATH XPATH PATTERN`
+> Usage 1: `//@ has PATH`
-In the first form, `has` checks that a given file exists.
+Check that the file given by `PATH` exists.
-In the second form, `has` is an alias for `matches`,
-except `PATTERN` is a whitespace-normalized[^1] string instead of a regex.
+> Usage 2: `//@ has PATH XPATH PATTERN`
-### `matches`
+Checks that the text of each element / attribute / text selected by `XPATH` in the
+whitespace-normalized[^1] file given by `PATH` matches the
+(also whitespace-normalized) string `PATTERN`.
-Usage: `//@ matches PATH XPATH PATTERN`
-
-Checks that the text of each element selected by `XPATH` in `PATH` matches the python-flavored regex `PATTERN`.
-
-### `matchesraw`
-
-Usage: `//@ matchesraw PATH PATTERN`
-
-Checks that the contents of the file `PATH` matches the regex `PATTERN`.
+**Tip**: If you'd like to avoid whitespace normalization and/or if you'd like to match with a regex,
+use `matches` instead.
### `hasraw`
-Usage: `//@ hasraw PATH PATTERN`
+> Usage: `//@ hasraw PATH PATTERN`
-Same as `matchesraw`, except `PATTERN` is a whitespace-normalized[^1] string instead of a regex.
+Checks that the contents of the whitespace-normalized[^1] file given by `PATH`
+matches the (also whitespace-normalized) string `PATTERN`.
+
+**Tip**: If you'd like to avoid whitespace normalization and / or if you'd like to match with a
+regex, use `matchesraw` instead.
+
+### `matches`
+
+> Usage: `//@ matches PATH XPATH PATTERN`
+
+Checks that the text of each element / attribute / text selected by `XPATH` in the
+file given by `PATH` matches the Python-flavored[^2] regex `PATTERN`.
+
+### `matchesraw`
+
+> Usage: `//@ matchesraw PATH PATTERN`
+
+Checks that the contents of the file given by `PATH` matches the
+Python-flavored[^2] regex `PATTERN`.
### `count`
-Usage: `//@ count PATH XPATH COUNT`
+> Usage: `//@ count PATH XPATH COUNT`
-Checks that there are exactly `COUNT` matches for `XPATH` within the file `PATH`.
+Checks that there are exactly `COUNT` matches for `XPATH` within the file given by `PATH`.
### `snapshot`
-Usage: `//@ snapshot NAME PATH XPATH`
+> Usage: `//@ snapshot NAME PATH XPATH`
-Creates a snapshot test named NAME.
-A snapshot test captures a subtree of the DOM, at the location
-determined by the XPath, and compares it to a pre-recorded value
-in a file. The file's name is the test's name with the `.rs` extension
-replaced with `.NAME.html`, where NAME is the snapshot's name.
+Checks that the element / text selected by `XPATH` in the file given by `PATH` matches the
+pre-recorded subtree or text (the "snapshot") in file `FILE_STEM.NAME.html` where `FILE_STEM`
+is the file stem of the test file.
-htmldocck supports the `--bless` option to accept the current subtree
-as expected, saving it to the file determined by the snapshot's name.
-compiletest's `--bless` flag is forwarded to htmldocck.
+Pass the `--bless` option to `compiletest` to accept the current subtree/text as expected.
+This will overwrite the aforementioned file (or create it if it doesn't exist). It will
+automatically normalize the channel-dependent URL `https://doc.rust-lang.org/CHANNEL` to
+the special string `{{channel}}`.
### `has-dir`
-Usage: `//@ has-dir PATH`
+> Usage: `//@ has-dir PATH`
-Checks for the existence of directory `PATH`.
+Checks for the existence of the directory given by `PATH`.
### `files`
-Usage: `//@ files PATH ENTRIES`
+> Usage: `//@ files PATH ENTRIES`
-Checks that the directory `PATH` contains exactly `ENTRIES`.
-`ENTRIES` is a python list of strings inside a quoted string,
-as if it were to be parsed by `eval`.
-(note that the list is actually parsed by `shlex.split`,
-so it cannot contain arbitrary python expressions).
+Checks that the directory given by `PATH` contains exactly `ENTRIES`.
+`ENTRIES` is a Python-like list of strings inside a quoted string.
-Example: `//@ files "foo/bar" '["index.html", "sidebar-items.js"]'`
+**Example**: `//@ files "foo/bar" '["index.html", "sidebar-items.js"]'`
-[^1]: Whitespace normalization means that all spans of consecutive whitespace are replaced with a single space. The files themselves are also whitespace-normalized.
+[^1]: Whitespace normalization means that all spans of consecutive whitespace are replaced with a single space.
+[^2]: They are Unicode aware (flag `UNICODE` is set), match case-sensitively and in single-line mode.
+
+## Compiletest Directives (Brief)
+
+As mentioned in the introduction, you also have access to [compiletest directives].
+Most importantly, they allow you to register auxiliary crates and
+to pass flags to the `rustdoc` binary under test.
+It's *strongly recommended* to read that chapter if you don't know anything about them yet.
+
+Here are some details that are relevant to this test suite specifically:
+
+* While you can use both `//@ compile-flags` and `//@ doc-flags` to pass flags to `rustdoc`,
+ prefer to user the latter to show intent. The former is meant for `rustc`.
+* Add `//@ build-aux-docs` to the test file that has auxiliary crates to not only compile the
+ auxiliaries with `rustc` but to also document them with `rustdoc`.
+
+## Caveats
+
+Testing for the absence of an element or a piece of text is quite fragile and not very future proof.
+
+It's not unusual that the *shape* of the generated HTML document tree changes from time to time.
+This includes for example renamings of CSS classes.
+
+Whenever that happens, *positive* checks will either continue to match the intended element /
+attribute / text (if their XPath expression is general / loose enough) and
+thus continue to test the correct thing or they won't in which case they would fail thereby
+forcing the author of the change to look at them.
+
+Compare that to *negative* checks (e.g., `//@ !has PATH XPATH PATTERN`) which won't fail if their
+XPath expression "no longer" matches. The author who changed "the shape" thus won't get notified and
+as a result someone else can unintentionally reintroduce `PATTERN` into the generated docs without
+the original negative check failing.
+
+**Note**: Please avoid the use of *negated* checks!
+
+**Tip**: If you can't avoid it, please **always** pair it with an analogous positive check in the
+immediate vicinity, so people changing "the shape" have a chance to notice and to update the
+negated check!
## Limitations
-`htmldocck.py` uses the xpath implementation from the standard library.
+
+HtmlDocCk uses the XPath implementation from the Python standard library.
This leads to several limitations:
+
* All `XPATH` arguments must start with `//` due to a flaw in the implementation.
* Many XPath features (functions, axies, etc.) are not supported.
* Only well-formed HTML can be parsed (hopefully rustdoc doesn't output mismatched tags).
+Furthmore, compiletest [revisions] are not supported.
+
+[revisions]: ../tests/compiletest.md#revisions
+[compiletest directives]: ../tests/directives.md
diff --git a/src/doc/rustc-dev-guide/src/rustdoc.md b/src/doc/rustc-dev-guide/src/rustdoc.md
index de70ba6..52ae48c 100644
--- a/src/doc/rustc-dev-guide/src/rustdoc.md
+++ b/src/doc/rustc-dev-guide/src/rustdoc.md
@@ -67,43 +67,29 @@
## Code structure
-* All paths in this section are relative to `src/librustdoc` in the rust-lang/rust repository.
+All paths in this section are relative to `src/librustdoc/` in the rust-lang/rust repository.
+
* Most of the HTML printing code is in `html/format.rs` and `html/render/mod.rs`.
- It's in a bunch of `fmt::Display` implementations and supplementary
- functions.
-* The types that got `Display` impls above are defined in `clean/mod.rs`, right
- next to the custom `Clean` trait used to process them out of the rustc HIR.
+ It's in a bunch of functions returning `impl std::fmt::Display`.
+* The data types that get rendered by the functions mentioned above are defined in `clean/types.rs`.
+ The functions responsible for creating them from the `HIR` and the `rustc_middle::ty` IR
+ live in `clean/mod.rs`.
* The bits specific to using rustdoc as a test harness are in
`doctest.rs`.
* The Markdown renderer is loaded up in `html/markdown.rs`, including functions
for extracting doctests from a given block of Markdown.
* Frontend CSS and JavaScript are stored in `html/static/`.
+ * Re. JavaScript, type annotations are written using [TypeScript-flavored JSDoc]
+comments and an external `.d.ts` file.
+ This way, the code itself remains plain, valid JavaScript.
+ We only use `tsc` as a linter.
+
+[TypeScript-flavored JSDoc]: https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html
## Tests
-* Tests on search engine and index are located in `tests/rustdoc-js` and `tests/rustdoc-js-std`.
- The format is specified
- [in the search guide](rustdoc-internals/search.md#testing-the-search-engine).
-* Tests on the "UI" of rustdoc (the terminal output it produces when run) are in
- `tests/rustdoc-ui`
-* Tests on the "GUI" of rustdoc (the HTML, JS, and CSS as rendered in a browser)
- are in `tests/rustdoc-gui`. These use a [NodeJS tool called
- browser-UI-test](https://github.com/GuillaumeGomez/browser-UI-test/) that uses
- puppeteer to run tests in a headless browser and check rendering and
- interactivity. For information on how to write this form of test,
- see [`tests/rustdoc-gui/README.md`][rustdoc-gui-readme]
- as well as [the description of the `.goml` format][goml-script]
-* Tests on the structure of rustdoc HTML output are located in `tests/rustdoc`,
- where they're handled by the test runner of bootstrap and
- the supplementary script `src/etc/htmldocck.py`.
- [These tests have several extra directives available to them](./rustdoc-internals/rustdoc-test-suite.md).
-* Additionally, JavaScript type annotations are written using [TypeScript-flavored JSDoc]
- comments and an external d.ts file. The code itself is plain, valid JavaScript; we only
- use tsc as a linter.
-
-[TypeScript-flavored JSDoc]: https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html
-[rustdoc-gui-readme]: https://github.com/rust-lang/rust/blob/master/tests/rustdoc-gui/README.md
-[goml-script]: https://github.com/GuillaumeGomez/browser-UI-test/blob/master/goml-script.md
+`rustdoc`'s integration tests are split across several test suites.
+See [Rustdoc tests suites](tests/compiletest.md#rustdoc-test-suites) for more details.
## Constraints
diff --git a/src/doc/rustc-dev-guide/src/tests/compiletest.md b/src/doc/rustc-dev-guide/src/tests/compiletest.md
index ee06ca3..20dd16c 100644
--- a/src/doc/rustc-dev-guide/src/tests/compiletest.md
+++ b/src/doc/rustc-dev-guide/src/tests/compiletest.md
@@ -56,6 +56,9 @@
The following test suites are available, with links for more information:
+[`tests`]: https://github.com/rust-lang/rust/blob/master/tests
+[`src/tools/compiletest/src/common.rs`]: https://github.com/rust-lang/rust/tree/master/src/tools/compiletest/src/common.rs
+
### Compiler-specific test suites
| Test suite | Purpose |
@@ -71,6 +74,7 @@
| [`mir-opt`](#mir-opt-tests) | Check MIR generation and optimizations |
| [`coverage`](#coverage-tests) | Check coverage instrumentation |
| [`coverage-run-rustdoc`](#coverage-tests) | `coverage` tests that also run instrumented doctests |
+| [`crashes`](#crashes-tests) | Check that the compiler ICEs/panics/crashes on certain inputs to catch accidental fixes |
### General purpose test suite
@@ -78,19 +82,23 @@
### Rustdoc test suites
-See [Rustdoc tests](../rustdoc.md#tests) for more details.
+| Test suite | Purpose |
+|--------------------------------------|--------------------------------------------------------------------------|
+| [`rustdoc`][rustdoc-html-tests] | Check HTML output of `rustdoc` |
+| [`rustdoc-gui`][rustdoc-gui-tests] | Check `rustdoc`'s GUI using a web browser |
+| [`rustdoc-js`][rustdoc-js-tests] | Check `rustdoc`'s search engine and index |
+| [`rustdoc-js-std`][rustdoc-js-tests] | Check `rustdoc`'s search engine and index on the std library docs |
+| [`rustdoc-json`][rustdoc-json-tests] | Check JSON output of `rustdoc` |
+| `rustdoc-ui` | Check terminal output of `rustdoc` ([see also](ui.md)) |
-| Test suite | Purpose |
-|------------------|--------------------------------------------------------------------------|
-| `rustdoc` | Check `rustdoc` generated files contain the expected documentation |
-| `rustdoc-gui` | Check `rustdoc`'s GUI using a web browser |
-| `rustdoc-js` | Check `rustdoc` search is working as expected |
-| `rustdoc-js-std` | Check rustdoc search is working as expected specifically on the std docs |
-| `rustdoc-json` | Check JSON output of `rustdoc` |
-| `rustdoc-ui` | Check terminal output of `rustdoc` |
+Some rustdoc-specific tests can also be found in `ui/rustdoc/`.
+These check rustdoc-related or -specific lints that (also) run as part of `rustc`, not (only) `rustdoc`.
+Run-make tests pertaining to rustdoc are typically named `run-make/rustdoc-*/`.
-[`tests`]: https://github.com/rust-lang/rust/blob/master/tests
-[`src/tools/compiletest/src/common.rs`]: https://github.com/rust-lang/rust/tree/master/src/tools/compiletest/src/common.rs
+[rustdoc-html-tests]: ../rustdoc-internals/rustdoc-test-suite.md
+[rustdoc-gui-tests]: ../rustdoc-internals/rustdoc-gui-test-suite.md
+[rustdoc-js-tests]: ../rustdoc-internals/search.md#testing-the-search-engine
+[rustdoc-json-tests]: ../rustdoc-internals/rustdoc-json-test-suite.md
### Pretty-printer tests
diff --git a/src/doc/rustc-dev-guide/src/tests/directives.md b/src/doc/rustc-dev-guide/src/tests/directives.md
index 2dff21e..839076b 100644
--- a/src/doc/rustc-dev-guide/src/tests/directives.md
+++ b/src/doc/rustc-dev-guide/src/tests/directives.md
@@ -202,6 +202,7 @@
`//@ needs-crate-type: cdylib, proc-macro` will cause the test to be ignored
on `wasm32-unknown-unknown` target because the target does not support the
`proc-macro` crate type.
+- `needs-target-std` — ignores if target platform does not have std support.
The following directives will check LLVM support:
@@ -261,7 +262,7 @@
| Directive | Explanation | Supported test suites | Possible values |
|-------------|--------------------------------------------------------------|------------------------------------------|---------------------------|
-| `doc-flags` | Flags passed to `rustdoc` when building the test or aux file | `rustdoc`, `rustdoc-js`, `rustdoc-json` | Any valid `rustdoc` flags |
+| `doc-flags` | Flags passed to `rustdoc` when building the test or aux file | `rustdoc`, `rustdoc-js`, `rustdoc-json` | Any valid `rustdoc` flags |
<!--
**FIXME(rustdoc)**: what does `check-test-line-numbers-match` do?
@@ -269,6 +270,17 @@
<https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/What.20is.20the.20.60check-test-line-numbers-match.60.20directive.3F>.
-->
+#### Test-suite-specific directives
+
+The test suites [`rustdoc`][rustdoc-html-tests], [`rustdoc-js`/`rustdoc-js-std`][rustdoc-js-tests]
+and [`rustdoc-json`][rustdoc-json-tests] each feature an additional set of directives whose basic
+syntax resembles the one of compiletest directives but which are ultimately read and checked by
+separate tools. For more information, please read their respective chapters as linked above.
+
+[rustdoc-html-tests]: ../rustdoc-internals/rustdoc-test-suite.md
+[rustdoc-js-tests]: ../rustdoc-internals/search.html#testing-the-search-engine
+[rustdoc-json-tests]: ../rustdoc-internals/rustdoc-json-test-suite.md
+
### Pretty printing
See [Pretty-printer](compiletest.md#pretty-printer-tests).
diff --git a/src/doc/rustc-dev-guide/src/tests/ui.md b/src/doc/rustc-dev-guide/src/tests/ui.md
index 3402838..25d3efd 100644
--- a/src/doc/rustc-dev-guide/src/tests/ui.md
+++ b/src/doc/rustc-dev-guide/src/tests/ui.md
@@ -220,8 +220,12 @@
`//~ERROR` although the former is more common in the codebase).
`~? <diagnostic kind>` (example being `~? ERROR`)
-is used to match diagnostics without line information.
-These can be placed on any line in the test file, but are conventionally placed at the end.
+is used to match diagnostics _without_ line info at all,
+or where the line info is outside the main test file[^main test file].
+These annotations can be placed on any line in the test file.
+
+[^main test file]: This is a file that has the `~?` annotations,
+as distinct from aux files, or sources that we have no control over.
### Error annotation examples
diff --git a/src/doc/rustc-dev-guide/triagebot.toml b/src/doc/rustc-dev-guide/triagebot.toml
index 978802e..b3f4c2d 100644
--- a/src/doc/rustc-dev-guide/triagebot.toml
+++ b/src/doc/rustc-dev-guide/triagebot.toml
@@ -72,6 +72,23 @@
# Documentation at: https://forge.rust-lang.org/triagebot/pr-assignment.html
[assign]
+# NOTE: do not add `[assign.owners]` if we still wish to keep the opt-in
+# reviewer model, as `[assign.owners]` will cause triagebot auto-reviewer
+# assignment to kick in.
+
+# Custom PR welcome message for when no auto reviewer assignment is performed
+# and no explicit manual reviewer selection is made.
+# Documentation at: https://forge.rust-lang.org/triagebot/pr-assignment.html#custom-welcome-messages
+[assign.custom_welcome_messages]
+welcome-message = ""
+welcome-message-no-reviewer = """\
+Thanks for the PR. If you have write access, feel free to merge this PR if it \
+does not need reviews. You can request a review using `r? rustc-dev-guide` or \
+`r? <username>`.
+"""
+
+# Groups for `r? <group>`.
+# Documentation at: https://forge.rust-lang.org/triagebot/pr-assignment.html#usage
# Keep members alphanumerically sorted.
[assign.adhoc_groups]
rustc-dev-guide = [
diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md
index e7dfaaf..559e486 100644
--- a/src/doc/rustc/src/platform-support.md
+++ b/src/doc/rustc/src/platform-support.md
@@ -33,7 +33,7 @@
target | notes
-------|-------
[`aarch64-apple-darwin`](platform-support/apple-darwin.md) | ARM64 macOS (11.0+, Big Sur+)
-`aarch64-unknown-linux-gnu` | ARM64 Linux (kernel 4.1, glibc 2.17+)
+`aarch64-unknown-linux-gnu` | ARM64 Linux (kernel 4.1+, glibc 2.17+)
`i686-pc-windows-msvc` | 32-bit MSVC (Windows 10+, Windows Server 2016+, Pentium 4) [^x86_32-floats-return-ABI] [^win32-msvc-alignment]
`i686-unknown-linux-gnu` | 32-bit Linux (kernel 3.2+, glibc 2.17+, Pentium 4) [^x86_32-floats-return-ABI]
[`x86_64-apple-darwin`](platform-support/apple-darwin.md) | 64-bit macOS (10.12+, Sierra+)
@@ -91,20 +91,20 @@
`aarch64-pc-windows-msvc` | ARM64 Windows MSVC
`aarch64-unknown-linux-musl` | ARM64 Linux with musl 1.2.3
[`aarch64-unknown-linux-ohos`](platform-support/openharmony.md) | ARM64 OpenHarmony
-`arm-unknown-linux-gnueabi` | Armv6 Linux (kernel 3.2, glibc 2.17)
-`arm-unknown-linux-gnueabihf` | Armv6 Linux, hardfloat (kernel 3.2, glibc 2.17)
-`armv7-unknown-linux-gnueabihf` | Armv7-A Linux, hardfloat (kernel 3.2, glibc 2.17)
+`arm-unknown-linux-gnueabi` | Armv6 Linux (kernel 3.2+, glibc 2.17)
+`arm-unknown-linux-gnueabihf` | Armv6 Linux, hardfloat (kernel 3.2+, glibc 2.17)
+`armv7-unknown-linux-gnueabihf` | Armv7-A Linux, hardfloat (kernel 3.2+, glibc 2.17)
[`armv7-unknown-linux-ohos`](platform-support/openharmony.md) | Armv7-A OpenHarmony
-[`loongarch64-unknown-linux-gnu`](platform-support/loongarch-linux.md) | LoongArch64 Linux, LP64D ABI (kernel 5.19, glibc 2.36)
-[`loongarch64-unknown-linux-musl`](platform-support/loongarch-linux.md) | LoongArch64 Linux, LP64D ABI (kernel 5.19, musl 1.2.5)
+[`loongarch64-unknown-linux-gnu`](platform-support/loongarch-linux.md) | LoongArch64 Linux, LP64D ABI (kernel 5.19+, glibc 2.36)
+[`loongarch64-unknown-linux-musl`](platform-support/loongarch-linux.md) | LoongArch64 Linux, LP64D ABI (kernel 5.19+, musl 1.2.5)
[`i686-pc-windows-gnu`](platform-support/windows-gnu.md) | 32-bit MinGW (Windows 10+, Windows Server 2016+, Pentium 4) [^x86_32-floats-return-ABI] [^win32-msvc-alignment]
-`powerpc-unknown-linux-gnu` | PowerPC Linux (kernel 3.2, glibc 2.17)
-`powerpc64-unknown-linux-gnu` | PPC64 Linux (kernel 3.2, glibc 2.17)
-[`powerpc64le-unknown-linux-gnu`](platform-support/powerpc64le-unknown-linux-gnu.md) | PPC64LE Linux (kernel 3.10, glibc 2.17)
-[`powerpc64le-unknown-linux-musl`](platform-support/powerpc64le-unknown-linux-musl.md) | PPC64LE Linux (kernel 4.19, musl 1.2.3)
-[`riscv64gc-unknown-linux-gnu`](platform-support/riscv64gc-unknown-linux-gnu.md) | RISC-V Linux (kernel 4.20, glibc 2.29)
-[`riscv64gc-unknown-linux-musl`](platform-support/riscv64gc-unknown-linux-musl.md) | RISC-V Linux (kernel 4.20, musl 1.2.3)
-[`s390x-unknown-linux-gnu`](platform-support/s390x-unknown-linux-gnu.md) | S390x Linux (kernel 3.2, glibc 2.17)
+`powerpc-unknown-linux-gnu` | PowerPC Linux (kernel 3.2+, glibc 2.17)
+`powerpc64-unknown-linux-gnu` | PPC64 Linux (kernel 3.2+, glibc 2.17)
+[`powerpc64le-unknown-linux-gnu`](platform-support/powerpc64le-unknown-linux-gnu.md) | PPC64LE Linux (kernel 3.10+, glibc 2.17)
+[`powerpc64le-unknown-linux-musl`](platform-support/powerpc64le-unknown-linux-musl.md) | PPC64LE Linux (kernel 4.19+, musl 1.2.3)
+[`riscv64gc-unknown-linux-gnu`](platform-support/riscv64gc-unknown-linux-gnu.md) | RISC-V Linux (kernel 4.20+, glibc 2.29)
+[`riscv64gc-unknown-linux-musl`](platform-support/riscv64gc-unknown-linux-musl.md) | RISC-V Linux (kernel 4.20+, musl 1.2.3)
+[`s390x-unknown-linux-gnu`](platform-support/s390x-unknown-linux-gnu.md) | S390x Linux (kernel 3.2+, glibc 2.17)
[`x86_64-unknown-freebsd`](platform-support/freebsd.md) | 64-bit x86 FreeBSD
[`x86_64-unknown-illumos`](platform-support/illumos.md) | illumos
`x86_64-unknown-linux-musl` | 64-bit Linux with musl 1.2.3
@@ -158,16 +158,16 @@
[`arm64ec-pc-windows-msvc`](platform-support/arm64ec-pc-windows-msvc.md) | ✓ | Arm64EC Windows MSVC
[`armebv7r-none-eabi`](platform-support/armv7r-none-eabi.md) | * | Bare Armv7-R, Big Endian
[`armebv7r-none-eabihf`](platform-support/armv7r-none-eabi.md) | * | Bare Armv7-R, Big Endian, hardfloat
-[`armv5te-unknown-linux-gnueabi`](platform-support/armv5te-unknown-linux-gnueabi.md) | ✓ | Armv5TE Linux (kernel 4.4, glibc 2.23)
+[`armv5te-unknown-linux-gnueabi`](platform-support/armv5te-unknown-linux-gnueabi.md) | ✓ | Armv5TE Linux (kernel 4.4+, glibc 2.23)
`armv5te-unknown-linux-musleabi` | ✓ | Armv5TE Linux with musl 1.2.3
[`armv7-linux-androideabi`](platform-support/android.md) | ✓ | Armv7-A Android
-`armv7-unknown-linux-gnueabi` | ✓ | Armv7-A Linux (kernel 4.15, glibc 2.27)
+`armv7-unknown-linux-gnueabi` | ✓ | Armv7-A Linux (kernel 4.15+, glibc 2.27)
`armv7-unknown-linux-musleabi` | ✓ | Armv7-A Linux with musl 1.2.3
`armv7-unknown-linux-musleabihf` | ✓ | Armv7-A Linux with musl 1.2.3, hardfloat
[`armv7a-none-eabi`](platform-support/arm-none-eabi.md) | * | Bare Armv7-A
[`armv7r-none-eabi`](platform-support/armv7r-none-eabi.md) | * | Bare Armv7-R
[`armv7r-none-eabihf`](platform-support/armv7r-none-eabi.md) | * | Bare Armv7-R, hardfloat
-`i586-unknown-linux-gnu` | ✓ | 32-bit Linux (kernel 3.2, glibc 2.17, original Pentium) [^x86_32-floats-x87]
+`i586-unknown-linux-gnu` | ✓ | 32-bit Linux (kernel 3.2+, glibc 2.17, original Pentium) [^x86_32-floats-x87]
`i586-unknown-linux-musl` | ✓ | 32-bit Linux (musl 1.2.3, original Pentium) [^x86_32-floats-x87]
[`i686-linux-android`](platform-support/android.md) | ✓ | 32-bit x86 Android ([Pentium 4 plus various extensions](https://developer.android.com/ndk/guides/abis.html#x86)) [^x86_32-floats-return-ABI]
[`i686-pc-windows-gnullvm`](platform-support/windows-gnullvm.md) | ✓ | 32-bit x86 MinGW (Windows 10+, Pentium 4), LLVM ABI [^x86_32-floats-return-ABI]
@@ -184,13 +184,13 @@
[`riscv32imc-unknown-none-elf`](platform-support/riscv32-unknown-none-elf.md) | * | Bare RISC-V (RV32IMC ISA)
`riscv64gc-unknown-none-elf` | * | Bare RISC-V (RV64IMAFDC ISA)
`riscv64imac-unknown-none-elf` | * | Bare RISC-V (RV64IMAC ISA)
-`sparc64-unknown-linux-gnu` | ✓ | SPARC Linux (kernel 4.4, glibc 2.23)
+`sparc64-unknown-linux-gnu` | ✓ | SPARC Linux (kernel 4.4+, glibc 2.23)
[`thumbv6m-none-eabi`](platform-support/thumbv6m-none-eabi.md) | * | Bare Armv6-M
[`thumbv7em-none-eabi`](platform-support/thumbv7em-none-eabi.md) | * | Bare Armv7E-M
[`thumbv7em-none-eabihf`](platform-support/thumbv7em-none-eabi.md) | * | Bare Armv7E-M, hardfloat
[`thumbv7m-none-eabi`](platform-support/thumbv7m-none-eabi.md) | * | Bare Armv7-M
[`thumbv7neon-linux-androideabi`](platform-support/android.md) | ✓ | Thumb2-mode Armv7-A Android with NEON
-`thumbv7neon-unknown-linux-gnueabihf` | ✓ | Thumb2-mode Armv7-A Linux with NEON (kernel 4.4, glibc 2.23)
+`thumbv7neon-unknown-linux-gnueabihf` | ✓ | Thumb2-mode Armv7-A Linux with NEON (kernel 4.4+, glibc 2.23)
[`thumbv8m.base-none-eabi`](platform-support/thumbv8m.base-none-eabi.md) | * | Bare Armv8-M Baseline
[`thumbv8m.main-none-eabi`](platform-support/thumbv8m.main-none-eabi.md) | * | Bare Armv8-M Mainline
[`thumbv8m.main-none-eabihf`](platform-support/thumbv8m.main-none-eabi.md) | * | Bare Armv8-M Mainline, hardfloat
@@ -206,7 +206,7 @@
[`x86_64-linux-android`](platform-support/android.md) | ✓ | 64-bit x86 Android
[`x86_64-pc-windows-gnullvm`](platform-support/windows-gnullvm.md) | ✓ | 64-bit x86 MinGW (Windows 10+), LLVM ABI
[`x86_64-unknown-fuchsia`](platform-support/fuchsia.md) | ✓ | 64-bit x86 Fuchsia
-`x86_64-unknown-linux-gnux32` | ✓ | 64-bit Linux (x32 ABI) (kernel 4.15, glibc 2.27)
+`x86_64-unknown-linux-gnux32` | ✓ | 64-bit Linux (x32 ABI) (kernel 4.15+, glibc 2.27)
[`x86_64-unknown-none`](platform-support/x86_64-unknown-none.md) | * | Freestanding/bare-metal x86_64, softfloat
[`x86_64-unknown-redox`](platform-support/redox.md) | ✓ | Redox OS
[`x86_64-unknown-uefi`](platform-support/unknown-uefi.md) | ? | 64-bit UEFI
@@ -324,6 +324,8 @@
[`i686-win7-windows-msvc`](platform-support/win7-windows-msvc.md) | ✓ | | 32-bit Windows 7 support [^x86_32-floats-return-ABI] [^win32-msvc-alignment]
[`i686-wrs-vxworks`](platform-support/vxworks.md) | ✓ | | [^x86_32-floats-return-ABI]
[`loongarch64-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | | LoongArch64 OpenHarmony
+[`loongarch32-unknown-none`](platform-support/loongarch-none.md) | * | LoongArch32 Bare-metal (ILP32D ABI)
+[`loongarch32-unknown-none-softfloat`](platform-support/loongarch-none.md) | * | LoongArch32 Bare-metal (ILP32S ABI)
[`m68k-unknown-linux-gnu`](platform-support/m68k-unknown-linux-gnu.md) | ? | | Motorola 680x0 Linux
[`m68k-unknown-none-elf`](platform-support/m68k-unknown-none-elf.md) | | | Motorola 680x0
`mips-unknown-linux-gnu` | ✓ | ✓ | MIPS Linux (kernel 4.4, glibc 2.23)
diff --git a/src/doc/rustc/src/platform-support/loongarch-none.md b/src/doc/rustc/src/platform-support/loongarch-none.md
index a2bd6e5..7c3a7e6 100644
--- a/src/doc/rustc/src/platform-support/loongarch-none.md
+++ b/src/doc/rustc/src/platform-support/loongarch-none.md
@@ -1,13 +1,13 @@
# `loongarch*-unknown-none*`
-**Tier: 2**
+Freestanding/bare-metal LoongArch binaries in ELF format: firmware, kernels, etc.
-Freestanding/bare-metal LoongArch64 binaries in ELF format: firmware, kernels, etc.
-
-| Target | Description |
-|--------|-------------|
-| `loongarch64-unknown-none` | LoongArch 64-bit, LP64D ABI (freestanding, hard-float) |
-| `loongarch64-unknown-none-softfloat` | LoongArch 64-bit, LP64S ABI (freestanding, soft-float) |
+| Target | Description | Tier |
+|--------|-------------|------|
+| `loongarch32-unknown-none` | LoongArch 32-bit, ILP32D ABI (freestanding, hard-float) | Tier 3 |
+| `loongarch32-unknown-none-softfloat` | LoongArch 32-bit, ILP32S ABI (freestanding, soft-float) | Tier 3 |
+| `loongarch64-unknown-none` | LoongArch 64-bit, LP64D ABI (freestanding, hard-float) | Tier 2 |
+| `loongarch64-unknown-none-softfloat` | LoongArch 64-bit, LP64S ABI (freestanding, soft-float) | Tier 2 |
## Target maintainers
@@ -29,13 +29,13 @@
via the `#[target_feature]` mechanism within Rust code.
By default, code generated with the soft-float target should run on any
-LoongArch64 hardware, with the hard-float target additionally requiring an FPU;
+LoongArch hardware, with the hard-float target additionally requiring an FPU;
enabling additional target features may raise this baseline.
Code generated with the targets will use the `medium` code model by default.
You can change this using the `-C code-model=` option to rustc.
-On `loongarch64-unknown-none*`, `extern "C"` uses the [architecture's standard calling convention][lapcs].
+On `loongarch*-unknown-none*`, `extern "C"` uses the [architecture's standard calling convention][lapcs].
[lapcs]: https://github.com/loongson/la-abi-specs/blob/release/lapcs.adoc
@@ -52,6 +52,8 @@
[build]
build-stage = 1
target = [
+ "loongarch32-unknown-none",
+ "loongarch32-unknown-none-softfloat",
"loongarch64-unknown-none",
"loongarch64-unknown-none-softfloat",
]
@@ -64,13 +66,28 @@
## Building Rust programs
+### loongarch32-unknown-none*
+
+The `loongarch32-unknown-none*` targets are Tier 3, so you must build the Rust
+compiler from source to use them.
+
+```sh
+# target flag may be used with any cargo or rustc command
+cargo build --target loongarch32-unknown-none
+cargo build --target loongarch32-unknown-none-softfloat
+```
+
+### loongarch64-unknown-none*
+
Starting with Rust 1.74, precompiled artifacts are provided via `rustup`:
```sh
# install cross-compile toolchain
rustup target add loongarch64-unknown-none
+rustup target add loongarch64-unknown-none-softfloat
# target flag may be used with any cargo or rustc command
cargo build --target loongarch64-unknown-none
+cargo build --target loongarch64-unknown-none-softfloat
```
## Cross-compilation toolchains and C code
@@ -79,10 +96,10 @@
linking, or if you want to compile C code along with Rust (such as for Rust
crates with C dependencies).
-Rust *may* be able to use an `loongarch64-unknown-linux-gnu-` toolchain with
+Rust *may* be able to use an `loongarch{32,64}-unknown-linux-{gnu,musl}-` toolchain with
appropriate standalone flags to build for this toolchain (depending on the assumptions
of that toolchain, see below), or you may wish to use a separate
-`loongarch64-unknown-none` toolchain.
+`loongarch{32,64}-unknown-none` toolchain.
On some LoongArch hosts that use ELF binaries, you *may* be able to use the host
C toolchain, if it does not introduce assumptions about the host environment
diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs
index 138ac3c..a91ea55 100644
--- a/src/librustdoc/clean/auto_trait.rs
+++ b/src/librustdoc/clean/auto_trait.rs
@@ -11,7 +11,7 @@
use crate::clean::{
self, Lifetime, clean_generic_param_def, clean_middle_ty, clean_predicate,
- clean_trait_ref_with_constraints, clean_ty_generics, simplify,
+ clean_trait_ref_with_constraints, clean_ty_generics_inner, simplify,
};
use crate::core::DocContext;
@@ -101,7 +101,7 @@ fn synthesize_auto_trait_impl<'tcx>(
// Instead, we generate `impl !Send for Foo<T>`, which better
// expresses the fact that `Foo<T>` never implements `Send`,
// regardless of the choice of `T`.
- let mut generics = clean_ty_generics(
+ let mut generics = clean_ty_generics_inner(
cx,
tcx.generics_of(item_def_id),
ty::GenericPredicates::default(),
diff --git a/src/librustdoc/clean/blanket_impl.rs b/src/librustdoc/clean/blanket_impl.rs
index 89245fe..c889f52 100644
--- a/src/librustdoc/clean/blanket_impl.rs
+++ b/src/librustdoc/clean/blanket_impl.rs
@@ -90,11 +90,7 @@ pub(crate) fn synthesize_blanket_impls(
stability: None,
kind: clean::ImplItem(Box::new(clean::Impl {
safety: hir::Safety::Safe,
- generics: clean_ty_generics(
- cx,
- tcx.generics_of(impl_def_id),
- tcx.explicit_predicates_of(impl_def_id),
- ),
+ generics: clean_ty_generics(cx, impl_def_id),
// FIXME(eddyb) compute both `trait_` and `for_` from
// the post-inference `trait_ref`, as it's more accurate.
trait_: Some(clean_trait_ref_with_constraints(
diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs
index ebc276b..a3762e4 100644
--- a/src/librustdoc/clean/cfg.rs
+++ b/src/librustdoc/clean/cfg.rs
@@ -508,6 +508,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
(sym::target_arch, Some(arch)) => match arch.as_str() {
"aarch64" => "AArch64",
"arm" => "ARM",
+ "loongarch32" => "LoongArch LA32",
"loongarch64" => "LoongArch LA64",
"m68k" => "M68k",
"csky" => "CSKY",
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs
index 55a116a..9b54913 100644
--- a/src/librustdoc/clean/inline.rs
+++ b/src/librustdoc/clean/inline.rs
@@ -264,16 +264,13 @@ pub(crate) fn build_trait(cx: &mut DocContext<'_>, did: DefId) -> clean::Trait {
.map(|item| clean_middle_assoc_item(item, cx))
.collect();
- let predicates = cx.tcx.predicates_of(did);
- let generics = clean_ty_generics(cx, cx.tcx.generics_of(did), predicates);
- let generics = filter_non_trait_generics(did, generics);
+ let generics = clean_ty_generics(cx, did);
let (generics, supertrait_bounds) = separate_self_bounds(generics);
clean::Trait { def_id: did, generics, items: trait_items, bounds: supertrait_bounds }
}
fn build_trait_alias(cx: &mut DocContext<'_>, did: DefId) -> clean::TraitAlias {
- let predicates = cx.tcx.predicates_of(did);
- let generics = clean_ty_generics(cx, cx.tcx.generics_of(did), predicates);
+ let generics = clean_ty_generics(cx, did);
let (generics, bounds) = separate_self_bounds(generics);
clean::TraitAlias { generics, bounds }
}
@@ -281,8 +278,7 @@ fn build_trait_alias(cx: &mut DocContext<'_>, did: DefId) -> clean::TraitAlias {
pub(super) fn build_function(cx: &mut DocContext<'_>, def_id: DefId) -> Box<clean::Function> {
let sig = cx.tcx.fn_sig(def_id).instantiate_identity();
// The generics need to be cleaned before the signature.
- let mut generics =
- clean_ty_generics(cx, cx.tcx.generics_of(def_id), cx.tcx.explicit_predicates_of(def_id));
+ let mut generics = clean_ty_generics(cx, def_id);
let bound_vars = clean_bound_vars(sig.bound_vars());
// At the time of writing early & late-bound params are stored separately in rustc,
@@ -311,30 +307,26 @@ pub(super) fn build_function(cx: &mut DocContext<'_>, def_id: DefId) -> Box<clea
}
fn build_enum(cx: &mut DocContext<'_>, did: DefId) -> clean::Enum {
- let predicates = cx.tcx.explicit_predicates_of(did);
-
clean::Enum {
- generics: clean_ty_generics(cx, cx.tcx.generics_of(did), predicates),
+ generics: clean_ty_generics(cx, did),
variants: cx.tcx.adt_def(did).variants().iter().map(|v| clean_variant_def(v, cx)).collect(),
}
}
fn build_struct(cx: &mut DocContext<'_>, did: DefId) -> clean::Struct {
- let predicates = cx.tcx.explicit_predicates_of(did);
let variant = cx.tcx.adt_def(did).non_enum_variant();
clean::Struct {
ctor_kind: variant.ctor_kind(),
- generics: clean_ty_generics(cx, cx.tcx.generics_of(did), predicates),
+ generics: clean_ty_generics(cx, did),
fields: variant.fields.iter().map(|x| clean_middle_field(x, cx)).collect(),
}
}
fn build_union(cx: &mut DocContext<'_>, did: DefId) -> clean::Union {
- let predicates = cx.tcx.explicit_predicates_of(did);
let variant = cx.tcx.adt_def(did).non_enum_variant();
- let generics = clean_ty_generics(cx, cx.tcx.generics_of(did), predicates);
+ let generics = clean_ty_generics(cx, did);
let fields = variant.fields.iter().map(|x| clean_middle_field(x, cx)).collect();
clean::Union { generics, fields }
}
@@ -344,14 +336,13 @@ fn build_type_alias(
did: DefId,
ret: &mut Vec<Item>,
) -> Box<clean::TypeAlias> {
- let predicates = cx.tcx.explicit_predicates_of(did);
let ty = cx.tcx.type_of(did).instantiate_identity();
let type_ = clean_middle_ty(ty::Binder::dummy(ty), cx, Some(did), None);
let inner_type = clean_ty_alias_inner_type(ty, cx, ret);
Box::new(clean::TypeAlias {
type_,
- generics: clean_ty_generics(cx, cx.tcx.generics_of(did), predicates),
+ generics: clean_ty_generics(cx, did),
inner_type,
item_type: None,
})
@@ -483,7 +474,6 @@ pub(crate) fn build_impl(
}
let document_hidden = cx.render_options.document_hidden;
- let predicates = tcx.explicit_predicates_of(did);
let (trait_items, generics) = match impl_item {
Some(impl_) => (
impl_
@@ -549,9 +539,7 @@ pub(crate) fn build_impl(
})
.map(|item| clean_middle_assoc_item(item, cx))
.collect::<Vec<_>>(),
- clean::enter_impl_trait(cx, |cx| {
- clean_ty_generics(cx, tcx.generics_of(did), predicates)
- }),
+ clean::enter_impl_trait(cx, |cx| clean_ty_generics(cx, did)),
),
};
let polarity = tcx.impl_polarity(did);
@@ -713,8 +701,7 @@ pub(crate) fn print_inlined_const(tcx: TyCtxt<'_>, did: DefId) -> String {
}
fn build_const_item(cx: &mut DocContext<'_>, def_id: DefId) -> clean::Constant {
- let mut generics =
- clean_ty_generics(cx, cx.tcx.generics_of(def_id), cx.tcx.explicit_predicates_of(def_id));
+ let mut generics = clean_ty_generics(cx, def_id);
clean::simplify::move_bounds_to_generic_parameters(&mut generics);
let ty = clean_middle_ty(
ty::Binder::dummy(cx.tcx.type_of(def_id).instantiate_identity()),
@@ -761,44 +748,6 @@ fn build_macro(
}
}
-/// A trait's generics clause actually contains all of the predicates for all of
-/// its associated types as well. We specifically move these clauses to the
-/// associated types instead when displaying, so when we're generating the
-/// generics for the trait itself we need to be sure to remove them.
-/// We also need to remove the implied "recursive" Self: Trait bound.
-///
-/// The inverse of this filtering logic can be found in the `Clean`
-/// implementation for `AssociatedType`
-fn filter_non_trait_generics(trait_did: DefId, mut g: clean::Generics) -> clean::Generics {
- for pred in &mut g.where_predicates {
- if let clean::WherePredicate::BoundPredicate { ty: clean::SelfTy, ref mut bounds, .. } =
- *pred
- {
- bounds.retain(|bound| match bound {
- clean::GenericBound::TraitBound(clean::PolyTrait { trait_, .. }, _) => {
- trait_.def_id() != trait_did
- }
- _ => true,
- });
- }
- }
-
- g.where_predicates.retain(|pred| match pred {
- clean::WherePredicate::BoundPredicate {
- ty:
- clean::QPath(box clean::QPathData {
- self_type: clean::Generic(_),
- trait_: Some(trait_),
- ..
- }),
- bounds,
- ..
- } => !bounds.is_empty() && trait_.def_id() != trait_did,
- _ => true,
- });
- g
-}
-
fn separate_self_bounds(mut g: clean::Generics) -> (clean::Generics, Vec<clean::GenericBound>) {
let mut ty_bounds = Vec::new();
g.where_predicates.retain(|pred| match *pred {
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index 7658e7a..db4bcda 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -793,7 +793,11 @@ pub(crate) fn clean_generics<'tcx>(
}
}
-fn clean_ty_generics<'tcx>(
+fn clean_ty_generics<'tcx>(cx: &mut DocContext<'tcx>, def_id: DefId) -> Generics {
+ clean_ty_generics_inner(cx, cx.tcx.generics_of(def_id), cx.tcx.explicit_predicates_of(def_id))
+}
+
+fn clean_ty_generics_inner<'tcx>(
cx: &mut DocContext<'tcx>,
gens: &ty::Generics,
preds: ty::GenericPredicates<'tcx>,
@@ -1297,11 +1301,7 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo
None,
);
- let mut generics = clean_ty_generics(
- cx,
- tcx.generics_of(assoc_item.def_id),
- tcx.explicit_predicates_of(assoc_item.def_id),
- );
+ let mut generics = clean_ty_generics(cx, assoc_item.def_id);
simplify::move_bounds_to_generic_parameters(&mut generics);
match assoc_item.container {
@@ -1389,7 +1389,7 @@ fn param_eq_arg(param: &GenericParamDef, arg: &GenericArg) -> bool {
let bounds = tcx.explicit_item_bounds(assoc_item.def_id).iter_identity_copied();
predicates = tcx.arena.alloc_from_iter(bounds.chain(predicates.iter().copied()));
}
- let mut generics = clean_ty_generics(
+ let mut generics = clean_ty_generics_inner(
cx,
tcx.generics_of(assoc_item.def_id),
ty::GenericPredicates { parent: None, predicates },
diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs
index f8209f2..4c53ea42 100644
--- a/src/tools/build-manifest/src/main.rs
+++ b/src/tools/build-manifest/src/main.rs
@@ -113,6 +113,8 @@
"i686-unknown-uefi",
"loongarch64-unknown-linux-gnu",
"loongarch64-unknown-linux-musl",
+ "loongarch32-unknown-none",
+ "loongarch32-unknown-none-softfloat",
"loongarch64-unknown-none",
"loongarch64-unknown-none-softfloat",
"m68k-unknown-linux-gnu",
diff --git a/src/tools/cargo b/src/tools/cargo
index 64a1246..fc1518e 160000
--- a/src/tools/cargo
+++ b/src/tools/cargo
@@ -1 +1 @@
-Subproject commit 64a12460708cf146e16cc61f28aba5dc2463bbb4
+Subproject commit fc1518ef02b77327d70d4026b95ea719dd9b8c51
diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs
index 4f93b49..9b9d94b 100644
--- a/src/tools/compiletest/src/common.rs
+++ b/src/tools/compiletest/src/common.rs
@@ -495,6 +495,7 @@ pub fn has_asm_support(&self) -> bool {
"arm64ec",
"riscv32",
"riscv64",
+ "loongarch32",
"loongarch64",
"s390x",
// These targets require an additional asm_experimental_arch feature.
diff --git a/src/tools/compiletest/src/directive-list.rs b/src/tools/compiletest/src/directive-list.rs
index 5757e42..2ecb4fc 100644
--- a/src/tools/compiletest/src/directive-list.rs
+++ b/src/tools/compiletest/src/directive-list.rs
@@ -73,6 +73,7 @@
"ignore-linux",
"ignore-lldb",
"ignore-llvm-version",
+ "ignore-loongarch32",
"ignore-loongarch64",
"ignore-macabi",
"ignore-macos",
@@ -165,6 +166,7 @@
"needs-subprocess",
"needs-symlink",
"needs-target-has-atomic",
+ "needs-target-std",
"needs-threads",
"needs-unwind",
"needs-wasmtime",
@@ -196,6 +198,7 @@
"only-i686-unknown-linux-gnu",
"only-ios",
"only-linux",
+ "only-loongarch32",
"only-loongarch64",
"only-loongarch64-unknown-linux-gnu",
"only-macos",
diff --git a/src/tools/compiletest/src/header/needs.rs b/src/tools/compiletest/src/header/needs.rs
index 2ace40c..b1165f4 100644
--- a/src/tools/compiletest/src/header/needs.rs
+++ b/src/tools/compiletest/src/header/needs.rs
@@ -174,6 +174,11 @@ pub(super) fn handle_needs(
condition: config.with_std_debug_assertions,
ignore_reason: "ignored if std wasn't built with debug assertions",
},
+ Need {
+ name: "needs-target-std",
+ condition: build_helper::targets::target_supports_std(&config.target),
+ ignore_reason: "ignored if target does not support std",
+ },
];
let (name, rest) = match ln.split_once([':', ' ']) {
diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs
index e7e5ff0..31b49b09 100644
--- a/src/tools/compiletest/src/header/tests.rs
+++ b/src/tools/compiletest/src/header/tests.rs
@@ -945,3 +945,14 @@ fn test_ignore_auxiliary() {
let config = cfg().build();
assert!(check_ignore(&config, "//@ ignore-auxiliary"));
}
+
+#[test]
+fn test_needs_target_std() {
+ // Cherry-picks two targets:
+ // 1. `x86_64-unknown-none`: Tier 2, intentionally never supports std.
+ // 2. `x86_64-unknown-linux-gnu`: Tier 1, always supports std.
+ let config = cfg().target("x86_64-unknown-none").build();
+ assert!(check_ignore(&config, "//@ needs-target-std"));
+ let config = cfg().target("x86_64-unknown-linux-gnu").build();
+ assert!(!check_ignore(&config, "//@ needs-target-std"));
+}
diff --git a/src/tools/miri/Cargo.lock b/src/tools/miri/Cargo.lock
index 6f4bd3e..192d4f4 100644
--- a/src/tools/miri/Cargo.lock
+++ b/src/tools/miri/Cargo.lock
@@ -555,7 +555,6 @@
"tempfile",
"tikv-jemalloc-sys",
"ui_test",
- "windows-sys",
]
[[package]]
diff --git a/src/tools/miri/Cargo.toml b/src/tools/miri/Cargo.toml
index e4d7abd..a314488 100644
--- a/src/tools/miri/Cargo.toml
+++ b/src/tools/miri/Cargo.toml
@@ -40,13 +40,6 @@
libffi = "4.0.0"
libloading = "0.8"
-[target.'cfg(target_family = "windows")'.dependencies]
-windows-sys = { version = "0.59", features = [
- "Win32_Foundation",
- "Win32_System_IO",
- "Win32_Storage_FileSystem",
-] }
-
[dev-dependencies]
ui_test = "0.29.1"
colored = "2"
diff --git a/src/tools/miri/README.md b/src/tools/miri/README.md
index de52139..fc7942a 100644
--- a/src/tools/miri/README.md
+++ b/src/tools/miri/README.md
@@ -396,18 +396,22 @@
* `-Zmiri-force-intrinsic-fallback` forces the use of the "fallback" body for all intrinsics that
have one. This is useful to test the fallback bodies, but should not be used otherwise. It is
**unsound** since the fallback body might not be checking for all UB.
-* `-Zmiri-native-lib=<path to a shared object file>` is an experimental flag for providing support
- for calling native functions from inside the interpreter via FFI. The flag is supported only on
- Unix systems. Functions not provided by that file are still executed via the usual Miri shims.
+* `-Zmiri-native-lib=<path to a shared object file or folder>` is an experimental flag for providing
+ support for calling native functions from inside the interpreter via FFI. The flag is supported
+ only on Unix systems. Functions not provided by that file are still executed via the usual Miri
+ shims. If a path to a directory is specified, all files in that directory are included
+ non-recursively. This flag can be passed multiple times to specify multiple files and/or
+ directories.
**WARNING**: If an invalid/incorrect `.so` file is specified, this can cause Undefined Behavior in
- Miri itself! And of course, Miri cannot do any checks on the actions taken by the native code.
+ Miri itself! And of course, Miri often cannot do any checks on the actions taken by the native code.
Note that Miri has its own handling of file descriptors, so if you want to replace *some*
functions working on file descriptors, you will have to replace *all* of them, or the two kinds of
- file descriptors will be mixed up. This is **work in progress**; currently, only integer and
- pointers arguments and return values are supported and memory allocated by the native code cannot
- be accessed from Rust (only the other way around). Native code must not spawn threads that keep
- running in the background after the call has returned to Rust and that access Rust-allocated
- memory. Finally, the flag is **unsound** in the sense that Miri stops tracking details such as
+ file descriptors will be mixed up.
+ This is **work in progress**; currently, only integer and pointers arguments and return values are
+ supported and memory allocated by the native code cannot be accessed from Rust (only the other way
+ around). Native code must not spawn threads that keep running in the background after the call has
+ returned to Rust and that access Rust-allocated memory.
+ Finally, the flag is **unsound** in the sense that Miri stops tracking details such as
initialization and provenance on memory shared with native code, so it is easily possible to write
code that has UB which is missed by Miri.
* `-Zmiri-measureme=<name>` enables `measureme` profiling for the interpreted program.
@@ -458,6 +462,10 @@
This is much less likely with Stacked Borrows.
Using Tree Borrows currently implies `-Zmiri-strict-provenance` because integer-to-pointer
casts are not supported in this mode, but that may change in the future.
+* `-Zmiri-tree-borrows-no-precise-interior-mut` makes Tree Borrows
+ track interior mutable data on the level of references instead of on the
+ byte-level as is done by default. Therefore, with this flag, Tree
+ Borrows will be more permissive.
* `-Zmiri-force-page-size=<num>` overrides the default page size for an architecture, in multiples of 1k.
`4` is default for most targets. This value should always be a power of 2 and nonzero.
diff --git a/src/tools/miri/cargo-miri/Cargo.lock b/src/tools/miri/cargo-miri/Cargo.lock
index c1915ae..d37f875 100644
--- a/src/tools/miri/cargo-miri/Cargo.lock
+++ b/src/tools/miri/cargo-miri/Cargo.lock
@@ -3,6 +3,15 @@
version = 4
[[package]]
+name = "aho-corasick"
+version = "1.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
name = "anyhow"
version = "1.0.97"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -207,12 +216,42 @@
]
[[package]]
-name = "rustc-build-sysroot"
-version = "0.5.7"
+name = "regex"
+version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "10edc2e4393515193bd766e2f6c050b0536a68e56f2b6d56c07ababfdc114ff0"
+checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-automata",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-automata"
+version = "0.4.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-syntax"
+version = "0.8.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
+
+[[package]]
+name = "rustc-build-sysroot"
+version = "0.5.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "16d115ad7e26e0d1337f64ae6598f758194696afc2e9f34c8a6f24582529c3dc"
dependencies = [
"anyhow",
+ "regex",
"rustc_version",
"tempfile",
"walkdir",
diff --git a/src/tools/miri/cargo-miri/Cargo.toml b/src/tools/miri/cargo-miri/Cargo.toml
index 5c579b2..e087339 100644
--- a/src/tools/miri/cargo-miri/Cargo.toml
+++ b/src/tools/miri/cargo-miri/Cargo.toml
@@ -18,7 +18,7 @@
rustc_version = "0.4"
serde_json = "1.0.40"
cargo_metadata = "0.19"
-rustc-build-sysroot = "0.5.7"
+rustc-build-sysroot = "0.5.8"
# Enable some feature flags that dev-dependencies need but dependencies
# do not. This makes `./miri install` after `./miri build` faster.
diff --git a/src/tools/miri/rust-version b/src/tools/miri/rust-version
index 553d410..43632bf 100644
--- a/src/tools/miri/rust-version
+++ b/src/tools/miri/rust-version
@@ -1 +1 @@
-337c11e5932275e7d450c1f2e26f289f0ddfa717
+c6768de2d63de7a41124a0fb8fc78f9e26111c01
diff --git a/src/tools/miri/src/alloc_addresses/mod.rs b/src/tools/miri/src/alloc_addresses/mod.rs
index 12a320b9..4a038fe 100644
--- a/src/tools/miri/src/alloc_addresses/mod.rs
+++ b/src/tools/miri/src/alloc_addresses/mod.rs
@@ -132,7 +132,7 @@ fn addr_from_alloc_id_uncached(
assert!(!matches!(info.kind, AllocKind::Dead));
// This allocation does not have a base address yet, pick or reuse one.
- if this.machine.native_lib.is_some() {
+ if !this.machine.native_lib.is_empty() {
// In native lib mode, we use the "real" address of the bytes for this allocation.
// This ensures the interpreted program and native code have the same view of memory.
let params = this.machine.get_default_alloc_params();
@@ -413,7 +413,7 @@ fn get_global_alloc_bytes(
) -> InterpResult<'tcx, MiriAllocBytes> {
let this = self.eval_context_ref();
assert!(this.tcx.try_get_global_alloc(id).is_some());
- if this.machine.native_lib.is_some() {
+ if !this.machine.native_lib.is_empty() {
// In native lib mode, MiriAllocBytes for global allocations are handled via `prepared_alloc_bytes`.
// This additional call ensures that some `MiriAllocBytes` are always prepared, just in case
// this function gets called before the first time `addr_from_alloc_id` gets called.
diff --git a/src/tools/miri/src/bin/miri.rs b/src/tools/miri/src/bin/miri.rs
index 0121472..2faaec5 100644
--- a/src/tools/miri/src/bin/miri.rs
+++ b/src/tools/miri/src/bin/miri.rs
@@ -35,7 +35,7 @@
use miri::{
BacktraceStyle, BorrowTrackerMethod, GenmcConfig, GenmcCtx, MiriConfig, MiriEntryFnType,
- ProvenanceMode, RetagFields, ValidationMode,
+ ProvenanceMode, RetagFields, TreeBorrowsParams, ValidationMode,
};
use rustc_abi::ExternAbi;
use rustc_data_structures::sync;
@@ -554,8 +554,21 @@ fn main() {
} else if arg == "-Zmiri-disable-stacked-borrows" {
miri_config.borrow_tracker = None;
} else if arg == "-Zmiri-tree-borrows" {
- miri_config.borrow_tracker = Some(BorrowTrackerMethod::TreeBorrows);
+ miri_config.borrow_tracker =
+ Some(BorrowTrackerMethod::TreeBorrows(TreeBorrowsParams {
+ precise_interior_mut: true,
+ }));
miri_config.provenance_mode = ProvenanceMode::Strict;
+ } else if arg == "-Zmiri-tree-borrows-no-precise-interior-mut" {
+ match &mut miri_config.borrow_tracker {
+ Some(BorrowTrackerMethod::TreeBorrows(params)) => {
+ params.precise_interior_mut = false;
+ }
+ _ =>
+ show_error!(
+ "`-Zmiri-tree-borrows` is required before `-Zmiri-tree-borrows-no-precise-interior-mut`"
+ ),
+ };
} else if arg == "-Zmiri-disable-data-race-detector" {
miri_config.data_race_detector = false;
miri_config.weak_memory_emulation = false;
@@ -692,11 +705,18 @@ fn main() {
};
} else if let Some(param) = arg.strip_prefix("-Zmiri-native-lib=") {
let filename = param.to_string();
- if std::path::Path::new(&filename).exists() {
- if let Some(other_filename) = miri_config.native_lib {
- show_error!("-Zmiri-native-lib is already set to {}", other_filename.display());
+ let file_path = std::path::Path::new(&filename);
+ if file_path.exists() {
+ // For directories, nonrecursively add all normal files inside
+ if let Ok(dir) = file_path.read_dir() {
+ for lib in dir.filter_map(|res| res.ok()) {
+ if lib.file_type().unwrap().is_file() {
+ miri_config.native_lib.push(lib.path().to_owned());
+ }
+ }
+ } else {
+ miri_config.native_lib.push(filename.into());
}
- miri_config.native_lib = Some(filename.into());
} else {
show_error!("-Zmiri-native-lib `{}` does not exist", filename);
}
@@ -725,18 +745,19 @@ fn main() {
}
}
// Tree Borrows implies strict provenance, and is not compatible with native calls.
- if matches!(miri_config.borrow_tracker, Some(BorrowTrackerMethod::TreeBorrows)) {
+ if matches!(miri_config.borrow_tracker, Some(BorrowTrackerMethod::TreeBorrows { .. })) {
if miri_config.provenance_mode != ProvenanceMode::Strict {
show_error!(
"Tree Borrows does not support integer-to-pointer casts, and hence requires strict provenance"
);
}
- if miri_config.native_lib.is_some() {
+ if !miri_config.native_lib.is_empty() {
show_error!("Tree Borrows is not compatible with calling native functions");
}
}
+
// Native calls and strict provenance are not compatible.
- if miri_config.native_lib.is_some() && miri_config.provenance_mode == ProvenanceMode::Strict {
+ if !miri_config.native_lib.is_empty() && miri_config.provenance_mode == ProvenanceMode::Strict {
show_error!("strict provenance is not compatible with calling native functions");
}
// You can set either one seed or many.
diff --git a/src/tools/miri/src/borrow_tracker/mod.rs b/src/tools/miri/src/borrow_tracker/mod.rs
index b66c561..36c61053 100644
--- a/src/tools/miri/src/borrow_tracker/mod.rs
+++ b/src/tools/miri/src/borrow_tracker/mod.rs
@@ -226,7 +226,13 @@ pub enum BorrowTrackerMethod {
/// Stacked Borrows, as implemented in borrow_tracker/stacked_borrows
StackedBorrows,
/// Tree borrows, as implemented in borrow_tracker/tree_borrows
- TreeBorrows,
+ TreeBorrows(TreeBorrowsParams),
+}
+
+/// Parameters that Tree Borrows can take.
+#[derive(Debug, Copy, Clone, PartialEq, Eq)]
+pub struct TreeBorrowsParams {
+ pub precise_interior_mut: bool,
}
impl BorrowTrackerMethod {
@@ -237,6 +243,13 @@ pub fn instantiate_global_state(self, config: &MiriConfig) -> GlobalState {
config.retag_fields,
))
}
+
+ pub fn get_tree_borrows_params(self) -> TreeBorrowsParams {
+ match self {
+ BorrowTrackerMethod::TreeBorrows(params) => params,
+ _ => panic!("can only be called when `BorrowTrackerMethod` is `TreeBorrows`"),
+ }
+ }
}
impl GlobalStateInner {
@@ -252,7 +265,7 @@ pub fn new_allocation(
AllocState::StackedBorrows(Box::new(RefCell::new(Stacks::new_allocation(
id, alloc_size, self, kind, machine,
)))),
- BorrowTrackerMethod::TreeBorrows =>
+ BorrowTrackerMethod::TreeBorrows { .. } =>
AllocState::TreeBorrows(Box::new(RefCell::new(Tree::new_allocation(
id, alloc_size, self, kind, machine,
)))),
@@ -271,7 +284,7 @@ fn retag_ptr_value(
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
match method {
BorrowTrackerMethod::StackedBorrows => this.sb_retag_ptr_value(kind, val),
- BorrowTrackerMethod::TreeBorrows => this.tb_retag_ptr_value(kind, val),
+ BorrowTrackerMethod::TreeBorrows { .. } => this.tb_retag_ptr_value(kind, val),
}
}
@@ -284,7 +297,7 @@ fn retag_place_contents(
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
match method {
BorrowTrackerMethod::StackedBorrows => this.sb_retag_place_contents(kind, place),
- BorrowTrackerMethod::TreeBorrows => this.tb_retag_place_contents(kind, place),
+ BorrowTrackerMethod::TreeBorrows { .. } => this.tb_retag_place_contents(kind, place),
}
}
@@ -293,7 +306,7 @@ fn protect_place(&mut self, place: &MPlaceTy<'tcx>) -> InterpResult<'tcx, MPlace
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
match method {
BorrowTrackerMethod::StackedBorrows => this.sb_protect_place(place),
- BorrowTrackerMethod::TreeBorrows => this.tb_protect_place(place),
+ BorrowTrackerMethod::TreeBorrows { .. } => this.tb_protect_place(place),
}
}
@@ -302,7 +315,7 @@ fn expose_tag(&self, alloc_id: AllocId, tag: BorTag) -> InterpResult<'tcx> {
let method = this.machine.borrow_tracker.as_ref().unwrap().borrow().borrow_tracker_method;
match method {
BorrowTrackerMethod::StackedBorrows => this.sb_expose_tag(alloc_id, tag),
- BorrowTrackerMethod::TreeBorrows => this.tb_expose_tag(alloc_id, tag),
+ BorrowTrackerMethod::TreeBorrows { .. } => this.tb_expose_tag(alloc_id, tag),
}
}
@@ -319,7 +332,7 @@ fn give_pointer_debug_name(
this.tcx.tcx.dcx().warn("Stacked Borrows does not support named pointers; `miri_pointer_name` is a no-op");
interp_ok(())
}
- BorrowTrackerMethod::TreeBorrows =>
+ BorrowTrackerMethod::TreeBorrows { .. } =>
this.tb_give_pointer_debug_name(ptr, nth_parent, name),
}
}
@@ -333,7 +346,7 @@ fn print_borrow_state(&mut self, alloc_id: AllocId, show_unnamed: bool) -> Inter
let method = borrow_tracker.borrow().borrow_tracker_method;
match method {
BorrowTrackerMethod::StackedBorrows => this.print_stacks(alloc_id),
- BorrowTrackerMethod::TreeBorrows => this.print_tree(alloc_id, show_unnamed),
+ BorrowTrackerMethod::TreeBorrows { .. } => this.print_tree(alloc_id, show_unnamed),
}
}
diff --git a/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs b/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs
index 411ae89..ce8fe03 100644
--- a/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs
+++ b/src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs
@@ -312,8 +312,6 @@ fn tb_reborrow(
}
let span = this.machine.current_span();
- let alloc_extra = this.get_alloc_extra(alloc_id)?;
- let mut tree_borrows = alloc_extra.borrow_tracker_tb().borrow_mut();
// Store initial permissions and their corresponding range.
let mut perms_map: RangeMap<LocationState> = RangeMap::new(
@@ -342,36 +340,83 @@ fn tb_reborrow(
assert!(new_perm.freeze_access);
let protected = new_perm.protector.is_some();
- this.visit_freeze_sensitive(place, ptr_size, |range, frozen| {
- has_unsafe_cell = has_unsafe_cell || !frozen;
+ let precise_interior_mut = this
+ .machine
+ .borrow_tracker
+ .as_mut()
+ .unwrap()
+ .get_mut()
+ .borrow_tracker_method
+ .get_tree_borrows_params()
+ .precise_interior_mut;
- // We are only ever `Frozen` inside the frozen bits.
- let (perm, access) = if frozen {
+ let default_perm = if !precise_interior_mut {
+ // NOTE: Using `ty_is_freeze` doesn't give the same result as going through the range
+ // and computing `has_unsafe_cell`. This is because of zero-sized `UnsafeCell`, for which
+ // `has_unsafe_cell` is false, but `!ty_is_freeze` is true.
+ let ty_is_freeze = place.layout.ty.is_freeze(*this.tcx, this.typing_env());
+ let (perm, access) = if ty_is_freeze {
(new_perm.freeze_perm, new_perm.freeze_access)
} else {
(new_perm.nonfreeze_perm, new_perm.nonfreeze_access)
};
+ let sifa = perm.strongest_idempotent_foreign_access(protected);
+ let new_loc = if access {
+ LocationState::new_accessed(perm, sifa)
+ } else {
+ LocationState::new_non_accessed(perm, sifa)
+ };
- // Store initial permissions.
- for (_loc_range, loc) in perms_map.iter_mut(range.start, range.size) {
+ for (_loc_range, loc) in perms_map.iter_mut_all() {
+ *loc = new_loc;
+ }
+
+ perm
+ } else {
+ this.visit_freeze_sensitive(place, ptr_size, |range, frozen| {
+ has_unsafe_cell = has_unsafe_cell || !frozen;
+
+ // We are only ever `Frozen` inside the frozen bits.
+ let (perm, access) = if frozen {
+ (new_perm.freeze_perm, new_perm.freeze_access)
+ } else {
+ (new_perm.nonfreeze_perm, new_perm.nonfreeze_access)
+ };
let sifa = perm.strongest_idempotent_foreign_access(protected);
// NOTE: Currently, `access` is false if and only if `perm` is Cell, so this `if`
// doesn't not change whether any code is UB or not. We could just always use
// `new_accessed` and everything would stay the same. But that seems conceptually
// odd, so we keep the initial "accessed" bit of the `LocationState` in sync with whether
// a read access is performed below.
- if access {
- *loc = LocationState::new_accessed(perm, sifa);
+ let new_loc = if access {
+ LocationState::new_accessed(perm, sifa)
} else {
- *loc = LocationState::new_non_accessed(perm, sifa);
- }
- }
+ LocationState::new_non_accessed(perm, sifa)
+ };
- // Some reborrows incur a read access to the parent.
- if access {
+ // Store initial permissions.
+ for (_loc_range, loc) in perms_map.iter_mut(range.start, range.size) {
+ *loc = new_loc;
+ }
+
+ interp_ok(())
+ })?;
+
+ // Allow lazily writing to surrounding data if we found an `UnsafeCell`.
+ if has_unsafe_cell { new_perm.nonfreeze_perm } else { new_perm.freeze_perm }
+ };
+
+ let alloc_extra = this.get_alloc_extra(alloc_id)?;
+ let mut tree_borrows = alloc_extra.borrow_tracker_tb().borrow_mut();
+
+ for (perm_range, perm) in perms_map.iter_mut_all() {
+ if perm.is_accessed() {
+ // Some reborrows incur a read access to the parent.
// Adjust range to be relative to allocation start (rather than to `place`).
- let mut range_in_alloc = range;
- range_in_alloc.start += base_offset;
+ let range_in_alloc = AllocRange {
+ start: Size::from_bytes(perm_range.start) + base_offset,
+ size: Size::from_bytes(perm_range.end - perm_range.start),
+ };
tree_borrows.perform_access(
orig_tag,
@@ -382,7 +427,7 @@ fn tb_reborrow(
)?;
// Also inform the data race model (but only if any bytes are actually affected).
- if range.size.bytes() > 0 {
+ if range_in_alloc.size.bytes() > 0 {
if let Some(data_race) = alloc_extra.data_race.as_vclocks_ref() {
data_race.read(
alloc_id,
@@ -394,8 +439,7 @@ fn tb_reborrow(
}
}
}
- interp_ok(())
- })?;
+ }
// Record the parent-child pair in the tree.
tree_borrows.new_child(
@@ -403,8 +447,7 @@ fn tb_reborrow(
orig_tag,
new_tag,
perms_map,
- // Allow lazily writing to surrounding data if we found an `UnsafeCell`.
- if has_unsafe_cell { new_perm.nonfreeze_perm } else { new_perm.freeze_perm },
+ default_perm,
protected,
span,
)?;
diff --git a/src/tools/miri/src/diagnostics.rs b/src/tools/miri/src/diagnostics.rs
index 1728a9c..58bf163 100644
--- a/src/tools/miri/src/diagnostics.rs
+++ b/src/tools/miri/src/diagnostics.rs
@@ -682,7 +682,10 @@ pub fn emit_diagnostic(&self, e: NonHaltingDiagnostic) {
),
];
if self.borrow_tracker.as_ref().is_some_and(|b| {
- matches!(b.borrow().borrow_tracker_method(), BorrowTrackerMethod::TreeBorrows)
+ matches!(
+ b.borrow().borrow_tracker_method(),
+ BorrowTrackerMethod::TreeBorrows { .. }
+ )
}) {
v.push(
note!("Tree Borrows does not support integer-to-pointer casts, so the program is likely to go wrong when this pointer gets used")
diff --git a/src/tools/miri/src/eval.rs b/src/tools/miri/src/eval.rs
index 5880e5f..6f5f756 100644
--- a/src/tools/miri/src/eval.rs
+++ b/src/tools/miri/src/eval.rs
@@ -148,9 +148,8 @@ pub struct MiriConfig {
pub report_progress: Option<u32>,
/// Whether Stacked Borrows and Tree Borrows retagging should recurse into fields of datatypes.
pub retag_fields: RetagFields,
- /// The location of a shared object file to load when calling external functions
- /// FIXME! consider allowing users to specify paths to multiple files, or to a directory
- pub native_lib: Option<PathBuf>,
+ /// The location of the shared object files to load when calling external functions
+ pub native_lib: Vec<PathBuf>,
/// Run a garbage collector for BorTags every N basic blocks.
pub gc_interval: u32,
/// The number of CPUs to be reported by miri.
@@ -197,7 +196,7 @@ fn default() -> MiriConfig {
preemption_rate: 0.01, // 1%
report_progress: None,
retag_fields: RetagFields::Yes,
- native_lib: None,
+ native_lib: vec![],
gc_interval: 10_000,
num_cpus: 1,
page_size: None,
diff --git a/src/tools/miri/src/intrinsics/atomic.rs b/src/tools/miri/src/intrinsics/atomic.rs
index a61226e..0a59a70 100644
--- a/src/tools/miri/src/intrinsics/atomic.rs
+++ b/src/tools/miri/src/intrinsics/atomic.rs
@@ -26,108 +26,131 @@ fn emulate_atomic_intrinsic(
) -> InterpResult<'tcx, EmulateItemResult> {
let this = self.eval_context_mut();
- let intrinsic_structure: Vec<_> = intrinsic_name.split('_').collect();
+ let get_ord_at = |i: usize| {
+ let ordering = generic_args.const_at(i).to_value();
+ ordering.valtree.unwrap_branch()[0].unwrap_leaf().to_atomic_ordering()
+ };
- fn read_ord(ord: &str) -> AtomicReadOrd {
+ fn read_ord(ord: AtomicOrdering) -> AtomicReadOrd {
match ord {
- "seqcst" => AtomicReadOrd::SeqCst,
- "acquire" => AtomicReadOrd::Acquire,
- "relaxed" => AtomicReadOrd::Relaxed,
- _ => panic!("invalid read ordering `{ord}`"),
- }
- }
-
- fn read_ord_const_generic(o: AtomicOrdering) -> AtomicReadOrd {
- match o {
AtomicOrdering::SeqCst => AtomicReadOrd::SeqCst,
AtomicOrdering::Acquire => AtomicReadOrd::Acquire,
AtomicOrdering::Relaxed => AtomicReadOrd::Relaxed,
- _ => panic!("invalid read ordering `{o:?}`"),
+ _ => panic!("invalid read ordering `{ord:?}`"),
}
}
- fn write_ord(ord: &str) -> AtomicWriteOrd {
+ fn write_ord(ord: AtomicOrdering) -> AtomicWriteOrd {
match ord {
- "seqcst" => AtomicWriteOrd::SeqCst,
- "release" => AtomicWriteOrd::Release,
- "relaxed" => AtomicWriteOrd::Relaxed,
- _ => panic!("invalid write ordering `{ord}`"),
+ AtomicOrdering::SeqCst => AtomicWriteOrd::SeqCst,
+ AtomicOrdering::Release => AtomicWriteOrd::Release,
+ AtomicOrdering::Relaxed => AtomicWriteOrd::Relaxed,
+ _ => panic!("invalid write ordering `{ord:?}`"),
}
}
- fn rw_ord(ord: &str) -> AtomicRwOrd {
+ fn rw_ord(ord: AtomicOrdering) -> AtomicRwOrd {
match ord {
- "seqcst" => AtomicRwOrd::SeqCst,
- "acqrel" => AtomicRwOrd::AcqRel,
- "acquire" => AtomicRwOrd::Acquire,
- "release" => AtomicRwOrd::Release,
- "relaxed" => AtomicRwOrd::Relaxed,
- _ => panic!("invalid read-write ordering `{ord}`"),
+ AtomicOrdering::SeqCst => AtomicRwOrd::SeqCst,
+ AtomicOrdering::AcqRel => AtomicRwOrd::AcqRel,
+ AtomicOrdering::Acquire => AtomicRwOrd::Acquire,
+ AtomicOrdering::Release => AtomicRwOrd::Release,
+ AtomicOrdering::Relaxed => AtomicRwOrd::Relaxed,
}
}
- fn fence_ord(ord: &str) -> AtomicFenceOrd {
+ fn fence_ord(ord: AtomicOrdering) -> AtomicFenceOrd {
match ord {
- "seqcst" => AtomicFenceOrd::SeqCst,
- "acqrel" => AtomicFenceOrd::AcqRel,
- "acquire" => AtomicFenceOrd::Acquire,
- "release" => AtomicFenceOrd::Release,
- _ => panic!("invalid fence ordering `{ord}`"),
+ AtomicOrdering::SeqCst => AtomicFenceOrd::SeqCst,
+ AtomicOrdering::AcqRel => AtomicFenceOrd::AcqRel,
+ AtomicOrdering::Acquire => AtomicFenceOrd::Acquire,
+ AtomicOrdering::Release => AtomicFenceOrd::Release,
+ _ => panic!("invalid fence ordering `{ord:?}`"),
}
}
- match &*intrinsic_structure {
- // New-style intrinsics that use const generics
- ["load"] => {
- let ordering = generic_args.const_at(1).to_value();
- let ordering =
- ordering.valtree.unwrap_branch()[0].unwrap_leaf().to_atomic_ordering();
- this.atomic_load(args, dest, read_ord_const_generic(ordering))?;
+ match intrinsic_name {
+ "load" => {
+ let ord = get_ord_at(1);
+ this.atomic_load(args, dest, read_ord(ord))?;
}
- // Old-style intrinsics that have the ordering in the intrinsic name
- ["store", ord] => this.atomic_store(args, write_ord(ord))?,
+ "store" => {
+ let ord = get_ord_at(1);
+ this.atomic_store(args, write_ord(ord))?
+ }
- ["fence", ord] => this.atomic_fence_intrinsic(args, fence_ord(ord))?,
- ["singlethreadfence", ord] => this.compiler_fence_intrinsic(args, fence_ord(ord))?,
+ "fence" => {
+ let ord = get_ord_at(0);
+ this.atomic_fence_intrinsic(args, fence_ord(ord))?
+ }
+ "singlethreadfence" => {
+ let ord = get_ord_at(0);
+ this.compiler_fence_intrinsic(args, fence_ord(ord))?;
+ }
- ["xchg", ord] => this.atomic_exchange(args, dest, rw_ord(ord))?,
- ["cxchg", ord1, ord2] =>
- this.atomic_compare_exchange(args, dest, rw_ord(ord1), read_ord(ord2))?,
- ["cxchgweak", ord1, ord2] =>
- this.atomic_compare_exchange_weak(args, dest, rw_ord(ord1), read_ord(ord2))?,
+ "xchg" => {
+ let ord = get_ord_at(1);
+ this.atomic_exchange(args, dest, rw_ord(ord))?;
+ }
+ "cxchg" => {
+ let ord1 = get_ord_at(1);
+ let ord2 = get_ord_at(2);
+ this.atomic_compare_exchange(args, dest, rw_ord(ord1), read_ord(ord2))?;
+ }
+ "cxchgweak" => {
+ let ord1 = get_ord_at(1);
+ let ord2 = get_ord_at(2);
+ this.atomic_compare_exchange_weak(args, dest, rw_ord(ord1), read_ord(ord2))?;
+ }
- ["or", ord] =>
- this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitOr, false), rw_ord(ord))?,
- ["xor", ord] =>
- this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitXor, false), rw_ord(ord))?,
- ["and", ord] =>
- this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, false), rw_ord(ord))?,
- ["nand", ord] =>
- this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, true), rw_ord(ord))?,
- ["xadd", ord] =>
- this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::Add, false), rw_ord(ord))?,
- ["xsub", ord] =>
- this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::Sub, false), rw_ord(ord))?,
- ["min", ord] => {
+ "or" => {
+ let ord = get_ord_at(1);
+ this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitOr, false), rw_ord(ord))?;
+ }
+ "xor" => {
+ let ord = get_ord_at(1);
+ this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitXor, false), rw_ord(ord))?;
+ }
+ "and" => {
+ let ord = get_ord_at(1);
+ this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, false), rw_ord(ord))?;
+ }
+ "nand" => {
+ let ord = get_ord_at(1);
+ this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, true), rw_ord(ord))?;
+ }
+ "xadd" => {
+ let ord = get_ord_at(1);
+ this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::Add, false), rw_ord(ord))?;
+ }
+ "xsub" => {
+ let ord = get_ord_at(1);
+ this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::Sub, false), rw_ord(ord))?;
+ }
+ "min" => {
+ let ord = get_ord_at(1);
// Later we will use the type to indicate signed vs unsigned,
// so make sure it matches the intrinsic name.
assert!(matches!(args[1].layout.ty.kind(), ty::Int(_)));
this.atomic_rmw_op(args, dest, AtomicOp::Min, rw_ord(ord))?;
}
- ["umin", ord] => {
+ "umin" => {
+ let ord = get_ord_at(1);
// Later we will use the type to indicate signed vs unsigned,
// so make sure it matches the intrinsic name.
assert!(matches!(args[1].layout.ty.kind(), ty::Uint(_)));
this.atomic_rmw_op(args, dest, AtomicOp::Min, rw_ord(ord))?;
}
- ["max", ord] => {
+ "max" => {
+ let ord = get_ord_at(1);
// Later we will use the type to indicate signed vs unsigned,
// so make sure it matches the intrinsic name.
assert!(matches!(args[1].layout.ty.kind(), ty::Int(_)));
this.atomic_rmw_op(args, dest, AtomicOp::Max, rw_ord(ord))?;
}
- ["umax", ord] => {
+ "umax" => {
+ let ord = get_ord_at(1);
// Later we will use the type to indicate signed vs unsigned,
// so make sure it matches the intrinsic name.
assert!(matches!(args[1].layout.ty.kind(), ty::Uint(_)));
diff --git a/src/tools/miri/src/intrinsics/mod.rs b/src/tools/miri/src/intrinsics/mod.rs
index a4882a2..9957e35 100644
--- a/src/tools/miri/src/intrinsics/mod.rs
+++ b/src/tools/miri/src/intrinsics/mod.rs
@@ -3,17 +3,20 @@
mod atomic;
mod simd;
+use std::ops::Neg;
+
use rand::Rng;
use rustc_abi::Size;
-use rustc_apfloat::{Float, Round};
+use rustc_apfloat::ieee::{IeeeFloat, Semantics};
+use rustc_apfloat::{self, Float, Round};
use rustc_middle::mir;
-use rustc_middle::ty::{self, FloatTy};
+use rustc_middle::ty::{self, FloatTy, ScalarInt};
use rustc_span::{Symbol, sym};
use self::atomic::EvalContextExt as _;
use self::helpers::{ToHost, ToSoft, check_intrinsic_arg_count};
use self::simd::EvalContextExt as _;
-use crate::math::apply_random_float_error_to_imm;
+use crate::math::{IeeeExt, apply_random_float_error_ulp};
use crate::*;
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
@@ -187,31 +190,39 @@ fn emulate_intrinsic_by_name(
=> {
let [f] = check_intrinsic_arg_count(args)?;
let f = this.read_scalar(f)?.to_f32()?;
- // Using host floats (but it's fine, these operations do not have
- // guaranteed precision).
- let host = f.to_host();
- let res = match intrinsic_name {
- "sinf32" => host.sin(),
- "cosf32" => host.cos(),
- "expf32" => host.exp(),
- "exp2f32" => host.exp2(),
- "logf32" => host.ln(),
- "log10f32" => host.log10(),
- "log2f32" => host.log2(),
- _ => bug!(),
- };
- let res = res.to_soft();
- // Apply a relative error of 16ULP to introduce some non-determinism
- // simulating imprecise implementations and optimizations.
- // FIXME: temporarily disabled as it breaks std tests.
- // let res = apply_random_float_error_ulp(
- // this,
- // res,
- // 4, // log2(16)
- // );
+
+ let res = fixed_float_value(intrinsic_name, &[f]).unwrap_or_else(||{
+ // Using host floats (but it's fine, these operations do not have
+ // guaranteed precision).
+ let host = f.to_host();
+ let res = match intrinsic_name {
+ "sinf32" => host.sin(),
+ "cosf32" => host.cos(),
+ "expf32" => host.exp(),
+ "exp2f32" => host.exp2(),
+ "logf32" => host.ln(),
+ "log10f32" => host.log10(),
+ "log2f32" => host.log2(),
+ _ => bug!(),
+ };
+ let res = res.to_soft();
+
+ // Apply a relative error of 4ULP to introduce some non-determinism
+ // simulating imprecise implementations and optimizations.
+ let res = apply_random_float_error_ulp(
+ this,
+ res,
+ 2, // log2(4)
+ );
+
+ // Clamp the result to the guaranteed range of this function according to the C standard,
+ // if any.
+ clamp_float_value(intrinsic_name, res)
+ });
let res = this.adjust_nan(res, &[f]);
this.write_scalar(res, dest)?;
}
+
#[rustfmt::skip]
| "sinf64"
| "cosf64"
@@ -223,28 +234,35 @@ fn emulate_intrinsic_by_name(
=> {
let [f] = check_intrinsic_arg_count(args)?;
let f = this.read_scalar(f)?.to_f64()?;
- // Using host floats (but it's fine, these operations do not have
- // guaranteed precision).
- let host = f.to_host();
- let res = match intrinsic_name {
- "sinf64" => host.sin(),
- "cosf64" => host.cos(),
- "expf64" => host.exp(),
- "exp2f64" => host.exp2(),
- "logf64" => host.ln(),
- "log10f64" => host.log10(),
- "log2f64" => host.log2(),
- _ => bug!(),
- };
- let res = res.to_soft();
- // Apply a relative error of 16ULP to introduce some non-determinism
- // simulating imprecise implementations and optimizations.
- // FIXME: temporarily disabled as it breaks std tests.
- // let res = apply_random_float_error_ulp(
- // this,
- // res,
- // 4, // log2(16)
- // );
+
+ let res = fixed_float_value(intrinsic_name, &[f]).unwrap_or_else(||{
+ // Using host floats (but it's fine, these operations do not have
+ // guaranteed precision).
+ let host = f.to_host();
+ let res = match intrinsic_name {
+ "sinf64" => host.sin(),
+ "cosf64" => host.cos(),
+ "expf64" => host.exp(),
+ "exp2f64" => host.exp2(),
+ "logf64" => host.ln(),
+ "log10f64" => host.log10(),
+ "log2f64" => host.log2(),
+ _ => bug!(),
+ };
+ let res = res.to_soft();
+
+ // Apply a relative error of 4ULP to introduce some non-determinism
+ // simulating imprecise implementations and optimizations.
+ let res = apply_random_float_error_ulp(
+ this,
+ res,
+ 2, // log2(4)
+ );
+
+ // Clamp the result to the guaranteed range of this function according to the C standard,
+ // if any.
+ clamp_float_value(intrinsic_name, res)
+ });
let res = this.adjust_nan(res, &[f]);
this.write_scalar(res, dest)?;
}
@@ -302,43 +320,75 @@ fn emulate_intrinsic_by_name(
}
"powf32" => {
- // FIXME: apply random relative error but without altering behaviour of powf
let [f1, f2] = check_intrinsic_arg_count(args)?;
let f1 = this.read_scalar(f1)?.to_f32()?;
let f2 = this.read_scalar(f2)?.to_f32()?;
- // Using host floats (but it's fine, this operation does not have guaranteed precision).
- let res = f1.to_host().powf(f2.to_host()).to_soft();
+
+ let res = fixed_float_value(intrinsic_name, &[f1, f2]).unwrap_or_else(|| {
+ // Using host floats (but it's fine, this operation does not have guaranteed precision).
+ let res = f1.to_host().powf(f2.to_host()).to_soft();
+
+ // Apply a relative error of 4ULP to introduce some non-determinism
+ // simulating imprecise implementations and optimizations.
+ apply_random_float_error_ulp(
+ this, res, 2, // log2(4)
+ )
+ });
let res = this.adjust_nan(res, &[f1, f2]);
this.write_scalar(res, dest)?;
}
"powf64" => {
- // FIXME: apply random relative error but without altering behaviour of powf
let [f1, f2] = check_intrinsic_arg_count(args)?;
let f1 = this.read_scalar(f1)?.to_f64()?;
let f2 = this.read_scalar(f2)?.to_f64()?;
- // Using host floats (but it's fine, this operation does not have guaranteed precision).
- let res = f1.to_host().powf(f2.to_host()).to_soft();
+
+ let res = fixed_float_value(intrinsic_name, &[f1, f2]).unwrap_or_else(|| {
+ // Using host floats (but it's fine, this operation does not have guaranteed precision).
+ let res = f1.to_host().powf(f2.to_host()).to_soft();
+
+ // Apply a relative error of 4ULP to introduce some non-determinism
+ // simulating imprecise implementations and optimizations.
+ apply_random_float_error_ulp(
+ this, res, 2, // log2(4)
+ )
+ });
let res = this.adjust_nan(res, &[f1, f2]);
this.write_scalar(res, dest)?;
}
"powif32" => {
- // FIXME: apply random relative error but without altering behaviour of powi
let [f, i] = check_intrinsic_arg_count(args)?;
let f = this.read_scalar(f)?.to_f32()?;
let i = this.read_scalar(i)?.to_i32()?;
- // Using host floats (but it's fine, this operation does not have guaranteed precision).
- let res = f.to_host().powi(i).to_soft();
+
+ let res = fixed_powi_float_value(f, i).unwrap_or_else(|| {
+ // Using host floats (but it's fine, this operation does not have guaranteed precision).
+ let res = f.to_host().powi(i).to_soft();
+
+ // Apply a relative error of 4ULP to introduce some non-determinism
+ // simulating imprecise implementations and optimizations.
+ apply_random_float_error_ulp(
+ this, res, 2, // log2(4)
+ )
+ });
let res = this.adjust_nan(res, &[f]);
this.write_scalar(res, dest)?;
}
"powif64" => {
- // FIXME: apply random relative error but without altering behaviour of powi
let [f, i] = check_intrinsic_arg_count(args)?;
let f = this.read_scalar(f)?.to_f64()?;
let i = this.read_scalar(i)?.to_i32()?;
- // Using host floats (but it's fine, this operation does not have guaranteed precision).
- let res = f.to_host().powi(i).to_soft();
+
+ let res = fixed_powi_float_value(f, i).unwrap_or_else(|| {
+ // Using host floats (but it's fine, this operation does not have guaranteed precision).
+ let res = f.to_host().powi(i).to_soft();
+
+ // Apply a relative error of 4ULP to introduce some non-determinism
+ // simulating imprecise implementations and optimizations.
+ apply_random_float_error_ulp(
+ this, res, 2, // log2(4)
+ )
+ });
let res = this.adjust_nan(res, &[f]);
this.write_scalar(res, dest)?;
}
@@ -425,3 +475,97 @@ fn emulate_intrinsic_by_name(
interp_ok(EmulateItemResult::NeedsReturn)
}
}
+
+/// Applies a random ULP floating point error to `val` and returns the new value.
+/// So if you want an X ULP error, `ulp_exponent` should be log2(X).
+///
+/// Will fail if `val` is not a floating point number.
+fn apply_random_float_error_to_imm<'tcx>(
+ ecx: &mut MiriInterpCx<'tcx>,
+ val: ImmTy<'tcx>,
+ ulp_exponent: u32,
+) -> InterpResult<'tcx, ImmTy<'tcx>> {
+ let scalar = val.to_scalar_int()?;
+ let res: ScalarInt = match val.layout.ty.kind() {
+ ty::Float(FloatTy::F16) =>
+ apply_random_float_error_ulp(ecx, scalar.to_f16(), ulp_exponent).into(),
+ ty::Float(FloatTy::F32) =>
+ apply_random_float_error_ulp(ecx, scalar.to_f32(), ulp_exponent).into(),
+ ty::Float(FloatTy::F64) =>
+ apply_random_float_error_ulp(ecx, scalar.to_f64(), ulp_exponent).into(),
+ ty::Float(FloatTy::F128) =>
+ apply_random_float_error_ulp(ecx, scalar.to_f128(), ulp_exponent).into(),
+ _ => bug!("intrinsic called with non-float input type"),
+ };
+
+ interp_ok(ImmTy::from_scalar_int(res, val.layout))
+}
+
+/// For the intrinsics:
+/// - sinf32, sinf64
+/// - cosf32, cosf64
+/// - expf32, expf64, exp2f32, exp2f64
+/// - logf32, logf64, log2f32, log2f64, log10f32, log10f64
+/// - powf32, powf64
+///
+/// Returns `Some(output)` if the `intrinsic` results in a defined fixed `output` specified in the C standard
+/// (specifically, C23 annex F.10) when given `args` as arguments. Outputs that are unaffected by a relative error
+/// (such as INF and zero) are not handled here, they are assumed to be handled by the underlying
+/// implementation. Returns `None` if no specific value is guaranteed.
+fn fixed_float_value<S: Semantics>(
+ intrinsic_name: &str,
+ args: &[IeeeFloat<S>],
+) -> Option<IeeeFloat<S>> {
+ let one = IeeeFloat::<S>::one();
+ match (intrinsic_name, args) {
+ // cos(+- 0) = 1
+ ("cosf32" | "cosf64", [input]) if input.is_zero() => Some(one),
+
+ // e^0 = 1
+ ("expf32" | "expf64" | "exp2f32" | "exp2f64", [input]) if input.is_zero() => Some(one),
+
+ // 1^y = 1 for any y, even a NaN.
+ ("powf32" | "powf64", [base, _]) if *base == one => Some(one),
+
+ // (-1)^(±INF) = 1
+ ("powf32" | "powf64", [base, exp]) if *base == -one && exp.is_infinite() => Some(one),
+
+ // FIXME(#4286): The C ecosystem is inconsistent with handling sNaN's, some return 1 others propogate
+ // the NaN. We should return either 1 or the NaN non-deterministically here.
+ // But for now, just handle them all the same.
+ // x^(±0) = 1 for any x, even a NaN
+ ("powf32" | "powf64", [_, exp]) if exp.is_zero() => Some(one),
+
+ // There are a lot of cases for fixed outputs according to the C Standard, but these are mainly INF or zero
+ // which are not affected by the applied error.
+ _ => None,
+ }
+}
+
+/// Returns `Some(output)` if `powi` (called `pown` in C) results in a fixed value specified in the C standard
+/// (specifically, C23 annex F.10.4.6) when doing `base^exp`. Otherwise, returns `None`.
+fn fixed_powi_float_value<S: Semantics>(base: IeeeFloat<S>, exp: i32) -> Option<IeeeFloat<S>> {
+ match (base.category(), exp) {
+ // x^0 = 1, if x is not a Signaling NaN
+ // FIXME(#4286): The C ecosystem is inconsistent with handling sNaN's, some return 1 others propogate
+ // the NaN. We should return either 1 or the NaN non-deterministically here.
+ // But for now, just handle them all the same.
+ (_, 0) => Some(IeeeFloat::<S>::one()),
+
+ _ => None,
+ }
+}
+
+/// Given an floating-point operation and a floating-point value, clamps the result to the output
+/// range of the given operation.
+fn clamp_float_value<S: Semantics>(intrinsic_name: &str, val: IeeeFloat<S>) -> IeeeFloat<S> {
+ match intrinsic_name {
+ // sin and cos: [-1, 1]
+ "sinf32" | "cosf32" | "sinf64" | "cosf64" =>
+ val.clamp(IeeeFloat::<S>::one().neg(), IeeeFloat::<S>::one()),
+ // exp: [0, +INF]
+ "expf32" | "exp2f32" | "expf64" | "exp2f64" =>
+ IeeeFloat::<S>::maximum(val, IeeeFloat::<S>::ZERO),
+ _ => val,
+ }
+}
diff --git a/src/tools/miri/src/lib.rs b/src/tools/miri/src/lib.rs
index 51ec19a..344e12e 100644
--- a/src/tools/miri/src/lib.rs
+++ b/src/tools/miri/src/lib.rs
@@ -16,6 +16,7 @@
#![feature(unqualified_local_imports)]
#![feature(derive_coerce_pointee)]
#![feature(arbitrary_self_types)]
+#![feature(file_lock)]
// Configure clippy and other lints
#![allow(
clippy::collapsible_else_if,
@@ -113,7 +114,9 @@
EvalContextExt as _, Item, Permission, Stack, Stacks,
};
pub use crate::borrow_tracker::tree_borrows::{EvalContextExt as _, Tree};
-pub use crate::borrow_tracker::{BorTag, BorrowTrackerMethod, EvalContextExt as _, RetagFields};
+pub use crate::borrow_tracker::{
+ BorTag, BorrowTrackerMethod, EvalContextExt as _, RetagFields, TreeBorrowsParams,
+};
pub use crate::clock::{Instant, MonotonicClock};
pub use crate::concurrency::cpu_affinity::MAX_CPUS;
pub use crate::concurrency::data_race::{
diff --git a/src/tools/miri/src/machine.rs b/src/tools/miri/src/machine.rs
index 15b3653d..b221dd8 100644
--- a/src/tools/miri/src/machine.rs
+++ b/src/tools/miri/src/machine.rs
@@ -558,9 +558,9 @@ pub struct MiriMachine<'tcx> {
/// Handle of the optional shared object file for native functions.
#[cfg(unix)]
- pub native_lib: Option<(libloading::Library, std::path::PathBuf)>,
+ pub native_lib: Vec<(libloading::Library, std::path::PathBuf)>,
#[cfg(not(unix))]
- pub native_lib: Option<!>,
+ pub native_lib: Vec<!>,
/// Run a garbage collector for BorTags every N basic blocks.
pub(crate) gc_interval: u32,
@@ -720,7 +720,7 @@ pub(crate) fn new(
extern_statics: FxHashMap::default(),
rng: RefCell::new(rng),
#[cfg(target_os = "linux")]
- allocator: if config.native_lib.is_some() {
+ allocator: if !config.native_lib.is_empty() {
Some(Rc::new(RefCell::new(crate::alloc::isolated_alloc::IsolatedAlloc::new())))
} else { None },
tracked_alloc_ids: config.tracked_alloc_ids.clone(),
@@ -732,7 +732,7 @@ pub(crate) fn new(
basic_block_count: 0,
monotonic_clock: MonotonicClock::new(config.isolated_op == IsolatedOp::Allow),
#[cfg(unix)]
- native_lib: config.native_lib.as_ref().map(|lib_file_path| {
+ native_lib: config.native_lib.iter().map(|lib_file_path| {
let host_triple = rustc_session::config::host_tuple();
let target_triple = tcx.sess.opts.target_triple.tuple();
// Check if host target == the session target.
@@ -752,11 +752,11 @@ pub(crate) fn new(
},
lib_file_path.clone(),
)
- }),
+ }).collect(),
#[cfg(not(unix))]
- native_lib: config.native_lib.as_ref().map(|_| {
+ native_lib: config.native_lib.iter().map(|_| {
panic!("calling functions from native libraries via FFI is only supported on Unix")
- }),
+ }).collect(),
gc_interval: config.gc_interval,
since_gc: 0,
num_cpus: config.num_cpus,
diff --git a/src/tools/miri/src/math.rs b/src/tools/miri/src/math.rs
index 2ff29c7..d1355a2 100644
--- a/src/tools/miri/src/math.rs
+++ b/src/tools/miri/src/math.rs
@@ -151,6 +151,20 @@ pub(crate) fn sqrt<S: rustc_apfloat::ieee::Semantics>(x: IeeeFloat<S>) -> IeeeFl
}
}
+/// Extend functionality of rustc_apfloat softfloats
+pub trait IeeeExt: rustc_apfloat::Float {
+ #[inline]
+ fn one() -> Self {
+ Self::from_u128(1).value
+ }
+
+ #[inline]
+ fn clamp(self, min: Self, max: Self) -> Self {
+ self.maximum(min).minimum(max)
+ }
+}
+impl<S: rustc_apfloat::ieee::Semantics> IeeeExt for IeeeFloat<S> {}
+
#[cfg(test)]
mod tests {
use rustc_apfloat::ieee::{DoubleS, HalfS, IeeeFloat, QuadS, SingleS};
diff --git a/src/tools/miri/src/shims/alloc.rs b/src/tools/miri/src/shims/alloc.rs
index 323b95d..f05c5fb 100644
--- a/src/tools/miri/src/shims/alloc.rs
+++ b/src/tools/miri/src/shims/alloc.rs
@@ -13,12 +13,16 @@ fn malloc_align(&self, size: u64) -> Align {
// alignment requirement and size less than or equal to the size requested."
// So first we need to figure out what the limits are for "fundamental alignment".
// This is given by `alignof(max_align_t)`. The following list is taken from
- // `library/std/src/sys/pal/common/alloc.rs` (where this is called `MIN_ALIGN`) and should
+ // `library/std/src/sys/alloc/mod.rs` (where this is called `MIN_ALIGN`) and should
// be kept in sync.
+ let os = this.tcx.sess.target.os.as_ref();
let max_fundamental_align = match this.tcx.sess.target.arch.as_ref() {
- "x86" | "arm" | "mips" | "mips32r6" | "powerpc" | "powerpc64" | "wasm32" => 8,
- "x86_64" | "aarch64" | "mips64" | "mips64r6" | "s390x" | "sparc64" | "loongarch64" =>
- 16,
+ "riscv32" if matches!(os, "espidf" | "zkvm") => 4,
+ "xtensa" if matches!(os, "espidf") => 4,
+ "x86" | "arm" | "m68k" | "csky" | "loongarch32" | "mips" | "mips32r6" | "powerpc"
+ | "powerpc64" | "sparc" | "wasm32" | "hexagon" | "riscv32" | "xtensa" => 8,
+ "x86_64" | "aarch64" | "arm64ec" | "loongarch64" | "mips64" | "mips64r6" | "s390x"
+ | "sparc64" | "riscv64" | "wasm64" => 16,
arch => bug!("unsupported target architecture for malloc: `{}`", arch),
};
// The C standard only requires sufficient alignment for any *type* with size less than or
diff --git a/src/tools/miri/src/shims/backtrace.rs b/src/tools/miri/src/shims/backtrace.rs
index 8606735..feb83ca 100644
--- a/src/tools/miri/src/shims/backtrace.rs
+++ b/src/tools/miri/src/shims/backtrace.rs
@@ -169,8 +169,14 @@ fn handle_miri_resolve_frame(
_ => throw_unsup_format!("unknown `miri_resolve_frame` flags {}", flags),
}
- this.write_scalar(Scalar::from_u32(lineno), &this.project_field(dest, FieldIdx::from_u32(2))?)?;
- this.write_scalar(Scalar::from_u32(colno), &this.project_field(dest, FieldIdx::from_u32(3))?)?;
+ this.write_scalar(
+ Scalar::from_u32(lineno),
+ &this.project_field(dest, FieldIdx::from_u32(2))?,
+ )?;
+ this.write_scalar(
+ Scalar::from_u32(colno),
+ &this.project_field(dest, FieldIdx::from_u32(3))?,
+ )?;
// Support a 4-field struct for now - this is deprecated
// and slated for removal.
diff --git a/src/tools/miri/src/shims/foreign_items.rs b/src/tools/miri/src/shims/foreign_items.rs
index ae04ca0..39b930f 100644
--- a/src/tools/miri/src/shims/foreign_items.rs
+++ b/src/tools/miri/src/shims/foreign_items.rs
@@ -238,7 +238,7 @@ fn emulate_foreign_item_inner(
// First deal with any external C functions in linked .so file.
#[cfg(unix)]
- if this.machine.native_lib.as_ref().is_some() {
+ if !this.machine.native_lib.is_empty() {
use crate::shims::native_lib::EvalContextExt as _;
// An Ok(false) here means that the function being called was not exported
// by the specified `.so` file; we should continue and check if it corresponds to
diff --git a/src/tools/miri/src/shims/native_lib.rs b/src/tools/miri/src/shims/native_lib.rs
index 1e6c933..acf258f 100644
--- a/src/tools/miri/src/shims/native_lib.rs
+++ b/src/tools/miri/src/shims/native_lib.rs
@@ -87,31 +87,35 @@ fn call_native_with_args<'a>(
}
/// Get the pointer to the function of the specified name in the shared object file,
- /// if it exists. The function must be in the shared object file specified: we do *not*
- /// return pointers to functions in dependencies of the library.
+ /// if it exists. The function must be in one of the shared object files specified:
+ /// we do *not* return pointers to functions in dependencies of libraries.
fn get_func_ptr_explicitly_from_lib(&mut self, link_name: Symbol) -> Option<CodePtr> {
let this = self.eval_context_mut();
- // Try getting the function from the shared library.
- let (lib, lib_path) = this.machine.native_lib.as_ref().unwrap();
- let func: libloading::Symbol<'_, unsafe extern "C" fn()> =
- unsafe { lib.get(link_name.as_str().as_bytes()).ok()? };
- #[expect(clippy::as_conversions)] // fn-ptr to raw-ptr cast needs `as`.
- let fn_ptr = *func.deref() as *mut std::ffi::c_void;
+ // Try getting the function from one of the shared libraries.
+ for (lib, lib_path) in &this.machine.native_lib {
+ let Ok(func): Result<libloading::Symbol<'_, unsafe extern "C" fn()>, _> =
+ (unsafe { lib.get(link_name.as_str().as_bytes()) })
+ else {
+ continue;
+ };
+ #[expect(clippy::as_conversions)] // fn-ptr to raw-ptr cast needs `as`.
+ let fn_ptr = *func.deref() as *mut std::ffi::c_void;
- // FIXME: this is a hack!
- // The `libloading` crate will automatically load system libraries like `libc`.
- // On linux `libloading` is based on `dlsym`: https://docs.rs/libloading/0.7.3/src/libloading/os/unix/mod.rs.html#202
- // and `dlsym`(https://linux.die.net/man/3/dlsym) looks through the dependency tree of the
- // library if it can't find the symbol in the library itself.
- // So, in order to check if the function was actually found in the specified
- // `machine.external_so_lib` we need to check its `dli_fname` and compare it to
- // the specified SO file path.
- // This code is a reimplementation of the mechanism for getting `dli_fname` in `libloading`,
- // from: https://docs.rs/libloading/0.7.3/src/libloading/os/unix/mod.rs.html#411
- // using the `libc` crate where this interface is public.
- let mut info = std::mem::MaybeUninit::<libc::Dl_info>::zeroed();
- unsafe {
- if libc::dladdr(fn_ptr, info.as_mut_ptr()) != 0 {
+ // FIXME: this is a hack!
+ // The `libloading` crate will automatically load system libraries like `libc`.
+ // On linux `libloading` is based on `dlsym`: https://docs.rs/libloading/0.7.3/src/libloading/os/unix/mod.rs.html#202
+ // and `dlsym`(https://linux.die.net/man/3/dlsym) looks through the dependency tree of the
+ // library if it can't find the symbol in the library itself.
+ // So, in order to check if the function was actually found in the specified
+ // `machine.external_so_lib` we need to check its `dli_fname` and compare it to
+ // the specified SO file path.
+ // This code is a reimplementation of the mechanism for getting `dli_fname` in `libloading`,
+ // from: https://docs.rs/libloading/0.7.3/src/libloading/os/unix/mod.rs.html#411
+ // using the `libc` crate where this interface is public.
+ let mut info = std::mem::MaybeUninit::<libc::Dl_info>::zeroed();
+ unsafe {
+ let res = libc::dladdr(fn_ptr, info.as_mut_ptr());
+ assert!(res != 0, "failed to load info about function we already loaded");
let info = info.assume_init();
#[cfg(target_os = "cygwin")]
let fname_ptr = info.dli_fname.as_ptr();
@@ -121,13 +125,15 @@ fn get_func_ptr_explicitly_from_lib(&mut self, link_name: Symbol) -> Option<Code
if std::ffi::CStr::from_ptr(fname_ptr).to_str().unwrap()
!= lib_path.to_str().unwrap()
{
- return None;
+ // The function is not actually in this .so, check the next one.
+ continue;
}
}
- }
- // Return a pointer to the function.
- Some(CodePtr(fn_ptr))
+ // Return a pointer to the function.
+ return Some(CodePtr(fn_ptr));
+ }
+ None
}
}
diff --git a/src/tools/miri/src/shims/unix/fs.rs b/src/tools/miri/src/shims/unix/fs.rs
index 31cb269..0f7d453 100644
--- a/src/tools/miri/src/shims/unix/fs.rs
+++ b/src/tools/miri/src/shims/unix/fs.rs
@@ -2,7 +2,8 @@
use std::borrow::Cow;
use std::fs::{
- DirBuilder, File, FileType, OpenOptions, ReadDir, read_dir, remove_dir, remove_file, rename,
+ DirBuilder, File, FileType, OpenOptions, ReadDir, TryLockError, read_dir, remove_dir,
+ remove_file, rename,
};
use std::io::{self, ErrorKind, Read, Seek, SeekFrom, Write};
use std::path::{Path, PathBuf};
@@ -89,103 +90,27 @@ fn flock<'tcx>(
communicate_allowed: bool,
op: FlockOp,
) -> InterpResult<'tcx, io::Result<()>> {
- // cfg(bootstrap)
- macro_rules! cfg_select_dispatch {
- ($($tokens:tt)*) => {
- #[cfg(bootstrap)]
- cfg_match! { $($tokens)* }
-
- #[cfg(not(bootstrap))]
- cfg_select! { $($tokens)* }
- };
- }
-
assert!(communicate_allowed, "isolation should have prevented even opening a file");
- cfg_select_dispatch! {
- all(target_family = "unix", not(target_os = "solaris")) => {
- use std::os::fd::AsRawFd;
- use FlockOp::*;
- // We always use non-blocking call to prevent interpreter from being blocked
- let (host_op, lock_nb) = match op {
- SharedLock { nonblocking } => (libc::LOCK_SH | libc::LOCK_NB, nonblocking),
- ExclusiveLock { nonblocking } => (libc::LOCK_EX | libc::LOCK_NB, nonblocking),
- Unlock => (libc::LOCK_UN, false),
- };
-
- let fd = self.file.as_raw_fd();
- let ret = unsafe { libc::flock(fd, host_op) };
- let res = match ret {
- 0 => Ok(()),
- -1 => {
- let err = io::Error::last_os_error();
- if !lock_nb && err.kind() == io::ErrorKind::WouldBlock {
- throw_unsup_format!("blocking `flock` is not currently supported");
- }
- Err(err)
- }
- ret => panic!("Unexpected return value from flock: {ret}"),
- };
- interp_ok(res)
+ use FlockOp::*;
+ // We must not block the interpreter loop, so we always `try_lock`.
+ let (res, nonblocking) = match op {
+ SharedLock { nonblocking } => (self.file.try_lock_shared(), nonblocking),
+ ExclusiveLock { nonblocking } => (self.file.try_lock(), nonblocking),
+ Unlock => {
+ return interp_ok(self.file.unlock());
}
- target_family = "windows" => {
- use std::os::windows::io::AsRawHandle;
+ };
- use windows_sys::Win32::Foundation::{
- ERROR_IO_PENDING, ERROR_LOCK_VIOLATION, FALSE, TRUE,
- };
- use windows_sys::Win32::Storage::FileSystem::{
- LOCKFILE_EXCLUSIVE_LOCK, LOCKFILE_FAIL_IMMEDIATELY, LockFileEx, UnlockFile,
- };
-
- let fh = self.file.as_raw_handle();
-
- use FlockOp::*;
- let (ret, lock_nb) = match op {
- SharedLock { nonblocking } | ExclusiveLock { nonblocking } => {
- // We always use non-blocking call to prevent interpreter from being blocked
- let mut flags = LOCKFILE_FAIL_IMMEDIATELY;
- if matches!(op, ExclusiveLock { .. }) {
- flags |= LOCKFILE_EXCLUSIVE_LOCK;
- }
- let ret = unsafe { LockFileEx(fh, flags, 0, !0, !0, &mut std::mem::zeroed()) };
- (ret, nonblocking)
- }
- Unlock => {
- let ret = unsafe { UnlockFile(fh, 0, 0, !0, !0) };
- (ret, false)
- }
- };
-
- let res = match ret {
- TRUE => Ok(()),
- FALSE => {
- let mut err = io::Error::last_os_error();
- // This only runs on Windows hosts so we can use `raw_os_error`.
- // We have to be careful not to forward that error code to target code.
- let code: u32 = err.raw_os_error().unwrap().try_into().unwrap();
- if matches!(code, ERROR_IO_PENDING | ERROR_LOCK_VIOLATION) {
- if lock_nb {
- // The io error mapping does not know about these error codes,
- // so we translate it to `WouldBlock` manually.
- let desc = format!("LockFileEx wouldblock error: {err}");
- err = io::Error::new(io::ErrorKind::WouldBlock, desc);
- } else {
- throw_unsup_format!("blocking `flock` is not currently supported");
- }
- }
- Err(err)
- }
- _ => panic!("Unexpected return value: {ret}"),
- };
- interp_ok(res)
- }
- _ => {
- let _ = op;
- throw_unsup_format!(
- "flock is supported only on UNIX (except Solaris) and Windows hosts"
- );
- }
+ match res {
+ Ok(()) => interp_ok(Ok(())),
+ Err(TryLockError::Error(err)) => interp_ok(Err(err)),
+ Err(TryLockError::WouldBlock) =>
+ if nonblocking {
+ interp_ok(Err(ErrorKind::WouldBlock.into()))
+ } else {
+ throw_unsup_format!("blocking `flock` is not currently supported");
+ },
}
}
}
diff --git a/src/tools/miri/src/shims/unix/linux_like/epoll.rs b/src/tools/miri/src/shims/unix/linux_like/epoll.rs
index f971fb1..d460abc 100644
--- a/src/tools/miri/src/shims/unix/linux_like/epoll.rs
+++ b/src/tools/miri/src/shims/unix/linux_like/epoll.rs
@@ -286,7 +286,8 @@ fn epoll_ctl(
if op == epoll_ctl_add || op == epoll_ctl_mod {
// Read event bitmask and data from epoll_event passed by caller.
- let mut events = this.read_scalar(&this.project_field(&event, FieldIdx::ZERO)?)?.to_u32()?;
+ let mut events =
+ this.read_scalar(&this.project_field(&event, FieldIdx::ZERO)?)?.to_u32()?;
let data = this.read_scalar(&this.project_field(&event, FieldIdx::ONE)?)?.to_u64()?;
// Unset the flag we support to discover if any unsupported flags are used.
diff --git a/src/tools/miri/tests/fail/const-ub-checks.stderr b/src/tools/miri/tests/fail/const-ub-checks.stderr
index 9bac524..df2d565 100644
--- a/src/tools/miri/tests/fail/const-ub-checks.stderr
+++ b/src/tools/miri/tests/fail/const-ub-checks.stderr
@@ -2,7 +2,7 @@
--> tests/fail/const-ub-checks.rs:LL:CC
|
LL | ptr.read();
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `UNALIGNED_READ` failed here
note: erroneous constant encountered
--> tests/fail/const-ub-checks.rs:LL:CC
diff --git a/src/tools/miri/tests/fail/erroneous_const2.stderr b/src/tools/miri/tests/fail/erroneous_const2.stderr
index 9d3f1b1..08d2cc1 100644
--- a/src/tools/miri/tests/fail/erroneous_const2.stderr
+++ b/src/tools/miri/tests/fail/erroneous_const2.stderr
@@ -2,7 +2,7 @@
--> tests/fail/erroneous_const2.rs:LL:CC
|
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
- | ^^^^^ evaluation of constant value failed here
+ | ^^^^^ evaluation of `FOO` failed here
note: erroneous constant encountered
--> tests/fail/erroneous_const2.rs:LL:CC
diff --git a/src/tools/miri/tests/pass-dep/libc/libc-fs.rs b/src/tools/miri/tests/pass-dep/libc/libc-fs.rs
index 129b18d..0ff48c3 100644
--- a/src/tools/miri/tests/pass-dep/libc/libc-fs.rs
+++ b/src/tools/miri/tests/pass-dep/libc/libc-fs.rs
@@ -88,16 +88,17 @@ fn test_dup() {
let name_ptr = name.as_bytes().as_ptr().cast::<libc::c_char>();
unsafe {
let fd = libc::open(name_ptr, libc::O_RDONLY);
+ let new_fd = libc::dup(fd);
+ let new_fd2 = libc::dup2(fd, 8);
+
let mut first_buf = [0u8; 4];
libc::read(fd, first_buf.as_mut_ptr() as *mut libc::c_void, 4);
assert_eq!(&first_buf, b"dup ");
- let new_fd = libc::dup(fd);
let mut second_buf = [0u8; 4];
libc::read(new_fd, second_buf.as_mut_ptr() as *mut libc::c_void, 4);
assert_eq!(&second_buf, b"and ");
- let new_fd2 = libc::dup2(fd, 8);
let mut third_buf = [0u8; 4];
libc::read(new_fd2, third_buf.as_mut_ptr() as *mut libc::c_void, 4);
assert_eq!(&third_buf, b"dup2");
diff --git a/src/tools/miri/tests/pass/both_borrows/smallvec.rs b/src/tools/miri/tests/pass/both_borrows/smallvec.rs
new file mode 100644
index 0000000..f48815e
--- /dev/null
+++ b/src/tools/miri/tests/pass/both_borrows/smallvec.rs
@@ -0,0 +1,99 @@
+//! This test represents a core part of `SmallVec`'s `extend_impl`.
+//! What makes it interesting as a test is that it relies on Stacked Borrow's "quirk"
+//! in a fundamental, hard-to-fix-without-full-trees way.
+
+//@revisions: stack tree
+//@[tree]compile-flags: -Zmiri-tree-borrows
+
+use std::marker::PhantomData;
+use std::mem::{ManuallyDrop, MaybeUninit};
+use std::ptr::NonNull;
+
+#[repr(C)]
+pub union RawSmallVec<T, const N: usize> {
+ inline: ManuallyDrop<MaybeUninit<[T; N]>>,
+ heap: (NonNull<T>, usize),
+}
+
+impl<T, const N: usize> RawSmallVec<T, N> {
+ const fn new() -> Self {
+ Self::new_inline(MaybeUninit::uninit())
+ }
+
+ const fn new_inline(inline: MaybeUninit<[T; N]>) -> Self {
+ Self { inline: ManuallyDrop::new(inline) }
+ }
+
+ const fn as_mut_ptr_inline(&mut self) -> *mut T {
+ (unsafe { &raw mut self.inline }) as *mut T
+ }
+
+ const unsafe fn as_mut_ptr_heap(&mut self) -> *mut T {
+ self.heap.0.as_ptr()
+ }
+}
+
+#[repr(transparent)]
+#[derive(Clone, Copy)]
+struct TaggedLen(usize);
+
+impl TaggedLen {
+ pub const fn new(len: usize, on_heap: bool, is_zst: bool) -> Self {
+ if is_zst {
+ debug_assert!(!on_heap);
+ TaggedLen(len)
+ } else {
+ debug_assert!(len < isize::MAX as usize);
+ TaggedLen((len << 1) | on_heap as usize)
+ }
+ }
+
+ pub const fn on_heap(self, is_zst: bool) -> bool {
+ if is_zst { false } else { (self.0 & 1_usize) == 1 }
+ }
+
+ pub const fn value(self, is_zst: bool) -> usize {
+ if is_zst { self.0 } else { self.0 >> 1 }
+ }
+}
+
+#[repr(C)]
+pub struct SmallVec<T, const N: usize> {
+ len: TaggedLen,
+ raw: RawSmallVec<T, N>,
+ _marker: PhantomData<T>,
+}
+
+impl<T, const N: usize> SmallVec<T, N> {
+ pub const fn new() -> SmallVec<T, N> {
+ Self {
+ len: TaggedLen::new(0, false, Self::is_zst()),
+ raw: RawSmallVec::new(),
+ _marker: PhantomData,
+ }
+ }
+
+ const fn is_zst() -> bool {
+ size_of::<T>() == 0
+ }
+
+ pub const fn as_mut_ptr(&mut self) -> *mut T {
+ if self.len.on_heap(Self::is_zst()) {
+ // SAFETY: see above
+ unsafe { self.raw.as_mut_ptr_heap() }
+ } else {
+ self.raw.as_mut_ptr_inline()
+ }
+ }
+
+ pub const fn len(&self) -> usize {
+ self.len.value(Self::is_zst())
+ }
+}
+
+fn main() {
+ let mut v = SmallVec::<i32, 4>::new();
+ let ptr = v.as_mut_ptr();
+ let _len = v.len(); // this call incurs a reborrow which just barely does not invalidate `ptr`
+ unsafe { ptr.write(0) };
+}
diff --git a/src/tools/miri/tests/pass/float.rs b/src/tools/miri/tests/pass/float.rs
index 98a88cf..3835791 100644
--- a/src/tools/miri/tests/pass/float.rs
+++ b/src/tools/miri/tests/pass/float.rs
@@ -45,6 +45,30 @@ macro_rules! assert_approx_eq {
};
}
+/// From IEEE 754 a Signaling NaN for single precision has the following representation:
+/// ```
+/// s | 1111 1111 | 0x..x
+/// ````
+/// Were at least one `x` is a 1.
+///
+/// This sNaN has the following representation and is used for testing purposes.:
+/// ```
+/// 0 | 1111111 | 01..0
+/// ```
+const SNAN_F32: f32 = f32::from_bits(0x7fa00000);
+
+/// From IEEE 754 a Signaling NaN for double precision has the following representation:
+/// ```
+/// s | 1111 1111 111 | 0x..x
+/// ````
+/// Were at least one `x` is a 1.
+///
+/// This sNaN has the following representation and is used for testing purposes.:
+/// ```
+/// 0 | 1111 1111 111 | 01..0
+/// ```
+const SNAN_F64: f64 = f64::from_bits(0x7ff4000000000000);
+
fn main() {
basic();
casts();
@@ -1008,17 +1032,84 @@ fn ldexp(a: f64, b: i32) -> f64 {
assert_approx_eq!(25f32.powf(-2f32), 0.0016f32);
assert_approx_eq!(400f64.powf(0.5f64), 20f64);
+ // Some inputs to powf and powi result in fixed outputs
+ // and thus must be exactly equal to that value.
+ // C standard says:
+ // 1^y = 1 for any y, even a NaN.
+ assert_eq!(1f32.powf(10.0), 1.0);
+ assert_eq!(1f64.powf(100.0), 1.0);
+ assert_eq!(1f32.powf(f32::INFINITY), 1.0);
+ assert_eq!(1f64.powf(f64::INFINITY), 1.0);
+ assert_eq!(1f32.powf(f32::NAN), 1.0);
+ assert_eq!(1f64.powf(f64::NAN), 1.0);
+
+ // f*::NAN is a quiet NAN and should return 1 as well.
+ assert_eq!(f32::NAN.powf(0.0), 1.0);
+ assert_eq!(f64::NAN.powf(0.0), 1.0);
+
+ assert_eq!(42f32.powf(0.0), 1.0);
+ assert_eq!(42f64.powf(0.0), 1.0);
+ assert_eq!(f32::INFINITY.powf(0.0), 1.0);
+ assert_eq!(f64::INFINITY.powf(0.0), 1.0);
+
+ // f*::NAN is a quiet NAN and should return 1 as well.
+ assert_eq!(f32::NAN.powi(0), 1.0);
+ assert_eq!(f64::NAN.powi(0), 1.0);
+
+ assert_eq!(10.0f32.powi(0), 1.0);
+ assert_eq!(10.0f64.powi(0), 1.0);
+ assert_eq!(f32::INFINITY.powi(0), 1.0);
+ assert_eq!(f64::INFINITY.powi(0), 1.0);
+
+ assert_eq!((-1f32).powf(f32::INFINITY), 1.0);
+ assert_eq!((-1f64).powf(f64::INFINITY), 1.0);
+ assert_eq!((-1f32).powf(f32::NEG_INFINITY), 1.0);
+ assert_eq!((-1f64).powf(f64::NEG_INFINITY), 1.0);
+
+ // For pow (powf in rust) the C standard says:
+ // x^0 = 1 for all x even a sNaN
+ // FIXME(#4286): this does not match the behavior of all implementations.
+ assert_eq!(SNAN_F32.powf(0.0), 1.0);
+ assert_eq!(SNAN_F64.powf(0.0), 1.0);
+
+ // For pown (powi in rust) the C standard says:
+ // x^0 = 1 for all x even a sNaN
+ // FIXME(#4286): this does not match the behavior of all implementations.
+ assert_eq!(SNAN_F32.powi(0), 1.0);
+ assert_eq!(SNAN_F64.powi(0), 1.0);
+
+ assert_eq!(0f32.powi(10), 0.0);
+ assert_eq!(0f64.powi(100), 0.0);
+ assert_eq!(0f32.powi(9), 0.0);
+ assert_eq!(0f64.powi(99), 0.0);
+
+ assert_biteq((-0f32).powf(10.0), 0.0, "-0^x = +0 where x is positive");
+ assert_biteq((-0f64).powf(100.0), 0.0, "-0^x = +0 where x is positive");
+ assert_biteq((-0f32).powf(9.0), -0.0, "-0^x = -0 where x is negative");
+ assert_biteq((-0f64).powf(99.0), -0.0, "-0^x = -0 where x is negative");
+
+ assert_biteq((-0f32).powi(10), 0.0, "-0^x = +0 where x is positive");
+ assert_biteq((-0f64).powi(100), 0.0, "-0^x = +0 where x is positive");
+ assert_biteq((-0f32).powi(9), -0.0, "-0^x = -0 where x is negative");
+ assert_biteq((-0f64).powi(99), -0.0, "-0^x = -0 where x is negative");
+
assert_approx_eq!(1f32.exp(), f32::consts::E);
assert_approx_eq!(1f64.exp(), f64::consts::E);
+ assert_eq!(0f32.exp(), 1.0);
+ assert_eq!(0f64.exp(), 1.0);
assert_approx_eq!(1f32.exp_m1(), f32::consts::E - 1.0);
assert_approx_eq!(1f64.exp_m1(), f64::consts::E - 1.0);
assert_approx_eq!(10f32.exp2(), 1024f32);
assert_approx_eq!(50f64.exp2(), 1125899906842624f64);
+ assert_eq!(0f32.exp2(), 1.0);
+ assert_eq!(0f64.exp2(), 1.0);
assert_approx_eq!(f32::consts::E.ln(), 1f32);
- assert_approx_eq!(1f64.ln(), 0f64);
+ assert_approx_eq!(f64::consts::E.ln(), 1f64);
+ assert_eq!(1f32.ln(), 0.0);
+ assert_eq!(1f64.ln(), 0.0);
assert_approx_eq!(0f32.ln_1p(), 0f32);
assert_approx_eq!(0f64.ln_1p(), 0f64);
@@ -1047,7 +1138,8 @@ fn ldexp(a: f64, b: i32) -> f64 {
// Trigonometric functions.
- assert_approx_eq!(0f32.sin(), 0f32);
+ assert_eq!(0f32.sin(), 0f32);
+ assert_eq!(0f64.sin(), 0f64);
assert_approx_eq!((f64::consts::PI / 2f64).sin(), 1f64);
assert_approx_eq!(f32::consts::FRAC_PI_6.sin(), 0.5);
assert_approx_eq!(f64::consts::FRAC_PI_6.sin(), 0.5);
@@ -1059,7 +1151,23 @@ fn ldexp(a: f64, b: i32) -> f64 {
assert_approx_eq!(2.0f32.asinh(), 1.443635475178810342493276740273105f32);
assert_approx_eq!((-2.0f64).asinh(), -1.443635475178810342493276740273105f64);
- assert_approx_eq!(0f32.cos(), 1f32);
+ // Ensure `sin` always returns something that is a valid input for `asin`, and same for
+ // `cos` and `acos`.
+ let halve_pi_f32 = std::f32::consts::FRAC_PI_2;
+ let halve_pi_f64 = std::f64::consts::FRAC_PI_2;
+ let pi_f32 = std::f32::consts::PI;
+ let pi_f64 = std::f64::consts::PI;
+ for _ in 0..64 {
+ // sin() should be clamped to [-1, 1] so asin() can never return NaN
+ assert!(!halve_pi_f32.sin().asin().is_nan());
+ assert!(!halve_pi_f64.sin().asin().is_nan());
+ // cos() should be clamped to [-1, 1] so acos() can never return NaN
+ assert!(!pi_f32.cos().acos().is_nan());
+ assert!(!pi_f64.cos().acos().is_nan());
+ }
+
+ assert_eq!(0f32.cos(), 1f32);
+ assert_eq!(0f64.cos(), 1f64);
assert_approx_eq!((f64::consts::PI * 2f64).cos(), 1f64);
assert_approx_eq!(f32::consts::FRAC_PI_3.cos(), 0.5);
assert_approx_eq!(f64::consts::FRAC_PI_3.cos(), 0.5);
@@ -1278,7 +1386,6 @@ fn test_non_determinism() {
frem_algebraic, frem_fast, fsub_algebraic, fsub_fast,
};
use std::{f32, f64};
- // TODO: Also test powi and powf when the non-determinism is implemented for them
/// Ensure that the operation is non-deterministic
#[track_caller]
@@ -1318,21 +1425,23 @@ pub fn test_operations_f16(a: f16, b: f16) {
}
pub fn test_operations_f32(a: f32, b: f32) {
test_operations_f!(a, b);
- // FIXME: temporarily disabled as it breaks std tests.
- // ensure_nondet(|| a.log(b));
- // ensure_nondet(|| a.exp());
- // ensure_nondet(|| 10f32.exp2());
- // ensure_nondet(|| f32::consts::E.ln());
+ // FIXME: some are temporarily disabled as it breaks std tests.
+ ensure_nondet(|| a.powf(b));
+ ensure_nondet(|| a.powi(2));
+ ensure_nondet(|| a.log(b));
+ ensure_nondet(|| a.exp());
+ ensure_nondet(|| 10f32.exp2());
+ ensure_nondet(|| f32::consts::E.ln());
+ ensure_nondet(|| 10f32.log10());
+ ensure_nondet(|| 8f32.log2());
// ensure_nondet(|| 1f32.ln_1p());
- // ensure_nondet(|| 10f32.log10());
- // ensure_nondet(|| 8f32.log2());
// ensure_nondet(|| 27.0f32.cbrt());
// ensure_nondet(|| 3.0f32.hypot(4.0f32));
- // ensure_nondet(|| 1f32.sin());
- // ensure_nondet(|| 0f32.cos());
- // // On i686-pc-windows-msvc , these functions are implemented by calling the `f64` version,
- // // which means the little rounding errors Miri introduces are discard by the cast down to `f32`.
- // // Just skip the test for them.
+ ensure_nondet(|| 1f32.sin());
+ ensure_nondet(|| 1f32.cos());
+ // On i686-pc-windows-msvc , these functions are implemented by calling the `f64` version,
+ // which means the little rounding errors Miri introduces are discarded by the cast down to
+ // `f32`. Just skip the test for them.
// if !cfg!(all(target_os = "windows", target_env = "msvc", target_arch = "x86")) {
// ensure_nondet(|| 1.0f32.tan());
// ensure_nondet(|| 1.0f32.asin());
@@ -1353,18 +1462,20 @@ pub fn test_operations_f32(a: f32, b: f32) {
}
pub fn test_operations_f64(a: f64, b: f64) {
test_operations_f!(a, b);
- // FIXME: temporarily disabled as it breaks std tests.
- // ensure_nondet(|| a.log(b));
- // ensure_nondet(|| a.exp());
- // ensure_nondet(|| 50f64.exp2());
- // ensure_nondet(|| 3f64.ln());
+ // FIXME: some are temporarily disabled as it breaks std tests.
+ ensure_nondet(|| a.powf(b));
+ ensure_nondet(|| a.powi(2));
+ ensure_nondet(|| a.log(b));
+ ensure_nondet(|| a.exp());
+ ensure_nondet(|| 50f64.exp2());
+ ensure_nondet(|| 3f64.ln());
+ ensure_nondet(|| f64::consts::E.log10());
+ ensure_nondet(|| f64::consts::E.log2());
// ensure_nondet(|| 1f64.ln_1p());
- // ensure_nondet(|| f64::consts::E.log10());
- // ensure_nondet(|| f64::consts::E.log2());
// ensure_nondet(|| 27.0f64.cbrt());
// ensure_nondet(|| 3.0f64.hypot(4.0f64));
- // ensure_nondet(|| 1f64.sin());
- // ensure_nondet(|| 0f64.cos());
+ ensure_nondet(|| 1f64.sin());
+ ensure_nondet(|| 1f64.cos());
// ensure_nondet(|| 1.0f64.tan());
// ensure_nondet(|| 1.0f64.asin());
// ensure_nondet(|| 5.0f64.acos());
diff --git a/src/tools/miri/tests/pass/shims/fs.rs b/src/tools/miri/tests/pass/shims/fs.rs
index 87df43c..2f30827 100644
--- a/src/tools/miri/tests/pass/shims/fs.rs
+++ b/src/tools/miri/tests/pass/shims/fs.rs
@@ -2,12 +2,12 @@
#![feature(io_error_more)]
#![feature(io_error_uncategorized)]
+#![feature(file_lock)]
use std::collections::BTreeMap;
use std::ffi::OsString;
use std::fs::{
- File, OpenOptions, canonicalize, create_dir, read_dir, remove_dir, remove_dir_all, remove_file,
- rename,
+ self, File, OpenOptions, create_dir, read_dir, remove_dir, remove_dir_all, remove_file, rename,
};
use std::io::{Error, ErrorKind, IsTerminal, Read, Result, Seek, SeekFrom, Write};
use std::path::Path;
@@ -33,6 +33,8 @@ fn main() {
test_canonicalize();
#[cfg(unix)]
test_pread_pwrite();
+ #[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
+ test_flock();
}
}
@@ -240,7 +242,7 @@ fn test_canonicalize() {
let path = dir_path.join("test_file");
drop(File::create(&path).unwrap());
- let p = canonicalize(format!("{}/./test_file", dir_path.to_string_lossy())).unwrap();
+ let p = fs::canonicalize(format!("{}/./test_file", dir_path.to_string_lossy())).unwrap();
assert_eq!(p.to_string_lossy().find("/./"), None);
remove_dir_all(&dir_path).unwrap();
@@ -351,3 +353,28 @@ fn test_pread_pwrite() {
f.read_exact(&mut buf1).unwrap();
assert_eq!(&buf1, b" m");
}
+
+// This function does seem to exist on Illumos but std does not expose it there.
+#[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
+fn test_flock() {
+ let bytes = b"Hello, World!\n";
+ let path = utils::prepare_with_content("miri_test_fs_flock.txt", bytes);
+ let file1 = OpenOptions::new().read(true).write(true).open(&path).unwrap();
+ let file2 = OpenOptions::new().read(true).write(true).open(&path).unwrap();
+
+ // Test that we can apply many shared locks
+ file1.lock_shared().unwrap();
+ file2.lock_shared().unwrap();
+ // Test that shared lock prevents exclusive lock
+ assert!(matches!(file1.try_lock().unwrap_err(), fs::TryLockError::WouldBlock));
+ // Unlock shared lock
+ file1.unlock().unwrap();
+ file2.unlock().unwrap();
+ // Take exclusive lock
+ file1.lock().unwrap();
+ // Test that shared lock prevents exclusive and shared locks
+ assert!(matches!(file2.try_lock().unwrap_err(), fs::TryLockError::WouldBlock));
+ assert!(matches!(file2.try_lock_shared().unwrap_err(), fs::TryLockError::WouldBlock));
+ // Unlock exclusive lock
+ file1.unlock().unwrap();
+}
diff --git a/src/tools/miri/tests/pass/tree_borrows/cell-inside-struct.rs b/src/tools/miri/tests/pass/tree_borrows/cell-inside-struct.rs
new file mode 100644
index 0000000..fd68685
--- /dev/null
+++ b/src/tools/miri/tests/pass/tree_borrows/cell-inside-struct.rs
@@ -0,0 +1,34 @@
+//! The same as `tests/fail/tree-borrows/cell-inside-struct` but with
+//! precise tracking of interior mutability disabled.
+//@compile-flags: -Zmiri-tree-borrows -Zmiri-tree-borrows-no-precise-interior-mut
+#[path = "../../utils/mod.rs"]
+#[macro_use]
+mod utils;
+
+use std::cell::Cell;
+
+struct Foo {
+ field1: u32,
+ field2: Cell<u32>,
+}
+
+pub fn main() {
+ let root = Foo { field1: 42, field2: Cell::new(88) };
+ unsafe {
+ let a = &root;
+
+ name!(a as *const Foo, "a");
+
+ let a: *const Foo = a as *const Foo;
+ let a: *mut Foo = a as *mut Foo;
+
+ let alloc_id = alloc_id!(a);
+ print_state!(alloc_id);
+
+ // Writing to `field2`, which is interior mutable, should be allowed.
+ (*a).field2.set(10);
+
+ // Writing to `field1` should be allowed because it also has the `Cell` permission.
+ (*a).field1 = 88;
+ }
+}
diff --git a/src/tools/miri/tests/pass/tree_borrows/cell-inside-struct.stderr b/src/tools/miri/tests/pass/tree_borrows/cell-inside-struct.stderr
new file mode 100644
index 0000000..1d93932
--- /dev/null
+++ b/src/tools/miri/tests/pass/tree_borrows/cell-inside-struct.stderr
@@ -0,0 +1,6 @@
+──────────────────────────────────────────────────
+Warning: this tree is indicative only. Some tags may have been hidden.
+0.. 8
+| Act | └─┬──<TAG=root of the allocation>
+|?Cel | └────<TAG=a>
+──────────────────────────────────────────────────
diff --git a/src/tools/rust-analyzer/.github/workflows/autopublish.yaml b/src/tools/rust-analyzer/.github/workflows/autopublish.yaml
index d3f0499..6e2be7f 100644
--- a/src/tools/rust-analyzer/.github/workflows/autopublish.yaml
+++ b/src/tools/rust-analyzer/.github/workflows/autopublish.yaml
@@ -28,7 +28,7 @@
run: rustup update --no-self-update stable
- name: Install cargo-workspaces
- run: cargo install cargo-workspaces
+ run: cargo install cargo-workspaces --version "0.3.6"
- name: Publish Crates
env:
@@ -54,8 +54,8 @@
cargo workspaces rename --from project-model project_model
cargo workspaces rename --from test-fixture test_fixture
cargo workspaces rename --from test-utils test_utils
- # Remove library crates from the workspaces so we don't auto-publish them as well
- sed -i 's/ "lib\/\*",//' ./Cargo.toml
+ # Remove library crates and xtask from the workspaces so we don't auto-publish them as well
+ sed -i 's|^members = .*$|members = ["crates/*"]|' Cargo.toml
cargo workspaces rename ra_ap_%n
find crates/rust-analyzer -type f -name '*.rs' -exec sed -i 's/rust_analyzer/ra_ap_rust_analyzer/g' {} +
cargo workspaces publish --yes --force '*' --exact --no-git-commit --allow-dirty --skip-published custom 0.0.$(($RUN_NUMBER + 133))
diff --git a/src/tools/rust-analyzer/.github/workflows/publish-libs.yaml b/src/tools/rust-analyzer/.github/workflows/publish-libs.yaml
index 93ae567..f2c8b63 100644
--- a/src/tools/rust-analyzer/.github/workflows/publish-libs.yaml
+++ b/src/tools/rust-analyzer/.github/workflows/publish-libs.yaml
@@ -22,7 +22,7 @@
run: rustup update --no-self-update stable
- name: Install cargo-workspaces
- run: cargo install cargo-workspaces
+ run: cargo install cargo-workspaces --version "0.3.6"
- name: Publish Crates
env:
diff --git a/src/tools/rust-analyzer/Cargo.toml b/src/tools/rust-analyzer/Cargo.toml
index 8c50718..975fe27 100644
--- a/src/tools/rust-analyzer/Cargo.toml
+++ b/src/tools/rust-analyzer/Cargo.toml
@@ -21,6 +21,8 @@
text-size.opt-level = 3
serde.opt-level = 3
salsa.opt-level = 3
+dissimilar.opt-level = 3
+
# This speeds up `cargo xtask dist`.
miniz_oxide.opt-level = 3
diff --git a/src/tools/rust-analyzer/crates/hir-def/src/dyn_map.rs b/src/tools/rust-analyzer/crates/hir-def/src/dyn_map.rs
index eed1490..20018b6 100644
--- a/src/tools/rust-analyzer/crates/hir-def/src/dyn_map.rs
+++ b/src/tools/rust-analyzer/crates/hir-def/src/dyn_map.rs
@@ -67,8 +67,14 @@ pub mod keys {
pub const PROC_MACRO: Key<ast::Fn, ProcMacroId> = Key::new();
pub const MACRO_CALL: Key<ast::MacroCall, MacroCallId> = Key::new();
pub const ATTR_MACRO_CALL: Key<ast::Item, MacroCallId> = Key::new();
- pub const DERIVE_MACRO_CALL: Key<ast::Attr, (AttrId, MacroCallId, Box<[Option<MacroCallId>]>)> =
- Key::new();
+ pub const DERIVE_MACRO_CALL: Key<
+ ast::Attr,
+ (
+ AttrId,
+ /* derive() */ MacroCallId,
+ /* actual derive macros */ Box<[Option<MacroCallId>]>,
+ ),
+ > = Key::new();
/// XXX: AST Nodes and SyntaxNodes have identity equality semantics: nodes are
/// equal if they point to exactly the same object.
diff --git a/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe/regression.rs b/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe/regression.rs
index cb4fcd8..2cc3ca8 100644
--- a/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe/regression.rs
+++ b/src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe/regression.rs
@@ -931,11 +931,12 @@ pub fn new() {
// PATH_TYPE@23..26
// PATH@23..26
// PATH_SEGMENT@23..26
-// L_ANGLE@23..24 "<"
-// PAREN_TYPE@24..26
-// L_PAREN@24..25 "("
-// ERROR@25..26
-// INT_NUMBER@25..26 "8"
+// TYPE_ANCHOR@23..26
+// L_ANGLE@23..24 "<"
+// PAREN_TYPE@24..26
+// L_PAREN@24..25 "("
+// ERROR@25..26
+// INT_NUMBER@25..26 "8"
// PLUS@26..27 "+"
// CONST_ARG@27..28
// LITERAL@27..28
diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/db.rs b/src/tools/rust-analyzer/crates/hir-ty/src/db.rs
index 980ee26..1e985dc 100644
--- a/src/tools/rust-analyzer/crates/hir-ty/src/db.rs
+++ b/src/tools/rust-analyzer/crates/hir-ty/src/db.rs
@@ -31,6 +31,7 @@
#[query_group::query_group]
pub trait HirDatabase: DefDatabase + std::fmt::Debug {
#[salsa::invoke(crate::infer::infer_query)]
+ #[salsa::cycle(cycle_result = crate::infer::infer_cycle_result)]
fn infer(&self, def: DefWithBodyId) -> Arc<InferenceResult>;
// region:mir
@@ -132,6 +133,7 @@ fn layout_of_adt(
// FIXME: Make this a non-interned query.
#[salsa::invoke_interned(crate::lower::const_param_ty_with_diagnostics_query)]
+ #[salsa::cycle(cycle_result = crate::lower::const_param_ty_with_diagnostics_cycle_result)]
fn const_param_ty_with_diagnostics(&self, def: ConstParamId) -> (Ty, Diagnostics);
#[salsa::invoke(crate::lower::const_param_ty_query)]
diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs
index e698fb2..14eb716 100644
--- a/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs
+++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer.rs
@@ -35,7 +35,8 @@
use either::Either;
use hir_def::{
AdtId, AssocItemId, ConstId, DefWithBodyId, FieldId, FunctionId, GenericDefId, GenericParamId,
- ImplId, ItemContainerId, Lookup, TraitId, TupleFieldId, TupleId, TypeAliasId, VariantId,
+ ImplId, ItemContainerId, LocalFieldId, Lookup, TraitId, TupleFieldId, TupleId, TypeAliasId,
+ VariantId,
builtin_type::{BuiltinInt, BuiltinType, BuiltinUint},
expr_store::{Body, ExpressionStore, HygieneId, path::Path},
hir::{BindingAnnotation, BindingId, ExprId, ExprOrPatId, LabelId, PatId},
@@ -135,6 +136,10 @@ pub(crate) fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> Arc<Infer
Arc::new(ctx.resolve_all())
}
+pub(crate) fn infer_cycle_result(_: &dyn HirDatabase, _: DefWithBodyId) -> Arc<InferenceResult> {
+ Arc::new(InferenceResult { has_errors: true, ..Default::default() })
+}
+
/// Fully normalize all the types found within `ty` in context of `owner` body definition.
///
/// This is appropriate to use only after type-check: it assumes
@@ -203,7 +208,7 @@ pub enum InferenceTyDiagnosticSource {
pub enum InferenceDiagnostic {
NoSuchField {
field: ExprOrPatId,
- private: bool,
+ private: Option<LocalFieldId>,
variant: VariantId,
},
PrivateField {
@@ -558,6 +563,9 @@ pub fn type_of_expr_or_pat(&self, id: ExprOrPatId) -> Option<&Ty> {
ExprOrPatId::PatId(id) => self.type_of_pat.get(id),
}
}
+ pub fn is_erroneous(&self) -> bool {
+ self.has_errors && self.type_of_expr.iter().count() == 0
+ }
}
impl Index<ExprId> for InferenceResult {
diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs
index 87b7f34..6403127 100644
--- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs
+++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/expr.rs
@@ -554,7 +554,7 @@ fn infer_expr_inner(
self.push_diagnostic(
InferenceDiagnostic::NoSuchField {
field: field.expr.into(),
- private: true,
+ private: Some(local_id),
variant: def,
},
);
@@ -564,7 +564,7 @@ fn infer_expr_inner(
None => {
self.push_diagnostic(InferenceDiagnostic::NoSuchField {
field: field.expr.into(),
- private: false,
+ private: None,
variant: def,
});
None
diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/infer/pat.rs b/src/tools/rust-analyzer/crates/hir-ty/src/infer/pat.rs
index a9a3265..4bc3e16 100644
--- a/src/tools/rust-analyzer/crates/hir-ty/src/infer/pat.rs
+++ b/src/tools/rust-analyzer/crates/hir-ty/src/infer/pat.rs
@@ -143,7 +143,7 @@ pub(super) fn infer_record_pat_like(
{
self.push_diagnostic(InferenceDiagnostic::NoSuchField {
field: inner.into(),
- private: true,
+ private: Some(local_id),
variant: def,
});
}
@@ -157,7 +157,7 @@ pub(super) fn infer_record_pat_like(
None => {
self.push_diagnostic(InferenceDiagnostic::NoSuchField {
field: inner.into(),
- private: false,
+ private: None,
variant: def,
});
self.err_ty()
diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs b/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs
index ea8e7cc..0a54676 100644
--- a/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs
+++ b/src/tools/rust-analyzer/crates/hir-ty/src/lower.rs
@@ -1604,6 +1604,14 @@ pub(crate) fn impl_self_ty_with_diagnostics_query(
)
}
+pub(crate) fn impl_self_ty_with_diagnostics_cycle_result(
+ db: &dyn HirDatabase,
+ impl_id: ImplId,
+) -> (Binders<Ty>, Diagnostics) {
+ let generics = generics(db, impl_id.into());
+ (make_binders(db, &generics, TyKind::Error.intern(Interner)), None)
+}
+
pub(crate) fn const_param_ty_query(db: &dyn HirDatabase, def: ConstParamId) -> Ty {
db.const_param_ty_with_diagnostics(def).0
}
@@ -1633,12 +1641,12 @@ pub(crate) fn const_param_ty_with_diagnostics_query(
(ty, create_diagnostics(ctx.diagnostics))
}
-pub(crate) fn impl_self_ty_with_diagnostics_cycle_result(
- db: &dyn HirDatabase,
- impl_id: ImplId,
-) -> (Binders<Ty>, Diagnostics) {
- let generics = generics(db, impl_id.into());
- (make_binders(db, &generics, TyKind::Error.intern(Interner)), None)
+pub(crate) fn const_param_ty_with_diagnostics_cycle_result(
+ _: &dyn HirDatabase,
+ _: crate::db::HirDatabaseData,
+ _: ConstParamId,
+) -> (Ty, Diagnostics) {
+ (TyKind::Error.intern(Interner), None)
}
pub(crate) fn impl_trait_query(db: &dyn HirDatabase, impl_id: ImplId) -> Option<Binders<TraitRef>> {
diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs b/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs
index e6caf2d..99d9351 100644
--- a/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs
+++ b/src/tools/rust-analyzer/crates/hir-ty/src/mir/lower.rs
@@ -2182,7 +2182,7 @@ pub fn lower_to_mir(
// need to take this input explicitly.
root_expr: ExprId,
) -> Result<MirBody> {
- if infer.type_mismatches().next().is_some() {
+ if infer.type_mismatches().next().is_some() || infer.is_erroneous() {
return Err(MirLowerError::HasErrors);
}
let mut ctx = MirLowerCtx::new(db, owner, body, infer);
diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/tests/incremental.rs b/src/tools/rust-analyzer/crates/hir-ty/src/tests/incremental.rs
index 48474d2..e8e3812 100644
--- a/src/tools/rust-analyzer/crates/hir-ty/src/tests/incremental.rs
+++ b/src/tools/rust-analyzer/crates/hir-ty/src/tests/incremental.rs
@@ -106,3 +106,256 @@ fn baz() -> i32 {
assert_eq!(format!("{events:?}").matches("infer_shim").count(), 1, "{events:#?}")
}
}
+
+#[test]
+fn adding_struct_invalidates_infer() {
+ let (mut db, pos) = TestDB::with_position(
+ "
+//- /lib.rs
+fn foo() -> i32 {
+ 1 + 1
+}
+
+fn bar() -> f32 {
+ 2.0 * 3.0
+}
+$0",
+ );
+ {
+ let events = db.log_executed(|| {
+ let module = db.module_for_file(pos.file_id.file_id(&db));
+ let _crate_def_map = module.def_map(&db);
+ db.trait_impls_in_crate(module.krate());
+ });
+ assert!(format!("{events:?}").contains("trait_impls_in_crate_shim"))
+ }
+
+ let new_text = "
+fn foo() -> i32 {
+ 1 + 1
+}
+
+fn bar() -> f32 {
+ 2.0 * 3.0
+}
+
+pub struct NewStruct {
+ field: i32,
+}
+";
+
+ db.set_file_text(pos.file_id.file_id(&db), new_text);
+
+ {
+ let actual = db.log_executed(|| {
+ let module = db.module_for_file(pos.file_id.file_id(&db));
+ let _crate_def_map = module.def_map(&db);
+ db.trait_impls_in_crate(module.krate());
+ });
+
+ let expected = vec![
+ "parse_shim".to_owned(),
+ "ast_id_map_shim".to_owned(),
+ "file_item_tree_shim".to_owned(),
+ "real_span_map_shim".to_owned(),
+ "crate_local_def_map".to_owned(),
+ "trait_impls_in_crate_shim".to_owned(),
+ ];
+
+ assert_eq!(expected, actual);
+ }
+}
+
+#[test]
+fn adding_enum_query_log() {
+ let (mut db, pos) = TestDB::with_position(
+ "
+//- /lib.rs
+fn foo() -> i32 {
+ 1 + 1
+}
+
+fn bar() -> f32 {
+ 2.0 * 3.0
+}
+$0",
+ );
+ {
+ let events = db.log_executed(|| {
+ let module = db.module_for_file(pos.file_id.file_id(&db));
+ let _crate_def_map = module.def_map(&db);
+ db.trait_impls_in_crate(module.krate());
+ });
+ assert!(format!("{events:?}").contains("trait_impls_in_crate_shim"))
+ }
+
+ let new_text = "
+fn foo() -> i32 {
+ 1 + 1
+}
+
+fn bar() -> f32 {
+ 2.0 * 3.0
+}
+
+pub enum SomeEnum {
+ A,
+ B
+}
+";
+
+ db.set_file_text(pos.file_id.file_id(&db), new_text);
+
+ {
+ let actual = db.log_executed(|| {
+ let module = db.module_for_file(pos.file_id.file_id(&db));
+ let _crate_def_map = module.def_map(&db);
+ db.trait_impls_in_crate(module.krate());
+ });
+
+ let expected = vec![
+ "parse_shim".to_owned(),
+ "ast_id_map_shim".to_owned(),
+ "file_item_tree_shim".to_owned(),
+ "real_span_map_shim".to_owned(),
+ "crate_local_def_map".to_owned(),
+ "trait_impls_in_crate_shim".to_owned(),
+ ];
+
+ assert_eq!(expected, actual);
+ }
+}
+
+#[test]
+fn adding_use_query_log() {
+ let (mut db, pos) = TestDB::with_position(
+ "
+//- /lib.rs
+fn foo() -> i32 {
+ 1 + 1
+}
+
+fn bar() -> f32 {
+ 2.0 * 3.0
+}
+$0",
+ );
+ {
+ let events = db.log_executed(|| {
+ let module = db.module_for_file(pos.file_id.file_id(&db));
+ let _crate_def_map = module.def_map(&db);
+ db.trait_impls_in_crate(module.krate());
+ });
+ assert!(format!("{events:?}").contains("trait_impls_in_crate_shim"))
+ }
+
+ let new_text = "
+use std::collections::HashMap;
+
+fn foo() -> i32 {
+ 1 + 1
+}
+
+fn bar() -> f32 {
+ 2.0 * 3.0
+}
+";
+
+ db.set_file_text(pos.file_id.file_id(&db), new_text);
+
+ {
+ let actual = db.log_executed(|| {
+ let module = db.module_for_file(pos.file_id.file_id(&db));
+ let _crate_def_map = module.def_map(&db);
+ db.trait_impls_in_crate(module.krate());
+ });
+
+ let expected = vec![
+ "parse_shim".to_owned(),
+ "ast_id_map_shim".to_owned(),
+ "file_item_tree_shim".to_owned(),
+ "real_span_map_shim".to_owned(),
+ "crate_local_def_map".to_owned(),
+ "trait_impls_in_crate_shim".to_owned(),
+ ];
+
+ assert_eq!(expected, actual);
+ }
+}
+
+#[test]
+fn adding_impl_query_log() {
+ let (mut db, pos) = TestDB::with_position(
+ "
+//- /lib.rs
+fn foo() -> i32 {
+ 1 + 1
+}
+
+fn bar() -> f32 {
+ 2.0 * 3.0
+}
+
+pub struct SomeStruct {
+ field: i32,
+}
+$0",
+ );
+ {
+ let events = db.log_executed(|| {
+ let module = db.module_for_file(pos.file_id.file_id(&db));
+ let _crate_def_map = module.def_map(&db);
+ db.trait_impls_in_crate(module.krate());
+ });
+ assert!(format!("{events:?}").contains("trait_impls_in_crate_shim"))
+ }
+
+ let new_text = "
+fn foo() -> i32 {
+ 1 + 1
+}
+
+fn bar() -> f32 {
+ 2.0 * 3.0
+}
+
+pub struct SomeStruct {
+ field: i32,
+}
+
+impl SomeStruct {
+ pub fn new(value: i32) -> Self {
+ Self { field: value }
+ }
+}
+";
+
+ db.set_file_text(pos.file_id.file_id(&db), new_text);
+
+ {
+ let actual = db.log_executed(|| {
+ let module = db.module_for_file(pos.file_id.file_id(&db));
+ let _crate_def_map = module.def_map(&db);
+ db.trait_impls_in_crate(module.krate());
+ });
+
+ let expected = vec![
+ "parse_shim".to_owned(),
+ "ast_id_map_shim".to_owned(),
+ "file_item_tree_shim".to_owned(),
+ "real_span_map_shim".to_owned(),
+ "crate_local_def_map".to_owned(),
+ "trait_impls_in_crate_shim".to_owned(),
+ "attrs_shim".to_owned(),
+ "impl_trait_with_diagnostics_shim".to_owned(),
+ "impl_signature_shim".to_owned(),
+ "impl_signature_with_source_map_shim".to_owned(),
+ "impl_self_ty_with_diagnostics_shim".to_owned(),
+ "struct_signature_shim".to_owned(),
+ "struct_signature_with_source_map_shim".to_owned(),
+ "type_for_adt_tracked".to_owned(),
+ ];
+
+ assert_eq!(expected, actual);
+ }
+}
diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/tests/regression.rs b/src/tools/rust-analyzer/crates/hir-ty/src/tests/regression.rs
index 47c695c..ff8adee 100644
--- a/src/tools/rust-analyzer/crates/hir-ty/src/tests/regression.rs
+++ b/src/tools/rust-analyzer/crates/hir-ty/src/tests/regression.rs
@@ -2301,3 +2301,51 @@ fn foo<A, B>(bar: Self::Bar<A, B>) {
"#]],
);
}
+
+#[test]
+fn no_panic_on_recursive_const() {
+ check_infer(
+ r#"
+struct Foo<const N: usize> {}
+impl<const N: Foo<N>> Foo<N> {
+ fn foo(self) {}
+}
+
+fn test() {
+ let _ = N;
+}
+"#,
+ expect![[r#"
+ 72..76 'self': Foo<N>
+ 78..80 '{}': ()
+ 94..112 '{ ...= N; }': ()
+ 104..105 '_': {unknown}
+ 108..109 'N': {unknown}
+ "#]],
+ );
+
+ check_infer(
+ r#"
+struct Foo<const N: usize>;
+const N: Foo<N> = Foo;
+
+impl<const N: usize> Foo<N> {
+ fn foo(self) -> usize {
+ N
+ }
+}
+
+fn test() {
+ let _ = N;
+}
+"#,
+ expect![[r#"
+ 93..97 'self': Foo<N>
+ 108..125 '{ ... }': usize
+ 118..119 'N': usize
+ 139..157 '{ ...= N; }': ()
+ 149..150 '_': Foo<_>
+ 153..154 'N': Foo<_>
+ "#]],
+ );
+}
diff --git a/src/tools/rust-analyzer/crates/hir/src/diagnostics.rs b/src/tools/rust-analyzer/crates/hir/src/diagnostics.rs
index b6e3002..f7b140e 100644
--- a/src/tools/rust-analyzer/crates/hir/src/diagnostics.rs
+++ b/src/tools/rust-analyzer/crates/hir/src/diagnostics.rs
@@ -224,7 +224,7 @@ pub struct MalformedDerive {
#[derive(Debug)]
pub struct NoSuchField {
pub field: InFile<AstPtr<Either<ast::RecordExprField, ast::RecordPatField>>>,
- pub private: bool,
+ pub private: Option<Field>,
pub variant: VariantId,
}
@@ -648,6 +648,7 @@ pub(crate) fn inference_diagnostic(
}
ExprOrPatId::PatId(pat) => source_map.pat_field_syntax(pat),
};
+ let private = private.map(|id| Field { id, parent: variant.into() });
NoSuchField { field: expr_or_pat, private, variant }.into()
}
&InferenceDiagnostic::MismatchedArgCount { call_expr, expected, found } => {
diff --git a/src/tools/rust-analyzer/crates/hir/src/semantics.rs b/src/tools/rust-analyzer/crates/hir/src/semantics.rs
index e017746..4a2e8e3 100644
--- a/src/tools/rust-analyzer/crates/hir/src/semantics.rs
+++ b/src/tools/rust-analyzer/crates/hir/src/semantics.rs
@@ -222,6 +222,21 @@ pub fn find_nodes_at_offset_with_descend<'slf, N: AstNode + 'slf>(
self.imp.descend_node_at_offset(node, offset).filter_map(|mut it| it.find_map(N::cast))
}
+ // FIXME: Rethink this API
+ pub fn find_namelike_at_offset_with_descend<'slf>(
+ &'slf self,
+ node: &SyntaxNode,
+ offset: TextSize,
+ ) -> impl Iterator<Item = ast::NameLike> + 'slf {
+ node.token_at_offset(offset)
+ .map(move |token| self.descend_into_macros_no_opaque(token))
+ .map(|descendants| descendants.into_iter().filter_map(move |it| it.value.parent()))
+ // re-order the tokens from token_at_offset by returning the ancestors with the smaller first nodes first
+ // See algo::ancestors_at_offset, which uses the same approach
+ .kmerge_by(|left, right| left.text_range().len().lt(&right.text_range().len()))
+ .filter_map(ast::NameLike::cast)
+ }
+
pub fn resolve_range_pat(&self, range_pat: &ast::RangePat) -> Option<Struct> {
self.imp.resolve_range_pat(range_pat).map(Struct::from)
}
@@ -535,7 +550,7 @@ fn derive_macro_calls(&self, attr: &ast::Attr) -> Option<Vec<Option<MacroCallId>
}
pub fn is_derive_annotated(&self, adt: InFile<&ast::Adt>) -> bool {
- self.with_ctx(|ctx| ctx.has_derives(adt))
+ self.with_ctx(|ctx| ctx.file_of_adt_has_derives(adt))
}
pub fn derive_helpers_in_scope(&self, adt: &ast::Adt) -> Option<Vec<(Symbol, Symbol)>> {
@@ -644,7 +659,7 @@ pub fn speculative_expand_derive_as_pseudo_attr_macro(
/// Checks if renaming `renamed` to `new_name` may introduce conflicts with other locals,
/// and returns the conflicting locals.
- pub fn rename_conflicts(&self, to_be_renamed: &Local, new_name: &str) -> Vec<Local> {
+ pub fn rename_conflicts(&self, to_be_renamed: &Local, new_name: &Name) -> Vec<Local> {
let body = self.db.body(to_be_renamed.parent);
let resolver = to_be_renamed.parent.resolver(self.db);
let starting_expr =
@@ -653,7 +668,7 @@ pub fn rename_conflicts(&self, to_be_renamed: &Local, new_name: &str) -> Vec<Loc
body: &body,
conflicts: FxHashSet::default(),
db: self.db,
- new_name: Symbol::intern(new_name),
+ new_name: new_name.symbol().clone(),
old_name: to_be_renamed.name(self.db).symbol().clone(),
owner: to_be_renamed.parent,
to_be_renamed: to_be_renamed.binding_id,
@@ -877,8 +892,9 @@ pub fn descend_token_into_include_expansion(
if first == last {
// node is just the token, so descend the token
- self.descend_into_macros_impl(
+ self.descend_into_macros_all(
InFile::new(file.file_id, first),
+ false,
&mut |InFile { value, .. }, _ctx| {
if let Some(node) = value
.parent_ancestors()
@@ -887,20 +903,21 @@ pub fn descend_token_into_include_expansion(
{
res.push(node)
}
- CONTINUE_NO_BREAKS
},
);
} else {
// Descend first and last token, then zip them to look for the node they belong to
let mut scratch: SmallVec<[_; 1]> = smallvec![];
- self.descend_into_macros_impl(InFile::new(file.file_id, first), &mut |token, _ctx| {
- scratch.push(token);
- CONTINUE_NO_BREAKS
- });
+ self.descend_into_macros_all(
+ InFile::new(file.file_id, first),
+ false,
+ &mut |token, _ctx| scratch.push(token),
+ );
let mut scratch = scratch.into_iter();
- self.descend_into_macros_impl(
+ self.descend_into_macros_all(
InFile::new(file.file_id, last),
+ false,
&mut |InFile { value: last, file_id: last_fid }, _ctx| {
if let Some(InFile { value: first, file_id: first_fid }) = scratch.next() {
if first_fid == last_fid {
@@ -917,17 +934,18 @@ pub fn descend_token_into_include_expansion(
}
}
}
- CONTINUE_NO_BREAKS
},
);
}
res
}
- pub fn is_inside_macro_call(&self, token: InFile<&SyntaxToken>) -> bool {
- // FIXME: Maybe `ancestors_with_macros()` is more suitable here? Currently
- // this is only used on real (not macro) files so this is not a problem.
- token.value.parent_ancestors().any(|ancestor| {
+ /// Returns true if the given input is within a macro call.
+ ///
+ /// Note that if this token itself is within the context of a macro expansion does not matter.
+ /// That is, we strictly check if it lies inside the input of a macro call.
+ pub fn is_inside_macro_call(&self, token @ InFile { value, .. }: InFile<&SyntaxToken>) -> bool {
+ value.parent_ancestors().any(|ancestor| {
if ast::MacroCall::can_cast(ancestor.kind()) {
return true;
}
@@ -952,7 +970,7 @@ pub fn is_inside_macro_call(&self, token: InFile<&SyntaxToken>) -> bool {
ast::Item::Union(it) => it.into(),
_ => return false,
};
- ctx.has_derives(token.with_value(&adt))
+ ctx.file_of_adt_has_derives(token.with_value(&adt))
})
})
}
@@ -962,18 +980,18 @@ pub fn descend_into_macros_cb(
token: SyntaxToken,
mut cb: impl FnMut(InFile<SyntaxToken>, SyntaxContext),
) {
- self.descend_into_macros_impl(self.wrap_token_infile(token), &mut |t, ctx| {
- cb(t, ctx);
- CONTINUE_NO_BREAKS
+ self.descend_into_macros_all(self.wrap_token_infile(token), false, &mut |t, ctx| {
+ cb(t, ctx)
});
}
pub fn descend_into_macros(&self, token: SyntaxToken) -> SmallVec<[SyntaxToken; 1]> {
let mut res = smallvec![];
- self.descend_into_macros_impl(self.wrap_token_infile(token.clone()), &mut |t, _ctx| {
- res.push(t.value);
- CONTINUE_NO_BREAKS
- });
+ self.descend_into_macros_all(
+ self.wrap_token_infile(token.clone()),
+ false,
+ &mut |t, _ctx| res.push(t.value),
+ );
if res.is_empty() {
res.push(token);
}
@@ -986,12 +1004,11 @@ pub fn descend_into_macros_no_opaque(
) -> SmallVec<[InFile<SyntaxToken>; 1]> {
let mut res = smallvec![];
let token = self.wrap_token_infile(token);
- self.descend_into_macros_impl(token.clone(), &mut |t, ctx| {
+ self.descend_into_macros_all(token.clone(), true, &mut |t, ctx| {
if !ctx.is_opaque(self.db) {
// Don't descend into opaque contexts
res.push(t);
}
- CONTINUE_NO_BREAKS
});
if res.is_empty() {
res.push(token);
@@ -1004,7 +1021,7 @@ pub fn descend_into_macros_breakable<T>(
token: InFile<SyntaxToken>,
mut cb: impl FnMut(InFile<SyntaxToken>, SyntaxContext) -> ControlFlow<T>,
) -> Option<T> {
- self.descend_into_macros_impl(token, &mut cb)
+ self.descend_into_macros_impl(token, false, &mut cb)
}
/// Descends the token into expansions, returning the tokens that matches the input
@@ -1074,44 +1091,56 @@ pub fn descend_into_macros_single_exact(&self, token: SyntaxToken) -> SyntaxToke
.unwrap_or(token)
}
+ fn descend_into_macros_all(
+ &self,
+ token: InFile<SyntaxToken>,
+ always_descend_into_derives: bool,
+ f: &mut dyn FnMut(InFile<SyntaxToken>, SyntaxContext),
+ ) {
+ self.descend_into_macros_impl(token, always_descend_into_derives, &mut |tok, ctx| {
+ f(tok, ctx);
+ CONTINUE_NO_BREAKS
+ });
+ }
+
fn descend_into_macros_impl<T>(
&self,
InFile { value: token, file_id }: InFile<SyntaxToken>,
+ always_descend_into_derives: bool,
f: &mut dyn FnMut(InFile<SyntaxToken>, SyntaxContext) -> ControlFlow<T>,
) -> Option<T> {
let _p = tracing::info_span!("descend_into_macros_impl").entered();
- let span = self.db.span_map(file_id).span_for_range(token.text_range());
+ let db = self.db;
+ let span = db.span_map(file_id).span_for_range(token.text_range());
// Process the expansion of a call, pushing all tokens with our span in the expansion back onto our stack
- let process_expansion_for_token = |stack: &mut Vec<_>, macro_file| {
- let InMacroFile { file_id, value: mapped_tokens } = self.with_ctx(|ctx| {
- Some(
- ctx.cache
- .get_or_insert_expansion(ctx.db, macro_file)
- .map_range_down(span)?
- .map(SmallVec::<[_; 2]>::from_iter),
- )
- })?;
- // we have found a mapping for the token if the vec is non-empty
- let res = mapped_tokens.is_empty().not().then_some(());
- // requeue the tokens we got from mapping our current token down
- stack.push((HirFileId::from(file_id), mapped_tokens));
- res
- };
+ let process_expansion_for_token =
+ |ctx: &mut SourceToDefCtx<'_, '_>, stack: &mut Vec<_>, macro_file| {
+ let InMacroFile { file_id, value: mapped_tokens } = ctx
+ .cache
+ .get_or_insert_expansion(ctx.db, macro_file)
+ .map_range_down(span)?
+ .map(SmallVec::<[_; 2]>::from_iter);
+ // we have found a mapping for the token if the vec is non-empty
+ let res = mapped_tokens.is_empty().not().then_some(());
+ // requeue the tokens we got from mapping our current token down
+ stack.push((HirFileId::from(file_id), mapped_tokens));
+ res
+ };
// A stack of tokens to process, along with the file they came from
// These are tracked to know which macro calls we still have to look into
// the tokens themselves aren't that interesting as the span that is being used to map
// things down never changes.
let mut stack: Vec<(_, SmallVec<[_; 2]>)> = vec![];
- let include = file_id.file_id().and_then(|file_id| {
- self.s2d_cache.borrow_mut().get_or_insert_include_for(self.db, file_id)
- });
+ let include = file_id
+ .file_id()
+ .and_then(|file_id| self.s2d_cache.borrow_mut().get_or_insert_include_for(db, file_id));
match include {
Some(include) => {
// include! inputs are always from real files, so they only need to be handled once upfront
- process_expansion_for_token(&mut stack, include)?;
+ self.with_ctx(|ctx| process_expansion_for_token(ctx, &mut stack, include))?;
}
None => {
stack.push((file_id, smallvec![(token, span.ctx)]));
@@ -1133,62 +1162,120 @@ fn descend_into_macros_impl<T>(
tokens.reverse();
while let Some((token, ctx)) = tokens.pop() {
let was_not_remapped = (|| {
- // First expand into attribute invocations
- let containing_attribute_macro_call = self.with_ctx(|ctx| {
- token.parent_ancestors().filter_map(ast::Item::cast).find_map(|item| {
- // Don't force populate the dyn cache for items that don't have an attribute anyways
- item.attrs().next()?;
- Some((ctx.item_to_macro_call(InFile::new(expansion, &item))?, item))
- })
- });
- if let Some((call_id, item)) = containing_attribute_macro_call {
- let attr_id = match self.db.lookup_intern_macro_call(call_id).kind {
- hir_expand::MacroCallKind::Attr { invoc_attr_index, .. } => {
- invoc_attr_index.ast_index()
- }
- _ => 0,
- };
- // FIXME: here, the attribute's text range is used to strip away all
- // entries from the start of the attribute "list" up the invoking
- // attribute. But in
- // ```
- // mod foo {
- // #![inner]
- // }
- // ```
- // we don't wanna strip away stuff in the `mod foo {` range, that is
- // here if the id corresponds to an inner attribute we got strip all
- // text ranges of the outer ones, and then all of the inner ones up
- // to the invoking attribute so that the inbetween is ignored.
- let text_range = item.syntax().text_range();
- let start = collect_attrs(&item)
- .nth(attr_id)
- .map(|attr| match attr.1 {
- Either::Left(it) => it.syntax().text_range().start(),
- Either::Right(it) => it.syntax().text_range().start(),
+ // First expand into attribute invocations, this is required to be handled
+ // upfront as any other macro call within will not semantically resolve unless
+ // also descended.
+ let res = self.with_ctx(|ctx| {
+ token
+ .parent_ancestors()
+ .filter_map(ast::Item::cast)
+ // FIXME: This might work incorrectly when we have a derive, followed by
+ // an attribute on an item, like:
+ // ```
+ // #[derive(Debug$0)]
+ // #[my_attr]
+ // struct MyStruct;
+ // ```
+ // here we should not consider the attribute at all, as our cursor
+ // technically lies outside of its expansion
+ .find_map(|item| {
+ // Don't force populate the dyn cache for items that don't have an attribute anyways
+ item.attrs().next()?;
+ ctx.item_to_macro_call(InFile::new(expansion, &item))
+ .zip(Some(item))
})
- .unwrap_or_else(|| text_range.start());
- let text_range = TextRange::new(start, text_range.end());
- filter_duplicates(tokens, text_range);
- return process_expansion_for_token(&mut stack, call_id);
+ .map(|(call_id, item)| {
+ let attr_id = match db.lookup_intern_macro_call(call_id).kind {
+ hir_expand::MacroCallKind::Attr {
+ invoc_attr_index, ..
+ } => invoc_attr_index.ast_index(),
+ _ => 0,
+ };
+ // FIXME: here, the attribute's text range is used to strip away all
+ // entries from the start of the attribute "list" up the invoking
+ // attribute. But in
+ // ```
+ // mod foo {
+ // #![inner]
+ // }
+ // ```
+ // we don't wanna strip away stuff in the `mod foo {` range, that is
+ // here if the id corresponds to an inner attribute we got strip all
+ // text ranges of the outer ones, and then all of the inner ones up
+ // to the invoking attribute so that the inbetween is ignored.
+ let text_range = item.syntax().text_range();
+ let start = collect_attrs(&item)
+ .nth(attr_id)
+ .map(|attr| match attr.1 {
+ Either::Left(it) => it.syntax().text_range().start(),
+ Either::Right(it) => it.syntax().text_range().start(),
+ })
+ .unwrap_or_else(|| text_range.start());
+ let text_range = TextRange::new(start, text_range.end());
+ filter_duplicates(tokens, text_range);
+ process_expansion_for_token(ctx, &mut stack, call_id)
+ })
+ });
+
+ if let Some(res) = res {
+ return res;
}
+ if always_descend_into_derives {
+ let res = self.with_ctx(|ctx| {
+ let (derives, adt) = token
+ .parent_ancestors()
+ .filter_map(ast::Adt::cast)
+ .find_map(|adt| {
+ Some((
+ ctx.derive_macro_calls(InFile::new(expansion, &adt))?
+ .map(|(a, b, c)| (a, b, c.to_owned()))
+ .collect::<SmallVec<[_; 2]>>(),
+ adt,
+ ))
+ })?;
+ let mut res = None;
+ for (_, derive_attr, derives) in derives {
+ // as there may be multiple derives registering the same helper
+ // name, we gotta make sure to call this for all of them!
+ // FIXME: We need to call `f` for all of them as well though!
+ res = res.or(process_expansion_for_token(
+ ctx,
+ &mut stack,
+ derive_attr,
+ ));
+ for derive in derives.into_iter().flatten() {
+ res = res
+ .or(process_expansion_for_token(ctx, &mut stack, derive));
+ }
+ }
+ // remove all tokens that are within the derives expansion
+ filter_duplicates(tokens, adt.syntax().text_range());
+ Some(res)
+ });
+ // if we found derives, we can early exit. There is no way we can be in any
+ // macro call at this point given we are not in a token tree
+ if let Some(res) = res {
+ return res;
+ }
+ }
// Then check for token trees, that means we are either in a function-like macro or
// secondary attribute inputs
let tt = token
.parent_ancestors()
.map_while(Either::<ast::TokenTree, ast::Meta>::cast)
.last()?;
+
match tt {
// function-like macro call
Either::Left(tt) => {
+ let macro_call = tt.syntax().parent().and_then(ast::MacroCall::cast)?;
if tt.left_delimiter_token().map_or(false, |it| it == token) {
return None;
}
if tt.right_delimiter_token().map_or(false, |it| it == token) {
return None;
}
- let macro_call = tt.syntax().parent().and_then(ast::MacroCall::cast)?;
let mcall = InFile::new(expansion, macro_call);
let file_id = match m_cache.get(&mcall) {
Some(&it) => it,
@@ -1201,13 +1288,16 @@ fn descend_into_macros_impl<T>(
let text_range = tt.syntax().text_range();
filter_duplicates(tokens, text_range);
- process_expansion_for_token(&mut stack, file_id).or(file_id
- .eager_arg(self.db)
- .and_then(|arg| {
- // also descend into eager expansions
- process_expansion_for_token(&mut stack, arg)
- }))
+ self.with_ctx(|ctx| {
+ process_expansion_for_token(ctx, &mut stack, file_id).or(file_id
+ .eager_arg(db)
+ .and_then(|arg| {
+ // also descend into eager expansions
+ process_expansion_for_token(ctx, &mut stack, arg)
+ }))
+ })
}
+ Either::Right(_) if always_descend_into_derives => None,
// derive or derive helper
Either::Right(meta) => {
// attribute we failed expansion for earlier, this might be a derive invocation
@@ -1216,31 +1306,33 @@ fn descend_into_macros_impl<T>(
let adt = match attr.syntax().parent().and_then(ast::Adt::cast) {
Some(adt) => {
// this might be a derive on an ADT
- let derive_call = self.with_ctx(|ctx| {
+ let res = self.with_ctx(|ctx| {
// so try downmapping the token into the pseudo derive expansion
// see [hir_expand::builtin_attr_macro] for how the pseudo derive expansion works
- ctx.attr_to_derive_macro_call(
- InFile::new(expansion, &adt),
- InFile::new(expansion, attr.clone()),
- )
- .map(|(_, call_id, _)| call_id)
- });
+ let derive_call = ctx
+ .attr_to_derive_macro_call(
+ InFile::new(expansion, &adt),
+ InFile::new(expansion, attr.clone()),
+ )?
+ .1;
- match derive_call {
- Some(call_id) => {
- // resolved to a derive
- let text_range = attr.syntax().text_range();
- // remove any other token in this macro input, all their mappings are the
- // same as this
- tokens.retain(|(t, _)| {
- !text_range.contains_range(t.text_range())
- });
- return process_expansion_for_token(
- &mut stack, call_id,
- );
- }
- None => Some(adt),
+ // resolved to a derive
+ let text_range = attr.syntax().text_range();
+ // remove any other token in this macro input, all their mappings are the
+ // same as this
+ tokens.retain(|(t, _)| {
+ !text_range.contains_range(t.text_range())
+ });
+ Some(process_expansion_for_token(
+ ctx,
+ &mut stack,
+ derive_call,
+ ))
+ });
+ if let Some(res) = res {
+ return res;
}
+ Some(adt)
}
None => {
// Otherwise this could be a derive helper on a variant or field
@@ -1254,12 +1346,9 @@ fn descend_into_macros_impl<T>(
)
}
}?;
- if !self.with_ctx(|ctx| ctx.has_derives(InFile::new(expansion, &adt))) {
- return None;
- }
let attr_name =
attr.path().and_then(|it| it.as_single_name_ref())?.as_name();
- // Not an attribute, nor a derive, so it's either an intert attribute or a derive helper
+ // Not an attribute, nor a derive, so it's either an inert attribute or a derive helper
// Try to resolve to a derive helper and downmap
let resolver = &token
.parent()
@@ -1267,7 +1356,7 @@ fn descend_into_macros_impl<T>(
self.analyze_impl(InFile::new(expansion, &parent), None, false)
})?
.resolver;
- let id = self.db.ast_id_map(expansion).ast_id(&adt);
+ let id = db.ast_id_map(expansion).ast_id(&adt);
let helpers = resolver
.def_map()
.derive_helpers_in_scope(InFile::new(expansion, id))?;
@@ -1278,20 +1367,22 @@ fn descend_into_macros_impl<T>(
}
let mut res = None;
- for (.., derive) in
- helpers.iter().filter(|(helper, ..)| *helper == attr_name)
- {
- // as there may be multiple derives registering the same helper
- // name, we gotta make sure to call this for all of them!
- // FIXME: We need to call `f` for all of them as well though!
- res = res.or(process_expansion_for_token(&mut stack, *derive));
- }
- res
+ self.with_ctx(|ctx| {
+ for (.., derive) in
+ helpers.iter().filter(|(helper, ..)| *helper == attr_name)
+ {
+ // as there may be multiple derives registering the same helper
+ // name, we gotta make sure to call this for all of them!
+ // FIXME: We need to call `f` for all of them as well though!
+ res = res
+ .or(process_expansion_for_token(ctx, &mut stack, *derive));
+ }
+ res
+ })
}
}
})()
.is_none();
-
if was_not_remapped {
if let ControlFlow::Break(b) = f(InFile::new(expansion, token), ctx) {
return Some(b);
@@ -1380,25 +1471,31 @@ fn token_ancestors_with_macros(
}
/// Iterates the ancestors of the given node, climbing up macro expansions while doing so.
+ // FIXME: Replace with `ancestors_with_macros_file` when all usages are updated.
pub fn ancestors_with_macros(
&self,
node: SyntaxNode,
) -> impl Iterator<Item = SyntaxNode> + Clone + '_ {
let node = self.find_file(&node);
- iter::successors(Some(node.cloned()), move |&InFile { file_id, ref value }| {
- match value.parent() {
- Some(parent) => Some(InFile::new(file_id, parent)),
- None => {
- let macro_file = file_id.macro_file()?;
+ self.ancestors_with_macros_file(node.cloned()).map(|it| it.value)
+ }
- self.with_ctx(|ctx| {
- let expansion_info = ctx.cache.get_or_insert_expansion(ctx.db, macro_file);
- expansion_info.arg().map(|node| node?.parent()).transpose()
- })
- }
+ /// Iterates the ancestors of the given node, climbing up macro expansions while doing so.
+ pub fn ancestors_with_macros_file(
+ &self,
+ node: InFile<SyntaxNode>,
+ ) -> impl Iterator<Item = InFile<SyntaxNode>> + Clone + '_ {
+ iter::successors(Some(node), move |&InFile { file_id, ref value }| match value.parent() {
+ Some(parent) => Some(InFile::new(file_id, parent)),
+ None => {
+ let macro_file = file_id.macro_file()?;
+
+ self.with_ctx(|ctx| {
+ let expansion_info = ctx.cache.get_or_insert_expansion(ctx.db, macro_file);
+ expansion_info.arg().map(|node| node?.parent()).transpose()
+ })
}
})
- .map(|it| it.value)
}
pub fn ancestors_at_offset_with_macros(
@@ -1851,18 +1948,12 @@ fn analyze_impl(
ChildContainer::TraitId(it) => {
return Some(SourceAnalyzer::new_generic_def(self.db, it.into(), node, offset));
}
- ChildContainer::TraitAliasId(it) => {
- return Some(SourceAnalyzer::new_generic_def(self.db, it.into(), node, offset));
- }
ChildContainer::ImplId(it) => {
return Some(SourceAnalyzer::new_generic_def(self.db, it.into(), node, offset));
}
ChildContainer::EnumId(it) => {
return Some(SourceAnalyzer::new_generic_def(self.db, it.into(), node, offset));
}
- ChildContainer::TypeAliasId(it) => {
- return Some(SourceAnalyzer::new_generic_def(self.db, it.into(), node, offset));
- }
ChildContainer::GenericDefId(it) => {
return Some(SourceAnalyzer::new_generic_def(self.db, it, node, offset));
}
diff --git a/src/tools/rust-analyzer/crates/hir/src/semantics/child_by_source.rs b/src/tools/rust-analyzer/crates/hir/src/semantics/child_by_source.rs
index 6accf9b..1a6d63c 100644
--- a/src/tools/rust-analyzer/crates/hir/src/semantics/child_by_source.rs
+++ b/src/tools/rust-analyzer/crates/hir/src/semantics/child_by_source.rs
@@ -17,6 +17,7 @@
DynMap,
keys::{self, Key},
},
+ hir::generics::GenericParams,
item_scope::ItemScope,
item_tree::ItemTreeNode,
nameres::DefMap,
@@ -49,6 +50,12 @@ fn child_by_source_to(&self, db: &dyn DefDatabase, res: &mut DynMap, file_id: Hi
data.items.iter().for_each(|&(_, item)| {
add_assoc_item(db, res, file_id, item);
});
+ let (_, source_map) = db.trait_signature_with_source_map(*self);
+ source_map.expansions().filter(|(ast, _)| ast.file_id == file_id).for_each(
+ |(ast, &exp_id)| {
+ res[keys::MACRO_CALL].insert(ast.value, exp_id);
+ },
+ );
}
}
@@ -68,6 +75,12 @@ fn child_by_source_to(&self, db: &dyn DefDatabase, res: &mut DynMap, file_id: Hi
data.items.iter().for_each(|&(_, item)| {
add_assoc_item(db, res, file_id, item);
});
+ let (_, source_map) = db.impl_signature_with_source_map(*self);
+ source_map.expansions().filter(|(ast, _)| ast.file_id == file_id).for_each(
+ |(ast, &exp_id)| {
+ res[keys::MACRO_CALL].insert(ast.value, exp_id);
+ },
+ );
}
}
@@ -178,6 +191,8 @@ fn child_by_source_to(&self, db: &dyn DefDatabase, res: &mut DynMap, _: HirFileI
Either::Right(source) => res[keys::RECORD_FIELD].insert(AstPtr::new(&source), id),
}
}
+ let (_, sm) = db.variant_fields_with_source_map(*self);
+ sm.expansions().for_each(|(ast, &exp_id)| res[keys::MACRO_CALL].insert(ast.value, exp_id));
}
}
@@ -195,6 +210,11 @@ fn child_by_source_to(&self, db: &dyn DefDatabase, res: &mut DynMap, file_id: Hi
res[keys::ENUM_VARIANT]
.insert(ast_id_map.get(tree[variant.lookup(db).id.value].ast_id), variant);
});
+ let (_, source_map) = db.enum_signature_with_source_map(*self);
+ source_map
+ .expansions()
+ .filter(|(ast, _)| ast.file_id == file_id)
+ .for_each(|(ast, &exp_id)| res[keys::MACRO_CALL].insert(ast.value, exp_id));
}
}
@@ -225,7 +245,8 @@ fn child_by_source_to(&self, db: &dyn DefDatabase, res: &mut DynMap, file_id: Hi
return;
}
- let generic_params = db.generic_params(*self);
+ let (generic_params, _, source_map) =
+ GenericParams::generic_params_and_store_and_source_map(db, *self);
let mut toc_idx_iter = generic_params.iter_type_or_consts().map(|(idx, _)| idx);
let lts_idx_iter = generic_params.iter_lt().map(|(idx, _)| idx);
@@ -253,6 +274,11 @@ fn child_by_source_to(&self, db: &dyn DefDatabase, res: &mut DynMap, file_id: Hi
res[keys::LIFETIME_PARAM].insert(AstPtr::new(&ast_param), id);
}
}
+
+ source_map
+ .expansions()
+ .filter(|(ast, _)| ast.file_id == file_id)
+ .for_each(|(ast, &exp_id)| res[keys::MACRO_CALL].insert(ast.value, exp_id));
}
}
diff --git a/src/tools/rust-analyzer/crates/hir/src/semantics/source_to_def.rs b/src/tools/rust-analyzer/crates/hir/src/semantics/source_to_def.rs
index 7f6c9af..71ee0f6 100644
--- a/src/tools/rust-analyzer/crates/hir/src/semantics/source_to_def.rs
+++ b/src/tools/rust-analyzer/crates/hir/src/semantics/source_to_def.rs
@@ -108,7 +108,7 @@
use stdx::impl_from;
use syntax::{
AstNode, AstPtr, SyntaxNode,
- ast::{self, HasName},
+ ast::{self, HasAttrs, HasName},
};
use tt::TextRange;
@@ -411,10 +411,25 @@ pub(super) fn attr_to_derive_macro_call(
.map(|&(attr_id, call_id, ref ids)| (attr_id, call_id, &**ids))
}
- pub(super) fn has_derives(&mut self, adt: InFile<&ast::Adt>) -> bool {
+ // FIXME: Make this more fine grained! This should be a `adt_has_derives`!
+ pub(super) fn file_of_adt_has_derives(&mut self, adt: InFile<&ast::Adt>) -> bool {
self.dyn_map(adt).as_ref().is_some_and(|map| !map[keys::DERIVE_MACRO_CALL].is_empty())
}
+ pub(super) fn derive_macro_calls<'slf>(
+ &'slf mut self,
+ adt: InFile<&ast::Adt>,
+ ) -> Option<impl Iterator<Item = (AttrId, MacroCallId, &'slf [Option<MacroCallId>])> + use<'slf>>
+ {
+ self.dyn_map(adt).as_ref().map(|&map| {
+ let dyn_map = &map[keys::DERIVE_MACRO_CALL];
+ adt.value
+ .attrs()
+ .filter_map(move |attr| dyn_map.get(&AstPtr::new(&attr)))
+ .map(|&(attr_id, call_id, ref ids)| (attr_id, call_id, &**ids))
+ })
+ }
+
fn to_def<Ast: AstNode + 'static, ID: Copy + 'static>(
&mut self,
src: InFile<&Ast>,
@@ -616,14 +631,14 @@ fn container_to_def(
match &item {
ast::Item::Module(it) => self.module_to_def(container.with_value(it))?.into(),
ast::Item::Trait(it) => self.trait_to_def(container.with_value(it))?.into(),
- ast::Item::TraitAlias(it) => {
- self.trait_alias_to_def(container.with_value(it))?.into()
- }
ast::Item::Impl(it) => self.impl_to_def(container.with_value(it))?.into(),
ast::Item::Enum(it) => self.enum_to_def(container.with_value(it))?.into(),
- ast::Item::TypeAlias(it) => {
- self.type_alias_to_def(container.with_value(it))?.into()
- }
+ ast::Item::TypeAlias(it) => ChildContainer::GenericDefId(
+ self.type_alias_to_def(container.with_value(it))?.into(),
+ ),
+ ast::Item::TraitAlias(it) => ChildContainer::GenericDefId(
+ self.trait_alias_to_def(container.with_value(it))?.into(),
+ ),
ast::Item::Struct(it) => {
let def = self.struct_to_def(container.with_value(it))?;
let is_in_body = it.field_list().is_some_and(|it| {
@@ -723,11 +738,9 @@ pub(crate) enum ChildContainer {
DefWithBodyId(DefWithBodyId),
ModuleId(ModuleId),
TraitId(TraitId),
- TraitAliasId(TraitAliasId),
ImplId(ImplId),
EnumId(EnumId),
VariantId(VariantId),
- TypeAliasId(TypeAliasId),
/// XXX: this might be the same def as, for example an `EnumId`. However,
/// here the children are generic parameters, and not, eg enum variants.
GenericDefId(GenericDefId),
@@ -736,11 +749,9 @@ pub(crate) enum ChildContainer {
DefWithBodyId,
ModuleId,
TraitId,
- TraitAliasId,
ImplId,
EnumId,
VariantId,
- TypeAliasId,
GenericDefId
for ChildContainer
}
@@ -752,11 +763,9 @@ fn child_by_source(self, db: &dyn HirDatabase, file_id: HirFileId) -> DynMap {
ChildContainer::DefWithBodyId(it) => it.child_by_source(db, file_id),
ChildContainer::ModuleId(it) => it.child_by_source(db, file_id),
ChildContainer::TraitId(it) => it.child_by_source(db, file_id),
- ChildContainer::TraitAliasId(_) => DynMap::default(),
ChildContainer::ImplId(it) => it.child_by_source(db, file_id),
ChildContainer::EnumId(it) => it.child_by_source(db, file_id),
ChildContainer::VariantId(it) => it.child_by_source(db, file_id),
- ChildContainer::TypeAliasId(_) => DynMap::default(),
ChildContainer::GenericDefId(it) => it.child_by_source(db, file_id),
}
}
diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_named_struct_to_tuple_struct.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_named_struct_to_tuple_struct.rs
index 5d75e44..32c4ae2 100644
--- a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_named_struct_to_tuple_struct.rs
+++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_named_struct_to_tuple_struct.rs
@@ -56,14 +56,22 @@ pub(crate) fn convert_named_struct_to_tuple_struct(
// XXX: We don't currently provide this assist for struct definitions inside macros, but if we
// are to lift this limitation, don't forget to make `edit_struct_def()` consider macro files
// too.
- let name = ctx.find_node_at_offset::<ast::Name>()?;
- let strukt = name.syntax().parent().and_then(<Either<ast::Struct, ast::Variant>>::cast)?;
- let field_list = strukt.as_ref().either(|s| s.field_list(), |v| v.field_list())?;
+ let strukt_or_variant = ctx
+ .find_node_at_offset::<ast::Struct>()
+ .map(Either::Left)
+ .or_else(|| ctx.find_node_at_offset::<ast::Variant>().map(Either::Right))?;
+ let field_list = strukt_or_variant.as_ref().either(|s| s.field_list(), |v| v.field_list())?;
+
+ if ctx.offset() > field_list.syntax().text_range().start() {
+ // Assist could be distracting after the braces
+ return None;
+ }
+
let record_fields = match field_list {
ast::FieldList::RecordFieldList(it) => it,
ast::FieldList::TupleFieldList(_) => return None,
};
- let strukt_def = match &strukt {
+ let strukt_def = match &strukt_or_variant {
Either::Left(s) => Either::Left(ctx.sema.to_def(s)?),
Either::Right(v) => Either::Right(ctx.sema.to_def(v)?),
};
@@ -71,11 +79,11 @@ pub(crate) fn convert_named_struct_to_tuple_struct(
acc.add(
AssistId::refactor_rewrite("convert_named_struct_to_tuple_struct"),
"Convert to tuple struct",
- strukt.syntax().text_range(),
+ strukt_or_variant.syntax().text_range(),
|edit| {
edit_field_references(ctx, edit, record_fields.fields());
edit_struct_references(ctx, edit, strukt_def);
- edit_struct_def(ctx, edit, &strukt, record_fields);
+ edit_struct_def(ctx, edit, &strukt_or_variant, record_fields);
},
)
}
@@ -294,6 +302,88 @@ fn into_inner(self) -> Inner {
}
#[test]
+ fn convert_simple_struct_cursor_on_struct_keyword() {
+ check_assist(
+ convert_named_struct_to_tuple_struct,
+ r#"
+struct Inner;
+struct$0 A { inner: Inner }
+
+impl A {
+ fn new(inner: Inner) -> A {
+ A { inner }
+ }
+
+ fn new_with_default() -> A {
+ A::new(Inner)
+ }
+
+ fn into_inner(self) -> Inner {
+ self.inner
+ }
+}"#,
+ r#"
+struct Inner;
+struct A(Inner);
+
+impl A {
+ fn new(inner: Inner) -> A {
+ A(inner)
+ }
+
+ fn new_with_default() -> A {
+ A::new(Inner)
+ }
+
+ fn into_inner(self) -> Inner {
+ self.0
+ }
+}"#,
+ );
+ }
+
+ #[test]
+ fn convert_simple_struct_cursor_on_visibility_keyword() {
+ check_assist(
+ convert_named_struct_to_tuple_struct,
+ r#"
+struct Inner;
+pub$0 struct A { inner: Inner }
+
+impl A {
+ fn new(inner: Inner) -> A {
+ A { inner }
+ }
+
+ fn new_with_default() -> A {
+ A::new(Inner)
+ }
+
+ fn into_inner(self) -> Inner {
+ self.inner
+ }
+}"#,
+ r#"
+struct Inner;
+pub struct A(Inner);
+
+impl A {
+ fn new(inner: Inner) -> A {
+ A(inner)
+ }
+
+ fn new_with_default() -> A {
+ A::new(Inner)
+ }
+
+ fn into_inner(self) -> Inner {
+ self.0
+ }
+}"#,
+ );
+ }
+
+ #[test]
fn convert_struct_referenced_via_self_kw() {
check_assist(
convert_named_struct_to_tuple_struct,
diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_tuple_struct_to_named_struct.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_tuple_struct_to_named_struct.rs
index 0c0b93b..8075619 100644
--- a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_tuple_struct_to_named_struct.rs
+++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_tuple_struct_to_named_struct.rs
@@ -51,18 +51,26 @@ pub(crate) fn convert_tuple_struct_to_named_struct(
acc: &mut Assists,
ctx: &AssistContext<'_>,
) -> Option<()> {
- let name = ctx.find_node_at_offset::<ast::Name>()?;
- let strukt = name.syntax().parent().and_then(<Either<ast::Struct, ast::Variant>>::cast)?;
- let field_list = strukt.as_ref().either(|s| s.field_list(), |v| v.field_list())?;
+ let strukt_or_variant = ctx
+ .find_node_at_offset::<ast::Struct>()
+ .map(Either::Left)
+ .or_else(|| ctx.find_node_at_offset::<ast::Variant>().map(Either::Right))?;
+ let field_list = strukt_or_variant.as_ref().either(|s| s.field_list(), |v| v.field_list())?;
+
+ if ctx.offset() > field_list.syntax().text_range().start() {
+ // Assist could be distracting after the braces
+ return None;
+ }
+
let tuple_fields = match field_list {
ast::FieldList::TupleFieldList(it) => it,
ast::FieldList::RecordFieldList(_) => return None,
};
- let strukt_def = match &strukt {
+ let strukt_def = match &strukt_or_variant {
Either::Left(s) => Either::Left(ctx.sema.to_def(s)?),
Either::Right(v) => Either::Right(ctx.sema.to_def(v)?),
};
- let target = strukt.as_ref().either(|s| s.syntax(), |v| v.syntax()).text_range();
+ let target = strukt_or_variant.as_ref().either(|s| s.syntax(), |v| v.syntax()).text_range();
acc.add(
AssistId::refactor_rewrite("convert_tuple_struct_to_named_struct"),
@@ -72,7 +80,7 @@ pub(crate) fn convert_tuple_struct_to_named_struct(
let names = generate_names(tuple_fields.fields());
edit_field_references(ctx, edit, tuple_fields.fields(), &names);
edit_struct_references(ctx, edit, strukt_def, &names);
- edit_struct_def(ctx, edit, &strukt, tuple_fields, names);
+ edit_struct_def(ctx, edit, &strukt_or_variant, tuple_fields, names);
},
)
}
@@ -317,6 +325,88 @@ fn into_inner(self) -> Inner {
}
#[test]
+ fn convert_simple_struct_cursor_on_struct_keyword() {
+ check_assist(
+ convert_tuple_struct_to_named_struct,
+ r#"
+struct Inner;
+struct$0 A(Inner);
+
+impl A {
+ fn new(inner: Inner) -> A {
+ A(inner)
+ }
+
+ fn new_with_default() -> A {
+ A::new(Inner)
+ }
+
+ fn into_inner(self) -> Inner {
+ self.0
+ }
+}"#,
+ r#"
+struct Inner;
+struct A { field1: Inner }
+
+impl A {
+ fn new(inner: Inner) -> A {
+ A { field1: inner }
+ }
+
+ fn new_with_default() -> A {
+ A::new(Inner)
+ }
+
+ fn into_inner(self) -> Inner {
+ self.field1
+ }
+}"#,
+ );
+ }
+
+ #[test]
+ fn convert_simple_struct_cursor_on_visibility_keyword() {
+ check_assist(
+ convert_tuple_struct_to_named_struct,
+ r#"
+struct Inner;
+pub$0 struct A(Inner);
+
+impl A {
+ fn new(inner: Inner) -> A {
+ A(inner)
+ }
+
+ fn new_with_default() -> A {
+ A::new(Inner)
+ }
+
+ fn into_inner(self) -> Inner {
+ self.0
+ }
+}"#,
+ r#"
+struct Inner;
+pub struct A { field1: Inner }
+
+impl A {
+ fn new(inner: Inner) -> A {
+ A { field1: inner }
+ }
+
+ fn new_with_default() -> A {
+ A::new(Inner)
+ }
+
+ fn into_inner(self) -> Inner {
+ self.field1
+ }
+}"#,
+ );
+ }
+
+ #[test]
fn convert_struct_referenced_via_self_kw() {
check_assist(
convert_tuple_struct_to_named_struct,
diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/fix_visibility.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/fix_visibility.rs
index 19e0a73..3badc17 100644
--- a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/fix_visibility.rs
+++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/fix_visibility.rs
@@ -7,10 +7,10 @@
use crate::{AssistContext, AssistId, Assists};
-// FIXME: this really should be a fix for diagnostic, rather than an assist.
-
// Assist: fix_visibility
//
+// Note that there is some duplication between this and the no_such_field diagnostic.
+//
// Makes inaccessible item public.
//
// ```
@@ -32,7 +32,6 @@
// ```
pub(crate) fn fix_visibility(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
add_vis_to_referenced_module_def(acc, ctx)
- .or_else(|| add_vis_to_referenced_record_field(acc, ctx))
}
fn add_vis_to_referenced_module_def(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
@@ -88,59 +87,6 @@ fn add_vis_to_referenced_module_def(acc: &mut Assists, ctx: &AssistContext<'_>)
})
}
-fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
- let record_field: ast::RecordExprField = ctx.find_node_at_offset()?;
- let (record_field_def, _, _) = ctx.sema.resolve_record_field(&record_field)?;
-
- let current_module = ctx.sema.scope(record_field.syntax())?.module();
- let current_edition = current_module.krate().edition(ctx.db());
- let visibility = record_field_def.visibility(ctx.db());
- if visibility.is_visible_from(ctx.db(), current_module.into()) {
- return None;
- }
-
- let parent = record_field_def.parent_def(ctx.db());
- let parent_name = parent.name(ctx.db());
- let target_module = parent.module(ctx.db());
-
- let in_file_source = record_field_def.source(ctx.db())?;
- let (vis_owner, target) = match in_file_source.value {
- hir::FieldSource::Named(it) => {
- let range = it.syntax().text_range();
- (ast::AnyHasVisibility::new(it), range)
- }
- hir::FieldSource::Pos(it) => {
- let range = it.syntax().text_range();
- (ast::AnyHasVisibility::new(it), range)
- }
- };
-
- let missing_visibility = if current_module.krate() == target_module.krate() {
- make::visibility_pub_crate()
- } else {
- make::visibility_pub()
- };
- let target_file = in_file_source.file_id.original_file(ctx.db());
-
- let target_name = record_field_def.name(ctx.db());
- let assist_label = format!(
- "Change visibility of {}.{} to {missing_visibility}",
- parent_name.display(ctx.db(), current_edition),
- target_name.display(ctx.db(), current_edition)
- );
-
- acc.add(AssistId::quick_fix("fix_visibility"), assist_label, target, |edit| {
- edit.edit_file(target_file.file_id(ctx.db()));
-
- let vis_owner = edit.make_mut(vis_owner);
- vis_owner.set_visibility(Some(missing_visibility.clone_for_update()));
-
- if let Some((cap, vis)) = ctx.config.snippet_cap.zip(vis_owner.visibility()) {
- edit.add_tabstop_before(cap, vis);
- }
- })
-}
-
fn target_data_for_def(
db: &dyn HirDatabase,
def: hir::ModuleDef,
@@ -294,44 +240,6 @@ fn main() { foo::Foo$0 }
}
#[test]
- fn fix_visibility_of_struct_field() {
- check_assist(
- fix_visibility,
- r"mod foo { pub struct Foo { bar: (), } }
- fn main() { foo::Foo { $0bar: () }; } ",
- r"mod foo { pub struct Foo { $0pub(crate) bar: (), } }
- fn main() { foo::Foo { bar: () }; } ",
- );
- check_assist(
- fix_visibility,
- r"
-//- /lib.rs
-mod foo;
-fn main() { foo::Foo { $0bar: () }; }
-//- /foo.rs
-pub struct Foo { bar: () }
-",
- r"pub struct Foo { $0pub(crate) bar: () }
-",
- );
- check_assist_not_applicable(
- fix_visibility,
- r"mod foo { pub struct Foo { pub bar: (), } }
- fn main() { foo::Foo { $0bar: () }; } ",
- );
- check_assist_not_applicable(
- fix_visibility,
- r"
-//- /lib.rs
-mod foo;
-fn main() { foo::Foo { $0bar: () }; }
-//- /foo.rs
-pub struct Foo { pub bar: () }
-",
- );
- }
-
- #[test]
fn fix_visibility_of_enum_variant_field() {
// Enum variants, as well as their fields, always get the enum's visibility. In fact, rustc
// rejects any visibility specifiers on them, so this assist should never fire on them.
@@ -368,44 +276,6 @@ pub struct Foo { pub bar: () }
}
#[test]
- fn fix_visibility_of_union_field() {
- check_assist(
- fix_visibility,
- r"mod foo { pub union Foo { bar: (), } }
- fn main() { foo::Foo { $0bar: () }; } ",
- r"mod foo { pub union Foo { $0pub(crate) bar: (), } }
- fn main() { foo::Foo { bar: () }; } ",
- );
- check_assist(
- fix_visibility,
- r"
-//- /lib.rs
-mod foo;
-fn main() { foo::Foo { $0bar: () }; }
-//- /foo.rs
-pub union Foo { bar: () }
-",
- r"pub union Foo { $0pub(crate) bar: () }
-",
- );
- check_assist_not_applicable(
- fix_visibility,
- r"mod foo { pub union Foo { pub bar: (), } }
- fn main() { foo::Foo { $0bar: () }; } ",
- );
- check_assist_not_applicable(
- fix_visibility,
- r"
-//- /lib.rs
-mod foo;
-fn main() { foo::Foo { $0bar: () }; }
-//- /foo.rs
-pub union Foo { pub bar: () }
-",
- );
- }
-
- #[test]
fn fix_visibility_of_const() {
check_assist(
fix_visibility,
@@ -572,19 +442,6 @@ fn replaces_pub_crate_with_pub() {
r"$0pub struct Bar;
",
);
- check_assist(
- fix_visibility,
- r"
-//- /main.rs crate:a deps:foo
-fn main() {
- foo::Foo { $0bar: () };
-}
-//- /lib.rs crate:foo
-pub struct Foo { pub(crate) bar: () }
-",
- r"pub struct Foo { $0pub bar: () }
-",
- );
}
#[test]
diff --git a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/remove_underscore.rs b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/remove_underscore.rs
index 912e193..a8e2741 100644
--- a/src/tools/rust-analyzer/crates/ide-assists/src/handlers/remove_underscore.rs
+++ b/src/tools/rust-analyzer/crates/ide-assists/src/handlers/remove_underscore.rs
@@ -1,6 +1,7 @@
use ide_db::{
assists::AssistId,
defs::{Definition, NameClass, NameRefClass},
+ rename::RenameDefinition,
};
use syntax::{AstNode, ast};
@@ -61,7 +62,7 @@ pub(crate) fn remove_underscore(acc: &mut Assists, ctx: &AssistContext<'_>) -> O
"Remove underscore from a used variable",
text_range,
|builder| {
- let changes = def.rename(&ctx.sema, new_name).unwrap();
+ let changes = def.rename(&ctx.sema, new_name, RenameDefinition::Yes).unwrap();
builder.source_change = changes;
},
)
diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/completions/attribute.rs b/src/tools/rust-analyzer/crates/ide-completion/src/completions/attribute.rs
index 3c195f8..705402c 100644
--- a/src/tools/rust-analyzer/crates/ide-completion/src/completions/attribute.rs
+++ b/src/tools/rust-analyzer/crates/ide-completion/src/completions/attribute.rs
@@ -25,6 +25,7 @@
mod cfg;
mod derive;
+mod diagnostic;
mod lint;
mod macro_use;
mod repr;
@@ -40,23 +41,22 @@ pub(crate) fn complete_known_attribute_input(
extern_crate: Option<&ast::ExternCrate>,
) -> Option<()> {
let attribute = fake_attribute_under_caret;
- let name_ref = match attribute.path() {
- Some(p) => Some(p.as_single_name_ref()?),
- None => None,
- };
- let (path, tt) = name_ref.zip(attribute.token_tree())?;
- tt.l_paren_token()?;
+ let path = attribute.path()?;
+ let segments = path.segments().map(|s| s.name_ref()).collect::<Option<Vec<_>>>()?;
+ let segments = segments.iter().map(|n| n.text()).collect::<Vec<_>>();
+ let segments = segments.iter().map(|t| t.as_str()).collect::<Vec<_>>();
+ let tt = attribute.token_tree()?;
- match path.text().as_str() {
- "repr" => repr::complete_repr(acc, ctx, tt),
- "feature" => lint::complete_lint(
+ match segments.as_slice() {
+ ["repr"] => repr::complete_repr(acc, ctx, tt),
+ ["feature"] => lint::complete_lint(
acc,
ctx,
colon_prefix,
&parse_tt_as_comma_sep_paths(tt, ctx.edition)?,
FEATURES,
),
- "allow" | "expect" | "deny" | "forbid" | "warn" => {
+ ["allow"] | ["expect"] | ["deny"] | ["forbid"] | ["warn"] => {
let existing_lints = parse_tt_as_comma_sep_paths(tt, ctx.edition)?;
let lints: Vec<Lint> = CLIPPY_LINT_GROUPS
@@ -70,13 +70,14 @@ pub(crate) fn complete_known_attribute_input(
lint::complete_lint(acc, ctx, colon_prefix, &existing_lints, &lints);
}
- "cfg" => cfg::complete_cfg(acc, ctx),
- "macro_use" => macro_use::complete_macro_use(
+ ["cfg"] => cfg::complete_cfg(acc, ctx),
+ ["macro_use"] => macro_use::complete_macro_use(
acc,
ctx,
extern_crate,
&parse_tt_as_comma_sep_paths(tt, ctx.edition)?,
),
+ ["diagnostic", "on_unimplemented"] => diagnostic::complete_on_unimplemented(acc, ctx, tt),
_ => (),
}
Some(())
@@ -139,6 +140,8 @@ pub(crate) fn complete_attribute_path(
}
Qualified::TypeAnchor { .. } | Qualified::With { .. } => {}
}
+ let qualifier_path =
+ if let Qualified::With { path, .. } = qualified { Some(path) } else { None };
let attributes = annotated_item_kind.and_then(|kind| {
if ast::Expr::can_cast(kind) {
@@ -149,18 +152,33 @@ pub(crate) fn complete_attribute_path(
});
let add_completion = |attr_completion: &AttrCompletion| {
- let mut item = CompletionItem::new(
- SymbolKind::Attribute,
- ctx.source_range(),
- attr_completion.label,
- ctx.edition,
- );
+ // if we don't already have the qualifiers of the completion, then
+ // add the missing parts to the label and snippet
+ let mut label = attr_completion.label.to_owned();
+ let mut snippet = attr_completion.snippet.map(|s| s.to_owned());
+ let segments = qualifier_path.iter().flat_map(|q| q.segments()).collect::<Vec<_>>();
+ let qualifiers = attr_completion.qualifiers;
+ let matching_qualifiers = segments
+ .iter()
+ .zip(qualifiers)
+ .take_while(|(s, q)| s.name_ref().is_some_and(|t| t.text() == **q))
+ .count();
+ if matching_qualifiers != qualifiers.len() {
+ let prefix = qualifiers[matching_qualifiers..].join("::");
+ label = format!("{prefix}::{label}");
+ if let Some(s) = snippet.as_mut() {
+ *s = format!("{prefix}::{s}");
+ }
+ }
+
+ let mut item =
+ CompletionItem::new(SymbolKind::Attribute, ctx.source_range(), label, ctx.edition);
if let Some(lookup) = attr_completion.lookup {
item.lookup_by(lookup);
}
- if let Some((snippet, cap)) = attr_completion.snippet.zip(ctx.config.snippet_cap) {
+ if let Some((snippet, cap)) = snippet.zip(ctx.config.snippet_cap) {
item.insert_snippet(cap, snippet);
}
@@ -184,6 +202,7 @@ struct AttrCompletion {
label: &'static str,
lookup: Option<&'static str>,
snippet: Option<&'static str>,
+ qualifiers: &'static [&'static str],
prefer_inner: bool,
}
@@ -192,6 +211,10 @@ fn key(&self) -> &'static str {
self.lookup.unwrap_or(self.label)
}
+ const fn qualifiers(self, qualifiers: &'static [&'static str]) -> AttrCompletion {
+ AttrCompletion { qualifiers, ..self }
+ }
+
const fn prefer_inner(self) -> AttrCompletion {
AttrCompletion { prefer_inner: true, ..self }
}
@@ -202,7 +225,7 @@ const fn attr(
lookup: Option<&'static str>,
snippet: Option<&'static str>,
) -> AttrCompletion {
- AttrCompletion { label, lookup, snippet, prefer_inner: false }
+ AttrCompletion { label, lookup, snippet, qualifiers: &[], prefer_inner: false }
}
macro_rules! attrs {
@@ -264,14 +287,14 @@ macro_rules! attrs {
FN,
attrs!(
item, linkable,
- "cold", "ignore", "inline", "must_use", "panic_handler", "proc_macro",
+ "cold", "ignore", "inline", "panic_handler", "proc_macro",
"proc_macro_derive", "proc_macro_attribute", "should_panic", "target_feature",
"test", "track_caller"
),
),
(STATIC, attrs!(item, linkable, "global_allocator", "used")),
- (TRAIT, attrs!(item, "must_use")),
- (IMPL, attrs!(item, "automatically_derived")),
+ (TRAIT, attrs!(item, "diagnostic::on_unimplemented")),
+ (IMPL, attrs!(item, "automatically_derived", "diagnostic::do_not_recommend")),
(ASSOC_ITEM_LIST, attrs!(item)),
(EXTERN_BLOCK, attrs!(item, "link")),
(EXTERN_ITEM_LIST, attrs!(item, "link")),
@@ -311,6 +334,14 @@ macro_rules! attrs {
attr("deny(…)", Some("deny"), Some("deny(${0:lint})")),
attr(r#"deprecated"#, Some("deprecated"), Some(r#"deprecated"#)),
attr("derive(…)", Some("derive"), Some(r#"derive(${0:Debug})"#)),
+ attr("do_not_recommend", Some("diagnostic::do_not_recommend"), None)
+ .qualifiers(&["diagnostic"]),
+ attr(
+ "on_unimplemented",
+ Some("diagnostic::on_unimplemented"),
+ Some(r#"on_unimplemented(${0:keys})"#),
+ )
+ .qualifiers(&["diagnostic"]),
attr(r#"doc = "…""#, Some("doc"), Some(r#"doc = "${0:docs}""#)),
attr(r#"doc(alias = "…")"#, Some("docalias"), Some(r#"doc(alias = "${0:docs}")"#)),
attr(r#"doc(hidden)"#, Some("dochidden"), Some(r#"doc(hidden)"#)),
diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/completions/attribute/diagnostic.rs b/src/tools/rust-analyzer/crates/ide-completion/src/completions/attribute/diagnostic.rs
new file mode 100644
index 0000000..8adc974
--- /dev/null
+++ b/src/tools/rust-analyzer/crates/ide-completion/src/completions/attribute/diagnostic.rs
@@ -0,0 +1,60 @@
+//! Completion for diagnostic attributes.
+
+use ide_db::SymbolKind;
+use syntax::ast;
+
+use crate::{CompletionItem, Completions, context::CompletionContext};
+
+use super::AttrCompletion;
+
+pub(super) fn complete_on_unimplemented(
+ acc: &mut Completions,
+ ctx: &CompletionContext<'_>,
+ input: ast::TokenTree,
+) {
+ if let Some(existing_keys) = super::parse_comma_sep_expr(input) {
+ for attr in ATTRIBUTE_ARGS {
+ let already_annotated = existing_keys
+ .iter()
+ .filter_map(|expr| match expr {
+ ast::Expr::PathExpr(path) => path.path()?.as_single_name_ref(),
+ ast::Expr::BinExpr(bin)
+ if bin.op_kind() == Some(ast::BinaryOp::Assignment { op: None }) =>
+ {
+ match bin.lhs()? {
+ ast::Expr::PathExpr(path) => path.path()?.as_single_name_ref(),
+ _ => None,
+ }
+ }
+ _ => None,
+ })
+ .any(|it| {
+ let text = it.text();
+ attr.key() == text && text != "note"
+ });
+ if already_annotated {
+ continue;
+ }
+
+ let mut item = CompletionItem::new(
+ SymbolKind::BuiltinAttr,
+ ctx.source_range(),
+ attr.label,
+ ctx.edition,
+ );
+ if let Some(lookup) = attr.lookup {
+ item.lookup_by(lookup);
+ }
+ if let Some((snippet, cap)) = attr.snippet.zip(ctx.config.snippet_cap) {
+ item.insert_snippet(cap, snippet);
+ }
+ item.add_to(acc, ctx.db);
+ }
+ }
+}
+
+const ATTRIBUTE_ARGS: &[AttrCompletion] = &[
+ super::attr(r#"label = "…""#, Some("label"), Some(r#"label = "${0:label}""#)),
+ super::attr(r#"message = "…""#, Some("message"), Some(r#"message = "${0:message}""#)),
+ super::attr(r#"note = "…""#, Some("note"), Some(r#"note = "${0:note}""#)),
+];
diff --git a/src/tools/rust-analyzer/crates/ide-completion/src/tests/attribute.rs b/src/tools/rust-analyzer/crates/ide-completion/src/tests/attribute.rs
index 32d3b50..411902f 100644
--- a/src/tools/rust-analyzer/crates/ide-completion/src/tests/attribute.rs
+++ b/src/tools/rust-analyzer/crates/ide-completion/src/tests/attribute.rs
@@ -30,6 +30,8 @@ pub fn my_derive() {}
at deprecated
at derive macro derive
at derive(…)
+ at diagnostic::do_not_recommend
+ at diagnostic::on_unimplemented
at doc = "…"
at doc(alias = "…")
at doc(hidden)
@@ -472,13 +474,13 @@ fn attr_on_trait() {
at cfg_attr(…)
at deny(…)
at deprecated
+ at diagnostic::on_unimplemented
at doc = "…"
at doc(alias = "…")
at doc(hidden)
at expect(…)
at forbid(…)
at must_use
- at must_use
at no_mangle
at warn(…)
kw crate::
@@ -498,6 +500,7 @@ fn attr_on_impl() {
at cfg_attr(…)
at deny(…)
at deprecated
+ at diagnostic::do_not_recommend
at doc = "…"
at doc(alias = "…")
at doc(hidden)
@@ -533,6 +536,76 @@ fn attr_on_impl() {
}
#[test]
+fn attr_with_qualifier() {
+ check(
+ r#"#[diagnostic::$0] impl () {}"#,
+ expect![[r#"
+ at allow(…)
+ at automatically_derived
+ at cfg(…)
+ at cfg_attr(…)
+ at deny(…)
+ at deprecated
+ at do_not_recommend
+ at doc = "…"
+ at doc(alias = "…")
+ at doc(hidden)
+ at expect(…)
+ at forbid(…)
+ at must_use
+ at no_mangle
+ at warn(…)
+ "#]],
+ );
+ check(
+ r#"#[diagnostic::$0] trait Foo {}"#,
+ expect![[r#"
+ at allow(…)
+ at cfg(…)
+ at cfg_attr(…)
+ at deny(…)
+ at deprecated
+ at doc = "…"
+ at doc(alias = "…")
+ at doc(hidden)
+ at expect(…)
+ at forbid(…)
+ at must_use
+ at no_mangle
+ at on_unimplemented
+ at warn(…)
+ "#]],
+ );
+}
+
+#[test]
+fn attr_diagnostic_on_unimplemented() {
+ check(
+ r#"#[diagnostic::on_unimplemented($0)] trait Foo {}"#,
+ expect![[r#"
+ ba label = "…"
+ ba message = "…"
+ ba note = "…"
+ "#]],
+ );
+ check(
+ r#"#[diagnostic::on_unimplemented(message = "foo", $0)] trait Foo {}"#,
+ expect![[r#"
+ ba label = "…"
+ ba note = "…"
+ "#]],
+ );
+ check(
+ r#"#[diagnostic::on_unimplemented(note = "foo", $0)] trait Foo {}"#,
+ expect![[r#"
+ ba label = "…"
+ ba message = "…"
+ ba note = "…"
+ "#]],
+ );
+}
+
+#[test]
fn attr_on_extern_block() {
check(
r#"#[$0] extern {}"#,
@@ -619,7 +692,6 @@ fn attr_on_fn() {
at link_name = "…"
at link_section = "…"
at must_use
- at must_use
at no_mangle
at panic_handler
at proc_macro
@@ -649,6 +721,8 @@ fn attr_in_source_file_end() {
at deny(…)
at deprecated
at derive(…)
+ at diagnostic::do_not_recommend
+ at diagnostic::on_unimplemented
at doc = "…"
at doc(alias = "…")
at doc(hidden)
diff --git a/src/tools/rust-analyzer/crates/ide-db/src/rename.rs b/src/tools/rust-analyzer/crates/ide-db/src/rename.rs
index fa2a46a..4e737e2 100644
--- a/src/tools/rust-analyzer/crates/ide-db/src/rename.rs
+++ b/src/tools/rust-analyzer/crates/ide-db/src/rename.rs
@@ -20,7 +20,7 @@
//!
//! The correct behavior in such cases is probably to show a dialog to the user.
//! Our current behavior is ¯\_(ツ)_/¯.
-use std::fmt;
+use std::fmt::{self, Display};
use crate::{
source_change::ChangeAnnotation,
@@ -28,13 +28,12 @@
};
use base_db::AnchoredPathBuf;
use either::Either;
-use hir::{EditionedFileId, FieldSource, FileRange, InFile, ModuleSource, Semantics};
+use hir::{FieldSource, FileRange, InFile, ModuleSource, Name, Semantics, sym};
use span::{Edition, FileId, SyntaxContext};
use stdx::{TupleExt, never};
use syntax::{
AstNode, SyntaxKind, T, TextRange,
ast::{self, HasName},
- utils::is_raw_identifier,
};
use crate::{
@@ -70,26 +69,33 @@ macro_rules! _bail {
}
pub use _bail as bail;
+#[derive(Copy, Clone, Debug, PartialEq, Eq)]
+pub enum RenameDefinition {
+ Yes,
+ No,
+}
+
impl Definition {
pub fn rename(
&self,
sema: &Semantics<'_, RootDatabase>,
new_name: &str,
+ rename_definition: RenameDefinition,
) -> Result<SourceChange> {
- // We append `r#` if needed.
- let new_name = new_name.trim_start_matches("r#");
-
// self.krate() returns None if
// self is a built-in attr, built-in type or tool module.
// it is not allowed for these defs to be renamed.
// cases where self.krate() is None is handled below.
- if let Some(krate) = self.krate(sema.db) {
+ let edition = if let Some(krate) = self.krate(sema.db) {
// Can we not rename non-local items?
// Then bail if non-local
if !krate.origin(sema.db).is_local() {
bail!("Cannot rename a non-local definition")
}
- }
+ krate.edition(sema.db)
+ } else {
+ Edition::LATEST
+ };
match *self {
Definition::Module(module) => rename_mod(sema, module, new_name),
@@ -103,8 +109,10 @@ pub fn rename(
bail!("Cannot rename a builtin attr.")
}
Definition::SelfType(_) => bail!("Cannot rename `Self`"),
- Definition::Macro(mac) => rename_reference(sema, Definition::Macro(mac), new_name),
- def => rename_reference(sema, def, new_name),
+ Definition::Macro(mac) => {
+ rename_reference(sema, Definition::Macro(mac), new_name, rename_definition, edition)
+ }
+ def => rename_reference(sema, def, new_name, rename_definition, edition),
}
}
@@ -237,10 +245,6 @@ fn rename_mod(
module: hir::Module,
new_name: &str,
) -> Result<SourceChange> {
- if IdentifierKind::classify(new_name)? != IdentifierKind::Ident {
- bail!("Invalid name `{0}`: cannot rename module to {0}", new_name);
- }
-
let mut source_change = SourceChange::default();
if module.is_crate_root() {
@@ -248,6 +252,14 @@ fn rename_mod(
}
let InFile { file_id, value: def_source } = module.definition_source(sema.db);
+ let edition = file_id.edition(sema.db);
+ let (new_name, kind) = IdentifierKind::classify(edition, new_name)?;
+ if kind != IdentifierKind::Ident {
+ bail!(
+ "Invalid name `{0}`: cannot rename module to {0}",
+ new_name.display(sema.db, edition)
+ );
+ }
if let ModuleSource::SourceFile(..) = def_source {
let anchor = file_id.original_file(sema.db).file_id(sema.db);
@@ -256,7 +268,7 @@ fn rename_mod(
// Module exists in a named file
if !is_mod_rs {
- let path = format!("{new_name}.rs");
+ let path = format!("{}.rs", new_name.as_str());
let dst = AnchoredPathBuf { anchor, path };
source_change.push_file_system_edit(FileSystemEdit::MoveFile { src: anchor, dst })
}
@@ -267,11 +279,11 @@ fn rename_mod(
let dir_paths = match (is_mod_rs, has_detached_child, module.name(sema.db)) {
// Go up one level since the anchor is inside the dir we're trying to rename
(true, _, Some(mod_name)) => {
- Some((format!("../{}", mod_name.as_str()), format!("../{new_name}")))
+ Some((format!("../{}", mod_name.as_str()), format!("../{}", new_name.as_str())))
}
// The anchor is on the same level as target dir
(false, true, Some(mod_name)) => {
- Some((mod_name.as_str().to_owned(), new_name.to_owned()))
+ Some((mod_name.as_str().to_owned(), new_name.as_str().to_owned()))
}
_ => None,
};
@@ -296,11 +308,7 @@ fn rename_mod(
.original_file_range_opt(sema.db)
.map(TupleExt::head)
{
- let new_name = if is_raw_identifier(new_name, file_id.edition(sema.db)) {
- format!("r#{new_name}")
- } else {
- new_name.to_owned()
- };
+ let new_name = new_name.display(sema.db, edition).to_string();
source_change.insert_source_edit(
file_id.file_id(sema.db),
TextEdit::replace(file_range.range, new_name),
@@ -314,9 +322,10 @@ fn rename_mod(
let def = Definition::Module(module);
let usages = def.usages(sema).all();
let ref_edits = usages.iter().map(|(file_id, references)| {
+ let edition = file_id.edition(sema.db);
(
file_id.file_id(sema.db),
- source_edit_from_references(references, def, new_name, file_id.edition(sema.db)),
+ source_edit_from_references(sema.db, references, def, &new_name, edition),
)
});
source_change.extend(ref_edits);
@@ -328,8 +337,10 @@ fn rename_reference(
sema: &Semantics<'_, RootDatabase>,
def: Definition,
new_name: &str,
+ rename_definition: RenameDefinition,
+ edition: Edition,
) -> Result<SourceChange> {
- let ident_kind = IdentifierKind::classify(new_name)?;
+ let (mut new_name, ident_kind) = IdentifierKind::classify(edition, new_name)?;
if matches!(
def,
@@ -337,18 +348,34 @@ fn rename_reference(
) {
match ident_kind {
IdentifierKind::Underscore => {
- bail!("Invalid name `{}`: not a lifetime identifier", new_name);
+ bail!(
+ "Invalid name `{}`: not a lifetime identifier",
+ new_name.display(sema.db, edition)
+ );
}
- _ => cov_mark::hit!(rename_lifetime),
+ IdentifierKind::Ident => {
+ new_name = Name::new_lifetime(&format!("'{}", new_name.as_str()))
+ }
+ IdentifierKind::Lifetime => (),
+ IdentifierKind::LowercaseSelf => bail!(
+ "Invalid name `{}`: not a lifetime identifier",
+ new_name.display(sema.db, edition)
+ ),
}
} else {
match ident_kind {
IdentifierKind::Lifetime => {
cov_mark::hit!(rename_not_an_ident_ref);
- bail!("Invalid name `{}`: not an identifier", new_name);
+ bail!("Invalid name `{}`: not an identifier", new_name.display(sema.db, edition));
}
IdentifierKind::Ident => cov_mark::hit!(rename_non_local),
IdentifierKind::Underscore => (),
+ IdentifierKind::LowercaseSelf => {
+ bail!(
+ "Invalid name `{}`: cannot rename to `self`",
+ new_name.display(sema.db, edition)
+ );
+ }
}
}
@@ -361,30 +388,29 @@ fn rename_reference(
}
let mut source_change = SourceChange::default();
source_change.extend(usages.iter().map(|(file_id, references)| {
+ let edition = file_id.edition(sema.db);
(
file_id.file_id(sema.db),
- source_edit_from_references(references, def, new_name, file_id.edition(sema.db)),
+ source_edit_from_references(sema.db, references, def, &new_name, edition),
)
}));
-
- // This needs to come after the references edits, because we change the annotation of existing edits
- // if a conflict is detected.
- let (file_id, edit) = source_edit_from_def(sema, def, new_name, &mut source_change)?;
- source_change.insert_source_edit(file_id, edit);
+ if rename_definition == RenameDefinition::Yes {
+ // This needs to come after the references edits, because we change the annotation of existing edits
+ // if a conflict is detected.
+ let (file_id, edit) = source_edit_from_def(sema, def, &new_name, &mut source_change)?;
+ source_change.insert_source_edit(file_id, edit);
+ }
Ok(source_change)
}
pub fn source_edit_from_references(
+ db: &RootDatabase,
references: &[FileReference],
def: Definition,
- new_name: &str,
+ new_name: &Name,
edition: Edition,
) -> TextEdit {
- let new_name = if is_raw_identifier(new_name, edition) {
- format!("r#{new_name}")
- } else {
- new_name.to_owned()
- };
+ let name_display = new_name.display(db, edition);
let mut edit = TextEdit::builder();
// macros can cause multiple refs to occur for the same text range, so keep track of what we have edited so far
let mut edited_ranges = Vec::new();
@@ -395,23 +421,15 @@ pub fn source_edit_from_references(
// to make special rewrites like shorthand syntax and such, so just rename the node in
// the macro input
FileReferenceNode::NameRef(name_ref) if name_range == range => {
- source_edit_from_name_ref(&mut edit, name_ref, &new_name, def)
+ source_edit_from_name_ref(&mut edit, name_ref, &name_display, def)
}
FileReferenceNode::Name(name) if name_range == range => {
- source_edit_from_name(&mut edit, name, &new_name)
+ source_edit_from_name(&mut edit, name, &name_display)
}
_ => false,
};
if !has_emitted_edit && !edited_ranges.contains(&range.start()) {
- let (range, new_name) = match name {
- FileReferenceNode::Lifetime(_) => (
- TextRange::new(range.start() + syntax::TextSize::from(1), range.end()),
- new_name.strip_prefix('\'').unwrap_or(&new_name).to_owned(),
- ),
- _ => (range, new_name.to_owned()),
- };
-
- edit.replace(range, new_name);
+ edit.replace(range, name_display.to_string());
edited_ranges.push(range.start());
}
}
@@ -419,7 +437,11 @@ pub fn source_edit_from_references(
edit.finish()
}
-fn source_edit_from_name(edit: &mut TextEditBuilder, name: &ast::Name, new_name: &str) -> bool {
+fn source_edit_from_name(
+ edit: &mut TextEditBuilder,
+ name: &ast::Name,
+ new_name: &dyn Display,
+) -> bool {
if ast::RecordPatField::for_field_name(name).is_some() {
if let Some(ident_pat) = name.syntax().parent().and_then(ast::IdentPat::cast) {
cov_mark::hit!(rename_record_pat_field_name_split);
@@ -439,7 +461,7 @@ fn source_edit_from_name(edit: &mut TextEditBuilder, name: &ast::Name, new_name:
fn source_edit_from_name_ref(
edit: &mut TextEditBuilder,
name_ref: &ast::NameRef,
- new_name: &str,
+ new_name: &dyn Display,
def: Definition,
) -> bool {
if name_ref.super_token().is_some() {
@@ -452,6 +474,7 @@ fn source_edit_from_name_ref(
match &(rcf_name_ref, rcf_expr.and_then(|it| expr_as_name_ref(&it))) {
// field: init-expr, check if we can use a field init shorthand
(Some(field_name), Some(init)) => {
+ let new_name = new_name.to_string();
if field_name == name_ref {
if init.text() == new_name {
cov_mark::hit!(test_rename_field_put_init_shorthand);
@@ -507,6 +530,7 @@ fn source_edit_from_name_ref(
{
// field name is being renamed
if let Some(name) = pat.name() {
+ let new_name = new_name.to_string();
if name.text() == new_name {
cov_mark::hit!(test_rename_field_put_init_shorthand_pat);
// Foo { field: ref mut local } -> Foo { ref mut field }
@@ -518,7 +542,7 @@ fn source_edit_from_name_ref(
let s = field_name.syntax().text_range().start();
let e = pat.syntax().text_range().start();
edit.delete(TextRange::new(s, e));
- edit.replace(name.syntax().text_range(), new_name.to_owned());
+ edit.replace(name.syntax().text_range(), new_name);
return true;
}
}
@@ -532,16 +556,9 @@ fn source_edit_from_name_ref(
fn source_edit_from_def(
sema: &Semantics<'_, RootDatabase>,
def: Definition,
- new_name: &str,
+ new_name: &Name,
source_change: &mut SourceChange,
) -> Result<(FileId, TextEdit)> {
- let new_name_edition_aware = |new_name: &str, file_id: EditionedFileId| {
- if is_raw_identifier(new_name, file_id.edition(sema.db)) {
- format!("r#{new_name}")
- } else {
- new_name.to_owned()
- }
- };
let mut edit = TextEdit::builder();
if let Definition::Local(local) = def {
let mut file_id = None;
@@ -573,7 +590,10 @@ fn source_edit_from_def(
{
Some(FileRange { file_id: file_id2, range }) => {
file_id = Some(file_id2);
- edit.replace(range, new_name_edition_aware(new_name, file_id2));
+ edit.replace(
+ range,
+ new_name.display(sema.db, file_id2.edition(sema.db)).to_string(),
+ );
continue;
}
None => {
@@ -587,7 +607,7 @@ fn source_edit_from_def(
// special cases required for renaming fields/locals in Record patterns
if let Some(pat_field) = pat.syntax().parent().and_then(ast::RecordPatField::cast) {
if let Some(name_ref) = pat_field.name_ref() {
- if new_name == name_ref.text().as_str().trim_start_matches("r#")
+ if new_name.as_str() == name_ref.text().as_str().trim_start_matches("r#")
&& pat.at_token().is_none()
{
// Foo { field: ref mut local } -> Foo { ref mut field }
@@ -607,7 +627,9 @@ fn source_edit_from_def(
// ^^^^^ replace this with `new_name`
edit.replace(
name_range,
- new_name_edition_aware(new_name, source.file_id),
+ new_name
+ .display(sema.db, source.file_id.edition(sema.db))
+ .to_string(),
);
}
} else {
@@ -618,10 +640,16 @@ fn source_edit_from_def(
pat.syntax().text_range().start(),
format!("{}: ", pat_field.field_name().unwrap()),
);
- edit.replace(name_range, new_name_edition_aware(new_name, source.file_id));
+ edit.replace(
+ name_range,
+ new_name.display(sema.db, source.file_id.edition(sema.db)).to_string(),
+ );
}
} else {
- edit.replace(name_range, new_name_edition_aware(new_name, source.file_id));
+ edit.replace(
+ name_range,
+ new_name.display(sema.db, source.file_id.edition(sema.db)).to_string(),
+ );
}
}
}
@@ -639,16 +667,13 @@ fn source_edit_from_def(
.range_for_rename(sema)
.ok_or_else(|| format_err!("No identifier available to rename"))?;
let (range, new_name) = match def {
- Definition::GenericParam(hir::GenericParam::LifetimeParam(_)) | Definition::Label(_) => (
- TextRange::new(range.start() + syntax::TextSize::from(1), range.end()),
- new_name.strip_prefix('\'').unwrap_or(new_name).to_owned(),
+ Definition::ExternCrateDecl(decl) if decl.alias(sema.db).is_none() => (
+ TextRange::empty(range.end()),
+ format!(" as {}", new_name.display(sema.db, file_id.edition(sema.db)),),
),
- Definition::ExternCrateDecl(decl) if decl.alias(sema.db).is_none() => {
- (TextRange::empty(range.end()), format!(" as {new_name}"))
- }
- _ => (range, new_name.to_owned()),
+ _ => (range, new_name.display(sema.db, file_id.edition(sema.db)).to_string()),
};
- edit.replace(range, new_name_edition_aware(&new_name, file_id));
+ edit.replace(range, new_name);
Ok((file_id.file_id(sema.db), edit.finish()))
}
@@ -657,26 +682,27 @@ pub enum IdentifierKind {
Ident,
Lifetime,
Underscore,
+ LowercaseSelf,
}
impl IdentifierKind {
- pub fn classify(new_name: &str) -> Result<IdentifierKind> {
- let new_name = new_name.trim_start_matches("r#");
- match parser::LexedStr::single_token(Edition::LATEST, new_name) {
+ pub fn classify(edition: Edition, new_name: &str) -> Result<(Name, IdentifierKind)> {
+ match parser::LexedStr::single_token(edition, new_name) {
Some(res) => match res {
- (SyntaxKind::IDENT, _) => {
- if let Some(inner) = new_name.strip_prefix("r#") {
- if matches!(inner, "self" | "crate" | "super" | "Self") {
- bail!("Invalid name: `{}` cannot be a raw identifier", inner);
- }
- }
- Ok(IdentifierKind::Ident)
+ (SyntaxKind::IDENT, _) => Ok((Name::new_root(new_name), IdentifierKind::Ident)),
+ (T![_], _) => {
+ Ok((Name::new_symbol_root(sym::underscore), IdentifierKind::Underscore))
}
- (T![_], _) => Ok(IdentifierKind::Underscore),
(SyntaxKind::LIFETIME_IDENT, _) if new_name != "'static" && new_name != "'_" => {
- Ok(IdentifierKind::Lifetime)
+ Ok((Name::new_lifetime(new_name), IdentifierKind::Lifetime))
}
- _ if is_raw_identifier(new_name, Edition::LATEST) => Ok(IdentifierKind::Ident),
+ _ if SyntaxKind::from_keyword(new_name, edition).is_some() => match new_name {
+ "self" => Ok((Name::new_root(new_name), IdentifierKind::LowercaseSelf)),
+ "crate" | "super" | "Self" => {
+ bail!("Invalid name `{}`: cannot rename to a keyword", new_name)
+ }
+ _ => Ok((Name::new_root(new_name), IdentifierKind::Ident)),
+ },
(_, Some(syntax_error)) => bail!("Invalid name `{}`: {}", new_name, syntax_error),
(_, None) => bail!("Invalid name `{}`: not an identifier", new_name),
},
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/incorrect_case.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/incorrect_case.rs
index 38f10c7..519ff19 100644
--- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/incorrect_case.rs
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/incorrect_case.rs
@@ -1,5 +1,5 @@
use hir::{CaseType, InFile, db::ExpandDatabase};
-use ide_db::{assists::Assist, defs::NameClass};
+use ide_db::{assists::Assist, defs::NameClass, rename::RenameDefinition};
use syntax::AstNode;
use crate::{
@@ -44,7 +44,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::IncorrectCase) -> Option<Vec<Ass
let label = format!("Rename to {}", d.suggested_text);
let mut res = unresolved_fix("change_case", &label, frange.range);
if ctx.resolve.should_resolve(&res.id) {
- let source_change = def.rename(&ctx.sema, &d.suggested_text);
+ let source_change = def.rename(&ctx.sema, &d.suggested_text, RenameDefinition::Yes);
res.source_change = Some(source_change.ok().unwrap_or_default());
}
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs
index 87c9397..bf7ddda 100644
--- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/json_is_not_rust.rs
@@ -135,6 +135,7 @@ pub(crate) fn json_in_items(
"JSON syntax is not valid as a Rust item",
FileRange { file_id: vfs_file_id, range },
)
+ .stable()
.with_fixes(Some(vec![{
let mut scb = SourceChangeBuilder::new(vfs_file_id);
let scope = scb.make_import_scope_mut(import_scope);
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/no_such_field.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/no_such_field.rs
index 84fb467..ef42f2d 100644
--- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/no_such_field.rs
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/no_such_field.rs
@@ -1,4 +1,5 @@
use either::Either;
+use hir::{Field, HasCrate};
use hir::{HasSource, HirDisplay, Semantics, VariantId, db::ExpandDatabase};
use ide_db::text_edit::TextEdit;
use ide_db::{EditionedFileId, RootDatabase, source_change::SourceChange};
@@ -13,44 +14,69 @@
//
// This diagnostic is triggered if created structure does not have field provided in record.
pub(crate) fn no_such_field(ctx: &DiagnosticsContext<'_>, d: &hir::NoSuchField) -> Diagnostic {
- let node = d.field.map(Into::into);
- if d.private {
- // FIXME: quickfix to add required visibility
- Diagnostic::new_with_syntax_node_ptr(
- ctx,
- DiagnosticCode::RustcHardError("E0451"),
- "field is private",
- node,
- )
- .stable()
+ let (code, message) = if d.private.is_some() {
+ ("E0451", "field is private")
+ } else if let VariantId::EnumVariantId(_) = d.variant {
+ ("E0559", "no such field")
} else {
- Diagnostic::new_with_syntax_node_ptr(
- ctx,
- match d.variant {
- VariantId::EnumVariantId(_) => DiagnosticCode::RustcHardError("E0559"),
- _ => DiagnosticCode::RustcHardError("E0560"),
- },
- "no such field",
- node,
- )
+ ("E0560", "no such field")
+ };
+
+ let node = d.field.map(Into::into);
+ Diagnostic::new_with_syntax_node_ptr(ctx, DiagnosticCode::RustcHardError(code), message, node)
.stable()
.with_fixes(fixes(ctx, d))
- }
}
fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::NoSuchField) -> Option<Vec<Assist>> {
// FIXME: quickfix for pattern
let root = ctx.sema.db.parse_or_expand(d.field.file_id);
match &d.field.value.to_node(&root) {
- Either::Left(node) => missing_record_expr_field_fixes(
- &ctx.sema,
- d.field.file_id.original_file(ctx.sema.db),
- node,
- ),
+ Either::Left(node) => {
+ if let Some(private_field) = d.private {
+ field_is_private_fixes(
+ &ctx.sema,
+ d.field.file_id.original_file(ctx.sema.db),
+ node,
+ private_field,
+ )
+ } else {
+ missing_record_expr_field_fixes(
+ &ctx.sema,
+ d.field.file_id.original_file(ctx.sema.db),
+ node,
+ )
+ }
+ }
_ => None,
}
}
+fn field_is_private_fixes(
+ sema: &Semantics<'_, RootDatabase>,
+ usage_file_id: EditionedFileId,
+ record_expr_field: &ast::RecordExprField,
+ private_field: Field,
+) -> Option<Vec<Assist>> {
+ let def_crate = private_field.krate(sema.db);
+ let usage_crate = sema.file_to_module_def(usage_file_id.file_id(sema.db))?.krate();
+ let visibility = if usage_crate == def_crate { "pub(crate) " } else { "pub " };
+
+ let source = private_field.source(sema.db)?;
+ let (range, _) = source.syntax().original_file_range_opt(sema.db)?;
+ let source_change = SourceChange::from_text_edit(
+ range.file_id.file_id(sema.db),
+ TextEdit::insert(range.range.start(), visibility.into()),
+ );
+
+ Some(vec![fix(
+ "increase_field_visibility",
+ "Increase field visibility",
+ source_change,
+ sema.original_range(record_expr_field.syntax()).range,
+ )])
+}
+
fn missing_record_expr_field_fixes(
sema: &Semantics<'_, RootDatabase>,
usage_file_id: EditionedFileId,
@@ -118,7 +144,7 @@ fn missing_record_expr_field_fixes(
"create_field",
"Create field",
source_change,
- record_expr_field.syntax().text_range(),
+ sema.original_range(record_expr_field.syntax()).range,
)]);
fn record_field_list(field_def_list: ast::FieldList) -> Option<ast::RecordFieldList> {
@@ -387,15 +413,15 @@ fn f(s@m::Struct {
// assignee expression
m::Struct {
field: 0,
- //^^^^^^^^ error: field is private
+ //^^^^^^^^ 💡 error: field is private
field2
- //^^^^^^ error: field is private
+ //^^^^^^ 💡 error: field is private
} = s;
m::Struct {
field: 0,
- //^^^^^^^^ error: field is private
+ //^^^^^^^^ 💡 error: field is private
field2
- //^^^^^^ error: field is private
+ //^^^^^^ 💡 error: field is private
};
}
"#,
@@ -403,6 +429,77 @@ fn f(s@m::Struct {
}
#[test]
+ fn test_struct_field_private_same_crate_fix() {
+ check_diagnostics(
+ r#"
+mod m {
+ pub struct Struct {
+ field: u32,
+ }
+}
+fn f() {
+ let _ = m::Struct {
+ field: 0,
+ //^^^^^^^^ 💡 error: field is private
+ };
+}
+"#,
+ );
+
+ check_fix(
+ r#"
+mod m {
+ pub struct Struct {
+ field: u32,
+ }
+}
+fn f() {
+ let _ = m::Struct {
+ field$0: 0,
+ };
+}
+"#,
+ r#"
+mod m {
+ pub struct Struct {
+ pub(crate) field: u32,
+ }
+}
+fn f() {
+ let _ = m::Struct {
+ field: 0,
+ };
+}
+"#,
+ );
+ }
+
+ #[test]
+ fn test_struct_field_private_other_crate_fix() {
+ check_fix(
+ r#"
+//- /lib.rs crate:another_crate
+pub struct Struct {
+ field: u32,
+}
+//- /lib.rs crate:this_crate deps:another_crate
+use another_crate;
+
+fn f() {
+ let _ = another_crate::Struct {
+ field$0: 0,
+ };
+}
+"#,
+ r#"
+pub struct Struct {
+ pub field: u32,
+}
+"#,
+ );
+ }
+
+ #[test]
fn editions_between_macros() {
check_diagnostics(
r#"
diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unlinked_file.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unlinked_file.rs
index af9126c..d96c658 100644
--- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unlinked_file.rs
+++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unlinked_file.rs
@@ -69,6 +69,7 @@ pub(crate) fn unlinked_file(
FileRange { file_id, range },
)
.with_unused(unused)
+ .stable()
.with_fixes(fixes),
);
}
diff --git a/src/tools/rust-analyzer/crates/ide/src/expand_macro.rs b/src/tools/rust-analyzer/crates/ide/src/expand_macro.rs
index 7c39633..f31886b 100644
--- a/src/tools/rust-analyzer/crates/ide/src/expand_macro.rs
+++ b/src/tools/rust-analyzer/crates/ide/src/expand_macro.rs
@@ -800,4 +800,65 @@ fn item(){}
foo();"#]],
);
}
+
+ #[test]
+ fn works_in_sig() {
+ check(
+ r#"
+macro_rules! foo {
+ () => { u32 };
+}
+fn foo() -> foo$0!() {
+ 42
+}
+"#,
+ expect![[r#"
+ foo!
+ u32"#]],
+ );
+ check(
+ r#"
+macro_rules! foo {
+ () => { u32 };
+}
+fn foo(_: foo$0!() ) {}
+"#,
+ expect![[r#"
+ foo!
+ u32"#]],
+ );
+ }
+
+ #[test]
+ fn works_in_generics() {
+ check(
+ r#"
+trait Trait {}
+macro_rules! foo {
+ () => { Trait };
+}
+impl<const C: foo$0!()> Trait for () {}
+"#,
+ expect![[r#"
+ foo!
+ Trait"#]],
+ );
+ }
+
+ #[test]
+ fn works_in_fields() {
+ check(
+ r#"
+macro_rules! foo {
+ () => { u32 };
+}
+struct S {
+ field: foo$0!(),
+}
+"#,
+ expect![[r#"
+ foo!
+ u32"#]],
+ );
+ }
}
diff --git a/src/tools/rust-analyzer/crates/ide/src/inlay_hints.rs b/src/tools/rust-analyzer/crates/ide/src/inlay_hints.rs
index 82704af..b094b09 100644
--- a/src/tools/rust-analyzer/crates/ide/src/inlay_hints.rs
+++ b/src/tools/rust-analyzer/crates/ide/src/inlay_hints.rs
@@ -6,7 +6,7 @@
use either::Either;
use hir::{
ClosureStyle, DisplayTarget, EditionedFileId, HasVisibility, HirDisplay, HirDisplayError,
- HirWrite, ModuleDef, ModuleDefId, Semantics, sym,
+ HirWrite, InRealFile, ModuleDef, ModuleDefId, Semantics, sym,
};
use ide_db::{FileRange, RootDatabase, famous_defs::FamousDefs, text_edit::TextEditBuilder};
use ide_db::{FxHashSet, text_edit::TextEdit};
@@ -34,6 +34,7 @@
mod generic_param;
mod implicit_drop;
mod implicit_static;
+mod implied_dyn_trait;
mod lifetime;
mod param_name;
mod range_exclusive;
@@ -95,16 +96,16 @@ pub(crate) fn inlay_hints(
return acc;
};
let famous_defs = FamousDefs(&sema, scope.krate());
+ let display_target = famous_defs.1.to_display_target(sema.db);
let ctx = &mut InlayHintCtx::default();
let mut hints = |event| {
if let Some(node) = handle_event(ctx, event) {
- hints(&mut acc, ctx, &famous_defs, config, file_id, node);
+ hints(&mut acc, ctx, &famous_defs, config, file_id, display_target, node);
}
};
let mut preorder = file.preorder();
while let Some(event) = preorder.next() {
- // FIXME: This can miss some hints that require the parent of the range to calculate
if matches!((&event, range_limit), (WalkEvent::Enter(node), Some(range)) if range.intersect(node.text_range()).is_none())
{
preorder.skip_subtree();
@@ -144,10 +145,12 @@ pub(crate) fn inlay_hints_resolve(
let famous_defs = FamousDefs(&sema, scope.krate());
let mut acc = Vec::new();
+ let display_target = famous_defs.1.to_display_target(sema.db);
+
let ctx = &mut InlayHintCtx::default();
let mut hints = |event| {
if let Some(node) = handle_event(ctx, event) {
- hints(&mut acc, ctx, &famous_defs, config, file_id, node);
+ hints(&mut acc, ctx, &famous_defs, config, file_id, display_target, node);
}
};
@@ -202,17 +205,19 @@ fn handle_event(ctx: &mut InlayHintCtx, node: WalkEvent<SyntaxNode>) -> Option<S
fn hints(
hints: &mut Vec<InlayHint>,
ctx: &mut InlayHintCtx,
- famous_defs @ FamousDefs(sema, _): &FamousDefs<'_, '_>,
+ famous_defs @ FamousDefs(sema, _krate): &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
file_id: EditionedFileId,
+ display_target: DisplayTarget,
node: SyntaxNode,
) {
- let file_id = file_id.editioned_file_id(sema.db);
- let Some(krate) = sema.first_crate(file_id.file_id()) else {
- return;
- };
- let display_target = krate.to_display_target(sema.db);
- closing_brace::hints(hints, sema, config, file_id, display_target, node.clone());
+ closing_brace::hints(
+ hints,
+ sema,
+ config,
+ display_target,
+ InRealFile { file_id, value: node.clone() },
+ );
if let Some(any_has_generic_args) = ast::AnyHasGenericArgs::cast(node.clone()) {
generic_param::hints(hints, famous_defs, config, any_has_generic_args);
}
@@ -231,18 +236,18 @@ fn hints(
closure_captures::hints(hints, famous_defs, config, it.clone());
closure_ret::hints(hints, famous_defs, config, display_target, it)
},
- ast::Expr::RangeExpr(it) => range_exclusive::hints(hints, famous_defs, config, file_id, it),
+ ast::Expr::RangeExpr(it) => range_exclusive::hints(hints, famous_defs, config, it),
_ => Some(()),
}
},
ast::Pat(it) => {
- binding_mode::hints(hints, famous_defs, config, file_id, &it);
+ binding_mode::hints(hints, famous_defs, config, &it);
match it {
ast::Pat::IdentPat(it) => {
bind_pat::hints(hints, famous_defs, config, display_target, &it);
}
ast::Pat::RangePat(it) => {
- range_exclusive::hints(hints, famous_defs, config, file_id, it);
+ range_exclusive::hints(hints, famous_defs, config, it);
}
_ => {}
}
@@ -250,30 +255,38 @@ fn hints(
},
ast::Item(it) => match it {
ast::Item::Fn(it) => {
- implicit_drop::hints(hints, famous_defs, config, file_id, &it);
+ implicit_drop::hints(hints, famous_defs, config, display_target, &it);
if let Some(extern_block) = &ctx.extern_block_parent {
- extern_block::fn_hints(hints, famous_defs, config, file_id, &it, extern_block);
+ extern_block::fn_hints(hints, famous_defs, config, &it, extern_block);
}
- lifetime::fn_hints(hints, ctx, famous_defs, config, file_id, it)
+ lifetime::fn_hints(hints, ctx, famous_defs, config, it)
},
ast::Item::Static(it) => {
if let Some(extern_block) = &ctx.extern_block_parent {
- extern_block::static_hints(hints, famous_defs, config, file_id, &it, extern_block);
+ extern_block::static_hints(hints, famous_defs, config, &it, extern_block);
}
- implicit_static::hints(hints, famous_defs, config, file_id, Either::Left(it))
+ implicit_static::hints(hints, famous_defs, config, Either::Left(it))
},
- ast::Item::Const(it) => implicit_static::hints(hints, famous_defs, config, file_id, Either::Right(it)),
- ast::Item::Enum(it) => discriminant::enum_hints(hints, famous_defs, config, file_id, it),
- ast::Item::ExternBlock(it) => extern_block::extern_block_hints(hints, famous_defs, config, file_id, it),
+ ast::Item::Const(it) => implicit_static::hints(hints, famous_defs, config, Either::Right(it)),
+ ast::Item::Enum(it) => discriminant::enum_hints(hints, famous_defs, config, it),
+ ast::Item::ExternBlock(it) => extern_block::extern_block_hints(hints, famous_defs, config, it),
_ => None,
},
// FIXME: trait object type elisions
ast::Type(ty) => match ty {
- ast::Type::FnPtrType(ptr) => lifetime::fn_ptr_hints(hints, ctx, famous_defs, config, file_id, ptr),
- ast::Type::PathType(path) => lifetime::fn_path_hints(hints, ctx, famous_defs, config, file_id, path),
+ ast::Type::FnPtrType(ptr) => lifetime::fn_ptr_hints(hints, ctx, famous_defs, config, ptr),
+ ast::Type::PathType(path) => {
+ lifetime::fn_path_hints(hints, ctx, famous_defs, config, &path);
+ implied_dyn_trait::hints(hints, famous_defs, config, Either::Left(path));
+ Some(())
+ },
+ ast::Type::DynTraitType(dyn_) => {
+ implied_dyn_trait::hints(hints, famous_defs, config, Either::Right(dyn_));
+ Some(())
+ },
_ => Some(()),
},
- ast::GenericParamList(it) => bounds::hints(hints, famous_defs, config, file_id, it),
+ ast::GenericParamList(it) => bounds::hints(hints, famous_defs, config, it),
_ => Some(()),
}
};
@@ -438,6 +451,7 @@ pub enum InlayKind {
Parameter,
GenericParameter,
Type,
+ Dyn,
Drop,
RangeExclusive,
ExternUnsafety,
diff --git a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/binding_mode.rs b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/binding_mode.rs
index d291732..169ab92 100644
--- a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/binding_mode.rs
+++ b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/binding_mode.rs
@@ -8,7 +8,6 @@
use ide_db::famous_defs::FamousDefs;
use ide_db::text_edit::TextEditBuilder;
-use span::EditionedFileId;
use syntax::ast::{self, AstNode};
use crate::{InlayHint, InlayHintLabel, InlayHintPosition, InlayHintsConfig, InlayKind};
@@ -17,7 +16,6 @@ pub(super) fn hints(
acc: &mut Vec<InlayHint>,
FamousDefs(sema, _): &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
- _file_id: EditionedFileId,
pat: &ast::Pat,
) -> Option<()> {
if !config.binding_mode_hints {
diff --git a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/bounds.rs b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/bounds.rs
index 8ddbfae..b9a98f8 100644
--- a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/bounds.rs
+++ b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/bounds.rs
@@ -3,7 +3,6 @@
//! Currently this renders the implied `Sized` bound.
use ide_db::{FileRange, famous_defs::FamousDefs};
-use span::EditionedFileId;
use syntax::ast::{self, AstNode, HasTypeBounds};
use crate::{
@@ -15,7 +14,6 @@ pub(super) fn hints(
acc: &mut Vec<InlayHint>,
famous_defs @ FamousDefs(sema, _): &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
- _file_id: EditionedFileId,
params: ast::GenericParamList,
) -> Option<()> {
if !config.sized_bound {
diff --git a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/closing_brace.rs b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/closing_brace.rs
index 2ec85da..ca3a982 100644
--- a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/closing_brace.rs
+++ b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/closing_brace.rs
@@ -3,9 +3,8 @@
//! fn g() {
//! } /* fn g */
//! ```
-use hir::{DisplayTarget, HirDisplay, Semantics};
+use hir::{DisplayTarget, HirDisplay, InRealFile, Semantics};
use ide_db::{FileRange, RootDatabase};
-use span::EditionedFileId;
use syntax::{
SyntaxKind, SyntaxNode, T,
ast::{self, AstNode, HasLoopBody, HasName},
@@ -21,15 +20,14 @@ pub(super) fn hints(
acc: &mut Vec<InlayHint>,
sema: &Semantics<'_, RootDatabase>,
config: &InlayHintsConfig,
- file_id: EditionedFileId,
display_target: DisplayTarget,
- original_node: SyntaxNode,
+ InRealFile { file_id, value: node }: InRealFile<SyntaxNode>,
) -> Option<()> {
let min_lines = config.closing_brace_hints_min_lines?;
let name = |it: ast::Name| it.syntax().text_range();
- let mut node = original_node.clone();
+ let mut node = node.clone();
let mut closing_token;
let (label, name_range) = if let Some(item_list) = ast::AssocItemList::cast(node.clone()) {
closing_token = item_list.r_curly_token()?;
@@ -44,7 +42,7 @@ pub(super) fn hints(
let hint_text = match trait_ {
Some(tr) => format!(
"impl {} for {}",
- tr.name(sema.db).display(sema.db, file_id.edition()),
+ tr.name(sema.db).display(sema.db, display_target.edition),
ty.display_truncated(sema.db, config.max_length, display_target,
)),
None => format!("impl {}", ty.display_truncated(sema.db, config.max_length, display_target)),
@@ -142,7 +140,8 @@ pub(super) fn hints(
return None;
}
- let linked_location = name_range.map(|range| FileRange { file_id: file_id.into(), range });
+ let linked_location =
+ name_range.map(|range| FileRange { file_id: file_id.file_id(sema.db), range });
acc.push(InlayHint {
range: closing_token.text_range(),
kind: InlayKind::ClosingBrace,
@@ -151,7 +150,7 @@ pub(super) fn hints(
position: InlayHintPosition::After,
pad_left: true,
pad_right: false,
- resolve_parent: Some(original_node.text_range()),
+ resolve_parent: Some(node.text_range()),
});
None
diff --git a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/discriminant.rs b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/discriminant.rs
index 827a043..a2a7028 100644
--- a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/discriminant.rs
+++ b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/discriminant.rs
@@ -7,7 +7,6 @@
use hir::Semantics;
use ide_db::text_edit::TextEdit;
use ide_db::{RootDatabase, famous_defs::FamousDefs};
-use span::EditionedFileId;
use syntax::ast::{self, AstNode, HasName};
use crate::{
@@ -19,7 +18,6 @@ pub(super) fn enum_hints(
acc: &mut Vec<InlayHint>,
FamousDefs(sema, _): &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
- _: EditionedFileId,
enum_: ast::Enum,
) -> Option<()> {
if let DiscriminantHints::Never = config.discriminant_hints {
diff --git a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/extern_block.rs b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/extern_block.rs
index 20f54b2..88152bf 100644
--- a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/extern_block.rs
+++ b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/extern_block.rs
@@ -1,6 +1,5 @@
//! Extern block hints
use ide_db::{famous_defs::FamousDefs, text_edit::TextEdit};
-use span::EditionedFileId;
use syntax::{AstNode, SyntaxToken, ast};
use crate::{InlayHint, InlayHintsConfig};
@@ -9,7 +8,6 @@ pub(super) fn extern_block_hints(
acc: &mut Vec<InlayHint>,
FamousDefs(sema, _): &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
- _file_id: EditionedFileId,
extern_block: ast::ExternBlock,
) -> Option<()> {
if extern_block.unsafe_token().is_some() {
@@ -36,7 +34,6 @@ pub(super) fn fn_hints(
acc: &mut Vec<InlayHint>,
FamousDefs(sema, _): &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
- _file_id: EditionedFileId,
fn_: &ast::Fn,
extern_block: &ast::ExternBlock,
) -> Option<()> {
@@ -55,7 +52,6 @@ pub(super) fn static_hints(
acc: &mut Vec<InlayHint>,
FamousDefs(sema, _): &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
- _file_id: EditionedFileId,
static_: &ast::Static,
extern_block: &ast::ExternBlock,
) -> Option<()> {
diff --git a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/implicit_drop.rs b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/implicit_drop.rs
index f52e279..bf4688e 100644
--- a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/implicit_drop.rs
+++ b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/implicit_drop.rs
@@ -12,7 +12,6 @@
};
use ide_db::{FileRange, famous_defs::FamousDefs};
-use span::EditionedFileId;
use syntax::{
ToSmolStr,
ast::{self, AstNode},
@@ -25,7 +24,7 @@ pub(super) fn hints(
acc: &mut Vec<InlayHint>,
FamousDefs(sema, _): &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
- file_id: EditionedFileId,
+ display_target: hir::DisplayTarget,
node: &ast::Fn,
) -> Option<()> {
if !config.implicit_drop_hints {
@@ -94,7 +93,7 @@ pub(super) fn hints(
MirSpan::Unknown => continue,
};
let binding = &hir.bindings[binding_idx];
- let name = binding.name.display_no_db(file_id.edition()).to_smolstr();
+ let name = binding.name.display_no_db(display_target.edition).to_smolstr();
if name.starts_with("<ra@") {
continue; // Ignore desugared variables
}
diff --git a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/implicit_static.rs b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/implicit_static.rs
index f3be09f..7212efd 100644
--- a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/implicit_static.rs
+++ b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/implicit_static.rs
@@ -5,7 +5,6 @@
use either::Either;
use ide_db::famous_defs::FamousDefs;
use ide_db::text_edit::TextEdit;
-use span::EditionedFileId;
use syntax::{
SyntaxKind,
ast::{self, AstNode},
@@ -17,7 +16,6 @@ pub(super) fn hints(
acc: &mut Vec<InlayHint>,
FamousDefs(_sema, _): &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
- _file_id: EditionedFileId,
statik_or_const: Either<ast::Static, ast::Const>,
) -> Option<()> {
if config.lifetime_elision_hints != LifetimeElisionHints::Always {
diff --git a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/implied_dyn_trait.rs b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/implied_dyn_trait.rs
new file mode 100644
index 0000000..32d1305
--- /dev/null
+++ b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/implied_dyn_trait.rs
@@ -0,0 +1,133 @@
+//! Implementation of trait bound hints.
+//!
+//! Currently this renders the implied `Sized` bound.
+use either::Either;
+use ide_db::{famous_defs::FamousDefs, text_edit::TextEdit};
+
+use syntax::ast::{self, AstNode};
+
+use crate::{InlayHint, InlayHintLabel, InlayHintPosition, InlayHintsConfig, InlayKind};
+
+pub(super) fn hints(
+ acc: &mut Vec<InlayHint>,
+ FamousDefs(sema, _): &FamousDefs<'_, '_>,
+ config: &InlayHintsConfig,
+ path: Either<ast::PathType, ast::DynTraitType>,
+) -> Option<()> {
+ let parent = path.syntax().parent()?;
+ let range = match path {
+ Either::Left(path) => {
+ let paren =
+ parent.ancestors().take_while(|it| ast::ParenType::can_cast(it.kind())).last();
+ let parent = paren.as_ref().and_then(|it| it.parent()).unwrap_or(parent);
+ if ast::TypeBound::can_cast(parent.kind())
+ || ast::TypeAnchor::can_cast(parent.kind())
+ || ast::Impl::cast(parent)
+ .and_then(|it| it.trait_())
+ .is_some_and(|it| it.syntax() == path.syntax())
+ {
+ return None;
+ }
+ sema.resolve_trait(&path.path()?)?;
+ paren.map_or_else(|| path.syntax().text_range(), |it| it.text_range())
+ }
+ Either::Right(dyn_) => {
+ if dyn_.dyn_token().is_some() {
+ return None;
+ }
+
+ dyn_.syntax().text_range()
+ }
+ };
+
+ acc.push(InlayHint {
+ range,
+ kind: InlayKind::Dyn,
+ label: InlayHintLabel::simple("dyn", None, None),
+ text_edit: Some(
+ config.lazy_text_edit(|| TextEdit::insert(range.start(), "dyn ".to_owned())),
+ ),
+ position: InlayHintPosition::Before,
+ pad_left: false,
+ pad_right: true,
+ resolve_parent: Some(range),
+ });
+
+ Some(())
+}
+
+#[cfg(test)]
+mod tests {
+
+ use expect_test::expect;
+
+ use crate::inlay_hints::InlayHintsConfig;
+
+ use crate::inlay_hints::tests::{DISABLED_CONFIG, check_edit, check_with_config};
+
+ #[track_caller]
+ fn check(#[rust_analyzer::rust_fixture] ra_fixture: &str) {
+ check_with_config(InlayHintsConfig { sized_bound: true, ..DISABLED_CONFIG }, ra_fixture);
+ }
+
+ #[test]
+ fn path_works() {
+ check(
+ r#"
+struct S {}
+trait T {}
+fn foo(_: T, _: dyn T, _: S) {}
+ // ^ dyn
+fn foo(_: &T, _: for<'a> T) {}
+ // ^ dyn
+ // ^ dyn
+impl T {}
+ // ^ dyn
+impl T for (T) {}
+ // ^^^ dyn
+"#,
+ );
+ }
+
+ #[test]
+ fn missing_dyn_bounds() {
+ check(
+ r#"
+trait T {}
+fn foo(
+ _: T + T,
+ // ^^^^^ dyn
+ _: T + 'a,
+ // ^^^^^^ dyn
+ _: 'a + T,
+ // ^^^^^^ dyn
+ _: &(T + T)
+ // ^^^^^ dyn
+ _: &mut (T + T)
+ // ^^^^^ dyn
+ _: *mut (T),
+ // ^^^ dyn
+) {}
+"#,
+ );
+ }
+
+ #[test]
+ fn edit() {
+ check_edit(
+ DISABLED_CONFIG,
+ r#"
+trait T {}
+fn foo(
+ _: &mut T
+) {}
+"#,
+ expect![[r#"
+ trait T {}
+ fn foo(
+ _: &mut dyn T
+ ) {}
+ "#]],
+ );
+ }
+}
diff --git a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/lifetime.rs b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/lifetime.rs
index baba49a..0069452 100644
--- a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/lifetime.rs
+++ b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/lifetime.rs
@@ -6,7 +6,6 @@
use ide_db::{FxHashMap, famous_defs::FamousDefs, syntax_helpers::node_ext::walk_ty};
use itertools::Itertools;
-use span::EditionedFileId;
use syntax::{SmolStr, format_smolstr};
use syntax::{
SyntaxKind, SyntaxToken,
@@ -23,7 +22,6 @@ pub(super) fn fn_hints(
ctx: &mut InlayHintCtx,
fd: &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
- file_id: EditionedFileId,
func: ast::Fn,
) -> Option<()> {
if config.lifetime_elision_hints == LifetimeElisionHints::Never {
@@ -40,7 +38,6 @@ pub(super) fn fn_hints(
ctx,
fd,
config,
- file_id,
param_list.params().filter_map(|it| {
Some((
it.pat().and_then(|it| match it {
@@ -74,7 +71,6 @@ pub(super) fn fn_ptr_hints(
ctx: &mut InlayHintCtx,
fd: &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
- file_id: EditionedFileId,
func: ast::FnPtrType,
) -> Option<()> {
if config.lifetime_elision_hints == LifetimeElisionHints::Never {
@@ -97,7 +93,6 @@ pub(super) fn fn_ptr_hints(
ctx,
fd,
config,
- file_id,
param_list.params().filter_map(|it| {
Some((
it.pat().and_then(|it| match it {
@@ -140,8 +135,7 @@ pub(super) fn fn_path_hints(
ctx: &mut InlayHintCtx,
fd: &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
- file_id: EditionedFileId,
- func: ast::PathType,
+ func: &ast::PathType,
) -> Option<()> {
if config.lifetime_elision_hints == LifetimeElisionHints::Never {
return None;
@@ -163,7 +157,6 @@ pub(super) fn fn_path_hints(
ctx,
fd,
config,
- file_id,
param_list.type_args().filter_map(|it| Some((None, it.ty()?))),
generic_param_list,
ret_type,
@@ -202,7 +195,6 @@ fn hints_(
ctx: &mut InlayHintCtx,
FamousDefs(_, _): &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
- _file_id: EditionedFileId,
params: impl Iterator<Item = (Option<ast::Name>, ast::Type)>,
generic_param_list: Option<ast::GenericParamList>,
ret_type: Option<ast::RetType>,
diff --git a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/range_exclusive.rs b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/range_exclusive.rs
index d67d845..47bd6d7 100644
--- a/src/tools/rust-analyzer/crates/ide/src/inlay_hints/range_exclusive.rs
+++ b/src/tools/rust-analyzer/crates/ide/src/inlay_hints/range_exclusive.rs
@@ -4,7 +4,6 @@
//! if let ../* < */100 = 50 {}
//! ```
use ide_db::famous_defs::FamousDefs;
-use span::EditionedFileId;
use syntax::{SyntaxToken, T, ast};
use crate::{InlayHint, InlayHintsConfig};
@@ -13,7 +12,6 @@ pub(super) fn hints(
acc: &mut Vec<InlayHint>,
FamousDefs(_sema, _): &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
- _file_id: EditionedFileId,
range: impl ast::RangeItem,
) -> Option<()> {
(config.range_exclusive_hints && range.end().is_some())
diff --git a/src/tools/rust-analyzer/crates/ide/src/rename.rs b/src/tools/rust-analyzer/crates/ide/src/rename.rs
index 0423e3d..fb84e8e 100644
--- a/src/tools/rust-analyzer/crates/ide/src/rename.rs
+++ b/src/tools/rust-analyzer/crates/ide/src/rename.rs
@@ -4,11 +4,11 @@
//! tests. This module also implements a couple of magic tricks, like renaming
//! `self` and to `self` (to switch between associated function and method).
-use hir::{AsAssocItem, InFile, Semantics};
+use hir::{AsAssocItem, InFile, Name, Semantics, sym};
use ide_db::{
FileId, FileRange, RootDatabase,
defs::{Definition, NameClass, NameRefClass},
- rename::{IdentifierKind, bail, format_err, source_edit_from_references},
+ rename::{IdentifierKind, RenameDefinition, bail, format_err, source_edit_from_references},
source_change::SourceChangeBuilder,
};
use itertools::Itertools;
@@ -33,8 +33,8 @@ pub(crate) fn prepare_rename(
let source_file = sema.parse_guess_edition(position.file_id);
let syntax = source_file.syntax();
- let res = find_definitions(&sema, syntax, position)?
- .map(|(frange, kind, def)| {
+ let res = find_definitions(&sema, syntax, position, &Name::new_symbol_root(sym::underscore))?
+ .map(|(frange, kind, def, _, _)| {
// ensure all ranges are valid
if def.range_for_rename(&sema).is_none() {
@@ -88,22 +88,28 @@ pub(crate) fn rename(
let source_file = sema.parse(file_id);
let syntax = source_file.syntax();
- let defs = find_definitions(&sema, syntax, position)?;
- let alias_fallback = alias_fallback(syntax, position, new_name);
+ let edition = file_id.edition(db);
+ let (new_name, kind) = IdentifierKind::classify(edition, new_name)?;
+
+ let defs = find_definitions(&sema, syntax, position, &new_name)?;
+ let alias_fallback =
+ alias_fallback(syntax, position, &new_name.display(db, edition).to_string());
let ops: RenameResult<Vec<SourceChange>> = match alias_fallback {
Some(_) => defs
// FIXME: This can use the `ide_db::rename_reference` (or def.rename) method once we can
// properly find "direct" usages/references.
- .map(|(.., def)| {
- match IdentifierKind::classify(new_name)? {
+ .map(|(.., def, new_name, _)| {
+ match kind {
IdentifierKind::Ident => (),
IdentifierKind::Lifetime => {
bail!("Cannot alias reference to a lifetime identifier")
}
IdentifierKind::Underscore => bail!("Cannot alias reference to `_`"),
+ IdentifierKind::LowercaseSelf => {
+ bail!("Cannot rename alias reference to `self`")
+ }
};
-
let mut usages = def.usages(&sema).all();
// FIXME: hack - removes the usage that triggered this rename operation.
@@ -120,7 +126,7 @@ pub(crate) fn rename(
source_change.extend(usages.references.get_mut(&file_id).iter().map(|refs| {
(
position.file_id,
- source_edit_from_references(refs, def, new_name, file_id.edition(db)),
+ source_edit_from_references(db, refs, def, &new_name, edition),
)
}));
@@ -128,18 +134,18 @@ pub(crate) fn rename(
})
.collect(),
None => defs
- .map(|(.., def)| {
+ .map(|(.., def, new_name, rename_def)| {
if let Definition::Local(local) = def {
if let Some(self_param) = local.as_self_param(sema.db) {
cov_mark::hit!(rename_self_to_param);
- return rename_self_to_param(&sema, local, self_param, new_name);
+ return rename_self_to_param(&sema, local, self_param, &new_name, kind);
}
- if new_name == "self" {
+ if kind == IdentifierKind::LowercaseSelf {
cov_mark::hit!(rename_to_self);
return rename_to_self(&sema, local);
}
}
- def.rename(&sema, new_name)
+ def.rename(&sema, new_name.as_str(), rename_def)
})
.collect(),
};
@@ -159,7 +165,7 @@ pub(crate) fn will_rename_file(
let sema = Semantics::new(db);
let module = sema.file_to_module_def(file_id)?;
let def = Definition::Module(module);
- let mut change = def.rename(&sema, new_name_stem).ok()?;
+ let mut change = def.rename(&sema, new_name_stem, RenameDefinition::Yes).ok()?;
change.file_system_edits.clear();
Some(change)
}
@@ -200,22 +206,40 @@ fn find_definitions(
sema: &Semantics<'_, RootDatabase>,
syntax: &SyntaxNode,
FilePosition { file_id, offset }: FilePosition,
-) -> RenameResult<impl Iterator<Item = (FileRange, SyntaxKind, Definition)>> {
- let token = syntax.token_at_offset(offset).find(|t| matches!(t.kind(), SyntaxKind::STRING));
+ new_name: &Name,
+) -> RenameResult<impl Iterator<Item = (FileRange, SyntaxKind, Definition, Name, RenameDefinition)>>
+{
+ let maybe_format_args =
+ syntax.token_at_offset(offset).find(|t| matches!(t.kind(), SyntaxKind::STRING));
if let Some((range, _, _, Some(resolution))) =
- token.and_then(|token| sema.check_for_format_args_template(token, offset))
+ maybe_format_args.and_then(|token| sema.check_for_format_args_template(token, offset))
{
return Ok(vec![(
FileRange { file_id, range },
SyntaxKind::STRING,
Definition::from(resolution),
+ new_name.clone(),
+ RenameDefinition::Yes,
)]
.into_iter());
}
+ let original_ident = syntax
+ .token_at_offset(offset)
+ .max_by_key(|t| {
+ t.kind().is_any_identifier() || matches!(t.kind(), SyntaxKind::LIFETIME_IDENT)
+ })
+ .map(|t| {
+ if t.kind() == SyntaxKind::LIFETIME_IDENT {
+ Name::new_lifetime(t.text())
+ } else {
+ Name::new_root(t.text())
+ }
+ })
+ .ok_or_else(|| format_err!("No references found at position"))?;
let symbols =
- sema.find_nodes_at_offset_with_descend::<ast::NameLike>(syntax, offset).map(|name_like| {
+ sema.find_namelike_at_offset_with_descend(syntax, offset).map(|name_like| {
let kind = name_like.syntax().kind();
let range = sema
.original_range_opt(name_like.syntax())
@@ -284,23 +308,28 @@ fn find_definitions(
.ok_or_else(|| format_err!("No references found at position"))
}
};
- res.map(|def| (range, kind, def))
+ res.map(|def| {
+ let n = def.name(sema.db)?;
+ if n == original_ident {
+ Some((range, kind, def, new_name.clone(), RenameDefinition::Yes))
+ } else if let Some(suffix) = n.as_str().strip_prefix(original_ident.as_str()) {
+ Some((range, kind, def, Name::new_root(&format!("{}{suffix}", new_name.as_str())), RenameDefinition::No))
+ } else {
+ n.as_str().strip_suffix(original_ident.as_str().trim_start_matches('\''))
+ .map(|prefix| (range, kind, def, Name::new_root(&format!("{prefix}{}", new_name.as_str())), RenameDefinition::No))
+ }
+ })
});
- let res: RenameResult<Vec<_>> = symbols.collect();
+ let res: RenameResult<Vec<_>> = symbols.filter_map(Result::transpose).collect();
match res {
Ok(v) => {
- if v.is_empty() {
- // FIXME: some semantic duplication between "empty vec" and "Err()"
- Err(format_err!("No references found at position"))
- } else {
- // remove duplicates, comparing `Definition`s
- Ok(v.into_iter()
- .unique_by(|&(.., def)| def)
- .map(|(a, b, c)| (a.into_file_id(sema.db), b, c))
- .collect::<Vec<_>>()
- .into_iter())
- }
+ // remove duplicates, comparing `Definition`s
+ Ok(v.into_iter()
+ .unique_by(|&(.., def, _, _)| def)
+ .map(|(a, b, c, d, e)| (a.into_file_id(sema.db), b, c, d, e))
+ .collect::<Vec<_>>()
+ .into_iter())
}
Err(e) => Err(e),
}
@@ -370,7 +399,13 @@ fn rename_to_self(
source_change.extend(usages.iter().map(|(file_id, references)| {
(
file_id.file_id(sema.db),
- source_edit_from_references(references, def, "self", file_id.edition(sema.db)),
+ source_edit_from_references(
+ sema.db,
+ references,
+ def,
+ &Name::new_symbol_root(sym::self_),
+ file_id.edition(sema.db),
+ ),
)
}));
source_change.insert_source_edit(
@@ -384,23 +419,25 @@ fn rename_self_to_param(
sema: &Semantics<'_, RootDatabase>,
local: hir::Local,
self_param: hir::SelfParam,
- new_name: &str,
+ new_name: &Name,
+ identifier_kind: IdentifierKind,
) -> RenameResult<SourceChange> {
- if new_name == "self" {
+ if identifier_kind == IdentifierKind::LowercaseSelf {
// Let's do nothing rather than complain.
cov_mark::hit!(rename_self_to_self);
return Ok(SourceChange::default());
}
- let identifier_kind = IdentifierKind::classify(new_name)?;
-
let InFile { file_id, value: self_param } =
sema.source(self_param).ok_or_else(|| format_err!("cannot find function source"))?;
let def = Definition::Local(local);
let usages = def.usages(sema).all();
- let edit = text_edit_from_self_param(&self_param, new_name)
- .ok_or_else(|| format_err!("No target type found"))?;
+ let edit = text_edit_from_self_param(
+ &self_param,
+ new_name.display(sema.db, file_id.edition(sema.db)).to_string(),
+ )
+ .ok_or_else(|| format_err!("No target type found"))?;
if usages.len() > 1 && identifier_kind == IdentifierKind::Underscore {
bail!("Cannot rename reference to `_` as it is being referenced multiple times");
}
@@ -409,13 +446,19 @@ fn rename_self_to_param(
source_change.extend(usages.iter().map(|(file_id, references)| {
(
file_id.file_id(sema.db),
- source_edit_from_references(references, def, new_name, file_id.edition(sema.db)),
+ source_edit_from_references(
+ sema.db,
+ references,
+ def,
+ new_name,
+ file_id.edition(sema.db),
+ ),
)
}));
Ok(source_change)
}
-fn text_edit_from_self_param(self_param: &ast::SelfParam, new_name: &str) -> Option<TextEdit> {
+fn text_edit_from_self_param(self_param: &ast::SelfParam, new_name: String) -> Option<TextEdit> {
fn target_type_name(impl_def: &ast::Impl) -> Option<String> {
if let Some(ast::Type::PathType(p)) = impl_def.self_ty() {
return Some(p.path()?.segment()?.name_ref()?.text().to_string());
@@ -427,7 +470,7 @@ fn target_type_name(impl_def: &ast::Impl) -> Option<String> {
Some(impl_def) => {
let type_name = target_type_name(&impl_def)?;
- let mut replacement_text = String::from(new_name);
+ let mut replacement_text = new_name;
replacement_text.push_str(": ");
match (self_param.amp_token(), self_param.mut_token()) {
(Some(_), None) => replacement_text.push('&'),
@@ -440,7 +483,7 @@ fn target_type_name(impl_def: &ast::Impl) -> Option<String> {
}
None => {
cov_mark::hit!(rename_self_outside_of_methods);
- let mut replacement_text = String::from(new_name);
+ let mut replacement_text = new_name;
replacement_text.push_str(": _");
Some(TextEdit::replace(self_param.syntax().text_range(), replacement_text))
}
@@ -710,7 +753,7 @@ fn test_rename_to_invalid_identifier3() {
check(
"super",
r#"fn main() { let i$0 = 1; }"#,
- "error: Invalid name `super`: not an identifier",
+ "error: Invalid name `super`: cannot rename to a keyword",
);
}
@@ -759,7 +802,11 @@ fn test_rename_mod_invalid() {
#[test]
fn test_rename_mod_invalid_raw_ident() {
- check("r#self", r#"mod foo$0 {}"#, "error: Invalid name `self`: not an identifier");
+ check(
+ "r#self",
+ r#"mod foo$0 {}"#,
+ "error: Invalid name `self`: cannot rename module to self",
+ );
}
#[test]
@@ -2359,7 +2406,6 @@ fn foo(foo: Foo) {
#[test]
fn test_rename_lifetimes() {
- cov_mark::check!(rename_lifetime);
check(
"'yeeee",
r#"
@@ -2536,7 +2582,7 @@ fn baz() {
x.0$0 = 5;
}
"#,
- "error: No identifier available to rename",
+ "error: No references found at position",
);
}
@@ -2566,7 +2612,7 @@ fn foo(self) -> Self$0 {
}
}
"#,
- "error: Cannot rename `Self`",
+ "error: No references found at position",
);
}
@@ -3262,4 +3308,100 @@ fn foo() -> impl use<U> Trait {}
"#,
);
}
+
+ #[test]
+ fn rename_macro_generated_type_from_type_with_a_suffix() {
+ check(
+ "Bar",
+ r#"
+//- proc_macros: generate_suffixed_type
+#[proc_macros::generate_suffixed_type]
+struct Foo$0;
+fn usage(_: FooSuffix) {}
+usage(FooSuffix);
+"#,
+ r#"
+#[proc_macros::generate_suffixed_type]
+struct Bar;
+fn usage(_: BarSuffix) {}
+usage(BarSuffix);
+"#,
+ );
+ }
+
+ #[test]
+ // FIXME
+ #[should_panic]
+ fn rename_macro_generated_type_from_type_usage_with_a_suffix() {
+ check(
+ "Bar",
+ r#"
+//- proc_macros: generate_suffixed_type
+#[proc_macros::generate_suffixed_type]
+struct Foo;
+fn usage(_: FooSuffix) {}
+usage(FooSuffix);
+fn other_place() { Foo$0; }
+"#,
+ r#"
+#[proc_macros::generate_suffixed_type]
+struct Bar;
+fn usage(_: BarSuffix) {}
+usage(BarSuffix);
+fn other_place() { Bar; }
+"#,
+ );
+ }
+
+ #[test]
+ fn rename_macro_generated_type_from_variant_with_a_suffix() {
+ check(
+ "Bar",
+ r#"
+//- proc_macros: generate_suffixed_type
+#[proc_macros::generate_suffixed_type]
+enum Quux {
+ Foo$0,
+}
+fn usage(_: FooSuffix) {}
+usage(FooSuffix);
+"#,
+ r#"
+#[proc_macros::generate_suffixed_type]
+enum Quux {
+ Bar,
+}
+fn usage(_: BarSuffix) {}
+usage(BarSuffix);
+"#,
+ );
+ }
+
+ #[test]
+ // FIXME
+ #[should_panic]
+ fn rename_macro_generated_type_from_variant_usage_with_a_suffix() {
+ check(
+ "Bar",
+ r#"
+//- proc_macros: generate_suffixed_type
+#[proc_macros::generate_suffixed_type]
+enum Quux {
+ Foo,
+}
+fn usage(_: FooSuffix) {}
+usage(FooSuffix);
+fn other_place() { Quux::Foo$0; }
+"#,
+ r#"
+#[proc_macros::generate_suffixed_type]
+enum Quux {
+ Bar,
+}
+fn usage(_: BarSuffix) {}
+usage(BartSuffix);
+fn other_place() { Quux::Bar$0; }
+"#,
+ );
+ }
}
diff --git a/src/tools/rust-analyzer/crates/parser/src/grammar/expressions/atom.rs b/src/tools/rust-analyzer/crates/parser/src/grammar/expressions/atom.rs
index 8cc332d..8ed0fc6 100644
--- a/src/tools/rust-analyzer/crates/parser/src/grammar/expressions/atom.rs
+++ b/src/tools/rust-analyzer/crates/parser/src/grammar/expressions/atom.rs
@@ -562,8 +562,12 @@ fn closure_expr(p: &mut Parser<'_>) -> CompletedMarker {
let m = p.start();
+ // test closure_binder
+ // fn main() { for<'a> || (); }
if p.at(T![for]) {
+ let b = p.start();
types::for_binder(p);
+ b.complete(p, CLOSURE_BINDER);
}
// test const_closure
// fn main() { let cl = const || _ = 0; }
diff --git a/src/tools/rust-analyzer/crates/parser/src/grammar/generic_params.rs b/src/tools/rust-analyzer/crates/parser/src/grammar/generic_params.rs
index 9d4fdbf..ea5a3bc 100644
--- a/src/tools/rust-analyzer/crates/parser/src/grammar/generic_params.rs
+++ b/src/tools/rust-analyzer/crates/parser/src/grammar/generic_params.rs
@@ -201,6 +201,17 @@ fn type_bound(p: &mut Parser<'_>) -> bool {
}
if paths::is_use_path_start(p) {
types::path_type_bounds(p, false);
+ // test_err type_bounds_macro_call_recovery
+ // fn foo<T: T![], T: T!, T: T!{}>() -> Box<T! + T!{}> {}
+ if p.at(T![!]) {
+ let m = p.start();
+ p.bump(T![!]);
+ p.error("unexpected `!` in type path, macro calls are not allowed here");
+ if p.at_ts(TokenSet::new(&[T!['{'], T!['['], T!['(']])) {
+ items::token_tree(p);
+ }
+ m.complete(p, ERROR);
+ }
} else {
m.abandon(p);
return false;
diff --git a/src/tools/rust-analyzer/crates/parser/src/grammar/paths.rs b/src/tools/rust-analyzer/crates/parser/src/grammar/paths.rs
index 770827c..dfe7cb5 100644
--- a/src/tools/rust-analyzer/crates/parser/src/grammar/paths.rs
+++ b/src/tools/rust-analyzer/crates/parser/src/grammar/paths.rs
@@ -89,19 +89,22 @@ fn path_segment(p: &mut Parser<'_>, mode: Mode, first: bool) -> Option<Completed
// test qual_paths
// type X = <A as B>::Output;
// fn foo() { <usize as Default>::default(); }
- if first && p.eat(T![<]) {
+ if first && p.at(T![<]) {
+ let m = p.start();
+ p.bump(T![<]);
// test_err angled_path_without_qual
// type X = <()>;
// type Y = <A as B>;
types::type_(p);
if p.eat(T![as]) {
if is_use_path_start(p) {
- types::path_type(p);
+ types::path_type_bounds(p, true);
} else {
p.error("expected a trait");
}
}
p.expect(T![>]);
+ m.complete(p, TYPE_ANCHOR);
if !p.at(T![::]) {
p.error("expected `::`");
}
diff --git a/src/tools/rust-analyzer/crates/parser/src/grammar/types.rs b/src/tools/rust-analyzer/crates/parser/src/grammar/types.rs
index 9d31e43..908440b 100644
--- a/src/tools/rust-analyzer/crates/parser/src/grammar/types.rs
+++ b/src/tools/rust-analyzer/crates/parser/src/grammar/types.rs
@@ -330,15 +330,6 @@ fn bare_dyn_trait_type(p: &mut Parser<'_>) {
m.complete(p, DYN_TRAIT_TYPE);
}
-// test path_type
-// type A = Foo;
-// type B = ::Foo;
-// type C = self::Foo;
-// type D = super::Foo;
-pub(super) fn path_type(p: &mut Parser<'_>) {
- path_type_bounds(p, true);
-}
-
// test macro_call_type
// type A = foo!();
// type B = crate::foo!();
@@ -365,6 +356,11 @@ fn path_or_macro_type(p: &mut Parser<'_>, allow_bounds: bool) {
}
}
+// test path_type
+// type A = Foo;
+// type B = ::Foo;
+// type C = self::Foo;
+// type D = super::Foo;
pub(super) fn path_type_bounds(p: &mut Parser<'_>, allow_bounds: bool) {
assert!(paths::is_path_start(p));
let m = p.start();
diff --git a/src/tools/rust-analyzer/crates/parser/src/syntax_kind/generated.rs b/src/tools/rust-analyzer/crates/parser/src/syntax_kind/generated.rs
index b172750..f534546 100644
--- a/src/tools/rust-analyzer/crates/parser/src/syntax_kind/generated.rs
+++ b/src/tools/rust-analyzer/crates/parser/src/syntax_kind/generated.rs
@@ -291,6 +291,7 @@ pub enum SyntaxKind {
TUPLE_STRUCT_PAT,
TUPLE_TYPE,
TYPE_ALIAS,
+ TYPE_ANCHOR,
TYPE_ARG,
TYPE_BOUND,
TYPE_BOUND_LIST,
@@ -463,6 +464,7 @@ pub const fn text(self) -> &'static str {
| TUPLE_STRUCT_PAT
| TUPLE_TYPE
| TYPE_ALIAS
+ | TYPE_ANCHOR
| TYPE_ARG
| TYPE_BOUND
| TYPE_BOUND_LIST
diff --git a/src/tools/rust-analyzer/crates/parser/test_data/generated/runner.rs b/src/tools/rust-analyzer/crates/parser/test_data/generated/runner.rs
index 030d8e0..6ec4192 100644
--- a/src/tools/rust-analyzer/crates/parser/test_data/generated/runner.rs
+++ b/src/tools/rust-analyzer/crates/parser/test_data/generated/runner.rs
@@ -83,6 +83,10 @@ fn break_ambiguity() {
#[test]
fn cast_expr() { run_and_expect_no_errors("test_data/parser/inline/ok/cast_expr.rs"); }
#[test]
+ fn closure_binder() {
+ run_and_expect_no_errors("test_data/parser/inline/ok/closure_binder.rs");
+ }
+ #[test]
fn closure_body_underscore_assignment() {
run_and_expect_no_errors(
"test_data/parser/inline/ok/closure_body_underscore_assignment.rs",
@@ -872,6 +876,10 @@ fn tuple_pat_leading_comma() {
run_and_expect_errors("test_data/parser/inline/err/tuple_pat_leading_comma.rs");
}
#[test]
+ fn type_bounds_macro_call_recovery() {
+ run_and_expect_errors("test_data/parser/inline/err/type_bounds_macro_call_recovery.rs");
+ }
+ #[test]
fn type_in_array_recover() {
run_and_expect_errors("test_data/parser/inline/err/type_in_array_recover.rs");
}
diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0024_many_type_parens.rast b/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0024_many_type_parens.rast
index f0dbc9b..025c12e 100644
--- a/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0024_many_type_parens.rast
+++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/err/0024_many_type_parens.rast
@@ -186,13 +186,14 @@
TUPLE_EXPR
L_PAREN "("
CLOSURE_EXPR
- FOR_KW "for"
- GENERIC_PARAM_LIST
- L_ANGLE "<"
- LIFETIME_PARAM
- LIFETIME
- LIFETIME_IDENT "'a"
- R_ANGLE ">"
+ CLOSURE_BINDER
+ FOR_KW "for"
+ GENERIC_PARAM_LIST
+ L_ANGLE "<"
+ LIFETIME_PARAM
+ LIFETIME
+ LIFETIME_IDENT "'a"
+ R_ANGLE ">"
WHITESPACE " "
BIN_EXPR
BIN_EXPR
diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/err/angled_path_without_qual.rast b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/err/angled_path_without_qual.rast
index 0529e97..53fbe0b 100644
--- a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/err/angled_path_without_qual.rast
+++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/err/angled_path_without_qual.rast
@@ -10,11 +10,12 @@
PATH_TYPE
PATH
PATH_SEGMENT
- L_ANGLE "<"
- TUPLE_TYPE
- L_PAREN "("
- R_PAREN ")"
- R_ANGLE ">"
+ TYPE_ANCHOR
+ L_ANGLE "<"
+ TUPLE_TYPE
+ L_PAREN "("
+ R_PAREN ")"
+ R_ANGLE ">"
SEMICOLON ";"
WHITESPACE "\n"
TYPE_ALIAS
@@ -28,21 +29,22 @@
PATH_TYPE
PATH
PATH_SEGMENT
- L_ANGLE "<"
- PATH_TYPE
- PATH
- PATH_SEGMENT
- NAME_REF
- IDENT "A"
- WHITESPACE " "
- AS_KW "as"
- WHITESPACE " "
- PATH_TYPE
- PATH
- PATH_SEGMENT
- NAME_REF
- IDENT "B"
- R_ANGLE ">"
+ TYPE_ANCHOR
+ L_ANGLE "<"
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "A"
+ WHITESPACE " "
+ AS_KW "as"
+ WHITESPACE " "
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "B"
+ R_ANGLE ">"
SEMICOLON ";"
WHITESPACE "\n"
error 13: expected `::`
diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/err/type_bounds_macro_call_recovery.rast b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/err/type_bounds_macro_call_recovery.rast
new file mode 100644
index 0000000..4722beb
--- /dev/null
+++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/err/type_bounds_macro_call_recovery.rast
@@ -0,0 +1,112 @@
+SOURCE_FILE
+ FN
+ FN_KW "fn"
+ WHITESPACE " "
+ NAME
+ IDENT "foo"
+ GENERIC_PARAM_LIST
+ L_ANGLE "<"
+ TYPE_PARAM
+ NAME
+ IDENT "T"
+ COLON ":"
+ WHITESPACE " "
+ TYPE_BOUND_LIST
+ TYPE_BOUND
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "T"
+ ERROR
+ BANG "!"
+ TOKEN_TREE
+ L_BRACK "["
+ R_BRACK "]"
+ COMMA ","
+ WHITESPACE " "
+ TYPE_PARAM
+ NAME
+ IDENT "T"
+ COLON ":"
+ WHITESPACE " "
+ TYPE_BOUND_LIST
+ TYPE_BOUND
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "T"
+ ERROR
+ BANG "!"
+ COMMA ","
+ WHITESPACE " "
+ TYPE_PARAM
+ NAME
+ IDENT "T"
+ COLON ":"
+ WHITESPACE " "
+ TYPE_BOUND_LIST
+ TYPE_BOUND
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "T"
+ ERROR
+ BANG "!"
+ TOKEN_TREE
+ L_CURLY "{"
+ R_CURLY "}"
+ R_ANGLE ">"
+ PARAM_LIST
+ L_PAREN "("
+ R_PAREN ")"
+ WHITESPACE " "
+ RET_TYPE
+ THIN_ARROW "->"
+ WHITESPACE " "
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "Box"
+ GENERIC_ARG_LIST
+ L_ANGLE "<"
+ TYPE_ARG
+ DYN_TRAIT_TYPE
+ TYPE_BOUND_LIST
+ TYPE_BOUND
+ MACRO_TYPE
+ MACRO_CALL
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "T"
+ BANG "!"
+ WHITESPACE " "
+ PLUS "+"
+ WHITESPACE " "
+ TYPE_BOUND
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "T"
+ ERROR
+ BANG "!"
+ TOKEN_TREE
+ L_CURLY "{"
+ R_CURLY "}"
+ R_ANGLE ">"
+ WHITESPACE " "
+ BLOCK_EXPR
+ STMT_LIST
+ L_CURLY "{"
+ R_CURLY "}"
+ WHITESPACE "\n"
+error 12: unexpected `!` in type path, macro calls are not allowed here
+error 21: unexpected `!` in type path, macro calls are not allowed here
+error 28: unexpected `!` in type path, macro calls are not allowed here
+error 43: expected `{`, `[`, `(`
+error 48: unexpected `!` in type path, macro calls are not allowed here
diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/err/type_bounds_macro_call_recovery.rs b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/err/type_bounds_macro_call_recovery.rs
new file mode 100644
index 0000000..517404fd
--- /dev/null
+++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/err/type_bounds_macro_call_recovery.rs
@@ -0,0 +1 @@
+fn foo<T: T![], T: T!, T: T!{}>() -> Box<T! + T!{}> {}
diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/call_expr.rast b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/call_expr.rast
index 19cc8d5..7c1d894 100644
--- a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/call_expr.rast
+++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/call_expr.rast
@@ -88,13 +88,14 @@
PATH
PATH
PATH_SEGMENT
- L_ANGLE "<"
- PATH_TYPE
- PATH
- PATH_SEGMENT
- NAME_REF
- IDENT "Foo"
- R_ANGLE ">"
+ TYPE_ANCHOR
+ L_ANGLE "<"
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "Foo"
+ R_ANGLE ">"
COLON2 "::"
PATH_SEGMENT
NAME_REF
@@ -119,21 +120,22 @@
PATH
PATH
PATH_SEGMENT
- L_ANGLE "<"
- PATH_TYPE
- PATH
- PATH_SEGMENT
- NAME_REF
- IDENT "Foo"
- WHITESPACE " "
- AS_KW "as"
- WHITESPACE " "
- PATH_TYPE
- PATH
- PATH_SEGMENT
- NAME_REF
- IDENT "Trait"
- R_ANGLE ">"
+ TYPE_ANCHOR
+ L_ANGLE "<"
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "Foo"
+ WHITESPACE " "
+ AS_KW "as"
+ WHITESPACE " "
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "Trait"
+ R_ANGLE ">"
COLON2 "::"
PATH_SEGMENT
NAME_REF
diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/closure_binder.rast b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/closure_binder.rast
new file mode 100644
index 0000000..c04dbe1
--- /dev/null
+++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/closure_binder.rast
@@ -0,0 +1,36 @@
+SOURCE_FILE
+ FN
+ FN_KW "fn"
+ WHITESPACE " "
+ NAME
+ IDENT "main"
+ PARAM_LIST
+ L_PAREN "("
+ R_PAREN ")"
+ WHITESPACE " "
+ BLOCK_EXPR
+ STMT_LIST
+ L_CURLY "{"
+ WHITESPACE " "
+ EXPR_STMT
+ CLOSURE_EXPR
+ CLOSURE_BINDER
+ FOR_KW "for"
+ GENERIC_PARAM_LIST
+ L_ANGLE "<"
+ LIFETIME_PARAM
+ LIFETIME
+ LIFETIME_IDENT "'a"
+ R_ANGLE ">"
+ WHITESPACE " "
+ PARAM_LIST
+ PIPE "|"
+ PIPE "|"
+ WHITESPACE " "
+ TUPLE_EXPR
+ L_PAREN "("
+ R_PAREN ")"
+ SEMICOLON ";"
+ WHITESPACE " "
+ R_CURLY "}"
+ WHITESPACE "\n"
diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/closure_binder.rs b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/closure_binder.rs
new file mode 100644
index 0000000..a6d8aaf
--- /dev/null
+++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/closure_binder.rs
@@ -0,0 +1 @@
+fn main() { for<'a> || (); }
diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/lambda_expr.rast b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/lambda_expr.rast
index c25ad84..ea401d2 100644
--- a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/lambda_expr.rast
+++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/lambda_expr.rast
@@ -202,13 +202,14 @@
WHITESPACE "\n "
EXPR_STMT
CLOSURE_EXPR
- FOR_KW "for"
- GENERIC_PARAM_LIST
- L_ANGLE "<"
- LIFETIME_PARAM
- LIFETIME
- LIFETIME_IDENT "'a"
- R_ANGLE ">"
+ CLOSURE_BINDER
+ FOR_KW "for"
+ GENERIC_PARAM_LIST
+ L_ANGLE "<"
+ LIFETIME_PARAM
+ LIFETIME
+ LIFETIME_IDENT "'a"
+ R_ANGLE ">"
WHITESPACE " "
PARAM_LIST
PIPE "|"
@@ -222,13 +223,14 @@
WHITESPACE "\n "
EXPR_STMT
CLOSURE_EXPR
- FOR_KW "for"
- GENERIC_PARAM_LIST
- L_ANGLE "<"
- LIFETIME_PARAM
- LIFETIME
- LIFETIME_IDENT "'a"
- R_ANGLE ">"
+ CLOSURE_BINDER
+ FOR_KW "for"
+ GENERIC_PARAM_LIST
+ L_ANGLE "<"
+ LIFETIME_PARAM
+ LIFETIME
+ LIFETIME_IDENT "'a"
+ R_ANGLE ">"
WHITESPACE " "
MOVE_KW "move"
WHITESPACE " "
diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/qual_paths.rast b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/qual_paths.rast
index 8c66cfe..10f8a6a 100644
--- a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/qual_paths.rast
+++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/qual_paths.rast
@@ -11,21 +11,22 @@
PATH
PATH
PATH_SEGMENT
- L_ANGLE "<"
- PATH_TYPE
- PATH
- PATH_SEGMENT
- NAME_REF
- IDENT "A"
- WHITESPACE " "
- AS_KW "as"
- WHITESPACE " "
- PATH_TYPE
- PATH
- PATH_SEGMENT
- NAME_REF
- IDENT "B"
- R_ANGLE ">"
+ TYPE_ANCHOR
+ L_ANGLE "<"
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "A"
+ WHITESPACE " "
+ AS_KW "as"
+ WHITESPACE " "
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "B"
+ R_ANGLE ">"
COLON2 "::"
PATH_SEGMENT
NAME_REF
@@ -51,21 +52,22 @@
PATH
PATH
PATH_SEGMENT
- L_ANGLE "<"
- PATH_TYPE
- PATH
- PATH_SEGMENT
- NAME_REF
- IDENT "usize"
- WHITESPACE " "
- AS_KW "as"
- WHITESPACE " "
- PATH_TYPE
- PATH
- PATH_SEGMENT
- NAME_REF
- IDENT "Default"
- R_ANGLE ">"
+ TYPE_ANCHOR
+ L_ANGLE "<"
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "usize"
+ WHITESPACE " "
+ AS_KW "as"
+ WHITESPACE " "
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "Default"
+ R_ANGLE ">"
COLON2 "::"
PATH_SEGMENT
NAME_REF
diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/type_path_in_pattern.rast b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/type_path_in_pattern.rast
index 297f757..3d27afa 100644
--- a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/type_path_in_pattern.rast
+++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/type_path_in_pattern.rast
@@ -19,10 +19,11 @@
PATH
PATH
PATH_SEGMENT
- L_ANGLE "<"
- INFER_TYPE
- UNDERSCORE "_"
- R_ANGLE ">"
+ TYPE_ANCHOR
+ L_ANGLE "<"
+ INFER_TYPE
+ UNDERSCORE "_"
+ R_ANGLE ">"
COLON2 "::"
PATH_SEGMENT
NAME_REF
diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/where_clause.rast b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/where_clause.rast
index a3cbe45..9adfe2c 100644
--- a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/where_clause.rast
+++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/where_clause.rast
@@ -84,21 +84,22 @@
PATH
PATH
PATH_SEGMENT
- L_ANGLE "<"
- PATH_TYPE
- PATH
- PATH_SEGMENT
- NAME_REF
- IDENT "T"
- WHITESPACE " "
- AS_KW "as"
- WHITESPACE " "
- PATH_TYPE
- PATH
- PATH_SEGMENT
- NAME_REF
- IDENT "Iterator"
- R_ANGLE ">"
+ TYPE_ANCHOR
+ L_ANGLE "<"
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "T"
+ WHITESPACE " "
+ AS_KW "as"
+ WHITESPACE " "
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "Iterator"
+ R_ANGLE ">"
COLON2 "::"
PATH_SEGMENT
NAME_REF
diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0036_fully_qualified.rast b/src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0036_fully_qualified.rast
index 9382020..2fecb1c 100644
--- a/src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0036_fully_qualified.rast
+++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0036_fully_qualified.rast
@@ -45,21 +45,22 @@
PATH
PATH
PATH_SEGMENT
- L_ANGLE "<"
- PATH_TYPE
- PATH
- PATH_SEGMENT
- NAME_REF
- IDENT "S"
- WHITESPACE " "
- AS_KW "as"
- WHITESPACE " "
- PATH_TYPE
- PATH
- PATH_SEGMENT
- NAME_REF
- IDENT "Iterator"
- R_ANGLE ">"
+ TYPE_ANCHOR
+ L_ANGLE "<"
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "S"
+ WHITESPACE " "
+ AS_KW "as"
+ WHITESPACE " "
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "Iterator"
+ R_ANGLE ">"
COLON2 "::"
PATH_SEGMENT
NAME_REF
diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0042_ufcs_call_list.rast b/src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0042_ufcs_call_list.rast
index a536b0e..d1d1ffa 100644
--- a/src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0042_ufcs_call_list.rast
+++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0042_ufcs_call_list.rast
@@ -107,13 +107,14 @@
PATH
PATH
PATH_SEGMENT
- L_ANGLE "<"
- PATH_TYPE
- PATH
- PATH_SEGMENT
- NAME_REF
- IDENT "Foo"
- R_ANGLE ">"
+ TYPE_ANCHOR
+ L_ANGLE "<"
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "Foo"
+ R_ANGLE ">"
COLON2 "::"
PATH_SEGMENT
NAME_REF
diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0067_where_for_pred.rast b/src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0067_where_for_pred.rast
index cd3b21a..8bf1090 100644
--- a/src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0067_where_for_pred.rast
+++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/ok/0067_where_for_pred.rast
@@ -288,26 +288,27 @@
PATH
PATH
PATH_SEGMENT
- L_ANGLE "<"
- REF_TYPE
- AMP "&"
- LIFETIME
- LIFETIME_IDENT "'a"
+ TYPE_ANCHOR
+ L_ANGLE "<"
+ REF_TYPE
+ AMP "&"
+ LIFETIME
+ LIFETIME_IDENT "'a"
+ WHITESPACE " "
+ PATH_TYPE
+ PATH
+ PATH_SEGMENT
+ NAME_REF
+ IDENT "T"
+ WHITESPACE " "
+ AS_KW "as"
WHITESPACE " "
PATH_TYPE
PATH
PATH_SEGMENT
NAME_REF
- IDENT "T"
- WHITESPACE " "
- AS_KW "as"
- WHITESPACE " "
- PATH_TYPE
- PATH
- PATH_SEGMENT
- NAME_REF
- IDENT "Baz"
- R_ANGLE ">"
+ IDENT "Baz"
+ R_ANGLE ">"
COLON2 "::"
PATH_SEGMENT
NAME_REF
diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl.rs
index 11dbd92..ad28599 100644
--- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl.rs
+++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl.rs
@@ -10,6 +10,7 @@
use std::fmt;
+use intern::Symbol;
use proc_macro::bridge;
mod token_stream;
@@ -112,3 +113,135 @@ fn literal_kind_to_internal(kind: bridge::LitKind) -> tt::LitKind {
bridge::LitKind::ErrWithGuar => tt::LitKind::Err(()),
}
}
+
+pub(super) fn literal_from_str<Span: Copy>(
+ s: &str,
+ span: Span,
+) -> Result<bridge::Literal<Span, Symbol>, ()> {
+ use proc_macro::bridge::LitKind;
+ use rustc_lexer::{LiteralKind, Token, TokenKind};
+
+ let mut tokens = rustc_lexer::tokenize(s);
+ let minus_or_lit = tokens.next().unwrap_or(Token { kind: TokenKind::Eof, len: 0 });
+
+ let lit = if minus_or_lit.kind == TokenKind::Minus {
+ let lit = tokens.next().ok_or(())?;
+ if !matches!(
+ lit.kind,
+ TokenKind::Literal { kind: LiteralKind::Int { .. } | LiteralKind::Float { .. }, .. }
+ ) {
+ return Err(());
+ }
+ lit
+ } else {
+ minus_or_lit
+ };
+
+ if tokens.next().is_some() {
+ return Err(());
+ }
+
+ let TokenKind::Literal { kind, suffix_start } = lit.kind else { return Err(()) };
+ let (kind, start_offset, end_offset) = match kind {
+ LiteralKind::Int { .. } => (LitKind::Integer, 0, 0),
+ LiteralKind::Float { .. } => (LitKind::Float, 0, 0),
+ LiteralKind::Char { terminated } => (LitKind::Char, 1, terminated as usize),
+ LiteralKind::Byte { terminated } => (LitKind::Byte, 2, terminated as usize),
+ LiteralKind::Str { terminated } => (LitKind::Str, 1, terminated as usize),
+ LiteralKind::ByteStr { terminated } => (LitKind::ByteStr, 2, terminated as usize),
+ LiteralKind::CStr { terminated } => (LitKind::CStr, 2, terminated as usize),
+ LiteralKind::RawStr { n_hashes } => (
+ LitKind::StrRaw(n_hashes.unwrap_or_default()),
+ 2 + n_hashes.unwrap_or_default() as usize,
+ 1 + n_hashes.unwrap_or_default() as usize,
+ ),
+ LiteralKind::RawByteStr { n_hashes } => (
+ LitKind::ByteStrRaw(n_hashes.unwrap_or_default()),
+ 3 + n_hashes.unwrap_or_default() as usize,
+ 1 + n_hashes.unwrap_or_default() as usize,
+ ),
+ LiteralKind::RawCStr { n_hashes } => (
+ LitKind::CStrRaw(n_hashes.unwrap_or_default()),
+ 3 + n_hashes.unwrap_or_default() as usize,
+ 1 + n_hashes.unwrap_or_default() as usize,
+ ),
+ };
+
+ let (lit, suffix) = s.split_at(suffix_start as usize);
+ let lit = &lit[start_offset..lit.len() - end_offset];
+ let suffix = match suffix {
+ "" | "_" => None,
+ suffix => Some(Symbol::intern(suffix)),
+ };
+
+ Ok(bridge::Literal { kind, symbol: Symbol::intern(lit), suffix, span })
+}
+
+pub(super) fn from_token_tree<Span: Copy>(
+ tree: bridge::TokenTree<TokenStream<Span>, Span, Symbol>,
+) -> TokenStream<Span> {
+ match tree {
+ bridge::TokenTree::Group(group) => {
+ let group = TopSubtree::from_bridge(group);
+ TokenStream { token_trees: group.0 }
+ }
+
+ bridge::TokenTree::Ident(ident) => {
+ let text = ident.sym;
+ let ident: tt::Ident<Span> = tt::Ident {
+ sym: text,
+ span: ident.span,
+ is_raw: if ident.is_raw { tt::IdentIsRaw::Yes } else { tt::IdentIsRaw::No },
+ };
+ let leaf = tt::Leaf::from(ident);
+ let tree = tt::TokenTree::from(leaf);
+ TokenStream { token_trees: vec![tree] }
+ }
+
+ bridge::TokenTree::Literal(literal) => {
+ let token_trees =
+ if let Some((_minus, symbol)) = literal.symbol.as_str().split_once('-') {
+ let punct = tt::Punct {
+ spacing: tt::Spacing::Alone,
+ span: literal.span,
+ char: '-' as char,
+ };
+ let leaf: tt::Leaf<Span> = tt::Leaf::from(punct);
+ let minus_tree = tt::TokenTree::from(leaf);
+
+ let literal = tt::Literal {
+ symbol: Symbol::intern(symbol),
+ suffix: literal.suffix,
+ span: literal.span,
+ kind: literal_kind_to_internal(literal.kind),
+ };
+ let leaf: tt::Leaf<Span> = tt::Leaf::from(literal);
+ let tree = tt::TokenTree::from(leaf);
+ vec![minus_tree, tree]
+ } else {
+ let literal = tt::Literal {
+ symbol: literal.symbol,
+ suffix: literal.suffix,
+ span: literal.span,
+ kind: literal_kind_to_internal(literal.kind),
+ };
+
+ let leaf: tt::Leaf<Span> = tt::Leaf::from(literal);
+ let tree = tt::TokenTree::from(leaf);
+ vec![tree]
+ };
+ TokenStream { token_trees }
+ }
+
+ bridge::TokenTree::Punct(p) => {
+ let punct = tt::Punct {
+ char: p.ch as char,
+ spacing: if p.joint { tt::Spacing::Joint } else { tt::Spacing::Alone },
+ span: p.span,
+ };
+ let leaf = tt::Leaf::from(punct);
+ let tree = tt::TokenTree::from(leaf);
+ TokenStream { token_trees: vec![tree] }
+ }
+ }
+}
diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs
index e0c6e68..5d1271b 100644
--- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs
+++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs
@@ -14,16 +14,7 @@
use span::{FIXUP_ERASED_FILE_AST_ID_MARKER, Span};
use tt::{TextRange, TextSize};
-use crate::server_impl::{TopSubtree, literal_kind_to_internal, token_stream::TokenStreamBuilder};
-mod tt {
- pub use tt::*;
-
- pub type TokenTree = ::tt::TokenTree<super::Span>;
- pub type Leaf = ::tt::Leaf<super::Span>;
- pub type Literal = ::tt::Literal<super::Span>;
- pub type Punct = ::tt::Punct<super::Span>;
- pub type Ident = ::tt::Ident<super::Span>;
-}
+use crate::server_impl::{from_token_tree, literal_from_str, token_stream::TokenStreamBuilder};
type TokenStream = crate::server_impl::TokenStream<Span>;
@@ -62,66 +53,7 @@ fn literal_from_str(
&mut self,
s: &str,
) -> Result<bridge::Literal<Self::Span, Self::Symbol>, ()> {
- use proc_macro::bridge::LitKind;
- use rustc_lexer::{LiteralKind, Token, TokenKind};
-
- let mut tokens = rustc_lexer::tokenize(s);
- let minus_or_lit = tokens.next().unwrap_or(Token { kind: TokenKind::Eof, len: 0 });
-
- let lit = if minus_or_lit.kind == TokenKind::Minus {
- let lit = tokens.next().ok_or(())?;
- if !matches!(
- lit.kind,
- TokenKind::Literal {
- kind: LiteralKind::Int { .. } | LiteralKind::Float { .. },
- ..
- }
- ) {
- return Err(());
- }
- lit
- } else {
- minus_or_lit
- };
-
- if tokens.next().is_some() {
- return Err(());
- }
-
- let TokenKind::Literal { kind, suffix_start } = lit.kind else { return Err(()) };
- let (kind, start_offset, end_offset) = match kind {
- LiteralKind::Int { .. } => (LitKind::Integer, 0, 0),
- LiteralKind::Float { .. } => (LitKind::Float, 0, 0),
- LiteralKind::Char { terminated } => (LitKind::Char, 1, terminated as usize),
- LiteralKind::Byte { terminated } => (LitKind::Byte, 2, terminated as usize),
- LiteralKind::Str { terminated } => (LitKind::Str, 1, terminated as usize),
- LiteralKind::ByteStr { terminated } => (LitKind::ByteStr, 2, terminated as usize),
- LiteralKind::CStr { terminated } => (LitKind::CStr, 2, terminated as usize),
- LiteralKind::RawStr { n_hashes } => (
- LitKind::StrRaw(n_hashes.unwrap_or_default()),
- 2 + n_hashes.unwrap_or_default() as usize,
- 1 + n_hashes.unwrap_or_default() as usize,
- ),
- LiteralKind::RawByteStr { n_hashes } => (
- LitKind::ByteStrRaw(n_hashes.unwrap_or_default()),
- 3 + n_hashes.unwrap_or_default() as usize,
- 1 + n_hashes.unwrap_or_default() as usize,
- ),
- LiteralKind::RawCStr { n_hashes } => (
- LitKind::CStrRaw(n_hashes.unwrap_or_default()),
- 3 + n_hashes.unwrap_or_default() as usize,
- 1 + n_hashes.unwrap_or_default() as usize,
- ),
- };
-
- let (lit, suffix) = s.split_at(suffix_start as usize);
- let lit = &lit[start_offset..lit.len() - end_offset];
- let suffix = match suffix {
- "" | "_" => None,
- suffix => Some(Symbol::intern(suffix)),
- };
-
- Ok(bridge::Literal { kind, symbol: Symbol::intern(lit), suffix, span: self.call_site })
+ literal_from_str(s, self.call_site)
}
fn emit_diagnostic(&mut self, _: bridge::Diagnostic<Self::Span>) {
@@ -149,70 +81,7 @@ fn from_token_tree(
&mut self,
tree: bridge::TokenTree<Self::TokenStream, Self::Span, Self::Symbol>,
) -> Self::TokenStream {
- match tree {
- bridge::TokenTree::Group(group) => {
- let group = TopSubtree::from_bridge(group);
- TokenStream { token_trees: group.0 }
- }
-
- bridge::TokenTree::Ident(ident) => {
- let text = ident.sym;
- let ident: tt::Ident = tt::Ident {
- sym: text,
- span: ident.span,
- is_raw: if ident.is_raw { tt::IdentIsRaw::Yes } else { tt::IdentIsRaw::No },
- };
- let leaf = tt::Leaf::from(ident);
- let tree = tt::TokenTree::from(leaf);
- TokenStream { token_trees: vec![tree] }
- }
-
- bridge::TokenTree::Literal(literal) => {
- let token_trees =
- if let Some((_minus, symbol)) = literal.symbol.as_str().split_once('-') {
- let punct = tt::Punct {
- spacing: tt::Spacing::Alone,
- span: literal.span,
- char: '-' as char,
- };
- let leaf: tt::Leaf = tt::Leaf::from(punct);
- let minus_tree = tt::TokenTree::from(leaf);
-
- let literal = tt::Literal {
- symbol: Symbol::intern(symbol),
- suffix: literal.suffix,
- span: literal.span,
- kind: literal_kind_to_internal(literal.kind),
- };
- let leaf: tt::Leaf = tt::Leaf::from(literal);
- let tree = tt::TokenTree::from(leaf);
- vec![minus_tree, tree]
- } else {
- let literal = tt::Literal {
- symbol: literal.symbol,
- suffix: literal.suffix,
- span: literal.span,
- kind: literal_kind_to_internal(literal.kind),
- };
-
- let leaf: tt::Leaf = tt::Leaf::from(literal);
- let tree = tt::TokenTree::from(leaf);
- vec![tree]
- };
- TokenStream { token_trees }
- }
-
- bridge::TokenTree::Punct(p) => {
- let punct = tt::Punct {
- char: p.ch as char,
- spacing: if p.joint { tt::Spacing::Joint } else { tt::Spacing::Alone },
- span: p.span,
- };
- let leaf = tt::Leaf::from(punct);
- let tree = tt::TokenTree::from(leaf);
- TokenStream { token_trees: vec![tree] }
- }
- }
+ from_token_tree(tree)
}
fn expand_expr(&mut self, self_: &Self::TokenStream) -> Result<Self::TokenStream, ()> {
diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs
index d55b269..b493b32 100644
--- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs
+++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs
@@ -5,23 +5,9 @@
use intern::Symbol;
use proc_macro::bridge::{self, server};
-use crate::server_impl::{TopSubtree, literal_kind_to_internal, token_stream::TokenStreamBuilder};
-mod tt {
- pub use span::TokenId;
+use crate::server_impl::{from_token_tree, literal_from_str, token_stream::TokenStreamBuilder};
- pub use tt::*;
-
- pub type TokenTree = ::tt::TokenTree<TokenId>;
- pub type Leaf = ::tt::Leaf<TokenId>;
- pub type Literal = ::tt::Literal<TokenId>;
- pub type Punct = ::tt::Punct<TokenId>;
- pub type Ident = ::tt::Ident<TokenId>;
-}
-type TokenTree = tt::TokenTree;
-type Punct = tt::Punct;
-type Spacing = tt::Spacing;
-type Literal = tt::Literal;
-type Span = tt::TokenId;
+type Span = span::TokenId;
type TokenStream = crate::server_impl::TokenStream<Span>;
pub struct FreeFunctions;
@@ -49,67 +35,7 @@ fn literal_from_str(
&mut self,
s: &str,
) -> Result<bridge::Literal<Self::Span, Self::Symbol>, ()> {
- use proc_macro::bridge::LitKind;
- use rustc_lexer::{LiteralKind, Token, TokenKind};
-
- let mut tokens = rustc_lexer::tokenize(s);
- let minus_or_lit = tokens.next().unwrap_or(Token { kind: TokenKind::Eof, len: 0 });
-
- let lit = if minus_or_lit.kind == TokenKind::Minus {
- let lit = tokens.next().ok_or(())?;
- if !matches!(
- lit.kind,
- TokenKind::Literal {
- kind: LiteralKind::Int { .. } | LiteralKind::Float { .. },
- ..
- }
- ) {
- return Err(());
- }
- lit
- } else {
- minus_or_lit
- };
-
- if tokens.next().is_some() {
- return Err(());
- }
-
- let TokenKind::Literal { kind, suffix_start } = lit.kind else { return Err(()) };
-
- let (kind, start_offset, end_offset) = match kind {
- LiteralKind::Int { .. } => (LitKind::Integer, 0, 0),
- LiteralKind::Float { .. } => (LitKind::Float, 0, 0),
- LiteralKind::Char { terminated } => (LitKind::Char, 1, terminated as usize),
- LiteralKind::Byte { terminated } => (LitKind::Byte, 2, terminated as usize),
- LiteralKind::Str { terminated } => (LitKind::Str, 1, terminated as usize),
- LiteralKind::ByteStr { terminated } => (LitKind::ByteStr, 2, terminated as usize),
- LiteralKind::CStr { terminated } => (LitKind::CStr, 2, terminated as usize),
- LiteralKind::RawStr { n_hashes } => (
- LitKind::StrRaw(n_hashes.unwrap_or_default()),
- 2 + n_hashes.unwrap_or_default() as usize,
- 1 + n_hashes.unwrap_or_default() as usize,
- ),
- LiteralKind::RawByteStr { n_hashes } => (
- LitKind::ByteStrRaw(n_hashes.unwrap_or_default()),
- 3 + n_hashes.unwrap_or_default() as usize,
- 1 + n_hashes.unwrap_or_default() as usize,
- ),
- LiteralKind::RawCStr { n_hashes } => (
- LitKind::CStrRaw(n_hashes.unwrap_or_default()),
- 3 + n_hashes.unwrap_or_default() as usize,
- 1 + n_hashes.unwrap_or_default() as usize,
- ),
- };
-
- let (lit, suffix) = s.split_at(suffix_start as usize);
- let lit = &lit[start_offset..lit.len() - end_offset];
- let suffix = match suffix {
- "" | "_" => None,
- suffix => Some(Symbol::intern(suffix)),
- };
-
- Ok(bridge::Literal { kind, symbol: Symbol::intern(lit), suffix, span: self.call_site })
+ literal_from_str(s, self.call_site)
}
fn emit_diagnostic(&mut self, _: bridge::Diagnostic<Self::Span>) {}
@@ -135,69 +61,7 @@ fn from_token_tree(
&mut self,
tree: bridge::TokenTree<Self::TokenStream, Self::Span, Self::Symbol>,
) -> Self::TokenStream {
- match tree {
- bridge::TokenTree::Group(group) => {
- let group = TopSubtree::from_bridge(group);
- TokenStream { token_trees: group.0 }
- }
-
- bridge::TokenTree::Ident(ident) => {
- let ident: tt::Ident = tt::Ident {
- sym: ident.sym,
- span: ident.span,
- is_raw: if ident.is_raw { tt::IdentIsRaw::Yes } else { tt::IdentIsRaw::No },
- };
- let leaf = tt::Leaf::from(ident);
- let tree = TokenTree::from(leaf);
- TokenStream { token_trees: vec![tree] }
- }
-
- bridge::TokenTree::Literal(literal) => {
- let token_trees =
- if let Some((_minus, symbol)) = literal.symbol.as_str().split_once('-') {
- let punct = tt::Punct {
- spacing: tt::Spacing::Alone,
- span: literal.span,
- char: '-' as char,
- };
- let leaf: tt::Leaf = tt::Leaf::from(punct);
- let minus_tree = tt::TokenTree::from(leaf);
-
- let literal = Literal {
- symbol: Symbol::intern(symbol),
- suffix: literal.suffix,
- span: literal.span,
- kind: literal_kind_to_internal(literal.kind),
- };
- let leaf: tt::Leaf = tt::Leaf::from(literal);
- let tree = tt::TokenTree::from(leaf);
- vec![minus_tree, tree]
- } else {
- let literal = Literal {
- symbol: literal.symbol,
- suffix: literal.suffix,
- span: literal.span,
- kind: literal_kind_to_internal(literal.kind),
- };
-
- let leaf: tt::Leaf = tt::Leaf::from(literal);
- let tree = tt::TokenTree::from(leaf);
- vec![tree]
- };
- TokenStream { token_trees }
- }
-
- bridge::TokenTree::Punct(p) => {
- let punct = Punct {
- char: p.ch as char,
- spacing: if p.joint { Spacing::Joint } else { Spacing::Alone },
- span: p.span,
- };
- let leaf = tt::Leaf::from(punct);
- let tree = TokenTree::from(leaf);
- TokenStream { token_trees: vec![tree] }
- }
- }
+ from_token_tree(tree)
}
fn expand_expr(&mut self, self_: &Self::TokenStream) -> Result<Self::TokenStream, ()> {
@@ -337,6 +201,8 @@ fn with_symbol_string(symbol: &Self::Symbol, f: impl FnOnce(&str)) {
#[cfg(test)]
mod tests {
+ use span::TokenId;
+
use super::*;
#[test]
@@ -345,18 +211,18 @@ fn test_ra_server_to_string() {
token_trees: vec![
tt::TokenTree::Leaf(tt::Leaf::Ident(tt::Ident {
sym: Symbol::intern("struct"),
- span: tt::TokenId(0),
+ span: TokenId(0),
is_raw: tt::IdentIsRaw::No,
})),
tt::TokenTree::Leaf(tt::Leaf::Ident(tt::Ident {
sym: Symbol::intern("T"),
- span: tt::TokenId(0),
+ span: TokenId(0),
is_raw: tt::IdentIsRaw::No,
})),
tt::TokenTree::Subtree(tt::Subtree {
delimiter: tt::Delimiter {
- open: tt::TokenId(0),
- close: tt::TokenId(0),
+ open: TokenId(0),
+ close: TokenId(0),
kind: tt::DelimiterKind::Brace,
},
len: 0,
@@ -372,8 +238,8 @@ fn test_ra_server_from_str() {
let subtree_paren_a = vec![
tt::TokenTree::Subtree(tt::Subtree {
delimiter: tt::Delimiter {
- open: tt::TokenId(0),
- close: tt::TokenId(0),
+ open: TokenId(0),
+ close: TokenId(0),
kind: tt::DelimiterKind::Parenthesis,
},
len: 1,
@@ -381,24 +247,24 @@ fn test_ra_server_from_str() {
tt::TokenTree::Leaf(tt::Leaf::Ident(tt::Ident {
is_raw: tt::IdentIsRaw::No,
sym: Symbol::intern("a"),
- span: tt::TokenId(0),
+ span: TokenId(0),
})),
];
- let t1 = TokenStream::from_str("(a)", tt::TokenId(0)).unwrap();
+ let t1 = TokenStream::from_str("(a)", TokenId(0)).unwrap();
assert_eq!(t1.token_trees.len(), 2);
assert!(t1.token_trees[0..2] == subtree_paren_a);
- let t2 = TokenStream::from_str("(a);", tt::TokenId(0)).unwrap();
+ let t2 = TokenStream::from_str("(a);", TokenId(0)).unwrap();
assert_eq!(t2.token_trees.len(), 3);
assert!(t2.token_trees[0..2] == subtree_paren_a);
- let underscore = TokenStream::from_str("_", tt::TokenId(0)).unwrap();
+ let underscore = TokenStream::from_str("_", TokenId(0)).unwrap();
assert!(
underscore.token_trees[0]
== tt::TokenTree::Leaf(tt::Leaf::Ident(tt::Ident {
sym: Symbol::intern("_"),
- span: tt::TokenId(0),
+ span: TokenId(0),
is_raw: tt::IdentIsRaw::No,
}))
);
diff --git a/src/tools/rust-analyzer/crates/project-model/src/cargo_workspace.rs b/src/tools/rust-analyzer/crates/project-model/src/cargo_workspace.rs
index 6e730b1..bb02284 100644
--- a/src/tools/rust-analyzer/crates/project-model/src/cargo_workspace.rs
+++ b/src/tools/rust-analyzer/crates/project-model/src/cargo_workspace.rs
@@ -431,12 +431,6 @@ fn fetch_metadata_(
.ok_or(cargo_metadata::Error::NoJson)?;
Ok((cargo_metadata::MetadataCommand::parse(stdout)?, None))
})()
- .map(|(metadata, error)| {
- (
- metadata,
- error.map(|e| e.context(format!("Failed to run `{:?}`", meta.cargo_command()))),
- )
- })
.with_context(|| format!("Failed to run `{:?}`", meta.cargo_command()))
}
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs
index d1ca8c1..5cbea9c 100644
--- a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs
+++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs
@@ -1192,7 +1192,7 @@ pub fn change_source_root_parent_map(
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum LinkedProject {
ProjectManifest(ProjectManifest),
- InlineJsonProject(ProjectJson),
+ InlineProjectJson(ProjectJson),
}
impl From<ProjectManifest> for LinkedProject {
@@ -1203,7 +1203,7 @@ fn from(v: ProjectManifest) -> Self {
impl From<ProjectJson> for LinkedProject {
fn from(v: ProjectJson) -> Self {
- LinkedProject::InlineJsonProject(v)
+ LinkedProject::InlineProjectJson(v)
}
}
@@ -1597,6 +1597,16 @@ pub fn diagnostics(&self, source_root: Option<SourceRootId>) -> DiagnosticsConfi
term_search_borrowck: self.assist_termSearch_borrowcheck(source_root).to_owned(),
}
}
+
+ pub fn diagnostic_fixes(&self, source_root: Option<SourceRootId>) -> DiagnosticsConfig {
+ // We always want to show quickfixes for diagnostics, even when diagnostics/experimental diagnostics are disabled.
+ DiagnosticsConfig {
+ enabled: true,
+ disable_experimental: false,
+ ..self.diagnostics(source_root)
+ }
+ }
+
pub fn expand_proc_attr_macros(&self) -> bool {
self.procMacro_enable().to_owned() && self.procMacro_attributes_enable().to_owned()
}
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs
index 69983a6..6d46ce6 100644
--- a/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs
+++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs
@@ -1439,7 +1439,7 @@ pub(crate) fn handle_code_action(
};
let assists = snap.analysis.assists_with_fixes(
&assists_config,
- &snap.config.diagnostics(Some(source_root)),
+ &snap.config.diagnostic_fixes(Some(source_root)),
resolve,
frange,
)?;
@@ -1530,7 +1530,7 @@ pub(crate) fn handle_code_action_resolve(
let assists = snap.analysis.assists_with_fixes(
&assists_config,
- &snap.config.diagnostics(Some(source_root)),
+ &snap.config.diagnostic_fixes(Some(source_root)),
AssistResolveStrategy::Single(assist_resolve),
frange,
)?;
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/utils.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/utils.rs
index 673eaa5..5bea7084 100644
--- a/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/utils.rs
+++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/utils.rs
@@ -108,8 +108,7 @@ pub(crate) fn show_and_log_error(&mut self, message: String, additional_info: Op
/// edge users from being upset!
pub(crate) fn poke_rust_analyzer_developer(&mut self, message: String) {
let from_source_build = option_env!("POKE_RA_DEVS").is_some();
- let profiling_enabled = std::env::var("RA_PROFILE").is_ok();
- if from_source_build || profiling_enabled {
+ if from_source_build {
self.show_and_log_error(message, None);
}
}
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs
index ae9e3e9..4677880 100644
--- a/src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs
+++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs
@@ -292,7 +292,7 @@ pub(crate) fn fetch_workspaces(
if let (Some(_command), Some(path)) = (&discover_command, &path) {
let build = linked_projects.iter().find_map(|project| match project {
- LinkedProject::InlineJsonProject(it) => it.crate_by_buildfile(path),
+ LinkedProject::InlineProjectJson(it) => it.crate_by_buildfile(path),
_ => None,
});
@@ -318,7 +318,7 @@ pub(crate) fn fetch_workspaces(
&progress,
)
}
- LinkedProject::InlineJsonProject(it) => {
+ LinkedProject::InlineProjectJson(it) => {
let workspace = project_model::ProjectWorkspace::load_inline(
it.clone(),
&cargo_config,
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/main.rs b/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/main.rs
index f6bcb56..59073af 100644
--- a/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/main.rs
+++ b/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/main.rs
@@ -975,10 +975,6 @@ fn preserves_dos_line_endings() {
}
fn out_dirs_check_impl(root_contains_symlink: bool) {
- if skip_slow_tests() {
- return;
- }
-
let mut server = Project::with_fixture(
r###"
//- /Cargo.toml
@@ -1130,12 +1126,18 @@ fn main() {
#[test]
fn out_dirs_check() {
+ if skip_slow_tests() {
+ return;
+ }
out_dirs_check_impl(false);
}
#[test]
#[cfg(not(windows))] // windows requires elevated permissions to create symlinks
fn root_contains_symlink_out_dirs_check() {
+ if skip_slow_tests() {
+ return;
+ }
out_dirs_check_impl(true);
}
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/ratoml.rs b/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/ratoml.rs
index 485f322..cac7efd 100644
--- a/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/ratoml.rs
+++ b/src/tools/rust-analyzer/crates/rust-analyzer/tests/slow-tests/ratoml.rs
@@ -439,6 +439,7 @@ enum Value {
}
#[test]
+#[ignore = "flaky test that tends to hang"]
fn ratoml_inherit_config_from_ws_root() {
if skip_slow_tests() {
return;
diff --git a/src/tools/rust-analyzer/crates/syntax/rust.ungram b/src/tools/rust-analyzer/crates/syntax/rust.ungram
index 10abca7..c81da06 100644
--- a/src/tools/rust-analyzer/crates/syntax/rust.ungram
+++ b/src/tools/rust-analyzer/crates/syntax/rust.ungram
@@ -39,7 +39,10 @@
| NameRef GenericArgList?
| NameRef ParenthesizedArgList RetType?
| NameRef ReturnTypeSyntax
-| '<' Type ('as' PathType)? '>'
+| TypeAnchor
+
+TypeAnchor =
+ '<' Type ('as' PathType)? '>'
ReturnTypeSyntax =
'(' '..' ')'
@@ -98,7 +101,7 @@
'where' predicates:(WherePred (',' WherePred)* ','?)
WherePred =
- ('for' GenericParamList)? (Lifetime | Type) ':' TypeBoundList?
+ ('for' GenericParamList)? (Lifetime | Type) ':' TypeBoundList?
//*************************//
diff --git a/src/tools/rust-analyzer/crates/syntax/src/ast/generated/nodes.rs b/src/tools/rust-analyzer/crates/syntax/src/ast/generated/nodes.rs
index cd9f4db..04c7e8a 100644
--- a/src/tools/rust-analyzer/crates/syntax/src/ast/generated/nodes.rs
+++ b/src/tools/rust-analyzer/crates/syntax/src/ast/generated/nodes.rs
@@ -1232,21 +1232,13 @@ pub fn parenthesized_arg_list(&self) -> Option<ParenthesizedArgList> {
support::child(&self.syntax)
}
#[inline]
- pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) }
- #[inline]
pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
#[inline]
pub fn return_type_syntax(&self) -> Option<ReturnTypeSyntax> { support::child(&self.syntax) }
#[inline]
- pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
+ pub fn type_anchor(&self) -> Option<TypeAnchor> { support::child(&self.syntax) }
#[inline]
pub fn coloncolon_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![::]) }
- #[inline]
- pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
- #[inline]
- pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
- #[inline]
- pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
}
pub struct PathType {
pub(crate) syntax: SyntaxNode,
@@ -1739,6 +1731,21 @@ pub fn default_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax
#[inline]
pub fn type_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![type]) }
}
+pub struct TypeAnchor {
+ pub(crate) syntax: SyntaxNode,
+}
+impl TypeAnchor {
+ #[inline]
+ pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) }
+ #[inline]
+ pub fn ty(&self) -> Option<Type> { support::child(&self.syntax) }
+ #[inline]
+ pub fn l_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![<]) }
+ #[inline]
+ pub fn r_angle_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![>]) }
+ #[inline]
+ pub fn as_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![as]) }
+}
pub struct TypeArg {
pub(crate) syntax: SyntaxNode,
}
@@ -7108,6 +7115,42 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("TypeAlias").field("syntax", &self.syntax).finish()
}
}
+impl AstNode for TypeAnchor {
+ #[inline]
+ fn kind() -> SyntaxKind
+ where
+ Self: Sized,
+ {
+ TYPE_ANCHOR
+ }
+ #[inline]
+ fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ANCHOR }
+ #[inline]
+ fn cast(syntax: SyntaxNode) -> Option<Self> {
+ if Self::can_cast(syntax.kind()) {
+ Some(Self { syntax })
+ } else {
+ None
+ }
+ }
+ #[inline]
+ fn syntax(&self) -> &SyntaxNode { &self.syntax }
+}
+impl hash::Hash for TypeAnchor {
+ fn hash<H: hash::Hasher>(&self, state: &mut H) { self.syntax.hash(state); }
+}
+impl Eq for TypeAnchor {}
+impl PartialEq for TypeAnchor {
+ fn eq(&self, other: &Self) -> bool { self.syntax == other.syntax }
+}
+impl Clone for TypeAnchor {
+ fn clone(&self) -> Self { Self { syntax: self.syntax.clone() } }
+}
+impl fmt::Debug for TypeAnchor {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ f.debug_struct("TypeAnchor").field("syntax", &self.syntax).finish()
+ }
+}
impl AstNode for TypeArg {
#[inline]
fn kind() -> SyntaxKind
@@ -10624,6 +10667,11 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
}
}
+impl std::fmt::Display for TypeAnchor {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ std::fmt::Display::fmt(self.syntax(), f)
+ }
+}
impl std::fmt::Display for TypeArg {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(self.syntax(), f)
diff --git a/src/tools/rust-analyzer/crates/syntax/src/ast/node_ext.rs b/src/tools/rust-analyzer/crates/syntax/src/ast/node_ext.rs
index b9ccd34..dcf8534 100644
--- a/src/tools/rust-analyzer/crates/syntax/src/ast/node_ext.rs
+++ b/src/tools/rust-analyzer/crates/syntax/src/ast/node_ext.rs
@@ -276,18 +276,15 @@ pub fn kind(&self) -> Option<PathSegmentKind> {
_ => PathSegmentKind::Name(name_ref),
}
} else {
- match self.syntax().first_child_or_token()?.kind() {
- T![<] => {
- // <T> or <T as Trait>
- // T is any TypeRef, Trait has to be a PathType
- let mut type_refs =
- self.syntax().children().filter(|node| ast::Type::can_cast(node.kind()));
- let type_ref = type_refs.next().and_then(ast::Type::cast);
- let trait_ref = type_refs.next().and_then(ast::PathType::cast);
- PathSegmentKind::Type { type_ref, trait_ref }
- }
- _ => return None,
- }
+ let anchor = self.type_anchor()?;
+ // FIXME: Move this over to `ast::TypeAnchor`
+ // <T> or <T as Trait>
+ // T is any TypeRef, Trait has to be a PathType
+ let mut type_refs =
+ anchor.syntax().children().filter(|node| ast::Type::can_cast(node.kind()));
+ let type_ref = type_refs.next().and_then(ast::Type::cast);
+ let trait_ref = type_refs.next().and_then(ast::PathType::cast);
+ PathSegmentKind::Type { type_ref, trait_ref }
};
Some(res)
}
@@ -473,7 +470,7 @@ pub fn for_trait_name_ref(name_ref: &ast::NameRef) -> Option<ast::Impl> {
// [#15778](https://github.com/rust-lang/rust-analyzer/issues/15778)
impl ast::PathSegment {
pub fn qualifying_trait(&self) -> Option<ast::PathType> {
- let mut path_types = support::children(self.syntax());
+ let mut path_types = support::children(self.type_anchor()?.syntax());
let first = path_types.next()?;
path_types.next().or(Some(first))
}
diff --git a/src/tools/rust-analyzer/crates/test-fixture/src/lib.rs b/src/tools/rust-analyzer/crates/test-fixture/src/lib.rs
index 96e1301..8eb48f8 100644
--- a/src/tools/rust-analyzer/crates/test-fixture/src/lib.rs
+++ b/src/tools/rust-analyzer/crates/test-fixture/src/lib.rs
@@ -538,6 +538,21 @@ pub fn disallow_cfg(_attr: TokenStream, input: TokenStream) -> TokenStream {
disabled: false,
},
),
+ (
+ r#"
+#[proc_macro_attribute]
+pub fn generate_suffixed_type(_attr: TokenStream, input: TokenStream) -> TokenStream {
+ input
+}
+"#
+ .into(),
+ ProcMacro {
+ name: Symbol::intern("generate_suffixed_type"),
+ kind: ProcMacroKind::Attr,
+ expander: sync::Arc::new(GenerateSuffixedTypeProcMacroExpander),
+ disabled: false,
+ },
+ ),
])
}
@@ -919,3 +934,57 @@ fn expand(
Ok(subtree.clone())
}
}
+
+// Generates a new type by adding a suffix to the original name
+#[derive(Debug)]
+struct GenerateSuffixedTypeProcMacroExpander;
+impl ProcMacroExpander for GenerateSuffixedTypeProcMacroExpander {
+ fn expand(
+ &self,
+ subtree: &TopSubtree,
+ _attrs: Option<&TopSubtree>,
+ _env: &Env,
+ _def_site: Span,
+ call_site: Span,
+ _mixed_site: Span,
+ _current_dir: String,
+ ) -> Result<TopSubtree, ProcMacroExpansionError> {
+ let TokenTree::Leaf(Leaf::Ident(ident)) = &subtree.0[1] else {
+ return Err(ProcMacroExpansionError::Panic("incorrect Input".into()));
+ };
+
+ let ident = match ident.sym.as_str() {
+ "struct" => {
+ let TokenTree::Leaf(Leaf::Ident(ident)) = &subtree.0[2] else {
+ return Err(ProcMacroExpansionError::Panic("incorrect Input".into()));
+ };
+ ident
+ }
+
+ "enum" => {
+ let TokenTree::Leaf(Leaf::Ident(ident)) = &subtree.0[4] else {
+ return Err(ProcMacroExpansionError::Panic("incorrect Input".into()));
+ };
+ ident
+ }
+
+ _ => {
+ return Err(ProcMacroExpansionError::Panic("incorrect Input".into()));
+ }
+ };
+
+ let generated_ident = tt::Ident {
+ sym: Symbol::intern(&format!("{}Suffix", ident.sym)),
+ span: ident.span,
+ is_raw: tt::IdentIsRaw::No,
+ };
+
+ let ret = quote! { call_site =>
+ #subtree
+
+ struct #generated_ident;
+ };
+
+ Ok(ret)
+ }
+}
diff --git a/src/tools/rust-analyzer/docs/book/src/non_cargo_based_projects.md b/src/tools/rust-analyzer/docs/book/src/non_cargo_based_projects.md
index 151f875..bbdb48b 100644
--- a/src/tools/rust-analyzer/docs/book/src/non_cargo_based_projects.md
+++ b/src/tools/rust-analyzer/docs/book/src/non_cargo_based_projects.md
@@ -5,7 +5,7 @@
rust-analyzer in the `rust-project.json` format:
```typescript
-interface JsonProject {
+interface ProjectJson {
/// Path to the sysroot directory.
///
/// The sysroot is where rustc looks for the
diff --git a/src/tools/rust-analyzer/editors/code/package-lock.json b/src/tools/rust-analyzer/editors/code/package-lock.json
index 18fb097..ab43114 100644
--- a/src/tools/rust-analyzer/editors/code/package-lock.json
+++ b/src/tools/rust-analyzer/editors/code/package-lock.json
@@ -5500,9 +5500,9 @@
}
},
"node_modules/tar-fs": {
- "version": "2.1.2",
- "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.2.tgz",
- "integrity": "sha512-EsaAXwxmx8UB7FRKqeozqEPop69DXcmYwTQwXvyAPF352HJsPdkVhvTaDPYqfNgruveJIJy3TA2l+2zj8LJIJA==",
+ "version": "2.1.3",
+ "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.3.tgz",
+ "integrity": "sha512-090nwYJDmlhwFwEW3QQl+vaNnxsO2yVsd45eTKRBzSzu+hlb1w2K9inVq5b0ngXuLVqQ4ApvsUHHnu/zQNkWAg==",
"dev": true,
"license": "MIT",
"optional": true,
diff --git a/src/tools/rust-analyzer/rust-version b/src/tools/rust-analyzer/rust-version
index 5b47d1b..af0dd5c 100644
--- a/src/tools/rust-analyzer/rust-version
+++ b/src/tools/rust-analyzer/rust-version
@@ -1 +1 @@
-a8e4c68dcb4dc1e48a0db294c5323cab0227fcb9
+7c10378e1fee5ddc6573b916aeb884ab10e0de17
diff --git a/tests/assembly/targets/targets-elf.rs b/tests/assembly/targets/targets-elf.rs
index 3255591..edf1654 100644
--- a/tests/assembly/targets/targets-elf.rs
+++ b/tests/assembly/targets/targets-elf.rs
@@ -259,6 +259,12 @@
//@ revisions: i686_wrs_vxworks
//@ [i686_wrs_vxworks] compile-flags: --target i686-wrs-vxworks
//@ [i686_wrs_vxworks] needs-llvm-components: x86
+//@ revisions: loongarch32_unknown_none
+//@ [loongarch32_unknown_none] compile-flags: --target loongarch32-unknown-none
+//@ [loongarch32_unknown_none] needs-llvm-components: loongarch
+//@ revisions: loongarch32_unknown_none_softfloat
+//@ [loongarch32_unknown_none_softfloat] compile-flags: --target loongarch32-unknown-none-softfloat
+//@ [loongarch32_unknown_none_softfloat] needs-llvm-components: loongarch
//@ revisions: loongarch64_unknown_linux_gnu
//@ [loongarch64_unknown_linux_gnu] compile-flags: --target loongarch64-unknown-linux-gnu
//@ [loongarch64_unknown_linux_gnu] needs-llvm-components: loongarch
diff --git a/tests/crashes/135863.rs b/tests/crashes/135863.rs
deleted file mode 100644
index a0ff598..0000000
--- a/tests/crashes/135863.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-//@ known-bug: #135863
-struct A;
-
-impl A {
- fn len(self: &&B) {}
-}
-
-fn main() {
- A.len()
-}
diff --git a/tests/crashes/139825.rs b/tests/crashes/139825.rs
deleted file mode 100644
index 8c5b6b8..0000000
--- a/tests/crashes/139825.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-//@ known-bug: #139825
-//@compile-flags: --check-cfg=cfg(docsrs,test) --crate-type lib
-struct a
-where
- for<#[cfg(b)] c> u8:;
diff --git a/tests/debuginfo/type-names.rs b/tests/debuginfo/type-names.rs
index 3c7eab7..ac61fef 100644
--- a/tests/debuginfo/type-names.rs
+++ b/tests/debuginfo/type-names.rs
@@ -19,7 +19,7 @@
// gdb-check:type = type_names::GenericStruct<type_names::mod1::Struct2, type_names::mod1::mod2::Struct3>
// gdb-command:whatis generic_struct2
-// gdb-check:type = type_names::GenericStruct<type_names::Struct1, extern "fastcall" fn(isize) -> usize>
+// gdb-check:type = type_names::GenericStruct<type_names::Struct1, extern "system" fn(isize) -> usize>
// gdb-command:whatis mod_struct
// gdb-check:type = type_names::mod1::Struct2
@@ -379,7 +379,7 @@ fn main() {
let simple_struct = Struct1;
let generic_struct1: GenericStruct<mod1::Struct2, mod1::mod2::Struct3> =
GenericStruct(PhantomData);
- let generic_struct2: GenericStruct<Struct1, extern "fastcall" fn(isize) -> usize> =
+ let generic_struct2: GenericStruct<Struct1, extern "system" fn(isize) -> usize> =
GenericStruct(PhantomData);
let mod_struct = mod1::Struct2;
diff --git a/tests/incremental/hashes/trait_defs.rs b/tests/incremental/hashes/trait_defs.rs
index cb8716d..7141ddb 100644
--- a/tests/incremental/hashes/trait_defs.rs
+++ b/tests/incremental/hashes/trait_defs.rs
@@ -440,7 +440,7 @@ trait TraitAddExternModifier {
// Change extern "C" to extern "stdcall"
#[cfg(any(cfail1,cfail4))]
-trait TraitChangeExternCToRustIntrinsic {
+trait TraitChangeExternCToExternSystem {
// --------------------------------------------------------------
// -------------------------
// --------------------------------------------------------------
@@ -458,7 +458,7 @@ trait TraitChangeExternCToRustIntrinsic {
#[rustc_clean(cfg="cfail3")]
#[rustc_clean(except="opt_hir_owner_nodes,fn_sig", cfg="cfail5")]
#[rustc_clean(cfg="cfail6")]
- extern "stdcall" fn method();
+ extern "system" fn method();
}
diff --git a/tests/mir-opt/early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff
index 7b94a4c..22ebe2f 100644
--- a/tests/mir-opt/early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff
+++ b/tests/mir-opt/early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff
@@ -32,16 +32,12 @@
StorageDead(_4);
_9 = discriminant((_3.0: Option2<u32>));
- switchInt(move _9) -> [0: bb2, 1: bb3, 2: bb4, otherwise: bb9];
-+ StorageLive(_12);
+ _12 = discriminant((_3.1: Option2<bool>));
-+ StorageLive(_13);
+ _13 = Ne(copy _9, move _12);
-+ StorageDead(_12);
+ switchInt(move _13) -> [0: bb7, otherwise: bb1];
}
bb1: {
-+ StorageDead(_13);
_0 = const 1_u32;
- goto -> bb8;
+ goto -> bb5;
@@ -100,7 +96,6 @@
+ }
+
+ bb7: {
-+ StorageDead(_13);
+ switchInt(copy _9) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb6];
}
}
diff --git a/tests/mir-opt/early_otherwise_branch.opt4.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch.opt4.EarlyOtherwiseBranch.diff
index f52795b..0da0eb3 100644
--- a/tests/mir-opt/early_otherwise_branch.opt4.EarlyOtherwiseBranch.diff
+++ b/tests/mir-opt/early_otherwise_branch.opt4.EarlyOtherwiseBranch.diff
@@ -32,16 +32,12 @@
StorageDead(_4);
_9 = discriminant((_3.0: Option2<u32>));
- switchInt(move _9) -> [0: bb2, 1: bb3, 2: bb4, otherwise: bb9];
-+ StorageLive(_12);
+ _12 = discriminant((_3.1: Option2<u32>));
-+ StorageLive(_13);
+ _13 = Ne(copy _9, move _12);
-+ StorageDead(_12);
+ switchInt(move _13) -> [0: bb7, otherwise: bb1];
}
bb1: {
-+ StorageDead(_13);
_0 = const 1_u32;
- goto -> bb8;
+ goto -> bb5;
@@ -100,7 +96,6 @@
+ }
+
+ bb7: {
-+ StorageDead(_13);
+ switchInt(copy _9) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb6];
}
}
diff --git a/tests/mir-opt/early_otherwise_branch.opt5.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch.opt5.EarlyOtherwiseBranch.diff
index b7447ef..b13d21e 100644
--- a/tests/mir-opt/early_otherwise_branch.opt5.EarlyOtherwiseBranch.diff
+++ b/tests/mir-opt/early_otherwise_branch.opt5.EarlyOtherwiseBranch.diff
@@ -20,13 +20,11 @@
StorageDead(_5);
StorageDead(_4);
- switchInt(copy (_3.0: u32)) -> [1: bb2, 2: bb3, 3: bb4, otherwise: bb1];
-+ StorageLive(_6);
+ _6 = Ne(copy (_3.0: u32), copy (_3.1: u32));
+ switchInt(move _6) -> [0: bb6, otherwise: bb1];
}
bb1: {
-+ StorageDead(_6);
_0 = const 0_u32;
- goto -> bb8;
+ goto -> bb5;
@@ -70,7 +68,6 @@
- bb8: {
- StorageDead(_3);
- return;
-+ StorageDead(_6);
+ switchInt(copy (_3.0: u32)) -> [1: bb4, 2: bb3, 3: bb2, otherwise: bb1];
}
}
diff --git a/tests/mir-opt/early_otherwise_branch.rs b/tests/mir-opt/early_otherwise_branch.rs
index 382c38c..19a5d25 100644
--- a/tests/mir-opt/early_otherwise_branch.rs
+++ b/tests/mir-opt/early_otherwise_branch.rs
@@ -1,6 +1,10 @@
//@ test-mir-pass: EarlyOtherwiseBranch
//@ compile-flags: -Zmir-enable-passes=+UnreachableEnumBranching
+#![feature(custom_mir, core_intrinsics)]
+
+use std::intrinsics::mir::*;
+
enum Option2<T> {
Some(T),
None,
@@ -124,6 +128,34 @@ fn opt5_failed_type(x: u32, y: u64) -> u32 {
}
}
+// EMIT_MIR early_otherwise_branch.target_self.EarlyOtherwiseBranch.diff
+#[custom_mir(dialect = "runtime")]
+fn target_self(val: i32) {
+ // CHECK-LABEL: fn target_self(
+ // CHECK: Ne(
+ // CHECK-NEXT: switchInt
+ mir! {
+ {
+ Goto(bb1)
+ }
+ bb1 = {
+ match val {
+ 0 => bb2,
+ _ => bb1,
+ }
+ }
+ bb2 = {
+ match val {
+ 0 => bb3,
+ _ => bb1,
+ }
+ }
+ bb3 = {
+ Return()
+ }
+ }
+}
+
fn main() {
opt1(None, Some(0));
opt2(None, Some(0));
@@ -131,4 +163,5 @@ fn main() {
opt4(Option2::None, Option2::Some(0));
opt5(0, 0);
opt5_failed(0, 0);
+ target_self(1);
}
diff --git a/tests/mir-opt/early_otherwise_branch.target_self.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch.target_self.EarlyOtherwiseBranch.diff
new file mode 100644
index 0000000..4f70847
--- /dev/null
+++ b/tests/mir-opt/early_otherwise_branch.target_self.EarlyOtherwiseBranch.diff
@@ -0,0 +1,28 @@
+- // MIR for `target_self` before EarlyOtherwiseBranch
++ // MIR for `target_self` after EarlyOtherwiseBranch
+
+ fn target_self(_1: i32) -> () {
+ let mut _0: ();
++ let mut _2: bool;
+
+ bb0: {
+ goto -> bb1;
+ }
+
+ bb1: {
+- switchInt(copy _1) -> [0: bb2, otherwise: bb1];
++ _2 = Ne(copy _1, copy _1);
++ switchInt(move _2) -> [0: bb3, otherwise: bb1];
+ }
+
+ bb2: {
+- switchInt(copy _1) -> [0: bb3, otherwise: bb1];
++ return;
+ }
+
+ bb3: {
+- return;
++ switchInt(copy _1) -> [0: bb2, otherwise: bb1];
+ }
+ }
+
diff --git a/tests/mir-opt/early_otherwise_branch_3_element_tuple.opt2.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch_3_element_tuple.opt2.EarlyOtherwiseBranch.diff
index 831d8cb..e087816 100644
--- a/tests/mir-opt/early_otherwise_branch_3_element_tuple.opt2.EarlyOtherwiseBranch.diff
+++ b/tests/mir-opt/early_otherwise_branch_3_element_tuple.opt2.EarlyOtherwiseBranch.diff
@@ -42,16 +42,12 @@
StorageDead(_5);
_14 = discriminant((_4.0: Option2<u32>));
- switchInt(move _14) -> [0: bb2, 1: bb4, 2: bb6, otherwise: bb12];
-+ StorageLive(_18);
+ _18 = discriminant((_4.1: Option2<u32>));
-+ StorageLive(_19);
+ _19 = Ne(copy _14, move _18);
-+ StorageDead(_18);
+ switchInt(move _19) -> [0: bb10, otherwise: bb1];
}
bb1: {
-+ StorageDead(_19);
_0 = const 1_u32;
- goto -> bb11;
+ goto -> bb8;
@@ -134,7 +130,6 @@
+ }
+
+ bb10: {
-+ StorageDead(_19);
+ switchInt(copy _14) -> [0: bb2, 1: bb3, 2: bb4, otherwise: bb9];
}
}
diff --git a/tests/run-make/atomic-lock-free/atomic_lock_free.rs b/tests/run-make/atomic-lock-free/atomic_lock_free.rs
index b49c504..e8bbd42 100644
--- a/tests/run-make/atomic-lock-free/atomic_lock_free.rs
+++ b/tests/run-make/atomic-lock-free/atomic_lock_free.rs
@@ -1,9 +1,20 @@
#![feature(no_core, intrinsics, lang_items)]
+#![feature(adt_const_params)]
#![crate_type = "rlib"]
#![no_core]
+pub enum AtomicOrdering {
+ // These values must match the compiler's `AtomicOrdering` defined in
+ // `rustc_middle/src/ty/consts/int.rs`!
+ Relaxed = 0,
+ Release = 1,
+ Acquire = 2,
+ AcqRel = 3,
+ SeqCst = 4,
+}
+
#[rustc_intrinsic]
-unsafe fn atomic_xadd_seqcst<T>(dst: *mut T, src: T) -> T;
+unsafe fn atomic_xadd<T, const ORD: AtomicOrdering>(dst: *mut T, src: T) -> T;
#[lang = "sized"]
trait Sized {}
@@ -11,55 +22,58 @@ trait Sized {}
trait Copy {}
#[lang = "freeze"]
trait Freeze {}
+#[lang = "const_param_ty"]
+pub trait ConstParamTy {}
impl<T: ?Sized> Copy for *mut T {}
+impl ConstParamTy for AtomicOrdering {}
#[cfg(target_has_atomic = "8")]
pub unsafe fn atomic_u8(x: *mut u8) {
- atomic_xadd_seqcst(x, 1);
- atomic_xadd_seqcst(x, 1);
+ atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
+ atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
}
#[cfg(target_has_atomic = "8")]
pub unsafe fn atomic_i8(x: *mut i8) {
- atomic_xadd_seqcst(x, 1);
+ atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
}
#[cfg(target_has_atomic = "16")]
pub unsafe fn atomic_u16(x: *mut u16) {
- atomic_xadd_seqcst(x, 1);
+ atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
}
#[cfg(target_has_atomic = "16")]
pub unsafe fn atomic_i16(x: *mut i16) {
- atomic_xadd_seqcst(x, 1);
+ atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
}
#[cfg(target_has_atomic = "32")]
pub unsafe fn atomic_u32(x: *mut u32) {
- atomic_xadd_seqcst(x, 1);
+ atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
}
#[cfg(target_has_atomic = "32")]
pub unsafe fn atomic_i32(x: *mut i32) {
- atomic_xadd_seqcst(x, 1);
+ atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
}
#[cfg(target_has_atomic = "64")]
pub unsafe fn atomic_u64(x: *mut u64) {
- atomic_xadd_seqcst(x, 1);
+ atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
}
#[cfg(target_has_atomic = "64")]
pub unsafe fn atomic_i64(x: *mut i64) {
- atomic_xadd_seqcst(x, 1);
+ atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
}
#[cfg(target_has_atomic = "128")]
pub unsafe fn atomic_u128(x: *mut u128) {
- atomic_xadd_seqcst(x, 1);
+ atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
}
#[cfg(target_has_atomic = "128")]
pub unsafe fn atomic_i128(x: *mut i128) {
- atomic_xadd_seqcst(x, 1);
+ atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
}
#[cfg(target_has_atomic = "ptr")]
pub unsafe fn atomic_usize(x: *mut usize) {
- atomic_xadd_seqcst(x, 1);
+ atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
}
#[cfg(target_has_atomic = "ptr")]
pub unsafe fn atomic_isize(x: *mut isize) {
- atomic_xadd_seqcst(x, 1);
+ atomic_xadd::<_, { AtomicOrdering::SeqCst }>(x, 1);
}
diff --git a/tests/run-make/cpp-global-destructors/rmake.rs b/tests/run-make/cpp-global-destructors/rmake.rs
index 9bc5c84..92aeb67 100644
--- a/tests/run-make/cpp-global-destructors/rmake.rs
+++ b/tests/run-make/cpp-global-destructors/rmake.rs
@@ -6,15 +6,11 @@
//@ ignore-cross-compile
// Reason: the compiled binary is executed
-//@ ignore-none
-// Reason: no-std is not supported.
//@ ignore-wasm32
//@ ignore-wasm64
// Reason: compiling C++ to WASM may cause problems.
-// Neither of these are tested in full CI.
-//@ ignore-nvptx64-nvidia-cuda
-// Reason: can't find crate "std"
+// Not exercised in full CI, but sgx technically supports std.
//@ ignore-sgx
use run_make_support::{build_native_static_lib_cxx, run, rustc};
diff --git a/tests/run-make/export-executable-symbols/rmake.rs b/tests/run-make/export-executable-symbols/rmake.rs
index 77f9681..dc8c59b 100644
--- a/tests/run-make/export-executable-symbols/rmake.rs
+++ b/tests/run-make/export-executable-symbols/rmake.rs
@@ -10,8 +10,7 @@
// (See #85673)
//@ ignore-wasm32
//@ ignore-wasm64
-//@ ignore-none
-// Reason: no-std is not supported
+//@ needs-target-std
use run_make_support::{bin_name, llvm_readobj, rustc};
diff --git a/tests/run-make/incr-foreign-head-span/rmake.rs b/tests/run-make/incr-foreign-head-span/rmake.rs
index 92e2ed5..d9841b3 100644
--- a/tests/run-make/incr-foreign-head-span/rmake.rs
+++ b/tests/run-make/incr-foreign-head-span/rmake.rs
@@ -5,10 +5,7 @@
// source file from disk during compilation of a downstream crate.
// See https://github.com/rust-lang/rust/issues/86480
-//@ ignore-none
-// Reason: no-std is not supported
-//@ ignore-nvptx64-nvidia-cuda
-// Reason: can't find crate for 'std'
+//@ needs-target-std
use run_make_support::{rfs, rust_lib_name, rustc};
diff --git a/tests/run-make/incr-prev-body-beyond-eof/rmake.rs b/tests/run-make/incr-prev-body-beyond-eof/rmake.rs
index 47dce85..cfa8d5b 100644
--- a/tests/run-make/incr-prev-body-beyond-eof/rmake.rs
+++ b/tests/run-make/incr-prev-body-beyond-eof/rmake.rs
@@ -7,11 +7,7 @@
// was hashed by rustc in addition to the span length, and the fix still
// works.
-//@ ignore-none
-// reason: no-std is not supported
-
-//@ ignore-nvptx64-nvidia-cuda
-// FIXME: can't find crate for `std`
+//@ needs-target-std
use run_make_support::{rfs, rustc};
diff --git a/tests/run-make/incr-test-moved-file/rmake.rs b/tests/run-make/incr-test-moved-file/rmake.rs
index 0ba1b0d..dfba95d 100644
--- a/tests/run-make/incr-test-moved-file/rmake.rs
+++ b/tests/run-make/incr-test-moved-file/rmake.rs
@@ -9,10 +9,7 @@
// for successful compilation.
// See https://github.com/rust-lang/rust/issues/83112
-//@ ignore-none
-// Reason: no-std is not supported
-//@ ignore-nvptx64-nvidia-cuda
-// FIXME: can't find crate for 'std'
+//@ needs-target-std
use run_make_support::{rfs, rustc};
diff --git a/tests/run-make/linker-warning/short-error.txt b/tests/run-make/linker-warning/short-error.txt
index a7f48af..33d0383 100644
--- a/tests/run-make/linker-warning/short-error.txt
+++ b/tests/run-make/linker-warning/short-error.txt
@@ -1,6 +1,6 @@
error: linking with `./fake-linker` failed: exit status: 1
|
- = note: "./fake-linker" "-m64" "/symbols.o" "<2 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,libcfg_if-*,liblibc-*,liballoc-*,librustc_std_workspace_core-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/build-root/test/run-make/linker-warning/rmake_out" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "main" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "run_make_error"
+ = note: "./fake-linker" "-m64" "/symbols.o" "<2 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,libcfg_if-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/build-root/test/run-make/linker-warning/rmake_out" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "main" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "run_make_error"
= note: some arguments are omitted. use `--verbose` to show all linker arguments
= note: error: baz
diff --git a/tests/run-make/moved-src-dir-fingerprint-ice/rmake.rs b/tests/run-make/moved-src-dir-fingerprint-ice/rmake.rs
index f63146e..0d96b40 100644
--- a/tests/run-make/moved-src-dir-fingerprint-ice/rmake.rs
+++ b/tests/run-make/moved-src-dir-fingerprint-ice/rmake.rs
@@ -12,10 +12,7 @@
// sessions.
// See https://github.com/rust-lang/rust/issues/85019
-//@ ignore-none
-// Reason: no-std is not supported
-//@ ignore-nvptx64-nvidia-cuda
-// FIXME: can't find crate for 'std'
+//@ needs-target-std
use run_make_support::{rfs, rust_lib_name, rustc};
diff --git a/tests/rustdoc-json/fn_pointer/abi.rs b/tests/rustdoc-json/fn_pointer/abi.rs
index 34150c0..ec76e0f 100644
--- a/tests/rustdoc-json/fn_pointer/abi.rs
+++ b/tests/rustdoc-json/fn_pointer/abi.rs
@@ -1,4 +1,4 @@
-#![feature(abi_vectorcall)]
+#![feature(rust_cold_cc)]
//@ is "$.index[?(@.name=='AbiRust')].inner.type_alias.type.function_pointer.header.abi" \"Rust\"
pub type AbiRust = fn();
@@ -15,8 +15,5 @@
//@ is "$.index[?(@.name=='AbiSystemUnwind')].inner.type_alias.type.function_pointer.header.abi" '{"System": {"unwind": true}}'
pub type AbiSystemUnwind = extern "system-unwind" fn();
-//@ is "$.index[?(@.name=='AbiVecorcall')].inner.type_alias.type.function_pointer.header.abi.Other" '"\"vectorcall\""'
-pub type AbiVecorcall = extern "vectorcall" fn();
-
-//@ is "$.index[?(@.name=='AbiVecorcallUnwind')].inner.type_alias.type.function_pointer.header.abi.Other" '"\"vectorcall-unwind\""'
-pub type AbiVecorcallUnwind = extern "vectorcall-unwind" fn();
+//@ is "$.index[?(@.name=='AbiRustCold')].inner.type_alias.type.function_pointer.header.abi.Other" '"\"rust-cold\""'
+pub type AbiRustCold = extern "rust-cold" fn();
diff --git a/tests/rustdoc-json/fns/abi.rs b/tests/rustdoc-json/fns/abi.rs
index 7277bb1..3373d13 100644
--- a/tests/rustdoc-json/fns/abi.rs
+++ b/tests/rustdoc-json/fns/abi.rs
@@ -1,4 +1,4 @@
-#![feature(abi_vectorcall)]
+#![feature(rust_cold_cc)]
//@ is "$.index[?(@.name=='abi_rust')].inner.function.header.abi" \"Rust\"
pub fn abi_rust() {}
@@ -15,8 +15,5 @@ pub extern "C-unwind" fn abi_c_unwind() {}
//@ is "$.index[?(@.name=='abi_system_unwind')].inner.function.header.abi" '{"System": {"unwind": true}}'
pub extern "system-unwind" fn abi_system_unwind() {}
-//@ is "$.index[?(@.name=='abi_vectorcall')].inner.function.header.abi.Other" '"\"vectorcall\""'
-pub extern "vectorcall" fn abi_vectorcall() {}
-
-//@ is "$.index[?(@.name=='abi_vectorcall_unwind')].inner.function.header.abi.Other" '"\"vectorcall-unwind\""'
-pub extern "vectorcall-unwind" fn abi_vectorcall_unwind() {}
+//@ is "$.index[?(@.name=='abi_rust_cold')].inner.function.header.abi.Other" '"\"rust-cold\""'
+pub extern "rust-cold" fn abi_rust_cold() {}
diff --git a/tests/rustdoc-json/methods/abi.rs b/tests/rustdoc-json/methods/abi.rs
index fa2387d..be6a117 100644
--- a/tests/rustdoc-json/methods/abi.rs
+++ b/tests/rustdoc-json/methods/abi.rs
@@ -1,5 +1,4 @@
-#![feature(abi_vectorcall)]
-
+#![feature(rust_cold_cc)]
//@ has "$.index[?(@.name=='Foo')]"
pub struct Foo;
@@ -19,11 +18,8 @@ pub extern "C-unwind" fn abi_c_unwind() {}
//@ is "$.index[?(@.name=='abi_system_unwind')].inner.function.header.abi" '{"System": {"unwind": true}}'
pub extern "system-unwind" fn abi_system_unwind() {}
- //@ is "$.index[?(@.name=='abi_vectorcall')].inner.function.header.abi.Other" '"\"vectorcall\""'
- pub extern "vectorcall" fn abi_vectorcall() {}
-
- //@ is "$.index[?(@.name=='abi_vectorcall_unwind')].inner.function.header.abi.Other" '"\"vectorcall-unwind\""'
- pub extern "vectorcall-unwind" fn abi_vectorcall_unwind() {}
+ //@ is "$.index[?(@.name=='abi_rust_cold')].inner.function.header.abi.Other" '"\"rust-cold\""'
+ pub extern "rust-cold" fn abi_rust_cold() {}
}
pub trait Bar {
@@ -42,9 +38,6 @@ extern "C-unwind" fn trait_abi_c_unwind() {}
//@ is "$.index[?(@.name=='trait_abi_system_unwind')].inner.function.header.abi" '{"System": {"unwind": true}}'
extern "system-unwind" fn trait_abi_system_unwind() {}
- //@ is "$.index[?(@.name=='trait_abi_vectorcall')].inner.function.header.abi.Other" '"\"vectorcall\""'
- extern "vectorcall" fn trait_abi_vectorcall() {}
-
- //@ is "$.index[?(@.name=='trait_abi_vectorcall_unwind')].inner.function.header.abi.Other" '"\"vectorcall-unwind\""'
- extern "vectorcall-unwind" fn trait_abi_vectorcall_unwind() {}
+ //@ is "$.index[?(@.name=='trait_abi_rust_cold')].inner.function.header.abi.Other" '"\"rust-cold\""'
+ extern "rust-cold" fn trait_abi_rust_cold() {}
}
diff --git a/tests/rustdoc-json/vectorcall.rs b/tests/rustdoc-json/vectorcall.rs
new file mode 100644
index 0000000..19cac24
--- /dev/null
+++ b/tests/rustdoc-json/vectorcall.rs
@@ -0,0 +1,27 @@
+#![feature(abi_vectorcall)]
+//@ only-x86_64
+
+//@ is "$.index[?(@.name=='AbiVectorcall')].inner.type_alias.type.function_pointer.header.abi.Other" '"\"vectorcall\""'
+pub type AbiVectorcall = extern "vectorcall" fn();
+
+//@ is "$.index[?(@.name=='AbiVectorcallUnwind')].inner.type_alias.type.function_pointer.header.abi.Other" '"\"vectorcall-unwind\""'
+pub type AbiVectorcallUnwind = extern "vectorcall-unwind" fn();
+
+//@ has "$.index[?(@.name=='Foo')]"
+pub struct Foo;
+
+impl Foo {
+ //@ is "$.index[?(@.name=='abi_vectorcall')].inner.function.header.abi.Other" '"\"vectorcall\""'
+ pub extern "vectorcall" fn abi_vectorcall() {}
+
+ //@ is "$.index[?(@.name=='abi_vectorcall_unwind')].inner.function.header.abi.Other" '"\"vectorcall-unwind\""'
+ pub extern "vectorcall-unwind" fn abi_vectorcall_unwind() {}
+}
+
+pub trait Bar {
+ //@ is "$.index[?(@.name=='trait_abi_vectorcall')].inner.function.header.abi.Other" '"\"vectorcall\""'
+ extern "vectorcall" fn trait_abi_vectorcall() {}
+
+ //@ is "$.index[?(@.name=='trait_abi_vectorcall_unwind')].inner.function.header.abi.Other" '"\"vectorcall-unwind\""'
+ extern "vectorcall-unwind" fn trait_abi_vectorcall_unwind() {}
+}
diff --git a/tests/rustdoc-ui/const-evalutation-ice.stderr b/tests/rustdoc-ui/const-evalutation-ice.stderr
index 2410782..5195831 100644
--- a/tests/rustdoc-ui/const-evalutation-ice.stderr
+++ b/tests/rustdoc-ui/const-evalutation-ice.stderr
@@ -2,7 +2,7 @@
--> $DIR/const-evalutation-ice.rs:10:22
|
LL | pub const N: usize = 0 - (mem::size_of::<S>() != 400) as usize;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `N` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui-fulldeps/stable-mir/check_abi.rs b/tests/ui-fulldeps/stable-mir/check_abi.rs
index 71edf81..15ef583 100644
--- a/tests/ui-fulldeps/stable-mir/check_abi.rs
+++ b/tests/ui-fulldeps/stable-mir/check_abi.rs
@@ -21,10 +21,13 @@
ArgAbi, CallConvention, FieldsShape, IntegerLength, PassMode, Primitive, Scalar, ValueAbi,
VariantsShape,
};
+use stable_mir::mir::MirVisitor;
use stable_mir::mir::mono::Instance;
use stable_mir::target::MachineInfo;
+use stable_mir::ty::{AdtDef, RigidTy, Ty, TyKind};
use stable_mir::{CrateDef, CrateItem, CrateItems, ItemKind};
use std::assert_matches::assert_matches;
+use std::collections::HashSet;
use std::convert::TryFrom;
use std::io::Write;
use std::ops::ControlFlow;
@@ -67,6 +70,17 @@ fn test_stable_mir() -> ControlFlow<()> {
assert!(ptr_variadic_fn_abi.c_variadic);
assert_eq!(ptr_variadic_fn_abi.args.len(), 1);
+ let entry = stable_mir::entry_fn().unwrap();
+ let main_fn = Instance::try_from(entry).unwrap();
+ let mut visitor = AdtDefVisitor::default();
+ visitor.visit_body(&main_fn.body().unwrap());
+ let AdtDefVisitor { adt_defs } = visitor;
+ assert_eq!(adt_defs.len(), 1);
+
+ // Test ADT representation options
+ let repr_c_struct = adt_defs.iter().find(|def| def.trimmed_name() == "ReprCStruct").unwrap();
+ assert!(repr_c_struct.repr().flags.is_c);
+
ControlFlow::Continue(())
}
@@ -138,6 +152,20 @@ fn get_item<'a>(
items.iter().find(|crate_item| (item.0 == crate_item.kind()) && crate_item.name() == item.1)
}
+#[derive(Default)]
+struct AdtDefVisitor {
+ adt_defs: HashSet<AdtDef>,
+}
+
+impl MirVisitor for AdtDefVisitor {
+ fn visit_ty(&mut self, ty: &Ty, _location: stable_mir::mir::visit::Location) {
+ if let TyKind::RigidTy(RigidTy::Adt(adt, _)) = ty.kind() {
+ self.adt_defs.insert(adt);
+ }
+ self.super_ty(ty)
+ }
+}
+
/// This test will generate and analyze a dummy crate using the stable mir.
/// For that, it will first write the dummy crate into a file.
/// Then it will create a `StableMir` using custom arguments and then
@@ -147,7 +175,7 @@ fn main() {
generate_input(&path).unwrap();
let args = &[
"rustc".to_string(),
- "--crate-type=lib".to_string(),
+ "-Cpanic=abort".to_string(),
"--crate-name".to_string(),
CRATE_NAME.to_string(),
path.to_string(),
@@ -185,6 +213,13 @@ pub fn fn_ptr_holder(complex_fn: ComplexFn, variadic_fn: VariadicFn) {{
// We only care about the signature.
todo!()
}}
+
+ fn main() {{
+ #[repr(C)]
+ struct ReprCStruct;
+
+ let _s = ReprCStruct;
+ }}
"#
)?;
Ok(())
diff --git a/tests/ui-fulldeps/stable-mir/closure-generic-body.rs b/tests/ui-fulldeps/stable-mir/closure-generic-body.rs
new file mode 100644
index 0000000..2a23345
--- /dev/null
+++ b/tests/ui-fulldeps/stable-mir/closure-generic-body.rs
@@ -0,0 +1,90 @@
+//@ run-pass
+//! Tests stable mir API for retrieving the body of a closure.
+
+//@ ignore-stage1
+//@ ignore-cross-compile
+//@ ignore-remote
+//@ edition: 2021
+
+#![feature(rustc_private)]
+#![feature(assert_matches)]
+
+extern crate rustc_middle;
+#[macro_use]
+extern crate rustc_smir;
+extern crate rustc_driver;
+extern crate rustc_interface;
+extern crate stable_mir;
+
+use std::io::Write;
+use std::ops::ControlFlow;
+
+use stable_mir::mir::{Body, ConstOperand, Operand, TerminatorKind};
+use stable_mir::ty::{FnDef, RigidTy, TyKind};
+
+const CRATE_NAME: &str = "crate_closure_body";
+
+fn test_closure_body() -> ControlFlow<()> {
+ let crate_items = stable_mir::all_local_items();
+ for item in crate_items {
+ let item_ty = item.ty();
+ match &item_ty.kind() {
+ TyKind::RigidTy(RigidTy::Closure(closure_def, _)) => {
+ let closure_body = closure_def.body().unwrap();
+ check_incr_closure_body(closure_body);
+ }
+ _ => {}
+ }
+ }
+
+ ControlFlow::Continue(())
+}
+
+fn check_incr_closure_body(body: Body) {
+ let first_block = &body.blocks[0];
+ let TerminatorKind::Call { func: Operand::Constant(ConstOperand { const_, .. }), .. } =
+ &first_block.terminator.kind
+ else {
+ panic!("expected Call Terminator, got: ");
+ };
+
+ let TyKind::RigidTy(RigidTy::FnDef(FnDef(def_id), ..), ..) = const_.ty().kind() else {
+ panic!("expected FnDef");
+ };
+
+ assert_eq!(def_id.name(), "id");
+}
+
+fn main() {
+ let path = "closure_body.rs";
+ generate_input(&path).unwrap();
+ let args = &[
+ "rustc".to_string(),
+ "-Cpanic=abort".to_string(),
+ "--crate-name".to_string(),
+ CRATE_NAME.to_string(),
+ path.to_string(),
+ ];
+ run!(args, test_closure_body).unwrap();
+}
+
+fn generate_input(path: &str) -> std::io::Result<()> {
+ let mut file = std::fs::File::create(path)?;
+ write!(
+ file,
+ r#"
+ fn id<T>(y: T) -> T {{
+ y
+ }}
+
+ fn main() {{
+ let cl_id= |x| {{
+ id(x)
+ }};
+
+ let _= cl_id(5);
+ }}
+ "#
+ )?;
+ Ok(())
+}
diff --git a/tests/ui-fulldeps/stable-mir/closure_body.rs b/tests/ui-fulldeps/stable-mir/closure_body.rs
new file mode 100644
index 0000000..7ed0dab
--- /dev/null
+++ b/tests/ui-fulldeps/stable-mir/closure_body.rs
@@ -0,0 +1,90 @@
+//@ run-pass
+//! Tests stable mir API for retrieving the body of a closure.
+
+//@ ignore-stage1
+//@ ignore-cross-compile
+//@ ignore-remote
+//@ edition: 2021
+
+#![feature(rustc_private)]
+#![feature(assert_matches)]
+
+extern crate rustc_middle;
+#[macro_use]
+extern crate rustc_smir;
+extern crate rustc_driver;
+extern crate rustc_interface;
+extern crate stable_mir;
+
+use std::io::Write;
+use std::ops::ControlFlow;
+
+use stable_mir::mir::{Body, ConstOperand, Operand, TerminatorKind};
+use stable_mir::ty::{FnDef, RigidTy, TyKind};
+
+const CRATE_NAME: &str = "crate_closure_body";
+
+fn test_closure_body() -> ControlFlow<()> {
+ let crate_items = stable_mir::all_local_items();
+ for item in crate_items {
+ let item_ty = item.ty();
+ match &item_ty.kind() {
+ TyKind::RigidTy(RigidTy::Closure(closure_def, _)) => {
+ let closure_body = closure_def.body().unwrap();
+ check_incr_closure_body(closure_body);
+ }
+ _ => {}
+ }
+ }
+
+ ControlFlow::Continue(())
+}
+
+fn check_incr_closure_body(body: Body) {
+ let first_block = &body.blocks[0];
+ let TerminatorKind::Call { func: Operand::Constant(ConstOperand { const_, .. }), .. } =
+ &first_block.terminator.kind
+ else {
+ panic!("expected Call Terminator, got: ");
+ };
+
+ let TyKind::RigidTy(RigidTy::FnDef(FnDef(def_id), ..), ..) = const_.ty().kind() else {
+ panic!("expected FnDef");
+ };
+
+ assert_eq!(def_id.name(), "incr");
+}
+
+fn main() {
+ let path = "closure_body.rs";
+ generate_input(&path).unwrap();
+ let args = &[
+ "rustc".to_string(),
+ "-Cpanic=abort".to_string(),
+ "--crate-name".to_string(),
+ CRATE_NAME.to_string(),
+ path.to_string(),
+ ];
+ run!(args, test_closure_body).unwrap();
+}
+
+fn generate_input(path: &str) -> std::io::Result<()> {
+ let mut file = std::fs::File::create(path)?;
+ write!(
+ file,
+ r#"
+ fn incr(y: i32) -> i32 {{
+ y + 1
+ }}
+
+ fn main() {{
+ let cl_incr = |x: i32| {{
+ incr(x)
+ }};
+
+ let _= cl_incr(5);
+ }}
+ "#
+ )?;
+ Ok(())
+}
diff --git a/tests/ui/abi/c-zst.aarch64-darwin.stderr b/tests/ui/abi/c-zst.aarch64-darwin.stderr
index 48fa2bf2..5e09145 100644
--- a/tests/ui/abi/c-zst.aarch64-darwin.stderr
+++ b/tests/ui/abi/c-zst.aarch64-darwin.stderr
@@ -5,9 +5,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -34,9 +33,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
diff --git a/tests/ui/abi/c-zst.powerpc-linux.stderr b/tests/ui/abi/c-zst.powerpc-linux.stderr
index bfdf94c..b8d6c63 100644
--- a/tests/ui/abi/c-zst.powerpc-linux.stderr
+++ b/tests/ui/abi/c-zst.powerpc-linux.stderr
@@ -5,9 +5,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -45,9 +44,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
diff --git a/tests/ui/abi/c-zst.s390x-linux.stderr b/tests/ui/abi/c-zst.s390x-linux.stderr
index bfdf94c..b8d6c63 100644
--- a/tests/ui/abi/c-zst.s390x-linux.stderr
+++ b/tests/ui/abi/c-zst.s390x-linux.stderr
@@ -5,9 +5,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -45,9 +44,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
diff --git a/tests/ui/abi/c-zst.sparc64-linux.stderr b/tests/ui/abi/c-zst.sparc64-linux.stderr
index bfdf94c..b8d6c63 100644
--- a/tests/ui/abi/c-zst.sparc64-linux.stderr
+++ b/tests/ui/abi/c-zst.sparc64-linux.stderr
@@ -5,9 +5,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -45,9 +44,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
diff --git a/tests/ui/abi/c-zst.x86_64-linux.stderr b/tests/ui/abi/c-zst.x86_64-linux.stderr
index 48fa2bf2..5e09145 100644
--- a/tests/ui/abi/c-zst.x86_64-linux.stderr
+++ b/tests/ui/abi/c-zst.x86_64-linux.stderr
@@ -5,9 +5,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -34,9 +33,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
diff --git a/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr b/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr
index bfdf94c..b8d6c63 100644
--- a/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr
+++ b/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr
@@ -5,9 +5,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -45,9 +44,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
diff --git a/tests/ui/abi/debug.stderr b/tests/ui/abi/debug.stderr
index 480f3f0..8ed6ded 100644
--- a/tests/ui/abi/debug.stderr
+++ b/tests/ui/abi/debug.stderr
@@ -5,9 +5,8 @@
ty: u8,
layout: Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -44,9 +43,8 @@
ty: bool,
layout: Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -103,9 +101,8 @@
ty: bool,
layout: Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -151,9 +148,8 @@
ty: u8,
layout: Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -201,9 +197,8 @@
ty: *const T,
layout: Layout {
size: $SOME_SIZE,
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -241,9 +236,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -288,9 +282,8 @@
ty: u8,
layout: Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -327,9 +320,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -362,9 +354,8 @@
ty: u32,
layout: Layout {
size: $SOME_SIZE,
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -401,9 +392,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -442,9 +432,8 @@
ty: [u8; 32],
layout: Layout {
size: Size(32 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -482,9 +471,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -517,9 +505,8 @@
ty: [u32; 32],
layout: Layout {
size: Size(128 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -557,9 +544,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -598,9 +584,8 @@
ty: f32,
layout: Layout {
size: $SOME_SIZE,
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -636,9 +621,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -671,9 +655,8 @@
ty: u32,
layout: Layout {
size: $SOME_SIZE,
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -710,9 +693,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -751,9 +733,8 @@
ty: i32,
layout: Layout {
size: $SOME_SIZE,
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -790,9 +771,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -825,9 +805,8 @@
ty: u32,
layout: Layout {
size: $SOME_SIZE,
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -864,9 +843,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -925,9 +903,8 @@
ty: &S,
layout: Layout {
size: $SOME_SIZE,
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -977,9 +954,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
diff --git a/tests/ui/abi/sysv64-zst.stderr b/tests/ui/abi/sysv64-zst.stderr
index f91d1b5..2233e8e 100644
--- a/tests/ui/abi/sysv64-zst.stderr
+++ b/tests/ui/abi/sysv64-zst.stderr
@@ -5,9 +5,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -34,9 +33,8 @@
ty: (),
layout: Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: $SOME_ALIGN,
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
diff --git a/tests/ui/abi/unsupported.aarch64.stderr b/tests/ui/abi/unsupported.aarch64.stderr
index c11cc4e..22dca00 100644
--- a/tests/ui/abi/unsupported.aarch64.stderr
+++ b/tests/ui/abi/unsupported.aarch64.stderr
@@ -1,5 +1,5 @@
warning: the calling convention "ptx-kernel" is not supported on this target
- --> $DIR/unsupported.rs:35:15
+ --> $DIR/unsupported.rs:38:15
|
LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -9,13 +9,13 @@
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:40:1
+ --> $DIR/unsupported.rs:43:1
|
LL | extern "ptx-kernel" {}
| ^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "aapcs" is not supported on this target
- --> $DIR/unsupported.rs:51:17
+ --> $DIR/unsupported.rs:50:17
|
LL | fn aapcs_ptr(f: extern "aapcs" fn()) {
| ^^^^^^^^^^^^^^^^^^^
@@ -24,13 +24,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"aapcs"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:64:1
+ --> $DIR/unsupported.rs:55:1
|
LL | extern "aapcs" {}
| ^^^^^^^^^^^^^^^^^
warning: the calling convention "msp430-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:73:18
+ --> $DIR/unsupported.rs:60:18
|
LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -39,13 +39,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:78:1
+ --> $DIR/unsupported.rs:65:1
|
LL | extern "msp430-interrupt" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "avr-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:83:15
+ --> $DIR/unsupported.rs:70:15
|
LL | fn avr_ptr(f: extern "avr-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -54,13 +54,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:88:1
+ --> $DIR/unsupported.rs:75:1
|
LL | extern "avr-interrupt" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "riscv-interrupt-m" is not supported on this target
- --> $DIR/unsupported.rs:96:17
+ --> $DIR/unsupported.rs:80:17
|
LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -69,13 +69,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:107:1
+ --> $DIR/unsupported.rs:85:1
|
LL | extern "riscv-interrupt-m" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "x86-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:118:15
+ --> $DIR/unsupported.rs:90:15
|
LL | fn x86_ptr(f: extern "x86-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -84,13 +84,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:129:1
+ --> $DIR/unsupported.rs:95:1
|
LL | extern "x86-interrupt" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "thiscall" is not supported on this target
- --> $DIR/unsupported.rs:141:20
+ --> $DIR/unsupported.rs:100:20
|
LL | fn thiscall_ptr(f: extern "thiscall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -99,13 +99,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"thiscall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:154:1
+ --> $DIR/unsupported.rs:105:1
|
LL | extern "thiscall" {}
| ^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "stdcall" is not supported on this target
- --> $DIR/unsupported.rs:167:19
+ --> $DIR/unsupported.rs:112:19
|
LL | fn stdcall_ptr(f: extern "stdcall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^
@@ -114,13 +114,69 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"stdcall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:180:1
+ --> $DIR/unsupported.rs:119:1
|
LL | extern "stdcall" {}
| ^^^^^^^^^^^^^^^^^^^
+ |
+ = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"`
+
+error[E0570]: `"stdcall-unwind"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:123:1
+ |
+LL | extern "stdcall-unwind" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"`
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:131:17
+ |
+LL | fn cdecl_ptr(f: extern "cdecl" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:136:1
+ |
+LL | extern "cdecl" {}
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:139:1
+ |
+LL | extern "cdecl-unwind" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C-unwind"` instead
+
+warning: the calling convention "vectorcall" is not supported on this target
+ --> $DIR/unsupported.rs:145:22
+ |
+LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+
+error[E0570]: `"vectorcall"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:150:1
+ |
+LL | extern "vectorcall" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target
- --> $DIR/unsupported.rs:187:21
+ --> $DIR/unsupported.rs:153:21
|
LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -129,7 +185,7 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target
- --> $DIR/unsupported.rs:195:22
+ --> $DIR/unsupported.rs:161:22
|
LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -138,77 +194,95 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:200:1
+ --> $DIR/unsupported.rs:166:1
|
LL | extern "C-cmse-nonsecure-entry" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:33:1
+ --> $DIR/unsupported.rs:36:1
|
LL | extern "ptx-kernel" fn ptx() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:42:1
+ --> $DIR/unsupported.rs:45:1
|
LL | extern "gpu-kernel" fn gpu() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"aapcs"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:45:1
+ --> $DIR/unsupported.rs:48:1
|
LL | extern "aapcs" fn aapcs() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:71:1
+ --> $DIR/unsupported.rs:58:1
|
LL | extern "msp430-interrupt" fn msp430() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:81:1
+ --> $DIR/unsupported.rs:68:1
|
LL | extern "avr-interrupt" fn avr() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:91:1
+ --> $DIR/unsupported.rs:78:1
|
LL | extern "riscv-interrupt-m" fn riscv() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:113:1
+ --> $DIR/unsupported.rs:88:1
|
LL | extern "x86-interrupt" fn x86() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"thiscall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:135:1
+ --> $DIR/unsupported.rs:98:1
|
LL | extern "thiscall" fn thiscall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"stdcall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:161:1
+ --> $DIR/unsupported.rs:108:1
|
LL | extern "stdcall" fn stdcall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"`
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:128:1
+ |
+LL | extern "cdecl" fn cdecl() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+
+error[E0570]: `"vectorcall"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:143:1
+ |
+LL | extern "vectorcall" fn vectorcall() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:193:1
+ --> $DIR/unsupported.rs:159:1
|
LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to 19 previous errors; 10 warnings emitted
+error: aborting due to 22 previous errors; 15 warnings emitted
For more information about this error, try `rustc --explain E0570`.
Future incompatibility report: Future breakage diagnostic:
warning: the calling convention "ptx-kernel" is not supported on this target
- --> $DIR/unsupported.rs:35:15
+ --> $DIR/unsupported.rs:38:15
|
LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -219,7 +293,7 @@
Future breakage diagnostic:
warning: the calling convention "aapcs" is not supported on this target
- --> $DIR/unsupported.rs:51:17
+ --> $DIR/unsupported.rs:50:17
|
LL | fn aapcs_ptr(f: extern "aapcs" fn()) {
| ^^^^^^^^^^^^^^^^^^^
@@ -230,7 +304,7 @@
Future breakage diagnostic:
warning: the calling convention "msp430-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:73:18
+ --> $DIR/unsupported.rs:60:18
|
LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -241,7 +315,7 @@
Future breakage diagnostic:
warning: the calling convention "avr-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:83:15
+ --> $DIR/unsupported.rs:70:15
|
LL | fn avr_ptr(f: extern "avr-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -252,7 +326,7 @@
Future breakage diagnostic:
warning: the calling convention "riscv-interrupt-m" is not supported on this target
- --> $DIR/unsupported.rs:96:17
+ --> $DIR/unsupported.rs:80:17
|
LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -263,7 +337,7 @@
Future breakage diagnostic:
warning: the calling convention "x86-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:118:15
+ --> $DIR/unsupported.rs:90:15
|
LL | fn x86_ptr(f: extern "x86-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -274,7 +348,7 @@
Future breakage diagnostic:
warning: the calling convention "thiscall" is not supported on this target
- --> $DIR/unsupported.rs:141:20
+ --> $DIR/unsupported.rs:100:20
|
LL | fn thiscall_ptr(f: extern "thiscall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -285,7 +359,7 @@
Future breakage diagnostic:
warning: the calling convention "stdcall" is not supported on this target
- --> $DIR/unsupported.rs:167:19
+ --> $DIR/unsupported.rs:112:19
|
LL | fn stdcall_ptr(f: extern "stdcall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^
@@ -295,8 +369,55 @@
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:131:17
+ |
+LL | fn cdecl_ptr(f: extern "cdecl" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:136:1
+ |
+LL | extern "cdecl" {}
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:139:1
+ |
+LL | extern "cdecl-unwind" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C-unwind"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: the calling convention "vectorcall" is not supported on this target
+ --> $DIR/unsupported.rs:145:22
+ |
+LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+ = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
+
+Future breakage diagnostic:
warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target
- --> $DIR/unsupported.rs:187:21
+ --> $DIR/unsupported.rs:153:21
|
LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -307,7 +428,7 @@
Future breakage diagnostic:
warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target
- --> $DIR/unsupported.rs:195:22
+ --> $DIR/unsupported.rs:161:22
|
LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -316,3 +437,15 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:128:1
+ |
+LL | extern "cdecl" fn cdecl() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
diff --git a/tests/ui/abi/unsupported.arm.stderr b/tests/ui/abi/unsupported.arm.stderr
index b2f2438..0ac6d88 100644
--- a/tests/ui/abi/unsupported.arm.stderr
+++ b/tests/ui/abi/unsupported.arm.stderr
@@ -1,5 +1,5 @@
warning: the calling convention "ptx-kernel" is not supported on this target
- --> $DIR/unsupported.rs:35:15
+ --> $DIR/unsupported.rs:38:15
|
LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -9,13 +9,13 @@
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:40:1
+ --> $DIR/unsupported.rs:43:1
|
LL | extern "ptx-kernel" {}
| ^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "msp430-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:73:18
+ --> $DIR/unsupported.rs:60:18
|
LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -24,13 +24,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:78:1
+ --> $DIR/unsupported.rs:65:1
|
LL | extern "msp430-interrupt" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "avr-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:83:15
+ --> $DIR/unsupported.rs:70:15
|
LL | fn avr_ptr(f: extern "avr-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -39,13 +39,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:88:1
+ --> $DIR/unsupported.rs:75:1
|
LL | extern "avr-interrupt" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "riscv-interrupt-m" is not supported on this target
- --> $DIR/unsupported.rs:96:17
+ --> $DIR/unsupported.rs:80:17
|
LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -54,13 +54,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:107:1
+ --> $DIR/unsupported.rs:85:1
|
LL | extern "riscv-interrupt-m" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "x86-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:118:15
+ --> $DIR/unsupported.rs:90:15
|
LL | fn x86_ptr(f: extern "x86-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -69,13 +69,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:129:1
+ --> $DIR/unsupported.rs:95:1
|
LL | extern "x86-interrupt" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "thiscall" is not supported on this target
- --> $DIR/unsupported.rs:141:20
+ --> $DIR/unsupported.rs:100:20
|
LL | fn thiscall_ptr(f: extern "thiscall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -84,13 +84,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"thiscall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:154:1
+ --> $DIR/unsupported.rs:105:1
|
LL | extern "thiscall" {}
| ^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "stdcall" is not supported on this target
- --> $DIR/unsupported.rs:167:19
+ --> $DIR/unsupported.rs:112:19
|
LL | fn stdcall_ptr(f: extern "stdcall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^
@@ -99,13 +99,69 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"stdcall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:180:1
+ --> $DIR/unsupported.rs:119:1
|
LL | extern "stdcall" {}
| ^^^^^^^^^^^^^^^^^^^
+ |
+ = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"`
+
+error[E0570]: `"stdcall-unwind"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:123:1
+ |
+LL | extern "stdcall-unwind" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"`
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:131:17
+ |
+LL | fn cdecl_ptr(f: extern "cdecl" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:136:1
+ |
+LL | extern "cdecl" {}
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:139:1
+ |
+LL | extern "cdecl-unwind" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C-unwind"` instead
+
+warning: the calling convention "vectorcall" is not supported on this target
+ --> $DIR/unsupported.rs:145:22
+ |
+LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+
+error[E0570]: `"vectorcall"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:150:1
+ |
+LL | extern "vectorcall" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target
- --> $DIR/unsupported.rs:187:21
+ --> $DIR/unsupported.rs:153:21
|
LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -114,7 +170,7 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target
- --> $DIR/unsupported.rs:195:22
+ --> $DIR/unsupported.rs:161:22
|
LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -123,71 +179,89 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:200:1
+ --> $DIR/unsupported.rs:166:1
|
LL | extern "C-cmse-nonsecure-entry" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:33:1
+ --> $DIR/unsupported.rs:36:1
|
LL | extern "ptx-kernel" fn ptx() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:42:1
+ --> $DIR/unsupported.rs:45:1
|
LL | extern "gpu-kernel" fn gpu() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:71:1
+ --> $DIR/unsupported.rs:58:1
|
LL | extern "msp430-interrupt" fn msp430() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:81:1
+ --> $DIR/unsupported.rs:68:1
|
LL | extern "avr-interrupt" fn avr() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:91:1
+ --> $DIR/unsupported.rs:78:1
|
LL | extern "riscv-interrupt-m" fn riscv() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:113:1
+ --> $DIR/unsupported.rs:88:1
|
LL | extern "x86-interrupt" fn x86() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"thiscall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:135:1
+ --> $DIR/unsupported.rs:98:1
|
LL | extern "thiscall" fn thiscall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"stdcall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:161:1
+ --> $DIR/unsupported.rs:108:1
|
LL | extern "stdcall" fn stdcall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"`
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:128:1
+ |
+LL | extern "cdecl" fn cdecl() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+
+error[E0570]: `"vectorcall"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:143:1
+ |
+LL | extern "vectorcall" fn vectorcall() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:193:1
+ --> $DIR/unsupported.rs:159:1
|
LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to 17 previous errors; 9 warnings emitted
+error: aborting due to 20 previous errors; 14 warnings emitted
For more information about this error, try `rustc --explain E0570`.
Future incompatibility report: Future breakage diagnostic:
warning: the calling convention "ptx-kernel" is not supported on this target
- --> $DIR/unsupported.rs:35:15
+ --> $DIR/unsupported.rs:38:15
|
LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -198,7 +272,7 @@
Future breakage diagnostic:
warning: the calling convention "msp430-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:73:18
+ --> $DIR/unsupported.rs:60:18
|
LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -209,7 +283,7 @@
Future breakage diagnostic:
warning: the calling convention "avr-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:83:15
+ --> $DIR/unsupported.rs:70:15
|
LL | fn avr_ptr(f: extern "avr-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -220,7 +294,7 @@
Future breakage diagnostic:
warning: the calling convention "riscv-interrupt-m" is not supported on this target
- --> $DIR/unsupported.rs:96:17
+ --> $DIR/unsupported.rs:80:17
|
LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -231,7 +305,7 @@
Future breakage diagnostic:
warning: the calling convention "x86-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:118:15
+ --> $DIR/unsupported.rs:90:15
|
LL | fn x86_ptr(f: extern "x86-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -242,7 +316,7 @@
Future breakage diagnostic:
warning: the calling convention "thiscall" is not supported on this target
- --> $DIR/unsupported.rs:141:20
+ --> $DIR/unsupported.rs:100:20
|
LL | fn thiscall_ptr(f: extern "thiscall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -253,7 +327,7 @@
Future breakage diagnostic:
warning: the calling convention "stdcall" is not supported on this target
- --> $DIR/unsupported.rs:167:19
+ --> $DIR/unsupported.rs:112:19
|
LL | fn stdcall_ptr(f: extern "stdcall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^
@@ -263,8 +337,55 @@
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:131:17
+ |
+LL | fn cdecl_ptr(f: extern "cdecl" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:136:1
+ |
+LL | extern "cdecl" {}
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:139:1
+ |
+LL | extern "cdecl-unwind" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C-unwind"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: the calling convention "vectorcall" is not supported on this target
+ --> $DIR/unsupported.rs:145:22
+ |
+LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+ = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
+
+Future breakage diagnostic:
warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target
- --> $DIR/unsupported.rs:187:21
+ --> $DIR/unsupported.rs:153:21
|
LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -275,7 +396,7 @@
Future breakage diagnostic:
warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target
- --> $DIR/unsupported.rs:195:22
+ --> $DIR/unsupported.rs:161:22
|
LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -284,3 +405,15 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:128:1
+ |
+LL | extern "cdecl" fn cdecl() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
diff --git a/tests/ui/abi/unsupported.i686.stderr b/tests/ui/abi/unsupported.i686.stderr
index 94bd9b8..4d903b4 100644
--- a/tests/ui/abi/unsupported.i686.stderr
+++ b/tests/ui/abi/unsupported.i686.stderr
@@ -1,5 +1,5 @@
warning: the calling convention "ptx-kernel" is not supported on this target
- --> $DIR/unsupported.rs:35:15
+ --> $DIR/unsupported.rs:38:15
|
LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -9,13 +9,13 @@
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:40:1
+ --> $DIR/unsupported.rs:43:1
|
LL | extern "ptx-kernel" {}
| ^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "aapcs" is not supported on this target
- --> $DIR/unsupported.rs:51:17
+ --> $DIR/unsupported.rs:50:17
|
LL | fn aapcs_ptr(f: extern "aapcs" fn()) {
| ^^^^^^^^^^^^^^^^^^^
@@ -24,13 +24,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"aapcs"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:64:1
+ --> $DIR/unsupported.rs:55:1
|
LL | extern "aapcs" {}
| ^^^^^^^^^^^^^^^^^
warning: the calling convention "msp430-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:73:18
+ --> $DIR/unsupported.rs:60:18
|
LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -39,13 +39,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:78:1
+ --> $DIR/unsupported.rs:65:1
|
LL | extern "msp430-interrupt" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "avr-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:83:15
+ --> $DIR/unsupported.rs:70:15
|
LL | fn avr_ptr(f: extern "avr-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -54,13 +54,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:88:1
+ --> $DIR/unsupported.rs:75:1
|
LL | extern "avr-interrupt" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "riscv-interrupt-m" is not supported on this target
- --> $DIR/unsupported.rs:96:17
+ --> $DIR/unsupported.rs:80:17
|
LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -69,13 +69,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:107:1
+ --> $DIR/unsupported.rs:85:1
|
LL | extern "riscv-interrupt-m" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target
- --> $DIR/unsupported.rs:187:21
+ --> $DIR/unsupported.rs:153:21
|
LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -84,7 +84,7 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target
- --> $DIR/unsupported.rs:195:22
+ --> $DIR/unsupported.rs:161:22
|
LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -93,49 +93,49 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:200:1
+ --> $DIR/unsupported.rs:166:1
|
LL | extern "C-cmse-nonsecure-entry" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:33:1
+ --> $DIR/unsupported.rs:36:1
|
LL | extern "ptx-kernel" fn ptx() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:42:1
+ --> $DIR/unsupported.rs:45:1
|
LL | extern "gpu-kernel" fn gpu() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"aapcs"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:45:1
+ --> $DIR/unsupported.rs:48:1
|
LL | extern "aapcs" fn aapcs() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:71:1
+ --> $DIR/unsupported.rs:58:1
|
LL | extern "msp430-interrupt" fn msp430() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:81:1
+ --> $DIR/unsupported.rs:68:1
|
LL | extern "avr-interrupt" fn avr() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:91:1
+ --> $DIR/unsupported.rs:78:1
|
LL | extern "riscv-interrupt-m" fn riscv() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:193:1
+ --> $DIR/unsupported.rs:159:1
|
LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -145,7 +145,7 @@
For more information about this error, try `rustc --explain E0570`.
Future incompatibility report: Future breakage diagnostic:
warning: the calling convention "ptx-kernel" is not supported on this target
- --> $DIR/unsupported.rs:35:15
+ --> $DIR/unsupported.rs:38:15
|
LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -156,7 +156,7 @@
Future breakage diagnostic:
warning: the calling convention "aapcs" is not supported on this target
- --> $DIR/unsupported.rs:51:17
+ --> $DIR/unsupported.rs:50:17
|
LL | fn aapcs_ptr(f: extern "aapcs" fn()) {
| ^^^^^^^^^^^^^^^^^^^
@@ -167,7 +167,7 @@
Future breakage diagnostic:
warning: the calling convention "msp430-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:73:18
+ --> $DIR/unsupported.rs:60:18
|
LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -178,7 +178,7 @@
Future breakage diagnostic:
warning: the calling convention "avr-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:83:15
+ --> $DIR/unsupported.rs:70:15
|
LL | fn avr_ptr(f: extern "avr-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -189,7 +189,7 @@
Future breakage diagnostic:
warning: the calling convention "riscv-interrupt-m" is not supported on this target
- --> $DIR/unsupported.rs:96:17
+ --> $DIR/unsupported.rs:80:17
|
LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -200,7 +200,7 @@
Future breakage diagnostic:
warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target
- --> $DIR/unsupported.rs:187:21
+ --> $DIR/unsupported.rs:153:21
|
LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -211,7 +211,7 @@
Future breakage diagnostic:
warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target
- --> $DIR/unsupported.rs:195:22
+ --> $DIR/unsupported.rs:161:22
|
LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/abi/unsupported.riscv32.stderr b/tests/ui/abi/unsupported.riscv32.stderr
index c6ff472..ad57a89 100644
--- a/tests/ui/abi/unsupported.riscv32.stderr
+++ b/tests/ui/abi/unsupported.riscv32.stderr
@@ -1,5 +1,5 @@
warning: the calling convention "ptx-kernel" is not supported on this target
- --> $DIR/unsupported.rs:35:15
+ --> $DIR/unsupported.rs:38:15
|
LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -9,13 +9,13 @@
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:40:1
+ --> $DIR/unsupported.rs:43:1
|
LL | extern "ptx-kernel" {}
| ^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "aapcs" is not supported on this target
- --> $DIR/unsupported.rs:51:17
+ --> $DIR/unsupported.rs:50:17
|
LL | fn aapcs_ptr(f: extern "aapcs" fn()) {
| ^^^^^^^^^^^^^^^^^^^
@@ -24,13 +24,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"aapcs"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:64:1
+ --> $DIR/unsupported.rs:55:1
|
LL | extern "aapcs" {}
| ^^^^^^^^^^^^^^^^^
warning: the calling convention "msp430-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:73:18
+ --> $DIR/unsupported.rs:60:18
|
LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -39,13 +39,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:78:1
+ --> $DIR/unsupported.rs:65:1
|
LL | extern "msp430-interrupt" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "avr-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:83:15
+ --> $DIR/unsupported.rs:70:15
|
LL | fn avr_ptr(f: extern "avr-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -54,13 +54,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:88:1
+ --> $DIR/unsupported.rs:75:1
|
LL | extern "avr-interrupt" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "x86-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:118:15
+ --> $DIR/unsupported.rs:90:15
|
LL | fn x86_ptr(f: extern "x86-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -69,13 +69,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:129:1
+ --> $DIR/unsupported.rs:95:1
|
LL | extern "x86-interrupt" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "thiscall" is not supported on this target
- --> $DIR/unsupported.rs:141:20
+ --> $DIR/unsupported.rs:100:20
|
LL | fn thiscall_ptr(f: extern "thiscall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -84,13 +84,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"thiscall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:154:1
+ --> $DIR/unsupported.rs:105:1
|
LL | extern "thiscall" {}
| ^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "stdcall" is not supported on this target
- --> $DIR/unsupported.rs:167:19
+ --> $DIR/unsupported.rs:112:19
|
LL | fn stdcall_ptr(f: extern "stdcall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^
@@ -99,13 +99,69 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"stdcall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:180:1
+ --> $DIR/unsupported.rs:119:1
|
LL | extern "stdcall" {}
| ^^^^^^^^^^^^^^^^^^^
+ |
+ = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"`
+
+error[E0570]: `"stdcall-unwind"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:123:1
+ |
+LL | extern "stdcall-unwind" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"`
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:131:17
+ |
+LL | fn cdecl_ptr(f: extern "cdecl" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:136:1
+ |
+LL | extern "cdecl" {}
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:139:1
+ |
+LL | extern "cdecl-unwind" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C-unwind"` instead
+
+warning: the calling convention "vectorcall" is not supported on this target
+ --> $DIR/unsupported.rs:145:22
+ |
+LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+
+error[E0570]: `"vectorcall"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:150:1
+ |
+LL | extern "vectorcall" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target
- --> $DIR/unsupported.rs:187:21
+ --> $DIR/unsupported.rs:153:21
|
LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -114,7 +170,7 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target
- --> $DIR/unsupported.rs:195:22
+ --> $DIR/unsupported.rs:161:22
|
LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -123,71 +179,89 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:200:1
+ --> $DIR/unsupported.rs:166:1
|
LL | extern "C-cmse-nonsecure-entry" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:33:1
+ --> $DIR/unsupported.rs:36:1
|
LL | extern "ptx-kernel" fn ptx() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:42:1
+ --> $DIR/unsupported.rs:45:1
|
LL | extern "gpu-kernel" fn gpu() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"aapcs"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:45:1
+ --> $DIR/unsupported.rs:48:1
|
LL | extern "aapcs" fn aapcs() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:71:1
+ --> $DIR/unsupported.rs:58:1
|
LL | extern "msp430-interrupt" fn msp430() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:81:1
+ --> $DIR/unsupported.rs:68:1
|
LL | extern "avr-interrupt" fn avr() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:113:1
+ --> $DIR/unsupported.rs:88:1
|
LL | extern "x86-interrupt" fn x86() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"thiscall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:135:1
+ --> $DIR/unsupported.rs:98:1
|
LL | extern "thiscall" fn thiscall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"stdcall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:161:1
+ --> $DIR/unsupported.rs:108:1
|
LL | extern "stdcall" fn stdcall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"`
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:128:1
+ |
+LL | extern "cdecl" fn cdecl() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+
+error[E0570]: `"vectorcall"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:143:1
+ |
+LL | extern "vectorcall" fn vectorcall() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:193:1
+ --> $DIR/unsupported.rs:159:1
|
LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to 17 previous errors; 9 warnings emitted
+error: aborting due to 20 previous errors; 14 warnings emitted
For more information about this error, try `rustc --explain E0570`.
Future incompatibility report: Future breakage diagnostic:
warning: the calling convention "ptx-kernel" is not supported on this target
- --> $DIR/unsupported.rs:35:15
+ --> $DIR/unsupported.rs:38:15
|
LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -198,7 +272,7 @@
Future breakage diagnostic:
warning: the calling convention "aapcs" is not supported on this target
- --> $DIR/unsupported.rs:51:17
+ --> $DIR/unsupported.rs:50:17
|
LL | fn aapcs_ptr(f: extern "aapcs" fn()) {
| ^^^^^^^^^^^^^^^^^^^
@@ -209,7 +283,7 @@
Future breakage diagnostic:
warning: the calling convention "msp430-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:73:18
+ --> $DIR/unsupported.rs:60:18
|
LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -220,7 +294,7 @@
Future breakage diagnostic:
warning: the calling convention "avr-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:83:15
+ --> $DIR/unsupported.rs:70:15
|
LL | fn avr_ptr(f: extern "avr-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -231,7 +305,7 @@
Future breakage diagnostic:
warning: the calling convention "x86-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:118:15
+ --> $DIR/unsupported.rs:90:15
|
LL | fn x86_ptr(f: extern "x86-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -242,7 +316,7 @@
Future breakage diagnostic:
warning: the calling convention "thiscall" is not supported on this target
- --> $DIR/unsupported.rs:141:20
+ --> $DIR/unsupported.rs:100:20
|
LL | fn thiscall_ptr(f: extern "thiscall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -253,7 +327,7 @@
Future breakage diagnostic:
warning: the calling convention "stdcall" is not supported on this target
- --> $DIR/unsupported.rs:167:19
+ --> $DIR/unsupported.rs:112:19
|
LL | fn stdcall_ptr(f: extern "stdcall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^
@@ -263,8 +337,55 @@
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:131:17
+ |
+LL | fn cdecl_ptr(f: extern "cdecl" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:136:1
+ |
+LL | extern "cdecl" {}
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:139:1
+ |
+LL | extern "cdecl-unwind" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C-unwind"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: the calling convention "vectorcall" is not supported on this target
+ --> $DIR/unsupported.rs:145:22
+ |
+LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+ = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
+
+Future breakage diagnostic:
warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target
- --> $DIR/unsupported.rs:187:21
+ --> $DIR/unsupported.rs:153:21
|
LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -275,7 +396,7 @@
Future breakage diagnostic:
warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target
- --> $DIR/unsupported.rs:195:22
+ --> $DIR/unsupported.rs:161:22
|
LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -284,3 +405,15 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:128:1
+ |
+LL | extern "cdecl" fn cdecl() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
diff --git a/tests/ui/abi/unsupported.riscv64.stderr b/tests/ui/abi/unsupported.riscv64.stderr
index c6ff472..ad57a89 100644
--- a/tests/ui/abi/unsupported.riscv64.stderr
+++ b/tests/ui/abi/unsupported.riscv64.stderr
@@ -1,5 +1,5 @@
warning: the calling convention "ptx-kernel" is not supported on this target
- --> $DIR/unsupported.rs:35:15
+ --> $DIR/unsupported.rs:38:15
|
LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -9,13 +9,13 @@
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:40:1
+ --> $DIR/unsupported.rs:43:1
|
LL | extern "ptx-kernel" {}
| ^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "aapcs" is not supported on this target
- --> $DIR/unsupported.rs:51:17
+ --> $DIR/unsupported.rs:50:17
|
LL | fn aapcs_ptr(f: extern "aapcs" fn()) {
| ^^^^^^^^^^^^^^^^^^^
@@ -24,13 +24,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"aapcs"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:64:1
+ --> $DIR/unsupported.rs:55:1
|
LL | extern "aapcs" {}
| ^^^^^^^^^^^^^^^^^
warning: the calling convention "msp430-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:73:18
+ --> $DIR/unsupported.rs:60:18
|
LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -39,13 +39,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:78:1
+ --> $DIR/unsupported.rs:65:1
|
LL | extern "msp430-interrupt" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "avr-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:83:15
+ --> $DIR/unsupported.rs:70:15
|
LL | fn avr_ptr(f: extern "avr-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -54,13 +54,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:88:1
+ --> $DIR/unsupported.rs:75:1
|
LL | extern "avr-interrupt" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "x86-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:118:15
+ --> $DIR/unsupported.rs:90:15
|
LL | fn x86_ptr(f: extern "x86-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -69,13 +69,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:129:1
+ --> $DIR/unsupported.rs:95:1
|
LL | extern "x86-interrupt" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "thiscall" is not supported on this target
- --> $DIR/unsupported.rs:141:20
+ --> $DIR/unsupported.rs:100:20
|
LL | fn thiscall_ptr(f: extern "thiscall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -84,13 +84,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"thiscall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:154:1
+ --> $DIR/unsupported.rs:105:1
|
LL | extern "thiscall" {}
| ^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "stdcall" is not supported on this target
- --> $DIR/unsupported.rs:167:19
+ --> $DIR/unsupported.rs:112:19
|
LL | fn stdcall_ptr(f: extern "stdcall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^
@@ -99,13 +99,69 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"stdcall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:180:1
+ --> $DIR/unsupported.rs:119:1
|
LL | extern "stdcall" {}
| ^^^^^^^^^^^^^^^^^^^
+ |
+ = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"`
+
+error[E0570]: `"stdcall-unwind"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:123:1
+ |
+LL | extern "stdcall-unwind" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"`
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:131:17
+ |
+LL | fn cdecl_ptr(f: extern "cdecl" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:136:1
+ |
+LL | extern "cdecl" {}
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:139:1
+ |
+LL | extern "cdecl-unwind" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C-unwind"` instead
+
+warning: the calling convention "vectorcall" is not supported on this target
+ --> $DIR/unsupported.rs:145:22
+ |
+LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+
+error[E0570]: `"vectorcall"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:150:1
+ |
+LL | extern "vectorcall" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target
- --> $DIR/unsupported.rs:187:21
+ --> $DIR/unsupported.rs:153:21
|
LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -114,7 +170,7 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target
- --> $DIR/unsupported.rs:195:22
+ --> $DIR/unsupported.rs:161:22
|
LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -123,71 +179,89 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:200:1
+ --> $DIR/unsupported.rs:166:1
|
LL | extern "C-cmse-nonsecure-entry" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:33:1
+ --> $DIR/unsupported.rs:36:1
|
LL | extern "ptx-kernel" fn ptx() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:42:1
+ --> $DIR/unsupported.rs:45:1
|
LL | extern "gpu-kernel" fn gpu() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"aapcs"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:45:1
+ --> $DIR/unsupported.rs:48:1
|
LL | extern "aapcs" fn aapcs() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:71:1
+ --> $DIR/unsupported.rs:58:1
|
LL | extern "msp430-interrupt" fn msp430() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:81:1
+ --> $DIR/unsupported.rs:68:1
|
LL | extern "avr-interrupt" fn avr() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:113:1
+ --> $DIR/unsupported.rs:88:1
|
LL | extern "x86-interrupt" fn x86() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"thiscall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:135:1
+ --> $DIR/unsupported.rs:98:1
|
LL | extern "thiscall" fn thiscall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"stdcall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:161:1
+ --> $DIR/unsupported.rs:108:1
|
LL | extern "stdcall" fn stdcall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"`
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:128:1
+ |
+LL | extern "cdecl" fn cdecl() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+
+error[E0570]: `"vectorcall"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:143:1
+ |
+LL | extern "vectorcall" fn vectorcall() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:193:1
+ --> $DIR/unsupported.rs:159:1
|
LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to 17 previous errors; 9 warnings emitted
+error: aborting due to 20 previous errors; 14 warnings emitted
For more information about this error, try `rustc --explain E0570`.
Future incompatibility report: Future breakage diagnostic:
warning: the calling convention "ptx-kernel" is not supported on this target
- --> $DIR/unsupported.rs:35:15
+ --> $DIR/unsupported.rs:38:15
|
LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -198,7 +272,7 @@
Future breakage diagnostic:
warning: the calling convention "aapcs" is not supported on this target
- --> $DIR/unsupported.rs:51:17
+ --> $DIR/unsupported.rs:50:17
|
LL | fn aapcs_ptr(f: extern "aapcs" fn()) {
| ^^^^^^^^^^^^^^^^^^^
@@ -209,7 +283,7 @@
Future breakage diagnostic:
warning: the calling convention "msp430-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:73:18
+ --> $DIR/unsupported.rs:60:18
|
LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -220,7 +294,7 @@
Future breakage diagnostic:
warning: the calling convention "avr-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:83:15
+ --> $DIR/unsupported.rs:70:15
|
LL | fn avr_ptr(f: extern "avr-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -231,7 +305,7 @@
Future breakage diagnostic:
warning: the calling convention "x86-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:118:15
+ --> $DIR/unsupported.rs:90:15
|
LL | fn x86_ptr(f: extern "x86-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -242,7 +316,7 @@
Future breakage diagnostic:
warning: the calling convention "thiscall" is not supported on this target
- --> $DIR/unsupported.rs:141:20
+ --> $DIR/unsupported.rs:100:20
|
LL | fn thiscall_ptr(f: extern "thiscall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -253,7 +327,7 @@
Future breakage diagnostic:
warning: the calling convention "stdcall" is not supported on this target
- --> $DIR/unsupported.rs:167:19
+ --> $DIR/unsupported.rs:112:19
|
LL | fn stdcall_ptr(f: extern "stdcall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^
@@ -263,8 +337,55 @@
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:131:17
+ |
+LL | fn cdecl_ptr(f: extern "cdecl" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:136:1
+ |
+LL | extern "cdecl" {}
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:139:1
+ |
+LL | extern "cdecl-unwind" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C-unwind"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: the calling convention "vectorcall" is not supported on this target
+ --> $DIR/unsupported.rs:145:22
+ |
+LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+ = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
+
+Future breakage diagnostic:
warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target
- --> $DIR/unsupported.rs:187:21
+ --> $DIR/unsupported.rs:153:21
|
LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -275,7 +396,7 @@
Future breakage diagnostic:
warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target
- --> $DIR/unsupported.rs:195:22
+ --> $DIR/unsupported.rs:161:22
|
LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -284,3 +405,15 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:128:1
+ |
+LL | extern "cdecl" fn cdecl() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
diff --git a/tests/ui/abi/unsupported.rs b/tests/ui/abi/unsupported.rs
index 8464650..43bdfe3 100644
--- a/tests/ui/abi/unsupported.rs
+++ b/tests/ui/abi/unsupported.rs
@@ -1,8 +1,10 @@
//@ add-core-stubs
-//@ revisions: x64 i686 aarch64 arm riscv32 riscv64
+//@ revisions: x64 x64_win i686 aarch64 arm riscv32 riscv64
//
//@ [x64] needs-llvm-components: x86
//@ [x64] compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=rlib
+//@ [x64_win] needs-llvm-components: x86
+//@ [x64_win] compile-flags: --target=x86_64-pc-windows-msvc --crate-type=rlib
//@ [i686] needs-llvm-components: x86
//@ [i686] compile-flags: --target=i686-unknown-linux-gnu --crate-type=rlib
//@ [aarch64] needs-llvm-components: aarch64
@@ -24,6 +26,7 @@
abi_x86_interrupt,
abi_riscv_interrupt,
abi_c_cmse_nonsecure_call,
+ abi_vectorcall,
cmse_nonsecure_entry
)]
@@ -43,30 +46,14 @@ extern "gpu-kernel" fn gpu() {}
//~^ ERROR is not a supported ABI
extern "aapcs" fn aapcs() {}
-//[x64]~^ ERROR is not a supported ABI
-//[i686]~^^ ERROR is not a supported ABI
-//[aarch64]~^^^ ERROR is not a supported ABI
-//[riscv32]~^^^^ ERROR is not a supported ABI
-//[riscv64]~^^^^^ ERROR is not a supported ABI
+//[x64,x64_win,i686,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI
fn aapcs_ptr(f: extern "aapcs" fn()) {
- //[x64]~^ WARN unsupported_fn_ptr_calling_conventions
- //[x64]~^^ WARN this was previously accepted
- //[i686]~^^^ WARN unsupported_fn_ptr_calling_conventions
- //[i686]~^^^^ WARN this was previously accepted
- //[aarch64]~^^^^^ WARN unsupported_fn_ptr_calling_conventions
- //[aarch64]~^^^^^^ WARN this was previously accepted
- //[riscv32]~^^^^^^^ WARN unsupported_fn_ptr_calling_conventions
- //[riscv32]~^^^^^^^^ WARN this was previously accepted
- //[riscv64]~^^^^^^^^^ WARN unsupported_fn_ptr_calling_conventions
- //[riscv64]~^^^^^^^^^^ WARN this was previously accepted
+ //[x64,x64_win,i686,aarch64,riscv32,riscv64]~^ WARN unsupported_fn_ptr_calling_conventions
+ //[x64,x64_win,i686,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted
f()
}
extern "aapcs" {}
-//[x64]~^ ERROR is not a supported ABI
-//[i686]~^^ ERROR is not a supported ABI
-//[aarch64]~^^^ ERROR is not a supported ABI
-//[riscv32]~^^^^ ERROR is not a supported ABI
-//[riscv64]~^^^^^ ERROR is not a supported ABI
+//[x64,x64_win,i686,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI
extern "msp430-interrupt" fn msp430() {}
//~^ ERROR is not a supported ABI
@@ -89,100 +76,79 @@ fn avr_ptr(f: extern "avr-interrupt" fn()) {
//~^ ERROR is not a supported ABI
extern "riscv-interrupt-m" fn riscv() {}
-//[arm]~^ ERROR is not a supported ABI
-//[x64]~^^ ERROR is not a supported ABI
-//[i686]~^^^ ERROR is not a supported ABI
-//[aarch64]~^^^^ ERROR is not a supported ABI
+//[x64,x64_win,i686,arm,aarch64]~^ ERROR is not a supported ABI
fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) {
- //[arm]~^ WARN unsupported_fn_ptr_calling_conventions
- //[arm]~^^ WARN this was previously accepted
- //[x64]~^^^ WARN unsupported_fn_ptr_calling_conventions
- //[x64]~^^^^ WARN this was previously accepted
- //[i686]~^^^^^ WARN unsupported_fn_ptr_calling_conventions
- //[i686]~^^^^^^ WARN this was previously accepted
- //[aarch64]~^^^^^^^ WARN unsupported_fn_ptr_calling_conventions
- //[aarch64]~^^^^^^^^ WARN this was previously accepted
+ //[x64,x64_win,i686,arm,aarch64]~^ WARN unsupported_fn_ptr_calling_conventions
+ //[x64,x64_win,i686,arm,aarch64]~^^ WARN this was previously accepted
f()
}
extern "riscv-interrupt-m" {}
-//[arm]~^ ERROR is not a supported ABI
-//[x64]~^^ ERROR is not a supported ABI
-//[i686]~^^^ ERROR is not a supported ABI
-//[aarch64]~^^^^ ERROR is not a supported ABI
+//[x64,x64_win,i686,arm,aarch64]~^ ERROR is not a supported ABI
extern "x86-interrupt" fn x86() {}
-//[aarch64]~^ ERROR is not a supported ABI
-//[arm]~^^ ERROR is not a supported ABI
-//[riscv32]~^^^ ERROR is not a supported ABI
-//[riscv64]~^^^^ ERROR is not a supported ABI
+//[aarch64,arm,riscv32,riscv64]~^ ERROR is not a supported ABI
fn x86_ptr(f: extern "x86-interrupt" fn()) {
- //[aarch64]~^ WARN unsupported_fn_ptr_calling_conventions
- //[aarch64]~^^ WARN this was previously accepted
- //[arm]~^^^ WARN unsupported_fn_ptr_calling_conventions
- //[arm]~^^^^ WARN this was previously accepted
- //[riscv32]~^^^^^ WARN unsupported_fn_ptr_calling_conventions
- //[riscv32]~^^^^^^ WARN this was previously accepted
- //[riscv64]~^^^^^^^ WARN unsupported_fn_ptr_calling_conventions
- //[riscv64]~^^^^^^^^ WARN this was previously accepted
+ //[aarch64,arm,riscv32,riscv64]~^ WARN unsupported_fn_ptr_calling_conventions
+ //[aarch64,arm,riscv32,riscv64]~^^ WARN this was previously accepted
f()
}
extern "x86-interrupt" {}
-//[aarch64]~^ ERROR is not a supported ABI
-//[arm]~^^ ERROR is not a supported ABI
-//[riscv32]~^^^ ERROR is not a supported ABI
-//[riscv64]~^^^^ ERROR is not a supported ABI
+//[aarch64,arm,riscv32,riscv64]~^ ERROR is not a supported ABI
extern "thiscall" fn thiscall() {}
-//[x64]~^ ERROR is not a supported ABI
-//[arm]~^^ ERROR is not a supported ABI
-//[aarch64]~^^^ ERROR is not a supported ABI
-//[riscv32]~^^^^ ERROR is not a supported ABI
-//[riscv64]~^^^^^ ERROR is not a supported ABI
+//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI
fn thiscall_ptr(f: extern "thiscall" fn()) {
- //[x64]~^ WARN unsupported_fn_ptr_calling_conventions
- //[x64]~^^ WARN this was previously accepted
- //[arm]~^^^ WARN unsupported_fn_ptr_calling_conventions
- //[arm]~^^^^ WARN this was previously accepted
- //[aarch64]~^^^^^ WARN unsupported_fn_ptr_calling_conventions
- //[aarch64]~^^^^^^ WARN this was previously accepted
- //[riscv32]~^^^^^^^ WARN unsupported_fn_ptr_calling_conventions
- //[riscv32]~^^^^^^^^ WARN this was previously accepted
- //[riscv64]~^^^^^^^^^ WARN unsupported_fn_ptr_calling_conventions
- //[riscv64]~^^^^^^^^^^ WARN this was previously accepted
+ //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ WARN unsupported_fn_ptr_calling_conventions
+ //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted
f()
}
extern "thiscall" {}
-//[x64]~^ ERROR is not a supported ABI
-//[arm]~^^ ERROR is not a supported ABI
-//[aarch64]~^^^ ERROR is not a supported ABI
-//[riscv32]~^^^^ ERROR is not a supported ABI
-//[riscv64]~^^^^^ ERROR is not a supported ABI
+//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI
extern "stdcall" fn stdcall() {}
-//[x64]~^ ERROR is not a supported ABI
-//[arm]~^^ ERROR is not a supported ABI
-//[aarch64]~^^^ ERROR is not a supported ABI
-//[riscv32]~^^^^ ERROR is not a supported ABI
-//[riscv64]~^^^^^ ERROR is not a supported ABI
+//[x64,arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI
+//[x64_win]~^^ WARN unsupported_calling_conventions
+//[x64_win]~^^^ WARN this was previously accepted
fn stdcall_ptr(f: extern "stdcall" fn()) {
- //[x64]~^ WARN unsupported_fn_ptr_calling_conventions
- //[x64]~^^ WARN this was previously accepted
- //[arm]~^^^ WARN unsupported_fn_ptr_calling_conventions
- //[arm]~^^^^ WARN this was previously accepted
- //[aarch64]~^^^^^ WARN unsupported_fn_ptr_calling_conventions
- //[aarch64]~^^^^^^ WARN this was previously accepted
- //[riscv32]~^^^^^^^ WARN unsupported_fn_ptr_calling_conventions
- //[riscv32]~^^^^^^^^ WARN this was previously accepted
- //[riscv64]~^^^^^^^^^ WARN unsupported_fn_ptr_calling_conventions
- //[riscv64]~^^^^^^^^^^ WARN this was previously accepted
+ //[x64_win]~^ WARN unsupported_calling_conventions
+ //[x64_win]~| WARN this was previously accepted
+ //[x64,arm,aarch64,riscv32,riscv64]~^^^ WARN unsupported_fn_ptr_calling_conventions
+ //[x64,arm,aarch64,riscv32,riscv64]~| WARN this was previously accepted
f()
}
extern "stdcall" {}
-//[x64]~^ ERROR is not a supported ABI
-//[arm]~^^ ERROR is not a supported ABI
-//[aarch64]~^^^ ERROR is not a supported ABI
-//[riscv32]~^^^^ ERROR is not a supported ABI
-//[riscv64]~^^^^^ ERROR is not a supported ABI
+//[x64,arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI
+//[x64_win]~^^ WARN unsupported_calling_conventions
+//[x64_win]~^^^ WARN this was previously accepted
+extern "stdcall-unwind" {}
+//[x64,arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI
+//[x64_win]~^^ WARN unsupported_calling_conventions
+//[x64_win]~^^^ WARN this was previously accepted
+
+extern "cdecl" fn cdecl() {}
+//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ WARN unsupported_calling_conventions
+//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted
+fn cdecl_ptr(f: extern "cdecl" fn()) {
+ //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ WARN unsupported_calling_conventions
+ //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted
+ f()
+}
+extern "cdecl" {}
+//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ WARN unsupported_calling_conventions
+//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted
+extern "cdecl-unwind" {}
+//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ WARN unsupported_calling_conventions
+//[x64,x64_win,arm,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted
+
+extern "vectorcall" fn vectorcall() {}
+//[arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI
+fn vectorcall_ptr(f: extern "vectorcall" fn()) {
+ //[arm,aarch64,riscv32,riscv64]~^ WARN unsupported_fn_ptr_calling_conventions
+ //[arm,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted
+ f()
+}
+extern "vectorcall" {}
+//[arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI
fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) {
//~^ WARN unsupported_fn_ptr_calling_conventions
@@ -199,3 +165,9 @@ fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) {
}
extern "C-cmse-nonsecure-entry" {}
//~^ ERROR is not a supported ABI
+
+#[cfg(windows)]
+#[link(name = "foo", kind = "raw-dylib")]
+extern "cdecl" {}
+//[x64_win]~^ WARN use of calling convention not supported on this target
+//[x64_win]~^^ WARN this was previously accepted
diff --git a/tests/ui/abi/unsupported.x64.stderr b/tests/ui/abi/unsupported.x64.stderr
index 0a9f9a6..f777fe8 100644
--- a/tests/ui/abi/unsupported.x64.stderr
+++ b/tests/ui/abi/unsupported.x64.stderr
@@ -1,5 +1,5 @@
warning: the calling convention "ptx-kernel" is not supported on this target
- --> $DIR/unsupported.rs:35:15
+ --> $DIR/unsupported.rs:38:15
|
LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -9,13 +9,13 @@
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:40:1
+ --> $DIR/unsupported.rs:43:1
|
LL | extern "ptx-kernel" {}
| ^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "aapcs" is not supported on this target
- --> $DIR/unsupported.rs:51:17
+ --> $DIR/unsupported.rs:50:17
|
LL | fn aapcs_ptr(f: extern "aapcs" fn()) {
| ^^^^^^^^^^^^^^^^^^^
@@ -24,13 +24,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"aapcs"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:64:1
+ --> $DIR/unsupported.rs:55:1
|
LL | extern "aapcs" {}
| ^^^^^^^^^^^^^^^^^
warning: the calling convention "msp430-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:73:18
+ --> $DIR/unsupported.rs:60:18
|
LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -39,13 +39,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:78:1
+ --> $DIR/unsupported.rs:65:1
|
LL | extern "msp430-interrupt" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "avr-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:83:15
+ --> $DIR/unsupported.rs:70:15
|
LL | fn avr_ptr(f: extern "avr-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -54,13 +54,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:88:1
+ --> $DIR/unsupported.rs:75:1
|
LL | extern "avr-interrupt" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "riscv-interrupt-m" is not supported on this target
- --> $DIR/unsupported.rs:96:17
+ --> $DIR/unsupported.rs:80:17
|
LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -69,13 +69,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:107:1
+ --> $DIR/unsupported.rs:85:1
|
LL | extern "riscv-interrupt-m" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "thiscall" is not supported on this target
- --> $DIR/unsupported.rs:141:20
+ --> $DIR/unsupported.rs:100:20
|
LL | fn thiscall_ptr(f: extern "thiscall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -84,13 +84,13 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"thiscall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:154:1
+ --> $DIR/unsupported.rs:105:1
|
LL | extern "thiscall" {}
| ^^^^^^^^^^^^^^^^^^^^
warning: the calling convention "stdcall" is not supported on this target
- --> $DIR/unsupported.rs:167:19
+ --> $DIR/unsupported.rs:112:19
|
LL | fn stdcall_ptr(f: extern "stdcall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^
@@ -99,13 +99,54 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"stdcall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:180:1
+ --> $DIR/unsupported.rs:119:1
|
LL | extern "stdcall" {}
| ^^^^^^^^^^^^^^^^^^^
+ |
+ = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"`
+
+error[E0570]: `"stdcall-unwind"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:123:1
+ |
+LL | extern "stdcall-unwind" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"`
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:131:17
+ |
+LL | fn cdecl_ptr(f: extern "cdecl" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:136:1
+ |
+LL | extern "cdecl" {}
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:139:1
+ |
+LL | extern "cdecl-unwind" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C-unwind"` instead
warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target
- --> $DIR/unsupported.rs:187:21
+ --> $DIR/unsupported.rs:153:21
|
LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -114,7 +155,7 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target
- --> $DIR/unsupported.rs:195:22
+ --> $DIR/unsupported.rs:161:22
|
LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -123,71 +164,83 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:200:1
+ --> $DIR/unsupported.rs:166:1
|
LL | extern "C-cmse-nonsecure-entry" {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:33:1
+ --> $DIR/unsupported.rs:36:1
|
LL | extern "ptx-kernel" fn ptx() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:42:1
+ --> $DIR/unsupported.rs:45:1
|
LL | extern "gpu-kernel" fn gpu() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"aapcs"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:45:1
+ --> $DIR/unsupported.rs:48:1
|
LL | extern "aapcs" fn aapcs() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:71:1
+ --> $DIR/unsupported.rs:58:1
|
LL | extern "msp430-interrupt" fn msp430() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:81:1
+ --> $DIR/unsupported.rs:68:1
|
LL | extern "avr-interrupt" fn avr() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:91:1
+ --> $DIR/unsupported.rs:78:1
|
LL | extern "riscv-interrupt-m" fn riscv() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"thiscall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:135:1
+ --> $DIR/unsupported.rs:98:1
|
LL | extern "thiscall" fn thiscall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"stdcall"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:161:1
+ --> $DIR/unsupported.rs:108:1
|
LL | extern "stdcall" fn stdcall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"`
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:128:1
+ |
+LL | extern "cdecl" fn cdecl() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:193:1
+ --> $DIR/unsupported.rs:159:1
|
LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to 17 previous errors; 9 warnings emitted
+error: aborting due to 18 previous errors; 13 warnings emitted
For more information about this error, try `rustc --explain E0570`.
Future incompatibility report: Future breakage diagnostic:
warning: the calling convention "ptx-kernel" is not supported on this target
- --> $DIR/unsupported.rs:35:15
+ --> $DIR/unsupported.rs:38:15
|
LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -198,7 +251,7 @@
Future breakage diagnostic:
warning: the calling convention "aapcs" is not supported on this target
- --> $DIR/unsupported.rs:51:17
+ --> $DIR/unsupported.rs:50:17
|
LL | fn aapcs_ptr(f: extern "aapcs" fn()) {
| ^^^^^^^^^^^^^^^^^^^
@@ -209,7 +262,7 @@
Future breakage diagnostic:
warning: the calling convention "msp430-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:73:18
+ --> $DIR/unsupported.rs:60:18
|
LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -220,7 +273,7 @@
Future breakage diagnostic:
warning: the calling convention "avr-interrupt" is not supported on this target
- --> $DIR/unsupported.rs:83:15
+ --> $DIR/unsupported.rs:70:15
|
LL | fn avr_ptr(f: extern "avr-interrupt" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -231,7 +284,7 @@
Future breakage diagnostic:
warning: the calling convention "riscv-interrupt-m" is not supported on this target
- --> $DIR/unsupported.rs:96:17
+ --> $DIR/unsupported.rs:80:17
|
LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -242,7 +295,7 @@
Future breakage diagnostic:
warning: the calling convention "thiscall" is not supported on this target
- --> $DIR/unsupported.rs:141:20
+ --> $DIR/unsupported.rs:100:20
|
LL | fn thiscall_ptr(f: extern "thiscall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -253,7 +306,7 @@
Future breakage diagnostic:
warning: the calling convention "stdcall" is not supported on this target
- --> $DIR/unsupported.rs:167:19
+ --> $DIR/unsupported.rs:112:19
|
LL | fn stdcall_ptr(f: extern "stdcall" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^
@@ -263,8 +316,44 @@
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:131:17
+ |
+LL | fn cdecl_ptr(f: extern "cdecl" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:136:1
+ |
+LL | extern "cdecl" {}
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:139:1
+ |
+LL | extern "cdecl-unwind" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C-unwind"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target
- --> $DIR/unsupported.rs:187:21
+ --> $DIR/unsupported.rs:153:21
|
LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -275,7 +364,7 @@
Future breakage diagnostic:
warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target
- --> $DIR/unsupported.rs:195:22
+ --> $DIR/unsupported.rs:161:22
|
LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -284,3 +373,15 @@
= note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
= note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:128:1
+ |
+LL | extern "cdecl" fn cdecl() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
diff --git a/tests/ui/abi/unsupported.x64_win.stderr b/tests/ui/abi/unsupported.x64_win.stderr
new file mode 100644
index 0000000..328f4c3
--- /dev/null
+++ b/tests/ui/abi/unsupported.x64_win.stderr
@@ -0,0 +1,453 @@
+warning: the calling convention "ptx-kernel" is not supported on this target
+ --> $DIR/unsupported.rs:38:15
+ |
+LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+ = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
+
+error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:43:1
+ |
+LL | extern "ptx-kernel" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^
+
+warning: the calling convention "aapcs" is not supported on this target
+ --> $DIR/unsupported.rs:50:17
+ |
+LL | fn aapcs_ptr(f: extern "aapcs" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+
+error[E0570]: `"aapcs"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:55:1
+ |
+LL | extern "aapcs" {}
+ | ^^^^^^^^^^^^^^^^^
+
+warning: the calling convention "msp430-interrupt" is not supported on this target
+ --> $DIR/unsupported.rs:60:18
+ |
+LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+
+error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:65:1
+ |
+LL | extern "msp430-interrupt" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: the calling convention "avr-interrupt" is not supported on this target
+ --> $DIR/unsupported.rs:70:15
+ |
+LL | fn avr_ptr(f: extern "avr-interrupt" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+
+error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:75:1
+ |
+LL | extern "avr-interrupt" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: the calling convention "riscv-interrupt-m" is not supported on this target
+ --> $DIR/unsupported.rs:80:17
+ |
+LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+
+error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:85:1
+ |
+LL | extern "riscv-interrupt-m" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: the calling convention "thiscall" is not supported on this target
+ --> $DIR/unsupported.rs:100:20
+ |
+LL | fn thiscall_ptr(f: extern "thiscall" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+
+error[E0570]: `"thiscall"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:105:1
+ |
+LL | extern "thiscall" {}
+ | ^^^^^^^^^^^^^^^^^^^^
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:112:19
+ |
+LL | fn stdcall_ptr(f: extern "stdcall" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"`
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:119:1
+ |
+LL | extern "stdcall" {}
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"`
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:123:1
+ |
+LL | extern "stdcall-unwind" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"`
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:131:17
+ |
+LL | fn cdecl_ptr(f: extern "cdecl" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:136:1
+ |
+LL | extern "cdecl" {}
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:139:1
+ |
+LL | extern "cdecl-unwind" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C-unwind"` instead
+
+warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target
+ --> $DIR/unsupported.rs:153:21
+ |
+LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+
+warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target
+ --> $DIR/unsupported.rs:161:22
+ |
+LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+
+error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:166:1
+ |
+LL | extern "C-cmse-nonsecure-entry" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:171:1
+ |
+LL | extern "cdecl" {}
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+
+error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:36:1
+ |
+LL | extern "ptx-kernel" fn ptx() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:45:1
+ |
+LL | extern "gpu-kernel" fn gpu() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0570]: `"aapcs"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:48:1
+ |
+LL | extern "aapcs" fn aapcs() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:58:1
+ |
+LL | extern "msp430-interrupt" fn msp430() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:68:1
+ |
+LL | extern "avr-interrupt" fn avr() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:78:1
+ |
+LL | extern "riscv-interrupt-m" fn riscv() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0570]: `"thiscall"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:98:1
+ |
+LL | extern "thiscall" fn thiscall() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:108:1
+ |
+LL | extern "stdcall" fn stdcall() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"`
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:128:1
+ |
+LL | extern "cdecl" fn cdecl() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+
+error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:159:1
+ |
+LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 15 previous errors; 17 warnings emitted
+
+For more information about this error, try `rustc --explain E0570`.
+Future incompatibility report: Future breakage diagnostic:
+warning: the calling convention "ptx-kernel" is not supported on this target
+ --> $DIR/unsupported.rs:38:15
+ |
+LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+ = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: the calling convention "aapcs" is not supported on this target
+ --> $DIR/unsupported.rs:50:17
+ |
+LL | fn aapcs_ptr(f: extern "aapcs" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+ = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: the calling convention "msp430-interrupt" is not supported on this target
+ --> $DIR/unsupported.rs:60:18
+ |
+LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+ = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: the calling convention "avr-interrupt" is not supported on this target
+ --> $DIR/unsupported.rs:70:15
+ |
+LL | fn avr_ptr(f: extern "avr-interrupt" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+ = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: the calling convention "riscv-interrupt-m" is not supported on this target
+ --> $DIR/unsupported.rs:80:17
+ |
+LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+ = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: the calling convention "thiscall" is not supported on this target
+ --> $DIR/unsupported.rs:100:20
+ |
+LL | fn thiscall_ptr(f: extern "thiscall" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+ = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:112:19
+ |
+LL | fn stdcall_ptr(f: extern "stdcall" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"`
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:119:1
+ |
+LL | extern "stdcall" {}
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"`
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:123:1
+ |
+LL | extern "stdcall-unwind" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"`
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:131:17
+ |
+LL | fn cdecl_ptr(f: extern "cdecl" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:136:1
+ |
+LL | extern "cdecl" {}
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:139:1
+ |
+LL | extern "cdecl-unwind" {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C-unwind"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target
+ --> $DIR/unsupported.rs:153:21
+ |
+LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+ = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target
+ --> $DIR/unsupported.rs:161:22
+ |
+LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
+ = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:171:1
+ |
+LL | extern "cdecl" {}
+ | ^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:108:1
+ |
+LL | extern "stdcall" fn stdcall() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"`
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
+Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:128:1
+ |
+LL | extern "cdecl" fn cdecl() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: use `extern "C"` instead
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
diff --git a/tests/ui/array-slice-vec/array_const_index-0.stderr b/tests/ui/array-slice-vec/array_const_index-0.stderr
index 1080705..04cb684 100644
--- a/tests/ui/array-slice-vec/array_const_index-0.stderr
+++ b/tests/ui/array-slice-vec/array_const_index-0.stderr
@@ -2,7 +2,7 @@
--> $DIR/array_const_index-0.rs:2:16
|
LL | const B: i32 = (&A)[1];
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `B` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/array-slice-vec/array_const_index-1.stderr b/tests/ui/array-slice-vec/array_const_index-1.stderr
index 5629984..68b0267 100644
--- a/tests/ui/array-slice-vec/array_const_index-1.stderr
+++ b/tests/ui/array-slice-vec/array_const_index-1.stderr
@@ -2,7 +2,7 @@
--> $DIR/array_const_index-1.rs:2:16
|
LL | const B: i32 = A[1];
- | ^^^^ evaluation of constant value failed here
+ | ^^^^ evaluation of `B` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/async-await/async-block-control-flow-static-semantics.stderr b/tests/ui/async-await/async-block-control-flow-static-semantics.stderr
index 4ed15a9..b64690b 100644
--- a/tests/ui/async-await/async-block-control-flow-static-semantics.stderr
+++ b/tests/ui/async-await/async-block-control-flow-static-semantics.stderr
@@ -1,19 +1,3 @@
-error[E0267]: `break` inside `async` block
- --> $DIR/async-block-control-flow-static-semantics.rs:32:9
- |
-LL | async {
- | ----- enclosing `async` block
-LL | break 0u8;
- | ^^^^^^^^^ cannot `break` inside `async` block
-
-error[E0267]: `break` inside `async` block
- --> $DIR/async-block-control-flow-static-semantics.rs:39:13
- |
-LL | async {
- | ----- enclosing `async` block
-LL | break 0u8;
- | ^^^^^^^^^ cannot `break` inside `async` block
-
error[E0308]: mismatched types
--> $DIR/async-block-control-flow-static-semantics.rs:21:58
|
@@ -50,6 +34,22 @@
|
= note: required for the cast from `&{async block@$DIR/async-block-control-flow-static-semantics.rs:14:17: 14:22}` to `&dyn Future<Output = ()>`
+error[E0267]: `break` inside `async` block
+ --> $DIR/async-block-control-flow-static-semantics.rs:32:9
+ |
+LL | async {
+ | ----- enclosing `async` block
+LL | break 0u8;
+ | ^^^^^^^^^ cannot `break` inside `async` block
+
+error[E0267]: `break` inside `async` block
+ --> $DIR/async-block-control-flow-static-semantics.rs:39:13
+ |
+LL | async {
+ | ----- enclosing `async` block
+LL | break 0u8;
+ | ^^^^^^^^^ cannot `break` inside `async` block
+
error[E0308]: mismatched types
--> $DIR/async-block-control-flow-static-semantics.rs:49:44
|
diff --git a/tests/ui/async-await/async-closures/without-precise-captures-we-are-powerless.stderr b/tests/ui/async-await/async-closures/without-precise-captures-we-are-powerless.stderr
index 329cec6..b725907 100644
--- a/tests/ui/async-await/async-closures/without-precise-captures-we-are-powerless.stderr
+++ b/tests/ui/async-await/async-closures/without-precise-captures-we-are-powerless.stderr
@@ -106,11 +106,13 @@
error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/without-precise-captures-we-are-powerless.rs:38:5
|
-LL | fn through_field_and_ref<'a>(x: &S<'a>) {
- | ------ help: add explicit lifetime `'a` to the type of `x`: `&'a S<'a>`
-...
LL | outlives::<'a>(call_once(c));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `x`
+ |
+LL | fn through_field_and_ref<'a>(x: &'a S<'a>) {
+ | ++
error[E0597]: `c` does not live long enough
--> $DIR/without-precise-captures-we-are-powerless.rs:43:20
@@ -131,11 +133,13 @@
error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/without-precise-captures-we-are-powerless.rs:44:5
|
-LL | fn through_field_and_ref_move<'a>(x: &S<'a>) {
- | ------ help: add explicit lifetime `'a` to the type of `x`: `&'a S<'a>`
-...
LL | outlives::<'a>(call_once(c));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `x`
+ |
+LL | fn through_field_and_ref_move<'a>(x: &'a S<'a>) {
+ | ++
error: aborting due to 10 previous errors
diff --git a/tests/ui/async-await/issues/issue-63388-1.stderr b/tests/ui/async-await/issues/issue-63388-1.stderr
index 277f7fa..a59fe7d 100644
--- a/tests/ui/async-await/issues/issue-63388-1.stderr
+++ b/tests/ui/async-await/issues/issue-63388-1.stderr
@@ -1,11 +1,14 @@
error[E0621]: explicit lifetime required in the type of `foo`
--> $DIR/issue-63388-1.rs:14:9
|
-LL | &'a self, foo: &dyn Foo
- | -------- help: add explicit lifetime `'a` to the type of `foo`: `&'a (dyn Foo + 'a)`
-...
LL | foo
| ^^^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `foo`
+ |
+LL - &'a self, foo: &dyn Foo
+LL + &'a self, foo: &'a (dyn Foo + 'a)
+ |
error: aborting due to 1 previous error
diff --git a/tests/ui/custom_attribute.rs b/tests/ui/attributes/attr_unknown_custom_attr.rs
similarity index 80%
rename from tests/ui/custom_attribute.rs
rename to tests/ui/attributes/attr_unknown_custom_attr.rs
index 4957184..cdbe48a 100644
--- a/tests/ui/custom_attribute.rs
+++ b/tests/ui/attributes/attr_unknown_custom_attr.rs
@@ -1,3 +1,5 @@
+//! Checks error handling for undefined custom attributes.
+
#![feature(stmt_expr_attributes)]
#[foo] //~ ERROR cannot find attribute `foo` in this scope
diff --git a/tests/ui/custom_attribute.stderr b/tests/ui/attributes/attr_unknown_custom_attr.stderr
similarity index 68%
rename from tests/ui/custom_attribute.stderr
rename to tests/ui/attributes/attr_unknown_custom_attr.stderr
index 4023892..76c3b88 100644
--- a/tests/ui/custom_attribute.stderr
+++ b/tests/ui/attributes/attr_unknown_custom_attr.stderr
@@ -1,17 +1,17 @@
error: cannot find attribute `foo` in this scope
- --> $DIR/custom_attribute.rs:3:3
+ --> $DIR/attr_unknown_custom_attr.rs:5:3
|
LL | #[foo]
| ^^^
error: cannot find attribute `foo` in this scope
- --> $DIR/custom_attribute.rs:5:7
+ --> $DIR/attr_unknown_custom_attr.rs:7:7
|
LL | #[foo]
| ^^^
error: cannot find attribute `foo` in this scope
- --> $DIR/custom_attribute.rs:7:7
+ --> $DIR/attr_unknown_custom_attr.rs:9:7
|
LL | #[foo]
| ^^^
diff --git a/tests/ui/crate-name-attr-used.rs b/tests/ui/attributes/crate-name-attr-validation.rs
similarity index 68%
rename from tests/ui/crate-name-attr-used.rs
rename to tests/ui/attributes/crate-name-attr-validation.rs
index 5d5a58c..e27893c 100644
--- a/tests/ui/crate-name-attr-used.rs
+++ b/tests/ui/attributes/crate-name-attr-validation.rs
@@ -1,3 +1,5 @@
+//! Checks proper validation of the `#![crate_name]` attribute.
+
//@ run-pass
//@ compile-flags:--crate-name crate_name_attr_used -F unused-attributes
diff --git a/tests/ui/crate-name-mismatch.rs b/tests/ui/attributes/crate-name-mismatch.rs
similarity index 65%
rename from tests/ui/crate-name-mismatch.rs
rename to tests/ui/attributes/crate-name-mismatch.rs
index 7651e0f..0c343d7 100644
--- a/tests/ui/crate-name-mismatch.rs
+++ b/tests/ui/attributes/crate-name-mismatch.rs
@@ -1,3 +1,5 @@
+//! Checks error handling for mismatched `--crate-name` and `#![crate_name]` values.
+
//@ compile-flags: --crate-name foo
#![crate_name = "bar"]
diff --git a/tests/ui/crate-name-mismatch.stderr b/tests/ui/attributes/crate-name-mismatch.stderr
similarity index 82%
rename from tests/ui/crate-name-mismatch.stderr
rename to tests/ui/attributes/crate-name-mismatch.stderr
index 5115626..4021fbe 100644
--- a/tests/ui/crate-name-mismatch.stderr
+++ b/tests/ui/attributes/crate-name-mismatch.stderr
@@ -1,5 +1,5 @@
error: `--crate-name` and `#[crate_name]` are required to match, but `foo` != `bar`
- --> $DIR/crate-name-mismatch.rs:3:1
+ --> $DIR/crate-name-mismatch.rs:5:1
|
LL | #![crate_name = "bar"]
| ^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/custom-attribute-multisegment.rs b/tests/ui/attributes/custom_attr_multisegment_error.rs
similarity index 65%
rename from tests/ui/custom-attribute-multisegment.rs
rename to tests/ui/attributes/custom_attr_multisegment_error.rs
index 2434921..1045282 100644
--- a/tests/ui/custom-attribute-multisegment.rs
+++ b/tests/ui/attributes/custom_attr_multisegment_error.rs
@@ -1,4 +1,4 @@
-// Unresolved multi-segment attributes are not treated as custom.
+//! Unresolved multi-segment attributes are not treated as custom.
mod existent {}
diff --git a/tests/ui/custom-attribute-multisegment.stderr b/tests/ui/attributes/custom_attr_multisegment_error.stderr
similarity index 84%
rename from tests/ui/custom-attribute-multisegment.stderr
rename to tests/ui/attributes/custom_attr_multisegment_error.stderr
index 90ebe27..02bed22 100644
--- a/tests/ui/custom-attribute-multisegment.stderr
+++ b/tests/ui/attributes/custom_attr_multisegment_error.stderr
@@ -1,5 +1,5 @@
error[E0433]: failed to resolve: could not find `nonexistent` in `existent`
- --> $DIR/custom-attribute-multisegment.rs:5:13
+ --> $DIR/custom_attr_multisegment_error.rs:5:13
|
LL | #[existent::nonexistent]
| ^^^^^^^^^^^ could not find `nonexistent` in `existent`
diff --git a/tests/ui/auxiliary/typeid-intrinsic-aux1.rs b/tests/ui/auxiliary/typeid-intrinsic-aux1.rs
index 281c079..a028008 100644
--- a/tests/ui/auxiliary/typeid-intrinsic-aux1.rs
+++ b/tests/ui/auxiliary/typeid-intrinsic-aux1.rs
@@ -9,9 +9,9 @@
pub type F = Option<isize>;
pub type G = usize;
pub type H = &'static str;
-pub type I = Box<Fn()>;
-pub type I32Iterator = Iterator<Item=i32>;
-pub type U32Iterator = Iterator<Item=u32>;
+pub type I = Box<dyn Fn()>;
+pub type I32Iterator = dyn Iterator<Item=i32>;
+pub type U32Iterator = dyn Iterator<Item=u32>;
pub fn id_A() -> TypeId { TypeId::of::<A>() }
pub fn id_B() -> TypeId { TypeId::of::<B>() }
diff --git a/tests/ui/auxiliary/typeid-intrinsic-aux2.rs b/tests/ui/auxiliary/typeid-intrinsic-aux2.rs
index 281c079..a028008 100644
--- a/tests/ui/auxiliary/typeid-intrinsic-aux2.rs
+++ b/tests/ui/auxiliary/typeid-intrinsic-aux2.rs
@@ -9,9 +9,9 @@
pub type F = Option<isize>;
pub type G = usize;
pub type H = &'static str;
-pub type I = Box<Fn()>;
-pub type I32Iterator = Iterator<Item=i32>;
-pub type U32Iterator = Iterator<Item=u32>;
+pub type I = Box<dyn Fn()>;
+pub type I32Iterator = dyn Iterator<Item=i32>;
+pub type U32Iterator = dyn Iterator<Item=u32>;
pub fn id_A() -> TypeId { TypeId::of::<A>() }
pub fn id_B() -> TypeId { TypeId::of::<B>() }
diff --git a/tests/ui/borrowck/issue-81899.stderr b/tests/ui/borrowck/issue-81899.stderr
index d236a17..96fe2ad 100644
--- a/tests/ui/borrowck/issue-81899.stderr
+++ b/tests/ui/borrowck/issue-81899.stderr
@@ -2,7 +2,7 @@
--> $DIR/issue-81899.rs:6:24
|
LL | const _CONST: &[u8] = &f(&[], |_| {});
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_CONST` failed inside this call
|
note: inside `f::<{closure@$DIR/issue-81899.rs:6:31: 6:34}>`
--> $DIR/issue-81899.rs:13:5
diff --git a/tests/ui/borrowck/issue-88434-minimal-example.stderr b/tests/ui/borrowck/issue-88434-minimal-example.stderr
index 3d9cc96..3921c47 100644
--- a/tests/ui/borrowck/issue-88434-minimal-example.stderr
+++ b/tests/ui/borrowck/issue-88434-minimal-example.stderr
@@ -2,7 +2,7 @@
--> $DIR/issue-88434-minimal-example.rs:5:22
|
LL | const _CONST: &() = &f(&|_| {});
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_CONST` failed inside this call
|
note: inside `f::<{closure@$DIR/issue-88434-minimal-example.rs:5:25: 5:28}>`
--> $DIR/issue-88434-minimal-example.rs:12:5
diff --git a/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr b/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr
index 90d7f36..c7f945d 100644
--- a/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr
+++ b/tests/ui/borrowck/issue-88434-removal-index-should-be-less.stderr
@@ -2,7 +2,7 @@
--> $DIR/issue-88434-removal-index-should-be-less.rs:5:24
|
LL | const _CONST: &[u8] = &f(&[], |_| {});
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_CONST` failed inside this call
|
note: inside `f::<{closure@$DIR/issue-88434-removal-index-should-be-less.rs:5:31: 5:34}>`
--> $DIR/issue-88434-removal-index-should-be-less.rs:12:5
diff --git a/tests/ui/box/empty-alloc-deref-rvalue.rs b/tests/ui/box/empty-alloc-deref-rvalue.rs
new file mode 100644
index 0000000..507a753
--- /dev/null
+++ b/tests/ui/box/empty-alloc-deref-rvalue.rs
@@ -0,0 +1,10 @@
+//! Smoke test: dereferencing boxed zero-sized types (ZSTs) should not crash.
+//!
+//! Originally a regression test of github.com/rust-lang/rust/issues/13360
+//! but repurposed for a smoke test.
+
+//@ run-pass
+
+pub fn main() {
+ let _: () = *Box::new(());
+}
diff --git a/tests/ui/check-cfg/hrtb-crash.rs b/tests/ui/check-cfg/hrtb-crash.rs
new file mode 100644
index 0000000..f2bce33
--- /dev/null
+++ b/tests/ui/check-cfg/hrtb-crash.rs
@@ -0,0 +1,7 @@
+// https://github.com/rust-lang/rust/issues/139825
+//@ compile-flags: --check-cfg=cfg(docsrs,test) --crate-type lib
+//@ check-pass
+struct A
+where
+ for<#[cfg(b)] c> u8:;
+//~^ WARN: unexpected `cfg` condition name
diff --git a/tests/ui/check-cfg/hrtb-crash.stderr b/tests/ui/check-cfg/hrtb-crash.stderr
new file mode 100644
index 0000000..431cf9c
--- /dev/null
+++ b/tests/ui/check-cfg/hrtb-crash.stderr
@@ -0,0 +1,13 @@
+warning: unexpected `cfg` condition name: `b`
+ --> $DIR/hrtb-crash.rs:6:15
+ |
+LL | for<#[cfg(b)] c> u8:;
+ | ^ help: found config with similar value: `target_feature = "b"`
+ |
+ = help: expected names are: `FALSE`, `docsrs`, and `test` and 31 more
+ = help: to expect this configuration use `--check-cfg=cfg(b)`
+ = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
+ = note: `#[warn(unexpected_cfgs)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr
index 7cda6c2e..532c1ab 100644
--- a/tests/ui/check-cfg/well-known-values.stderr
+++ b/tests/ui/check-cfg/well-known-values.stderr
@@ -138,7 +138,7 @@
LL | target_arch = "_UNEXPECTED_VALUE",
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
- = note: expected values for `target_arch` are: `aarch64`, `amdgpu`, `arm`, `arm64ec`, `avr`, `bpf`, `csky`, `hexagon`, `loongarch64`, `m68k`, `mips`, `mips32r6`, `mips64`, `mips64r6`, `msp430`, `nvptx64`, `powerpc`, `powerpc64`, `riscv32`, `riscv64`, `s390x`, `sparc`, `sparc64`, `wasm32`, `wasm64`, `x86`, `x86_64`, and `xtensa`
+ = note: expected values for `target_arch` are: `aarch64`, `amdgpu`, `arm`, `arm64ec`, `avr`, `bpf`, `csky`, `hexagon`, `loongarch32`, `loongarch64`, `m68k`, `mips`, `mips32r6`, `mips64`, `mips64r6`, `msp430`, `nvptx64`, `powerpc`, `powerpc64`, `riscv32`, `riscv64`, `s390x`, `sparc`, `sparc64`, `wasm32`, `wasm64`, `x86`, `x86_64`, and `xtensa`
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
diff --git a/tests/ui/coherence/const-errs-dont-conflict-103369.stderr b/tests/ui/coherence/const-errs-dont-conflict-103369.stderr
index e577a36..c8ed75a 100644
--- a/tests/ui/coherence/const-errs-dont-conflict-103369.stderr
+++ b/tests/ui/coherence/const-errs-dont-conflict-103369.stderr
@@ -2,7 +2,7 @@
--> $DIR/const-errs-dont-conflict-103369.rs:5:25
|
LL | impl ConstGenericTrait<{my_fn(1)}> for () {}
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `<() as ConstGenericTrait<{my_fn(1)}>>::{constant#0}` failed inside this call
|
note: inside `my_fn`
--> $DIR/const-errs-dont-conflict-103369.rs:10:5
@@ -14,7 +14,7 @@
--> $DIR/const-errs-dont-conflict-103369.rs:7:25
|
LL | impl ConstGenericTrait<{my_fn(2)}> for () {}
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `<() as ConstGenericTrait<{my_fn(2)}>>::{constant#0}` failed inside this call
|
note: inside `my_fn`
--> $DIR/const-errs-dont-conflict-103369.rs:10:5
diff --git a/tests/ui/complex.rs b/tests/ui/complex.rs
deleted file mode 100644
index d1da9d1..0000000
--- a/tests/ui/complex.rs
+++ /dev/null
@@ -1,38 +0,0 @@
-//@ run-pass
-
-#![allow(unconditional_recursion)]
-#![allow(non_camel_case_types)]
-#![allow(dead_code)]
-#![allow(unused_mut)]
-
-
-
-type t = isize;
-
-fn nothing() { }
-
-fn putstr(_s: String) { }
-
-fn putint(_i: isize) {
- let mut i: isize = 33;
- while i < 36 { putstr("hi".to_string()); i = i + 1; }
-}
-
-fn zerg(i: isize) -> isize { return i; }
-
-fn foo(x: isize) -> isize {
- let mut y: t = x + 2;
- putstr("hello".to_string());
- while y < 10 { putint(y); if y * 3 == 4 { y = y + 2; nothing(); } }
- let mut z: t;
- z = 0x55;
- foo(z);
- return 0;
-}
-
-pub fn main() {
- let x: isize = 2 + 2;
- println!("{}", x);
- println!("hello, world");
- println!("{}", 10);
-}
diff --git a/tests/ui/const-generics/const-arg-in-const-arg.min.stderr b/tests/ui/const-generics/const-arg-in-const-arg.min.stderr
index 16512cb..ebb3e82 100644
--- a/tests/ui/const-generics/const-arg-in-const-arg.min.stderr
+++ b/tests/ui/const-generics/const-arg-in-const-arg.min.stderr
@@ -13,7 +13,7 @@
LL | let _: [u8; bar::<N>()];
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
@@ -58,7 +58,7 @@
LL | let _ = [0; bar::<N>()];
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
@@ -112,7 +112,7 @@
LL | let _: Foo<{ bar::<N>() }>;
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
@@ -166,7 +166,7 @@
LL | let _ = Foo::<{ bar::<N>() }>;
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
diff --git a/tests/ui/const-generics/defaults/complex-generic-default-expr.min.stderr b/tests/ui/const-generics/defaults/complex-generic-default-expr.min.stderr
index 199546c..e41e488 100644
--- a/tests/ui/const-generics/defaults/complex-generic-default-expr.min.stderr
+++ b/tests/ui/const-generics/defaults/complex-generic-default-expr.min.stderr
@@ -4,7 +4,7 @@
LL | struct Foo<const N: usize, const M: usize = { N + 1 }>;
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
diff --git a/tests/ui/const-generics/defaults/default-param-wf-concrete.next.stderr b/tests/ui/const-generics/defaults/default-param-wf-concrete.next.stderr
index 3299c27..133d8f6 100644
--- a/tests/ui/const-generics/defaults/default-param-wf-concrete.next.stderr
+++ b/tests/ui/const-generics/defaults/default-param-wf-concrete.next.stderr
@@ -2,7 +2,7 @@
--> $DIR/default-param-wf-concrete.rs:4:28
|
LL | struct Foo<const N: u8 = { 255 + 1 }>;
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `Foo::{constant#0}` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/const-generics/defaults/default-param-wf-concrete.old.stderr b/tests/ui/const-generics/defaults/default-param-wf-concrete.old.stderr
index 3299c27..133d8f6 100644
--- a/tests/ui/const-generics/defaults/default-param-wf-concrete.old.stderr
+++ b/tests/ui/const-generics/defaults/default-param-wf-concrete.old.stderr
@@ -2,7 +2,7 @@
--> $DIR/default-param-wf-concrete.rs:4:28
|
LL | struct Foo<const N: u8 = { 255 + 1 }>;
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `Foo::{constant#0}` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/const-generics/defaults/wfness.stderr b/tests/ui/const-generics/defaults/wfness.stderr
index ef5167c..4f42afe 100644
--- a/tests/ui/const-generics/defaults/wfness.stderr
+++ b/tests/ui/const-generics/defaults/wfness.stderr
@@ -2,7 +2,7 @@
--> $DIR/wfness.rs:1:33
|
LL | struct Ooopsies<const N: u8 = { u8::MAX + 1 }>;
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `Ooopsies::{constant#0}` failed here
error[E0277]: the trait bound `(): Trait<2>` is not satisfied
--> $DIR/wfness.rs:8:9
diff --git a/tests/ui/const-generics/early/const_arg_trivial_macro_expansion-4.stderr b/tests/ui/const-generics/early/const_arg_trivial_macro_expansion-4.stderr
index 4722968..a1aee04 100644
--- a/tests/ui/const-generics/early/const_arg_trivial_macro_expansion-4.stderr
+++ b/tests/ui/const-generics/early/const_arg_trivial_macro_expansion-4.stderr
@@ -7,7 +7,7 @@
LL | fn foo<const N: usize>() -> Foo<{ arg!{} arg!{} }> { loop {} }
| ------ in this macro invocation
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
= note: this error originates in the macro `arg` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -20,7 +20,7 @@
LL | fn foo<const N: usize>() -> Foo<{ arg!{} arg!{} }> { loop {} }
| ------ in this macro invocation
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
= note: this error originates in the macro `arg` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -30,7 +30,7 @@
LL | fn bar<const N: usize>() -> [(); { empty!{}; N }] { loop {} }
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to 3 previous errors
diff --git a/tests/ui/const-generics/early/macro_rules-braces.stderr b/tests/ui/const-generics/early/macro_rules-braces.stderr
index 3269506..30efa18 100644
--- a/tests/ui/const-generics/early/macro_rules-braces.stderr
+++ b/tests/ui/const-generics/early/macro_rules-braces.stderr
@@ -26,7 +26,7 @@
LL | let _: foo!({{ N }});
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
@@ -35,7 +35,7 @@
LL | let _: bar!({ N });
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
@@ -44,7 +44,7 @@
LL | let _: baz!({{ N }});
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
@@ -53,7 +53,7 @@
LL | let _: biz!({ N });
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to 6 previous errors
diff --git a/tests/ui/const-generics/early/trivial-const-arg-macro-nested-braces-2.stderr b/tests/ui/const-generics/early/trivial-const-arg-macro-nested-braces-2.stderr
index e40d059..d68715b 100644
--- a/tests/ui/const-generics/early/trivial-const-arg-macro-nested-braces-2.stderr
+++ b/tests/ui/const-generics/early/trivial-const-arg-macro-nested-braces-2.stderr
@@ -7,7 +7,7 @@
LL | fn foo<const N: usize>() -> A<{{ y!() }}> {
| ---- in this macro invocation
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
= note: this error originates in the macro `y` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/const-generics/early/trivial-const-arg-macro-nested-braces.stderr b/tests/ui/const-generics/early/trivial-const-arg-macro-nested-braces.stderr
index b91d6c7..1171b35 100644
--- a/tests/ui/const-generics/early/trivial-const-arg-macro-nested-braces.stderr
+++ b/tests/ui/const-generics/early/trivial-const-arg-macro-nested-braces.stderr
@@ -7,7 +7,7 @@
LL | fn foo<const N: usize>() -> A<{ y!() }> {
| ---- in this macro invocation
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
= note: this error originates in the macro `y` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/const-generics/early/trivial-const-arg-nested-braces.stderr b/tests/ui/const-generics/early/trivial-const-arg-nested-braces.stderr
index d60516b..b812e33 100644
--- a/tests/ui/const-generics/early/trivial-const-arg-nested-braces.stderr
+++ b/tests/ui/const-generics/early/trivial-const-arg-nested-braces.stderr
@@ -4,7 +4,7 @@
LL | fn foo<const N: usize>() -> A<{ { N } }> {
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to 1 previous error
diff --git a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr
index a8b6f06..1f93c4f 100644
--- a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr
@@ -4,7 +4,7 @@
LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
@@ -13,7 +13,7 @@
LL | arr: [u8; CFG.arr_size],
| ^^^ cannot perform const operation using `CFG`
|
- = help: const parameters may only be used as standalone arguments, i.e. `CFG`
+ = help: const parameters may only be used as standalone arguments here, i.e. `CFG`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: `Config` is forbidden as the type of a const generic parameter
diff --git a/tests/ui/const-generics/generic_const_exprs/bad-multiply.stderr b/tests/ui/const-generics/generic_const_exprs/bad-multiply.stderr
index a8d6ceb..7719831 100644
--- a/tests/ui/const-generics/generic_const_exprs/bad-multiply.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/bad-multiply.stderr
@@ -4,7 +4,7 @@
LL | SmallVec<{ D * 2 }>:,
| ^ cannot perform const operation using `D`
|
- = help: const parameters may only be used as standalone arguments, i.e. `D`
+ = help: const parameters may only be used as standalone arguments here, i.e. `D`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error[E0747]: constant provided when a type was expected
diff --git a/tests/ui/const-generics/generic_const_exprs/feature-gate-generic_const_exprs.stderr b/tests/ui/const-generics/generic_const_exprs/feature-gate-generic_const_exprs.stderr
index 9c4e3d8..3208bbb 100644
--- a/tests/ui/const-generics/generic_const_exprs/feature-gate-generic_const_exprs.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/feature-gate-generic_const_exprs.stderr
@@ -4,7 +4,7 @@
LL | type Arr<const N: usize> = [u8; N - 1];
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to 1 previous error
diff --git a/tests/ui/const-generics/generic_const_exprs/issue-72787.min.stderr b/tests/ui/const-generics/generic_const_exprs/issue-72787.min.stderr
index 2454b31..cccf6dc 100644
--- a/tests/ui/const-generics/generic_const_exprs/issue-72787.min.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/issue-72787.min.stderr
@@ -4,7 +4,7 @@
LL | Condition<{ LHS <= RHS }>: True
| ^^^ cannot perform const operation using `LHS`
|
- = help: const parameters may only be used as standalone arguments, i.e. `LHS`
+ = help: const parameters may only be used as standalone arguments here, i.e. `LHS`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
@@ -13,7 +13,7 @@
LL | Condition<{ LHS <= RHS }>: True
| ^^^ cannot perform const operation using `RHS`
|
- = help: const parameters may only be used as standalone arguments, i.e. `RHS`
+ = help: const parameters may only be used as standalone arguments here, i.e. `RHS`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
@@ -22,7 +22,7 @@
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
| ^ cannot perform const operation using `I`
|
- = help: const parameters may only be used as standalone arguments, i.e. `I`
+ = help: const parameters may only be used as standalone arguments here, i.e. `I`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
@@ -31,7 +31,7 @@
LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
| ^ cannot perform const operation using `J`
|
- = help: const parameters may only be used as standalone arguments, i.e. `J`
+ = help: const parameters may only be used as standalone arguments here, i.e. `J`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to 4 previous errors
diff --git a/tests/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.min.stderr b/tests/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.min.stderr
index c504464..f91a2a3 100644
--- a/tests/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.min.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.min.stderr
@@ -4,7 +4,7 @@
LL | where Assert::<{N < usize::MAX / 2}>: IsTrue,
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to 1 previous error
diff --git a/tests/ui/const-generics/generic_const_exprs/trivial-anon-const-use-cases.full.stderr b/tests/ui/const-generics/generic_const_exprs/trivial-anon-const-use-cases.full.stderr
new file mode 100644
index 0000000..586ac63
--- /dev/null
+++ b/tests/ui/const-generics/generic_const_exprs/trivial-anon-const-use-cases.full.stderr
@@ -0,0 +1,13 @@
+error: unconstrained generic constant
+ --> $DIR/trivial-anon-const-use-cases.rs:14:12
+ |
+LL | stuff: [u8; { S + 1 }], // `S + 1` is NOT a valid const expression in this context.
+ | ^^^^^^^^^^^^^^^
+ |
+help: try adding a `where` bound
+ |
+LL | struct Y<const S: usize> where [(); { S + 1 }]: {
+ | ++++++++++++++++++++++
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/const-generics/generic_const_exprs/trivial-anon-const-use-cases.min.stderr b/tests/ui/const-generics/generic_const_exprs/trivial-anon-const-use-cases.min.stderr
new file mode 100644
index 0000000..6a868e9
--- /dev/null
+++ b/tests/ui/const-generics/generic_const_exprs/trivial-anon-const-use-cases.min.stderr
@@ -0,0 +1,11 @@
+error: generic parameters may not be used in const operations
+ --> $DIR/trivial-anon-const-use-cases.rs:14:19
+ |
+LL | stuff: [u8; { S + 1 }], // `S + 1` is NOT a valid const expression in this context.
+ | ^ cannot perform const operation using `S`
+ |
+ = help: const parameters may only be used as standalone arguments here, i.e. `S`
+ = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/const-generics/generic_const_exprs/trivial-anon-const-use-cases.rs b/tests/ui/const-generics/generic_const_exprs/trivial-anon-const-use-cases.rs
new file mode 100644
index 0000000..b1fd4cb
--- /dev/null
+++ b/tests/ui/const-generics/generic_const_exprs/trivial-anon-const-use-cases.rs
@@ -0,0 +1,19 @@
+//! Regression test for <https://github.com/rust-lang/rust/issues/79429>.
+
+//@ revisions: full min
+#![cfg_attr(full, feature(generic_const_exprs))]
+#![cfg_attr(full, allow(incomplete_features))]
+
+struct X<const S: usize>;
+
+impl<const S: usize> X<S> {
+ const LEN: usize = S + 1; // `S + 1` is a valid const expression in this context.
+}
+
+struct Y<const S: usize> {
+ stuff: [u8; { S + 1 }], // `S + 1` is NOT a valid const expression in this context.
+ //[min]~^ ERROR generic parameters may not be used in const operations
+ //[full]~^^ ERROR unconstrained generic constant
+}
+
+fn main() {}
diff --git a/tests/ui/const-generics/issues/issue-100313.stderr b/tests/ui/const-generics/issues/issue-100313.stderr
index 2ae4c30..d1a0249 100644
--- a/tests/ui/const-generics/issues/issue-100313.stderr
+++ b/tests/ui/const-generics/issues/issue-100313.stderr
@@ -2,7 +2,7 @@
--> $DIR/issue-100313.rs:18:5
|
LL | x.set_false();
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `_` failed inside this call
|
note: inside `T::<&true>::set_false`
--> $DIR/issue-100313.rs:11:13
diff --git a/tests/ui/const-generics/issues/issue-68366.min.stderr b/tests/ui/const-generics/issues/issue-68366.min.stderr
index 10b5a06..4d721e9 100644
--- a/tests/ui/const-generics/issues/issue-68366.min.stderr
+++ b/tests/ui/const-generics/issues/issue-68366.min.stderr
@@ -4,7 +4,7 @@
LL | impl <const N: usize> Collatz<{Some(N)}> {}
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: `Option<usize>` is forbidden as the type of a const generic parameter
diff --git a/tests/ui/const-generics/issues/issue-76701-ty-param-in-const.stderr b/tests/ui/const-generics/issues/issue-76701-ty-param-in-const.stderr
index da2fbc5..e58c894 100644
--- a/tests/ui/const-generics/issues/issue-76701-ty-param-in-const.stderr
+++ b/tests/ui/const-generics/issues/issue-76701-ty-param-in-const.stderr
@@ -13,7 +13,7 @@
LL | fn const_param<const N: usize>() -> [u8; N + 1] {
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to 2 previous errors
diff --git a/tests/ui/const-generics/issues/issue-80375.stderr b/tests/ui/const-generics/issues/issue-80375.stderr
index 015196f..9a15e03 100644
--- a/tests/ui/const-generics/issues/issue-80375.stderr
+++ b/tests/ui/const-generics/issues/issue-80375.stderr
@@ -4,7 +4,7 @@
LL | struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
| ^^^^^ cannot perform const operation using `COUNT`
|
- = help: const parameters may only be used as standalone arguments, i.e. `COUNT`
+ = help: const parameters may only be used as standalone arguments here, i.e. `COUNT`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to 1 previous error
diff --git a/tests/ui/const-generics/legacy-const-generics-bad.stderr b/tests/ui/const-generics/legacy-const-generics-bad.stderr
index 3a5fa41..a8681d6 100644
--- a/tests/ui/const-generics/legacy-const-generics-bad.stderr
+++ b/tests/ui/const-generics/legacy-const-generics-bad.stderr
@@ -16,7 +16,7 @@
LL | legacy_const_generics::foo(0, N + 1, 2);
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to 2 previous errors
diff --git a/tests/ui/const-generics/min_const_generics/complex-expression.stderr b/tests/ui/const-generics/min_const_generics/complex-expression.stderr
index 3affdcf..35039bb 100644
--- a/tests/ui/const-generics/min_const_generics/complex-expression.stderr
+++ b/tests/ui/const-generics/min_const_generics/complex-expression.stderr
@@ -4,7 +4,7 @@
LL | struct Break0<const N: usize>([u8; { N + 1 }]);
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
@@ -13,7 +13,7 @@
LL | struct Break1<const N: usize>([u8; { { N } }]);
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
@@ -22,7 +22,7 @@
LL | let _: [u8; N + 1];
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
@@ -31,7 +31,7 @@
LL | let _ = [0; N + 1];
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
diff --git a/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr b/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr
index 172fd37..92b226f 100644
--- a/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr
+++ b/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr
@@ -2,7 +2,7 @@
--> $DIR/invalid-patterns.rs:40:32
|
LL | get_flag::<false, { unsafe { char_raw.character } }>();
- | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^ evaluation of `main::{constant#7}` failed here
error[E0080]: constructing invalid value: encountered 0x42, but expected a boolean
--> $DIR/invalid-patterns.rs:42:14
@@ -30,7 +30,7 @@
--> $DIR/invalid-patterns.rs:44:58
|
LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>();
- | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^ evaluation of `main::{constant#11}` failed here
error[E0308]: mismatched types
--> $DIR/invalid-patterns.rs:31:21
diff --git a/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr b/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr
index 172fd37..92b226f 100644
--- a/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr
+++ b/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr
@@ -2,7 +2,7 @@
--> $DIR/invalid-patterns.rs:40:32
|
LL | get_flag::<false, { unsafe { char_raw.character } }>();
- | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^ evaluation of `main::{constant#7}` failed here
error[E0080]: constructing invalid value: encountered 0x42, but expected a boolean
--> $DIR/invalid-patterns.rs:42:14
@@ -30,7 +30,7 @@
--> $DIR/invalid-patterns.rs:44:58
|
LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>();
- | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^ evaluation of `main::{constant#11}` failed here
error[E0308]: mismatched types
--> $DIR/invalid-patterns.rs:31:21
diff --git a/tests/ui/const-generics/repeat_expr_hack_gives_right_generics.stderr b/tests/ui/const-generics/repeat_expr_hack_gives_right_generics.stderr
index ead6c62..fe32fbc 100644
--- a/tests/ui/const-generics/repeat_expr_hack_gives_right_generics.stderr
+++ b/tests/ui/const-generics/repeat_expr_hack_gives_right_generics.stderr
@@ -4,7 +4,7 @@
LL | bar::<{ [1; N] }>();
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
@@ -13,7 +13,7 @@
LL | bar::<{ [1; { N + 1 }] }>();
| ^ cannot perform const operation using `N`
|
- = help: const parameters may only be used as standalone arguments, i.e. `N`
+ = help: const parameters may only be used as standalone arguments here, i.e. `N`
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to 2 previous errors
diff --git a/tests/ui/const-ptr/forbidden_slices.stderr b/tests/ui/const-ptr/forbidden_slices.stderr
index d4dcc6e..25d6f04 100644
--- a/tests/ui/const-ptr/forbidden_slices.stderr
+++ b/tests/ui/const-ptr/forbidden_slices.stderr
@@ -103,13 +103,13 @@
--> $DIR/forbidden_slices.rs:50:33
|
LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; // errors inside libcore
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `R1` failed here
error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC10 which is only 4 bytes from the end of the allocation
--> $DIR/forbidden_slices.rs:54:25
|
LL | from_ptr_range(ptr..ptr.add(2)) // errors inside libcore
- | ^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^ evaluation of `R2` failed here
error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitialized memory, but expected an integer
--> $DIR/forbidden_slices.rs:57:1
@@ -161,19 +161,19 @@
--> $DIR/forbidden_slices.rs:79:25
|
LL | from_ptr_range(ptr..ptr.add(1))
- | ^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^ evaluation of `R8` failed here
error[E0080]: `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation
--> $DIR/forbidden_slices.rs:85:34
|
LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `R9` failed here
error[E0080]: `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation
--> $DIR/forbidden_slices.rs:87:35
|
LL | pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `R10` failed here
error: aborting due to 18 previous errors
diff --git a/tests/ui/const-ptr/out_of_bounds_read.stderr b/tests/ui/const-ptr/out_of_bounds_read.stderr
index e921a5f..a98765b 100644
--- a/tests/ui/const-ptr/out_of_bounds_read.stderr
+++ b/tests/ui/const-ptr/out_of_bounds_read.stderr
@@ -2,19 +2,19 @@
--> $DIR/out_of_bounds_read.rs:8:33
|
LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
- | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_READ` failed here
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
--> $DIR/out_of_bounds_read.rs:10:39
|
LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
- | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `main::_CONST_READ` failed here
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
--> $DIR/out_of_bounds_read.rs:12:37
|
LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_MUT_READ` failed here
error: aborting due to 3 previous errors
diff --git a/tests/ui/constructor-lifetime-args.rs b/tests/ui/constructor-lifetime-args.rs
deleted file mode 100644
index f5802e7..0000000
--- a/tests/ui/constructor-lifetime-args.rs
+++ /dev/null
@@ -1,26 +0,0 @@
-// All lifetime parameters in struct constructors are currently considered early bound,
-// i.e., `S::<ARGS>` is interpreted kinda like an associated item `S::<ARGS>::ctor`.
-// This behavior is a bit weird, because if equivalent constructor were written manually
-// it would get late bound lifetime parameters.
-// Variant constructors behave in the same way, lifetime parameters are considered
-// belonging to the enum and being early bound.
-// https://github.com/rust-lang/rust/issues/30904
-
-struct S<'a, 'b>(&'a u8, &'b u8);
-enum E<'a, 'b> {
- V(&'a u8),
- U(&'b u8),
-}
-
-fn main() {
- S(&0, &0); // OK
- S::<'static>(&0, &0);
- //~^ ERROR struct takes 2 lifetime arguments
- S::<'static, 'static, 'static>(&0, &0);
- //~^ ERROR struct takes 2 lifetime arguments
- E::V(&0); // OK
- E::V::<'static>(&0);
- //~^ ERROR enum takes 2 lifetime arguments
- E::V::<'static, 'static, 'static>(&0);
- //~^ ERROR enum takes 2 lifetime arguments
-}
diff --git a/tests/ui/consts/assert-type-intrinsics.stderr b/tests/ui/consts/assert-type-intrinsics.stderr
index 90f00371..92fc90a 100644
--- a/tests/ui/consts/assert-type-intrinsics.stderr
+++ b/tests/ui/consts/assert-type-intrinsics.stderr
@@ -2,19 +2,19 @@
--> $DIR/assert-type-intrinsics.rs:11:9
|
LL | MaybeUninit::<!>::uninit().assume_init();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_BAD1` failed here
error[E0080]: evaluation panicked: aborted execution: attempted to leave type `&i32` uninitialized, which is invalid
--> $DIR/assert-type-intrinsics.rs:15:9
|
LL | intrinsics::assert_mem_uninitialized_valid::<&'static i32>();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_BAD2` failed here
error[E0080]: evaluation panicked: aborted execution: attempted to zero-initialize type `&i32`, which is invalid
--> $DIR/assert-type-intrinsics.rs:19:9
|
LL | intrinsics::assert_zero_valid::<&'static i32>();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_BAD3` failed here
error: aborting due to 3 previous errors
diff --git a/tests/ui/consts/const-array-oob.stderr b/tests/ui/consts/const-array-oob.stderr
index d4a0266..7d5f234 100644
--- a/tests/ui/consts/const-array-oob.stderr
+++ b/tests/ui/consts/const-array-oob.stderr
@@ -2,13 +2,13 @@
--> $DIR/const-array-oob.rs:5:19
|
LL | const BLUB: [u32; FOO[4]] = [5, 6];
- | ^^^^^^ evaluation of constant value failed here
+ | ^^^^^^ evaluation of `BLUB::{constant#0}` failed here
error[E0080]: index out of bounds: the length is 3 but the index is 5
--> $DIR/const-array-oob.rs:2:20
|
LL | const BAR: usize = FOO[5];
- | ^^^^^^ evaluation of constant value failed here
+ | ^^^^^^ evaluation of `BAR` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/consts/const-assert-unchecked-ub.stderr b/tests/ui/consts/const-assert-unchecked-ub.stderr
index 0a78594..d8e68fc 100644
--- a/tests/ui/consts/const-assert-unchecked-ub.stderr
+++ b/tests/ui/consts/const-assert-unchecked-ub.stderr
@@ -2,7 +2,7 @@
--> $DIR/const-assert-unchecked-ub.rs:3:5
|
LL | std::hint::assert_unchecked(n < 32);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-compare-bytes-ub.stderr b/tests/ui/consts/const-compare-bytes-ub.stderr
index 1b3824f..c1706a8 100644
--- a/tests/ui/consts/const-compare-bytes-ub.stderr
+++ b/tests/ui/consts/const-compare-bytes-ub.stderr
@@ -2,49 +2,49 @@
--> $DIR/const-compare-bytes-ub.rs:9:9
|
LL | compare_bytes(0 as *const u8, 2 as *const u8, 1)
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::LHS_NULL` failed here
error[E0080]: memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
--> $DIR/const-compare-bytes-ub.rs:13:9
|
LL | compare_bytes(1 as *const u8, 0 as *const u8, 1)
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::RHS_NULL` failed here
error[E0080]: memory access failed: attempting to access 1 byte, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
--> $DIR/const-compare-bytes-ub.rs:17:9
|
LL | compare_bytes(1 as *const u8, 2 as *const u8, 1)
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::DANGLING_PTR_NON_ZERO_LENGTH` failed here
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0 which is only 3 bytes from the end of the allocation
--> $DIR/const-compare-bytes-ub.rs:21:9
|
LL | compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4)
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::LHS_OUT_OF_BOUNDS` failed here
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC1 which is only 3 bytes from the end of the allocation
--> $DIR/const-compare-bytes-ub.rs:25:9
|
LL | compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4)
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::RHS_OUT_OF_BOUNDS` failed here
error[E0080]: reading memory at ALLOC2[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
--> $DIR/const-compare-bytes-ub.rs:29:9
|
LL | compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1)
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::LHS_UNINIT` failed here
error[E0080]: reading memory at ALLOC3[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory
--> $DIR/const-compare-bytes-ub.rs:33:9
|
LL | compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1)
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::RHS_UNINIT` failed here
error[E0080]: unable to turn pointer into integer
--> $DIR/const-compare-bytes-ub.rs:37:9
|
LL | compare_bytes([&1].as_ptr().cast(), [&2].as_ptr().cast(), std::mem::size_of::<usize>())
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::WITH_PROVENANCE` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
diff --git a/tests/ui/consts/const-deref-ptr.stderr b/tests/ui/consts/const-deref-ptr.stderr
index f233b7d..aa89aed 100644
--- a/tests/ui/consts/const-deref-ptr.stderr
+++ b/tests/ui/consts/const-deref-ptr.stderr
@@ -2,7 +2,7 @@
--> $DIR/const-deref-ptr.rs:4:30
|
LL | static C: u64 = unsafe { *(0xdeadbeef as *const u64) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::C` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-err-early.stderr b/tests/ui/consts/const-err-early.stderr
index 98f9b4f..2d8dd08 100644
--- a/tests/ui/consts/const-err-early.stderr
+++ b/tests/ui/consts/const-err-early.stderr
@@ -2,31 +2,31 @@
--> $DIR/const-err-early.rs:1:19
|
LL | pub const A: i8 = -i8::MIN;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `A` failed here
error[E0080]: attempt to compute `200_u8 + 200_u8`, which would overflow
--> $DIR/const-err-early.rs:2:19
|
LL | pub const B: u8 = 200u8 + 200u8;
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `B` failed here
error[E0080]: attempt to compute `200_u8 * 4_u8`, which would overflow
--> $DIR/const-err-early.rs:3:19
|
LL | pub const C: u8 = 200u8 * 4;
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `C` failed here
error[E0080]: attempt to compute `42_u8 - 43_u8`, which would overflow
--> $DIR/const-err-early.rs:4:19
|
LL | pub const D: u8 = 42u8 - (42u8 + 1);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `D` failed here
error[E0080]: index out of bounds: the length is 1 but the index is 1
--> $DIR/const-err-early.rs:5:19
|
LL | pub const E: u8 = [5u8][1];
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `E` failed here
error: aborting due to 5 previous errors
diff --git a/tests/ui/consts/const-err-enum-discriminant.stderr b/tests/ui/consts/const-err-enum-discriminant.stderr
index 702d85b..8724333 100644
--- a/tests/ui/consts/const-err-enum-discriminant.stderr
+++ b/tests/ui/consts/const-err-enum-discriminant.stderr
@@ -2,7 +2,7 @@
--> $DIR/const-err-enum-discriminant.rs:8:21
|
LL | Boo = [unsafe { Foo { b: () }.a }; 4][3],
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `Bar::Boo::{constant#0}` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-err-multi.rs b/tests/ui/consts/const-err-multi.rs
index 2fb0d29..90214b6 100644
--- a/tests/ui/consts/const-err-multi.rs
+++ b/tests/ui/consts/const-err-multi.rs
@@ -1,12 +1,12 @@
pub const A: i8 = -i8::MIN;
-//~^ NOTE constant
+//~^ NOTE failed here
//~| ERROR attempt to negate `i8::MIN`, which would overflow
pub const B: i8 = A;
-//~^ NOTE constant
+//~^ NOTE erroneous constant
pub const C: u8 = A as u8;
-//~^ NOTE constant
+//~^ NOTE erroneous constant
pub const D: i8 = 50 - A;
-//~^ NOTE constant
+//~^ NOTE erroneous constant
fn main() {
let _ = (A, B, C, D);
diff --git a/tests/ui/consts/const-err-multi.stderr b/tests/ui/consts/const-err-multi.stderr
index 9e1554e..5153165 100644
--- a/tests/ui/consts/const-err-multi.stderr
+++ b/tests/ui/consts/const-err-multi.stderr
@@ -2,7 +2,7 @@
--> $DIR/const-err-multi.rs:1:19
|
LL | pub const A: i8 = -i8::MIN;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `A` failed here
note: erroneous constant encountered
--> $DIR/const-err-multi.rs:4:19
diff --git a/tests/ui/consts/const-eval-fail-too-big.stderr b/tests/ui/consts/const-eval-fail-too-big.stderr
index 3bc20de..d58efbf 100644
--- a/tests/ui/consts/const-eval-fail-too-big.stderr
+++ b/tests/ui/consts/const-eval-fail-too-big.stderr
@@ -2,7 +2,7 @@
--> $DIR/const-eval-fail-too-big.rs:4:28
|
LL | let x = [0u8; !0usize];
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `B::{constant#0}` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr b/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr
index b19d0ea..b232cbf 100644
--- a/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr
+++ b/tests/ui/consts/const-eval/assign-to-static-within-other-static.stderr
@@ -2,7 +2,7 @@
--> $DIR/assign-to-static-within-other-static.rs:8:5
|
LL | FOO = 5;
- | ^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^ evaluation of `BOO` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-eval/conditional_array_execution.stderr b/tests/ui/consts/const-eval/conditional_array_execution.stderr
index 65ae9a9..9a0a752 100644
--- a/tests/ui/consts/const-eval/conditional_array_execution.stderr
+++ b/tests/ui/consts/const-eval/conditional_array_execution.stderr
@@ -2,7 +2,7 @@
--> $DIR/conditional_array_execution.rs:3:19
|
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
- | ^^^^^ evaluation of constant value failed here
+ | ^^^^^ evaluation of `FOO` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-eval/const-eval-overflow-2.stderr b/tests/ui/consts/const-eval/const-eval-overflow-2.stderr
index 90b9460..ffb8cad 100644
--- a/tests/ui/consts/const-eval/const-eval-overflow-2.stderr
+++ b/tests/ui/consts/const-eval/const-eval-overflow-2.stderr
@@ -2,7 +2,7 @@
--> $DIR/const-eval-overflow-2.rs:11:25
|
LL | const NEG_NEG_128: i8 = -NEG_128;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `NEG_NEG_128` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-eval/const-eval-overflow-3.stderr b/tests/ui/consts/const-eval/const-eval-overflow-3.stderr
index 5ad7d08..aeb8871 100644
--- a/tests/ui/consts/const-eval/const-eval-overflow-3.stderr
+++ b/tests/ui/consts/const-eval/const-eval-overflow-3.stderr
@@ -2,7 +2,7 @@
--> $DIR/const-eval-overflow-3.rs:18:11
|
LL | = [0; (i8::MAX + 1) as usize];
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `A_I8_I::{constant#1}` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-eval/const-eval-overflow-4.stderr b/tests/ui/consts/const-eval/const-eval-overflow-4.stderr
index c14a880..daabb33 100644
--- a/tests/ui/consts/const-eval/const-eval-overflow-4.stderr
+++ b/tests/ui/consts/const-eval/const-eval-overflow-4.stderr
@@ -2,7 +2,7 @@
--> $DIR/const-eval-overflow-4.rs:11:13
|
LL | : [u32; (i8::MAX as i8 + 1i8) as usize]
- | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `A_I8_T::{constant#0}` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-eval/const-eval-overflow2.stderr b/tests/ui/consts/const-eval/const-eval-overflow2.stderr
index a705604..6ec3fa7 100644
--- a/tests/ui/consts/const-eval/const-eval-overflow2.stderr
+++ b/tests/ui/consts/const-eval/const-eval-overflow2.stderr
@@ -2,49 +2,49 @@
--> $DIR/const-eval-overflow2.rs:12:6
|
LL | i8::MIN - 1,
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `VALS_I8` failed here
error[E0080]: attempt to compute `i16::MIN - 1_i16`, which would overflow
--> $DIR/const-eval-overflow2.rs:18:6
|
LL | i16::MIN - 1,
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `VALS_I16` failed here
error[E0080]: attempt to compute `i32::MIN - 1_i32`, which would overflow
--> $DIR/const-eval-overflow2.rs:24:6
|
LL | i32::MIN - 1,
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `VALS_I32` failed here
error[E0080]: attempt to compute `i64::MIN - 1_i64`, which would overflow
--> $DIR/const-eval-overflow2.rs:30:6
|
LL | i64::MIN - 1,
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `VALS_I64` failed here
error[E0080]: attempt to compute `0_u8 - 1_u8`, which would overflow
--> $DIR/const-eval-overflow2.rs:36:6
|
LL | u8::MIN - 1,
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `VALS_U8` failed here
error[E0080]: attempt to compute `0_u16 - 1_u16`, which would overflow
--> $DIR/const-eval-overflow2.rs:41:6
|
LL | u16::MIN - 1,
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `VALS_U16` failed here
error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow
--> $DIR/const-eval-overflow2.rs:46:6
|
LL | u32::MIN - 1,
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `VALS_U32` failed here
error[E0080]: attempt to compute `0_u64 - 1_u64`, which would overflow
--> $DIR/const-eval-overflow2.rs:52:6
|
LL | u64::MIN - 1,
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `VALS_U64` failed here
error: aborting due to 8 previous errors
diff --git a/tests/ui/consts/const-eval/const-eval-overflow2b.stderr b/tests/ui/consts/const-eval/const-eval-overflow2b.stderr
index 33de4b6..5b8e559 100644
--- a/tests/ui/consts/const-eval/const-eval-overflow2b.stderr
+++ b/tests/ui/consts/const-eval/const-eval-overflow2b.stderr
@@ -2,49 +2,49 @@
--> $DIR/const-eval-overflow2b.rs:12:6
|
LL | i8::MAX + 1,
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `VALS_I8` failed here
error[E0080]: attempt to compute `i16::MAX + 1_i16`, which would overflow
--> $DIR/const-eval-overflow2b.rs:18:6
|
LL | i16::MAX + 1,
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `VALS_I16` failed here
error[E0080]: attempt to compute `i32::MAX + 1_i32`, which would overflow
--> $DIR/const-eval-overflow2b.rs:24:6
|
LL | i32::MAX + 1,
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `VALS_I32` failed here
error[E0080]: attempt to compute `i64::MAX + 1_i64`, which would overflow
--> $DIR/const-eval-overflow2b.rs:30:6
|
LL | i64::MAX + 1,
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `VALS_I64` failed here
error[E0080]: attempt to compute `u8::MAX + 1_u8`, which would overflow
--> $DIR/const-eval-overflow2b.rs:36:6
|
LL | u8::MAX + 1,
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `VALS_U8` failed here
error[E0080]: attempt to compute `u16::MAX + 1_u16`, which would overflow
--> $DIR/const-eval-overflow2b.rs:41:6
|
LL | u16::MAX + 1,
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `VALS_U16` failed here
error[E0080]: attempt to compute `u32::MAX + 1_u32`, which would overflow
--> $DIR/const-eval-overflow2b.rs:46:6
|
LL | u32::MAX + 1,
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `VALS_U32` failed here
error[E0080]: attempt to compute `u64::MAX + 1_u64`, which would overflow
--> $DIR/const-eval-overflow2b.rs:52:6
|
LL | u64::MAX + 1,
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `VALS_U64` failed here
error: aborting due to 8 previous errors
diff --git a/tests/ui/consts/const-eval/const-eval-overflow2c.stderr b/tests/ui/consts/const-eval/const-eval-overflow2c.stderr
index 69949b5..99eeadf 100644
--- a/tests/ui/consts/const-eval/const-eval-overflow2c.stderr
+++ b/tests/ui/consts/const-eval/const-eval-overflow2c.stderr
@@ -2,49 +2,49 @@
--> $DIR/const-eval-overflow2c.rs:12:6
|
LL | i8::MIN * 2,
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `VALS_I8` failed here
error[E0080]: attempt to compute `i16::MIN * 2_i16`, which would overflow
--> $DIR/const-eval-overflow2c.rs:18:6
|
LL | i16::MIN * 2,
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `VALS_I16` failed here
error[E0080]: attempt to compute `i32::MIN * 2_i32`, which would overflow
--> $DIR/const-eval-overflow2c.rs:24:6
|
LL | i32::MIN * 2,
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `VALS_I32` failed here
error[E0080]: attempt to compute `i64::MIN * 2_i64`, which would overflow
--> $DIR/const-eval-overflow2c.rs:30:6
|
LL | i64::MIN * 2,
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `VALS_I64` failed here
error[E0080]: attempt to compute `u8::MAX * 2_u8`, which would overflow
--> $DIR/const-eval-overflow2c.rs:36:6
|
LL | u8::MAX * 2,
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `VALS_U8` failed here
error[E0080]: attempt to compute `u16::MAX * 2_u16`, which would overflow
--> $DIR/const-eval-overflow2c.rs:41:6
|
LL | u16::MAX * 2,
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `VALS_U16` failed here
error[E0080]: attempt to compute `u32::MAX * 2_u32`, which would overflow
--> $DIR/const-eval-overflow2c.rs:46:6
|
LL | u32::MAX * 2,
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `VALS_U32` failed here
error[E0080]: attempt to compute `u64::MAX * 2_u64`, which would overflow
--> $DIR/const-eval-overflow2c.rs:52:6
|
LL | u64::MAX * 2,
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `VALS_U64` failed here
error: aborting due to 8 previous errors
diff --git a/tests/ui/consts/const-eval/const-eval-query-stack.stderr b/tests/ui/consts/const-eval/const-eval-query-stack.stderr
index d5b7e67..96206dc 100644
--- a/tests/ui/consts/const-eval/const-eval-query-stack.stderr
+++ b/tests/ui/consts/const-eval/const-eval-query-stack.stderr
@@ -2,7 +2,7 @@
--> $DIR/const-eval-query-stack.rs:16:16
|
LL | const X: i32 = 1 / 0;
- | ^^^^^ evaluation of constant value failed here
+ | ^^^^^ evaluation of `X` failed here
note: please make sure that you have updated to the latest nightly
diff --git a/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr b/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr
index 3a1e8c7..d28d684 100644
--- a/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr
+++ b/tests/ui/consts/const-eval/const-pointer-values-in-various-types.64bit.stderr
@@ -2,7 +2,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:27:49
|
LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_USIZE_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -11,7 +11,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:30:43
|
LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U8_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -20,7 +20,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:33:45
|
LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U16_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -29,7 +29,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:36:45
|
LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U32_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -38,7 +38,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:39:45
|
LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U64_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -47,13 +47,13 @@
--> $DIR/const-pointer-values-in-various-types.rs:42:47
|
LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_U128_UNION` failed here
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:45:43
|
LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I8_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -62,7 +62,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:48:45
|
LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I16_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -71,7 +71,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:51:45
|
LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I32_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -80,7 +80,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:54:45
|
LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I64_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -89,13 +89,13 @@
--> $DIR/const-pointer-values-in-various-types.rs:57:47
|
LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_I128_UNION` failed here
error[E0080]: unable to turn pointer into integer
--> $DIR/const-pointer-values-in-various-types.rs:60:45
|
LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_F32_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -104,7 +104,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:63:45
|
LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_F64_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -113,7 +113,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:66:47
|
LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_BOOL_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -122,7 +122,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:69:47
|
LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::I32_REF_CHAR_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -131,7 +131,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:72:39
|
LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U8_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -140,7 +140,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:75:41
|
LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U16_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -149,7 +149,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:78:41
|
LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U32_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -158,7 +158,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:81:41
|
LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U64_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -167,7 +167,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:84:43
|
LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_U128_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -176,7 +176,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:87:39
|
LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I8_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -185,7 +185,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:90:41
|
LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I16_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -194,7 +194,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:93:41
|
LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I32_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -203,7 +203,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:96:41
|
LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I64_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -212,7 +212,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:99:43
|
LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_I128_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -221,7 +221,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:102:41
|
LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_F32_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -230,7 +230,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:105:41
|
LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_F64_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -239,7 +239,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:108:43
|
LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_BOOL_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -248,7 +248,7 @@
--> $DIR/const-pointer-values-in-various-types.rs:111:43
|
LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::STR_CHAR_UNION` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
diff --git a/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs b/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs
index 03976a0..8d928e2 100644
--- a/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs
+++ b/tests/ui/consts/const-eval/const_fn_ptr_fail2.rs
@@ -14,10 +14,10 @@ const fn bar(x: fn(usize) -> usize, y: usize) -> usize {
}
const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday
-//~^ NOTE evaluation of constant value failed
+//~^ NOTE failed inside this call
//~| ERROR calling non-const function `double`
const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday
-//~^ NOTE evaluation of constant value failed
+//~^ NOTE failed inside this call
//~| ERROR calling non-const function `double`
fn main() {
diff --git a/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr b/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr
index 6eddb72..3ac96b4 100644
--- a/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr
+++ b/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr
@@ -2,7 +2,7 @@
--> $DIR/const_fn_ptr_fail2.rs:16:18
|
LL | const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `Y` failed inside this call
|
note: inside `bar`
--> $DIR/const_fn_ptr_fail2.rs:9:5
@@ -14,7 +14,7 @@
--> $DIR/const_fn_ptr_fail2.rs:19:18
|
LL | const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `Z` failed inside this call
|
note: inside `bar`
--> $DIR/const_fn_ptr_fail2.rs:9:5
diff --git a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr
index 6e5e0e7..7e7b59c 100644
--- a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr
+++ b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr
@@ -2,7 +2,7 @@
--> $DIR/const_panic-normalize-tabs-115498.rs:3:17
|
LL | struct Bug([u8; panic!{"\t"}]);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `Bug::0::{constant#0}` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-eval/const_panic.stderr b/tests/ui/consts/const-eval/const_panic.stderr
index 1b54212..46b36ec 100644
--- a/tests/ui/consts/const-eval/const_panic.stderr
+++ b/tests/ui/consts/const-eval/const_panic.stderr
@@ -2,25 +2,25 @@
--> $DIR/const_panic.rs:6:15
|
LL | const Z: () = std::panic!("cheese");
- | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `Z` failed here
error[E0080]: evaluation panicked: explicit panic
--> $DIR/const_panic.rs:9:16
|
LL | const Z2: () = std::panic!();
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `Z2` failed here
error[E0080]: evaluation panicked: internal error: entered unreachable code
--> $DIR/const_panic.rs:12:15
|
LL | const Y: () = std::unreachable!();
- | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `Y` failed here
error[E0080]: evaluation panicked: not implemented
--> $DIR/const_panic.rs:15:15
|
LL | const X: () = std::unimplemented!();
- | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `X` failed here
|
= note: this error originates in the macro `std::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -28,37 +28,37 @@
--> $DIR/const_panic.rs:18:15
|
LL | const W: () = std::panic!(MSG);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `W` failed here
error[E0080]: evaluation panicked: hello
--> $DIR/const_panic.rs:21:16
|
LL | const W2: () = std::panic!("{}", MSG);
- | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `W2` failed here
error[E0080]: evaluation panicked: cheese
--> $DIR/const_panic.rs:24:20
|
LL | const Z_CORE: () = core::panic!("cheese");
- | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `Z_CORE` failed here
error[E0080]: evaluation panicked: explicit panic
--> $DIR/const_panic.rs:27:21
|
LL | const Z2_CORE: () = core::panic!();
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `Z2_CORE` failed here
error[E0080]: evaluation panicked: internal error: entered unreachable code
--> $DIR/const_panic.rs:30:20
|
LL | const Y_CORE: () = core::unreachable!();
- | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^ evaluation of `Y_CORE` failed here
error[E0080]: evaluation panicked: not implemented
--> $DIR/const_panic.rs:33:20
|
LL | const X_CORE: () = core::unimplemented!();
- | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `X_CORE` failed here
|
= note: this error originates in the macro `core::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -66,13 +66,13 @@
--> $DIR/const_panic.rs:36:20
|
LL | const W_CORE: () = core::panic!(MSG);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `W_CORE` failed here
error[E0080]: evaluation panicked: hello
--> $DIR/const_panic.rs:39:21
|
LL | const W2_CORE: () = core::panic!("{}", MSG);
- | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `W2_CORE` failed here
error: aborting due to 12 previous errors
diff --git a/tests/ui/consts/const-eval/const_panic_2021.stderr b/tests/ui/consts/const-eval/const_panic_2021.stderr
index 15b173f..ba771a3 100644
--- a/tests/ui/consts/const-eval/const_panic_2021.stderr
+++ b/tests/ui/consts/const-eval/const_panic_2021.stderr
@@ -2,25 +2,25 @@
--> $DIR/const_panic_2021.rs:6:15
|
LL | const A: () = std::panic!("blåhaj");
- | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `A` failed here
error[E0080]: evaluation panicked: explicit panic
--> $DIR/const_panic_2021.rs:9:15
|
LL | const B: () = std::panic!();
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `B` failed here
error[E0080]: evaluation panicked: internal error: entered unreachable code
--> $DIR/const_panic_2021.rs:12:15
|
LL | const C: () = std::unreachable!();
- | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `C` failed here
error[E0080]: evaluation panicked: not implemented
--> $DIR/const_panic_2021.rs:15:15
|
LL | const D: () = std::unimplemented!();
- | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `D` failed here
|
= note: this error originates in the macro `std::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -28,31 +28,31 @@
--> $DIR/const_panic_2021.rs:18:15
|
LL | const E: () = std::panic!("{}", MSG);
- | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `E` failed here
error[E0080]: evaluation panicked: shark
--> $DIR/const_panic_2021.rs:21:20
|
LL | const A_CORE: () = core::panic!("shark");
- | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `A_CORE` failed here
error[E0080]: evaluation panicked: explicit panic
--> $DIR/const_panic_2021.rs:24:20
|
LL | const B_CORE: () = core::panic!();
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `B_CORE` failed here
error[E0080]: evaluation panicked: internal error: entered unreachable code
--> $DIR/const_panic_2021.rs:27:20
|
LL | const C_CORE: () = core::unreachable!();
- | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^ evaluation of `C_CORE` failed here
error[E0080]: evaluation panicked: not implemented
--> $DIR/const_panic_2021.rs:30:20
|
LL | const D_CORE: () = core::unimplemented!();
- | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `D_CORE` failed here
|
= note: this error originates in the macro `core::unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)
@@ -60,7 +60,7 @@
--> $DIR/const_panic_2021.rs:33:20
|
LL | const E_CORE: () = core::panic!("{}", MSG);
- | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `E_CORE` failed here
error: aborting due to 10 previous errors
diff --git a/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr b/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr
index 3c308e3..e07b172 100644
--- a/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr
+++ b/tests/ui/consts/const-eval/const_panic_libcore_bin.stderr
@@ -2,19 +2,19 @@
--> $DIR/const_panic_libcore_bin.rs:8:15
|
LL | const Z: () = panic!("cheese");
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `Z` failed here
error[E0080]: evaluation panicked: internal error: entered unreachable code
--> $DIR/const_panic_libcore_bin.rs:11:15
|
LL | const Y: () = unreachable!();
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `Y` failed here
error[E0080]: evaluation panicked: not implemented
--> $DIR/const_panic_libcore_bin.rs:14:15
|
LL | const X: () = unimplemented!();
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `X` failed here
|
= note: this error originates in the macro `unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/consts/const-eval/const_panic_track_caller.rs b/tests/ui/consts/const-eval/const_panic_track_caller.rs
index 5f5d853..f5ede56 100644
--- a/tests/ui/consts/const-eval/const_panic_track_caller.rs
+++ b/tests/ui/consts/const-eval/const_panic_track_caller.rs
@@ -17,5 +17,5 @@ const fn c() -> u32 {
}
const X: u32 = c();
-//~^ NOTE evaluation of constant value failed
+//~^ NOTE failed inside this call
//~| ERROR hey
diff --git a/tests/ui/consts/const-eval/const_panic_track_caller.stderr b/tests/ui/consts/const-eval/const_panic_track_caller.stderr
index b4017cc..4793c53 100644
--- a/tests/ui/consts/const-eval/const_panic_track_caller.stderr
+++ b/tests/ui/consts/const-eval/const_panic_track_caller.stderr
@@ -2,7 +2,7 @@
--> $DIR/const_panic_track_caller.rs:19:16
|
LL | const X: u32 = c();
- | ^^^ evaluation of constant value failed here
+ | ^^^ evaluation of `X` failed inside this call
|
note: inside `c`
--> $DIR/const_panic_track_caller.rs:15:5
diff --git a/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr b/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr
index 6f096ee..6341292 100644
--- a/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr
+++ b/tests/ui/consts/const-eval/const_raw_ptr_ops2.stderr
@@ -2,13 +2,13 @@
--> $DIR/const_raw_ptr_ops2.rs:7:26
|
LL | const Z2: i32 = unsafe { *(42 as *const i32) };
- | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `Z2` failed here
error[E0080]: memory access failed: attempting to access 4 bytes, but got 0x2c[noalloc] which is a dangling pointer (it has no provenance)
--> $DIR/const_raw_ptr_ops2.rs:8:26
|
LL | const Z3: i32 = unsafe { *(44 as *const i32) };
- | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `Z3` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr
index 9132c7e..a1f0b7b 100644
--- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr
+++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr
@@ -2,7 +2,7 @@
--> $DIR/alloc_intrinsic_errors.rs:7:18
|
LL | const FOO: i32 = foo();
- | ^^^^^ evaluation of constant value failed here
+ | ^^^^^ evaluation of `FOO` failed inside this call
|
note: inside `foo`
--> $DIR/alloc_intrinsic_errors.rs:10:17
diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr
index cb419f2..d4039e1 100644
--- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr
+++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr
@@ -13,7 +13,7 @@
--> $DIR/dealloc_intrinsic_dangling.rs:22:5
|
LL | *reference
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_Y` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr
index 3038d60..803b772 100644
--- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr
+++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_duplicate.stderr
@@ -2,7 +2,7 @@
--> $DIR/dealloc_intrinsic_duplicate.rs:9:5
|
LL | intrinsics::const_deallocate(ptr, 4, 4);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_X` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr
index dea55c6..2d61f06 100644
--- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr
+++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr
@@ -2,25 +2,25 @@
--> $DIR/dealloc_intrinsic_incorrect_layout.rs:8:5
|
LL | intrinsics::const_deallocate(ptr, 4, 2);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_X` failed here
error[E0080]: incorrect layout on deallocation: ALLOC1 has size 4 and alignment 4, but gave size 2 and alignment 4
--> $DIR/dealloc_intrinsic_incorrect_layout.rs:13:5
|
LL | intrinsics::const_deallocate(ptr, 2, 4);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_Y` failed here
error[E0080]: incorrect layout on deallocation: ALLOC2 has size 4 and alignment 4, but gave size 3 and alignment 4
--> $DIR/dealloc_intrinsic_incorrect_layout.rs:19:5
|
LL | intrinsics::const_deallocate(ptr, 3, 4);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_Z` failed here
error[E0080]: invalid align passed to `const_deallocate`: 3 is not a power of 2
--> $DIR/dealloc_intrinsic_incorrect_layout.rs:25:5
|
LL | intrinsics::const_deallocate(ptr, 4, 3);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_W` failed here
error: aborting due to 4 previous errors
diff --git a/tests/ui/consts/const-eval/index_out_of_bounds.stderr b/tests/ui/consts/const-eval/index_out_of_bounds.stderr
index f4ec4c5..56e340c 100644
--- a/tests/ui/consts/const-eval/index_out_of_bounds.stderr
+++ b/tests/ui/consts/const-eval/index_out_of_bounds.stderr
@@ -2,7 +2,7 @@
--> $DIR/index_out_of_bounds.rs:1:19
|
LL | static FOO: i32 = [][0];
- | ^^^^^ evaluation of static initializer failed here
+ | ^^^^^ evaluation of `FOO` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-eval/issue-43197.stderr b/tests/ui/consts/const-eval/issue-43197.stderr
index cad23be..c525fd1 100644
--- a/tests/ui/consts/const-eval/issue-43197.stderr
+++ b/tests/ui/consts/const-eval/issue-43197.stderr
@@ -2,13 +2,13 @@
--> $DIR/issue-43197.rs:6:20
|
LL | const X: u32 = 0 - 1;
- | ^^^^^ evaluation of constant value failed here
+ | ^^^^^ evaluation of `main::X` failed here
error[E0080]: attempt to compute `0_u32 - 1_u32`, which would overflow
--> $DIR/issue-43197.rs:8:24
|
LL | const Y: u32 = foo(0 - 1);
- | ^^^^^ evaluation of constant value failed here
+ | ^^^^^ evaluation of `main::Y` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/consts/const-eval/issue-49296.stderr b/tests/ui/consts/const-eval/issue-49296.stderr
index 4a66ec6..9da3e3d 100644
--- a/tests/ui/consts/const-eval/issue-49296.stderr
+++ b/tests/ui/consts/const-eval/issue-49296.stderr
@@ -2,7 +2,7 @@
--> $DIR/issue-49296.rs:9:16
|
LL | const X: u64 = *wat(42);
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `X` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr
index ffff759..d2c1e4f 100644
--- a/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr
+++ b/tests/ui/consts/const-eval/issue-91827-extern-types-field-offset.stderr
@@ -2,7 +2,7 @@
--> $DIR/issue-91827-extern-types-field-offset.rs:38:17
|
LL | let field = &x.a;
- | ^^^^ evaluation of constant value failed here
+ | ^^^^ evaluation of `OFFSET` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr b/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr
index f8cf609..f8a6fa2 100644
--- a/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr
+++ b/tests/ui/consts/const-eval/mod-static-with-const-fn.stderr
@@ -2,7 +2,7 @@
--> $DIR/mod-static-with-const-fn.rs:14:5
|
LL | *FOO.0.get() = 5;
- | ^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `BAR` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr b/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr
index 32ae947..8dbb05c 100644
--- a/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr
+++ b/tests/ui/consts/const-eval/nonnull_as_ref_ub.stderr
@@ -2,7 +2,7 @@
--> $DIR/nonnull_as_ref_ub.rs:4:29
|
LL | const _: () = assert!(42 == *unsafe { NON_NULL.as_ref() });
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-eval/panic-assoc-never-type.stderr b/tests/ui/consts/const-eval/panic-assoc-never-type.stderr
index 64c9f92..d3a2931 100644
--- a/tests/ui/consts/const-eval/panic-assoc-never-type.stderr
+++ b/tests/ui/consts/const-eval/panic-assoc-never-type.stderr
@@ -2,7 +2,7 @@
--> $DIR/panic-assoc-never-type.rs:10:21
|
LL | const VOID: ! = panic!();
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `PrintName::VOID` failed here
note: erroneous constant encountered
--> $DIR/panic-assoc-never-type.rs:15:13
diff --git a/tests/ui/consts/const-eval/panic-never-type.stderr b/tests/ui/consts/const-eval/panic-never-type.stderr
index cacce93..317be64 100644
--- a/tests/ui/consts/const-eval/panic-never-type.stderr
+++ b/tests/ui/consts/const-eval/panic-never-type.stderr
@@ -2,7 +2,7 @@
--> $DIR/panic-never-type.rs:4:17
|
LL | const VOID: ! = panic!();
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `VOID` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-eval/parse_ints.stderr b/tests/ui/consts/const-eval/parse_ints.stderr
index 99aad80..7e529c0 100644
--- a/tests/ui/consts/const-eval/parse_ints.stderr
+++ b/tests/ui/consts/const-eval/parse_ints.stderr
@@ -2,7 +2,7 @@
--> $DIR/parse_ints.rs:5:24
|
LL | const _TOO_LOW: () = { u64::from_str_radix("12345ABCD", 1); };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_TOO_LOW` failed inside this call
|
note: inside `core::num::<impl u64>::from_str_radix`
--> $SRC_DIR/core/src/num/mod.rs:LL:COL
@@ -14,7 +14,7 @@
--> $DIR/parse_ints.rs:6:25
|
LL | const _TOO_HIGH: () = { u64::from_str_radix("12345ABCD", 37); };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_TOO_HIGH` failed inside this call
|
note: inside `core::num::<impl u64>::from_str_radix`
--> $SRC_DIR/core/src/num/mod.rs:LL:COL
diff --git a/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr b/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr
index 4d51449..6ef1cfd 100644
--- a/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr
+++ b/tests/ui/consts/const-eval/partial_ptr_overwrite.stderr
@@ -2,7 +2,7 @@
--> $DIR/partial_ptr_overwrite.rs:7:9
|
LL | *(ptr as *mut u8) = 123;
- | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `PARTIAL_OVERWRITE` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.rs b/tests/ui/consts/const-eval/raw-pointer-ub.rs
index c8d1e36..df7bc2f 100644
--- a/tests/ui/consts/const-eval/raw-pointer-ub.rs
+++ b/tests/ui/consts/const-eval/raw-pointer-ub.rs
@@ -1,14 +1,14 @@
const MISALIGNED_LOAD: () = unsafe {
let mem = [0u32; 8];
let ptr = mem.as_ptr().byte_add(1);
- let _val = *ptr; //~NOTE: evaluation of constant value failed
+ let _val = *ptr; //~NOTE: failed here
//~^ERROR: based on pointer with alignment 1, but alignment 4 is required
};
const MISALIGNED_STORE: () = unsafe {
let mut mem = [0u32; 8];
let ptr = mem.as_mut_ptr().byte_add(1);
- *ptr = 0; //~NOTE: evaluation of constant value failed
+ *ptr = 0; //~NOTE: failed here
//~^ERROR: based on pointer with alignment 1, but alignment 4 is required
};
@@ -17,7 +17,7 @@
let y = x.as_ptr().cast::<u32>();
let mut z = 123;
y.copy_to_nonoverlapping(&mut z, 1);
- //~^ NOTE evaluation of constant value failed
+ //~^ NOTE failed inside this call
//~| NOTE inside `std::ptr::copy_nonoverlapping::<u32>`
//~| ERROR accessing memory with alignment 1, but alignment 4 is required
// The actual error points into the implementation of `copy_to_nonoverlapping`.
@@ -30,14 +30,14 @@
let mem = [0f32; 8];
let ptr = mem.as_ptr().cast::<Aligned>();
// Accessing an f32 field but we still require the alignment of the pointer type.
- let _val = (*ptr).0; //~NOTE: evaluation of constant value failed
+ let _val = (*ptr).0; //~NOTE: failed here
//~^ERROR: based on pointer with alignment 4, but alignment 16 is required
};
const OOB: () = unsafe {
let mem = [0u32; 1];
let ptr = mem.as_ptr().cast::<u64>();
- let _val = *ptr; //~NOTE: evaluation of constant value failed
+ let _val = *ptr; //~NOTE: failed here
//~^ERROR: is only 4 bytes from the end of the allocation
};
diff --git a/tests/ui/consts/const-eval/raw-pointer-ub.stderr b/tests/ui/consts/const-eval/raw-pointer-ub.stderr
index e424924..00af20a 100644
--- a/tests/ui/consts/const-eval/raw-pointer-ub.stderr
+++ b/tests/ui/consts/const-eval/raw-pointer-ub.stderr
@@ -2,19 +2,19 @@
--> $DIR/raw-pointer-ub.rs:4:16
|
LL | let _val = *ptr;
- | ^^^^ evaluation of constant value failed here
+ | ^^^^ evaluation of `MISALIGNED_LOAD` failed here
error[E0080]: accessing memory based on pointer with alignment 1, but alignment 4 is required
--> $DIR/raw-pointer-ub.rs:11:5
|
LL | *ptr = 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `MISALIGNED_STORE` failed here
error[E0080]: accessing memory with alignment 1, but alignment 4 is required
--> $DIR/raw-pointer-ub.rs:19:5
|
LL | y.copy_to_nonoverlapping(&mut z, 1);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MISALIGNED_COPY` failed inside this call
|
note: inside `std::ptr::copy_nonoverlapping::<u32>`
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
@@ -23,13 +23,13 @@
--> $DIR/raw-pointer-ub.rs:33:16
|
LL | let _val = (*ptr).0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `MISALIGNED_FIELD` failed here
error[E0080]: memory access failed: attempting to access 8 bytes, but got ALLOC0 which is only 4 bytes from the end of the allocation
--> $DIR/raw-pointer-ub.rs:40:16
|
LL | let _val = *ptr;
- | ^^^^ evaluation of constant value failed here
+ | ^^^^ evaluation of `OOB` failed here
error: aborting due to 5 previous errors
diff --git a/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr b/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr
index be86541..e435a1e 100644
--- a/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr
+++ b/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr
@@ -2,7 +2,7 @@
--> $DIR/ref_to_int_match.rs:24:27
|
LL | const BAR: Int = unsafe { Foo { r: &42 }.f };
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `BAR` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
diff --git a/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr b/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr
index be86541..e435a1e 100644
--- a/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr
+++ b/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr
@@ -2,7 +2,7 @@
--> $DIR/ref_to_int_match.rs:24:27
|
LL | const BAR: Int = unsafe { Foo { r: &42 }.f };
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `BAR` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
diff --git a/tests/ui/consts/const-eval/shift_overflow.stderr b/tests/ui/consts/const-eval/shift_overflow.stderr
index e5703fb..8c32ddb 100644
--- a/tests/ui/consts/const-eval/shift_overflow.stderr
+++ b/tests/ui/consts/const-eval/shift_overflow.stderr
@@ -2,7 +2,7 @@
--> $DIR/shift_overflow.rs:3:9
|
LL | X = 1 << ((u32::MAX as u64) + 1),
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `Foo::X::{constant#0}` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-eval/transmute-size-mismatch.rs b/tests/ui/consts/const-eval/transmute-size-mismatch.rs
index ea5cdce..15b69af 100644
--- a/tests/ui/consts/const-eval/transmute-size-mismatch.rs
+++ b/tests/ui/consts/const-eval/transmute-size-mismatch.rs
@@ -19,10 +19,10 @@
}
}
-const FROM_BIGGER: u16 = unsafe { mir_transmute(123_i32) }; //~ NOTE evaluation of constant value failed
+const FROM_BIGGER: u16 = unsafe { mir_transmute(123_i32) }; //~ NOTE failed inside this call
//~^ ERROR transmuting from 4-byte type to 2-byte type: `i32` -> `u16`
-const FROM_SMALLER: u32 = unsafe { mir_transmute(123_i16) }; //~ NOTE evaluation of constant value failed
+const FROM_SMALLER: u32 = unsafe { mir_transmute(123_i16) }; //~ NOTE failed inside this call
//~^ ERROR transmuting from 2-byte type to 4-byte type: `i16` -> `u32`
fn main() {}
diff --git a/tests/ui/consts/const-eval/transmute-size-mismatch.stderr b/tests/ui/consts/const-eval/transmute-size-mismatch.stderr
index 92088a4..d0457e3 100644
--- a/tests/ui/consts/const-eval/transmute-size-mismatch.stderr
+++ b/tests/ui/consts/const-eval/transmute-size-mismatch.stderr
@@ -2,7 +2,7 @@
--> $DIR/transmute-size-mismatch.rs:22:35
|
LL | const FROM_BIGGER: u16 = unsafe { mir_transmute(123_i32) };
- | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `FROM_BIGGER` failed inside this call
|
note: inside `mir_transmute::<i32, u16>`
--> $DIR/transmute-size-mismatch.rs:12:13
@@ -14,7 +14,7 @@
--> $DIR/transmute-size-mismatch.rs:25:36
|
LL | const FROM_SMALLER: u32 = unsafe { mir_transmute(123_i16) };
- | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `FROM_SMALLER` failed inside this call
|
note: inside `mir_transmute::<i16, u32>`
--> $DIR/transmute-size-mismatch.rs:12:13
diff --git a/tests/ui/consts/const-eval/ub-enum-overwrite.stderr b/tests/ui/consts/const-eval/ub-enum-overwrite.stderr
index 0c1a606..52af52d 100644
--- a/tests/ui/consts/const-eval/ub-enum-overwrite.stderr
+++ b/tests/ui/consts/const-eval/ub-enum-overwrite.stderr
@@ -2,7 +2,7 @@
--> $DIR/ub-enum-overwrite.rs:11:14
|
LL | unsafe { *p }
- | ^^ evaluation of constant value failed here
+ | ^^ evaluation of `_` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-eval/ub-enum.stderr b/tests/ui/consts/const-eval/ub-enum.stderr
index 7015102..29f7a1f 100644
--- a/tests/ui/consts/const-eval/ub-enum.stderr
+++ b/tests/ui/consts/const-eval/ub-enum.stderr
@@ -13,7 +13,7 @@
--> $DIR/ub-enum.rs:32:1
|
LL | const BAD_ENUM_PTR: Enum = unsafe { mem::transmute(&1) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_ENUM_PTR` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -22,7 +22,7 @@
--> $DIR/ub-enum.rs:35:1
|
LL | const BAD_ENUM_WRAPPED: Wrap<Enum> = unsafe { mem::transmute(&1) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_ENUM_WRAPPED` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -42,7 +42,7 @@
--> $DIR/ub-enum.rs:49:1
|
LL | const BAD_ENUM2_PTR: Enum2 = unsafe { mem::transmute(&0) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_ENUM2_PTR` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -51,7 +51,7 @@
--> $DIR/ub-enum.rs:52:1
|
LL | const BAD_ENUM2_WRAPPED: Wrap<Enum2> = unsafe { mem::transmute(&0) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_ENUM2_WRAPPED` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -60,13 +60,13 @@
--> $DIR/ub-enum.rs:61:41
|
LL | const BAD_ENUM2_UNDEF: Enum2 = unsafe { MaybeUninit { uninit: () }.init };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_ENUM2_UNDEF` failed here
error[E0080]: unable to turn pointer into integer
--> $DIR/ub-enum.rs:65:1
|
LL | const BAD_ENUM2_OPTION_PTR: Option<Enum2> = unsafe { mem::transmute(&0) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_ENUM2_OPTION_PTR` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -108,19 +108,19 @@
--> $DIR/ub-enum.rs:97:77
|
LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) };
- | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_UNINHABITED_WITH_DATA1` failed here
error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
--> $DIR/ub-enum.rs:99:77
|
LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) };
- | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_UNINHABITED_WITH_DATA2` failed here
error[E0080]: read discriminant of an uninhabited enum variant
--> $DIR/ub-enum.rs:105:9
|
LL | std::mem::discriminant(&*(&() as *const () as *const Never));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TEST_ICE_89765` failed inside this call
|
note: inside `discriminant::<Never>`
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
diff --git a/tests/ui/consts/const-eval/ub-invalid-values.rs b/tests/ui/consts/const-eval/ub-invalid-values.rs
index e5d387f..8c47b11 100644
--- a/tests/ui/consts/const-eval/ub-invalid-values.rs
+++ b/tests/ui/consts/const-eval/ub-invalid-values.rs
@@ -5,7 +5,7 @@
const _: () = {
let v = 3_u8;
- bool_cast(&v as *const u8 as *const bool); //~ NOTE: evaluation of constant value failed
+ bool_cast(&v as *const u8 as *const bool); //~ NOTE: failed inside this call
//~^ ERROR interpreting an invalid 8-bit value as a bool
};
diff --git a/tests/ui/consts/const-eval/ub-invalid-values.stderr b/tests/ui/consts/const-eval/ub-invalid-values.stderr
index 83879ee..3a3b9bc 100644
--- a/tests/ui/consts/const-eval/ub-invalid-values.stderr
+++ b/tests/ui/consts/const-eval/ub-invalid-values.stderr
@@ -2,7 +2,7 @@
--> $DIR/ub-invalid-values.rs:8:5
|
LL | bool_cast(&v as *const u8 as *const bool);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed inside this call
|
note: inside `bool_cast`
--> $DIR/ub-invalid-values.rs:2:16
diff --git a/tests/ui/consts/const-eval/ub-nonnull.stderr b/tests/ui/consts/const-eval/ub-nonnull.stderr
index 0a02dbb..314141e 100644
--- a/tests/ui/consts/const-eval/ub-nonnull.stderr
+++ b/tests/ui/consts/const-eval/ub-nonnull.stderr
@@ -13,7 +13,7 @@
--> $DIR/ub-nonnull.rs:22:29
|
LL | let out_of_bounds_ptr = &ptr[255];
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `OUT_OF_BOUNDS_PTR` failed here
error[E0080]: constructing invalid value at .0: encountered 0, but expected something greater or equal to 1
--> $DIR/ub-nonnull.rs:26:1
@@ -41,7 +41,7 @@
--> $DIR/ub-nonnull.rs:36:38
|
LL | const UNINIT: NonZero<u8> = unsafe { MaybeUninit { uninit: () }.init };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINIT` failed here
error[E0080]: constructing invalid value: encountered 42, but expected something in the range 10..=30
--> $DIR/ub-nonnull.rs:44:1
diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.stderr b/tests/ui/consts/const-eval/ub-ref-ptr.stderr
index e10f21b..d5ccc39 100644
--- a/tests/ui/consts/const-eval/ub-ref-ptr.stderr
+++ b/tests/ui/consts/const-eval/ub-ref-ptr.stderr
@@ -46,7 +46,7 @@
--> $DIR/ub-ref-ptr.rs:33:1
|
LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `REF_AS_USIZE` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -55,7 +55,7 @@
--> $DIR/ub-ref-ptr.rs:36:39
|
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `REF_AS_USIZE_SLICE` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -70,7 +70,7 @@
--> $DIR/ub-ref-ptr.rs:39:86
|
LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) };
- | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^ evaluation of `REF_AS_USIZE_BOX_SLICE` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -107,7 +107,7 @@
--> $DIR/ub-ref-ptr.rs:48:41
|
LL | const UNINIT_PTR: *const i32 = unsafe { MaybeUninit { uninit: () }.init };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINIT_PTR` failed here
error[E0080]: constructing invalid value: encountered null pointer, but expected a function pointer
--> $DIR/ub-ref-ptr.rs:51:1
@@ -124,7 +124,7 @@
--> $DIR/ub-ref-ptr.rs:53:38
|
LL | const UNINIT_FN_PTR: fn() = unsafe { MaybeUninit { uninit: () }.init };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINIT_FN_PTR` failed here
error[E0080]: constructing invalid value: encountered 0xd[noalloc], but expected a function pointer
--> $DIR/ub-ref-ptr.rs:55:1
@@ -152,7 +152,7 @@
--> $DIR/ub-ref-ptr.rs:64:5
|
LL | ptr.read();
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `UNALIGNED_READ` failed here
error: aborting due to 15 previous errors
diff --git a/tests/ui/consts/const-eval/ub-uninhabit.stderr b/tests/ui/consts/const-eval/ub-uninhabit.stderr
index 582a7a0..b0f475f 100644
--- a/tests/ui/consts/const-eval/ub-uninhabit.stderr
+++ b/tests/ui/consts/const-eval/ub-uninhabit.stderr
@@ -2,7 +2,7 @@
--> $DIR/ub-uninhabit.rs:20:35
|
LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_BAD_BAD` failed here
error[E0080]: constructing invalid value: encountered a reference pointing to uninhabited type Bar
--> $DIR/ub-uninhabit.rs:23:1
@@ -19,13 +19,13 @@
--> $DIR/ub-uninhabit.rs:26:42
|
LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_BAD_ARRAY` failed here
error[E0080]: constructing invalid value: encountered a value of the never type `!`
--> $DIR/ub-uninhabit.rs:32:16
|
LL | let _val = intrinsics::read_via_copy(ptr);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `READ_NEVER` failed here
error: aborting due to 4 previous errors
diff --git a/tests/ui/consts/const-eval/ub-wide-ptr.stderr b/tests/ui/consts/const-eval/ub-wide-ptr.stderr
index a586f15..8724dd9 100644
--- a/tests/ui/consts/const-eval/ub-wide-ptr.stderr
+++ b/tests/ui/consts/const-eval/ub-wide-ptr.stderr
@@ -24,7 +24,7 @@
--> $DIR/ub-wide-ptr.rs:44:1
|
LL | const STR_LENGTH_PTR: &str = unsafe { mem::transmute((&42u8, &3)) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `STR_LENGTH_PTR` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -33,7 +33,7 @@
--> $DIR/ub-wide-ptr.rs:47:1
|
LL | const MY_STR_LENGTH_PTR: &MyStr = unsafe { mem::transmute((&42u8, &3)) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MY_STR_LENGTH_PTR` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -75,7 +75,7 @@
--> $DIR/ub-wide-ptr.rs:63:1
|
LL | const SLICE_LENGTH_UNINIT: &[u8] = unsafe {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SLICE_LENGTH_UNINIT` failed here
error[E0080]: constructing invalid value: encountered a dangling reference (going beyond the bounds of its allocation)
--> $DIR/ub-wide-ptr.rs:69:1
@@ -103,7 +103,7 @@
--> $DIR/ub-wide-ptr.rs:75:1
|
LL | const SLICE_LENGTH_PTR: &[u8] = unsafe { mem::transmute((&42u8, &3)) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SLICE_LENGTH_PTR` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -123,7 +123,7 @@
--> $DIR/ub-wide-ptr.rs:81:1
|
LL | const SLICE_LENGTH_PTR_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, &3)) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SLICE_LENGTH_PTR_BOX` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -183,7 +183,7 @@
--> $DIR/ub-wide-ptr.rs:101:1
|
LL | const RAW_SLICE_LENGTH_UNINIT: *const [u8] = unsafe {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_SLICE_LENGTH_UNINIT` failed here
error[E0080]: constructing invalid value at .0: encountered ALLOC12<imm>, but expected a vtable pointer
--> $DIR/ub-wide-ptr.rs:109:1
diff --git a/tests/ui/consts/const-eval/ub-write-through-immutable.stderr b/tests/ui/consts/const-eval/ub-write-through-immutable.stderr
index dbcd071..13b2585 100644
--- a/tests/ui/consts/const-eval/ub-write-through-immutable.stderr
+++ b/tests/ui/consts/const-eval/ub-write-through-immutable.stderr
@@ -2,13 +2,13 @@
--> $DIR/ub-write-through-immutable.rs:10:5
|
LL | *ptr = 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `WRITE_AFTER_CAST` failed here
error[E0080]: writing through a pointer that was derived from a shared (immutable) reference
--> $DIR/ub-write-through-immutable.rs:16:5
|
LL | *ptr = 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `WRITE_AFTER_TRANSMUTE` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/consts/const-eval/union-const-eval-field.stderr b/tests/ui/consts/const-eval/union-const-eval-field.stderr
index eb3906a..07ff4c3 100644
--- a/tests/ui/consts/const-eval/union-const-eval-field.stderr
+++ b/tests/ui/consts/const-eval/union-const-eval-field.stderr
@@ -2,7 +2,7 @@
--> $DIR/union-const-eval-field.rs:28:37
|
LL | const FIELD3: Field3 = unsafe { UNION.field3 };
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `read_field3::FIELD3` failed here
note: erroneous constant encountered
--> $DIR/union-const-eval-field.rs:30:5
diff --git a/tests/ui/consts/const-eval/union-ice.stderr b/tests/ui/consts/const-eval/union-ice.stderr
index 86c4271..b00fcc9 100644
--- a/tests/ui/consts/const-eval/union-ice.stderr
+++ b/tests/ui/consts/const-eval/union-ice.stderr
@@ -2,19 +2,19 @@
--> $DIR/union-ice.rs:14:33
|
LL | const FIELD3: Field3 = unsafe { UNION.field3 };
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `FIELD3` failed here
error[E0080]: using uninitialized data, but this operation requires initialized memory
--> $DIR/union-ice.rs:19:17
|
LL | b: unsafe { UNION.field3 },
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `FIELD_PATH` failed here
error[E0080]: using uninitialized data, but this operation requires initialized memory
--> $DIR/union-ice.rs:31:18
|
LL | unsafe { UNION.field3 },
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `FIELD_PATH2` failed here
error: aborting due to 3 previous errors
diff --git a/tests/ui/consts/const-eval/union-ub.32bit.stderr b/tests/ui/consts/const-eval/union-ub.32bit.stderr
index 7b263c2..9f06979 100644
--- a/tests/ui/consts/const-eval/union-ub.32bit.stderr
+++ b/tests/ui/consts/const-eval/union-ub.32bit.stderr
@@ -13,7 +13,7 @@
--> $DIR/union-ub.rs:35:36
|
LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINIT_BOOL` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/consts/const-eval/union-ub.64bit.stderr b/tests/ui/consts/const-eval/union-ub.64bit.stderr
index 7b263c2..9f06979 100644
--- a/tests/ui/consts/const-eval/union-ub.64bit.stderr
+++ b/tests/ui/consts/const-eval/union-ub.64bit.stderr
@@ -13,7 +13,7 @@
--> $DIR/union-ub.rs:35:36
|
LL | const UNINIT_BOOL: bool = unsafe { DummyUnion { unit: () }.bool };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINIT_BOOL` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/consts/const-eval/unused-broken-const.stderr b/tests/ui/consts/const-eval/unused-broken-const.stderr
index 5745539..57bce6c 100644
--- a/tests/ui/consts/const-eval/unused-broken-const.stderr
+++ b/tests/ui/consts/const-eval/unused-broken-const.stderr
@@ -2,7 +2,7 @@
--> $DIR/unused-broken-const.rs:5:18
|
LL | const FOO: i32 = [][0];
- | ^^^^^ evaluation of constant value failed here
+ | ^^^^^ evaluation of `FOO` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-eval/unwind-abort.stderr b/tests/ui/consts/const-eval/unwind-abort.stderr
index 94cf3ac..cccfe56 100644
--- a/tests/ui/consts/const-eval/unwind-abort.stderr
+++ b/tests/ui/consts/const-eval/unwind-abort.stderr
@@ -2,7 +2,7 @@
--> $DIR/unwind-abort.rs:7:15
|
LL | const _: () = foo();
- | ^^^^^ evaluation of constant value failed here
+ | ^^^^^ evaluation of `_` failed inside this call
|
note: inside `foo`
--> $DIR/unwind-abort.rs:4:5
diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr b/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr
index 4557b39..848c65f 100644
--- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr
+++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.stderr
@@ -2,7 +2,7 @@
--> $DIR/validate_uninhabited_zsts.rs:17:33
|
LL | const FOO: [empty::Empty; 3] = [foo(); 3];
- | ^^^^^ evaluation of constant value failed here
+ | ^^^^^ evaluation of `FOO` failed inside this call
|
note: inside `foo`
--> $DIR/validate_uninhabited_zsts.rs:4:14
@@ -14,7 +14,7 @@
--> $DIR/validate_uninhabited_zsts.rs:20:42
|
LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
- | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAR` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/consts/const-eval/validation-ice-extern-type-field.stderr b/tests/ui/consts/const-eval/validation-ice-extern-type-field.stderr
index 08d791f..6108739 100644
--- a/tests/ui/consts/const-eval/validation-ice-extern-type-field.stderr
+++ b/tests/ui/consts/const-eval/validation-ice-extern-type-field.stderr
@@ -2,7 +2,7 @@
--> $DIR/validation-ice-extern-type-field.rs:12:1
|
LL | const C1: &ThinDst = unsafe { std::mem::transmute(b"d".as_ptr()) };
- | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^ evaluation of `C1` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-external-macro-const-err.stderr b/tests/ui/consts/const-external-macro-const-err.stderr
index 7cd646b..3ec9e4f 100644
--- a/tests/ui/consts/const-external-macro-const-err.stderr
+++ b/tests/ui/consts/const-external-macro-const-err.stderr
@@ -2,7 +2,7 @@
--> $DIR/const-external-macro-const-err.rs:12:5
|
LL | static_assert!(2 + 2 == 5);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_` failed here
|
= note: this error originates in the macro `static_assert` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/consts/const-int-unchecked.stderr b/tests/ui/consts/const-int-unchecked.stderr
index 20c109b..65a1162 100644
--- a/tests/ui/consts/const-int-unchecked.stderr
+++ b/tests/ui/consts/const-int-unchecked.stderr
@@ -2,295 +2,295 @@
--> $DIR/const-int-unchecked.rs:14:29
|
LL | const SHL_U8: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_U8` failed here
error[E0080]: overflowing shift by 16 in `unchecked_shl`
--> $DIR/const-int-unchecked.rs:16:31
|
LL | const SHL_U16: u16 = unsafe { intrinsics::unchecked_shl(5_u16, 16) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_U16` failed here
error[E0080]: overflowing shift by 32 in `unchecked_shl`
--> $DIR/const-int-unchecked.rs:18:31
|
LL | const SHL_U32: u32 = unsafe { intrinsics::unchecked_shl(5_u32, 32) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_U32` failed here
error[E0080]: overflowing shift by 64 in `unchecked_shl`
--> $DIR/const-int-unchecked.rs:20:31
|
LL | const SHL_U64: u64 = unsafe { intrinsics::unchecked_shl(5_u64, 64) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_U64` failed here
error[E0080]: overflowing shift by 128 in `unchecked_shl`
--> $DIR/const-int-unchecked.rs:22:33
|
LL | const SHL_U128: u128 = unsafe { intrinsics::unchecked_shl(5_u128, 128) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_U128` failed here
error[E0080]: overflowing shift by 8 in `unchecked_shl`
--> $DIR/const-int-unchecked.rs:27:29
|
LL | const SHL_I8: i8 = unsafe { intrinsics::unchecked_shl(5_i8, 8) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I8` failed here
error[E0080]: overflowing shift by 16 in `unchecked_shl`
--> $DIR/const-int-unchecked.rs:29:31
|
LL | const SHL_I16: i16 = unsafe { intrinsics::unchecked_shl(5_i16, 16) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I16` failed here
error[E0080]: overflowing shift by 32 in `unchecked_shl`
--> $DIR/const-int-unchecked.rs:31:31
|
LL | const SHL_I32: i32 = unsafe { intrinsics::unchecked_shl(5_i32, 32) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I32` failed here
error[E0080]: overflowing shift by 64 in `unchecked_shl`
--> $DIR/const-int-unchecked.rs:33:31
|
LL | const SHL_I64: i64 = unsafe { intrinsics::unchecked_shl(5_i64, 64) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I64` failed here
error[E0080]: overflowing shift by 128 in `unchecked_shl`
--> $DIR/const-int-unchecked.rs:35:33
|
LL | const SHL_I128: i128 = unsafe { intrinsics::unchecked_shl(5_i128, 128) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I128` failed here
error[E0080]: overflowing shift by -1 in `unchecked_shl`
--> $DIR/const-int-unchecked.rs:40:33
|
LL | const SHL_I8_NEG: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -1) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I8_NEG` failed here
error[E0080]: overflowing shift by -1 in `unchecked_shl`
--> $DIR/const-int-unchecked.rs:42:35
|
LL | const SHL_I16_NEG: i16 = unsafe { intrinsics::unchecked_shl(5_i16, -1) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I16_NEG` failed here
error[E0080]: overflowing shift by -1 in `unchecked_shl`
--> $DIR/const-int-unchecked.rs:44:35
|
LL | const SHL_I32_NEG: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -1) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I32_NEG` failed here
error[E0080]: overflowing shift by -1 in `unchecked_shl`
--> $DIR/const-int-unchecked.rs:46:35
|
LL | const SHL_I64_NEG: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -1) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I64_NEG` failed here
error[E0080]: overflowing shift by -1 in `unchecked_shl`
--> $DIR/const-int-unchecked.rs:48:37
|
LL | const SHL_I128_NEG: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -1) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I128_NEG` failed here
error[E0080]: overflowing shift by -6 in `unchecked_shl`
--> $DIR/const-int-unchecked.rs:54:40
|
LL | const SHL_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -6) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I8_NEG_RANDOM` failed here
error[E0080]: overflowing shift by -13 in `unchecked_shl`
--> $DIR/const-int-unchecked.rs:56:42
|
LL | const SHL_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shl(5_i16, -13) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I16_NEG_RANDOM` failed here
error[E0080]: overflowing shift by -25 in `unchecked_shl`
--> $DIR/const-int-unchecked.rs:58:42
|
LL | const SHL_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -25) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I32_NEG_RANDOM` failed here
error[E0080]: overflowing shift by -30 in `unchecked_shl`
--> $DIR/const-int-unchecked.rs:60:42
|
LL | const SHL_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -30) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I64_NEG_RANDOM` failed here
error[E0080]: overflowing shift by -93 in `unchecked_shl`
--> $DIR/const-int-unchecked.rs:62:44
|
LL | const SHL_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -93) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHL_I128_NEG_RANDOM` failed here
error[E0080]: overflowing shift by 8 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:69:29
|
LL | const SHR_U8: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_U8` failed here
error[E0080]: overflowing shift by 16 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:71:31
|
LL | const SHR_U16: u16 = unsafe { intrinsics::unchecked_shr(5_u16, 16) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_U16` failed here
error[E0080]: overflowing shift by 32 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:73:31
|
LL | const SHR_U32: u32 = unsafe { intrinsics::unchecked_shr(5_u32, 32) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_U32` failed here
error[E0080]: overflowing shift by 64 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:75:31
|
LL | const SHR_U64: u64 = unsafe { intrinsics::unchecked_shr(5_u64, 64) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_U64` failed here
error[E0080]: overflowing shift by 128 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:77:33
|
LL | const SHR_U128: u128 = unsafe { intrinsics::unchecked_shr(5_u128, 128) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_U128` failed here
error[E0080]: overflowing shift by 8 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:82:29
|
LL | const SHR_I8: i8 = unsafe { intrinsics::unchecked_shr(5_i8, 8) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I8` failed here
error[E0080]: overflowing shift by 16 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:84:31
|
LL | const SHR_I16: i16 = unsafe { intrinsics::unchecked_shr(5_i16, 16) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I16` failed here
error[E0080]: overflowing shift by 32 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:86:31
|
LL | const SHR_I32: i32 = unsafe { intrinsics::unchecked_shr(5_i32, 32) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I32` failed here
error[E0080]: overflowing shift by 64 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:88:31
|
LL | const SHR_I64: i64 = unsafe { intrinsics::unchecked_shr(5_i64, 64) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I64` failed here
error[E0080]: overflowing shift by 128 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:90:33
|
LL | const SHR_I128: i128 = unsafe { intrinsics::unchecked_shr(5_i128, 128) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I128` failed here
error[E0080]: overflowing shift by -1 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:95:33
|
LL | const SHR_I8_NEG: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -1) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I8_NEG` failed here
error[E0080]: overflowing shift by -1 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:97:35
|
LL | const SHR_I16_NEG: i16 = unsafe { intrinsics::unchecked_shr(5_i16, -1) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I16_NEG` failed here
error[E0080]: overflowing shift by -1 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:99:35
|
LL | const SHR_I32_NEG: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -1) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I32_NEG` failed here
error[E0080]: overflowing shift by -1 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:101:35
|
LL | const SHR_I64_NEG: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -1) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I64_NEG` failed here
error[E0080]: overflowing shift by -1 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:103:37
|
LL | const SHR_I128_NEG: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -1) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I128_NEG` failed here
error[E0080]: overflowing shift by -6 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:109:40
|
LL | const SHR_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -6) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I8_NEG_RANDOM` failed here
error[E0080]: overflowing shift by -13 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:111:42
|
LL | const SHR_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shr(5_i16, -13) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I16_NEG_RANDOM` failed here
error[E0080]: overflowing shift by -25 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:113:42
|
LL | const SHR_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -25) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I32_NEG_RANDOM` failed here
error[E0080]: overflowing shift by -30 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:115:42
|
LL | const SHR_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -30) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I64_NEG_RANDOM` failed here
error[E0080]: overflowing shift by -93 in `unchecked_shr`
--> $DIR/const-int-unchecked.rs:117:44
|
LL | const SHR_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -93) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `SHR_I128_NEG_RANDOM` failed here
error[E0080]: arithmetic overflow in `unchecked_add`
--> $DIR/const-int-unchecked.rs:122:25
|
LL | const _: u16 = unsafe { std::intrinsics::unchecked_add(40000u16, 30000) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here
error[E0080]: arithmetic overflow in `unchecked_sub`
--> $DIR/const-int-unchecked.rs:125:25
|
LL | const _: u32 = unsafe { std::intrinsics::unchecked_sub(14u32, 22) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here
error[E0080]: arithmetic overflow in `unchecked_mul`
--> $DIR/const-int-unchecked.rs:128:25
|
LL | const _: u16 = unsafe { std::intrinsics::unchecked_mul(300u16, 250u16) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here
error[E0080]: dividing by zero
--> $DIR/const-int-unchecked.rs:131:25
|
LL | const _: i32 = unsafe { std::intrinsics::unchecked_div(1, 0) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here
error[E0080]: overflow in signed division (dividing MIN by -1)
--> $DIR/const-int-unchecked.rs:133:25
|
LL | const _: i32 = unsafe { std::intrinsics::unchecked_div(i32::MIN, -1) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here
error[E0080]: calculating the remainder with a divisor of zero
--> $DIR/const-int-unchecked.rs:136:25
|
LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(1, 0) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here
error[E0080]: overflow in signed remainder (dividing MIN by -1)
--> $DIR/const-int-unchecked.rs:138:25
|
LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::MIN, -1) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here
error[E0080]: `ctlz_nonzero` called on 0
--> $DIR/const-int-unchecked.rs:143:25
|
LL | const _: u32 = unsafe { std::intrinsics::ctlz_nonzero(0) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here
error[E0080]: `cttz_nonzero` called on 0
--> $DIR/const-int-unchecked.rs:145:25
|
LL | const _: u32 = unsafe { std::intrinsics::cttz_nonzero(0) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here
error: aborting due to 49 previous errors
diff --git a/tests/ui/consts/const-len-underflow-separate-spans.next.stderr b/tests/ui/consts/const-len-underflow-separate-spans.next.stderr
index 510b9cd..ef46522 100644
--- a/tests/ui/consts/const-len-underflow-separate-spans.next.stderr
+++ b/tests/ui/consts/const-len-underflow-separate-spans.next.stderr
@@ -2,7 +2,7 @@
--> $DIR/const-len-underflow-separate-spans.rs:10:20
|
LL | const LEN: usize = ONE - TWO;
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `LEN` failed here
note: erroneous constant encountered
--> $DIR/const-len-underflow-separate-spans.rs:15:17
diff --git a/tests/ui/consts/const-len-underflow-separate-spans.old.stderr b/tests/ui/consts/const-len-underflow-separate-spans.old.stderr
index 510b9cd..ef46522 100644
--- a/tests/ui/consts/const-len-underflow-separate-spans.old.stderr
+++ b/tests/ui/consts/const-len-underflow-separate-spans.old.stderr
@@ -2,7 +2,7 @@
--> $DIR/const-len-underflow-separate-spans.rs:10:20
|
LL | const LEN: usize = ONE - TWO;
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `LEN` failed here
note: erroneous constant encountered
--> $DIR/const-len-underflow-separate-spans.rs:15:17
diff --git a/tests/ui/consts/const-len-underflow-separate-spans.rs b/tests/ui/consts/const-len-underflow-separate-spans.rs
index a815eca..ee8c79d 100644
--- a/tests/ui/consts/const-len-underflow-separate-spans.rs
+++ b/tests/ui/consts/const-len-underflow-separate-spans.rs
@@ -8,7 +8,7 @@
const ONE: usize = 1;
const TWO: usize = 2;
const LEN: usize = ONE - TWO;
-//~^ NOTE constant
+//~^ NOTE failed here
//~| ERROR attempt to compute `1_usize - 2_usize`, which would overflow
fn main() {
diff --git a/tests/ui/consts/const-len-underflow-subspans.stderr b/tests/ui/consts/const-len-underflow-subspans.stderr
index 42d7441..51825a0 100644
--- a/tests/ui/consts/const-len-underflow-subspans.stderr
+++ b/tests/ui/consts/const-len-underflow-subspans.stderr
@@ -2,7 +2,7 @@
--> $DIR/const-len-underflow-subspans.rs:8:17
|
LL | let a: [i8; ONE - TWO] = unimplemented!();
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `main::{constant#0}` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-ptr-is-null.stderr b/tests/ui/consts/const-ptr-is-null.stderr
index 9d83f8d..be0a134 100644
--- a/tests/ui/consts/const-ptr-is-null.stderr
+++ b/tests/ui/consts/const-ptr-is-null.stderr
@@ -2,7 +2,7 @@
--> $DIR/const-ptr-is-null.rs:22:14
|
LL | assert!(!ptr.wrapping_sub(512).is_null());
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MAYBE_NULL` failed inside this call
|
note: inside `std::ptr::const_ptr::<impl *const i32>::is_null`
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
diff --git a/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr b/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr
index 714d85b..64b7a41 100644
--- a/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr
+++ b/tests/ui/consts/const-size_of_val-align_of_val-extern-type.stderr
@@ -2,13 +2,13 @@
--> $DIR/const-size_of_val-align_of_val-extern-type.rs:10:31
|
LL | const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_SIZE` failed here
error[E0080]: `extern type` does not have known layout
--> $DIR/const-size_of_val-align_of_val-extern-type.rs:11:32
|
LL | const _ALIGN: usize = unsafe { min_align_of_val(&4 as *const i32 as *const Opaque) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_ALIGN` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/consts/const-slice-oob.stderr b/tests/ui/consts/const-slice-oob.stderr
index d93c4783..9435baa 100644
--- a/tests/ui/consts/const-slice-oob.stderr
+++ b/tests/ui/consts/const-slice-oob.stderr
@@ -2,7 +2,7 @@
--> $DIR/const-slice-oob.rs:2:18
|
LL | const BAR: u32 = FOO[5];
- | ^^^^^^ evaluation of constant value failed here
+ | ^^^^^^ evaluation of `BAR` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/const-unwrap.stderr b/tests/ui/consts/const-unwrap.stderr
index 88c9185..0b3e92d 100644
--- a/tests/ui/consts/const-unwrap.stderr
+++ b/tests/ui/consts/const-unwrap.stderr
@@ -2,13 +2,13 @@
--> $DIR/const-unwrap.rs:6:18
|
LL | const BAR: i32 = Option::<i32>::None.unwrap();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAR` failed here
error[E0080]: evaluation panicked: absolutely not!
--> $DIR/const-unwrap.rs:9:18
|
LL | const BAZ: i32 = Option::<i32>::None.expect("absolutely not!");
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAZ` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/consts/const_refs_to_static_fail.stderr b/tests/ui/consts/const_refs_to_static_fail.stderr
index 96a6593..86d6c11d 100644
--- a/tests/ui/consts/const_refs_to_static_fail.stderr
+++ b/tests/ui/consts/const_refs_to_static_fail.stderr
@@ -19,7 +19,7 @@
--> $DIR/const_refs_to_static_fail.rs:18:13
|
LL | assert!(*C2 == 0);
- | ^^^ evaluation of constant value failed here
+ | ^^^ evaluation of `C2_READ` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/consts/const_unsafe_unreachable_ub.rs b/tests/ui/consts/const_unsafe_unreachable_ub.rs
index 7c6c7a6..39f0539 100644
--- a/tests/ui/consts/const_unsafe_unreachable_ub.rs
+++ b/tests/ui/consts/const_unsafe_unreachable_ub.rs
@@ -8,7 +8,7 @@
}
const BAR: bool = unsafe { foo(false) };
-//~^ NOTE evaluation of constant value failed
+//~^ NOTE failed inside this call
//~| ERROR entering unreachable code
fn main() {
diff --git a/tests/ui/consts/const_unsafe_unreachable_ub.stderr b/tests/ui/consts/const_unsafe_unreachable_ub.stderr
index 6d9f8c1..7d2448c 100644
--- a/tests/ui/consts/const_unsafe_unreachable_ub.stderr
+++ b/tests/ui/consts/const_unsafe_unreachable_ub.stderr
@@ -2,7 +2,7 @@
--> $DIR/const_unsafe_unreachable_ub.rs:10:28
|
LL | const BAR: bool = unsafe { foo(false) };
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `BAR` failed inside this call
|
note: inside `foo`
--> $DIR/const_unsafe_unreachable_ub.rs:4:18
diff --git a/tests/ui/consts/control-flow/assert.stderr b/tests/ui/consts/control-flow/assert.stderr
index 6b68f70..026097a 100644
--- a/tests/ui/consts/control-flow/assert.stderr
+++ b/tests/ui/consts/control-flow/assert.stderr
@@ -2,7 +2,7 @@
--> $DIR/assert.rs:5:15
|
LL | const _: () = assert!(false);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/copy-intrinsic.stderr b/tests/ui/consts/copy-intrinsic.stderr
index b9d89cf..41cf7e5 100644
--- a/tests/ui/consts/copy-intrinsic.stderr
+++ b/tests/ui/consts/copy-intrinsic.stderr
@@ -2,25 +2,25 @@
--> $DIR/copy-intrinsic.rs:20:5
|
LL | copy_nonoverlapping(0x100 as *const i32, dangle, 1);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `COPY_OOB_1` failed here
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x28 which is at or beyond the end of the allocation of size 4 bytes
--> $DIR/copy-intrinsic.rs:28:5
|
LL | copy_nonoverlapping(dangle, 0x100 as *mut i32, 1);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `COPY_OOB_2` failed here
error[E0080]: overflow computing total size of `copy`
--> $DIR/copy-intrinsic.rs:34:5
|
LL | copy(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `COPY_SIZE_OVERFLOW` failed here
error[E0080]: overflow computing total size of `copy_nonoverlapping`
--> $DIR/copy-intrinsic.rs:39:5
|
LL | copy_nonoverlapping(&x, &mut y, 1usize << (mem::size_of::<usize>() * 8 - 1));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `COPY_NONOVERLAPPING_SIZE_OVERFLOW` failed here
error: aborting due to 4 previous errors
diff --git a/tests/ui/consts/eval-enum.stderr b/tests/ui/consts/eval-enum.stderr
index adfb7c7..d647485 100644
--- a/tests/ui/consts/eval-enum.stderr
+++ b/tests/ui/consts/eval-enum.stderr
@@ -2,13 +2,13 @@
--> $DIR/eval-enum.rs:2:15
|
LL | DivZero = 1 / 0,
- | ^^^^^ evaluation of constant value failed here
+ | ^^^^^ evaluation of `Test::DivZero::{constant#0}` failed here
error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero
--> $DIR/eval-enum.rs:4:15
|
LL | RemZero = 1 % 0,
- | ^^^^^ evaluation of constant value failed here
+ | ^^^^^ evaluation of `Test::RemZero::{constant#0}` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr b/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr
index 0d8fd5a..6af7286 100644
--- a/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr
+++ b/tests/ui/consts/extra-const-ub/detect-extra-ub.with_flag.stderr
@@ -2,13 +2,13 @@
--> $DIR/detect-extra-ub.rs:30:20
|
LL | let _x: bool = transmute(3u8);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `INVALID_BOOL` failed here
error[E0080]: constructing invalid value: encountered a pointer, but expected an integer
--> $DIR/detect-extra-ub.rs:35:21
|
LL | let _x: usize = transmute(&3u8);
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `INVALID_PTR_IN_INT` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -17,7 +17,7 @@
--> $DIR/detect-extra-ub.rs:40:28
|
LL | let _x: PtrSizedEnum = transmute(&3u8);
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `INVALID_PTR_IN_ENUM` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -26,7 +26,7 @@
--> $DIR/detect-extra-ub.rs:46:30
|
LL | let _x: (usize, usize) = transmute(x);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `INVALID_SLICE_TO_USIZE_TRANSMUTE` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -35,19 +35,19 @@
--> $DIR/detect-extra-ub.rs:51:20
|
LL | let _x: &u32 = transmute(&[0u8; 4]);
- | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^ evaluation of `UNALIGNED_PTR` failed here
error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabited enum variant
--> $DIR/detect-extra-ub.rs:58:13
|
LL | let v = *addr_of!(data).cast::<UninhDiscriminant>();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNINHABITED_VARIANT` failed here
error[E0080]: constructing invalid value at [0]: encountered a partial pointer or a mix of pointers
--> $DIR/detect-extra-ub.rs:77:16
|
LL | let _val = *(&mem as *const Align as *const [*const u8; 2]);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `PARTIAL_POINTER` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -56,7 +56,7 @@
--> $DIR/detect-extra-ub.rs:91:16
|
LL | let _val = &*slice;
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `OVERSIZED_REF` failed here
error: aborting due to 8 previous errors
diff --git a/tests/ui/consts/issue-32829.stderr b/tests/ui/consts/issue-32829.stderr
index 0a04c66..b02b912 100644
--- a/tests/ui/consts/issue-32829.stderr
+++ b/tests/ui/consts/issue-32829.stderr
@@ -2,7 +2,7 @@
--> $DIR/issue-32829.rs:1:22
|
LL | static S : u64 = { { panic!("foo"); 0 } };
- | ^^^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^^^ evaluation of `S` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/issue-64506.stderr b/tests/ui/consts/issue-64506.stderr
index dfb2c45..9fce07c 100644
--- a/tests/ui/consts/issue-64506.stderr
+++ b/tests/ui/consts/issue-64506.stderr
@@ -2,7 +2,7 @@
--> $DIR/issue-64506.rs:16:22
|
LL | let x = unsafe { Foo { b: () }.a };
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `FOO` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/issue-66693-panic-in-array-len.stderr b/tests/ui/consts/issue-66693-panic-in-array-len.stderr
index e0db213..241643a 100644
--- a/tests/ui/consts/issue-66693-panic-in-array-len.stderr
+++ b/tests/ui/consts/issue-66693-panic-in-array-len.stderr
@@ -8,7 +8,7 @@
--> $DIR/issue-66693-panic-in-array-len.rs:10:21
|
LL | let _ = [false; panic!()];
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `main::{constant#1}` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/consts/issue-66693.stderr b/tests/ui/consts/issue-66693.stderr
index 6d6edf8..5540d4f 100644
--- a/tests/ui/consts/issue-66693.stderr
+++ b/tests/ui/consts/issue-66693.stderr
@@ -14,13 +14,13 @@
--> $DIR/issue-66693.rs:16:15
|
LL | const _: () = panic!();
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_` failed here
error[E0080]: evaluation panicked: panic in static
--> $DIR/issue-66693.rs:18:19
|
LL | static _BAR: () = panic!("panic in static");
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_BAR` failed here
error: argument to `panic!()` in a const context must have type `&str`
--> $DIR/issue-66693.rs:11:5
diff --git a/tests/ui/consts/issue-76064.stderr b/tests/ui/consts/issue-76064.stderr
index 9722517..17dcb22 100644
--- a/tests/ui/consts/issue-76064.stderr
+++ b/tests/ui/consts/issue-76064.stderr
@@ -2,7 +2,7 @@
--> $DIR/issue-76064.rs:1:17
|
LL | struct Bug([u8; panic!("panic")]);
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `Bug::0::{constant#0}` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/issue-miri-1910.stderr b/tests/ui/consts/issue-miri-1910.stderr
index 8166b68..140b186 100644
--- a/tests/ui/consts/issue-miri-1910.stderr
+++ b/tests/ui/consts/issue-miri-1910.stderr
@@ -2,7 +2,7 @@
--> $DIR/issue-miri-1910.rs:7:5
|
LL | (&foo as *const _ as *const u8).add(one_and_a_half_pointers).read();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `C` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
diff --git a/tests/ui/consts/large_const_alloc.stderr b/tests/ui/consts/large_const_alloc.stderr
index 8f19def..a0b2155 100644
--- a/tests/ui/consts/large_const_alloc.stderr
+++ b/tests/ui/consts/large_const_alloc.stderr
@@ -2,13 +2,13 @@
--> $DIR/large_const_alloc.rs:11:13
|
LL | let x = [0_u8; (1 << 47) - 1];
- | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `FOO` failed here
error[E0080]: tried to allocate more memory than available to compiler
--> $DIR/large_const_alloc.rs:16:13
|
LL | let x = [0_u8; (1 << 47) - 1];
- | ^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `FOO2` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/consts/miri_unleashed/abi-mismatch.rs b/tests/ui/consts/miri_unleashed/abi-mismatch.rs
index 91115f8..843de1e 100644
--- a/tests/ui/consts/miri_unleashed/abi-mismatch.rs
+++ b/tests/ui/consts/miri_unleashed/abi-mismatch.rs
@@ -9,7 +9,7 @@ const fn call_rust_fn(my_fn: extern "Rust" fn()) {
}
static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) });
-//~^ NOTE evaluation of static initializer failed here
+//~^ NOTE failed inside this call
//~| ERROR calling a function with calling convention "C" using calling convention "Rust"
fn main() {}
diff --git a/tests/ui/consts/miri_unleashed/abi-mismatch.stderr b/tests/ui/consts/miri_unleashed/abi-mismatch.stderr
index 6cd2a0b..4576eed 100644
--- a/tests/ui/consts/miri_unleashed/abi-mismatch.stderr
+++ b/tests/ui/consts/miri_unleashed/abi-mismatch.stderr
@@ -2,7 +2,7 @@
--> $DIR/abi-mismatch.rs:11:18
|
LL | static VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) });
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `VAL` failed inside this call
|
note: inside `call_rust_fn`
--> $DIR/abi-mismatch.rs:7:5
diff --git a/tests/ui/consts/miri_unleashed/assoc_const.stderr b/tests/ui/consts/miri_unleashed/assoc_const.stderr
index e843615..1ba4f3b 100644
--- a/tests/ui/consts/miri_unleashed/assoc_const.stderr
+++ b/tests/ui/consts/miri_unleashed/assoc_const.stderr
@@ -2,7 +2,7 @@
--> $DIR/assoc_const.rs:12:31
|
LL | const F: u32 = (U::X, 42).1;
- | ^ evaluation of `<std::string::String as Bar<std::vec::Vec<u32>, std::string::String>>::F` failed here
+ | ^ evaluation of `<std::string::String as Bar<std::vec::Vec<u32>, std::string::String>>::F` failed inside this call
|
note: inside `drop_in_place::<(Vec<u32>, u32)> - shim(Some((Vec<u32>, u32)))`
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
diff --git a/tests/ui/consts/miri_unleashed/box.stderr b/tests/ui/consts/miri_unleashed/box.stderr
index d6ceeeb..25b7176 100644
--- a/tests/ui/consts/miri_unleashed/box.stderr
+++ b/tests/ui/consts/miri_unleashed/box.stderr
@@ -2,7 +2,7 @@
--> $DIR/box.rs:8:11
|
LL | &mut *(Box::new(0))
- | ^^^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^^^ evaluation of `TEST_BAD` failed here
warning: skipping const checks
|
diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr
index f016198..eed3b4d 100644
--- a/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr
+++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr
@@ -2,19 +2,19 @@
--> $DIR/const_refers_to_static.rs:11:5
|
LL | FOO.fetch_add(1, Ordering::Relaxed)
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MUTATE_INTERIOR_MUT` failed here
error[E0080]: constant accesses mutable global memory
--> $DIR/const_refers_to_static.rs:16:14
|
LL | unsafe { *(&FOO as *const _ as *const usize) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `READ_INTERIOR_MUT` failed here
error[E0080]: constant accesses mutable global memory
--> $DIR/const_refers_to_static.rs:20:32
|
LL | const READ_MUT: u32 = unsafe { MUTABLE };
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `READ_MUT` failed here
error[E0080]: constructing invalid value: encountered reference to mutable memory in `const`
--> $DIR/const_refers_to_static.rs:23:1
diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr
index 8c176d5..8af3a19 100644
--- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr
+++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr
@@ -35,7 +35,7 @@
--> $DIR/const_refers_to_static_cross_crate.rs:30:15
|
LL | match static_cross_crate::OPT_ZERO {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `U8_MUT3` failed here
error: aborting due to 4 previous errors
diff --git a/tests/ui/consts/miri_unleashed/drop.rs b/tests/ui/consts/miri_unleashed/drop.rs
index 6921ffa..46af338 100644
--- a/tests/ui/consts/miri_unleashed/drop.rs
+++ b/tests/ui/consts/miri_unleashed/drop.rs
@@ -13,7 +13,7 @@ fn main() {}
// The actual error is tested by the error-pattern above.
static TEST_BAD: () = {
let _v: Vec<i32> = Vec::new();
-}; //~ NOTE evaluation of static initializer failed here
+}; //~ NOTE failed inside this call
//~| ERROR calling non-const function `<Vec<i32> as Drop>::drop`
//~| NOTE inside `drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))`
diff --git a/tests/ui/consts/miri_unleashed/drop.stderr b/tests/ui/consts/miri_unleashed/drop.stderr
index f0a776d..a664229 100644
--- a/tests/ui/consts/miri_unleashed/drop.stderr
+++ b/tests/ui/consts/miri_unleashed/drop.stderr
@@ -2,7 +2,7 @@
--> $DIR/drop.rs:16:1
|
LL | };
- | ^ evaluation of static initializer failed here
+ | ^ evaluation of `TEST_BAD` failed inside this call
|
note: inside `drop_in_place::<Vec<i32>> - shim(Some(Vec<i32>))`
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
diff --git a/tests/ui/consts/miri_unleashed/extern-static.stderr b/tests/ui/consts/miri_unleashed/extern-static.stderr
index a1e4be5..57b4f07 100644
--- a/tests/ui/consts/miri_unleashed/extern-static.stderr
+++ b/tests/ui/consts/miri_unleashed/extern-static.stderr
@@ -2,13 +2,13 @@
--> $DIR/extern-static.rs:11:25
|
LL | unsafe { let _val = DATA; }
- | ^^^^ evaluation of static initializer failed here
+ | ^^^^ evaluation of `TEST_READ` failed here
error[E0080]: cannot access extern static `DATA`
--> $DIR/extern-static.rs:15:14
|
LL | unsafe { DATA = 0; }
- | ^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^ evaluation of `TEST_WRITE` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/consts/miri_unleashed/inline_asm.stderr b/tests/ui/consts/miri_unleashed/inline_asm.stderr
index 2f9d2dc..49e5482 100644
--- a/tests/ui/consts/miri_unleashed/inline_asm.stderr
+++ b/tests/ui/consts/miri_unleashed/inline_asm.stderr
@@ -2,7 +2,7 @@
--> $DIR/inline_asm.rs:10:14
|
LL | unsafe { asm!("nop"); }
- | ^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^ evaluation of `TEST_BAD` failed here
warning: skipping const checks
|
diff --git a/tests/ui/consts/miri_unleashed/mutable_references.stderr b/tests/ui/consts/miri_unleashed/mutable_references.stderr
index aaea7bd..22860e4 100644
--- a/tests/ui/consts/miri_unleashed/mutable_references.stderr
+++ b/tests/ui/consts/miri_unleashed/mutable_references.stderr
@@ -113,7 +113,7 @@
--> $DIR/mutable_references.rs:70:43
|
LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `POINTS_TO_MUTABLE2` failed here
error: encountered mutable pointer in final value of constant
--> $DIR/mutable_references.rs:73:1
diff --git a/tests/ui/consts/miri_unleashed/mutating_global.stderr b/tests/ui/consts/miri_unleashed/mutating_global.stderr
index 706bc8e..f97f88a 100644
--- a/tests/ui/consts/miri_unleashed/mutating_global.stderr
+++ b/tests/ui/consts/miri_unleashed/mutating_global.stderr
@@ -2,7 +2,7 @@
--> $DIR/mutating_global.rs:9:9
|
LL | GLOBAL = 99
- | ^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^ evaluation of `MUTATING_GLOBAL` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/miri_unleashed/non_const_fn.stderr b/tests/ui/consts/miri_unleashed/non_const_fn.stderr
index f490e51..7755183 100644
--- a/tests/ui/consts/miri_unleashed/non_const_fn.stderr
+++ b/tests/ui/consts/miri_unleashed/non_const_fn.stderr
@@ -2,7 +2,7 @@
--> $DIR/non_const_fn.rs:7:16
|
LL | static C: () = foo();
- | ^^^^^ evaluation of static initializer failed here
+ | ^^^^^ evaluation of `C` failed here
warning: skipping const checks
|
diff --git a/tests/ui/consts/miri_unleashed/ptr_arith.stderr b/tests/ui/consts/miri_unleashed/ptr_arith.stderr
index 280c76c..661a8de 100644
--- a/tests/ui/consts/miri_unleashed/ptr_arith.stderr
+++ b/tests/ui/consts/miri_unleashed/ptr_arith.stderr
@@ -2,13 +2,13 @@
--> $DIR/ptr_arith.rs:7:13
|
LL | let x = &0 as *const _ as usize;
- | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `PTR_INT_CAST` failed here
error[E0080]: unable to turn pointer into integer
--> $DIR/ptr_arith.rs:14:14
|
LL | let _v = x + 0;
- | ^ evaluation of static initializer failed here
+ | ^ evaluation of `PTR_INT_TRANSMUTE` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
diff --git a/tests/ui/consts/miri_unleashed/tls.stderr b/tests/ui/consts/miri_unleashed/tls.stderr
index cdfe8bf..08e069d 100644
--- a/tests/ui/consts/miri_unleashed/tls.stderr
+++ b/tests/ui/consts/miri_unleashed/tls.stderr
@@ -2,13 +2,13 @@
--> $DIR/tls.rs:11:25
|
LL | unsafe { let _val = A; }
- | ^ evaluation of static initializer failed here
+ | ^ evaluation of `TEST_BAD` failed here
error[E0080]: cannot access thread local static `A`
--> $DIR/tls.rs:19:26
|
LL | unsafe { let _val = &A; }
- | ^ evaluation of static initializer failed here
+ | ^ evaluation of `TEST_BAD_REF` failed here
warning: skipping const checks
|
diff --git a/tests/ui/consts/missing_span_in_backtrace.stderr b/tests/ui/consts/missing_span_in_backtrace.stderr
index 5ba5e34..de4acbf 100644
--- a/tests/ui/consts/missing_span_in_backtrace.stderr
+++ b/tests/ui/consts/missing_span_in_backtrace.stderr
@@ -6,7 +6,7 @@
16 | | &mut ptr2 as *mut _ as *mut MaybeUninit<u8>,
17 | | mem::size_of::<&i32>(),
18 | | );
- | |_________^ evaluation of constant value failed here
+ | |_________^ evaluation of `X` failed inside this call
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
diff --git a/tests/ui/consts/no-ice-from-static-in-const-issue-52060.stderr b/tests/ui/consts/no-ice-from-static-in-const-issue-52060.stderr
index 318082f..210bb34 100644
--- a/tests/ui/consts/no-ice-from-static-in-const-issue-52060.stderr
+++ b/tests/ui/consts/no-ice-from-static-in-const-issue-52060.stderr
@@ -2,7 +2,7 @@
--> $DIR/no-ice-from-static-in-const-issue-52060.rs:5:35
|
LL | static B: [u32; 1] = [0; unsafe { A.len() }];
- | ^ evaluation of constant value failed here
+ | ^ evaluation of `B::{constant#1}` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/offset_from_ub.stderr b/tests/ui/consts/offset_from_ub.stderr
index 842698e..558e1ea 100644
--- a/tests/ui/consts/offset_from_ub.stderr
+++ b/tests/ui/consts/offset_from_ub.stderr
@@ -2,13 +2,13 @@
--> $DIR/offset_from_ub.rs:20:27
|
LL | let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `DIFFERENT_ALLOC` failed here
error[E0080]: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation
--> $DIR/offset_from_ub.rs:26:14
|
LL | unsafe { (42 as *const u8).offset_from(&5u8) as usize }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `NOT_PTR` failed inside this call
|
note: inside `std::ptr::const_ptr::<impl *const u8>::offset_from`
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -17,67 +17,67 @@
--> $DIR/offset_from_ub.rs:34:14
|
LL | unsafe { ptr_offset_from(field_ptr, base_ptr as *const u16) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `NOT_MULTIPLE_OF_SIZE` failed here
error[E0080]: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation
--> $DIR/offset_from_ub.rs:42:14
|
LL | unsafe { ptr_offset_from(ptr2, ptr1) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `DIFFERENT_INT` failed here
error[E0080]: `ptr_offset_from` called on two different pointers where the memory range between them is not in-bounds of an allocation
--> $DIR/offset_from_ub.rs:51:14
|
LL | unsafe { ptr_offset_from(end_ptr, start_ptr) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OUT_OF_BOUNDS_1` failed here
error[E0080]: `ptr_offset_from` called on two different pointers where the memory range between them is not in-bounds of an allocation
--> $DIR/offset_from_ub.rs:60:14
|
LL | unsafe { ptr_offset_from(start_ptr, end_ptr) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OUT_OF_BOUNDS_2` failed here
error[E0080]: `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation
--> $DIR/offset_from_ub.rs:69:14
|
LL | unsafe { ptr_offset_from_unsigned(field_ptr, base_ptr) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `DIFFERENT_ALLOC_UNSIGNED` failed here
error[E0080]: `ptr_offset_from` called when first pointer is too far ahead of second
--> $DIR/offset_from_ub.rs:76:14
|
LL | unsafe { ptr_offset_from(ptr2, ptr1) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TOO_FAR_APART1` failed here
error[E0080]: `ptr_offset_from` called when first pointer is too far before second
--> $DIR/offset_from_ub.rs:82:14
|
LL | unsafe { ptr_offset_from(ptr1, ptr2) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TOO_FAR_APART2` failed here
error[E0080]: `ptr_offset_from` called when first pointer is too far before second
--> $DIR/offset_from_ub.rs:90:14
|
LL | unsafe { ptr_offset_from(ptr1, ptr2) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TOO_FAR_APART3` failed here
error[E0080]: `ptr_offset_from_unsigned` called when first pointer has smaller offset than second: 0 < 8
--> $DIR/offset_from_ub.rs:97:14
|
LL | unsafe { ptr_offset_from_unsigned(p, p.add(2)) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `WRONG_ORDER_UNSIGNED` failed here
error[E0080]: `ptr_offset_from_unsigned` called when first pointer is too far ahead of second
--> $DIR/offset_from_ub.rs:104:14
|
LL | unsafe { ptr_offset_from_unsigned(ptr2, ptr1) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `TOO_FAR_APART_UNSIGNED` failed here
error[E0080]: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation
--> $DIR/offset_from_ub.rs:112:14
|
LL | unsafe { ptr2.offset_from(ptr1) }
- | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OFFSET_VERY_FAR1` failed inside this call
|
note: inside `std::ptr::const_ptr::<impl *const u8>::offset_from`
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
@@ -86,7 +86,7 @@
--> $DIR/offset_from_ub.rs:118:14
|
LL | unsafe { ptr1.offset_from(ptr2.wrapping_offset(1)) }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OFFSET_VERY_FAR2` failed inside this call
|
note: inside `std::ptr::const_ptr::<impl *const u8>::offset_from`
--> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL
diff --git a/tests/ui/consts/offset_ub.stderr b/tests/ui/consts/offset_ub.stderr
index 4135804..255583c 100644
--- a/tests/ui/consts/offset_ub.stderr
+++ b/tests/ui/consts/offset_ub.stderr
@@ -2,67 +2,67 @@
--> $DIR/offset_ub.rs:8:46
|
LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BEFORE_START` failed here
error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got ALLOC1 which is only 1 byte from the end of the allocation
--> $DIR/offset_ub.rs:9:43
|
LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `AFTER_END` failed here
error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got ALLOC2 which is only $BYTES bytes from the end of the allocation
--> $DIR/offset_ub.rs:10:45
|
LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `AFTER_ARRAY` failed here
error[E0080]: overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize`
--> $DIR/offset_ub.rs:12:43
|
LL | pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MAX) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OVERFLOW` failed here
error[E0080]: overflowing pointer arithmetic: the total offset in bytes does not fit in an `isize`
--> $DIR/offset_ub.rs:13:44
|
LL | pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MIN) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNDERFLOW` failed here
error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance)
--> $DIR/offset_ub.rs:14:56
|
LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `OVERFLOW_ADDRESS_SPACE` failed here
error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
--> $DIR/offset_ub.rs:15:57
|
LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNDERFLOW_ADDRESS_SPACE` failed here
error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got ALLOC3-0x2 which is only $BYTES bytes from the beginning of the allocation
--> $DIR/offset_ub.rs:16:49
|
LL | pub const NEGATIVE_OFFSET: *const u8 = unsafe { [0u8; 1].as_ptr().wrapping_offset(-2).offset(-2) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `NEGATIVE_OFFSET` failed here
error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 1 byte, but got ALLOC4 which is at or beyond the end of the allocation of size $BYTES bytes
--> $DIR/offset_ub.rs:18:50
|
LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `ZERO_SIZED_ALLOC` failed here
error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by $BYTES bytes, but got 0x1[noalloc] which is a dangling pointer (it has no provenance)
--> $DIR/offset_ub.rs:19:42
|
LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::<u8>::dangling().as_ptr().offset(4) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `DANGLING` failed here
error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by -$BYTES bytes, but got 0xf..f[noalloc] which is a dangling pointer (it has no provenance)
--> $DIR/offset_ub.rs:22:47
|
LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `UNDERFLOW_ABS` failed here
error: aborting due to 11 previous errors
diff --git a/tests/ui/consts/overflowing-consts.noopt.stderr b/tests/ui/consts/overflowing-consts.noopt.stderr
index e317060..1ef2a60 100644
--- a/tests/ui/consts/overflowing-consts.noopt.stderr
+++ b/tests/ui/consts/overflowing-consts.noopt.stderr
@@ -2,1021 +2,1021 @@
--> $DIR/overflowing-consts.rs:18:22
|
LL | const _NI8_SHL: i8 = 1i8 << 8;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI8_SHL` failed here
error[E0080]: attempt to shift left by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:19:26
|
LL | const _NI8_SHL_P: &i8 = &(1i8 << 8);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI8_SHL_P` failed here
error[E0080]: attempt to shift left by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:21:24
|
LL | const _NI16_SHL: i16 = 1i16 << 16;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI16_SHL` failed here
error[E0080]: attempt to shift left by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:22:28
|
LL | const _NI16_SHL_P: &i16 = &(1i16 << 16);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI16_SHL_P` failed here
error[E0080]: attempt to shift left by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:24:24
|
LL | const _NI32_SHL: i32 = 1i32 << 32;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI32_SHL` failed here
error[E0080]: attempt to shift left by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:25:28
|
LL | const _NI32_SHL_P: &i32 = &(1i32 << 32);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI32_SHL_P` failed here
error[E0080]: attempt to shift left by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:27:24
|
LL | const _NI64_SHL: i64 = 1i64 << 64;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI64_SHL` failed here
error[E0080]: attempt to shift left by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:28:28
|
LL | const _NI64_SHL_P: &i64 = &(1i64 << 64);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI64_SHL_P` failed here
error[E0080]: attempt to shift left by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:30:26
|
LL | const _NI128_SHL: i128 = 1i128 << 128;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI128_SHL` failed here
error[E0080]: attempt to shift left by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:31:30
|
LL | const _NI128_SHL_P: &i128 = &(1i128 << 128);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI128_SHL_P` failed here
error[E0080]: attempt to shift left by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:33:22
|
LL | const _NU8_SHL: u8 = 1u8 << 8;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU8_SHL` failed here
error[E0080]: attempt to shift left by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:34:26
|
LL | const _NU8_SHL_P: &u8 = &(1u8 << 8);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU8_SHL_P` failed here
error[E0080]: attempt to shift left by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:36:24
|
LL | const _NU16_SHL: u16 = 1u16 << 16;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU16_SHL` failed here
error[E0080]: attempt to shift left by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:37:28
|
LL | const _NU16_SHL_P: &u16 = &(1u16 << 16);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU16_SHL_P` failed here
error[E0080]: attempt to shift left by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:39:24
|
LL | const _NU32_SHL: u32 = 1u32 << 32;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU32_SHL` failed here
error[E0080]: attempt to shift left by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:40:28
|
LL | const _NU32_SHL_P: &u32 = &(1u32 << 32);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU32_SHL_P` failed here
error[E0080]: attempt to shift left by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:42:24
|
LL | const _NU64_SHL: u64 = 1u64 << 64;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU64_SHL` failed here
error[E0080]: attempt to shift left by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:43:28
|
LL | const _NU64_SHL_P: &u64 = &(1u64 << 64);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU64_SHL_P` failed here
error[E0080]: attempt to shift left by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:45:26
|
LL | const _NU128_SHL: u128 = 1u128 << 128;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU128_SHL` failed here
error[E0080]: attempt to shift left by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:46:30
|
LL | const _NU128_SHL_P: &u128 = &(1u128 << 128);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NU128_SHL_P` failed here
error[E0080]: attempt to shift left by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:48:28
|
LL | const _NISIZE_SHL: isize = 1isize << BITS;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHL` failed here
error[E0080]: attempt to shift left by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:49:32
|
LL | const _NISIZE_SHL_P: &isize = &(1isize << BITS);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHL_P` failed here
error[E0080]: attempt to shift left by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:51:28
|
LL | const _NUSIZE_SHL: usize = 1usize << BITS;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHL` failed here
error[E0080]: attempt to shift left by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:52:32
|
LL | const _NUSIZE_SHL_P: &usize = &(1usize << BITS);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHL_P` failed here
error[E0080]: attempt to shift right by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:55:22
|
LL | const _NI8_SHR: i8 = 1i8 >> 8;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI8_SHR` failed here
error[E0080]: attempt to shift right by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:56:26
|
LL | const _NI8_SHR_P: &i8 = &(1i8 >> 8);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI8_SHR_P` failed here
error[E0080]: attempt to shift right by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:58:24
|
LL | const _NI16_SHR: i16 = 1i16 >> 16;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI16_SHR` failed here
error[E0080]: attempt to shift right by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:59:28
|
LL | const _NI16_SHR_P: &i16 = &(1i16 >> 16);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI16_SHR_P` failed here
error[E0080]: attempt to shift right by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:61:24
|
LL | const _NI32_SHR: i32 = 1i32 >> 32;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI32_SHR` failed here
error[E0080]: attempt to shift right by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:62:28
|
LL | const _NI32_SHR_P: &i32 = &(1i32 >> 32);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI32_SHR_P` failed here
error[E0080]: attempt to shift right by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:64:24
|
LL | const _NI64_SHR: i64 = 1i64 >> 64;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI64_SHR` failed here
error[E0080]: attempt to shift right by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:65:28
|
LL | const _NI64_SHR_P: &i64 = &(1i64 >> 64);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI64_SHR_P` failed here
error[E0080]: attempt to shift right by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:67:26
|
LL | const _NI128_SHR: i128 = 1i128 >> 128;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI128_SHR` failed here
error[E0080]: attempt to shift right by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:68:30
|
LL | const _NI128_SHR_P: &i128 = &(1i128 >> 128);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI128_SHR_P` failed here
error[E0080]: attempt to shift right by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:70:22
|
LL | const _NU8_SHR: u8 = 1u8 >> 8;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU8_SHR` failed here
error[E0080]: attempt to shift right by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:71:26
|
LL | const _NU8_SHR_P: &u8 = &(1u8 >> 8);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU8_SHR_P` failed here
error[E0080]: attempt to shift right by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:73:24
|
LL | const _NU16_SHR: u16 = 1u16 >> 16;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU16_SHR` failed here
error[E0080]: attempt to shift right by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:74:28
|
LL | const _NU16_SHR_P: &u16 = &(1u16 >> 16);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU16_SHR_P` failed here
error[E0080]: attempt to shift right by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:76:24
|
LL | const _NU32_SHR: u32 = 1u32 >> 32;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU32_SHR` failed here
error[E0080]: attempt to shift right by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:77:28
|
LL | const _NU32_SHR_P: &u32 = &(1u32 >> 32);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU32_SHR_P` failed here
error[E0080]: attempt to shift right by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:79:24
|
LL | const _NU64_SHR: u64 = 1u64 >> 64;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU64_SHR` failed here
error[E0080]: attempt to shift right by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:80:28
|
LL | const _NU64_SHR_P: &u64 = &(1u64 >> 64);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU64_SHR_P` failed here
error[E0080]: attempt to shift right by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:82:26
|
LL | const _NU128_SHR: u128 = 1u128 >> 128;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU128_SHR` failed here
error[E0080]: attempt to shift right by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:83:30
|
LL | const _NU128_SHR_P: &u128 = &(1u128 >> 128);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NU128_SHR_P` failed here
error[E0080]: attempt to shift right by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:85:28
|
LL | const _NISIZE_SHR: isize = 1isize >> BITS;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHR` failed here
error[E0080]: attempt to shift right by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:86:32
|
LL | const _NISIZE_SHR_P: &isize = &(1isize >> BITS);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHR_P` failed here
error[E0080]: attempt to shift right by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:88:28
|
LL | const _NUSIZE_SHR: usize = 1usize >> BITS;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHR` failed here
error[E0080]: attempt to shift right by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:89:32
|
LL | const _NUSIZE_SHR_P: &usize = &(1usize >> BITS);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHR_P` failed here
error[E0080]: attempt to compute `1_i8 + i8::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:92:22
|
LL | const _NI8_ADD: i8 = 1i8 + i8::MAX;
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `_NI8_ADD` failed here
error[E0080]: attempt to compute `1_i8 + i8::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:93:26
|
LL | const _NI8_ADD_P: &i8 = &(1i8 + i8::MAX);
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NI8_ADD_P` failed here
error[E0080]: attempt to compute `1_i16 + i16::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:95:24
|
LL | const _NI16_ADD: i16 = 1i16 + i16::MAX;
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NI16_ADD` failed here
error[E0080]: attempt to compute `1_i16 + i16::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:96:28
|
LL | const _NI16_ADD_P: &i16 = &(1i16 + i16::MAX);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NI16_ADD_P` failed here
error[E0080]: attempt to compute `1_i32 + i32::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:98:24
|
LL | const _NI32_ADD: i32 = 1i32 + i32::MAX;
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NI32_ADD` failed here
error[E0080]: attempt to compute `1_i32 + i32::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:99:28
|
LL | const _NI32_ADD_P: &i32 = &(1i32 + i32::MAX);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NI32_ADD_P` failed here
error[E0080]: attempt to compute `1_i64 + i64::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:101:24
|
LL | const _NI64_ADD: i64 = 1i64 + i64::MAX;
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NI64_ADD` failed here
error[E0080]: attempt to compute `1_i64 + i64::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:102:28
|
LL | const _NI64_ADD_P: &i64 = &(1i64 + i64::MAX);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NI64_ADD_P` failed here
error[E0080]: attempt to compute `1_i128 + i128::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:104:26
|
LL | const _NI128_ADD: i128 = 1i128 + i128::MAX;
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NI128_ADD` failed here
error[E0080]: attempt to compute `1_i128 + i128::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:105:30
|
LL | const _NI128_ADD_P: &i128 = &(1i128 + i128::MAX);
- | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NI128_ADD_P` failed here
error[E0080]: attempt to compute `1_u8 + u8::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:107:22
|
LL | const _NU8_ADD: u8 = 1u8 + u8::MAX;
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `_NU8_ADD` failed here
error[E0080]: attempt to compute `1_u8 + u8::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:108:26
|
LL | const _NU8_ADD_P: &u8 = &(1u8 + u8::MAX);
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NU8_ADD_P` failed here
error[E0080]: attempt to compute `1_u16 + u16::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:110:24
|
LL | const _NU16_ADD: u16 = 1u16 + u16::MAX;
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NU16_ADD` failed here
error[E0080]: attempt to compute `1_u16 + u16::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:111:28
|
LL | const _NU16_ADD_P: &u16 = &(1u16 + u16::MAX);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NU16_ADD_P` failed here
error[E0080]: attempt to compute `1_u32 + u32::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:113:24
|
LL | const _NU32_ADD: u32 = 1u32 + u32::MAX;
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NU32_ADD` failed here
error[E0080]: attempt to compute `1_u32 + u32::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:114:28
|
LL | const _NU32_ADD_P: &u32 = &(1u32 + u32::MAX);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NU32_ADD_P` failed here
error[E0080]: attempt to compute `1_u64 + u64::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:116:24
|
LL | const _NU64_ADD: u64 = 1u64 + u64::MAX;
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NU64_ADD` failed here
error[E0080]: attempt to compute `1_u64 + u64::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:117:28
|
LL | const _NU64_ADD_P: &u64 = &(1u64 + u64::MAX);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NU64_ADD_P` failed here
error[E0080]: attempt to compute `1_u128 + u128::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:119:26
|
LL | const _NU128_ADD: u128 = 1u128 + u128::MAX;
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NU128_ADD` failed here
error[E0080]: attempt to compute `1_u128 + u128::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:120:30
|
LL | const _NU128_ADD_P: &u128 = &(1u128 + u128::MAX);
- | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NU128_ADD_P` failed here
error[E0080]: attempt to compute `1_isize + isize::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:122:28
|
LL | const _NISIZE_ADD: isize = 1isize + isize::MAX;
- | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_ADD` failed here
error[E0080]: attempt to compute `1_isize + isize::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:123:32
|
LL | const _NISIZE_ADD_P: &isize = &(1isize + isize::MAX);
- | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_ADD_P` failed here
error[E0080]: attempt to compute `1_usize + usize::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:125:28
|
LL | const _NUSIZE_ADD: usize = 1usize + usize::MAX;
- | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_ADD` failed here
error[E0080]: attempt to compute `1_usize + usize::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:126:32
|
LL | const _NUSIZE_ADD_P: &usize = &(1usize + usize::MAX);
- | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_ADD_P` failed here
error[E0080]: attempt to compute `-5_i8 - i8::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:129:22
|
LL | const _NI8_SUB: i8 = -5i8 - i8::MAX;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI8_SUB` failed here
error[E0080]: attempt to compute `-5_i8 - i8::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:130:26
|
LL | const _NI8_SUB_P: &i8 = &(-5i8 - i8::MAX);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NI8_SUB_P` failed here
error[E0080]: attempt to compute `-5_i16 - i16::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:132:24
|
LL | const _NI16_SUB: i16 = -5i16 - i16::MAX;
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NI16_SUB` failed here
error[E0080]: attempt to compute `-5_i16 - i16::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:133:28
|
LL | const _NI16_SUB_P: &i16 = &(-5i16 - i16::MAX);
- | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI16_SUB_P` failed here
error[E0080]: attempt to compute `-5_i32 - i32::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:135:24
|
LL | const _NI32_SUB: i32 = -5i32 - i32::MAX;
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NI32_SUB` failed here
error[E0080]: attempt to compute `-5_i32 - i32::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:136:28
|
LL | const _NI32_SUB_P: &i32 = &(-5i32 - i32::MAX);
- | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI32_SUB_P` failed here
error[E0080]: attempt to compute `-5_i64 - i64::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:138:24
|
LL | const _NI64_SUB: i64 = -5i64 - i64::MAX;
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NI64_SUB` failed here
error[E0080]: attempt to compute `-5_i64 - i64::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:139:28
|
LL | const _NI64_SUB_P: &i64 = &(-5i64 - i64::MAX);
- | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI64_SUB_P` failed here
error[E0080]: attempt to compute `-5_i128 - i128::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:141:26
|
LL | const _NI128_SUB: i128 = -5i128 - i128::MAX;
- | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI128_SUB` failed here
error[E0080]: attempt to compute `-5_i128 - i128::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:142:30
|
LL | const _NI128_SUB_P: &i128 = &(-5i128 - i128::MAX);
- | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^ evaluation of `_NI128_SUB_P` failed here
error[E0080]: attempt to compute `1_u8 - 5_u8`, which would overflow
--> $DIR/overflowing-consts.rs:144:22
|
LL | const _NU8_SUB: u8 = 1u8 - 5;
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `_NU8_SUB` failed here
error[E0080]: attempt to compute `1_u8 - 5_u8`, which would overflow
--> $DIR/overflowing-consts.rs:145:26
|
LL | const _NU8_SUB_P: &u8 = &(1u8 - 5);
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NU8_SUB_P` failed here
error[E0080]: attempt to compute `1_u16 - 5_u16`, which would overflow
--> $DIR/overflowing-consts.rs:147:24
|
LL | const _NU16_SUB: u16 = 1u16 - 5;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU16_SUB` failed here
error[E0080]: attempt to compute `1_u16 - 5_u16`, which would overflow
--> $DIR/overflowing-consts.rs:148:28
|
LL | const _NU16_SUB_P: &u16 = &(1u16 - 5);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU16_SUB_P` failed here
error[E0080]: attempt to compute `1_u32 - 5_u32`, which would overflow
--> $DIR/overflowing-consts.rs:150:24
|
LL | const _NU32_SUB: u32 = 1u32 - 5;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU32_SUB` failed here
error[E0080]: attempt to compute `1_u32 - 5_u32`, which would overflow
--> $DIR/overflowing-consts.rs:151:28
|
LL | const _NU32_SUB_P: &u32 = &(1u32 - 5);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU32_SUB_P` failed here
error[E0080]: attempt to compute `1_u64 - 5_u64`, which would overflow
--> $DIR/overflowing-consts.rs:153:24
|
LL | const _NU64_SUB: u64 = 1u64 - 5;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU64_SUB` failed here
error[E0080]: attempt to compute `1_u64 - 5_u64`, which would overflow
--> $DIR/overflowing-consts.rs:154:28
|
LL | const _NU64_SUB_P: &u64 = &(1u64 - 5);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU64_SUB_P` failed here
error[E0080]: attempt to compute `1_u128 - 5_u128`, which would overflow
--> $DIR/overflowing-consts.rs:156:26
|
LL | const _NU128_SUB: u128 = 1u128 - 5;
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NU128_SUB` failed here
error[E0080]: attempt to compute `1_u128 - 5_u128`, which would overflow
--> $DIR/overflowing-consts.rs:157:30
|
LL | const _NU128_SUB_P: &u128 = &(1u128 - 5);
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NU128_SUB_P` failed here
error[E0080]: attempt to compute `-5_isize - isize::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:159:28
|
LL | const _NISIZE_SUB: isize = -5isize - isize::MAX;
- | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SUB` failed here
error[E0080]: attempt to compute `-5_isize - isize::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:160:32
|
LL | const _NISIZE_SUB_P: &isize = &(-5isize - isize::MAX);
- | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SUB_P` failed here
error[E0080]: attempt to compute `1_usize - 5_usize`, which would overflow
--> $DIR/overflowing-consts.rs:162:28
|
LL | const _NUSIZE_SUB: usize = 1usize - 5;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NUSIZE_SUB` failed here
error[E0080]: attempt to compute `1_usize - 5_usize`, which would overflow
--> $DIR/overflowing-consts.rs:163:32
|
LL | const _NUSIZE_SUB_P: &usize = &(1usize - 5);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NUSIZE_SUB_P` failed here
error[E0080]: attempt to compute `i8::MAX * 5_i8`, which would overflow
--> $DIR/overflowing-consts.rs:166:22
|
LL | const _NI8_MUL: i8 = i8::MAX * 5;
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NI8_MUL` failed here
error[E0080]: attempt to compute `i8::MAX * 5_i8`, which would overflow
--> $DIR/overflowing-consts.rs:167:26
|
LL | const _NI8_MUL_P: &i8 = &(i8::MAX * 5);
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `_NI8_MUL_P` failed here
error[E0080]: attempt to compute `i16::MAX * 5_i16`, which would overflow
--> $DIR/overflowing-consts.rs:169:24
|
LL | const _NI16_MUL: i16 = i16::MAX * 5;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI16_MUL` failed here
error[E0080]: attempt to compute `i16::MAX * 5_i16`, which would overflow
--> $DIR/overflowing-consts.rs:170:28
|
LL | const _NI16_MUL_P: &i16 = &(i16::MAX * 5);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI16_MUL_P` failed here
error[E0080]: attempt to compute `i32::MAX * 5_i32`, which would overflow
--> $DIR/overflowing-consts.rs:172:24
|
LL | const _NI32_MUL: i32 = i32::MAX * 5;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI32_MUL` failed here
error[E0080]: attempt to compute `i32::MAX * 5_i32`, which would overflow
--> $DIR/overflowing-consts.rs:173:28
|
LL | const _NI32_MUL_P: &i32 = &(i32::MAX * 5);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI32_MUL_P` failed here
error[E0080]: attempt to compute `i64::MAX * 5_i64`, which would overflow
--> $DIR/overflowing-consts.rs:175:24
|
LL | const _NI64_MUL: i64 = i64::MAX * 5;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI64_MUL` failed here
error[E0080]: attempt to compute `i64::MAX * 5_i64`, which would overflow
--> $DIR/overflowing-consts.rs:176:28
|
LL | const _NI64_MUL_P: &i64 = &(i64::MAX * 5);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI64_MUL_P` failed here
error[E0080]: attempt to compute `i128::MAX * 5_i128`, which would overflow
--> $DIR/overflowing-consts.rs:178:26
|
LL | const _NI128_MUL: i128 = i128::MAX * 5;
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `_NI128_MUL` failed here
error[E0080]: attempt to compute `i128::MAX * 5_i128`, which would overflow
--> $DIR/overflowing-consts.rs:179:30
|
LL | const _NI128_MUL_P: &i128 = &(i128::MAX * 5);
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NI128_MUL_P` failed here
error[E0080]: attempt to compute `u8::MAX * 5_u8`, which would overflow
--> $DIR/overflowing-consts.rs:181:22
|
LL | const _NU8_MUL: u8 = u8::MAX * 5;
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NU8_MUL` failed here
error[E0080]: attempt to compute `u8::MAX * 5_u8`, which would overflow
--> $DIR/overflowing-consts.rs:182:26
|
LL | const _NU8_MUL_P: &u8 = &(u8::MAX * 5);
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `_NU8_MUL_P` failed here
error[E0080]: attempt to compute `u16::MAX * 5_u16`, which would overflow
--> $DIR/overflowing-consts.rs:184:24
|
LL | const _NU16_MUL: u16 = u16::MAX * 5;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU16_MUL` failed here
error[E0080]: attempt to compute `u16::MAX * 5_u16`, which would overflow
--> $DIR/overflowing-consts.rs:185:28
|
LL | const _NU16_MUL_P: &u16 = &(u16::MAX * 5);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NU16_MUL_P` failed here
error[E0080]: attempt to compute `u32::MAX * 5_u32`, which would overflow
--> $DIR/overflowing-consts.rs:187:24
|
LL | const _NU32_MUL: u32 = u32::MAX * 5;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU32_MUL` failed here
error[E0080]: attempt to compute `u32::MAX * 5_u32`, which would overflow
--> $DIR/overflowing-consts.rs:188:28
|
LL | const _NU32_MUL_P: &u32 = &(u32::MAX * 5);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NU32_MUL_P` failed here
error[E0080]: attempt to compute `u64::MAX * 5_u64`, which would overflow
--> $DIR/overflowing-consts.rs:190:24
|
LL | const _NU64_MUL: u64 = u64::MAX * 5;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU64_MUL` failed here
error[E0080]: attempt to compute `u64::MAX * 5_u64`, which would overflow
--> $DIR/overflowing-consts.rs:191:28
|
LL | const _NU64_MUL_P: &u64 = &(u64::MAX * 5);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NU64_MUL_P` failed here
error[E0080]: attempt to compute `u128::MAX * 5_u128`, which would overflow
--> $DIR/overflowing-consts.rs:193:26
|
LL | const _NU128_MUL: u128 = u128::MAX * 5;
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `_NU128_MUL` failed here
error[E0080]: attempt to compute `u128::MAX * 5_u128`, which would overflow
--> $DIR/overflowing-consts.rs:194:30
|
LL | const _NU128_MUL_P: &u128 = &(u128::MAX * 5);
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NU128_MUL_P` failed here
error[E0080]: attempt to compute `isize::MAX * 5_isize`, which would overflow
--> $DIR/overflowing-consts.rs:196:28
|
LL | const _NISIZE_MUL: isize = isize::MAX * 5;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NISIZE_MUL` failed here
error[E0080]: attempt to compute `isize::MAX * 5_isize`, which would overflow
--> $DIR/overflowing-consts.rs:197:32
|
LL | const _NISIZE_MUL_P: &isize = &(isize::MAX * 5);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_MUL_P` failed here
error[E0080]: attempt to compute `usize::MAX * 5_usize`, which would overflow
--> $DIR/overflowing-consts.rs:199:28
|
LL | const _NUSIZE_MUL: usize = usize::MAX * 5;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NUSIZE_MUL` failed here
error[E0080]: attempt to compute `usize::MAX * 5_usize`, which would overflow
--> $DIR/overflowing-consts.rs:200:32
|
LL | const _NUSIZE_MUL_P: &usize = &(usize::MAX * 5);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_MUL_P` failed here
error[E0080]: attempt to divide `1_i8` by zero
--> $DIR/overflowing-consts.rs:203:22
|
LL | const _NI8_DIV: i8 = 1i8 / 0;
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `_NI8_DIV` failed here
error[E0080]: attempt to divide `1_i8` by zero
--> $DIR/overflowing-consts.rs:204:26
|
LL | const _NI8_DIV_P: &i8 = &(1i8 / 0);
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NI8_DIV_P` failed here
error[E0080]: attempt to divide `1_i16` by zero
--> $DIR/overflowing-consts.rs:206:24
|
LL | const _NI16_DIV: i16 = 1i16 / 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI16_DIV` failed here
error[E0080]: attempt to divide `1_i16` by zero
--> $DIR/overflowing-consts.rs:207:28
|
LL | const _NI16_DIV_P: &i16 = &(1i16 / 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI16_DIV_P` failed here
error[E0080]: attempt to divide `1_i32` by zero
--> $DIR/overflowing-consts.rs:209:24
|
LL | const _NI32_DIV: i32 = 1i32 / 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI32_DIV` failed here
error[E0080]: attempt to divide `1_i32` by zero
--> $DIR/overflowing-consts.rs:210:28
|
LL | const _NI32_DIV_P: &i32 = &(1i32 / 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI32_DIV_P` failed here
error[E0080]: attempt to divide `1_i64` by zero
--> $DIR/overflowing-consts.rs:212:24
|
LL | const _NI64_DIV: i64 = 1i64 / 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI64_DIV` failed here
error[E0080]: attempt to divide `1_i64` by zero
--> $DIR/overflowing-consts.rs:213:28
|
LL | const _NI64_DIV_P: &i64 = &(1i64 / 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI64_DIV_P` failed here
error[E0080]: attempt to divide `1_i128` by zero
--> $DIR/overflowing-consts.rs:215:26
|
LL | const _NI128_DIV: i128 = 1i128 / 0;
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NI128_DIV` failed here
error[E0080]: attempt to divide `1_i128` by zero
--> $DIR/overflowing-consts.rs:216:30
|
LL | const _NI128_DIV_P: &i128 = &(1i128 / 0);
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NI128_DIV_P` failed here
error[E0080]: attempt to divide `1_u8` by zero
--> $DIR/overflowing-consts.rs:218:22
|
LL | const _NU8_DIV: u8 = 1u8 / 0;
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `_NU8_DIV` failed here
error[E0080]: attempt to divide `1_u8` by zero
--> $DIR/overflowing-consts.rs:219:26
|
LL | const _NU8_DIV_P: &u8 = &(1u8 / 0);
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NU8_DIV_P` failed here
error[E0080]: attempt to divide `1_u16` by zero
--> $DIR/overflowing-consts.rs:221:24
|
LL | const _NU16_DIV: u16 = 1u16 / 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU16_DIV` failed here
error[E0080]: attempt to divide `1_u16` by zero
--> $DIR/overflowing-consts.rs:222:28
|
LL | const _NU16_DIV_P: &u16 = &(1u16 / 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU16_DIV_P` failed here
error[E0080]: attempt to divide `1_u32` by zero
--> $DIR/overflowing-consts.rs:224:24
|
LL | const _NU32_DIV: u32 = 1u32 / 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU32_DIV` failed here
error[E0080]: attempt to divide `1_u32` by zero
--> $DIR/overflowing-consts.rs:225:28
|
LL | const _NU32_DIV_P: &u32 = &(1u32 / 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU32_DIV_P` failed here
error[E0080]: attempt to divide `1_u64` by zero
--> $DIR/overflowing-consts.rs:227:24
|
LL | const _NU64_DIV: u64 = 1u64 / 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU64_DIV` failed here
error[E0080]: attempt to divide `1_u64` by zero
--> $DIR/overflowing-consts.rs:228:28
|
LL | const _NU64_DIV_P: &u64 = &(1u64 / 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU64_DIV_P` failed here
error[E0080]: attempt to divide `1_u128` by zero
--> $DIR/overflowing-consts.rs:230:26
|
LL | const _NU128_DIV: u128 = 1u128 / 0;
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NU128_DIV` failed here
error[E0080]: attempt to divide `1_u128` by zero
--> $DIR/overflowing-consts.rs:231:30
|
LL | const _NU128_DIV_P: &u128 = &(1u128 / 0);
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NU128_DIV_P` failed here
error[E0080]: attempt to divide `1_isize` by zero
--> $DIR/overflowing-consts.rs:233:28
|
LL | const _NISIZE_DIV: isize = 1isize / 0;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NISIZE_DIV` failed here
error[E0080]: attempt to divide `1_isize` by zero
--> $DIR/overflowing-consts.rs:234:32
|
LL | const _NISIZE_DIV_P: &isize = &(1isize / 0);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NISIZE_DIV_P` failed here
error[E0080]: attempt to divide `1_usize` by zero
--> $DIR/overflowing-consts.rs:236:28
|
LL | const _NUSIZE_DIV: usize = 1usize / 0;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NUSIZE_DIV` failed here
error[E0080]: attempt to divide `1_usize` by zero
--> $DIR/overflowing-consts.rs:237:32
|
LL | const _NUSIZE_DIV_P: &usize = &(1usize / 0);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NUSIZE_DIV_P` failed here
error[E0080]: attempt to calculate the remainder of `1_i8` with a divisor of zero
--> $DIR/overflowing-consts.rs:240:22
|
LL | const _NI8_MOD: i8 = 1i8 % 0;
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `_NI8_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_i8` with a divisor of zero
--> $DIR/overflowing-consts.rs:241:26
|
LL | const _NI8_MOD_P: &i8 = &(1i8 % 0);
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NI8_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_i16` with a divisor of zero
--> $DIR/overflowing-consts.rs:243:24
|
LL | const _NI16_MOD: i16 = 1i16 % 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI16_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_i16` with a divisor of zero
--> $DIR/overflowing-consts.rs:244:28
|
LL | const _NI16_MOD_P: &i16 = &(1i16 % 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI16_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_i32` with a divisor of zero
--> $DIR/overflowing-consts.rs:246:24
|
LL | const _NI32_MOD: i32 = 1i32 % 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI32_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_i32` with a divisor of zero
--> $DIR/overflowing-consts.rs:247:28
|
LL | const _NI32_MOD_P: &i32 = &(1i32 % 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI32_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_i64` with a divisor of zero
--> $DIR/overflowing-consts.rs:249:24
|
LL | const _NI64_MOD: i64 = 1i64 % 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI64_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_i64` with a divisor of zero
--> $DIR/overflowing-consts.rs:250:28
|
LL | const _NI64_MOD_P: &i64 = &(1i64 % 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI64_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_i128` with a divisor of zero
--> $DIR/overflowing-consts.rs:252:26
|
LL | const _NI128_MOD: i128 = 1i128 % 0;
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NI128_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_i128` with a divisor of zero
--> $DIR/overflowing-consts.rs:253:30
|
LL | const _NI128_MOD_P: &i128 = &(1i128 % 0);
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NI128_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_u8` with a divisor of zero
--> $DIR/overflowing-consts.rs:255:22
|
LL | const _NU8_MOD: u8 = 1u8 % 0;
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `_NU8_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_u8` with a divisor of zero
--> $DIR/overflowing-consts.rs:256:26
|
LL | const _NU8_MOD_P: &u8 = &(1u8 % 0);
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NU8_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_u16` with a divisor of zero
--> $DIR/overflowing-consts.rs:258:24
|
LL | const _NU16_MOD: u16 = 1u16 % 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU16_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_u16` with a divisor of zero
--> $DIR/overflowing-consts.rs:259:28
|
LL | const _NU16_MOD_P: &u16 = &(1u16 % 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU16_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_u32` with a divisor of zero
--> $DIR/overflowing-consts.rs:261:24
|
LL | const _NU32_MOD: u32 = 1u32 % 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU32_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_u32` with a divisor of zero
--> $DIR/overflowing-consts.rs:262:28
|
LL | const _NU32_MOD_P: &u32 = &(1u32 % 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU32_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_u64` with a divisor of zero
--> $DIR/overflowing-consts.rs:264:24
|
LL | const _NU64_MOD: u64 = 1u64 % 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU64_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_u64` with a divisor of zero
--> $DIR/overflowing-consts.rs:265:28
|
LL | const _NU64_MOD_P: &u64 = &(1u64 % 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU64_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_u128` with a divisor of zero
--> $DIR/overflowing-consts.rs:267:26
|
LL | const _NU128_MOD: u128 = 1u128 % 0;
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NU128_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_u128` with a divisor of zero
--> $DIR/overflowing-consts.rs:268:30
|
LL | const _NU128_MOD_P: &u128 = &(1u128 % 0);
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NU128_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero
--> $DIR/overflowing-consts.rs:270:28
|
LL | const _NISIZE_MOD: isize = 1isize % 0;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NISIZE_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero
--> $DIR/overflowing-consts.rs:271:32
|
LL | const _NISIZE_MOD_P: &isize = &(1isize % 0);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NISIZE_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_usize` with a divisor of zero
--> $DIR/overflowing-consts.rs:273:28
|
LL | const _NUSIZE_MOD: usize = 1usize % 0;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NUSIZE_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_usize` with a divisor of zero
--> $DIR/overflowing-consts.rs:274:32
|
LL | const _NUSIZE_MOD_P: &usize = &(1usize % 0);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NUSIZE_MOD_P` failed here
error[E0080]: index out of bounds: the length is 3 but the index is 4
--> $DIR/overflowing-consts.rs:277:24
|
LL | const _NI32_OOB: i32 = [1, 2, 3][4];
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI32_OOB` failed here
error[E0080]: index out of bounds: the length is 3 but the index is 4
--> $DIR/overflowing-consts.rs:278:28
|
LL | const _NI32_OOB_P: &i32 = &([1, 2, 3][4]);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI32_OOB_P` failed here
error: aborting due to 170 previous errors
diff --git a/tests/ui/consts/overflowing-consts.opt.stderr b/tests/ui/consts/overflowing-consts.opt.stderr
index e317060..1ef2a60 100644
--- a/tests/ui/consts/overflowing-consts.opt.stderr
+++ b/tests/ui/consts/overflowing-consts.opt.stderr
@@ -2,1021 +2,1021 @@
--> $DIR/overflowing-consts.rs:18:22
|
LL | const _NI8_SHL: i8 = 1i8 << 8;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI8_SHL` failed here
error[E0080]: attempt to shift left by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:19:26
|
LL | const _NI8_SHL_P: &i8 = &(1i8 << 8);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI8_SHL_P` failed here
error[E0080]: attempt to shift left by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:21:24
|
LL | const _NI16_SHL: i16 = 1i16 << 16;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI16_SHL` failed here
error[E0080]: attempt to shift left by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:22:28
|
LL | const _NI16_SHL_P: &i16 = &(1i16 << 16);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI16_SHL_P` failed here
error[E0080]: attempt to shift left by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:24:24
|
LL | const _NI32_SHL: i32 = 1i32 << 32;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI32_SHL` failed here
error[E0080]: attempt to shift left by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:25:28
|
LL | const _NI32_SHL_P: &i32 = &(1i32 << 32);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI32_SHL_P` failed here
error[E0080]: attempt to shift left by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:27:24
|
LL | const _NI64_SHL: i64 = 1i64 << 64;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI64_SHL` failed here
error[E0080]: attempt to shift left by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:28:28
|
LL | const _NI64_SHL_P: &i64 = &(1i64 << 64);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI64_SHL_P` failed here
error[E0080]: attempt to shift left by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:30:26
|
LL | const _NI128_SHL: i128 = 1i128 << 128;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI128_SHL` failed here
error[E0080]: attempt to shift left by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:31:30
|
LL | const _NI128_SHL_P: &i128 = &(1i128 << 128);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI128_SHL_P` failed here
error[E0080]: attempt to shift left by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:33:22
|
LL | const _NU8_SHL: u8 = 1u8 << 8;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU8_SHL` failed here
error[E0080]: attempt to shift left by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:34:26
|
LL | const _NU8_SHL_P: &u8 = &(1u8 << 8);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU8_SHL_P` failed here
error[E0080]: attempt to shift left by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:36:24
|
LL | const _NU16_SHL: u16 = 1u16 << 16;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU16_SHL` failed here
error[E0080]: attempt to shift left by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:37:28
|
LL | const _NU16_SHL_P: &u16 = &(1u16 << 16);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU16_SHL_P` failed here
error[E0080]: attempt to shift left by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:39:24
|
LL | const _NU32_SHL: u32 = 1u32 << 32;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU32_SHL` failed here
error[E0080]: attempt to shift left by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:40:28
|
LL | const _NU32_SHL_P: &u32 = &(1u32 << 32);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU32_SHL_P` failed here
error[E0080]: attempt to shift left by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:42:24
|
LL | const _NU64_SHL: u64 = 1u64 << 64;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU64_SHL` failed here
error[E0080]: attempt to shift left by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:43:28
|
LL | const _NU64_SHL_P: &u64 = &(1u64 << 64);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU64_SHL_P` failed here
error[E0080]: attempt to shift left by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:45:26
|
LL | const _NU128_SHL: u128 = 1u128 << 128;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU128_SHL` failed here
error[E0080]: attempt to shift left by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:46:30
|
LL | const _NU128_SHL_P: &u128 = &(1u128 << 128);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NU128_SHL_P` failed here
error[E0080]: attempt to shift left by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:48:28
|
LL | const _NISIZE_SHL: isize = 1isize << BITS;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHL` failed here
error[E0080]: attempt to shift left by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:49:32
|
LL | const _NISIZE_SHL_P: &isize = &(1isize << BITS);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHL_P` failed here
error[E0080]: attempt to shift left by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:51:28
|
LL | const _NUSIZE_SHL: usize = 1usize << BITS;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHL` failed here
error[E0080]: attempt to shift left by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:52:32
|
LL | const _NUSIZE_SHL_P: &usize = &(1usize << BITS);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHL_P` failed here
error[E0080]: attempt to shift right by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:55:22
|
LL | const _NI8_SHR: i8 = 1i8 >> 8;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI8_SHR` failed here
error[E0080]: attempt to shift right by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:56:26
|
LL | const _NI8_SHR_P: &i8 = &(1i8 >> 8);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI8_SHR_P` failed here
error[E0080]: attempt to shift right by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:58:24
|
LL | const _NI16_SHR: i16 = 1i16 >> 16;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI16_SHR` failed here
error[E0080]: attempt to shift right by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:59:28
|
LL | const _NI16_SHR_P: &i16 = &(1i16 >> 16);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI16_SHR_P` failed here
error[E0080]: attempt to shift right by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:61:24
|
LL | const _NI32_SHR: i32 = 1i32 >> 32;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI32_SHR` failed here
error[E0080]: attempt to shift right by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:62:28
|
LL | const _NI32_SHR_P: &i32 = &(1i32 >> 32);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI32_SHR_P` failed here
error[E0080]: attempt to shift right by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:64:24
|
LL | const _NI64_SHR: i64 = 1i64 >> 64;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI64_SHR` failed here
error[E0080]: attempt to shift right by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:65:28
|
LL | const _NI64_SHR_P: &i64 = &(1i64 >> 64);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI64_SHR_P` failed here
error[E0080]: attempt to shift right by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:67:26
|
LL | const _NI128_SHR: i128 = 1i128 >> 128;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI128_SHR` failed here
error[E0080]: attempt to shift right by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:68:30
|
LL | const _NI128_SHR_P: &i128 = &(1i128 >> 128);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI128_SHR_P` failed here
error[E0080]: attempt to shift right by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:70:22
|
LL | const _NU8_SHR: u8 = 1u8 >> 8;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU8_SHR` failed here
error[E0080]: attempt to shift right by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:71:26
|
LL | const _NU8_SHR_P: &u8 = &(1u8 >> 8);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU8_SHR_P` failed here
error[E0080]: attempt to shift right by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:73:24
|
LL | const _NU16_SHR: u16 = 1u16 >> 16;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU16_SHR` failed here
error[E0080]: attempt to shift right by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:74:28
|
LL | const _NU16_SHR_P: &u16 = &(1u16 >> 16);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU16_SHR_P` failed here
error[E0080]: attempt to shift right by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:76:24
|
LL | const _NU32_SHR: u32 = 1u32 >> 32;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU32_SHR` failed here
error[E0080]: attempt to shift right by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:77:28
|
LL | const _NU32_SHR_P: &u32 = &(1u32 >> 32);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU32_SHR_P` failed here
error[E0080]: attempt to shift right by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:79:24
|
LL | const _NU64_SHR: u64 = 1u64 >> 64;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU64_SHR` failed here
error[E0080]: attempt to shift right by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:80:28
|
LL | const _NU64_SHR_P: &u64 = &(1u64 >> 64);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU64_SHR_P` failed here
error[E0080]: attempt to shift right by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:82:26
|
LL | const _NU128_SHR: u128 = 1u128 >> 128;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU128_SHR` failed here
error[E0080]: attempt to shift right by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:83:30
|
LL | const _NU128_SHR_P: &u128 = &(1u128 >> 128);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NU128_SHR_P` failed here
error[E0080]: attempt to shift right by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:85:28
|
LL | const _NISIZE_SHR: isize = 1isize >> BITS;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHR` failed here
error[E0080]: attempt to shift right by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:86:32
|
LL | const _NISIZE_SHR_P: &isize = &(1isize >> BITS);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHR_P` failed here
error[E0080]: attempt to shift right by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:88:28
|
LL | const _NUSIZE_SHR: usize = 1usize >> BITS;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHR` failed here
error[E0080]: attempt to shift right by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:89:32
|
LL | const _NUSIZE_SHR_P: &usize = &(1usize >> BITS);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHR_P` failed here
error[E0080]: attempt to compute `1_i8 + i8::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:92:22
|
LL | const _NI8_ADD: i8 = 1i8 + i8::MAX;
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `_NI8_ADD` failed here
error[E0080]: attempt to compute `1_i8 + i8::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:93:26
|
LL | const _NI8_ADD_P: &i8 = &(1i8 + i8::MAX);
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NI8_ADD_P` failed here
error[E0080]: attempt to compute `1_i16 + i16::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:95:24
|
LL | const _NI16_ADD: i16 = 1i16 + i16::MAX;
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NI16_ADD` failed here
error[E0080]: attempt to compute `1_i16 + i16::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:96:28
|
LL | const _NI16_ADD_P: &i16 = &(1i16 + i16::MAX);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NI16_ADD_P` failed here
error[E0080]: attempt to compute `1_i32 + i32::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:98:24
|
LL | const _NI32_ADD: i32 = 1i32 + i32::MAX;
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NI32_ADD` failed here
error[E0080]: attempt to compute `1_i32 + i32::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:99:28
|
LL | const _NI32_ADD_P: &i32 = &(1i32 + i32::MAX);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NI32_ADD_P` failed here
error[E0080]: attempt to compute `1_i64 + i64::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:101:24
|
LL | const _NI64_ADD: i64 = 1i64 + i64::MAX;
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NI64_ADD` failed here
error[E0080]: attempt to compute `1_i64 + i64::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:102:28
|
LL | const _NI64_ADD_P: &i64 = &(1i64 + i64::MAX);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NI64_ADD_P` failed here
error[E0080]: attempt to compute `1_i128 + i128::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:104:26
|
LL | const _NI128_ADD: i128 = 1i128 + i128::MAX;
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NI128_ADD` failed here
error[E0080]: attempt to compute `1_i128 + i128::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:105:30
|
LL | const _NI128_ADD_P: &i128 = &(1i128 + i128::MAX);
- | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NI128_ADD_P` failed here
error[E0080]: attempt to compute `1_u8 + u8::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:107:22
|
LL | const _NU8_ADD: u8 = 1u8 + u8::MAX;
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `_NU8_ADD` failed here
error[E0080]: attempt to compute `1_u8 + u8::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:108:26
|
LL | const _NU8_ADD_P: &u8 = &(1u8 + u8::MAX);
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NU8_ADD_P` failed here
error[E0080]: attempt to compute `1_u16 + u16::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:110:24
|
LL | const _NU16_ADD: u16 = 1u16 + u16::MAX;
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NU16_ADD` failed here
error[E0080]: attempt to compute `1_u16 + u16::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:111:28
|
LL | const _NU16_ADD_P: &u16 = &(1u16 + u16::MAX);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NU16_ADD_P` failed here
error[E0080]: attempt to compute `1_u32 + u32::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:113:24
|
LL | const _NU32_ADD: u32 = 1u32 + u32::MAX;
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NU32_ADD` failed here
error[E0080]: attempt to compute `1_u32 + u32::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:114:28
|
LL | const _NU32_ADD_P: &u32 = &(1u32 + u32::MAX);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NU32_ADD_P` failed here
error[E0080]: attempt to compute `1_u64 + u64::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:116:24
|
LL | const _NU64_ADD: u64 = 1u64 + u64::MAX;
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NU64_ADD` failed here
error[E0080]: attempt to compute `1_u64 + u64::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:117:28
|
LL | const _NU64_ADD_P: &u64 = &(1u64 + u64::MAX);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NU64_ADD_P` failed here
error[E0080]: attempt to compute `1_u128 + u128::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:119:26
|
LL | const _NU128_ADD: u128 = 1u128 + u128::MAX;
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NU128_ADD` failed here
error[E0080]: attempt to compute `1_u128 + u128::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:120:30
|
LL | const _NU128_ADD_P: &u128 = &(1u128 + u128::MAX);
- | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NU128_ADD_P` failed here
error[E0080]: attempt to compute `1_isize + isize::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:122:28
|
LL | const _NISIZE_ADD: isize = 1isize + isize::MAX;
- | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_ADD` failed here
error[E0080]: attempt to compute `1_isize + isize::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:123:32
|
LL | const _NISIZE_ADD_P: &isize = &(1isize + isize::MAX);
- | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_ADD_P` failed here
error[E0080]: attempt to compute `1_usize + usize::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:125:28
|
LL | const _NUSIZE_ADD: usize = 1usize + usize::MAX;
- | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_ADD` failed here
error[E0080]: attempt to compute `1_usize + usize::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:126:32
|
LL | const _NUSIZE_ADD_P: &usize = &(1usize + usize::MAX);
- | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_ADD_P` failed here
error[E0080]: attempt to compute `-5_i8 - i8::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:129:22
|
LL | const _NI8_SUB: i8 = -5i8 - i8::MAX;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI8_SUB` failed here
error[E0080]: attempt to compute `-5_i8 - i8::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:130:26
|
LL | const _NI8_SUB_P: &i8 = &(-5i8 - i8::MAX);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NI8_SUB_P` failed here
error[E0080]: attempt to compute `-5_i16 - i16::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:132:24
|
LL | const _NI16_SUB: i16 = -5i16 - i16::MAX;
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NI16_SUB` failed here
error[E0080]: attempt to compute `-5_i16 - i16::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:133:28
|
LL | const _NI16_SUB_P: &i16 = &(-5i16 - i16::MAX);
- | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI16_SUB_P` failed here
error[E0080]: attempt to compute `-5_i32 - i32::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:135:24
|
LL | const _NI32_SUB: i32 = -5i32 - i32::MAX;
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NI32_SUB` failed here
error[E0080]: attempt to compute `-5_i32 - i32::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:136:28
|
LL | const _NI32_SUB_P: &i32 = &(-5i32 - i32::MAX);
- | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI32_SUB_P` failed here
error[E0080]: attempt to compute `-5_i64 - i64::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:138:24
|
LL | const _NI64_SUB: i64 = -5i64 - i64::MAX;
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NI64_SUB` failed here
error[E0080]: attempt to compute `-5_i64 - i64::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:139:28
|
LL | const _NI64_SUB_P: &i64 = &(-5i64 - i64::MAX);
- | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI64_SUB_P` failed here
error[E0080]: attempt to compute `-5_i128 - i128::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:141:26
|
LL | const _NI128_SUB: i128 = -5i128 - i128::MAX;
- | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI128_SUB` failed here
error[E0080]: attempt to compute `-5_i128 - i128::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:142:30
|
LL | const _NI128_SUB_P: &i128 = &(-5i128 - i128::MAX);
- | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^ evaluation of `_NI128_SUB_P` failed here
error[E0080]: attempt to compute `1_u8 - 5_u8`, which would overflow
--> $DIR/overflowing-consts.rs:144:22
|
LL | const _NU8_SUB: u8 = 1u8 - 5;
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `_NU8_SUB` failed here
error[E0080]: attempt to compute `1_u8 - 5_u8`, which would overflow
--> $DIR/overflowing-consts.rs:145:26
|
LL | const _NU8_SUB_P: &u8 = &(1u8 - 5);
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NU8_SUB_P` failed here
error[E0080]: attempt to compute `1_u16 - 5_u16`, which would overflow
--> $DIR/overflowing-consts.rs:147:24
|
LL | const _NU16_SUB: u16 = 1u16 - 5;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU16_SUB` failed here
error[E0080]: attempt to compute `1_u16 - 5_u16`, which would overflow
--> $DIR/overflowing-consts.rs:148:28
|
LL | const _NU16_SUB_P: &u16 = &(1u16 - 5);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU16_SUB_P` failed here
error[E0080]: attempt to compute `1_u32 - 5_u32`, which would overflow
--> $DIR/overflowing-consts.rs:150:24
|
LL | const _NU32_SUB: u32 = 1u32 - 5;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU32_SUB` failed here
error[E0080]: attempt to compute `1_u32 - 5_u32`, which would overflow
--> $DIR/overflowing-consts.rs:151:28
|
LL | const _NU32_SUB_P: &u32 = &(1u32 - 5);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU32_SUB_P` failed here
error[E0080]: attempt to compute `1_u64 - 5_u64`, which would overflow
--> $DIR/overflowing-consts.rs:153:24
|
LL | const _NU64_SUB: u64 = 1u64 - 5;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU64_SUB` failed here
error[E0080]: attempt to compute `1_u64 - 5_u64`, which would overflow
--> $DIR/overflowing-consts.rs:154:28
|
LL | const _NU64_SUB_P: &u64 = &(1u64 - 5);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU64_SUB_P` failed here
error[E0080]: attempt to compute `1_u128 - 5_u128`, which would overflow
--> $DIR/overflowing-consts.rs:156:26
|
LL | const _NU128_SUB: u128 = 1u128 - 5;
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NU128_SUB` failed here
error[E0080]: attempt to compute `1_u128 - 5_u128`, which would overflow
--> $DIR/overflowing-consts.rs:157:30
|
LL | const _NU128_SUB_P: &u128 = &(1u128 - 5);
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NU128_SUB_P` failed here
error[E0080]: attempt to compute `-5_isize - isize::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:159:28
|
LL | const _NISIZE_SUB: isize = -5isize - isize::MAX;
- | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SUB` failed here
error[E0080]: attempt to compute `-5_isize - isize::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:160:32
|
LL | const _NISIZE_SUB_P: &isize = &(-5isize - isize::MAX);
- | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SUB_P` failed here
error[E0080]: attempt to compute `1_usize - 5_usize`, which would overflow
--> $DIR/overflowing-consts.rs:162:28
|
LL | const _NUSIZE_SUB: usize = 1usize - 5;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NUSIZE_SUB` failed here
error[E0080]: attempt to compute `1_usize - 5_usize`, which would overflow
--> $DIR/overflowing-consts.rs:163:32
|
LL | const _NUSIZE_SUB_P: &usize = &(1usize - 5);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NUSIZE_SUB_P` failed here
error[E0080]: attempt to compute `i8::MAX * 5_i8`, which would overflow
--> $DIR/overflowing-consts.rs:166:22
|
LL | const _NI8_MUL: i8 = i8::MAX * 5;
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NI8_MUL` failed here
error[E0080]: attempt to compute `i8::MAX * 5_i8`, which would overflow
--> $DIR/overflowing-consts.rs:167:26
|
LL | const _NI8_MUL_P: &i8 = &(i8::MAX * 5);
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `_NI8_MUL_P` failed here
error[E0080]: attempt to compute `i16::MAX * 5_i16`, which would overflow
--> $DIR/overflowing-consts.rs:169:24
|
LL | const _NI16_MUL: i16 = i16::MAX * 5;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI16_MUL` failed here
error[E0080]: attempt to compute `i16::MAX * 5_i16`, which would overflow
--> $DIR/overflowing-consts.rs:170:28
|
LL | const _NI16_MUL_P: &i16 = &(i16::MAX * 5);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI16_MUL_P` failed here
error[E0080]: attempt to compute `i32::MAX * 5_i32`, which would overflow
--> $DIR/overflowing-consts.rs:172:24
|
LL | const _NI32_MUL: i32 = i32::MAX * 5;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI32_MUL` failed here
error[E0080]: attempt to compute `i32::MAX * 5_i32`, which would overflow
--> $DIR/overflowing-consts.rs:173:28
|
LL | const _NI32_MUL_P: &i32 = &(i32::MAX * 5);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI32_MUL_P` failed here
error[E0080]: attempt to compute `i64::MAX * 5_i64`, which would overflow
--> $DIR/overflowing-consts.rs:175:24
|
LL | const _NI64_MUL: i64 = i64::MAX * 5;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI64_MUL` failed here
error[E0080]: attempt to compute `i64::MAX * 5_i64`, which would overflow
--> $DIR/overflowing-consts.rs:176:28
|
LL | const _NI64_MUL_P: &i64 = &(i64::MAX * 5);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI64_MUL_P` failed here
error[E0080]: attempt to compute `i128::MAX * 5_i128`, which would overflow
--> $DIR/overflowing-consts.rs:178:26
|
LL | const _NI128_MUL: i128 = i128::MAX * 5;
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `_NI128_MUL` failed here
error[E0080]: attempt to compute `i128::MAX * 5_i128`, which would overflow
--> $DIR/overflowing-consts.rs:179:30
|
LL | const _NI128_MUL_P: &i128 = &(i128::MAX * 5);
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NI128_MUL_P` failed here
error[E0080]: attempt to compute `u8::MAX * 5_u8`, which would overflow
--> $DIR/overflowing-consts.rs:181:22
|
LL | const _NU8_MUL: u8 = u8::MAX * 5;
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NU8_MUL` failed here
error[E0080]: attempt to compute `u8::MAX * 5_u8`, which would overflow
--> $DIR/overflowing-consts.rs:182:26
|
LL | const _NU8_MUL_P: &u8 = &(u8::MAX * 5);
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `_NU8_MUL_P` failed here
error[E0080]: attempt to compute `u16::MAX * 5_u16`, which would overflow
--> $DIR/overflowing-consts.rs:184:24
|
LL | const _NU16_MUL: u16 = u16::MAX * 5;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU16_MUL` failed here
error[E0080]: attempt to compute `u16::MAX * 5_u16`, which would overflow
--> $DIR/overflowing-consts.rs:185:28
|
LL | const _NU16_MUL_P: &u16 = &(u16::MAX * 5);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NU16_MUL_P` failed here
error[E0080]: attempt to compute `u32::MAX * 5_u32`, which would overflow
--> $DIR/overflowing-consts.rs:187:24
|
LL | const _NU32_MUL: u32 = u32::MAX * 5;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU32_MUL` failed here
error[E0080]: attempt to compute `u32::MAX * 5_u32`, which would overflow
--> $DIR/overflowing-consts.rs:188:28
|
LL | const _NU32_MUL_P: &u32 = &(u32::MAX * 5);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NU32_MUL_P` failed here
error[E0080]: attempt to compute `u64::MAX * 5_u64`, which would overflow
--> $DIR/overflowing-consts.rs:190:24
|
LL | const _NU64_MUL: u64 = u64::MAX * 5;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU64_MUL` failed here
error[E0080]: attempt to compute `u64::MAX * 5_u64`, which would overflow
--> $DIR/overflowing-consts.rs:191:28
|
LL | const _NU64_MUL_P: &u64 = &(u64::MAX * 5);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NU64_MUL_P` failed here
error[E0080]: attempt to compute `u128::MAX * 5_u128`, which would overflow
--> $DIR/overflowing-consts.rs:193:26
|
LL | const _NU128_MUL: u128 = u128::MAX * 5;
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `_NU128_MUL` failed here
error[E0080]: attempt to compute `u128::MAX * 5_u128`, which would overflow
--> $DIR/overflowing-consts.rs:194:30
|
LL | const _NU128_MUL_P: &u128 = &(u128::MAX * 5);
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NU128_MUL_P` failed here
error[E0080]: attempt to compute `isize::MAX * 5_isize`, which would overflow
--> $DIR/overflowing-consts.rs:196:28
|
LL | const _NISIZE_MUL: isize = isize::MAX * 5;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NISIZE_MUL` failed here
error[E0080]: attempt to compute `isize::MAX * 5_isize`, which would overflow
--> $DIR/overflowing-consts.rs:197:32
|
LL | const _NISIZE_MUL_P: &isize = &(isize::MAX * 5);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_MUL_P` failed here
error[E0080]: attempt to compute `usize::MAX * 5_usize`, which would overflow
--> $DIR/overflowing-consts.rs:199:28
|
LL | const _NUSIZE_MUL: usize = usize::MAX * 5;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NUSIZE_MUL` failed here
error[E0080]: attempt to compute `usize::MAX * 5_usize`, which would overflow
--> $DIR/overflowing-consts.rs:200:32
|
LL | const _NUSIZE_MUL_P: &usize = &(usize::MAX * 5);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_MUL_P` failed here
error[E0080]: attempt to divide `1_i8` by zero
--> $DIR/overflowing-consts.rs:203:22
|
LL | const _NI8_DIV: i8 = 1i8 / 0;
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `_NI8_DIV` failed here
error[E0080]: attempt to divide `1_i8` by zero
--> $DIR/overflowing-consts.rs:204:26
|
LL | const _NI8_DIV_P: &i8 = &(1i8 / 0);
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NI8_DIV_P` failed here
error[E0080]: attempt to divide `1_i16` by zero
--> $DIR/overflowing-consts.rs:206:24
|
LL | const _NI16_DIV: i16 = 1i16 / 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI16_DIV` failed here
error[E0080]: attempt to divide `1_i16` by zero
--> $DIR/overflowing-consts.rs:207:28
|
LL | const _NI16_DIV_P: &i16 = &(1i16 / 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI16_DIV_P` failed here
error[E0080]: attempt to divide `1_i32` by zero
--> $DIR/overflowing-consts.rs:209:24
|
LL | const _NI32_DIV: i32 = 1i32 / 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI32_DIV` failed here
error[E0080]: attempt to divide `1_i32` by zero
--> $DIR/overflowing-consts.rs:210:28
|
LL | const _NI32_DIV_P: &i32 = &(1i32 / 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI32_DIV_P` failed here
error[E0080]: attempt to divide `1_i64` by zero
--> $DIR/overflowing-consts.rs:212:24
|
LL | const _NI64_DIV: i64 = 1i64 / 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI64_DIV` failed here
error[E0080]: attempt to divide `1_i64` by zero
--> $DIR/overflowing-consts.rs:213:28
|
LL | const _NI64_DIV_P: &i64 = &(1i64 / 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI64_DIV_P` failed here
error[E0080]: attempt to divide `1_i128` by zero
--> $DIR/overflowing-consts.rs:215:26
|
LL | const _NI128_DIV: i128 = 1i128 / 0;
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NI128_DIV` failed here
error[E0080]: attempt to divide `1_i128` by zero
--> $DIR/overflowing-consts.rs:216:30
|
LL | const _NI128_DIV_P: &i128 = &(1i128 / 0);
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NI128_DIV_P` failed here
error[E0080]: attempt to divide `1_u8` by zero
--> $DIR/overflowing-consts.rs:218:22
|
LL | const _NU8_DIV: u8 = 1u8 / 0;
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `_NU8_DIV` failed here
error[E0080]: attempt to divide `1_u8` by zero
--> $DIR/overflowing-consts.rs:219:26
|
LL | const _NU8_DIV_P: &u8 = &(1u8 / 0);
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NU8_DIV_P` failed here
error[E0080]: attempt to divide `1_u16` by zero
--> $DIR/overflowing-consts.rs:221:24
|
LL | const _NU16_DIV: u16 = 1u16 / 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU16_DIV` failed here
error[E0080]: attempt to divide `1_u16` by zero
--> $DIR/overflowing-consts.rs:222:28
|
LL | const _NU16_DIV_P: &u16 = &(1u16 / 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU16_DIV_P` failed here
error[E0080]: attempt to divide `1_u32` by zero
--> $DIR/overflowing-consts.rs:224:24
|
LL | const _NU32_DIV: u32 = 1u32 / 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU32_DIV` failed here
error[E0080]: attempt to divide `1_u32` by zero
--> $DIR/overflowing-consts.rs:225:28
|
LL | const _NU32_DIV_P: &u32 = &(1u32 / 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU32_DIV_P` failed here
error[E0080]: attempt to divide `1_u64` by zero
--> $DIR/overflowing-consts.rs:227:24
|
LL | const _NU64_DIV: u64 = 1u64 / 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU64_DIV` failed here
error[E0080]: attempt to divide `1_u64` by zero
--> $DIR/overflowing-consts.rs:228:28
|
LL | const _NU64_DIV_P: &u64 = &(1u64 / 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU64_DIV_P` failed here
error[E0080]: attempt to divide `1_u128` by zero
--> $DIR/overflowing-consts.rs:230:26
|
LL | const _NU128_DIV: u128 = 1u128 / 0;
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NU128_DIV` failed here
error[E0080]: attempt to divide `1_u128` by zero
--> $DIR/overflowing-consts.rs:231:30
|
LL | const _NU128_DIV_P: &u128 = &(1u128 / 0);
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NU128_DIV_P` failed here
error[E0080]: attempt to divide `1_isize` by zero
--> $DIR/overflowing-consts.rs:233:28
|
LL | const _NISIZE_DIV: isize = 1isize / 0;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NISIZE_DIV` failed here
error[E0080]: attempt to divide `1_isize` by zero
--> $DIR/overflowing-consts.rs:234:32
|
LL | const _NISIZE_DIV_P: &isize = &(1isize / 0);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NISIZE_DIV_P` failed here
error[E0080]: attempt to divide `1_usize` by zero
--> $DIR/overflowing-consts.rs:236:28
|
LL | const _NUSIZE_DIV: usize = 1usize / 0;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NUSIZE_DIV` failed here
error[E0080]: attempt to divide `1_usize` by zero
--> $DIR/overflowing-consts.rs:237:32
|
LL | const _NUSIZE_DIV_P: &usize = &(1usize / 0);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NUSIZE_DIV_P` failed here
error[E0080]: attempt to calculate the remainder of `1_i8` with a divisor of zero
--> $DIR/overflowing-consts.rs:240:22
|
LL | const _NI8_MOD: i8 = 1i8 % 0;
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `_NI8_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_i8` with a divisor of zero
--> $DIR/overflowing-consts.rs:241:26
|
LL | const _NI8_MOD_P: &i8 = &(1i8 % 0);
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NI8_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_i16` with a divisor of zero
--> $DIR/overflowing-consts.rs:243:24
|
LL | const _NI16_MOD: i16 = 1i16 % 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI16_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_i16` with a divisor of zero
--> $DIR/overflowing-consts.rs:244:28
|
LL | const _NI16_MOD_P: &i16 = &(1i16 % 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI16_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_i32` with a divisor of zero
--> $DIR/overflowing-consts.rs:246:24
|
LL | const _NI32_MOD: i32 = 1i32 % 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI32_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_i32` with a divisor of zero
--> $DIR/overflowing-consts.rs:247:28
|
LL | const _NI32_MOD_P: &i32 = &(1i32 % 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI32_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_i64` with a divisor of zero
--> $DIR/overflowing-consts.rs:249:24
|
LL | const _NI64_MOD: i64 = 1i64 % 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI64_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_i64` with a divisor of zero
--> $DIR/overflowing-consts.rs:250:28
|
LL | const _NI64_MOD_P: &i64 = &(1i64 % 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI64_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_i128` with a divisor of zero
--> $DIR/overflowing-consts.rs:252:26
|
LL | const _NI128_MOD: i128 = 1i128 % 0;
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NI128_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_i128` with a divisor of zero
--> $DIR/overflowing-consts.rs:253:30
|
LL | const _NI128_MOD_P: &i128 = &(1i128 % 0);
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NI128_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_u8` with a divisor of zero
--> $DIR/overflowing-consts.rs:255:22
|
LL | const _NU8_MOD: u8 = 1u8 % 0;
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `_NU8_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_u8` with a divisor of zero
--> $DIR/overflowing-consts.rs:256:26
|
LL | const _NU8_MOD_P: &u8 = &(1u8 % 0);
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NU8_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_u16` with a divisor of zero
--> $DIR/overflowing-consts.rs:258:24
|
LL | const _NU16_MOD: u16 = 1u16 % 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU16_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_u16` with a divisor of zero
--> $DIR/overflowing-consts.rs:259:28
|
LL | const _NU16_MOD_P: &u16 = &(1u16 % 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU16_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_u32` with a divisor of zero
--> $DIR/overflowing-consts.rs:261:24
|
LL | const _NU32_MOD: u32 = 1u32 % 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU32_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_u32` with a divisor of zero
--> $DIR/overflowing-consts.rs:262:28
|
LL | const _NU32_MOD_P: &u32 = &(1u32 % 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU32_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_u64` with a divisor of zero
--> $DIR/overflowing-consts.rs:264:24
|
LL | const _NU64_MOD: u64 = 1u64 % 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU64_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_u64` with a divisor of zero
--> $DIR/overflowing-consts.rs:265:28
|
LL | const _NU64_MOD_P: &u64 = &(1u64 % 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU64_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_u128` with a divisor of zero
--> $DIR/overflowing-consts.rs:267:26
|
LL | const _NU128_MOD: u128 = 1u128 % 0;
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NU128_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_u128` with a divisor of zero
--> $DIR/overflowing-consts.rs:268:30
|
LL | const _NU128_MOD_P: &u128 = &(1u128 % 0);
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NU128_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero
--> $DIR/overflowing-consts.rs:270:28
|
LL | const _NISIZE_MOD: isize = 1isize % 0;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NISIZE_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero
--> $DIR/overflowing-consts.rs:271:32
|
LL | const _NISIZE_MOD_P: &isize = &(1isize % 0);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NISIZE_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_usize` with a divisor of zero
--> $DIR/overflowing-consts.rs:273:28
|
LL | const _NUSIZE_MOD: usize = 1usize % 0;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NUSIZE_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_usize` with a divisor of zero
--> $DIR/overflowing-consts.rs:274:32
|
LL | const _NUSIZE_MOD_P: &usize = &(1usize % 0);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NUSIZE_MOD_P` failed here
error[E0080]: index out of bounds: the length is 3 but the index is 4
--> $DIR/overflowing-consts.rs:277:24
|
LL | const _NI32_OOB: i32 = [1, 2, 3][4];
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI32_OOB` failed here
error[E0080]: index out of bounds: the length is 3 but the index is 4
--> $DIR/overflowing-consts.rs:278:28
|
LL | const _NI32_OOB_P: &i32 = &([1, 2, 3][4]);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI32_OOB_P` failed here
error: aborting due to 170 previous errors
diff --git a/tests/ui/consts/overflowing-consts.opt_with_overflow_checks.stderr b/tests/ui/consts/overflowing-consts.opt_with_overflow_checks.stderr
index e317060..1ef2a60 100644
--- a/tests/ui/consts/overflowing-consts.opt_with_overflow_checks.stderr
+++ b/tests/ui/consts/overflowing-consts.opt_with_overflow_checks.stderr
@@ -2,1021 +2,1021 @@
--> $DIR/overflowing-consts.rs:18:22
|
LL | const _NI8_SHL: i8 = 1i8 << 8;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI8_SHL` failed here
error[E0080]: attempt to shift left by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:19:26
|
LL | const _NI8_SHL_P: &i8 = &(1i8 << 8);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI8_SHL_P` failed here
error[E0080]: attempt to shift left by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:21:24
|
LL | const _NI16_SHL: i16 = 1i16 << 16;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI16_SHL` failed here
error[E0080]: attempt to shift left by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:22:28
|
LL | const _NI16_SHL_P: &i16 = &(1i16 << 16);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI16_SHL_P` failed here
error[E0080]: attempt to shift left by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:24:24
|
LL | const _NI32_SHL: i32 = 1i32 << 32;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI32_SHL` failed here
error[E0080]: attempt to shift left by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:25:28
|
LL | const _NI32_SHL_P: &i32 = &(1i32 << 32);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI32_SHL_P` failed here
error[E0080]: attempt to shift left by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:27:24
|
LL | const _NI64_SHL: i64 = 1i64 << 64;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI64_SHL` failed here
error[E0080]: attempt to shift left by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:28:28
|
LL | const _NI64_SHL_P: &i64 = &(1i64 << 64);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI64_SHL_P` failed here
error[E0080]: attempt to shift left by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:30:26
|
LL | const _NI128_SHL: i128 = 1i128 << 128;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI128_SHL` failed here
error[E0080]: attempt to shift left by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:31:30
|
LL | const _NI128_SHL_P: &i128 = &(1i128 << 128);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI128_SHL_P` failed here
error[E0080]: attempt to shift left by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:33:22
|
LL | const _NU8_SHL: u8 = 1u8 << 8;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU8_SHL` failed here
error[E0080]: attempt to shift left by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:34:26
|
LL | const _NU8_SHL_P: &u8 = &(1u8 << 8);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU8_SHL_P` failed here
error[E0080]: attempt to shift left by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:36:24
|
LL | const _NU16_SHL: u16 = 1u16 << 16;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU16_SHL` failed here
error[E0080]: attempt to shift left by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:37:28
|
LL | const _NU16_SHL_P: &u16 = &(1u16 << 16);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU16_SHL_P` failed here
error[E0080]: attempt to shift left by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:39:24
|
LL | const _NU32_SHL: u32 = 1u32 << 32;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU32_SHL` failed here
error[E0080]: attempt to shift left by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:40:28
|
LL | const _NU32_SHL_P: &u32 = &(1u32 << 32);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU32_SHL_P` failed here
error[E0080]: attempt to shift left by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:42:24
|
LL | const _NU64_SHL: u64 = 1u64 << 64;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU64_SHL` failed here
error[E0080]: attempt to shift left by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:43:28
|
LL | const _NU64_SHL_P: &u64 = &(1u64 << 64);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU64_SHL_P` failed here
error[E0080]: attempt to shift left by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:45:26
|
LL | const _NU128_SHL: u128 = 1u128 << 128;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU128_SHL` failed here
error[E0080]: attempt to shift left by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:46:30
|
LL | const _NU128_SHL_P: &u128 = &(1u128 << 128);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NU128_SHL_P` failed here
error[E0080]: attempt to shift left by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:48:28
|
LL | const _NISIZE_SHL: isize = 1isize << BITS;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHL` failed here
error[E0080]: attempt to shift left by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:49:32
|
LL | const _NISIZE_SHL_P: &isize = &(1isize << BITS);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHL_P` failed here
error[E0080]: attempt to shift left by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:51:28
|
LL | const _NUSIZE_SHL: usize = 1usize << BITS;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHL` failed here
error[E0080]: attempt to shift left by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:52:32
|
LL | const _NUSIZE_SHL_P: &usize = &(1usize << BITS);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHL_P` failed here
error[E0080]: attempt to shift right by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:55:22
|
LL | const _NI8_SHR: i8 = 1i8 >> 8;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI8_SHR` failed here
error[E0080]: attempt to shift right by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:56:26
|
LL | const _NI8_SHR_P: &i8 = &(1i8 >> 8);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI8_SHR_P` failed here
error[E0080]: attempt to shift right by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:58:24
|
LL | const _NI16_SHR: i16 = 1i16 >> 16;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI16_SHR` failed here
error[E0080]: attempt to shift right by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:59:28
|
LL | const _NI16_SHR_P: &i16 = &(1i16 >> 16);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI16_SHR_P` failed here
error[E0080]: attempt to shift right by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:61:24
|
LL | const _NI32_SHR: i32 = 1i32 >> 32;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI32_SHR` failed here
error[E0080]: attempt to shift right by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:62:28
|
LL | const _NI32_SHR_P: &i32 = &(1i32 >> 32);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI32_SHR_P` failed here
error[E0080]: attempt to shift right by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:64:24
|
LL | const _NI64_SHR: i64 = 1i64 >> 64;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI64_SHR` failed here
error[E0080]: attempt to shift right by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:65:28
|
LL | const _NI64_SHR_P: &i64 = &(1i64 >> 64);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI64_SHR_P` failed here
error[E0080]: attempt to shift right by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:67:26
|
LL | const _NI128_SHR: i128 = 1i128 >> 128;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI128_SHR` failed here
error[E0080]: attempt to shift right by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:68:30
|
LL | const _NI128_SHR_P: &i128 = &(1i128 >> 128);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI128_SHR_P` failed here
error[E0080]: attempt to shift right by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:70:22
|
LL | const _NU8_SHR: u8 = 1u8 >> 8;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU8_SHR` failed here
error[E0080]: attempt to shift right by `8_i32`, which would overflow
--> $DIR/overflowing-consts.rs:71:26
|
LL | const _NU8_SHR_P: &u8 = &(1u8 >> 8);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU8_SHR_P` failed here
error[E0080]: attempt to shift right by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:73:24
|
LL | const _NU16_SHR: u16 = 1u16 >> 16;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU16_SHR` failed here
error[E0080]: attempt to shift right by `16_i32`, which would overflow
--> $DIR/overflowing-consts.rs:74:28
|
LL | const _NU16_SHR_P: &u16 = &(1u16 >> 16);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU16_SHR_P` failed here
error[E0080]: attempt to shift right by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:76:24
|
LL | const _NU32_SHR: u32 = 1u32 >> 32;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU32_SHR` failed here
error[E0080]: attempt to shift right by `32_i32`, which would overflow
--> $DIR/overflowing-consts.rs:77:28
|
LL | const _NU32_SHR_P: &u32 = &(1u32 >> 32);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU32_SHR_P` failed here
error[E0080]: attempt to shift right by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:79:24
|
LL | const _NU64_SHR: u64 = 1u64 >> 64;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU64_SHR` failed here
error[E0080]: attempt to shift right by `64_i32`, which would overflow
--> $DIR/overflowing-consts.rs:80:28
|
LL | const _NU64_SHR_P: &u64 = &(1u64 >> 64);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU64_SHR_P` failed here
error[E0080]: attempt to shift right by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:82:26
|
LL | const _NU128_SHR: u128 = 1u128 >> 128;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU128_SHR` failed here
error[E0080]: attempt to shift right by `128_i32`, which would overflow
--> $DIR/overflowing-consts.rs:83:30
|
LL | const _NU128_SHR_P: &u128 = &(1u128 >> 128);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NU128_SHR_P` failed here
error[E0080]: attempt to shift right by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:85:28
|
LL | const _NISIZE_SHR: isize = 1isize >> BITS;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHR` failed here
error[E0080]: attempt to shift right by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:86:32
|
LL | const _NISIZE_SHR_P: &isize = &(1isize >> BITS);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SHR_P` failed here
error[E0080]: attempt to shift right by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:88:28
|
LL | const _NUSIZE_SHR: usize = 1usize >> BITS;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHR` failed here
error[E0080]: attempt to shift right by `%BITS%`, which would overflow
--> $DIR/overflowing-consts.rs:89:32
|
LL | const _NUSIZE_SHR_P: &usize = &(1usize >> BITS);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_SHR_P` failed here
error[E0080]: attempt to compute `1_i8 + i8::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:92:22
|
LL | const _NI8_ADD: i8 = 1i8 + i8::MAX;
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `_NI8_ADD` failed here
error[E0080]: attempt to compute `1_i8 + i8::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:93:26
|
LL | const _NI8_ADD_P: &i8 = &(1i8 + i8::MAX);
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NI8_ADD_P` failed here
error[E0080]: attempt to compute `1_i16 + i16::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:95:24
|
LL | const _NI16_ADD: i16 = 1i16 + i16::MAX;
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NI16_ADD` failed here
error[E0080]: attempt to compute `1_i16 + i16::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:96:28
|
LL | const _NI16_ADD_P: &i16 = &(1i16 + i16::MAX);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NI16_ADD_P` failed here
error[E0080]: attempt to compute `1_i32 + i32::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:98:24
|
LL | const _NI32_ADD: i32 = 1i32 + i32::MAX;
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NI32_ADD` failed here
error[E0080]: attempt to compute `1_i32 + i32::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:99:28
|
LL | const _NI32_ADD_P: &i32 = &(1i32 + i32::MAX);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NI32_ADD_P` failed here
error[E0080]: attempt to compute `1_i64 + i64::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:101:24
|
LL | const _NI64_ADD: i64 = 1i64 + i64::MAX;
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NI64_ADD` failed here
error[E0080]: attempt to compute `1_i64 + i64::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:102:28
|
LL | const _NI64_ADD_P: &i64 = &(1i64 + i64::MAX);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NI64_ADD_P` failed here
error[E0080]: attempt to compute `1_i128 + i128::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:104:26
|
LL | const _NI128_ADD: i128 = 1i128 + i128::MAX;
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NI128_ADD` failed here
error[E0080]: attempt to compute `1_i128 + i128::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:105:30
|
LL | const _NI128_ADD_P: &i128 = &(1i128 + i128::MAX);
- | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NI128_ADD_P` failed here
error[E0080]: attempt to compute `1_u8 + u8::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:107:22
|
LL | const _NU8_ADD: u8 = 1u8 + u8::MAX;
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `_NU8_ADD` failed here
error[E0080]: attempt to compute `1_u8 + u8::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:108:26
|
LL | const _NU8_ADD_P: &u8 = &(1u8 + u8::MAX);
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NU8_ADD_P` failed here
error[E0080]: attempt to compute `1_u16 + u16::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:110:24
|
LL | const _NU16_ADD: u16 = 1u16 + u16::MAX;
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NU16_ADD` failed here
error[E0080]: attempt to compute `1_u16 + u16::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:111:28
|
LL | const _NU16_ADD_P: &u16 = &(1u16 + u16::MAX);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NU16_ADD_P` failed here
error[E0080]: attempt to compute `1_u32 + u32::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:113:24
|
LL | const _NU32_ADD: u32 = 1u32 + u32::MAX;
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NU32_ADD` failed here
error[E0080]: attempt to compute `1_u32 + u32::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:114:28
|
LL | const _NU32_ADD_P: &u32 = &(1u32 + u32::MAX);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NU32_ADD_P` failed here
error[E0080]: attempt to compute `1_u64 + u64::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:116:24
|
LL | const _NU64_ADD: u64 = 1u64 + u64::MAX;
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NU64_ADD` failed here
error[E0080]: attempt to compute `1_u64 + u64::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:117:28
|
LL | const _NU64_ADD_P: &u64 = &(1u64 + u64::MAX);
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NU64_ADD_P` failed here
error[E0080]: attempt to compute `1_u128 + u128::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:119:26
|
LL | const _NU128_ADD: u128 = 1u128 + u128::MAX;
- | ^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^ evaluation of `_NU128_ADD` failed here
error[E0080]: attempt to compute `1_u128 + u128::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:120:30
|
LL | const _NU128_ADD_P: &u128 = &(1u128 + u128::MAX);
- | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NU128_ADD_P` failed here
error[E0080]: attempt to compute `1_isize + isize::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:122:28
|
LL | const _NISIZE_ADD: isize = 1isize + isize::MAX;
- | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_ADD` failed here
error[E0080]: attempt to compute `1_isize + isize::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:123:32
|
LL | const _NISIZE_ADD_P: &isize = &(1isize + isize::MAX);
- | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_ADD_P` failed here
error[E0080]: attempt to compute `1_usize + usize::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:125:28
|
LL | const _NUSIZE_ADD: usize = 1usize + usize::MAX;
- | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_ADD` failed here
error[E0080]: attempt to compute `1_usize + usize::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:126:32
|
LL | const _NUSIZE_ADD_P: &usize = &(1usize + usize::MAX);
- | ^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_ADD_P` failed here
error[E0080]: attempt to compute `-5_i8 - i8::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:129:22
|
LL | const _NI8_SUB: i8 = -5i8 - i8::MAX;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI8_SUB` failed here
error[E0080]: attempt to compute `-5_i8 - i8::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:130:26
|
LL | const _NI8_SUB_P: &i8 = &(-5i8 - i8::MAX);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NI8_SUB_P` failed here
error[E0080]: attempt to compute `-5_i16 - i16::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:132:24
|
LL | const _NI16_SUB: i16 = -5i16 - i16::MAX;
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NI16_SUB` failed here
error[E0080]: attempt to compute `-5_i16 - i16::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:133:28
|
LL | const _NI16_SUB_P: &i16 = &(-5i16 - i16::MAX);
- | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI16_SUB_P` failed here
error[E0080]: attempt to compute `-5_i32 - i32::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:135:24
|
LL | const _NI32_SUB: i32 = -5i32 - i32::MAX;
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NI32_SUB` failed here
error[E0080]: attempt to compute `-5_i32 - i32::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:136:28
|
LL | const _NI32_SUB_P: &i32 = &(-5i32 - i32::MAX);
- | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI32_SUB_P` failed here
error[E0080]: attempt to compute `-5_i64 - i64::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:138:24
|
LL | const _NI64_SUB: i64 = -5i64 - i64::MAX;
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NI64_SUB` failed here
error[E0080]: attempt to compute `-5_i64 - i64::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:139:28
|
LL | const _NI64_SUB_P: &i64 = &(-5i64 - i64::MAX);
- | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI64_SUB_P` failed here
error[E0080]: attempt to compute `-5_i128 - i128::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:141:26
|
LL | const _NI128_SUB: i128 = -5i128 - i128::MAX;
- | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^ evaluation of `_NI128_SUB` failed here
error[E0080]: attempt to compute `-5_i128 - i128::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:142:30
|
LL | const _NI128_SUB_P: &i128 = &(-5i128 - i128::MAX);
- | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^ evaluation of `_NI128_SUB_P` failed here
error[E0080]: attempt to compute `1_u8 - 5_u8`, which would overflow
--> $DIR/overflowing-consts.rs:144:22
|
LL | const _NU8_SUB: u8 = 1u8 - 5;
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `_NU8_SUB` failed here
error[E0080]: attempt to compute `1_u8 - 5_u8`, which would overflow
--> $DIR/overflowing-consts.rs:145:26
|
LL | const _NU8_SUB_P: &u8 = &(1u8 - 5);
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NU8_SUB_P` failed here
error[E0080]: attempt to compute `1_u16 - 5_u16`, which would overflow
--> $DIR/overflowing-consts.rs:147:24
|
LL | const _NU16_SUB: u16 = 1u16 - 5;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU16_SUB` failed here
error[E0080]: attempt to compute `1_u16 - 5_u16`, which would overflow
--> $DIR/overflowing-consts.rs:148:28
|
LL | const _NU16_SUB_P: &u16 = &(1u16 - 5);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU16_SUB_P` failed here
error[E0080]: attempt to compute `1_u32 - 5_u32`, which would overflow
--> $DIR/overflowing-consts.rs:150:24
|
LL | const _NU32_SUB: u32 = 1u32 - 5;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU32_SUB` failed here
error[E0080]: attempt to compute `1_u32 - 5_u32`, which would overflow
--> $DIR/overflowing-consts.rs:151:28
|
LL | const _NU32_SUB_P: &u32 = &(1u32 - 5);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU32_SUB_P` failed here
error[E0080]: attempt to compute `1_u64 - 5_u64`, which would overflow
--> $DIR/overflowing-consts.rs:153:24
|
LL | const _NU64_SUB: u64 = 1u64 - 5;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU64_SUB` failed here
error[E0080]: attempt to compute `1_u64 - 5_u64`, which would overflow
--> $DIR/overflowing-consts.rs:154:28
|
LL | const _NU64_SUB_P: &u64 = &(1u64 - 5);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU64_SUB_P` failed here
error[E0080]: attempt to compute `1_u128 - 5_u128`, which would overflow
--> $DIR/overflowing-consts.rs:156:26
|
LL | const _NU128_SUB: u128 = 1u128 - 5;
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NU128_SUB` failed here
error[E0080]: attempt to compute `1_u128 - 5_u128`, which would overflow
--> $DIR/overflowing-consts.rs:157:30
|
LL | const _NU128_SUB_P: &u128 = &(1u128 - 5);
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NU128_SUB_P` failed here
error[E0080]: attempt to compute `-5_isize - isize::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:159:28
|
LL | const _NISIZE_SUB: isize = -5isize - isize::MAX;
- | ^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SUB` failed here
error[E0080]: attempt to compute `-5_isize - isize::MAX`, which would overflow
--> $DIR/overflowing-consts.rs:160:32
|
LL | const _NISIZE_SUB_P: &isize = &(-5isize - isize::MAX);
- | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_SUB_P` failed here
error[E0080]: attempt to compute `1_usize - 5_usize`, which would overflow
--> $DIR/overflowing-consts.rs:162:28
|
LL | const _NUSIZE_SUB: usize = 1usize - 5;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NUSIZE_SUB` failed here
error[E0080]: attempt to compute `1_usize - 5_usize`, which would overflow
--> $DIR/overflowing-consts.rs:163:32
|
LL | const _NUSIZE_SUB_P: &usize = &(1usize - 5);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NUSIZE_SUB_P` failed here
error[E0080]: attempt to compute `i8::MAX * 5_i8`, which would overflow
--> $DIR/overflowing-consts.rs:166:22
|
LL | const _NI8_MUL: i8 = i8::MAX * 5;
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NI8_MUL` failed here
error[E0080]: attempt to compute `i8::MAX * 5_i8`, which would overflow
--> $DIR/overflowing-consts.rs:167:26
|
LL | const _NI8_MUL_P: &i8 = &(i8::MAX * 5);
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `_NI8_MUL_P` failed here
error[E0080]: attempt to compute `i16::MAX * 5_i16`, which would overflow
--> $DIR/overflowing-consts.rs:169:24
|
LL | const _NI16_MUL: i16 = i16::MAX * 5;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI16_MUL` failed here
error[E0080]: attempt to compute `i16::MAX * 5_i16`, which would overflow
--> $DIR/overflowing-consts.rs:170:28
|
LL | const _NI16_MUL_P: &i16 = &(i16::MAX * 5);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI16_MUL_P` failed here
error[E0080]: attempt to compute `i32::MAX * 5_i32`, which would overflow
--> $DIR/overflowing-consts.rs:172:24
|
LL | const _NI32_MUL: i32 = i32::MAX * 5;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI32_MUL` failed here
error[E0080]: attempt to compute `i32::MAX * 5_i32`, which would overflow
--> $DIR/overflowing-consts.rs:173:28
|
LL | const _NI32_MUL_P: &i32 = &(i32::MAX * 5);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI32_MUL_P` failed here
error[E0080]: attempt to compute `i64::MAX * 5_i64`, which would overflow
--> $DIR/overflowing-consts.rs:175:24
|
LL | const _NI64_MUL: i64 = i64::MAX * 5;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI64_MUL` failed here
error[E0080]: attempt to compute `i64::MAX * 5_i64`, which would overflow
--> $DIR/overflowing-consts.rs:176:28
|
LL | const _NI64_MUL_P: &i64 = &(i64::MAX * 5);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI64_MUL_P` failed here
error[E0080]: attempt to compute `i128::MAX * 5_i128`, which would overflow
--> $DIR/overflowing-consts.rs:178:26
|
LL | const _NI128_MUL: i128 = i128::MAX * 5;
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `_NI128_MUL` failed here
error[E0080]: attempt to compute `i128::MAX * 5_i128`, which would overflow
--> $DIR/overflowing-consts.rs:179:30
|
LL | const _NI128_MUL_P: &i128 = &(i128::MAX * 5);
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NI128_MUL_P` failed here
error[E0080]: attempt to compute `u8::MAX * 5_u8`, which would overflow
--> $DIR/overflowing-consts.rs:181:22
|
LL | const _NU8_MUL: u8 = u8::MAX * 5;
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NU8_MUL` failed here
error[E0080]: attempt to compute `u8::MAX * 5_u8`, which would overflow
--> $DIR/overflowing-consts.rs:182:26
|
LL | const _NU8_MUL_P: &u8 = &(u8::MAX * 5);
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `_NU8_MUL_P` failed here
error[E0080]: attempt to compute `u16::MAX * 5_u16`, which would overflow
--> $DIR/overflowing-consts.rs:184:24
|
LL | const _NU16_MUL: u16 = u16::MAX * 5;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU16_MUL` failed here
error[E0080]: attempt to compute `u16::MAX * 5_u16`, which would overflow
--> $DIR/overflowing-consts.rs:185:28
|
LL | const _NU16_MUL_P: &u16 = &(u16::MAX * 5);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NU16_MUL_P` failed here
error[E0080]: attempt to compute `u32::MAX * 5_u32`, which would overflow
--> $DIR/overflowing-consts.rs:187:24
|
LL | const _NU32_MUL: u32 = u32::MAX * 5;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU32_MUL` failed here
error[E0080]: attempt to compute `u32::MAX * 5_u32`, which would overflow
--> $DIR/overflowing-consts.rs:188:28
|
LL | const _NU32_MUL_P: &u32 = &(u32::MAX * 5);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NU32_MUL_P` failed here
error[E0080]: attempt to compute `u64::MAX * 5_u64`, which would overflow
--> $DIR/overflowing-consts.rs:190:24
|
LL | const _NU64_MUL: u64 = u64::MAX * 5;
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NU64_MUL` failed here
error[E0080]: attempt to compute `u64::MAX * 5_u64`, which would overflow
--> $DIR/overflowing-consts.rs:191:28
|
LL | const _NU64_MUL_P: &u64 = &(u64::MAX * 5);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NU64_MUL_P` failed here
error[E0080]: attempt to compute `u128::MAX * 5_u128`, which would overflow
--> $DIR/overflowing-consts.rs:193:26
|
LL | const _NU128_MUL: u128 = u128::MAX * 5;
- | ^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^ evaluation of `_NU128_MUL` failed here
error[E0080]: attempt to compute `u128::MAX * 5_u128`, which would overflow
--> $DIR/overflowing-consts.rs:194:30
|
LL | const _NU128_MUL_P: &u128 = &(u128::MAX * 5);
- | ^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^ evaluation of `_NU128_MUL_P` failed here
error[E0080]: attempt to compute `isize::MAX * 5_isize`, which would overflow
--> $DIR/overflowing-consts.rs:196:28
|
LL | const _NISIZE_MUL: isize = isize::MAX * 5;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NISIZE_MUL` failed here
error[E0080]: attempt to compute `isize::MAX * 5_isize`, which would overflow
--> $DIR/overflowing-consts.rs:197:32
|
LL | const _NISIZE_MUL_P: &isize = &(isize::MAX * 5);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NISIZE_MUL_P` failed here
error[E0080]: attempt to compute `usize::MAX * 5_usize`, which would overflow
--> $DIR/overflowing-consts.rs:199:28
|
LL | const _NUSIZE_MUL: usize = usize::MAX * 5;
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NUSIZE_MUL` failed here
error[E0080]: attempt to compute `usize::MAX * 5_usize`, which would overflow
--> $DIR/overflowing-consts.rs:200:32
|
LL | const _NUSIZE_MUL_P: &usize = &(usize::MAX * 5);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `_NUSIZE_MUL_P` failed here
error[E0080]: attempt to divide `1_i8` by zero
--> $DIR/overflowing-consts.rs:203:22
|
LL | const _NI8_DIV: i8 = 1i8 / 0;
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `_NI8_DIV` failed here
error[E0080]: attempt to divide `1_i8` by zero
--> $DIR/overflowing-consts.rs:204:26
|
LL | const _NI8_DIV_P: &i8 = &(1i8 / 0);
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NI8_DIV_P` failed here
error[E0080]: attempt to divide `1_i16` by zero
--> $DIR/overflowing-consts.rs:206:24
|
LL | const _NI16_DIV: i16 = 1i16 / 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI16_DIV` failed here
error[E0080]: attempt to divide `1_i16` by zero
--> $DIR/overflowing-consts.rs:207:28
|
LL | const _NI16_DIV_P: &i16 = &(1i16 / 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI16_DIV_P` failed here
error[E0080]: attempt to divide `1_i32` by zero
--> $DIR/overflowing-consts.rs:209:24
|
LL | const _NI32_DIV: i32 = 1i32 / 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI32_DIV` failed here
error[E0080]: attempt to divide `1_i32` by zero
--> $DIR/overflowing-consts.rs:210:28
|
LL | const _NI32_DIV_P: &i32 = &(1i32 / 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI32_DIV_P` failed here
error[E0080]: attempt to divide `1_i64` by zero
--> $DIR/overflowing-consts.rs:212:24
|
LL | const _NI64_DIV: i64 = 1i64 / 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI64_DIV` failed here
error[E0080]: attempt to divide `1_i64` by zero
--> $DIR/overflowing-consts.rs:213:28
|
LL | const _NI64_DIV_P: &i64 = &(1i64 / 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI64_DIV_P` failed here
error[E0080]: attempt to divide `1_i128` by zero
--> $DIR/overflowing-consts.rs:215:26
|
LL | const _NI128_DIV: i128 = 1i128 / 0;
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NI128_DIV` failed here
error[E0080]: attempt to divide `1_i128` by zero
--> $DIR/overflowing-consts.rs:216:30
|
LL | const _NI128_DIV_P: &i128 = &(1i128 / 0);
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NI128_DIV_P` failed here
error[E0080]: attempt to divide `1_u8` by zero
--> $DIR/overflowing-consts.rs:218:22
|
LL | const _NU8_DIV: u8 = 1u8 / 0;
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `_NU8_DIV` failed here
error[E0080]: attempt to divide `1_u8` by zero
--> $DIR/overflowing-consts.rs:219:26
|
LL | const _NU8_DIV_P: &u8 = &(1u8 / 0);
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NU8_DIV_P` failed here
error[E0080]: attempt to divide `1_u16` by zero
--> $DIR/overflowing-consts.rs:221:24
|
LL | const _NU16_DIV: u16 = 1u16 / 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU16_DIV` failed here
error[E0080]: attempt to divide `1_u16` by zero
--> $DIR/overflowing-consts.rs:222:28
|
LL | const _NU16_DIV_P: &u16 = &(1u16 / 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU16_DIV_P` failed here
error[E0080]: attempt to divide `1_u32` by zero
--> $DIR/overflowing-consts.rs:224:24
|
LL | const _NU32_DIV: u32 = 1u32 / 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU32_DIV` failed here
error[E0080]: attempt to divide `1_u32` by zero
--> $DIR/overflowing-consts.rs:225:28
|
LL | const _NU32_DIV_P: &u32 = &(1u32 / 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU32_DIV_P` failed here
error[E0080]: attempt to divide `1_u64` by zero
--> $DIR/overflowing-consts.rs:227:24
|
LL | const _NU64_DIV: u64 = 1u64 / 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU64_DIV` failed here
error[E0080]: attempt to divide `1_u64` by zero
--> $DIR/overflowing-consts.rs:228:28
|
LL | const _NU64_DIV_P: &u64 = &(1u64 / 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU64_DIV_P` failed here
error[E0080]: attempt to divide `1_u128` by zero
--> $DIR/overflowing-consts.rs:230:26
|
LL | const _NU128_DIV: u128 = 1u128 / 0;
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NU128_DIV` failed here
error[E0080]: attempt to divide `1_u128` by zero
--> $DIR/overflowing-consts.rs:231:30
|
LL | const _NU128_DIV_P: &u128 = &(1u128 / 0);
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NU128_DIV_P` failed here
error[E0080]: attempt to divide `1_isize` by zero
--> $DIR/overflowing-consts.rs:233:28
|
LL | const _NISIZE_DIV: isize = 1isize / 0;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NISIZE_DIV` failed here
error[E0080]: attempt to divide `1_isize` by zero
--> $DIR/overflowing-consts.rs:234:32
|
LL | const _NISIZE_DIV_P: &isize = &(1isize / 0);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NISIZE_DIV_P` failed here
error[E0080]: attempt to divide `1_usize` by zero
--> $DIR/overflowing-consts.rs:236:28
|
LL | const _NUSIZE_DIV: usize = 1usize / 0;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NUSIZE_DIV` failed here
error[E0080]: attempt to divide `1_usize` by zero
--> $DIR/overflowing-consts.rs:237:32
|
LL | const _NUSIZE_DIV_P: &usize = &(1usize / 0);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NUSIZE_DIV_P` failed here
error[E0080]: attempt to calculate the remainder of `1_i8` with a divisor of zero
--> $DIR/overflowing-consts.rs:240:22
|
LL | const _NI8_MOD: i8 = 1i8 % 0;
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `_NI8_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_i8` with a divisor of zero
--> $DIR/overflowing-consts.rs:241:26
|
LL | const _NI8_MOD_P: &i8 = &(1i8 % 0);
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NI8_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_i16` with a divisor of zero
--> $DIR/overflowing-consts.rs:243:24
|
LL | const _NI16_MOD: i16 = 1i16 % 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI16_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_i16` with a divisor of zero
--> $DIR/overflowing-consts.rs:244:28
|
LL | const _NI16_MOD_P: &i16 = &(1i16 % 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI16_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_i32` with a divisor of zero
--> $DIR/overflowing-consts.rs:246:24
|
LL | const _NI32_MOD: i32 = 1i32 % 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI32_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_i32` with a divisor of zero
--> $DIR/overflowing-consts.rs:247:28
|
LL | const _NI32_MOD_P: &i32 = &(1i32 % 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI32_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_i64` with a divisor of zero
--> $DIR/overflowing-consts.rs:249:24
|
LL | const _NI64_MOD: i64 = 1i64 % 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NI64_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_i64` with a divisor of zero
--> $DIR/overflowing-consts.rs:250:28
|
LL | const _NI64_MOD_P: &i64 = &(1i64 % 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NI64_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_i128` with a divisor of zero
--> $DIR/overflowing-consts.rs:252:26
|
LL | const _NI128_MOD: i128 = 1i128 % 0;
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NI128_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_i128` with a divisor of zero
--> $DIR/overflowing-consts.rs:253:30
|
LL | const _NI128_MOD_P: &i128 = &(1i128 % 0);
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NI128_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_u8` with a divisor of zero
--> $DIR/overflowing-consts.rs:255:22
|
LL | const _NU8_MOD: u8 = 1u8 % 0;
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `_NU8_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_u8` with a divisor of zero
--> $DIR/overflowing-consts.rs:256:26
|
LL | const _NU8_MOD_P: &u8 = &(1u8 % 0);
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NU8_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_u16` with a divisor of zero
--> $DIR/overflowing-consts.rs:258:24
|
LL | const _NU16_MOD: u16 = 1u16 % 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU16_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_u16` with a divisor of zero
--> $DIR/overflowing-consts.rs:259:28
|
LL | const _NU16_MOD_P: &u16 = &(1u16 % 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU16_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_u32` with a divisor of zero
--> $DIR/overflowing-consts.rs:261:24
|
LL | const _NU32_MOD: u32 = 1u32 % 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU32_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_u32` with a divisor of zero
--> $DIR/overflowing-consts.rs:262:28
|
LL | const _NU32_MOD_P: &u32 = &(1u32 % 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU32_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_u64` with a divisor of zero
--> $DIR/overflowing-consts.rs:264:24
|
LL | const _NU64_MOD: u64 = 1u64 % 0;
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_NU64_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_u64` with a divisor of zero
--> $DIR/overflowing-consts.rs:265:28
|
LL | const _NU64_MOD_P: &u64 = &(1u64 % 0);
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NU64_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_u128` with a divisor of zero
--> $DIR/overflowing-consts.rs:267:26
|
LL | const _NU128_MOD: u128 = 1u128 % 0;
- | ^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^ evaluation of `_NU128_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_u128` with a divisor of zero
--> $DIR/overflowing-consts.rs:268:30
|
LL | const _NU128_MOD_P: &u128 = &(1u128 % 0);
- | ^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^ evaluation of `_NU128_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero
--> $DIR/overflowing-consts.rs:270:28
|
LL | const _NISIZE_MOD: isize = 1isize % 0;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NISIZE_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_isize` with a divisor of zero
--> $DIR/overflowing-consts.rs:271:32
|
LL | const _NISIZE_MOD_P: &isize = &(1isize % 0);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NISIZE_MOD_P` failed here
error[E0080]: attempt to calculate the remainder of `1_usize` with a divisor of zero
--> $DIR/overflowing-consts.rs:273:28
|
LL | const _NUSIZE_MOD: usize = 1usize % 0;
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `_NUSIZE_MOD` failed here
error[E0080]: attempt to calculate the remainder of `1_usize` with a divisor of zero
--> $DIR/overflowing-consts.rs:274:32
|
LL | const _NUSIZE_MOD_P: &usize = &(1usize % 0);
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NUSIZE_MOD_P` failed here
error[E0080]: index out of bounds: the length is 3 but the index is 4
--> $DIR/overflowing-consts.rs:277:24
|
LL | const _NI32_OOB: i32 = [1, 2, 3][4];
- | ^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^ evaluation of `_NI32_OOB` failed here
error[E0080]: index out of bounds: the length is 3 but the index is 4
--> $DIR/overflowing-consts.rs:278:28
|
LL | const _NI32_OOB_P: &i32 = &([1, 2, 3][4]);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `_NI32_OOB_P` failed here
error: aborting due to 170 previous errors
diff --git a/tests/ui/consts/promoted_running_out_of_memory_issue-130687.stderr b/tests/ui/consts/promoted_running_out_of_memory_issue-130687.stderr
index 6c09a1f..a5a50c5 100644
--- a/tests/ui/consts/promoted_running_out_of_memory_issue-130687.stderr
+++ b/tests/ui/consts/promoted_running_out_of_memory_issue-130687.stderr
@@ -2,7 +2,7 @@
--> $DIR/promoted_running_out_of_memory_issue-130687.rs:13:32
|
LL | const _: &'static Data = &Data([0; (1 << 47) - 1]);
- | ^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/promoted_size_overflow.stderr b/tests/ui/consts/promoted_size_overflow.stderr
index 226c78ec..529b232 100644
--- a/tests/ui/consts/promoted_size_overflow.stderr
+++ b/tests/ui/consts/promoted_size_overflow.stderr
@@ -2,7 +2,7 @@
--> $DIR/promoted_size_overflow.rs:3:29
|
LL | const _: &'static [Data] = &[];
- | ^^ evaluation of constant value failed here
+ | ^^ evaluation of `_` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/qualif-indirect-mutation-fail.stderr b/tests/ui/consts/qualif-indirect-mutation-fail.stderr
index 6cd7741..79724ee 100644
--- a/tests/ui/consts/qualif-indirect-mutation-fail.stderr
+++ b/tests/ui/consts/qualif-indirect-mutation-fail.stderr
@@ -11,7 +11,7 @@
--> $DIR/qualif-indirect-mutation-fail.rs:18:1
|
LL | };
- | ^ evaluation of constant value failed here
+ | ^ evaluation of `A1` failed inside this call
|
note: inside `drop_in_place::<Option<String>> - shim(Some(Option<String>))`
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
@@ -32,7 +32,7 @@
--> $DIR/qualif-indirect-mutation-fail.rs:29:1
|
LL | };
- | ^ evaluation of constant value failed here
+ | ^ evaluation of `A2` failed inside this call
|
note: inside `drop_in_place::<Option<String>> - shim(Some(Option<String>))`
--> $SRC_DIR/core/src/ptr/mod.rs:LL:COL
diff --git a/tests/ui/consts/recursive-zst-static.default.stderr b/tests/ui/consts/recursive-zst-static.default.stderr
index 8066182..fee33a8 100644
--- a/tests/ui/consts/recursive-zst-static.default.stderr
+++ b/tests/ui/consts/recursive-zst-static.default.stderr
@@ -2,7 +2,7 @@
--> $DIR/recursive-zst-static.rs:10:18
|
LL | static FOO: () = FOO;
- | ^^^ evaluation of static initializer failed here
+ | ^^^ evaluation of `FOO` failed here
error[E0391]: cycle detected when evaluating initializer of static `A`
--> $DIR/recursive-zst-static.rs:13:16
diff --git a/tests/ui/consts/recursive-zst-static.unleash.stderr b/tests/ui/consts/recursive-zst-static.unleash.stderr
index 8066182..fee33a8 100644
--- a/tests/ui/consts/recursive-zst-static.unleash.stderr
+++ b/tests/ui/consts/recursive-zst-static.unleash.stderr
@@ -2,7 +2,7 @@
--> $DIR/recursive-zst-static.rs:10:18
|
LL | static FOO: () = FOO;
- | ^^^ evaluation of static initializer failed here
+ | ^^^ evaluation of `FOO` failed here
error[E0391]: cycle detected when evaluating initializer of static `A`
--> $DIR/recursive-zst-static.rs:13:16
diff --git a/tests/ui/consts/recursive.stderr b/tests/ui/consts/recursive.stderr
index 97fa9e7..a382fab 100644
--- a/tests/ui/consts/recursive.stderr
+++ b/tests/ui/consts/recursive.stderr
@@ -13,7 +13,7 @@
--> $DIR/recursive.rs:7:15
|
LL | const X: () = f(1);
- | ^^^^ evaluation of constant value failed here
+ | ^^^^ evaluation of `X` failed inside this call
|
note: [... 126 additional calls inside `f::<i32>` ...]
--> $DIR/recursive.rs:4:5
diff --git a/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr b/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr
index b14c9af..12c5acd 100644
--- a/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr
+++ b/tests/ui/consts/required-consts/interpret-in-promoted.noopt.stderr
@@ -2,7 +2,7 @@
--> $DIR/interpret-in-promoted.rs:15:28
|
LL | let _x: &'static () = &ub();
- | ^^^^ evaluation of constant value failed here
+ | ^^^^ evaluation of `FOO` failed inside this call
|
note: inside `ub`
--> $DIR/interpret-in-promoted.rs:9:5
diff --git a/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr b/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr
index b14c9af..12c5acd 100644
--- a/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr
+++ b/tests/ui/consts/required-consts/interpret-in-promoted.opt.stderr
@@ -2,7 +2,7 @@
--> $DIR/interpret-in-promoted.rs:15:28
|
LL | let _x: &'static () = &ub();
- | ^^^^ evaluation of constant value failed here
+ | ^^^^ evaluation of `FOO` failed inside this call
|
note: inside `ub`
--> $DIR/interpret-in-promoted.rs:9:5
diff --git a/tests/ui/consts/slice-index-overflow-issue-130284.stderr b/tests/ui/consts/slice-index-overflow-issue-130284.stderr
index 641aed3..63c355b 100644
--- a/tests/ui/consts/slice-index-overflow-issue-130284.stderr
+++ b/tests/ui/consts/slice-index-overflow-issue-130284.stderr
@@ -2,7 +2,7 @@
--> $DIR/slice-index-overflow-issue-130284.rs:7:20
|
LL | let _ice = (*fat)[usize::MAX - 1];
- | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^ evaluation of `C` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/static_mut_containing_mut_ref2.stderr b/tests/ui/consts/static_mut_containing_mut_ref2.stderr
index 49b35da..556a4d9 100644
--- a/tests/ui/consts/static_mut_containing_mut_ref2.stderr
+++ b/tests/ui/consts/static_mut_containing_mut_ref2.stderr
@@ -2,7 +2,7 @@
--> $DIR/static_mut_containing_mut_ref2.rs:6:5
|
LL | *(&mut STDERR_BUFFER_SPACE) = 42;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `STDERR_BUFFER` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/static_mut_containing_mut_ref3.stderr b/tests/ui/consts/static_mut_containing_mut_ref3.stderr
index 71d7014..b8ad231 100644
--- a/tests/ui/consts/static_mut_containing_mut_ref3.stderr
+++ b/tests/ui/consts/static_mut_containing_mut_ref3.stderr
@@ -2,7 +2,7 @@
--> $DIR/static_mut_containing_mut_ref3.rs:3:31
|
LL | static mut BAR: () = unsafe { FOO.0 = 99; };
- | ^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^ evaluation of `BAR` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/consts/uninhabited-const-issue-61744.rs b/tests/ui/consts/uninhabited-const-issue-61744.rs
index 698245b..56f0939 100644
--- a/tests/ui/consts/uninhabited-const-issue-61744.rs
+++ b/tests/ui/consts/uninhabited-const-issue-61744.rs
@@ -11,7 +11,7 @@
trait Const {
const CONSTANT: i32 = unsafe { fake_type() }; //~ ERROR reached the configured maximum number of stack frames
- //~^ NOTE evaluation of `<i32 as Const>::CONSTANT` failed here
+ //~^ NOTE evaluation of `<i32 as Const>::CONSTANT` failed inside this call
}
impl<T> Const for T {}
diff --git a/tests/ui/consts/uninhabited-const-issue-61744.stderr b/tests/ui/consts/uninhabited-const-issue-61744.stderr
index f13f612..cae4f8c 100644
--- a/tests/ui/consts/uninhabited-const-issue-61744.stderr
+++ b/tests/ui/consts/uninhabited-const-issue-61744.stderr
@@ -2,7 +2,7 @@
--> $DIR/uninhabited-const-issue-61744.rs:13:36
|
LL | const CONSTANT: i32 = unsafe { fake_type() };
- | ^^^^^^^^^^^ evaluation of `<i32 as Const>::CONSTANT` failed here
+ | ^^^^^^^^^^^ evaluation of `<i32 as Const>::CONSTANT` failed inside this call
|
note: inside `fake_type::<i32>`
--> $DIR/uninhabited-const-issue-61744.rs:5:5
diff --git a/tests/ui/consts/write-to-static-mut-in-static.stderr b/tests/ui/consts/write-to-static-mut-in-static.stderr
index c98c7d8..bb5e217 100644
--- a/tests/ui/consts/write-to-static-mut-in-static.stderr
+++ b/tests/ui/consts/write-to-static-mut-in-static.stderr
@@ -2,13 +2,13 @@
--> $DIR/write-to-static-mut-in-static.rs:2:33
|
LL | pub static mut B: () = unsafe { A = 1; };
- | ^^^^^ evaluation of static initializer failed here
+ | ^^^^^ evaluation of `B` failed here
error[E0080]: encountered static that tried to initialize itself with itself
--> $DIR/write-to-static-mut-in-static.rs:7:21
|
LL | pub static D: u32 = D;
- | ^ evaluation of static initializer failed here
+ | ^ evaluation of `D` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/crate-leading-sep.rs b/tests/ui/crate-leading-sep.rs
deleted file mode 100644
index 6f4dd0b..0000000
--- a/tests/ui/crate-leading-sep.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-//@ run-pass
-
-#![allow(dropping_copy_types)]
-
-fn main() {
- use ::std::mem;
- mem::drop(2_usize);
-}
diff --git a/tests/ui/crate-method-reexport-grrrrrrr.rs b/tests/ui/crate-method-reexport-grrrrrrr.rs
deleted file mode 100644
index aca399f..0000000
--- a/tests/ui/crate-method-reexport-grrrrrrr.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-//@ run-pass
-
-// This is a regression test that the metadata for the
-// name_pool::methods impl in the other crate is reachable from this
-// crate.
-
-//@ aux-build:crate-method-reexport-grrrrrrr2.rs
-
-extern crate crate_method_reexport_grrrrrrr2;
-
-pub fn main() {
- use crate_method_reexport_grrrrrrr2::rust::add;
- use crate_method_reexport_grrrrrrr2::rust::cx;
- let x: Box<_> = Box::new(());
- x.cx();
- let y = ();
- y.add("hi".to_string());
-}
diff --git a/tests/ui/crate_type_flag.rs b/tests/ui/crate_type_flag.rs
deleted file mode 100644
index 03bea36..0000000
--- a/tests/ui/crate_type_flag.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-//@ compile-flags: --crate-type dynlib
-
-fn main() {}
-
-//~? ERROR unknown crate type: `dynlib`
diff --git a/tests/ui/auxiliary/crate-method-reexport-grrrrrrr2.rs b/tests/ui/cross-crate/auxiliary/method_reexport_aux.rs
similarity index 79%
rename from tests/ui/auxiliary/crate-method-reexport-grrrrrrr2.rs
rename to tests/ui/cross-crate/auxiliary/method_reexport_aux.rs
index 06413e1..7579f03 100644
--- a/tests/ui/auxiliary/crate-method-reexport-grrrrrrr2.rs
+++ b/tests/ui/cross-crate/auxiliary/method_reexport_aux.rs
@@ -1,4 +1,6 @@
-#![crate_name="crate_method_reexport_grrrrrrr2"]
+//! Used by `tests/ui/cross-crate/cross-crate-method-reexport.rs`
+
+#![crate_name="method_reexport_aux"]
pub use name_pool::add;
diff --git a/tests/ui/cross-crate/cross-crate-method-reexport.rs b/tests/ui/cross-crate/cross-crate-method-reexport.rs
new file mode 100644
index 0000000..e9eab99
--- /dev/null
+++ b/tests/ui/cross-crate/cross-crate-method-reexport.rs
@@ -0,0 +1,18 @@
+//@ run-pass
+
+// This is a regression test that the metadata for the
+// name_pool::methods impl in the other crate is reachable from this
+// crate.
+
+//@ aux-build:method_reexport_aux.rs
+
+extern crate method_reexport_aux;
+
+pub fn main() {
+ use method_reexport_aux::rust::add;
+ use method_reexport_aux::rust::cx;
+ let x: Box<_> = Box::new(());
+ x.cx();
+ let y = ();
+ y.add("hi".to_string());
+}
diff --git a/tests/ui/default-method-parsing.rs b/tests/ui/default-method-parsing.rs
deleted file mode 100644
index 84c3ab7..0000000
--- a/tests/ui/default-method-parsing.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-//@ check-pass
-
-trait Foo {
- fn m(&self, _:isize) { }
-}
-
-pub fn main() { }
diff --git a/tests/ui/deprecation/deprecated_no_stack_check.rs b/tests/ui/deprecation/deprecated_no_stack_check.rs
index 8e1f5bb..ef48209 100644
--- a/tests/ui/deprecation/deprecated_no_stack_check.rs
+++ b/tests/ui/deprecation/deprecated_no_stack_check.rs
@@ -1,3 +1,5 @@
+//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
+
#![deny(warnings)]
#![feature(no_stack_check)]
//~^ ERROR: feature has been removed [E0557]
diff --git a/tests/ui/deprecation/deprecated_no_stack_check.stderr b/tests/ui/deprecation/deprecated_no_stack_check.stderr
index d78ca20..2d08b1b 100644
--- a/tests/ui/deprecation/deprecated_no_stack_check.stderr
+++ b/tests/ui/deprecation/deprecated_no_stack_check.stderr
@@ -1,8 +1,10 @@
error[E0557]: feature has been removed
- --> $DIR/deprecated_no_stack_check.rs:2:12
+ --> $DIR/deprecated_no_stack_check.rs:4:12
|
LL | #![feature(no_stack_check)]
| ^^^^^^^^^^^^^^ feature has been removed
+ |
+ = note: removed in 1.0.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/40110> for more information
error: aborting due to 1 previous error
diff --git a/tests/ui/exclusive-drop-and-copy.rs b/tests/ui/derives/copy-drop-mutually-exclusive.rs
similarity index 79%
rename from tests/ui/exclusive-drop-and-copy.rs
rename to tests/ui/derives/copy-drop-mutually-exclusive.rs
index 210ecae..5147605 100644
--- a/tests/ui/exclusive-drop-and-copy.rs
+++ b/tests/ui/derives/copy-drop-mutually-exclusive.rs
@@ -1,4 +1,4 @@
-// issue #20126
+//! Regression test for issue #20126: Copy and Drop traits are mutually exclusive
#[derive(Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented
struct Foo;
diff --git a/tests/ui/exclusive-drop-and-copy.stderr b/tests/ui/derives/copy-drop-mutually-exclusive.stderr
similarity index 82%
rename from tests/ui/exclusive-drop-and-copy.stderr
rename to tests/ui/derives/copy-drop-mutually-exclusive.stderr
index 340ca89..771bbc9 100644
--- a/tests/ui/exclusive-drop-and-copy.stderr
+++ b/tests/ui/derives/copy-drop-mutually-exclusive.stderr
@@ -1,11 +1,11 @@
error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor
- --> $DIR/exclusive-drop-and-copy.rs:3:10
+ --> $DIR/copy-drop-mutually-exclusive.rs:3:10
|
LL | #[derive(Copy, Clone)]
| ^^^^ `Copy` not allowed on types with destructors
error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor
- --> $DIR/exclusive-drop-and-copy.rs:10:10
+ --> $DIR/copy-drop-mutually-exclusive.rs:10:10
|
LL | #[derive(Copy, Clone)]
| ^^^^ `Copy` not allowed on types with destructors
diff --git a/tests/ui/conservative_impl_trait.rs b/tests/ui/diagnostic-width/impl-trait-invalid-iterator-error.rs
similarity index 78%
rename from tests/ui/conservative_impl_trait.rs
rename to tests/ui/diagnostic-width/impl-trait-invalid-iterator-error.rs
index b7f795e..0558893 100644
--- a/tests/ui/conservative_impl_trait.rs
+++ b/tests/ui/diagnostic-width/impl-trait-invalid-iterator-error.rs
@@ -1,4 +1,4 @@
-// #39872, #39553
+//! Test for #39872 and #39553
fn will_ice(something: &u32) -> impl Iterator<Item = &u32> {
//~^ ERROR `()` is not an iterator
diff --git a/tests/ui/conservative_impl_trait.stderr b/tests/ui/diagnostic-width/impl-trait-invalid-iterator-error.stderr
similarity index 86%
rename from tests/ui/conservative_impl_trait.stderr
rename to tests/ui/diagnostic-width/impl-trait-invalid-iterator-error.stderr
index eecdb6f..0146fa7 100644
--- a/tests/ui/conservative_impl_trait.stderr
+++ b/tests/ui/diagnostic-width/impl-trait-invalid-iterator-error.stderr
@@ -1,5 +1,5 @@
error[E0277]: `()` is not an iterator
- --> $DIR/conservative_impl_trait.rs:3:33
+ --> $DIR/impl-trait-invalid-iterator-error.rs:3:33
|
LL | fn will_ice(something: &u32) -> impl Iterator<Item = &u32> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator
diff --git a/tests/ui/drop/or-pattern-drop-order.rs b/tests/ui/drop/or-pattern-drop-order.rs
new file mode 100644
index 0000000..fdc2822
--- /dev/null
+++ b/tests/ui/drop/or-pattern-drop-order.rs
@@ -0,0 +1,109 @@
+//@ run-pass
+//! Test drop order for different ways of declaring pattern bindings involving or-patterns.
+//! Currently, it's inconsistent between language constructs (#142163).
+
+use std::cell::RefCell;
+use std::ops::Drop;
+
+// For more informative failures, we collect drops in a `Vec` before checking their order.
+struct DropOrder(RefCell<Vec<u32>>);
+struct LogDrop<'o>(&'o DropOrder, u32);
+
+impl<'o> Drop for LogDrop<'o> {
+ fn drop(&mut self) {
+ self.0.0.borrow_mut().push(self.1);
+ }
+}
+
+#[track_caller]
+fn assert_drop_order(expected_drops: impl IntoIterator<Item = u32>, f: impl Fn(&DropOrder)) {
+ let order = DropOrder(RefCell::new(Vec::new()));
+ f(&order);
+ let order = order.0.into_inner();
+ let correct_order: Vec<u32> = expected_drops.into_iter().collect();
+ assert_eq!(order, correct_order);
+}
+
+#[expect(unused_variables, unused_assignments, irrefutable_let_patterns)]
+fn main() {
+ // When bindings are declared with `let pat;`, they're visited in left-to-right order, using the
+ // order given by the first occurrence of each variable. They're later dropped in reverse.
+ assert_drop_order(1..=3, |o| {
+ // Drops are right-to-left: `z`, `y`, `x`.
+ let (x, Ok(y) | Err(y), z);
+ // Assignment order doesn't matter.
+ z = LogDrop(o, 1);
+ y = LogDrop(o, 2);
+ x = LogDrop(o, 3);
+ });
+ assert_drop_order(1..=2, |o| {
+ // The first or-pattern alternative determines the bindings' drop order: `y`, `x`.
+ let ((true, x, y) | (false, y, x));
+ x = LogDrop(o, 2);
+ y = LogDrop(o, 1);
+ });
+
+ // When bindings are declared with `let pat = expr;`, bindings within or-patterns are seen last,
+ // thus they're dropped first.
+ assert_drop_order(1..=3, |o| {
+ // Drops are right-to-left, treating `y` as rightmost: `y`, `z`, `x`.
+ let (x, Ok(y) | Err(y), z) = (LogDrop(o, 3), Ok(LogDrop(o, 1)), LogDrop(o, 2));
+ });
+ assert_drop_order(1..=2, |o| {
+ // The first or-pattern alternative determines the bindings' drop order: `y`, `x`.
+ let ((true, x, y) | (false, y, x)) = (true, LogDrop(o, 2), LogDrop(o, 1));
+ });
+ assert_drop_order(1..=2, |o| {
+ // That drop order is used regardless of which or-pattern alternative matches: `y`, `x`.
+ let ((true, x, y) | (false, y, x)) = (false, LogDrop(o, 1), LogDrop(o, 2));
+ });
+
+ // `match` treats or-patterns as last like `let pat = expr;`, but also determines drop order
+ // using the order of the bindings in the *last* or-pattern alternative.
+ assert_drop_order(1..=3, |o| {
+ // Drops are right-to-left, treating `y` as rightmost: `y`, `z`, `x`.
+ match (LogDrop(o, 3), Ok(LogDrop(o, 1)), LogDrop(o, 2)) { (x, Ok(y) | Err(y), z) => {} }
+ });
+ assert_drop_order(1..=2, |o| {
+ // The last or-pattern alternative determines the bindings' drop order: `x`, `y`.
+ match (true, LogDrop(o, 1), LogDrop(o, 2)) { (true, x, y) | (false, y, x) => {} }
+ });
+ assert_drop_order(1..=2, |o| {
+ // That drop order is used regardless of which or-pattern alternative matches: `x`, `y`.
+ match (false, LogDrop(o, 2), LogDrop(o, 1)) { (true, x, y) | (false, y, x) => {} }
+ });
+
+ // Function params are visited one-by-one, and the order of bindings within a param's pattern is
+ // the same as `let pat = expr`;
+ assert_drop_order(1..=3, |o| {
+ // Among separate params, the drop order is right-to-left: `z`, `y`, `x`.
+ (|x, (Ok(y) | Err(y)), z| {})(LogDrop(o, 3), Ok(LogDrop(o, 2)), LogDrop(o, 1));
+ });
+ assert_drop_order(1..=3, |o| {
+ // Within a param's pattern, or-patterns are treated as rightmost: `y`, `z`, `x`.
+ (|(x, Ok(y) | Err(y), z)| {})((LogDrop(o, 3), Ok(LogDrop(o, 1)), LogDrop(o, 2)));
+ });
+ assert_drop_order(1..=2, |o| {
+ // The first or-pattern alternative determines the bindings' drop order: `y`, `x`.
+ (|((true, x, y) | (false, y, x))| {})((true, LogDrop(o, 2), LogDrop(o, 1)));
+ });
+
+ // `if let` and `let`-`else` see bindings in the same order as `let pat = expr;`.
+ // Vars in or-patterns are seen last (dropped first), and the first alternative's order is used.
+ assert_drop_order(1..=3, |o| {
+ if let (x, Ok(y) | Err(y), z) = (LogDrop(o, 3), Ok(LogDrop(o, 1)), LogDrop(o, 2)) {}
+ });
+ assert_drop_order(1..=3, |o| {
+ let (x, Ok(y) | Err(y), z) = (LogDrop(o, 3), Ok(LogDrop(o, 1)), LogDrop(o, 2)) else {
+ unreachable!();
+ };
+ });
+ assert_drop_order(1..=2, |o| {
+ if let (true, x, y) | (false, y, x) = (true, LogDrop(o, 2), LogDrop(o, 1)) {}
+ });
+ assert_drop_order(1..=2, |o| {
+ let ((true, x, y) | (false, y, x)) = (true, LogDrop(o, 2), LogDrop(o, 1)) else {
+ unreachable!();
+ };
+ });
+}
diff --git a/tests/ui/dropck/eager-by-ref-binding-for-guards.rs b/tests/ui/dropck/eager-by-ref-binding-for-guards.rs
new file mode 100644
index 0000000..3f47583
--- /dev/null
+++ b/tests/ui/dropck/eager-by-ref-binding-for-guards.rs
@@ -0,0 +1,31 @@
+//! The drop check is currently more permissive when match arms have guards, due to eagerly creating
+//! by-ref bindings for the guard (#142057).
+
+struct Struct<T>(T);
+impl<T> Drop for Struct<T> {
+ fn drop(&mut self) {}
+}
+
+fn main() {
+ // This is an error: `short1` is dead before `long1` is dropped.
+ match (Struct(&&0), 1) {
+ (mut long1, ref short1) => long1.0 = &short1,
+ //~^ ERROR `short1` does not live long enough
+ }
+ // This is OK: `short2`'s storage is live until after `long2`'s drop runs.
+ match (Struct(&&0), 1) {
+ (mut long2, ref short2) if true => long2.0 = &short2,
+ _ => unreachable!(),
+ }
+ // This depends on the binding modes of the final or-pattern alternatives (see #142163):
+ let res: &Result<u8, &u8> = &Ok(1);
+ match (Struct(&&0), res) {
+ (mut long3, Ok(short3) | &Err(short3)) if true => long3.0 = &short3,
+ //~^ ERROR `short3` does not live long enough
+ _ => unreachable!(),
+ }
+ match (Struct(&&0), res) {
+ (mut long4, &Err(short4) | Ok(short4)) if true => long4.0 = &short4,
+ _ => unreachable!(),
+ }
+}
diff --git a/tests/ui/dropck/eager-by-ref-binding-for-guards.stderr b/tests/ui/dropck/eager-by-ref-binding-for-guards.stderr
new file mode 100644
index 0000000..cb1a04c
--- /dev/null
+++ b/tests/ui/dropck/eager-by-ref-binding-for-guards.stderr
@@ -0,0 +1,28 @@
+error[E0597]: `short1` does not live long enough
+ --> $DIR/eager-by-ref-binding-for-guards.rs:12:46
+ |
+LL | (mut long1, ref short1) => long1.0 = &short1,
+ | ---------- ^^^^^^-
+ | | | |
+ | | | `short1` dropped here while still borrowed
+ | | | borrow might be used here, when `long1` is dropped and runs the `Drop` code for type `Struct`
+ | | borrowed value does not live long enough
+ | binding `short1` declared here
+ |
+ = note: values in a scope are dropped in the opposite order they are defined
+
+error[E0597]: `short3` does not live long enough
+ --> $DIR/eager-by-ref-binding-for-guards.rs:23:69
+ |
+LL | (mut long3, Ok(short3) | &Err(short3)) if true => long3.0 = &short3,
+ | ------ ^^^^^^-
+ | | | |
+ | | | `short3` dropped here while still borrowed
+ | | | borrow might be used here, when `long3` is dropped and runs the `Drop` code for type `Struct`
+ | binding `short3` declared here borrowed value does not live long enough
+ |
+ = note: values in a scope are dropped in the opposite order they are defined
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0597`.
diff --git a/tests/ui/dropck/let-else-more-permissive.rs b/tests/ui/dropck/let-else-more-permissive.rs
new file mode 100644
index 0000000..0020814
--- /dev/null
+++ b/tests/ui/dropck/let-else-more-permissive.rs
@@ -0,0 +1,30 @@
+//! The drop check is currently more permissive when `let` statements have an `else` block, due to
+//! scheduling drops for bindings' storage before pattern-matching (#142056).
+
+struct Struct<T>(T);
+impl<T> Drop for Struct<T> {
+ fn drop(&mut self) {}
+}
+
+fn main() {
+ {
+ // This is an error: `short1` is dead before `long1` is dropped.
+ let (mut long1, short1) = (Struct(&0), 1);
+ long1.0 = &short1;
+ //~^ ERROR `short1` does not live long enough
+ }
+ {
+ // This is OK: `short2`'s storage is live until after `long2`'s drop runs.
+ #[expect(irrefutable_let_patterns)]
+ let (mut long2, short2) = (Struct(&0), 1) else { unreachable!() };
+ long2.0 = &short2;
+ }
+ {
+ // Sanity check: `short3`'s drop is significant; it's dropped before `long3`:
+ let tmp = Box::new(0);
+ #[expect(irrefutable_let_patterns)]
+ let (mut long3, short3) = (Struct(&tmp), Box::new(1)) else { unreachable!() };
+ long3.0 = &short3;
+ //~^ ERROR `short3` does not live long enough
+ }
+}
diff --git a/tests/ui/dropck/let-else-more-permissive.stderr b/tests/ui/dropck/let-else-more-permissive.stderr
new file mode 100644
index 0000000..7c37e17
--- /dev/null
+++ b/tests/ui/dropck/let-else-more-permissive.stderr
@@ -0,0 +1,35 @@
+error[E0597]: `short1` does not live long enough
+ --> $DIR/let-else-more-permissive.rs:13:19
+ |
+LL | let (mut long1, short1) = (Struct(&0), 1);
+ | ------ binding `short1` declared here
+LL | long1.0 = &short1;
+ | ^^^^^^^ borrowed value does not live long enough
+LL |
+LL | }
+ | -
+ | |
+ | `short1` dropped here while still borrowed
+ | borrow might be used here, when `long1` is dropped and runs the `Drop` code for type `Struct`
+ |
+ = note: values in a scope are dropped in the opposite order they are defined
+
+error[E0597]: `short3` does not live long enough
+ --> $DIR/let-else-more-permissive.rs:27:19
+ |
+LL | let (mut long3, short3) = (Struct(&tmp), Box::new(1)) else { unreachable!() };
+ | ------ binding `short3` declared here
+LL | long3.0 = &short3;
+ | ^^^^^^^ borrowed value does not live long enough
+LL |
+LL | }
+ | -
+ | |
+ | `short3` dropped here while still borrowed
+ | borrow might be used here, when `long3` is dropped and runs the `Drop` code for type `Struct`
+ |
+ = note: values in a scope are dropped in the opposite order they are defined
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0597`.
diff --git a/tests/ui/editions/edition-keywords-2018-2015-parsing.stderr b/tests/ui/editions/edition-keywords-2018-2015-parsing.stderr
index 152a6f3..34f5c7d 100644
--- a/tests/ui/editions/edition-keywords-2018-2015-parsing.stderr
+++ b/tests/ui/editions/edition-keywords-2018-2015-parsing.stderr
@@ -44,22 +44,22 @@
LL | (r#async) => (1)
| ^^^^^^^
-error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `|`, or `||`
+error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `{`, `|`, or `||`
--> $DIR/auxiliary/edition-kw-macro-2015.rs:27:23
|
LL | ($i: ident) => ($i)
- | ^ expected one of `move`, `use`, `|`, or `||`
+ | ^ expected one of `move`, `use`, `{`, `|`, or `||`
|
::: $DIR/edition-keywords-2018-2015-parsing.rs:22:8
|
LL | if passes_ident!(async) == 1 {} // FIXME: Edition hygiene bug, async here is 2018 and reserved
| -------------------- in this macro invocation
-error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `|`, or `||`
+error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `{`, `|`, or `||`
--> $DIR/edition-keywords-2018-2015-parsing.rs:24:24
|
LL | if passes_tt!(async) == 1 {}
- | ^ expected one of `move`, `use`, `|`, or `||`
+ | ^ expected one of `move`, `use`, `{`, `|`, or `||`
error[E0308]: mismatched types
--> $DIR/edition-keywords-2018-2015-parsing.rs:29:33
diff --git a/tests/ui/editions/edition-keywords-2018-2018-parsing.stderr b/tests/ui/editions/edition-keywords-2018-2018-parsing.stderr
index 53f1b82..dd3f493 100644
--- a/tests/ui/editions/edition-keywords-2018-2018-parsing.stderr
+++ b/tests/ui/editions/edition-keywords-2018-2018-parsing.stderr
@@ -44,34 +44,34 @@
LL | (r#async) => (1)
| ^^^^^^^
-error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `|`, or `||`
+error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `{`, `|`, or `||`
--> $DIR/auxiliary/edition-kw-macro-2018.rs:27:23
|
LL | ($i: ident) => ($i)
- | ^ expected one of `move`, `use`, `|`, or `||`
+ | ^ expected one of `move`, `use`, `{`, `|`, or `||`
|
::: $DIR/edition-keywords-2018-2018-parsing.rs:29:8
|
LL | if passes_ident!(async) == 1 {} // FIXME: Edition hygiene bug, async here is 2018 and reserved
| -------------------- in this macro invocation
-error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `|`, or `||`
+error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `{`, `|`, or `||`
--> $DIR/edition-keywords-2018-2018-parsing.rs:31:24
|
LL | if passes_tt!(async) == 1 {}
- | ^ expected one of `move`, `use`, `|`, or `||`
+ | ^ expected one of `move`, `use`, `{`, `|`, or `||`
-error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `|`, or `||`
+error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `{`, `|`, or `||`
--> $DIR/edition-keywords-2018-2018-parsing.rs:14:23
|
LL | ($i: ident) => ($i)
- | ^ expected one of `move`, `use`, `|`, or `||`
+ | ^ expected one of `move`, `use`, `{`, `|`, or `||`
-error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `|`, or `||`
+error: macro expansion ends with an incomplete expression: expected one of `move`, `use`, `{`, `|`, or `||`
--> $DIR/edition-keywords-2018-2018-parsing.rs:35:30
|
LL | if local_passes_tt!(async) == 1 {}
- | ^ expected one of `move`, `use`, `|`, or `||`
+ | ^ expected one of `move`, `use`, `{`, `|`, or `||`
error[E0308]: mismatched types
--> $DIR/edition-keywords-2018-2018-parsing.rs:40:33
diff --git a/tests/ui/empty-allocation-rvalue-non-null.rs b/tests/ui/empty-allocation-rvalue-non-null.rs
deleted file mode 100644
index 0cd4fde..0000000
--- a/tests/ui/empty-allocation-rvalue-non-null.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-//@ run-pass
-
-#![allow(unused_variables)]
-
-pub fn main() {
- let x: () = *Box::new(());
-}
diff --git a/tests/ui/empty-type-parameter-list.rs b/tests/ui/empty-type-parameter-list.rs
deleted file mode 100644
index e8d6b2a..0000000
--- a/tests/ui/empty-type-parameter-list.rs
+++ /dev/null
@@ -1,24 +0,0 @@
-//@ run-pass
-// Test that empty type parameter list (<>) is synonymous with
-// no type parameters at all
-
-struct S<>;
-trait T<> {} //~ WARN trait `T` is never used
-enum E<> { V }
-impl<> T<> for S<> {}
-impl T for E {}
-fn foo<>() {}
-fn bar() {}
-
-fn main() {
- let _ = S;
- let _ = S::<>;
- let _ = E::V;
- let _ = E::<>::V;
- foo();
- foo::<>();
-
- // Test that we can supply <> to non generic things
- bar::<>();
- let _: i32<>;
-}
diff --git a/tests/ui/enum-discriminant/eval-error.stderr b/tests/ui/enum-discriminant/eval-error.stderr
index b4061d7..c29d258 100644
--- a/tests/ui/enum-discriminant/eval-error.stderr
+++ b/tests/ui/enum-discriminant/eval-error.stderr
@@ -49,7 +49,7 @@
--> $DIR/eval-error.rs:9:30
|
LL | let _: Option<Foo> = None;
- | ^^^^ evaluation of constant value failed here
+ | ^^^^ evaluation of `Bar::Boo::{constant#0}` failed here
error: aborting due to 5 previous errors
diff --git a/tests/ui/error-codes/E0080.stderr b/tests/ui/error-codes/E0080.stderr
index 431d4e04..c784546 100644
--- a/tests/ui/error-codes/E0080.stderr
+++ b/tests/ui/error-codes/E0080.stderr
@@ -2,13 +2,13 @@
--> $DIR/E0080.rs:2:9
|
LL | X = (1 << 500),
- | ^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^ evaluation of `Enum::X::{constant#0}` failed here
error[E0080]: attempt to divide `1_isize` by zero
--> $DIR/E0080.rs:3:9
|
LL | Y = (1 / 0),
- | ^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^ evaluation of `Enum::Y::{constant#0}` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/error-codes/E0092.rs b/tests/ui/error-codes/E0092.rs
deleted file mode 100644
index 19a7c65..0000000
--- a/tests/ui/error-codes/E0092.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-#![feature(intrinsics)]
-
-#[rustc_intrinsic]
-unsafe fn atomic_foo(); //~ ERROR E0092
-
-fn main() {}
diff --git a/tests/ui/error-codes/E0092.stderr b/tests/ui/error-codes/E0092.stderr
deleted file mode 100644
index 003c989..0000000
--- a/tests/ui/error-codes/E0092.stderr
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0092]: unrecognized atomic operation function: `foo`
- --> $DIR/E0092.rs:4:11
- |
-LL | unsafe fn atomic_foo();
- | ^^^^^^^^^^ unrecognized atomic operation
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0092`.
diff --git a/tests/ui/error-should-say-copy-not-pod.rs b/tests/ui/error-should-say-copy-not-pod.rs
deleted file mode 100644
index 40c4730..0000000
--- a/tests/ui/error-should-say-copy-not-pod.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-// Tests that the error message uses the word Copy, not Pod.
-
-fn check_bound<T:Copy>(_: T) {}
-
-fn main() {
- check_bound("nocopy".to_string()); //~ ERROR : Copy` is not satisfied
-}
diff --git a/tests/ui/error-should-say-copy-not-pod.stderr b/tests/ui/error-should-say-copy-not-pod.stderr
deleted file mode 100644
index 6aa129f..0000000
--- a/tests/ui/error-should-say-copy-not-pod.stderr
+++ /dev/null
@@ -1,22 +0,0 @@
-error[E0277]: the trait bound `String: Copy` is not satisfied
- --> $DIR/error-should-say-copy-not-pod.rs:6:17
- |
-LL | check_bound("nocopy".to_string());
- | ----------- ^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
- | |
- | required by a bound introduced by this call
- |
-note: required by a bound in `check_bound`
- --> $DIR/error-should-say-copy-not-pod.rs:3:18
- |
-LL | fn check_bound<T:Copy>(_: T) {}
- | ^^^^ required by this bound in `check_bound`
-help: consider removing this method call, as the receiver has type `&'static str` and `&'static str: Copy` trivially holds
- |
-LL - check_bound("nocopy".to_string());
-LL + check_bound("nocopy");
- |
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/explicit-i-suffix.rs b/tests/ui/explicit-i-suffix.rs
deleted file mode 100644
index 0a6ed49..0000000
--- a/tests/ui/explicit-i-suffix.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-//@ run-pass
-
-#![allow(unused_must_use)]
-
-pub fn main() {
- let x: isize = 8;
- let y = 9;
- x + y;
-
- let q: isize = -8;
- let r = -9;
- q + r;
-}
diff --git a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr
index 2d558e9a..25e3039 100644
--- a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr
+++ b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr
@@ -2,7 +2,7 @@
--> $DIR/ctfe-id-unlimited.rs:28:20
|
LL | const ID_ED: u32 = rec_id(ORIGINAL);
- | ^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `ID_ED` failed inside this call
|
note: inside `rec_id`
--> $DIR/ctfe-id-unlimited.rs:21:5
diff --git a/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.rs b/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.rs
index bf32232..26fb7b1 100644
--- a/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.rs
+++ b/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.rs
@@ -10,7 +10,7 @@ const fn g() {
//~^ NOTE in this expansion of panic!
}
-const _: () = f(); //~ NOTE evaluation of constant value failed
+const _: () = f(); //~ NOTE failed inside this call
//~^ ERROR explicit panic
fn main() {}
diff --git a/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.stderr b/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.stderr
index 457290b..380c2bf 100644
--- a/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.stderr
+++ b/tests/ui/explicit-tail-calls/ctfe-tail-call-panic.stderr
@@ -2,7 +2,7 @@
--> $DIR/ctfe-tail-call-panic.rs:13:15
|
LL | const _: () = f();
- | ^^^ evaluation of constant value failed here
+ | ^^^ evaluation of `_` failed inside this call
|
note: inside `g`
--> $DIR/ctfe-tail-call-panic.rs:9:5
diff --git a/tests/ui/ext-nonexistent.rs b/tests/ui/ext-nonexistent.rs
deleted file mode 100644
index 1293324..0000000
--- a/tests/ui/ext-nonexistent.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-fn main() { iamnotanextensionthatexists!(""); }
-//~^ ERROR cannot find macro `iamnotanextensionthatexists` in this scope
diff --git a/tests/ui/ext-nonexistent.stderr b/tests/ui/ext-nonexistent.stderr
deleted file mode 100644
index edb59bb..0000000
--- a/tests/ui/ext-nonexistent.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: cannot find macro `iamnotanextensionthatexists` in this scope
- --> $DIR/ext-nonexistent.rs:1:13
- |
-LL | fn main() { iamnotanextensionthatexists!(""); }
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to 1 previous error
-
diff --git a/tests/ui/extern/issue-28324.stderr b/tests/ui/extern/issue-28324.stderr
index 89dfab9..4637163 100644
--- a/tests/ui/extern/issue-28324.stderr
+++ b/tests/ui/extern/issue-28324.stderr
@@ -2,7 +2,7 @@
--> $DIR/issue-28324.rs:5:23
|
LL | pub static BAZ: u32 = *&error_message_count;
- | ^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAZ` failed here
error[E0133]: use of extern static is unsafe and requires unsafe function or block
--> $DIR/issue-28324.rs:5:25
diff --git a/tests/ui/fact.rs b/tests/ui/fact.rs
deleted file mode 100644
index e94c12d..0000000
--- a/tests/ui/fact.rs
+++ /dev/null
@@ -1,26 +0,0 @@
-//@ run-pass
-
-fn f(x: isize) -> isize {
- // println!("in f:");
-
- println!("{}", x);
- if x == 1 {
- // println!("bottoming out");
-
- return 1;
- } else {
- // println!("recurring");
-
- let y: isize = x * f(x - 1);
- // println!("returned");
-
- println!("{}", y);
- return y;
- }
-}
-
-pub fn main() {
- assert_eq!(f(5), 120);
- // println!("all done");
-
-}
diff --git a/tests/ui/feature-gates/feature-gate-coverage-attribute.rs b/tests/ui/feature-gates/feature-gate-coverage-attribute.rs
index 0a46375..2cf4b76 100644
--- a/tests/ui/feature-gates/feature-gate-coverage-attribute.rs
+++ b/tests/ui/feature-gates/feature-gate-coverage-attribute.rs
@@ -1,3 +1,5 @@
+//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
+
#![crate_type = "lib"]
#![feature(no_coverage)] //~ ERROR feature has been removed [E0557]
diff --git a/tests/ui/feature-gates/feature-gate-coverage-attribute.stderr b/tests/ui/feature-gates/feature-gate-coverage-attribute.stderr
index 00e0f0a..8c23544 100644
--- a/tests/ui/feature-gates/feature-gate-coverage-attribute.stderr
+++ b/tests/ui/feature-gates/feature-gate-coverage-attribute.stderr
@@ -1,13 +1,14 @@
error[E0557]: feature has been removed
- --> $DIR/feature-gate-coverage-attribute.rs:2:12
+ --> $DIR/feature-gate-coverage-attribute.rs:4:12
|
LL | #![feature(no_coverage)]
| ^^^^^^^^^^^ feature has been removed
|
+ = note: removed in 1.74.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/114656> for more information
= note: renamed to `coverage_attribute`
error[E0658]: the `#[coverage]` attribute is an experimental feature
- --> $DIR/feature-gate-coverage-attribute.rs:10:1
+ --> $DIR/feature-gate-coverage-attribute.rs:12:1
|
LL | #[coverage(off)]
| ^^^^^^^^^^^^^^^^
diff --git a/tests/ui/feature-gates/feature-gate-keylocker_x86.rs b/tests/ui/feature-gates/feature-gate-keylocker_x86.rs
deleted file mode 100644
index cef80ad..0000000
--- a/tests/ui/feature-gates/feature-gate-keylocker_x86.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-//@ only-x86_64
-#[target_feature(enable = "kl")]
-//~^ ERROR: currently unstable
-unsafe fn foo() {}
-
-fn main() {}
diff --git a/tests/ui/feature-gates/feature-gate-keylocker_x86.stderr b/tests/ui/feature-gates/feature-gate-keylocker_x86.stderr
deleted file mode 100644
index ed814d3..0000000
--- a/tests/ui/feature-gates/feature-gate-keylocker_x86.stderr
+++ /dev/null
@@ -1,13 +0,0 @@
-error[E0658]: the target feature `kl` is currently unstable
- --> $DIR/feature-gate-keylocker_x86.rs:2:18
- |
-LL | #[target_feature(enable = "kl")]
- | ^^^^^^^^^^^^^
- |
- = note: see issue #134813 <https://github.com/rust-lang/rust/issues/134813> for more information
- = help: add `#![feature(keylocker_x86)]` to the crate attributes to enable
- = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/feature-gates/feature-gate-sha512_sm_x86.rs b/tests/ui/feature-gates/feature-gate-sha512_sm_x86.rs
deleted file mode 100644
index 176a40e..0000000
--- a/tests/ui/feature-gates/feature-gate-sha512_sm_x86.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-//@ only-x86_64
-#[target_feature(enable = "sha512")]
-//~^ ERROR: currently unstable
-unsafe fn foo() {}
-
-fn main() {}
diff --git a/tests/ui/feature-gates/feature-gate-sha512_sm_x86.stderr b/tests/ui/feature-gates/feature-gate-sha512_sm_x86.stderr
deleted file mode 100644
index da9eea0..0000000
--- a/tests/ui/feature-gates/feature-gate-sha512_sm_x86.stderr
+++ /dev/null
@@ -1,13 +0,0 @@
-error[E0658]: the target feature `sha512` is currently unstable
- --> $DIR/feature-gate-sha512_sm_x86.rs:2:18
- |
-LL | #[target_feature(enable = "sha512")]
- | ^^^^^^^^^^^^^^^^^
- |
- = note: see issue #126624 <https://github.com/rust-lang/rust/issues/126624> for more information
- = help: add `#![feature(sha512_sm_x86)]` to the crate attributes to enable
- = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.stderr b/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.stderr
index aaaaeec..fb05273 100644
--- a/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.stderr
+++ b/tests/ui/feature-gates/feature-gated-feature-in-macro-arg.stderr
@@ -7,7 +7,7 @@
= help: add `#![feature(intrinsics)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-error[E0133]: call to unsafe function `atomic_fence` is unsafe and requires unsafe function or block
+error[E0133]: call to unsafe function `main::atomic_fence` is unsafe and requires unsafe function or block
--> $DIR/feature-gated-feature-in-macro-arg.rs:11:9
|
LL | atomic_fence();
diff --git a/tests/ui/feature-gates/gated-bad-feature.rs b/tests/ui/feature-gates/gated-bad-feature.rs
index 51f2db5..3114f66 100644
--- a/tests/ui/feature-gates/gated-bad-feature.rs
+++ b/tests/ui/feature-gates/gated-bad-feature.rs
@@ -1,3 +1,4 @@
+//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
#![feature(foo_bar_baz, foo(bar), foo = "baz", foo)]
//~^ ERROR malformed `feature`
//~| ERROR malformed `feature`
diff --git a/tests/ui/feature-gates/gated-bad-feature.stderr b/tests/ui/feature-gates/gated-bad-feature.stderr
index 2d01bdf..0e75dff 100644
--- a/tests/ui/feature-gates/gated-bad-feature.stderr
+++ b/tests/ui/feature-gates/gated-bad-feature.stderr
@@ -1,41 +1,43 @@
error[E0556]: malformed `feature` attribute input
- --> $DIR/gated-bad-feature.rs:1:25
+ --> $DIR/gated-bad-feature.rs:2:25
|
LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)]
| ^^^^^^^^ help: expected just one word: `foo`
error[E0556]: malformed `feature` attribute input
- --> $DIR/gated-bad-feature.rs:1:35
+ --> $DIR/gated-bad-feature.rs:2:35
|
LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)]
| ^^^^^^^^^^^ help: expected just one word: `foo`
error[E0557]: feature has been removed
- --> $DIR/gated-bad-feature.rs:8:12
+ --> $DIR/gated-bad-feature.rs:9:12
|
LL | #![feature(test_removed_feature)]
| ^^^^^^^^^^^^^^^^^^^^ feature has been removed
+ |
+ = note: removed in 1.0.0 (you are using $RUSTC_VERSION)
error: malformed `feature` attribute input
- --> $DIR/gated-bad-feature.rs:6:1
+ --> $DIR/gated-bad-feature.rs:7:1
|
LL | #![feature]
| ^^^^^^^^^^^ help: must be of the form: `#![feature(name1, name2, ...)]`
error: malformed `feature` attribute input
- --> $DIR/gated-bad-feature.rs:7:1
+ --> $DIR/gated-bad-feature.rs:8:1
|
LL | #![feature = "foo"]
| ^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![feature(name1, name2, ...)]`
error[E0635]: unknown feature `foo_bar_baz`
- --> $DIR/gated-bad-feature.rs:1:12
+ --> $DIR/gated-bad-feature.rs:2:12
|
LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)]
| ^^^^^^^^^^^
error[E0635]: unknown feature `foo`
- --> $DIR/gated-bad-feature.rs:1:48
+ --> $DIR/gated-bad-feature.rs:2:48
|
LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)]
| ^^^
diff --git a/tests/ui/feature-gates/removed-features-note-version-and-pr-issue-141619.rs b/tests/ui/feature-gates/removed-features-note-version-and-pr-issue-141619.rs
new file mode 100644
index 0000000..ec6adb4
--- /dev/null
+++ b/tests/ui/feature-gates/removed-features-note-version-and-pr-issue-141619.rs
@@ -0,0 +1,6 @@
+//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
+
+#![feature(external_doc)] //~ ERROR feature has been removed
+#![doc(include("README.md"))] //~ ERROR unknown `doc` attribute `include`
+
+fn main(){}
diff --git a/tests/ui/feature-gates/removed-features-note-version-and-pr-issue-141619.stderr b/tests/ui/feature-gates/removed-features-note-version-and-pr-issue-141619.stderr
new file mode 100644
index 0000000..43205c7
--- /dev/null
+++ b/tests/ui/feature-gates/removed-features-note-version-and-pr-issue-141619.stderr
@@ -0,0 +1,20 @@
+error[E0557]: feature has been removed
+ --> $DIR/removed-features-note-version-and-pr-issue-141619.rs:3:12
+ |
+LL | #![feature(external_doc)]
+ | ^^^^^^^^^^^^ feature has been removed
+ |
+ = note: removed in 1.54.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/85457> for more information
+ = note: use #[doc = include_str!("filename")] instead, which handles macro invocations
+
+error: unknown `doc` attribute `include`
+ --> $DIR/removed-features-note-version-and-pr-issue-141619.rs:4:8
+ |
+LL | #![doc(include("README.md"))]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: `#[deny(invalid_doc_attributes)]` on by default
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0557`.
diff --git a/tests/ui/generic-const-items/def-site-eval.fail.stderr b/tests/ui/generic-const-items/def-site-eval.fail.stderr
index b861654..e39fbdf 100644
--- a/tests/ui/generic-const-items/def-site-eval.fail.stderr
+++ b/tests/ui/generic-const-items/def-site-eval.fail.stderr
@@ -2,7 +2,7 @@
--> $DIR/def-site-eval.rs:13:20
|
LL | const _<'_a>: () = panic!();
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `_` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr
index a89356f..e5c3bbb 100644
--- a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr
+++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-0.stderr
@@ -4,7 +4,7 @@
LL | / const UNUSABLE: () = ()
LL | | where
LL | | String: Copy;
- | |_________________^ evaluation of constant value failed here
+ | |_________________^ evaluation of `UNUSABLE` failed here
error[E0277]: the trait bound `String: Copy` is not satisfied
--> $DIR/trivially-unsatisfied-bounds-0.rs:11:13
diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr
index 3aa26eb..a5f6dd9 100644
--- a/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr
+++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds-1.stderr
@@ -4,7 +4,7 @@
LL | / const UNUSED: () = ()
LL | | where
LL | | String: Copy;
- | |_________________^ evaluation of constant value failed here
+ | |_________________^ evaluation of `UNUSED` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/generics/empty-generic-brackets-equiv.rs b/tests/ui/generics/empty-generic-brackets-equiv.rs
new file mode 100644
index 0000000..d84498a
--- /dev/null
+++ b/tests/ui/generics/empty-generic-brackets-equiv.rs
@@ -0,0 +1,27 @@
+//! Test that empty type parameter list <> is equivalent to no type parameters
+//!
+//! Checks` that empty angle brackets <> are syntactically valid and equivalent
+//! to omitting type parameters entirely across various language constructs.
+
+//@ run-pass
+
+struct S<>;
+trait T<> {} //~ WARN trait `T` is never used
+enum E<> {
+ V
+}
+impl<> T<> for S<> {}
+impl T for E {}
+fn foo<>() {}
+fn bar() {}
+fn main() {
+ let _ = S;
+ let _ = S::<>;
+ let _ = E::V;
+ let _ = E::<>::V;
+ foo();
+ foo::<>();
+ // Test that we can supply <> to non-generic things
+ bar::<>();
+ let _: i32<>;
+}
diff --git a/tests/ui/empty-type-parameter-list.stderr b/tests/ui/generics/empty-generic-brackets-equiv.stderr
similarity index 75%
rename from tests/ui/empty-type-parameter-list.stderr
rename to tests/ui/generics/empty-generic-brackets-equiv.stderr
index 31a5015..151ee46 100644
--- a/tests/ui/empty-type-parameter-list.stderr
+++ b/tests/ui/generics/empty-generic-brackets-equiv.stderr
@@ -1,5 +1,5 @@
warning: trait `T` is never used
- --> $DIR/empty-type-parameter-list.rs:6:7
+ --> $DIR/empty-generic-brackets-equiv.rs:9:7
|
LL | trait T<> {}
| ^
diff --git a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr
index ba7d777..53c5568 100644
--- a/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr
+++ b/tests/ui/impl-trait/must_outlive_least_region_or_bound.stderr
@@ -65,9 +65,12 @@
--> $DIR/must_outlive_least_region_or_bound.rs:15:41
|
LL | fn foo<'a>(x: &i32) -> impl Copy + 'a { x }
- | ---- ^ lifetime `'a` required
- | |
- | help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
+ | ^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `x`
+ |
+LL | fn foo<'a>(x: &'a i32) -> impl Copy + 'a { x }
+ | ++
error: lifetime may not live long enough
--> $DIR/must_outlive_least_region_or_bound.rs:30:55
diff --git a/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr b/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr
index 132f7de..5ce6eb0 100644
--- a/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr
+++ b/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr
@@ -1,5 +1,5 @@
error[E0282]: type annotations needed
- --> $DIR/recursive-coroutine-boxed.rs:14:23
+ --> $DIR/recursive-coroutine-boxed.rs:11:23
|
LL | let mut gen = Box::pin(foo());
| ^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `Box`
diff --git a/tests/ui/impl-trait/recursive-coroutine-boxed.rs b/tests/ui/impl-trait/recursive-coroutine-boxed.rs
index 8d38e6a..306edc3 100644
--- a/tests/ui/impl-trait/recursive-coroutine-boxed.rs
+++ b/tests/ui/impl-trait/recursive-coroutine-boxed.rs
@@ -7,9 +7,6 @@
use std::ops::{Coroutine, CoroutineState};
fn foo() -> impl Coroutine<Yield = (), Return = ()> {
- // FIXME(-Znext-solver): this fails with a mismatched types as the
- // hidden type of the opaque ends up as {type error}. We should not
- // emit errors for such goals.
#[coroutine] || {
let mut gen = Box::pin(foo());
//[next]~^ ERROR type annotations needed
diff --git a/tests/ui/imports/global-path-resolution-drop.rs b/tests/ui/imports/global-path-resolution-drop.rs
new file mode 100644
index 0000000..29a6afa
--- /dev/null
+++ b/tests/ui/imports/global-path-resolution-drop.rs
@@ -0,0 +1,10 @@
+//! Checks global path resolution of `mem::drop` using a leading `::`.
+
+//@ run-pass
+
+#![allow(dropping_copy_types)]
+
+fn main() {
+ use ::std::mem;
+ mem::drop(2_usize);
+}
diff --git a/tests/ui/infinite/infinite-recursion-const-fn.stderr b/tests/ui/infinite/infinite-recursion-const-fn.stderr
index 529bad5..f5f6e2a 100644
--- a/tests/ui/infinite/infinite-recursion-const-fn.stderr
+++ b/tests/ui/infinite/infinite-recursion-const-fn.stderr
@@ -2,7 +2,7 @@
--> $DIR/infinite-recursion-const-fn.rs:9:18
|
LL | const ARR: [i32; a()] = [5; 6];
- | ^^^ evaluation of constant value failed here
+ | ^^^ evaluation of `ARR::{constant#0}` failed inside this call
|
note: inside `a`
--> $DIR/infinite-recursion-const-fn.rs:4:5
diff --git a/tests/ui/inline-const/break-inside-inline-const-issue-128604.rs b/tests/ui/inline-const/break-inside-inline-const-issue-128604.rs
index a9795d1..cc0d757 100644
--- a/tests/ui/inline-const/break-inside-inline-const-issue-128604.rs
+++ b/tests/ui/inline-const/break-inside-inline-const-issue-128604.rs
@@ -23,3 +23,9 @@
}
}
}
+
+const FOO: () = break;
+//~^ ERROR: `break` outside of a loop or labeled block
+
+static BAR: () = break;
+//~^ ERROR: `break` outside of a loop or labeled block
diff --git a/tests/ui/inline-const/break-inside-inline-const-issue-128604.stderr b/tests/ui/inline-const/break-inside-inline-const-issue-128604.stderr
index 300cd45..6a967c5 100644
--- a/tests/ui/inline-const/break-inside-inline-const-issue-128604.stderr
+++ b/tests/ui/inline-const/break-inside-inline-const-issue-128604.stderr
@@ -11,17 +11,6 @@
| ^^^^^ cannot `break` outside of a loop or labeled block
error[E0268]: `break` outside of a loop or labeled block
- --> $DIR/break-inside-inline-const-issue-128604.rs:2:21
- |
-LL | let _ = ['a'; { break 2; 1 }];
- | ^^^^^^^ cannot `break` outside of a loop or labeled block
- |
-help: consider labeling this block to be able to break within it
- |
-LL | let _ = ['a'; 'block: { break 'block 2; 1 }];
- | +++++++ ++++++
-
-error[E0268]: `break` outside of a loop or labeled block
--> $DIR/break-inside-inline-const-issue-128604.rs:9:13
|
LL | break;
@@ -34,6 +23,29 @@
LL ~ break 'block;
|
-error: aborting due to 4 previous errors
+error[E0268]: `break` outside of a loop or labeled block
+ --> $DIR/break-inside-inline-const-issue-128604.rs:2:21
+ |
+LL | let _ = ['a'; { break 2; 1 }];
+ | ^^^^^^^ cannot `break` outside of a loop or labeled block
+ |
+help: consider labeling this block to be able to break within it
+ |
+LL | let _ = ['a'; 'block: { break 'block 2; 1 }];
+ | +++++++ ++++++
+
+error[E0268]: `break` outside of a loop or labeled block
+ --> $DIR/break-inside-inline-const-issue-128604.rs:27:17
+ |
+LL | const FOO: () = break;
+ | ^^^^^ cannot `break` outside of a loop or labeled block
+
+error[E0268]: `break` outside of a loop or labeled block
+ --> $DIR/break-inside-inline-const-issue-128604.rs:30:18
+ |
+LL | static BAR: () = break;
+ | ^^^^^ cannot `break` outside of a loop or labeled block
+
+error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0268`.
diff --git a/tests/ui/inline-const/cross-const-control-flow-125846.stderr b/tests/ui/inline-const/cross-const-control-flow-125846.stderr
index 0a910e7..5ea571f 100644
--- a/tests/ui/inline-const/cross-const-control-flow-125846.stderr
+++ b/tests/ui/inline-const/cross-const-control-flow-125846.stderr
@@ -39,6 +39,16 @@
| | only allowed inside `async` functions and blocks
| this is not `async`
+error[E0572]: return statement outside of function body
+ --> $DIR/cross-const-control-flow-125846.rs:4:13
+ |
+LL | / fn foo() {
+LL | | const { return }
+ | | --^^^^^^-- the return is part of this body...
+LL | |
+LL | | }
+ | |_- ...not the enclosing function body
+
error[E0268]: `break` outside of a loop or labeled block
--> $DIR/cross-const-control-flow-125846.rs:9:19
|
@@ -63,16 +73,6 @@
LL | const { continue }
| ^^^^^^^^ cannot `continue` outside of a loop
-error[E0572]: return statement outside of function body
- --> $DIR/cross-const-control-flow-125846.rs:4:13
- |
-LL | / fn foo() {
-LL | | const { return }
- | | --^^^^^^-- the return is part of this body...
-LL | |
-LL | | }
- | |_- ...not the enclosing function body
-
error: aborting due to 9 previous errors
Some errors have detailed explanations: E0268, E0435, E0572, E0728, E0767.
diff --git a/tests/ui/intrinsics/auxiliary/cci_intrinsic.rs b/tests/ui/intrinsics/auxiliary/cci_intrinsic.rs
index 1014ac6..95fc673 100644
--- a/tests/ui/intrinsics/auxiliary/cci_intrinsic.rs
+++ b/tests/ui/intrinsics/auxiliary/cci_intrinsic.rs
@@ -1,11 +1,12 @@
-#![feature(intrinsics)]
+#![feature(intrinsics, adt_const_params)]
-pub mod rusti {
+mod rusti {
#[rustc_intrinsic]
- pub unsafe fn atomic_xchg_seqcst<T>(dst: *mut T, src: T) -> T;
+ pub unsafe fn size_of_val<T: ?Sized>(ptr: *const T) -> usize;
}
+// A monomorphic function, inlined cross-crate, referencing an intrinsic.
#[inline(always)]
-pub fn atomic_xchg_seqcst(dst: *mut isize, src: isize) -> isize {
- unsafe { rusti::atomic_xchg_seqcst(dst, src) }
+pub fn size_of_val(val: &[u8]) -> usize {
+ unsafe { rusti::size_of_val(val) }
}
diff --git a/tests/ui/intrinsics/intrinsic-alignment.rs b/tests/ui/intrinsics/intrinsic-alignment.rs
index a467c44..30a523f 100644
--- a/tests/ui/intrinsics/intrinsic-alignment.rs
+++ b/tests/ui/intrinsics/intrinsic-alignment.rs
@@ -23,18 +23,12 @@
mod m {
#[cfg(target_arch = "x86")]
pub fn main() {
- unsafe {
- assert_eq!(crate::rusti::pref_align_of::<u64>(), 8);
- assert_eq!(crate::rusti::min_align_of::<u64>(), 4);
- }
+ assert_eq!(crate::rusti::min_align_of::<u64>(), 4);
}
#[cfg(not(target_arch = "x86"))]
pub fn main() {
- unsafe {
- assert_eq!(crate::rusti::pref_align_of::<u64>(), 8);
- assert_eq!(crate::rusti::min_align_of::<u64>(), 8);
- }
+ assert_eq!(crate::rusti::min_align_of::<u64>(), 8);
}
}
@@ -42,30 +36,21 @@ pub fn main() {
mod m {
#[cfg(target_arch = "x86_64")]
pub fn main() {
- unsafe {
- assert_eq!(crate::rusti::pref_align_of::<u64>(), 8);
- assert_eq!(crate::rusti::min_align_of::<u64>(), 8);
- }
+ assert_eq!(crate::rusti::min_align_of::<u64>(), 8);
}
}
#[cfg(target_os = "windows")]
mod m {
pub fn main() {
- unsafe {
- assert_eq!(crate::rusti::pref_align_of::<u64>(), 8);
- assert_eq!(crate::rusti::min_align_of::<u64>(), 8);
- }
+ assert_eq!(crate::rusti::min_align_of::<u64>(), 8);
}
}
#[cfg(target_family = "wasm")]
mod m {
pub fn main() {
- unsafe {
- assert_eq!(crate::rusti::pref_align_of::<u64>(), 8);
- assert_eq!(crate::rusti::min_align_of::<u64>(), 8);
- }
+ assert_eq!(crate::rusti::min_align_of::<u64>(), 8);
}
}
diff --git a/tests/ui/intrinsics/intrinsic-atomics-cc.rs b/tests/ui/intrinsics/intrinsic-atomics-cc.rs
deleted file mode 100644
index 612a21a..0000000
--- a/tests/ui/intrinsics/intrinsic-atomics-cc.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-//@ run-pass
-//@ aux-build:cci_intrinsic.rs
-
-
-extern crate cci_intrinsic;
-use cci_intrinsic::atomic_xchg_seqcst;
-
-pub fn main() {
- let mut x = 1;
- atomic_xchg_seqcst(&mut x, 5);
- assert_eq!(x, 5);
-}
diff --git a/tests/ui/intrinsics/intrinsic-atomics.rs b/tests/ui/intrinsics/intrinsic-atomics.rs
index f96c6dc..2275aaf 100644
--- a/tests/ui/intrinsics/intrinsic-atomics.rs
+++ b/tests/ui/intrinsics/intrinsic-atomics.rs
@@ -1,50 +1,50 @@
//@ run-pass
#![feature(core_intrinsics)]
-use std::intrinsics::{self as rusti, AtomicOrdering};
+use std::intrinsics::{self as rusti, AtomicOrdering::*};
pub fn main() {
unsafe {
let mut x: Box<_> = Box::new(1);
- assert_eq!(rusti::atomic_load::<_, { AtomicOrdering::SeqCst }>(&*x), 1);
+ assert_eq!(rusti::atomic_load::<_, { SeqCst }>(&*x), 1);
*x = 5;
- assert_eq!(rusti::atomic_load::<_, { AtomicOrdering::Acquire }>(&*x), 5);
+ assert_eq!(rusti::atomic_load::<_, { Acquire }>(&*x), 5);
- rusti::atomic_store_seqcst(&mut *x, 3);
+ rusti::atomic_store::<_, { SeqCst }>(&mut *x, 3);
assert_eq!(*x, 3);
- rusti::atomic_store_release(&mut *x, 1);
+ rusti::atomic_store::<_, { Release }>(&mut *x, 1);
assert_eq!(*x, 1);
- assert_eq!(rusti::atomic_cxchg_seqcst_seqcst(&mut *x, 1, 2), (1, true));
+ assert_eq!(rusti::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(&mut *x, 1, 2), (1, true));
assert_eq!(*x, 2);
- assert_eq!(rusti::atomic_cxchg_acquire_acquire(&mut *x, 1, 3), (2, false));
+ assert_eq!(rusti::atomic_cxchg::<_, { Acquire }, { Acquire }>(&mut *x, 1, 3), (2, false));
assert_eq!(*x, 2);
- assert_eq!(rusti::atomic_cxchg_release_relaxed(&mut *x, 2, 1), (2, true));
+ assert_eq!(rusti::atomic_cxchg::<_, { Release }, { Relaxed }>(&mut *x, 2, 1), (2, true));
assert_eq!(*x, 1);
- assert_eq!(rusti::atomic_xchg_seqcst(&mut *x, 0), 1);
+ assert_eq!(rusti::atomic_xchg::<_, { SeqCst }>(&mut *x, 0), 1);
assert_eq!(*x, 0);
- assert_eq!(rusti::atomic_xchg_acquire(&mut *x, 1), 0);
+ assert_eq!(rusti::atomic_xchg::<_, { Acquire }>(&mut *x, 1), 0);
assert_eq!(*x, 1);
- assert_eq!(rusti::atomic_xchg_release(&mut *x, 0), 1);
+ assert_eq!(rusti::atomic_xchg::<_, { Release }>(&mut *x, 0), 1);
assert_eq!(*x, 0);
- assert_eq!(rusti::atomic_xadd_seqcst(&mut *x, 1), 0);
- assert_eq!(rusti::atomic_xadd_acquire(&mut *x, 1), 1);
- assert_eq!(rusti::atomic_xadd_release(&mut *x, 1), 2);
+ assert_eq!(rusti::atomic_xadd::<_, { SeqCst }>(&mut *x, 1), 0);
+ assert_eq!(rusti::atomic_xadd::<_, { Acquire }>(&mut *x, 1), 1);
+ assert_eq!(rusti::atomic_xadd::<_, { Release }>(&mut *x, 1), 2);
assert_eq!(*x, 3);
- assert_eq!(rusti::atomic_xsub_seqcst(&mut *x, 1), 3);
- assert_eq!(rusti::atomic_xsub_acquire(&mut *x, 1), 2);
- assert_eq!(rusti::atomic_xsub_release(&mut *x, 1), 1);
+ assert_eq!(rusti::atomic_xsub::<_, { SeqCst }>(&mut *x, 1), 3);
+ assert_eq!(rusti::atomic_xsub::<_, { Acquire }>(&mut *x, 1), 2);
+ assert_eq!(rusti::atomic_xsub::<_, { Release }>(&mut *x, 1), 1);
assert_eq!(*x, 0);
loop {
- let res = rusti::atomic_cxchgweak_seqcst_seqcst(&mut *x, 0, 1);
+ let res = rusti::atomic_cxchgweak::<_, { SeqCst }, { SeqCst }>(&mut *x, 0, 1);
assert_eq!(res.0, 0);
if res.1 {
break;
@@ -53,7 +53,7 @@ pub fn main() {
assert_eq!(*x, 1);
loop {
- let res = rusti::atomic_cxchgweak_acquire_acquire(&mut *x, 1, 2);
+ let res = rusti::atomic_cxchgweak::<_, { Acquire }, { Acquire }>(&mut *x, 1, 2);
assert_eq!(res.0, 1);
if res.1 {
break;
@@ -62,7 +62,7 @@ pub fn main() {
assert_eq!(*x, 2);
loop {
- let res = rusti::atomic_cxchgweak_release_relaxed(&mut *x, 2, 3);
+ let res = rusti::atomic_cxchgweak::<_, { Release }, { Relaxed }>(&mut *x, 2, 3);
assert_eq!(res.0, 2);
if res.1 {
break;
diff --git a/tests/ui/intrinsics/intrinsic-inline-cc.rs b/tests/ui/intrinsics/intrinsic-inline-cc.rs
new file mode 100644
index 0000000..f2b961a
--- /dev/null
+++ b/tests/ui/intrinsics/intrinsic-inline-cc.rs
@@ -0,0 +1,9 @@
+//@ run-pass
+//@ aux-build:cci_intrinsic.rs
+
+extern crate cci_intrinsic;
+
+pub fn main() {
+ let val = cci_intrinsic::size_of_val(&[1u8, 2, 3]);
+ assert_eq!(val, 3);
+}
diff --git a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr
index 1d2c263..10f4d8d 100644
--- a/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr
+++ b/tests/ui/intrinsics/intrinsic-raw_eq-const-bad.stderr
@@ -2,13 +2,13 @@
--> $DIR/intrinsic-raw_eq-const-bad.rs:4:5
|
LL | std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16))
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_EQ_PADDING` failed here
error[E0080]: unable to turn pointer into integer
--> $DIR/intrinsic-raw_eq-const-bad.rs:9:5
|
LL | std::intrinsics::raw_eq(&(&0), &(&1))
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_EQ_PTR` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -17,7 +17,7 @@
--> $DIR/intrinsic-raw_eq-const-bad.rs:16:5
|
LL | std::intrinsics::raw_eq(aref, aref)
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `RAW_EQ_NOT_ALIGNED` failed here
error: aborting due to 3 previous errors
diff --git a/tests/ui/intrinsics/non-integer-atomic.rs b/tests/ui/intrinsics/non-integer-atomic.rs
index 5464bf7..853c163 100644
--- a/tests/ui/intrinsics/non-integer-atomic.rs
+++ b/tests/ui/intrinsics/non-integer-atomic.rs
@@ -4,7 +4,7 @@
#![allow(warnings)]
#![crate_type = "rlib"]
-use std::intrinsics::{self, AtomicOrdering};
+use std::intrinsics::{self, AtomicOrdering::*};
#[derive(Copy, Clone)]
pub struct Foo(i64);
@@ -12,81 +12,81 @@
pub type Quux = [u8; 100];
pub unsafe fn test_bool_load(p: &mut bool, v: bool) {
- intrinsics::atomic_load::<_, { AtomicOrdering::SeqCst }>(p);
+ intrinsics::atomic_load::<_, { SeqCst }>(p);
//~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `bool`
}
pub unsafe fn test_bool_store(p: &mut bool, v: bool) {
- intrinsics::atomic_store_seqcst(p, v);
- //~^ ERROR `atomic_store_seqcst` intrinsic: expected basic integer type, found `bool`
+ intrinsics::atomic_store::<_, { SeqCst }>(p, v);
+ //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `bool`
}
pub unsafe fn test_bool_xchg(p: &mut bool, v: bool) {
- intrinsics::atomic_xchg_seqcst(p, v);
- //~^ ERROR `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `bool`
+ intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
+ //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `bool`
}
pub unsafe fn test_bool_cxchg(p: &mut bool, v: bool) {
- intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v);
- //~^ ERROR `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `bool`
+ intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
+ //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `bool`
}
pub unsafe fn test_Foo_load(p: &mut Foo, v: Foo) {
- intrinsics::atomic_load::<_, { AtomicOrdering::SeqCst }>(p);
+ intrinsics::atomic_load::<_, { SeqCst }>(p);
//~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `Foo`
}
pub unsafe fn test_Foo_store(p: &mut Foo, v: Foo) {
- intrinsics::atomic_store_seqcst(p, v);
- //~^ ERROR `atomic_store_seqcst` intrinsic: expected basic integer type, found `Foo`
+ intrinsics::atomic_store::<_, { SeqCst }>(p, v);
+ //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `Foo`
}
pub unsafe fn test_Foo_xchg(p: &mut Foo, v: Foo) {
- intrinsics::atomic_xchg_seqcst(p, v);
- //~^ ERROR `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `Foo`
+ intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
+ //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `Foo`
}
pub unsafe fn test_Foo_cxchg(p: &mut Foo, v: Foo) {
- intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v);
- //~^ ERROR `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `Foo`
+ intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
+ //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `Foo`
}
pub unsafe fn test_Bar_load(p: &mut Bar, v: Bar) {
- intrinsics::atomic_load::<_, { AtomicOrdering::SeqCst }>(p);
+ intrinsics::atomic_load::<_, { SeqCst }>(p);
//~^ ERROR expected basic integer type, found `&dyn Fn()`
}
pub unsafe fn test_Bar_store(p: &mut Bar, v: Bar) {
- intrinsics::atomic_store_seqcst(p, v);
+ intrinsics::atomic_store::<_, { SeqCst }>(p, v);
//~^ ERROR expected basic integer type, found `&dyn Fn()`
}
pub unsafe fn test_Bar_xchg(p: &mut Bar, v: Bar) {
- intrinsics::atomic_xchg_seqcst(p, v);
+ intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
//~^ ERROR expected basic integer type, found `&dyn Fn()`
}
pub unsafe fn test_Bar_cxchg(p: &mut Bar, v: Bar) {
- intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v);
+ intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
//~^ ERROR expected basic integer type, found `&dyn Fn()`
}
pub unsafe fn test_Quux_load(p: &mut Quux, v: Quux) {
- intrinsics::atomic_load::<_, { AtomicOrdering::SeqCst }>(p);
+ intrinsics::atomic_load::<_, { SeqCst }>(p);
//~^ ERROR `atomic_load` intrinsic: expected basic integer type, found `[u8; 100]`
}
pub unsafe fn test_Quux_store(p: &mut Quux, v: Quux) {
- intrinsics::atomic_store_seqcst(p, v);
- //~^ ERROR `atomic_store_seqcst` intrinsic: expected basic integer type, found `[u8; 100]`
+ intrinsics::atomic_store::<_, { SeqCst }>(p, v);
+ //~^ ERROR `atomic_store` intrinsic: expected basic integer type, found `[u8; 100]`
}
pub unsafe fn test_Quux_xchg(p: &mut Quux, v: Quux) {
- intrinsics::atomic_xchg_seqcst(p, v);
- //~^ ERROR `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `[u8; 100]`
+ intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
+ //~^ ERROR `atomic_xchg` intrinsic: expected basic integer type, found `[u8; 100]`
}
pub unsafe fn test_Quux_cxchg(p: &mut Quux, v: Quux) {
- intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v);
- //~^ ERROR `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `[u8; 100]`
+ intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
+ //~^ ERROR `atomic_cxchg` intrinsic: expected basic integer type, found `[u8; 100]`
}
diff --git a/tests/ui/intrinsics/non-integer-atomic.stderr b/tests/ui/intrinsics/non-integer-atomic.stderr
index 58c2dc0..e539d99 100644
--- a/tests/ui/intrinsics/non-integer-atomic.stderr
+++ b/tests/ui/intrinsics/non-integer-atomic.stderr
@@ -1,98 +1,98 @@
error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `bool`
--> $DIR/non-integer-atomic.rs:15:5
|
-LL | intrinsics::atomic_load::<_, { AtomicOrdering::SeqCst }>(p);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | intrinsics::atomic_load::<_, { SeqCst }>(p);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error[E0511]: invalid monomorphization of `atomic_store_seqcst` intrinsic: expected basic integer type, found `bool`
+error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `bool`
--> $DIR/non-integer-atomic.rs:20:5
|
-LL | intrinsics::atomic_store_seqcst(p, v);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error[E0511]: invalid monomorphization of `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `bool`
+error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `bool`
--> $DIR/non-integer-atomic.rs:25:5
|
-LL | intrinsics::atomic_xchg_seqcst(p, v);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error[E0511]: invalid monomorphization of `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `bool`
+error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `bool`
--> $DIR/non-integer-atomic.rs:30:5
|
-LL | intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `Foo`
--> $DIR/non-integer-atomic.rs:35:5
|
-LL | intrinsics::atomic_load::<_, { AtomicOrdering::SeqCst }>(p);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | intrinsics::atomic_load::<_, { SeqCst }>(p);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error[E0511]: invalid monomorphization of `atomic_store_seqcst` intrinsic: expected basic integer type, found `Foo`
+error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `Foo`
--> $DIR/non-integer-atomic.rs:40:5
|
-LL | intrinsics::atomic_store_seqcst(p, v);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error[E0511]: invalid monomorphization of `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `Foo`
+error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `Foo`
--> $DIR/non-integer-atomic.rs:45:5
|
-LL | intrinsics::atomic_xchg_seqcst(p, v);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error[E0511]: invalid monomorphization of `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `Foo`
+error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `Foo`
--> $DIR/non-integer-atomic.rs:50:5
|
-LL | intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `&dyn Fn()`
--> $DIR/non-integer-atomic.rs:55:5
|
-LL | intrinsics::atomic_load::<_, { AtomicOrdering::SeqCst }>(p);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | intrinsics::atomic_load::<_, { SeqCst }>(p);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error[E0511]: invalid monomorphization of `atomic_store_seqcst` intrinsic: expected basic integer type, found `&dyn Fn()`
+error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `&dyn Fn()`
--> $DIR/non-integer-atomic.rs:60:5
|
-LL | intrinsics::atomic_store_seqcst(p, v);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error[E0511]: invalid monomorphization of `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `&dyn Fn()`
+error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `&dyn Fn()`
--> $DIR/non-integer-atomic.rs:65:5
|
-LL | intrinsics::atomic_xchg_seqcst(p, v);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error[E0511]: invalid monomorphization of `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `&dyn Fn()`
+error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `&dyn Fn()`
--> $DIR/non-integer-atomic.rs:70:5
|
-LL | intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `atomic_load` intrinsic: expected basic integer type, found `[u8; 100]`
--> $DIR/non-integer-atomic.rs:75:5
|
-LL | intrinsics::atomic_load::<_, { AtomicOrdering::SeqCst }>(p);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | intrinsics::atomic_load::<_, { SeqCst }>(p);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error[E0511]: invalid monomorphization of `atomic_store_seqcst` intrinsic: expected basic integer type, found `[u8; 100]`
+error[E0511]: invalid monomorphization of `atomic_store` intrinsic: expected basic integer type, found `[u8; 100]`
--> $DIR/non-integer-atomic.rs:80:5
|
-LL | intrinsics::atomic_store_seqcst(p, v);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | intrinsics::atomic_store::<_, { SeqCst }>(p, v);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error[E0511]: invalid monomorphization of `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `[u8; 100]`
+error[E0511]: invalid monomorphization of `atomic_xchg` intrinsic: expected basic integer type, found `[u8; 100]`
--> $DIR/non-integer-atomic.rs:85:5
|
-LL | intrinsics::atomic_xchg_seqcst(p, v);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | intrinsics::atomic_xchg::<_, { SeqCst }>(p, v);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error[E0511]: invalid monomorphization of `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `[u8; 100]`
+error[E0511]: invalid monomorphization of `atomic_cxchg` intrinsic: expected basic integer type, found `[u8; 100]`
--> $DIR/non-integer-atomic.rs:90:5
|
-LL | intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | intrinsics::atomic_cxchg::<_, { SeqCst }, { SeqCst }>(p, v, v);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 16 previous errors
diff --git a/tests/ui/issues/issue-13058.stderr b/tests/ui/issues/issue-13058.stderr
index 7cc2860..4f4108f 100644
--- a/tests/ui/issues/issue-13058.stderr
+++ b/tests/ui/issues/issue-13058.stderr
@@ -1,11 +1,13 @@
error[E0621]: explicit lifetime required in the type of `cont`
--> $DIR/issue-13058.rs:14:21
|
-LL | fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool
- | -- help: add explicit lifetime `'r` to the type of `cont`: `&'r T`
-LL | {
LL | let cont_iter = cont.iter();
| ^^^^^^^^^^^ lifetime `'r` required
+ |
+help: add explicit lifetime `'r` to the type of `cont`
+ |
+LL | fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &'r T) -> bool
+ | ++
error: aborting due to 1 previous error
diff --git a/tests/ui/issues/issue-14285.stderr b/tests/ui/issues/issue-14285.stderr
index 4f89ae5..edd139e 100644
--- a/tests/ui/issues/issue-14285.stderr
+++ b/tests/ui/issues/issue-14285.stderr
@@ -1,10 +1,14 @@
error[E0621]: explicit lifetime required in the type of `a`
--> $DIR/issue-14285.rs:12:5
|
-LL | fn foo<'a>(a: &dyn Foo) -> B<'a> {
- | -------- help: add explicit lifetime `'a` to the type of `a`: `&'a (dyn Foo + 'a)`
LL | B(a)
| ^^^^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `a`
+ |
+LL - fn foo<'a>(a: &dyn Foo) -> B<'a> {
+LL + fn foo<'a>(a: &'a (dyn Foo + 'a)) -> B<'a> {
+ |
error: aborting due to 1 previous error
diff --git a/tests/ui/issues/issue-15034.stderr b/tests/ui/issues/issue-15034.stderr
index 587a5c8..7db8ade 100644
--- a/tests/ui/issues/issue-15034.stderr
+++ b/tests/ui/issues/issue-15034.stderr
@@ -1,10 +1,13 @@
error[E0621]: explicit lifetime required in the type of `lexer`
--> $DIR/issue-15034.rs:17:9
|
-LL | pub fn new(lexer: &'a mut Lexer) -> Parser<'a> {
- | ------------- help: add explicit lifetime `'a` to the type of `lexer`: `&'a mut Lexer<'a>`
LL | Parser { lexer: lexer }
| ^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `lexer`
+ |
+LL | pub fn new(lexer: &'a mut Lexer<'a>) -> Parser<'a> {
+ | ++++
error: aborting due to 1 previous error
diff --git a/tests/ui/issues/issue-3154.stderr b/tests/ui/issues/issue-3154.stderr
index 3106aad..c17e59f 100644
--- a/tests/ui/issues/issue-3154.stderr
+++ b/tests/ui/issues/issue-3154.stderr
@@ -1,10 +1,13 @@
error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/issue-3154.rs:6:5
|
-LL | fn thing<'a,Q>(x: &Q) -> Thing<'a,Q> {
- | -- help: add explicit lifetime `'a` to the type of `x`: `&'a Q`
LL | Thing { x: x }
| ^^^^^^^^^^^^^^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `x`
+ |
+LL | fn thing<'a,Q>(x: &'a Q) -> Thing<'a,Q> {
+ | ++
error: aborting due to 1 previous error
diff --git a/tests/ui/issues/issue-40288-2.stderr b/tests/ui/issues/issue-40288-2.stderr
index 2c64856..81cb7cd 100644
--- a/tests/ui/issues/issue-40288-2.stderr
+++ b/tests/ui/issues/issue-40288-2.stderr
@@ -1,20 +1,24 @@
error[E0621]: explicit lifetime required in the type of `y`
--> $DIR/issue-40288-2.rs:9:5
|
-LL | fn lifetime_transmute_slice<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T {
- | -- help: add explicit lifetime `'a` to the type of `y`: `&'a T`
-...
LL | out[0]
| ^^^^^^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `y`
+ |
+LL | fn lifetime_transmute_slice<'a, T: ?Sized>(x: &'a T, y: &'a T) -> &'a T {
+ | ++
error[E0621]: explicit lifetime required in the type of `y`
--> $DIR/issue-40288-2.rs:24:5
|
-LL | fn lifetime_transmute_struct<'a, T: ?Sized>(x: &'a T, y: &T) -> &'a T {
- | -- help: add explicit lifetime `'a` to the type of `y`: `&'a T`
-...
LL | out.head
| ^^^^^^^^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `y`
+ |
+LL | fn lifetime_transmute_struct<'a, T: ?Sized>(x: &'a T, y: &'a T) -> &'a T {
+ | ++
error: aborting due to 2 previous errors
diff --git a/tests/ui/issues/issue-76191.stderr b/tests/ui/issues/issue-76191.stderr
index 1f19db4..d8b54be 100644
--- a/tests/ui/issues/issue-76191.stderr
+++ b/tests/ui/issues/issue-76191.stderr
@@ -2,7 +2,7 @@
--> $DIR/issue-76191.rs:8:37
|
LL | const RANGE2: RangeInclusive<i32> = panic!();
- | ^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^ evaluation of `RANGE2` failed here
error[E0308]: mismatched types
--> $DIR/issue-76191.rs:14:9
diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr
index abaa16c..b2ce638 100644
--- a/tests/ui/layout/debug.stderr
+++ b/tests/ui/layout/debug.stderr
@@ -6,9 +6,8 @@
error: layout_of(E) = Layout {
size: Size(12 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -45,9 +44,8 @@
variants: [
Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -67,9 +65,8 @@
},
Layout {
size: Size(12 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -108,9 +105,8 @@
error: layout_of(S) = Layout {
size: Size(8 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -156,9 +152,8 @@
error: layout_of(U) = Layout {
size: Size(8 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -182,9 +177,8 @@
error: layout_of(Result<i32, i32>) = Layout {
size: Size(8 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -234,9 +228,8 @@
variants: [
Layout {
size: Size(8 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -273,9 +266,8 @@
},
Layout {
size: Size(8 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -323,9 +315,8 @@
error: layout_of(i32) = Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -353,9 +344,8 @@
error: layout_of(V) = Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(2 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -379,9 +369,8 @@
error: layout_of(W) = Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(2 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -405,9 +394,8 @@
error: layout_of(Y) = Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(2 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -431,9 +419,8 @@
error: layout_of(P1) = Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -457,9 +444,8 @@
error: layout_of(P2) = Layout {
size: Size(8 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -483,9 +469,8 @@
error: layout_of(P3) = Layout {
size: Size(16 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -509,9 +494,8 @@
error: layout_of(P4) = Layout {
size: Size(12 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -535,9 +519,8 @@
error: layout_of(P5) = Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Union {
@@ -566,9 +549,8 @@
error: layout_of(MaybeUninit<u8>) = Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Union {
diff --git a/tests/ui/layout/enum.stderr b/tests/ui/layout/enum.stderr
index 7f0b38d..f95b577 100644
--- a/tests/ui/layout/enum.stderr
+++ b/tests/ui/layout/enum.stderr
@@ -1,4 +1,4 @@
-error: align: AbiAndPrefAlign { abi: Align(2 bytes), pref: $PREF_ALIGN }
+error: align: AbiAlign { abi: Align(2 bytes) }
--> $DIR/enum.rs:9:1
|
LL | enum UninhabitedVariantAlign {
diff --git a/tests/ui/layout/hexagon-enum.stderr b/tests/ui/layout/hexagon-enum.stderr
index 9c3a8662..d910456 100644
--- a/tests/ui/layout/hexagon-enum.stderr
+++ b/tests/ui/layout/hexagon-enum.stderr
@@ -1,8 +1,7 @@
error: layout_of(A) = Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: Align(1 bytes),
},
backend_repr: Scalar(
Initialized {
@@ -45,9 +44,8 @@
variants: [
Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: Align(1 bytes),
},
backend_repr: Memory {
sized: true,
@@ -78,9 +76,8 @@
error: layout_of(B) = Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: Align(1 bytes),
},
backend_repr: Scalar(
Initialized {
@@ -123,9 +120,8 @@
variants: [
Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: Align(1 bytes),
},
backend_repr: Memory {
sized: true,
@@ -156,9 +152,8 @@
error: layout_of(C) = Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(2 bytes),
- pref: Align(2 bytes),
},
backend_repr: Scalar(
Initialized {
@@ -201,9 +196,8 @@
variants: [
Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(2 bytes),
- pref: Align(2 bytes),
},
backend_repr: Memory {
sized: true,
@@ -234,9 +228,8 @@
error: layout_of(P) = Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: Align(4 bytes),
},
backend_repr: Scalar(
Initialized {
@@ -279,9 +272,8 @@
variants: [
Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: Align(4 bytes),
},
backend_repr: Memory {
sized: true,
@@ -312,9 +304,8 @@
error: layout_of(T) = Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: Align(4 bytes),
},
backend_repr: Scalar(
Initialized {
@@ -357,9 +348,8 @@
variants: [
Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: Align(4 bytes),
},
backend_repr: Memory {
sized: true,
diff --git a/tests/ui/layout/invalid-unsized-const-eval.stderr b/tests/ui/layout/invalid-unsized-const-eval.stderr
index 0735688..d5a294d 100644
--- a/tests/ui/layout/invalid-unsized-const-eval.stderr
+++ b/tests/ui/layout/invalid-unsized-const-eval.stderr
@@ -11,7 +11,7 @@
--> $DIR/invalid-unsized-const-eval.rs:12:1
|
LL | static EMPTY_SET: LazyLock = todo!();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `EMPTY_SET` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr b/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr
index e08107f..1a43fd4 100644
--- a/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr
+++ b/tests/ui/layout/invalid-unsized-in-always-sized-tail.stderr
@@ -22,7 +22,7 @@
--> $DIR/invalid-unsized-in-always-sized-tail.rs:15:28
|
LL | static CHECK: () = assert!(align_of::<P2>() == 1);
- | ^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^^^^^^ evaluation of `CHECK` failed inside this call
|
note: inside `align_of::<P2>`
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
diff --git a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr
index ef7f0cd..2087fed 100644
--- a/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr
+++ b/tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr
@@ -1,8 +1,7 @@
error: layout_of(MissingPayloadField) = Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -51,9 +50,8 @@
variants: [
Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -89,9 +87,8 @@
},
Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -122,9 +119,8 @@
error: layout_of(CommonPayloadField) = Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -174,9 +170,8 @@
variants: [
Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -213,9 +208,8 @@
},
Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -263,9 +257,8 @@
error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -314,9 +307,8 @@
variants: [
Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -352,9 +344,8 @@
},
Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -401,9 +392,8 @@
error: layout_of(NicheFirst) = Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -456,9 +446,8 @@
variants: [
Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -506,9 +495,8 @@
},
Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -528,9 +516,8 @@
},
Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -561,9 +548,8 @@
error: layout_of(NicheSecond) = Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -616,9 +602,8 @@
variants: [
Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -666,9 +651,8 @@
},
Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -688,9 +672,8 @@
},
Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
diff --git a/tests/ui/layout/issue-96185-overaligned-enum.stderr b/tests/ui/layout/issue-96185-overaligned-enum.stderr
index a9081af..6bcc5b4 100644
--- a/tests/ui/layout/issue-96185-overaligned-enum.stderr
+++ b/tests/ui/layout/issue-96185-overaligned-enum.stderr
@@ -1,8 +1,7 @@
error: layout_of(Aligned1) = Layout {
size: Size(8 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(8 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -39,9 +38,8 @@
variants: [
Layout {
size: Size(8 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(8 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -63,9 +61,8 @@
},
Layout {
size: Size(8 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(8 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -100,9 +97,8 @@
error: layout_of(Aligned2) = Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -145,9 +141,8 @@
variants: [
Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -169,9 +164,8 @@
},
Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
diff --git a/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr b/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr
index c85c40d..ea29320 100644
--- a/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr
+++ b/tests/ui/layout/issue-unsized-tail-restatic-ice-122488.stderr
@@ -26,7 +26,7 @@
--> $DIR/issue-unsized-tail-restatic-ice-122488.rs:8:1
|
LL | const DATA: *const ArenaSet<Vec<u8>> = std::ptr::null_mut();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `DATA` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/layout/thumb-enum.stderr b/tests/ui/layout/thumb-enum.stderr
index b635d1a..9bd8ced 100644
--- a/tests/ui/layout/thumb-enum.stderr
+++ b/tests/ui/layout/thumb-enum.stderr
@@ -1,8 +1,7 @@
error: layout_of(A) = Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: Align(4 bytes),
},
backend_repr: Scalar(
Initialized {
@@ -45,9 +44,8 @@
variants: [
Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: Align(4 bytes),
},
backend_repr: Memory {
sized: true,
@@ -78,9 +76,8 @@
error: layout_of(B) = Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: Align(4 bytes),
},
backend_repr: Scalar(
Initialized {
@@ -123,9 +120,8 @@
variants: [
Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: Align(4 bytes),
},
backend_repr: Memory {
sized: true,
@@ -156,9 +152,8 @@
error: layout_of(C) = Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(2 bytes),
- pref: Align(4 bytes),
},
backend_repr: Scalar(
Initialized {
@@ -201,9 +196,8 @@
variants: [
Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(2 bytes),
- pref: Align(4 bytes),
},
backend_repr: Memory {
sized: true,
@@ -234,9 +228,8 @@
error: layout_of(P) = Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: Align(4 bytes),
},
backend_repr: Scalar(
Initialized {
@@ -279,9 +272,8 @@
variants: [
Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: Align(4 bytes),
},
backend_repr: Memory {
sized: true,
@@ -312,9 +304,8 @@
error: layout_of(T) = Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: Align(4 bytes),
},
backend_repr: Scalar(
Initialized {
@@ -357,9 +348,8 @@
variants: [
Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: Align(4 bytes),
},
backend_repr: Memory {
sized: true,
diff --git a/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.stderr b/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.stderr
index fa58b1f8..43fe9e3 100644
--- a/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.stderr
+++ b/tests/ui/layout/uncomputable-due-to-trivial-bounds-ice-135138.stderr
@@ -2,7 +2,7 @@
--> $DIR/uncomputable-due-to-trivial-bounds-ice-135138.rs:7:16
|
LL | [(); { let _a: Option<str> = None; 0 }];
- | ^^ evaluation of constant value failed here
+ | ^^ evaluation of `return_str::{constant#0}` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/layout/unknown-when-no-type-parameter.rs b/tests/ui/layout/unknown-when-no-type-parameter.rs
index 81386fe..f787998 100644
--- a/tests/ui/layout/unknown-when-no-type-parameter.rs
+++ b/tests/ui/layout/unknown-when-no-type-parameter.rs
@@ -11,7 +11,7 @@ fn foo()
[(); size_of::<<() as Project>::Assoc>()];
//~^ ERROR the type `<() as Project>::Assoc` has an unknown layout
//~| NOTE inside `std::mem::size_of::<<() as Project>::Assoc>`
- //~| NOTE evaluation of constant value failed
+ //~| NOTE failed inside this call
}
fn main() {}
diff --git a/tests/ui/layout/unknown-when-no-type-parameter.stderr b/tests/ui/layout/unknown-when-no-type-parameter.stderr
index f0a6496..9bb42c4 100644
--- a/tests/ui/layout/unknown-when-no-type-parameter.stderr
+++ b/tests/ui/layout/unknown-when-no-type-parameter.stderr
@@ -2,7 +2,7 @@
--> $DIR/unknown-when-no-type-parameter.rs:11:10
|
LL | [(); size_of::<<() as Project>::Assoc>()];
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `foo::{constant#0}` failed inside this call
|
note: inside `std::mem::size_of::<<() as Project>::Assoc>`
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
diff --git a/tests/ui/layout/unknown-when-ptr-metadata-is-DST.stderr b/tests/ui/layout/unknown-when-ptr-metadata-is-DST.stderr
index 8cf5ce7..fd9eedc 100644
--- a/tests/ui/layout/unknown-when-ptr-metadata-is-DST.stderr
+++ b/tests/ui/layout/unknown-when-ptr-metadata-is-DST.stderr
@@ -2,7 +2,7 @@
--> $DIR/unknown-when-ptr-metadata-is-DST.rs:8:16
|
LL | [(); { let _a: Option<&str> = None; 0 }];
- | ^^ evaluation of constant value failed here
+ | ^^ evaluation of `return_str::{constant#0}` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/layout/zero-sized-array-enum-niche.stderr b/tests/ui/layout/zero-sized-array-enum-niche.stderr
index 1ba184b..1707b8a 100644
--- a/tests/ui/layout/zero-sized-array-enum-niche.stderr
+++ b/tests/ui/layout/zero-sized-array-enum-niche.stderr
@@ -1,8 +1,7 @@
error: layout_of(Result<[u32; 0], bool>) = Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -39,9 +38,8 @@
variants: [
Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -65,9 +63,8 @@
},
Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -111,9 +108,8 @@
error: layout_of(MultipleAlignments) = Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -150,9 +146,8 @@
variants: [
Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(2 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -176,9 +171,8 @@
},
Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -202,9 +196,8 @@
},
Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -248,9 +241,8 @@
error: layout_of(Result<[u32; 0], Packed<NonZero<u16>>>) = Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -287,9 +279,8 @@
variants: [
Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -313,9 +304,8 @@
},
Layout {
size: Size(3 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -359,9 +349,8 @@
error: layout_of(Result<[u32; 0], Packed<U16IsZero>>) = Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -402,9 +391,8 @@
variants: [
Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -428,9 +416,8 @@
},
Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $PREF_ALIGN,
},
backend_repr: Memory {
sized: true,
diff --git a/tests/ui/lazy-type-alias/def-site-param-defaults-wf.stderr b/tests/ui/lazy-type-alias/def-site-param-defaults-wf.stderr
index e0d2574..b97f770 100644
--- a/tests/ui/lazy-type-alias/def-site-param-defaults-wf.stderr
+++ b/tests/ui/lazy-type-alias/def-site-param-defaults-wf.stderr
@@ -2,7 +2,7 @@
--> $DIR/def-site-param-defaults-wf.rs:5:45
|
LL | type Alias<T = Vec<str>, const N: usize = { 0 - 1 }> = T;
- | ^^^^^ evaluation of constant value failed here
+ | ^^^^^ evaluation of `Alias::{constant#0}` failed here
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> $DIR/def-site-param-defaults-wf.rs:5:16
diff --git a/tests/ui/lifetimes/constructor-lifetime-early-binding-error.rs b/tests/ui/lifetimes/constructor-lifetime-early-binding-error.rs
new file mode 100644
index 0000000..2d5a444
--- /dev/null
+++ b/tests/ui/lifetimes/constructor-lifetime-early-binding-error.rs
@@ -0,0 +1,22 @@
+//! Tests that all lifetime parameters in struct (`S`) and enum (`E`) constructors are
+//! treated as early bound, similar to associated items, rather than late bound as in manual
+//! constructors.
+
+struct S<'a, 'b>(&'a u8, &'b u8);
+enum E<'a, 'b> {
+ V(&'a u8),
+ U(&'b u8),
+}
+
+fn main() {
+ S(&0, &0); // OK
+ S::<'static>(&0, &0);
+ //~^ ERROR struct takes 2 lifetime arguments
+ S::<'static, 'static, 'static>(&0, &0);
+ //~^ ERROR struct takes 2 lifetime arguments
+ E::V(&0); // OK
+ E::V::<'static>(&0);
+ //~^ ERROR enum takes 2 lifetime arguments
+ E::V::<'static, 'static, 'static>(&0);
+ //~^ ERROR enum takes 2 lifetime arguments
+}
diff --git a/tests/ui/constructor-lifetime-args.stderr b/tests/ui/lifetimes/constructor-lifetime-early-binding-error.stderr
similarity index 78%
rename from tests/ui/constructor-lifetime-args.stderr
rename to tests/ui/lifetimes/constructor-lifetime-early-binding-error.stderr
index d3759f4..94699a3 100644
--- a/tests/ui/constructor-lifetime-args.stderr
+++ b/tests/ui/lifetimes/constructor-lifetime-early-binding-error.stderr
@@ -1,5 +1,5 @@
error[E0107]: struct takes 2 lifetime arguments but 1 lifetime argument was supplied
- --> $DIR/constructor-lifetime-args.rs:17:5
+ --> $DIR/constructor-lifetime-early-binding-error.rs:13:5
|
LL | S::<'static>(&0, &0);
| ^ ------- supplied 1 lifetime argument
@@ -7,7 +7,7 @@
| expected 2 lifetime arguments
|
note: struct defined here, with 2 lifetime parameters: `'a`, `'b`
- --> $DIR/constructor-lifetime-args.rs:9:8
+ --> $DIR/constructor-lifetime-early-binding-error.rs:5:8
|
LL | struct S<'a, 'b>(&'a u8, &'b u8);
| ^ -- --
@@ -17,7 +17,7 @@
| +++++++++
error[E0107]: struct takes 2 lifetime arguments but 3 lifetime arguments were supplied
- --> $DIR/constructor-lifetime-args.rs:19:5
+ --> $DIR/constructor-lifetime-early-binding-error.rs:15:5
|
LL | S::<'static, 'static, 'static>(&0, &0);
| ^ --------- help: remove the lifetime argument
@@ -25,13 +25,13 @@
| expected 2 lifetime arguments
|
note: struct defined here, with 2 lifetime parameters: `'a`, `'b`
- --> $DIR/constructor-lifetime-args.rs:9:8
+ --> $DIR/constructor-lifetime-early-binding-error.rs:5:8
|
LL | struct S<'a, 'b>(&'a u8, &'b u8);
| ^ -- --
error[E0107]: enum takes 2 lifetime arguments but 1 lifetime argument was supplied
- --> $DIR/constructor-lifetime-args.rs:22:8
+ --> $DIR/constructor-lifetime-early-binding-error.rs:18:8
|
LL | E::V::<'static>(&0);
| ^ ------- supplied 1 lifetime argument
@@ -39,7 +39,7 @@
| expected 2 lifetime arguments
|
note: enum defined here, with 2 lifetime parameters: `'a`, `'b`
- --> $DIR/constructor-lifetime-args.rs:10:6
+ --> $DIR/constructor-lifetime-early-binding-error.rs:6:6
|
LL | enum E<'a, 'b> {
| ^ -- --
@@ -49,7 +49,7 @@
| +++++++++
error[E0107]: enum takes 2 lifetime arguments but 3 lifetime arguments were supplied
- --> $DIR/constructor-lifetime-args.rs:24:8
+ --> $DIR/constructor-lifetime-early-binding-error.rs:20:8
|
LL | E::V::<'static, 'static, 'static>(&0);
| ^ --------- help: remove the lifetime argument
@@ -57,7 +57,7 @@
| expected 2 lifetime arguments
|
note: enum defined here, with 2 lifetime parameters: `'a`, `'b`
- --> $DIR/constructor-lifetime-args.rs:10:6
+ --> $DIR/constructor-lifetime-early-binding-error.rs:6:6
|
LL | enum E<'a, 'b> {
| ^ -- --
diff --git a/tests/ui/lifetimes/lifetime-errors/42701_one_named_and_one_anonymous.stderr b/tests/ui/lifetimes/lifetime-errors/42701_one_named_and_one_anonymous.stderr
index af22078..c524aab 100644
--- a/tests/ui/lifetimes/lifetime-errors/42701_one_named_and_one_anonymous.stderr
+++ b/tests/ui/lifetimes/lifetime-errors/42701_one_named_and_one_anonymous.stderr
@@ -1,11 +1,13 @@
error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/42701_one_named_and_one_anonymous.rs:10:9
|
-LL | fn foo2<'a>(a: &'a Foo, x: &i32) -> &'a i32 {
- | ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
-...
LL | &*x
| ^^^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `x`
+ |
+LL | fn foo2<'a>(a: &'a Foo, x: &'a i32) -> &'a i32 {
+ | ++
error: aborting due to 1 previous error
diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-early-bound-in-struct.stderr b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-early-bound-in-struct.stderr
index e202c31..44a542e 100644
--- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-early-bound-in-struct.stderr
+++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-early-bound-in-struct.stderr
@@ -1,11 +1,13 @@
error[E0621]: explicit lifetime required in the type of `other`
--> $DIR/ex1-return-one-existing-name-early-bound-in-struct.rs:11:21
|
-LL | fn bar(&self, other: Foo) -> Foo<'a> {
- | --- help: add explicit lifetime `'a` to the type of `other`: `Foo<'a>`
-...
LL | other
| ^^^^^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `other`
+ |
+LL | fn bar(&self, other: Foo<'a>) -> Foo<'a> {
+ | ++++
error: aborting due to 1 previous error
diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-2.stderr b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-2.stderr
index 5518ded..52cf859 100644
--- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-2.stderr
+++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-2.stderr
@@ -1,10 +1,13 @@
error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/ex1-return-one-existing-name-if-else-2.rs:2:16
|
-LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
- | ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
LL | if x > y { x } else { y }
| ^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `x`
+ |
+LL | fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32 {
+ | ++
error: aborting due to 1 previous error
diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-3.stderr b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-3.stderr
index c689fa9..fbd9695 100644
--- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-3.stderr
+++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-3.stderr
@@ -1,10 +1,13 @@
error[E0621]: explicit lifetime required in parameter type
--> $DIR/ex1-return-one-existing-name-if-else-3.rs:2:27
|
-LL | fn foo<'a>((x, y): (&'a i32, &i32)) -> &'a i32 {
- | --------------- help: add explicit lifetime `'a` to type: `(&'a i32, &'a i32)`
LL | if x > y { x } else { y }
| ^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to type
+ |
+LL | fn foo<'a>((x, y): (&'a i32, &'a i32)) -> &'a i32 {
+ | ++
error: aborting due to 1 previous error
diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.stderr b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.stderr
index 3da50cf..c875381 100644
--- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.stderr
+++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-2.stderr
@@ -1,10 +1,13 @@
error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/ex1-return-one-existing-name-if-else-using-impl-2.rs:4:15
|
-LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
- | ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
LL | if x > y { x } else { y }
| ^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `x`
+ |
+LL | fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32 {
+ | ++
error: aborting due to 1 previous error
diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr
index 071bda2..83cd11b 100644
--- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr
+++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr
@@ -1,10 +1,13 @@
error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/ex1-return-one-existing-name-if-else-using-impl-3.rs:7:36
|
-LL | fn foo<'a>(&'a self, x: &i32) -> &i32 {
- | ---- help: add explicit lifetime `'a` to the type of `x`: `&'a i32`
LL | if true { &self.field } else { x }
| ^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `x`
+ |
+LL | fn foo<'a>(&'a self, x: &'a i32) -> &i32 {
+ | ++
error: aborting due to 1 previous error
diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else.stderr b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else.stderr
index 1df0776..bf09bd2 100644
--- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else.stderr
+++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else.stderr
@@ -1,10 +1,13 @@
error[E0621]: explicit lifetime required in the type of `y`
--> $DIR/ex1-return-one-existing-name-if-else.rs:2:27
|
-LL | fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 {
- | ---- help: add explicit lifetime `'a` to the type of `y`: `&'a i32`
LL | if x > y { x } else { y }
| ^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `y`
+ |
+LL | fn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32 {
+ | ++
error: aborting due to 1 previous error
diff --git a/tests/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.stderr b/tests/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.stderr
index 25a2f4b..f37e1ba 100644
--- a/tests/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.stderr
+++ b/tests/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-2.stderr
@@ -1,10 +1,13 @@
error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/ex2a-push-one-existing-name-2.rs:6:5
|
-LL | fn foo<'a>(x: Ref<i32>, y: &mut Vec<Ref<'a, i32>>) {
- | -------- help: add explicit lifetime `'a` to the type of `x`: `Ref<'a, i32>`
LL | y.push(x);
| ^^^^^^^^^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `x`
+ |
+LL | fn foo<'a>(x: Ref<'a, i32>, y: &mut Vec<Ref<'a, i32>>) {
+ | +++
error: aborting due to 1 previous error
diff --git a/tests/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.stderr b/tests/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.stderr
index e272597..c25b4c9 100644
--- a/tests/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.stderr
+++ b/tests/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name-early-bound.stderr
@@ -1,11 +1,13 @@
error[E0621]: explicit lifetime required in the type of `y`
--> $DIR/ex2a-push-one-existing-name-early-bound.rs:8:5
|
-LL | fn baz<'a, 'b, T>(x: &mut Vec<&'a T>, y: &T)
- | -- help: add explicit lifetime `'a` to the type of `y`: `&'a T`
-...
LL | x.push(y);
| ^^^^^^^^^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `y`
+ |
+LL | fn baz<'a, 'b, T>(x: &mut Vec<&'a T>, y: &'a T)
+ | ++
error: aborting due to 1 previous error
diff --git a/tests/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.stderr b/tests/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.stderr
index 1025581..8c7bee4 100644
--- a/tests/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.stderr
+++ b/tests/ui/lifetimes/lifetime-errors/ex2a-push-one-existing-name.stderr
@@ -1,10 +1,13 @@
error[E0621]: explicit lifetime required in the type of `y`
--> $DIR/ex2a-push-one-existing-name.rs:6:5
|
-LL | fn foo<'a>(x: &mut Vec<Ref<'a, i32>>, y: Ref<i32>) {
- | -------- help: add explicit lifetime `'a` to the type of `y`: `Ref<'a, i32>`
LL | x.push(y);
| ^^^^^^^^^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `y`
+ |
+LL | fn foo<'a>(x: &mut Vec<Ref<'a, i32>>, y: Ref<'a, i32>) {
+ | +++
error: aborting due to 1 previous error
diff --git a/tests/ui/lifetimes/noisy-follow-up-erro.stderr b/tests/ui/lifetimes/noisy-follow-up-erro.stderr
index 04863ba..eb52147 100644
--- a/tests/ui/lifetimes/noisy-follow-up-erro.stderr
+++ b/tests/ui/lifetimes/noisy-follow-up-erro.stderr
@@ -15,11 +15,14 @@
error[E0621]: explicit lifetime required in the type of `foo`
--> $DIR/noisy-follow-up-erro.rs:14:9
|
-LL | fn boom(&self, foo: &mut Foo<'_, '_, 'a>) -> Result<(), &'a ()> {
- | -------------------- help: add explicit lifetime `'a` to the type of `foo`: `&mut Foo<'_, 'a>`
-LL |
LL | self.bar().map_err(|()| foo.acc(self))?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `foo`
+ |
+LL - fn boom(&self, foo: &mut Foo<'_, '_, 'a>) -> Result<(), &'a ()> {
+LL + fn boom(&self, foo: &mut Foo<'_, 'a>) -> Result<(), &'a ()> {
+ |
error: aborting due to 2 previous errors
diff --git a/tests/ui/limits/huge-static.stderr b/tests/ui/limits/huge-static.stderr
index 63d04b7..9073d7b 100644
--- a/tests/ui/limits/huge-static.stderr
+++ b/tests/ui/limits/huge-static.stderr
@@ -2,13 +2,13 @@
--> $DIR/huge-static.rs:18:1
|
LL | static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MY_TOO_BIG_ARRAY_1` failed here
error[E0080]: values of the type `[u8; 2305843009213693952]` are too big for the target architecture
--> $DIR/huge-static.rs:20:1
|
LL | static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE];
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `MY_TOO_BIG_ARRAY_2` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/limits/issue-55878.stderr b/tests/ui/limits/issue-55878.stderr
index 2735779..a529efa 100644
--- a/tests/ui/limits/issue-55878.stderr
+++ b/tests/ui/limits/issue-55878.stderr
@@ -2,7 +2,7 @@
--> $DIR/issue-55878.rs:4:26
|
LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>());
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main` failed inside this call
|
note: inside `std::mem::size_of::<[u8; usize::MAX]>`
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
diff --git a/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.rs b/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.rs
index 48af6b0..df69782 100644
--- a/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.rs
+++ b/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.rs
@@ -3,6 +3,8 @@
//@ compile-flags: --crate-type lib --emit link
#[link(name = "foo", kind = "raw-dylib")]
extern "stdcall" {
+//~^ WARN: calling convention not supported on this target
+//~| WARN: previously accepted
fn f(x: i32);
//~^ ERROR ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture
}
diff --git a/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.stderr b/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.stderr
index ef02240..e7a32f4 100644
--- a/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.stderr
+++ b/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.stderr
@@ -1,8 +1,41 @@
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported-abi.rs:5:1
+ |
+LL | / extern "stdcall" {
+LL | |
+LL | |
+LL | | fn f(x: i32);
+LL | |
+LL | | }
+ | |_^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"`
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+
error: ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture
- --> $DIR/unsupported-abi.rs:6:5
+ --> $DIR/unsupported-abi.rs:8:5
|
LL | fn f(x: i32);
| ^^^^^^^^^^^^^
-error: aborting due to 1 previous error
+error: aborting due to 1 previous error; 1 warning emitted
+
+Future incompatibility report: Future breakage diagnostic:
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported-abi.rs:5:1
+ |
+LL | / extern "stdcall" {
+LL | |
+LL | |
+LL | | fn f(x: i32);
+LL | |
+LL | | }
+ | |_^
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018>
+ = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"`
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
diff --git a/tests/ui/linking/crate-type-invalid-flag-error.rs b/tests/ui/linking/crate-type-invalid-flag-error.rs
new file mode 100644
index 0000000..3f84184
--- /dev/null
+++ b/tests/ui/linking/crate-type-invalid-flag-error.rs
@@ -0,0 +1,7 @@
+// Test for #70183 that --crate-type flag display valid value.
+
+//@ compile-flags: --crate-type dynlib
+
+fn main() {}
+
+//~? ERROR unknown crate type: `dynlib`
diff --git a/tests/ui/crate_type_flag.stderr b/tests/ui/linking/crate-type-invalid-flag-error.stderr
similarity index 100%
rename from tests/ui/crate_type_flag.stderr
rename to tests/ui/linking/crate-type-invalid-flag-error.stderr
diff --git a/tests/ui/lint/dead-code/const-underscore-issue-142104.rs b/tests/ui/lint/dead-code/const-underscore-issue-142104.rs
new file mode 100644
index 0000000..b255027
--- /dev/null
+++ b/tests/ui/lint/dead-code/const-underscore-issue-142104.rs
@@ -0,0 +1,15 @@
+//@ check-pass
+
+// This test makes sure we always considers `const _` items as live for dead code analysis.
+
+#![deny(dead_code)]
+
+const fn is_nonzero(x: u8) -> bool {
+ x != 0
+}
+
+const _: () = {
+ assert!(is_nonzero(2));
+};
+
+fn main() {}
diff --git a/tests/ui/loops/issue-43162.stderr b/tests/ui/loops/issue-43162.stderr
index 40d9200..f6b6bf2 100644
--- a/tests/ui/loops/issue-43162.stderr
+++ b/tests/ui/loops/issue-43162.stderr
@@ -4,12 +4,6 @@
LL | break true;
| ^^^^^^^^^^ cannot `break` outside of a loop or labeled block
-error[E0268]: `break` outside of a loop or labeled block
- --> $DIR/issue-43162.rs:7:5
- |
-LL | break {};
- | ^^^^^^^^ cannot `break` outside of a loop or labeled block
-
error[E0308]: mismatched types
--> $DIR/issue-43162.rs:1:13
|
@@ -18,6 +12,12 @@
| |
| implicitly returns `()` as its body has no tail or `return` expression
+error[E0268]: `break` outside of a loop or labeled block
+ --> $DIR/issue-43162.rs:7:5
+ |
+LL | break {};
+ | ^^^^^^^^ cannot `break` outside of a loop or labeled block
+
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0268, E0308.
diff --git a/tests/ui/macros/macro-reexport-removed.rs b/tests/ui/macros/macro-reexport-removed.rs
index 4a05468..c1267f1 100644
--- a/tests/ui/macros/macro-reexport-removed.rs
+++ b/tests/ui/macros/macro-reexport-removed.rs
@@ -1,4 +1,5 @@
//@ aux-build:two_macros.rs
+//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
#![feature(macro_reexport)] //~ ERROR feature has been removed
diff --git a/tests/ui/macros/macro-reexport-removed.stderr b/tests/ui/macros/macro-reexport-removed.stderr
index 475a586..d4940ee 100644
--- a/tests/ui/macros/macro-reexport-removed.stderr
+++ b/tests/ui/macros/macro-reexport-removed.stderr
@@ -1,13 +1,14 @@
error[E0557]: feature has been removed
- --> $DIR/macro-reexport-removed.rs:3:12
+ --> $DIR/macro-reexport-removed.rs:4:12
|
LL | #![feature(macro_reexport)]
| ^^^^^^^^^^^^^^ feature has been removed
|
+ = note: removed in 1.0.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/49982> for more information
= note: subsumed by `pub use`
error: cannot find attribute `macro_reexport` in this scope
- --> $DIR/macro-reexport-removed.rs:5:3
+ --> $DIR/macro-reexport-removed.rs:6:3
|
LL | #[macro_reexport(macro_one)]
| ^^^^^^^^^^^^^^ help: a built-in attribute with a similar name exists: `macro_export`
diff --git a/tests/ui/ext-expand-inner-exprs.rs b/tests/ui/macros/nested-macro-expansion.rs
similarity index 71%
rename from tests/ui/ext-expand-inner-exprs.rs
rename to tests/ui/macros/nested-macro-expansion.rs
index 94610d0..3b94b10 100644
--- a/tests/ui/ext-expand-inner-exprs.rs
+++ b/tests/ui/macros/nested-macro-expansion.rs
@@ -1,3 +1,5 @@
+//! Test nested macro expansion with concat! macros
+
//@ run-pass
static FOO : &'static str = concat!(concat!("hel", "lo"), "world");
diff --git a/tests/ui/object-lifetime/object-lifetime-default-from-box-error.stderr b/tests/ui/object-lifetime/object-lifetime-default-from-box-error.stderr
index 15b3692..05eb611 100644
--- a/tests/ui/object-lifetime/object-lifetime-default-from-box-error.stderr
+++ b/tests/ui/object-lifetime/object-lifetime-default-from-box-error.stderr
@@ -21,11 +21,13 @@
error[E0621]: explicit lifetime required in the type of `ss`
--> $DIR/object-lifetime-default-from-box-error.rs:33:5
|
-LL | fn store1<'b>(ss: &mut SomeStruct, b: Box<dyn SomeTrait+'b>) {
- | --------------- help: add explicit lifetime `'b` to the type of `ss`: `&mut SomeStruct<'b>`
-...
LL | ss.r = b;
| ^^^^ lifetime `'b` required
+ |
+help: add explicit lifetime `'b` to the type of `ss`
+ |
+LL | fn store1<'b>(ss: &mut SomeStruct<'b>, b: Box<dyn SomeTrait+'b>) {
+ | ++++
error: aborting due to 3 previous errors
diff --git a/tests/ui/parser/block-no-opening-brace.rs b/tests/ui/parser/block-no-opening-brace.rs
index b08c830..ea5a98f 100644
--- a/tests/ui/parser/block-no-opening-brace.rs
+++ b/tests/ui/parser/block-no-opening-brace.rs
@@ -27,10 +27,10 @@ fn in_try() {
let x = 0;
}
-// FIXME(#80931)
fn in_async() {
async
- let x = 0; //~ ERROR expected one of `move`, `use`, `|`, or `||`, found keyword `let`
+ let x = 0;
+ //~^ ERROR expected one of `move`, `use`, `{`, `|`, or `||`, found keyword `let`
}
// FIXME(#78168)
diff --git a/tests/ui/parser/block-no-opening-brace.stderr b/tests/ui/parser/block-no-opening-brace.stderr
index f51ee92..cf9eeba 100644
--- a/tests/ui/parser/block-no-opening-brace.stderr
+++ b/tests/ui/parser/block-no-opening-brace.stderr
@@ -43,11 +43,11 @@
LL | try
| ^^^ expected expression
-error: expected one of `move`, `use`, `|`, or `||`, found keyword `let`
- --> $DIR/block-no-opening-brace.rs:33:9
+error: expected one of `move`, `use`, `{`, `|`, or `||`, found keyword `let`
+ --> $DIR/block-no-opening-brace.rs:32:9
|
LL | async
- | - expected one of `move`, `use`, `|`, or `||`
+ | - expected one of `move`, `use`, `{`, `|`, or `||`
LL | let x = 0;
| ^^^ unexpected token
diff --git a/tests/ui/parser/misspelled-keywords/async-move.stderr b/tests/ui/parser/misspelled-keywords/async-move.stderr
index 2507326..26449a1 100644
--- a/tests/ui/parser/misspelled-keywords/async-move.stderr
+++ b/tests/ui/parser/misspelled-keywords/async-move.stderr
@@ -1,8 +1,8 @@
-error: expected one of `move`, `use`, `|`, or `||`, found `Move`
+error: expected one of `move`, `use`, `{`, `|`, or `||`, found `Move`
--> $DIR/async-move.rs:4:11
|
LL | async Move {}
- | ^^^^ expected one of `move`, `use`, `|`, or `||`
+ | ^^^^ expected one of `move`, `use`, `{`, `|`, or `||`
|
help: write keyword `move` in lowercase
|
diff --git a/tests/ui/recursion/recursive-static-definition.stderr b/tests/ui/recursion/recursive-static-definition.stderr
index 7063e5c..ce93c41 100644
--- a/tests/ui/recursion/recursive-static-definition.stderr
+++ b/tests/ui/recursion/recursive-static-definition.stderr
@@ -2,13 +2,13 @@
--> $DIR/recursive-static-definition.rs:1:23
|
LL | pub static FOO: u32 = FOO;
- | ^^^ evaluation of static initializer failed here
+ | ^^^ evaluation of `FOO` failed here
error[E0080]: encountered static that tried to initialize itself with itself
--> $DIR/recursive-static-definition.rs:9:23
|
LL | pub static BAR: Foo = BAR;
- | ^^^ evaluation of static initializer failed here
+ | ^^^ evaluation of `BAR` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/regions/regions-glb-free-free.stderr b/tests/ui/regions/regions-glb-free-free.stderr
index 727669f..6ea09e3 100644
--- a/tests/ui/regions/regions-glb-free-free.stderr
+++ b/tests/ui/regions/regions-glb-free-free.stderr
@@ -1,8 +1,6 @@
error[E0621]: explicit lifetime required in the type of `s`
--> $DIR/regions-glb-free-free.rs:15:13
|
-LL | pub fn set_desc(self, s: &str) -> Flag<'a> {
- | ---- help: add explicit lifetime `'a` to the type of `s`: `&'a str`
LL | / Flag {
LL | | name: self.name,
LL | | desc: s,
@@ -10,6 +8,11 @@
LL | | value: self.value
LL | | }
| |_____________^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `s`
+ |
+LL | pub fn set_desc(self, s: &'a str) -> Flag<'a> {
+ | ++
error: aborting due to 1 previous error
diff --git a/tests/ui/regions/regions-infer-at-fn-not-param.stderr b/tests/ui/regions/regions-infer-at-fn-not-param.stderr
index 4c76602..58ff258 100644
--- a/tests/ui/regions/regions-infer-at-fn-not-param.stderr
+++ b/tests/ui/regions/regions-infer-at-fn-not-param.stderr
@@ -2,9 +2,12 @@
--> $DIR/regions-infer-at-fn-not-param.rs:13:57
|
LL | fn take1<'a>(p: Parameterized1) -> Parameterized1<'a> { p }
- | -------------- ^ lifetime `'a` required
- | |
- | help: add explicit lifetime `'a` to the type of `p`: `Parameterized1<'a>`
+ | ^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `p`
+ |
+LL | fn take1<'a>(p: Parameterized1<'a>) -> Parameterized1<'a> { p }
+ | ++++
error: aborting due to 1 previous error
diff --git a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr
index c11acc9..63d6859 100644
--- a/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr
+++ b/tests/ui/repr/repr-c-dead-variants.aarch64-unknown-linux-gnu.stderr
@@ -1,8 +1,7 @@
error: layout_of(Univariant) = Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -45,9 +44,8 @@
variants: [
Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -88,9 +86,8 @@
error: layout_of(TwoVariants) = Layout {
size: Size(8 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -139,9 +136,8 @@
variants: [
Layout {
size: Size(8 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -177,9 +173,8 @@
},
Layout {
size: Size(8 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -226,9 +221,8 @@
error: layout_of(DeadBranchHasOtherField) = Layout {
size: Size(16 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(8 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -265,9 +259,8 @@
variants: [
Layout {
size: Size(16 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(8 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -295,9 +288,8 @@
},
Layout {
size: Size(16 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(8 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
diff --git a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr
index a788815..555471b 100644
--- a/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr
+++ b/tests/ui/repr/repr-c-dead-variants.armebv7r-none-eabi.stderr
@@ -1,8 +1,7 @@
error: layout_of(Univariant) = Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -45,9 +44,8 @@
variants: [
Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -88,9 +86,8 @@
error: layout_of(TwoVariants) = Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -139,9 +136,8 @@
variants: [
Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -177,9 +173,8 @@
},
Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -226,9 +221,8 @@
error: layout_of(DeadBranchHasOtherField) = Layout {
size: Size(16 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(8 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -265,9 +259,8 @@
variants: [
Layout {
size: Size(16 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(8 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -295,9 +288,8 @@
},
Layout {
size: Size(16 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(8 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
diff --git a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr
index c11acc9..63d6859 100644
--- a/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr
+++ b/tests/ui/repr/repr-c-dead-variants.i686-pc-windows-msvc.stderr
@@ -1,8 +1,7 @@
error: layout_of(Univariant) = Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -45,9 +44,8 @@
variants: [
Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -88,9 +86,8 @@
error: layout_of(TwoVariants) = Layout {
size: Size(8 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -139,9 +136,8 @@
variants: [
Layout {
size: Size(8 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -177,9 +173,8 @@
},
Layout {
size: Size(8 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -226,9 +221,8 @@
error: layout_of(DeadBranchHasOtherField) = Layout {
size: Size(16 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(8 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -265,9 +259,8 @@
variants: [
Layout {
size: Size(16 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(8 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -295,9 +288,8 @@
},
Layout {
size: Size(16 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(8 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
diff --git a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr
index c11acc9..63d6859 100644
--- a/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr
+++ b/tests/ui/repr/repr-c-dead-variants.x86_64-unknown-linux-gnu.stderr
@@ -1,8 +1,7 @@
error: layout_of(Univariant) = Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -45,9 +44,8 @@
variants: [
Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -88,9 +86,8 @@
error: layout_of(TwoVariants) = Layout {
size: Size(8 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -139,9 +136,8 @@
variants: [
Layout {
size: Size(8 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -177,9 +173,8 @@
},
Layout {
size: Size(8 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -226,9 +221,8 @@
error: layout_of(DeadBranchHasOtherField) = Layout {
size: Size(16 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(8 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -265,9 +259,8 @@
variants: [
Layout {
size: Size(16 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(8 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -295,9 +288,8 @@
},
Layout {
size: Size(16 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(8 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
diff --git a/tests/ui/repr/repr-c-int-dead-variants.stderr b/tests/ui/repr/repr-c-int-dead-variants.stderr
index f635741..d88a842 100644
--- a/tests/ui/repr/repr-c-int-dead-variants.stderr
+++ b/tests/ui/repr/repr-c-int-dead-variants.stderr
@@ -1,8 +1,7 @@
error: layout_of(UnivariantU8) = Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -45,9 +44,8 @@
variants: [
Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -88,9 +86,8 @@
error: layout_of(TwoVariantsU8) = Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -139,9 +136,8 @@
variants: [
Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -177,9 +173,8 @@
},
Layout {
size: Size(2 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: ScalarPair(
Initialized {
@@ -226,9 +221,8 @@
error: layout_of(DeadBranchHasOtherFieldU8) = Layout {
size: Size(16 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(8 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -265,9 +259,8 @@
variants: [
Layout {
size: Size(16 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(8 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -295,9 +288,8 @@
},
Layout {
size: Size(16 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(8 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
diff --git a/tests/ui/resolve/auxiliary/issue-80079.rs b/tests/ui/resolve/auxiliary/issue-80079.rs
index 190ca75..bfae5c5 100644
--- a/tests/ui/resolve/auxiliary/issue-80079.rs
+++ b/tests/ui/resolve/auxiliary/issue-80079.rs
@@ -1,7 +1,7 @@
#![crate_type = "lib"]
pub mod public {
- use private_import;
+ use crate::private_import;
// should not be suggested since it is private
struct Foo;
diff --git a/tests/ui/resolve/auxiliary/privacy-struct-ctor.rs b/tests/ui/resolve/auxiliary/privacy-struct-ctor.rs
index 6d0bc72..ac157a8 100644
--- a/tests/ui/resolve/auxiliary/privacy-struct-ctor.rs
+++ b/tests/ui/resolve/auxiliary/privacy-struct-ctor.rs
@@ -2,7 +2,7 @@
pub struct S(u8);
pub mod n {
- pub(in m) struct Z(pub(in m::n) u8);
+ pub(in crate::m) struct Z(pub(in crate::m::n) u8);
}
}
diff --git a/tests/ui/resolve/extern-prelude-fail.rs b/tests/ui/resolve/extern-prelude-fail.rs
index c0716f1..7d0df03 100644
--- a/tests/ui/resolve/extern-prelude-fail.rs
+++ b/tests/ui/resolve/extern-prelude-fail.rs
@@ -1,3 +1,4 @@
+//@ edition: 2015
//@ compile-flags:--extern extern_prelude
//@ aux-build:extern-prelude.rs
diff --git a/tests/ui/resolve/extern-prelude-fail.stderr b/tests/ui/resolve/extern-prelude-fail.stderr
index 199a312..b966815 100644
--- a/tests/ui/resolve/extern-prelude-fail.stderr
+++ b/tests/ui/resolve/extern-prelude-fail.stderr
@@ -1,5 +1,5 @@
error[E0432]: unresolved import `extern_prelude`
- --> $DIR/extern-prelude-fail.rs:7:9
+ --> $DIR/extern-prelude-fail.rs:8:9
|
LL | use extern_prelude::S;
| ^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `extern_prelude`
@@ -10,7 +10,7 @@
|
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `extern_prelude`
- --> $DIR/extern-prelude-fail.rs:8:15
+ --> $DIR/extern-prelude-fail.rs:9:15
|
LL | let s = ::extern_prelude::S;
| ^^^^^^^^^^^^^^ use of unresolved module or unlinked crate `extern_prelude`
diff --git a/tests/ui/resolve/issue-42944.rs b/tests/ui/resolve/issue-42944.rs
index 7e439c1..24aa110 100644
--- a/tests/ui/resolve/issue-42944.rs
+++ b/tests/ui/resolve/issue-42944.rs
@@ -3,7 +3,7 @@
}
mod bar {
- use foo::Bx;
+ use crate::foo::Bx;
fn foo() {
Bx(());
diff --git a/tests/ui/resolve/issue-5035.rs b/tests/ui/resolve/issue-5035.rs
index 82c4bc0..a9e2509 100644
--- a/tests/ui/resolve/issue-5035.rs
+++ b/tests/ui/resolve/issue-5035.rs
@@ -4,7 +4,7 @@ trait I {}
type K = dyn I;
impl K for isize {} //~ ERROR expected trait, found type alias `K`
-use ImportError; //~ ERROR unresolved import `ImportError` [E0432]
+use crate::ImportError; //~ ERROR unresolved import `crate::ImportError` [E0432]
//~^ NOTE no `ImportError` in the root
impl ImportError for () {} // check that this is not an additional error (cf. issue #35142)
diff --git a/tests/ui/resolve/issue-5035.stderr b/tests/ui/resolve/issue-5035.stderr
index f571743..b26c962 100644
--- a/tests/ui/resolve/issue-5035.stderr
+++ b/tests/ui/resolve/issue-5035.stderr
@@ -1,8 +1,8 @@
-error[E0432]: unresolved import `ImportError`
+error[E0432]: unresolved import `crate::ImportError`
--> $DIR/issue-5035.rs:7:5
|
-LL | use ImportError;
- | ^^^^^^^^^^^ no `ImportError` in the root
+LL | use crate::ImportError;
+ | ^^^^^^^^^^^^^^^^^^ no `ImportError` in the root
error[E0404]: expected trait, found type alias `K`
--> $DIR/issue-5035.rs:5:6
diff --git a/tests/ui/resolve/nonexistent-macro.rs b/tests/ui/resolve/nonexistent-macro.rs
new file mode 100644
index 0000000..6630754
--- /dev/null
+++ b/tests/ui/resolve/nonexistent-macro.rs
@@ -0,0 +1,6 @@
+//! Test error handling for undefined macro calls
+
+fn main() {
+ iamnotanextensionthatexists!("");
+ //~^ ERROR cannot find macro `iamnotanextensionthatexists` in this scope
+}
diff --git a/tests/ui/resolve/nonexistent-macro.stderr b/tests/ui/resolve/nonexistent-macro.stderr
new file mode 100644
index 0000000..7e89e07
--- /dev/null
+++ b/tests/ui/resolve/nonexistent-macro.stderr
@@ -0,0 +1,8 @@
+error: cannot find macro `iamnotanextensionthatexists` in this scope
+ --> $DIR/nonexistent-macro.rs:4:5
+ |
+LL | iamnotanextensionthatexists!("");
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/resolve/privacy-enum-ctor.rs b/tests/ui/resolve/privacy-enum-ctor.rs
index f0d2cf8..3f79b12 100644
--- a/tests/ui/resolve/privacy-enum-ctor.rs
+++ b/tests/ui/resolve/privacy-enum-ctor.rs
@@ -8,7 +8,7 @@ pub enum E {
}
pub mod n {
- pub(in m) enum Z {
+ pub(in crate::m) enum Z {
Fn(u8),
Struct {
s: u8,
@@ -17,7 +17,7 @@ pub(in m) enum Z {
}
}
- use m::n::Z; // OK, only the type is imported
+ use crate::m::n::Z; // OK, only the type is imported
fn f() {
n::Z;
diff --git a/tests/ui/resolve/privacy-enum-ctor.stderr b/tests/ui/resolve/privacy-enum-ctor.stderr
index f349b93..4ec1b6b 100644
--- a/tests/ui/resolve/privacy-enum-ctor.stderr
+++ b/tests/ui/resolve/privacy-enum-ctor.stderr
@@ -7,7 +7,7 @@
note: the enum is defined here
--> $DIR/privacy-enum-ctor.rs:11:9
|
-LL | / pub(in m) enum Z {
+LL | / pub(in crate::m) enum Z {
LL | | Fn(u8),
LL | | Struct {
LL | | s: u8,
@@ -35,7 +35,7 @@
note: the enum is defined here
--> $DIR/privacy-enum-ctor.rs:11:9
|
-LL | / pub(in m) enum Z {
+LL | / pub(in crate::m) enum Z {
LL | | Fn(u8),
LL | | Struct {
LL | | s: u8,
@@ -154,8 +154,8 @@
note: enum `m::Z` exists but is inaccessible
--> $DIR/privacy-enum-ctor.rs:11:9
|
-LL | pub(in m) enum Z {
- | ^^^^^^^^^^^^^^^^ not accessible
+LL | pub(in crate::m) enum Z {
+ | ^^^^^^^^^^^^^^^^^^^^^^^ not accessible
error[E0423]: expected value, found enum `m::n::Z`
--> $DIR/privacy-enum-ctor.rs:57:16
@@ -166,7 +166,7 @@
note: the enum is defined here
--> $DIR/privacy-enum-ctor.rs:11:9
|
-LL | / pub(in m) enum Z {
+LL | / pub(in crate::m) enum Z {
LL | | Fn(u8),
LL | | Struct {
LL | | s: u8,
@@ -197,8 +197,8 @@
note: enum `m::Z` exists but is inaccessible
--> $DIR/privacy-enum-ctor.rs:11:9
|
-LL | pub(in m) enum Z {
- | ^^^^^^^^^^^^^^^^ not accessible
+LL | pub(in crate::m) enum Z {
+ | ^^^^^^^^^^^^^^^^^^^^^^^ not accessible
error[E0412]: cannot find type `Z` in this scope
--> $DIR/privacy-enum-ctor.rs:64:12
@@ -212,8 +212,8 @@
note: enum `m::Z` exists but is inaccessible
--> $DIR/privacy-enum-ctor.rs:11:9
|
-LL | pub(in m) enum Z {
- | ^^^^^^^^^^^^^^^^ not accessible
+LL | pub(in crate::m) enum Z {
+ | ^^^^^^^^^^^^^^^^^^^^^^^ not accessible
error[E0412]: cannot find type `Z` in this scope
--> $DIR/privacy-enum-ctor.rs:68:12
@@ -227,8 +227,8 @@
note: enum `m::Z` exists but is inaccessible
--> $DIR/privacy-enum-ctor.rs:11:9
|
-LL | pub(in m) enum Z {
- | ^^^^^^^^^^^^^^^^ not accessible
+LL | pub(in crate::m) enum Z {
+ | ^^^^^^^^^^^^^^^^^^^^^^^ not accessible
error[E0603]: enum `Z` is private
--> $DIR/privacy-enum-ctor.rs:57:22
@@ -239,8 +239,8 @@
note: the enum `Z` is defined here
--> $DIR/privacy-enum-ctor.rs:11:9
|
-LL | pub(in m) enum Z {
- | ^^^^^^^^^^^^^^^^
+LL | pub(in crate::m) enum Z {
+ | ^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: enum `Z` is private
--> $DIR/privacy-enum-ctor.rs:61:22
@@ -253,8 +253,8 @@
note: the enum `Z` is defined here
--> $DIR/privacy-enum-ctor.rs:11:9
|
-LL | pub(in m) enum Z {
- | ^^^^^^^^^^^^^^^^
+LL | pub(in crate::m) enum Z {
+ | ^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: enum `Z` is private
--> $DIR/privacy-enum-ctor.rs:64:22
@@ -265,8 +265,8 @@
note: the enum `Z` is defined here
--> $DIR/privacy-enum-ctor.rs:11:9
|
-LL | pub(in m) enum Z {
- | ^^^^^^^^^^^^^^^^
+LL | pub(in crate::m) enum Z {
+ | ^^^^^^^^^^^^^^^^^^^^^^^
error[E0603]: enum `Z` is private
--> $DIR/privacy-enum-ctor.rs:68:22
@@ -279,8 +279,8 @@
note: the enum `Z` is defined here
--> $DIR/privacy-enum-ctor.rs:11:9
|
-LL | pub(in m) enum Z {
- | ^^^^^^^^^^^^^^^^
+LL | pub(in crate::m) enum Z {
+ | ^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/privacy-enum-ctor.rs:27:20
diff --git a/tests/ui/resolve/privacy-struct-ctor.rs b/tests/ui/resolve/privacy-struct-ctor.rs
index da0e9f2..70c7519 100644
--- a/tests/ui/resolve/privacy-struct-ctor.rs
+++ b/tests/ui/resolve/privacy-struct-ctor.rs
@@ -9,10 +9,10 @@ pub struct S2 {
}
pub mod n {
- pub(in m) struct Z(pub(in m::n) u8);
+ pub(in crate::m) struct Z(pub(in crate::m::n) u8);
}
- use m::n::Z; // OK, only the type is imported
+ use crate::m::n::Z; // OK, only the type is imported
fn f() {
n::Z;
diff --git a/tests/ui/resolve/privacy-struct-ctor.stderr b/tests/ui/resolve/privacy-struct-ctor.stderr
index 1d8c741..0a6b1b4 100644
--- a/tests/ui/resolve/privacy-struct-ctor.stderr
+++ b/tests/ui/resolve/privacy-struct-ctor.stderr
@@ -42,8 +42,8 @@
error[E0603]: tuple struct constructor `Z` is private
--> $DIR/privacy-struct-ctor.rs:18:12
|
-LL | pub(in m) struct Z(pub(in m::n) u8);
- | --------------- a constructor is private if any of the fields is private
+LL | pub(in crate::m) struct Z(pub(in crate::m::n) u8);
+ | ---------------------- a constructor is private if any of the fields is private
...
LL | n::Z;
| ^ private tuple struct constructor
@@ -51,12 +51,12 @@
note: the tuple struct constructor `Z` is defined here
--> $DIR/privacy-struct-ctor.rs:12:9
|
-LL | pub(in m) struct Z(pub(in m::n) u8);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | pub(in crate::m) struct Z(pub(in crate::m::n) u8);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider making the field publicly accessible
|
-LL - pub(in m) struct Z(pub(in m::n) u8);
-LL + pub(in m) struct Z(pub u8);
+LL - pub(in crate::m) struct Z(pub(in crate::m::n) u8);
+LL + pub(in crate::m) struct Z(pub u8);
|
error[E0603]: tuple struct constructor `S` is private
@@ -100,8 +100,8 @@
error[E0603]: tuple struct constructor `Z` is private
--> $DIR/privacy-struct-ctor.rs:35:11
|
-LL | pub(in m) struct Z(pub(in m::n) u8);
- | --------------- a constructor is private if any of the fields is private
+LL | pub(in crate::m) struct Z(pub(in crate::m::n) u8);
+ | ---------------------- a constructor is private if any of the fields is private
...
LL | m::n::Z;
| ^ private tuple struct constructor
@@ -109,12 +109,12 @@
note: the tuple struct constructor `Z` is defined here
--> $DIR/privacy-struct-ctor.rs:12:9
|
-LL | pub(in m) struct Z(pub(in m::n) u8);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | pub(in crate::m) struct Z(pub(in crate::m::n) u8);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider making the field publicly accessible
|
-LL - pub(in m) struct Z(pub(in m::n) u8);
-LL + pub(in m) struct Z(pub u8);
+LL - pub(in crate::m) struct Z(pub(in crate::m::n) u8);
+LL + pub(in crate::m) struct Z(pub u8);
|
error[E0603]: tuple struct constructor `S` is private
@@ -140,16 +140,16 @@
LL | xcrate::m::n::Z;
| ^ private tuple struct constructor
|
- ::: $DIR/auxiliary/privacy-struct-ctor.rs:5:28
+ ::: $DIR/auxiliary/privacy-struct-ctor.rs:5:35
|
-LL | pub(in m) struct Z(pub(in m::n) u8);
- | --------------- a constructor is private if any of the fields is private
+LL | pub(in crate::m) struct Z(pub(in crate::m::n) u8);
+ | ---------------------- a constructor is private if any of the fields is private
|
note: the tuple struct constructor `Z` is defined here
--> $DIR/auxiliary/privacy-struct-ctor.rs:5:9
|
-LL | pub(in m) struct Z(pub(in m::n) u8);
- | ^^^^^^^^^^^^^^^^^^
+LL | pub(in crate::m) struct Z(pub(in crate::m::n) u8);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 10 previous errors
diff --git a/tests/ui/resolve/resolve-bad-visibility.rs b/tests/ui/resolve/resolve-bad-visibility.rs
index 7d48bb9..8163561 100644
--- a/tests/ui/resolve/resolve-bad-visibility.rs
+++ b/tests/ui/resolve/resolve-bad-visibility.rs
@@ -1,3 +1,4 @@
+//@ edition: 2015
enum E {}
trait Tr {}
diff --git a/tests/ui/resolve/resolve-bad-visibility.stderr b/tests/ui/resolve/resolve-bad-visibility.stderr
index ac7e1c7..c7bbdfb 100644
--- a/tests/ui/resolve/resolve-bad-visibility.stderr
+++ b/tests/ui/resolve/resolve-bad-visibility.stderr
@@ -1,23 +1,23 @@
error[E0577]: expected module, found enum `E`
- --> $DIR/resolve-bad-visibility.rs:4:8
+ --> $DIR/resolve-bad-visibility.rs:5:8
|
LL | pub(in E) struct S;
| ^ not a module
error[E0577]: expected module, found trait `Tr`
- --> $DIR/resolve-bad-visibility.rs:5:8
+ --> $DIR/resolve-bad-visibility.rs:6:8
|
LL | pub(in Tr) struct Z;
| ^^ not a module
error[E0742]: visibilities can only be restricted to ancestor modules
- --> $DIR/resolve-bad-visibility.rs:6:8
+ --> $DIR/resolve-bad-visibility.rs:7:8
|
LL | pub(in std::vec) struct F;
| ^^^^^^^^
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `nonexistent`
- --> $DIR/resolve-bad-visibility.rs:7:8
+ --> $DIR/resolve-bad-visibility.rs:8:8
|
LL | pub(in nonexistent) struct G;
| ^^^^^^^^^^^ use of unresolved module or unlinked crate `nonexistent`
@@ -28,7 +28,7 @@
|
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `too_soon`
- --> $DIR/resolve-bad-visibility.rs:8:8
+ --> $DIR/resolve-bad-visibility.rs:9:8
|
LL | pub(in too_soon) struct H;
| ^^^^^^^^ use of unresolved module or unlinked crate `too_soon`
diff --git a/tests/ui/resolve/suggest-builder-fn.rs b/tests/ui/resolve/suggest-builder-fn.rs
index 0d9b355..959675e 100644
--- a/tests/ui/resolve/suggest-builder-fn.rs
+++ b/tests/ui/resolve/suggest-builder-fn.rs
@@ -32,7 +32,7 @@ fn build_with_self(&self) -> Self {
}
mod SomeMod {
- use Bar;
+ use crate::Bar;
impl Bar {
// Public method. Should be suggested
diff --git a/tests/ui/resolve/unresolved-segments-visibility.rs b/tests/ui/resolve/unresolved-segments-visibility.rs
index c26171f..fc86b31 100644
--- a/tests/ui/resolve/unresolved-segments-visibility.rs
+++ b/tests/ui/resolve/unresolved-segments-visibility.rs
@@ -5,7 +5,7 @@
mod foo {
mod bar {
- pub(in b::string::String::newy) extern crate alloc as e;
+ pub(in crate::b::string::String::newy) extern crate alloc as e;
//~^ ERROR failed to resolve: `String` is a struct, not a module [E0433]
}
}
diff --git a/tests/ui/resolve/unresolved-segments-visibility.stderr b/tests/ui/resolve/unresolved-segments-visibility.stderr
index 09f3c50..082579c 100644
--- a/tests/ui/resolve/unresolved-segments-visibility.stderr
+++ b/tests/ui/resolve/unresolved-segments-visibility.stderr
@@ -1,8 +1,8 @@
error[E0433]: failed to resolve: `String` is a struct, not a module
- --> $DIR/unresolved-segments-visibility.rs:8:27
+ --> $DIR/unresolved-segments-visibility.rs:8:34
|
-LL | pub(in b::string::String::newy) extern crate alloc as e;
- | ^^^^^^ `String` is a struct, not a module
+LL | pub(in crate::b::string::String::newy) extern crate alloc as e;
+ | ^^^^^^ `String` is a struct, not a module
error: aborting due to 1 previous error
diff --git a/tests/ui/deep.rs b/tests/ui/runtime/deep_recursion.rs
similarity index 84%
rename from tests/ui/deep.rs
rename to tests/ui/runtime/deep_recursion.rs
index 5a631d0..bf220f1 100644
--- a/tests/ui/deep.rs
+++ b/tests/ui/runtime/deep_recursion.rs
@@ -1,3 +1,5 @@
+//! Checks deep recursion behavior.
+
//@ run-pass
//@ ignore-emscripten apparently blows the stack
diff --git a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.fixed b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.fixed
index fbe415e..d685c49 100644
--- a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.fixed
+++ b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.fixed
@@ -1,3 +1,4 @@
+//@ edition: 2015
//@ run-rustfix
#![deny(absolute_paths_not_starting_with_crate)]
diff --git a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.rs b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.rs
index 72a2124..7a5ecf2 100644
--- a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.rs
+++ b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.rs
@@ -1,3 +1,4 @@
+//@ edition: 2015
//@ run-rustfix
#![deny(absolute_paths_not_starting_with_crate)]
diff --git a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.stderr b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.stderr
index 036b9cc..c0a322e 100644
--- a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.stderr
+++ b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.stderr
@@ -1,5 +1,5 @@
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-fully-qualified-paths.rs:18:25
+ --> $DIR/edition-lint-fully-qualified-paths.rs:19:25
|
LL | let _: <foo::Baz as ::foo::Foo>::Bar = ();
| ^^^^^^^^^^ help: use `crate`: `crate::foo::Foo`
@@ -7,13 +7,13 @@
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
note: the lint level is defined here
- --> $DIR/edition-lint-fully-qualified-paths.rs:3:9
+ --> $DIR/edition-lint-fully-qualified-paths.rs:4:9
|
LL | #![deny(absolute_paths_not_starting_with_crate)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-fully-qualified-paths.rs:18:25
+ --> $DIR/edition-lint-fully-qualified-paths.rs:19:25
|
LL | let _: <foo::Baz as ::foo::Foo>::Bar = ();
| ^^^^^^^^^^ help: use `crate`: `crate::foo::Foo`
@@ -23,7 +23,7 @@
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-fully-qualified-paths.rs:24:13
+ --> $DIR/edition-lint-fully-qualified-paths.rs:25:13
|
LL | let _: <::foo::Baz as foo::Foo>::Bar = ();
| ^^^^^^^^^^ help: use `crate`: `crate::foo::Baz`
diff --git a/tests/ui/rust-2018/edition-lint-nested-empty-paths.fixed b/tests/ui/rust-2018/edition-lint-nested-empty-paths.fixed
index 7ec4210..4a584a5 100644
--- a/tests/ui/rust-2018/edition-lint-nested-empty-paths.fixed
+++ b/tests/ui/rust-2018/edition-lint-nested-empty-paths.fixed
@@ -1,3 +1,4 @@
+//@ edition: 2015
//@ run-rustfix
#![deny(absolute_paths_not_starting_with_crate)]
diff --git a/tests/ui/rust-2018/edition-lint-nested-empty-paths.rs b/tests/ui/rust-2018/edition-lint-nested-empty-paths.rs
index 135908c..2baafbd 100644
--- a/tests/ui/rust-2018/edition-lint-nested-empty-paths.rs
+++ b/tests/ui/rust-2018/edition-lint-nested-empty-paths.rs
@@ -1,3 +1,4 @@
+//@ edition: 2015
//@ run-rustfix
#![deny(absolute_paths_not_starting_with_crate)]
diff --git a/tests/ui/rust-2018/edition-lint-nested-empty-paths.stderr b/tests/ui/rust-2018/edition-lint-nested-empty-paths.stderr
index 4174c2f..041572b 100644
--- a/tests/ui/rust-2018/edition-lint-nested-empty-paths.stderr
+++ b/tests/ui/rust-2018/edition-lint-nested-empty-paths.stderr
@@ -1,5 +1,5 @@
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-nested-empty-paths.rs:16:5
+ --> $DIR/edition-lint-nested-empty-paths.rs:17:5
|
LL | use foo::{bar::{baz::{}}};
| ^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}}}`
@@ -7,13 +7,13 @@
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
note: the lint level is defined here
- --> $DIR/edition-lint-nested-empty-paths.rs:3:9
+ --> $DIR/edition-lint-nested-empty-paths.rs:4:9
|
LL | #![deny(absolute_paths_not_starting_with_crate)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-nested-empty-paths.rs:20:5
+ --> $DIR/edition-lint-nested-empty-paths.rs:21:5
|
LL | use foo::{bar::{XX, baz::{}}};
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
@@ -22,7 +22,7 @@
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-nested-empty-paths.rs:20:5
+ --> $DIR/edition-lint-nested-empty-paths.rs:21:5
|
LL | use foo::{bar::{XX, baz::{}}};
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}`
@@ -32,7 +32,7 @@
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-nested-empty-paths.rs:26:5
+ --> $DIR/edition-lint-nested-empty-paths.rs:27:5
|
LL | use foo::{bar::{baz::{}, baz1::{}}};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`
@@ -41,7 +41,7 @@
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-nested-empty-paths.rs:26:5
+ --> $DIR/edition-lint-nested-empty-paths.rs:27:5
|
LL | use foo::{bar::{baz::{}, baz1::{}}};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}`
diff --git a/tests/ui/rust-2018/edition-lint-nested-paths.fixed b/tests/ui/rust-2018/edition-lint-nested-paths.fixed
index 93ccb2f..bf0038c 100644
--- a/tests/ui/rust-2018/edition-lint-nested-paths.fixed
+++ b/tests/ui/rust-2018/edition-lint-nested-paths.fixed
@@ -1,3 +1,4 @@
+//@ edition: 2015
//@ run-rustfix
#![deny(absolute_paths_not_starting_with_crate)]
diff --git a/tests/ui/rust-2018/edition-lint-nested-paths.rs b/tests/ui/rust-2018/edition-lint-nested-paths.rs
index 1c1d21d..87dc51a 100644
--- a/tests/ui/rust-2018/edition-lint-nested-paths.rs
+++ b/tests/ui/rust-2018/edition-lint-nested-paths.rs
@@ -1,3 +1,4 @@
+//@ edition: 2015
//@ run-rustfix
#![deny(absolute_paths_not_starting_with_crate)]
diff --git a/tests/ui/rust-2018/edition-lint-nested-paths.stderr b/tests/ui/rust-2018/edition-lint-nested-paths.stderr
index d059a25..4a70bb7 100644
--- a/tests/ui/rust-2018/edition-lint-nested-paths.stderr
+++ b/tests/ui/rust-2018/edition-lint-nested-paths.stderr
@@ -1,5 +1,5 @@
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-nested-paths.rs:5:5
+ --> $DIR/edition-lint-nested-paths.rs:6:5
|
LL | use foo::{a, b};
| ^^^^^^^^^^^ help: use `crate`: `crate::foo::{a, b}`
@@ -7,13 +7,13 @@
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
note: the lint level is defined here
- --> $DIR/edition-lint-nested-paths.rs:3:9
+ --> $DIR/edition-lint-nested-paths.rs:4:9
|
LL | #![deny(absolute_paths_not_starting_with_crate)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-nested-paths.rs:5:5
+ --> $DIR/edition-lint-nested-paths.rs:6:5
|
LL | use foo::{a, b};
| ^^^^^^^^^^^ help: use `crate`: `crate::foo::{a, b}`
@@ -23,7 +23,7 @@
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-nested-paths.rs:22:13
+ --> $DIR/edition-lint-nested-paths.rs:23:13
|
LL | use foo::{self as x, c};
| ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}`
@@ -32,7 +32,7 @@
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-nested-paths.rs:22:13
+ --> $DIR/edition-lint-nested-paths.rs:23:13
|
LL | use foo::{self as x, c};
| ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}`
diff --git a/tests/ui/rust-2018/edition-lint-paths.fixed b/tests/ui/rust-2018/edition-lint-paths.fixed
index 014bf91..9664b46 100644
--- a/tests/ui/rust-2018/edition-lint-paths.fixed
+++ b/tests/ui/rust-2018/edition-lint-paths.fixed
@@ -1,3 +1,4 @@
+//@ edition: 2015
//@ aux-build:edition-lint-paths.rs
//@ run-rustfix
diff --git a/tests/ui/rust-2018/edition-lint-paths.rs b/tests/ui/rust-2018/edition-lint-paths.rs
index 0ecd090..39cdad3 100644
--- a/tests/ui/rust-2018/edition-lint-paths.rs
+++ b/tests/ui/rust-2018/edition-lint-paths.rs
@@ -1,3 +1,4 @@
+//@ edition: 2015
//@ aux-build:edition-lint-paths.rs
//@ run-rustfix
diff --git a/tests/ui/rust-2018/edition-lint-paths.stderr b/tests/ui/rust-2018/edition-lint-paths.stderr
index 553a3bf..fde1733 100644
--- a/tests/ui/rust-2018/edition-lint-paths.stderr
+++ b/tests/ui/rust-2018/edition-lint-paths.stderr
@@ -1,5 +1,5 @@
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-paths.rs:11:9
+ --> $DIR/edition-lint-paths.rs:12:9
|
LL | use bar::Bar;
| ^^^^^^^^ help: use `crate`: `crate::bar::Bar`
@@ -7,13 +7,13 @@
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
note: the lint level is defined here
- --> $DIR/edition-lint-paths.rs:4:9
+ --> $DIR/edition-lint-paths.rs:5:9
|
LL | #![deny(absolute_paths_not_starting_with_crate)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-paths.rs:18:9
+ --> $DIR/edition-lint-paths.rs:19:9
|
LL | use bar;
| ^^^ help: use `crate`: `crate::bar`
@@ -22,7 +22,7 @@
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-paths.rs:24:9
+ --> $DIR/edition-lint-paths.rs:25:9
|
LL | use {main, Bar as SomethingElse};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}`
@@ -31,7 +31,7 @@
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-paths.rs:24:9
+ --> $DIR/edition-lint-paths.rs:25:9
|
LL | use {main, Bar as SomethingElse};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}`
@@ -41,7 +41,7 @@
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-paths.rs:24:9
+ --> $DIR/edition-lint-paths.rs:25:9
|
LL | use {main, Bar as SomethingElse};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{main, Bar as SomethingElse}`
@@ -51,7 +51,7 @@
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-paths.rs:39:5
+ --> $DIR/edition-lint-paths.rs:40:5
|
LL | use bar::Bar;
| ^^^^^^^^ help: use `crate`: `crate::bar::Bar`
@@ -60,7 +60,7 @@
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-paths.rs:51:9
+ --> $DIR/edition-lint-paths.rs:52:9
|
LL | use *;
| ^ help: use `crate`: `crate::*`
@@ -69,7 +69,7 @@
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-paths.rs:56:6
+ --> $DIR/edition-lint-paths.rs:57:6
|
LL | impl ::foo::SomeTrait for u32 {}
| ^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::SomeTrait`
@@ -78,7 +78,7 @@
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/edition-lint-paths.rs:61:13
+ --> $DIR/edition-lint-paths.rs:62:13
|
LL | let x = ::bar::Bar;
| ^^^^^^^^^^ help: use `crate`: `crate::bar::Bar`
diff --git a/tests/ui/rust-2018/extern-crate-rename.fixed b/tests/ui/rust-2018/extern-crate-rename.fixed
index 36b5280..b6b665f5 100644
--- a/tests/ui/rust-2018/extern-crate-rename.fixed
+++ b/tests/ui/rust-2018/extern-crate-rename.fixed
@@ -1,3 +1,4 @@
+//@ edition: 2015
//@ aux-build:edition-lint-paths.rs
//@ run-rustfix
diff --git a/tests/ui/rust-2018/extern-crate-rename.rs b/tests/ui/rust-2018/extern-crate-rename.rs
index 725e3aa..3257ab8 100644
--- a/tests/ui/rust-2018/extern-crate-rename.rs
+++ b/tests/ui/rust-2018/extern-crate-rename.rs
@@ -1,3 +1,4 @@
+//@ edition: 2015
//@ aux-build:edition-lint-paths.rs
//@ run-rustfix
diff --git a/tests/ui/rust-2018/extern-crate-rename.stderr b/tests/ui/rust-2018/extern-crate-rename.stderr
index 6b25120..36986c8 100644
--- a/tests/ui/rust-2018/extern-crate-rename.stderr
+++ b/tests/ui/rust-2018/extern-crate-rename.stderr
@@ -1,5 +1,5 @@
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/extern-crate-rename.rs:11:5
+ --> $DIR/extern-crate-rename.rs:12:5
|
LL | use my_crate::foo;
| ^^^^^^^^^^^^^ help: use `crate`: `crate::my_crate::foo`
@@ -7,7 +7,7 @@
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
note: the lint level is defined here
- --> $DIR/extern-crate-rename.rs:7:9
+ --> $DIR/extern-crate-rename.rs:8:9
|
LL | #![deny(absolute_paths_not_starting_with_crate)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/rust-2018/extern-crate-submod.fixed b/tests/ui/rust-2018/extern-crate-submod.fixed
index dc864d8..8657960 100644
--- a/tests/ui/rust-2018/extern-crate-submod.fixed
+++ b/tests/ui/rust-2018/extern-crate-submod.fixed
@@ -1,3 +1,4 @@
+//@ edition: 2015
//@ aux-build:edition-lint-paths.rs
//@ run-rustfix
diff --git a/tests/ui/rust-2018/extern-crate-submod.rs b/tests/ui/rust-2018/extern-crate-submod.rs
index f15bc6b..bf0a38d 100644
--- a/tests/ui/rust-2018/extern-crate-submod.rs
+++ b/tests/ui/rust-2018/extern-crate-submod.rs
@@ -1,3 +1,4 @@
+//@ edition: 2015
//@ aux-build:edition-lint-paths.rs
//@ run-rustfix
diff --git a/tests/ui/rust-2018/extern-crate-submod.stderr b/tests/ui/rust-2018/extern-crate-submod.stderr
index 0d45d32..85e26d7 100644
--- a/tests/ui/rust-2018/extern-crate-submod.stderr
+++ b/tests/ui/rust-2018/extern-crate-submod.stderr
@@ -1,5 +1,5 @@
error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition
- --> $DIR/extern-crate-submod.rs:18:5
+ --> $DIR/extern-crate-submod.rs:19:5
|
LL | use m::edition_lint_paths::foo;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::m::edition_lint_paths::foo`
@@ -7,7 +7,7 @@
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130>
note: the lint level is defined here
- --> $DIR/extern-crate-submod.rs:8:9
+ --> $DIR/extern-crate-submod.rs:9:9
|
LL | #![deny(absolute_paths_not_starting_with_crate)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/rust-2018/try-ident.fixed b/tests/ui/rust-2018/try-ident.fixed
index b1c446e..b514c6d 100644
--- a/tests/ui/rust-2018/try-ident.fixed
+++ b/tests/ui/rust-2018/try-ident.fixed
@@ -1,3 +1,4 @@
+//@ edition: 2015
//@ run-rustfix
//@ check-pass
diff --git a/tests/ui/rust-2018/try-ident.rs b/tests/ui/rust-2018/try-ident.rs
index 8e62f69..2b8bb92 100644
--- a/tests/ui/rust-2018/try-ident.rs
+++ b/tests/ui/rust-2018/try-ident.rs
@@ -1,3 +1,4 @@
+//@ edition: 2015
//@ run-rustfix
//@ check-pass
diff --git a/tests/ui/rust-2018/try-ident.stderr b/tests/ui/rust-2018/try-ident.stderr
index eaf4c23..aca623d 100644
--- a/tests/ui/rust-2018/try-ident.stderr
+++ b/tests/ui/rust-2018/try-ident.stderr
@@ -1,5 +1,5 @@
warning: `try` is a keyword in the 2018 edition
- --> $DIR/try-ident.rs:7:5
+ --> $DIR/try-ident.rs:8:5
|
LL | try();
| ^^^ help: you can use a raw identifier to stay compatible: `r#try`
@@ -7,14 +7,14 @@
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
note: the lint level is defined here
- --> $DIR/try-ident.rs:4:9
+ --> $DIR/try-ident.rs:5:9
|
LL | #![warn(rust_2018_compatibility)]
| ^^^^^^^^^^^^^^^^^^^^^^^
= note: `#[warn(keyword_idents_2018)]` implied by `#[warn(rust_2018_compatibility)]`
warning: `try` is a keyword in the 2018 edition
- --> $DIR/try-ident.rs:12:4
+ --> $DIR/try-ident.rs:13:4
|
LL | fn try() {
| ^^^ help: you can use a raw identifier to stay compatible: `r#try`
diff --git a/tests/ui/rust-2018/try-macro.fixed b/tests/ui/rust-2018/try-macro.fixed
index 98c48d6..f2d8cf2 100644
--- a/tests/ui/rust-2018/try-macro.fixed
+++ b/tests/ui/rust-2018/try-macro.fixed
@@ -1,5 +1,6 @@
// Test that `try!` macros are rewritten.
+//@ edition: 2015
//@ run-rustfix
//@ check-pass
diff --git a/tests/ui/rust-2018/try-macro.rs b/tests/ui/rust-2018/try-macro.rs
index 99480b2..fec8eaa 100644
--- a/tests/ui/rust-2018/try-macro.rs
+++ b/tests/ui/rust-2018/try-macro.rs
@@ -1,5 +1,6 @@
// Test that `try!` macros are rewritten.
+//@ edition: 2015
//@ run-rustfix
//@ check-pass
diff --git a/tests/ui/rust-2018/try-macro.stderr b/tests/ui/rust-2018/try-macro.stderr
index 095c755..20105e1 100644
--- a/tests/ui/rust-2018/try-macro.stderr
+++ b/tests/ui/rust-2018/try-macro.stderr
@@ -1,5 +1,5 @@
warning: `try` is a keyword in the 2018 edition
- --> $DIR/try-macro.rs:12:5
+ --> $DIR/try-macro.rs:13:5
|
LL | try!(x);
| ^^^ help: you can use a raw identifier to stay compatible: `r#try`
@@ -7,7 +7,7 @@
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
note: the lint level is defined here
- --> $DIR/try-macro.rs:6:9
+ --> $DIR/try-macro.rs:7:9
|
LL | #![warn(rust_2018_compatibility)]
| ^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/rustdoc/renamed-features-rustdoc_internals.rs b/tests/ui/rustdoc/renamed-features-rustdoc_internals.rs
index 739c624..2257130 100644
--- a/tests/ui/rustdoc/renamed-features-rustdoc_internals.rs
+++ b/tests/ui/rustdoc/renamed-features-rustdoc_internals.rs
@@ -1,3 +1,5 @@
+//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
+
#![feature(doc_keyword)] //~ ERROR
#![feature(doc_primitive)] //~ ERROR
#![crate_type = "lib"]
diff --git a/tests/ui/rustdoc/renamed-features-rustdoc_internals.stderr b/tests/ui/rustdoc/renamed-features-rustdoc_internals.stderr
index d0979ce..9c664da 100644
--- a/tests/ui/rustdoc/renamed-features-rustdoc_internals.stderr
+++ b/tests/ui/rustdoc/renamed-features-rustdoc_internals.stderr
@@ -1,17 +1,19 @@
error[E0557]: feature has been removed
- --> $DIR/renamed-features-rustdoc_internals.rs:1:12
+ --> $DIR/renamed-features-rustdoc_internals.rs:3:12
|
LL | #![feature(doc_keyword)]
| ^^^^^^^^^^^ feature has been removed
|
+ = note: removed in 1.58.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/90420> for more information
= note: merged into `#![feature(rustdoc_internals)]`
error[E0557]: feature has been removed
- --> $DIR/renamed-features-rustdoc_internals.rs:2:12
+ --> $DIR/renamed-features-rustdoc_internals.rs:4:12
|
LL | #![feature(doc_primitive)]
| ^^^^^^^^^^^^^ feature has been removed
|
+ = note: removed in 1.58.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/90420> for more information
= note: merged into `#![feature(rustdoc_internals)]`
error: aborting due to 2 previous errors
diff --git a/tests/ui/self/self-shadowing-import.rs b/tests/ui/self/self-shadowing-import.rs
index 85574da..78d04e0 100644
--- a/tests/ui/self/self-shadowing-import.rs
+++ b/tests/ui/self/self-shadowing-import.rs
@@ -9,7 +9,7 @@ pub mod a {
}
mod c {
- use a::b::a;
+ use crate::a::b::a;
pub fn bar() { assert_eq!(a::foo(), 1); }
}
diff --git a/tests/ui/sepcomp/auxiliary/sepcomp_lib.rs b/tests/ui/sepcomp/auxiliary/sepcomp_lib.rs
index 59efb3f..a0d91c5 100644
--- a/tests/ui/sepcomp/auxiliary/sepcomp_lib.rs
+++ b/tests/ui/sepcomp/auxiliary/sepcomp_lib.rs
@@ -13,8 +13,8 @@ pub fn two() -> usize {
}
pub mod c {
- use a::one;
- use b::two;
+ use crate::a::one;
+ use crate::b::two;
pub fn three() -> usize {
one() + two()
}
diff --git a/tests/ui/sepcomp/sepcomp-extern.rs b/tests/ui/sepcomp/sepcomp-extern.rs
index 6acd3a1..d0756c5 100644
--- a/tests/ui/sepcomp/sepcomp-extern.rs
+++ b/tests/ui/sepcomp/sepcomp-extern.rs
@@ -16,13 +16,13 @@ fn call1() -> usize {
mod a {
pub fn call2() -> usize {
- unsafe { ::foo() }
+ unsafe { crate::foo() }
}
}
mod b {
pub fn call3() -> usize {
- unsafe { ::foo() }
+ unsafe { crate::foo() }
}
}
diff --git a/tests/ui/sepcomp/sepcomp-fns-backwards.rs b/tests/ui/sepcomp/sepcomp-fns-backwards.rs
index 35326d1..c671771 100644
--- a/tests/ui/sepcomp/sepcomp-fns-backwards.rs
+++ b/tests/ui/sepcomp/sepcomp-fns-backwards.rs
@@ -12,13 +12,13 @@ fn pad() -> usize { 0 }
mod b {
pub fn three() -> usize {
- ::one() + ::a::two()
+ crate::one() + crate::a::two()
}
}
mod a {
pub fn two() -> usize {
- ::one() + ::one()
+ crate::one() + crate::one()
}
}
diff --git a/tests/ui/sepcomp/sepcomp-fns.rs b/tests/ui/sepcomp/sepcomp-fns.rs
index 399193e..1486a24 100644
--- a/tests/ui/sepcomp/sepcomp-fns.rs
+++ b/tests/ui/sepcomp/sepcomp-fns.rs
@@ -13,13 +13,13 @@ fn one() -> usize { 1 }
mod a {
pub fn two() -> usize {
- ::one() + ::one()
+ crate::one() + crate::one()
}
}
mod b {
pub fn three() -> usize {
- ::one() + ::a::two()
+ crate::one() + crate::a::two()
}
}
diff --git a/tests/ui/sepcomp/sepcomp-statics.rs b/tests/ui/sepcomp/sepcomp-statics.rs
index 580bb62..3fe897f 100644
--- a/tests/ui/sepcomp/sepcomp-statics.rs
+++ b/tests/ui/sepcomp/sepcomp-statics.rs
@@ -15,13 +15,13 @@ mod b {
// that `a` and `b` don't go into the same compilation unit.
fn pad() -> usize { 0 }
- pub static THREE: usize = ::ONE + ::a::TWO;
+ pub static THREE: usize = crate::ONE + crate::a::TWO;
}
mod a {
fn pad() -> usize { 0 }
- pub const TWO: usize = ::ONE + ::ONE;
+ pub const TWO: usize = crate::ONE + crate::ONE;
}
fn main() {
diff --git a/tests/ui/sepcomp/sepcomp-unwind.rs b/tests/ui/sepcomp/sepcomp-unwind.rs
index 8c25278..9559167 100644
--- a/tests/ui/sepcomp/sepcomp-unwind.rs
+++ b/tests/ui/sepcomp/sepcomp-unwind.rs
@@ -26,10 +26,10 @@ pub fn f() {
mod b {
pub fn g() {
- ::a::f();
+ crate::a::f();
}
}
fn main() {
- thread::spawn(move|| { ::b::g() }).join().unwrap_err();
+ thread::spawn(move|| { b::g() }).join().unwrap_err();
}
diff --git a/tests/ui/shadowed-use-visibility.rs b/tests/ui/shadowed-use-visibility.rs
index 6618126..5ce4103 100644
--- a/tests/ui/shadowed-use-visibility.rs
+++ b/tests/ui/shadowed-use-visibility.rs
@@ -5,7 +5,7 @@ mod foo {
pub fn f() {}
pub use self::f as bar;
- use foo as bar;
+ use crate::foo as bar;
}
fn main() {
diff --git a/tests/ui/shadowed/shadowed-trait-methods.rs b/tests/ui/shadowed/shadowed-trait-methods.rs
index f9c25d9..6cc5159 100644
--- a/tests/ui/shadowed/shadowed-trait-methods.rs
+++ b/tests/ui/shadowed/shadowed-trait-methods.rs
@@ -5,7 +5,7 @@ pub trait T { fn f(&self) {} }
impl T for () {}
}
-mod bar { pub use foo::T; }
+mod bar { pub use crate::foo::T; }
fn main() {
pub use bar::*;
diff --git a/tests/ui/shadowed/shadowed-use-visibility.rs b/tests/ui/shadowed/shadowed-use-visibility.rs
index 6b80197..070aeaf 100644
--- a/tests/ui/shadowed/shadowed-use-visibility.rs
+++ b/tests/ui/shadowed/shadowed-use-visibility.rs
@@ -1,15 +1,15 @@
mod foo {
pub fn f() {}
- use foo as bar;
+ use crate::foo as bar;
pub use self::f as bar;
}
mod bar {
- use foo::bar::f as g; //~ ERROR module import `bar` is private
+ use crate::foo::bar::f as g; //~ ERROR module import `bar` is private
- use foo as f;
- pub use foo::*;
+ use crate::foo as f;
+ pub use crate::foo::*;
}
use bar::f::f; //~ ERROR module import `f` is private
diff --git a/tests/ui/shadowed/shadowed-use-visibility.stderr b/tests/ui/shadowed/shadowed-use-visibility.stderr
index 1a642ae..b062341 100644
--- a/tests/ui/shadowed/shadowed-use-visibility.stderr
+++ b/tests/ui/shadowed/shadowed-use-visibility.stderr
@@ -1,14 +1,14 @@
error[E0603]: module import `bar` is private
- --> $DIR/shadowed-use-visibility.rs:9:14
+ --> $DIR/shadowed-use-visibility.rs:9:21
|
-LL | use foo::bar::f as g;
- | ^^^ private module import
+LL | use crate::foo::bar::f as g;
+ | ^^^ private module import
|
note: the module import `bar` is defined here...
--> $DIR/shadowed-use-visibility.rs:4:9
|
-LL | use foo as bar;
- | ^^^^^^^^^^
+LL | use crate::foo as bar;
+ | ^^^^^^^^^^^^^^^^^
note: ...and refers to the module `foo` which is defined here
--> $DIR/shadowed-use-visibility.rs:1:1
|
@@ -24,8 +24,8 @@
note: the module import `f` is defined here...
--> $DIR/shadowed-use-visibility.rs:11:9
|
-LL | use foo as f;
- | ^^^^^^^^
+LL | use crate::foo as f;
+ | ^^^^^^^^^^^^^^^
note: ...and refers to the module `foo` which is defined here
--> $DIR/shadowed-use-visibility.rs:1:1
|
diff --git a/tests/ui/sized/stack-overflow-trait-infer-98842.32bit.stderr b/tests/ui/sized/stack-overflow-trait-infer-98842.32bit.stderr
index 354ca78..d097b80 100644
--- a/tests/ui/sized/stack-overflow-trait-infer-98842.32bit.stderr
+++ b/tests/ui/sized/stack-overflow-trait-infer-98842.32bit.stderr
@@ -13,7 +13,7 @@
--> $DIR/stack-overflow-trait-infer-98842.rs:14:1
|
LL | const _: *const Foo = 0 as _;
- | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/sized/stack-overflow-trait-infer-98842.64bit.stderr b/tests/ui/sized/stack-overflow-trait-infer-98842.64bit.stderr
index 354ca78..d097b80 100644
--- a/tests/ui/sized/stack-overflow-trait-infer-98842.64bit.stderr
+++ b/tests/ui/sized/stack-overflow-trait-infer-98842.64bit.stderr
@@ -13,7 +13,7 @@
--> $DIR/stack-overflow-trait-infer-98842.rs:14:1
|
LL | const _: *const Foo = 0 as _;
- | ^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^ evaluation of `_` failed here
error: aborting due to 2 previous errors
diff --git a/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.rs b/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.rs
index 66a432b..baa664d 100644
--- a/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.rs
+++ b/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.rs
@@ -1,3 +1,5 @@
+//@ edition: 2015
+
#![warn(rust_2021_incompatible_closure_captures)]
fn main() {}
diff --git a/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.stderr b/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.stderr
index 5ecbedf..00b9a81 100644
--- a/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.stderr
+++ b/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.stderr
@@ -1,5 +1,5 @@
error[E0670]: `async fn` is not permitted in Rust 2015
- --> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.rs:8:16
+ --> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.rs:10:16
|
LL | pub(crate) async fn new(
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
@@ -8,7 +8,7 @@
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0412]: cannot find type `Duration` in this scope
- --> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.rs:10:19
+ --> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.rs:12:19
|
LL | interval: Duration,
| ^^^^^^^^ not found in this scope
diff --git a/tests/ui/span/dropck_arr_cycle_checked.rs b/tests/ui/span/dropck_arr_cycle_checked.rs
index a14db5f..adecb3f 100644
--- a/tests/ui/span/dropck_arr_cycle_checked.rs
+++ b/tests/ui/span/dropck_arr_cycle_checked.rs
@@ -19,7 +19,7 @@ pub fn next_count() -> usize {
}
mod id {
- use s;
+ use crate::s;
#[derive(Debug)]
pub struct Id {
orig_count: usize,
diff --git a/tests/ui/span/dropck_vec_cycle_checked.rs b/tests/ui/span/dropck_vec_cycle_checked.rs
index c5d2150..b015131c 100644
--- a/tests/ui/span/dropck_vec_cycle_checked.rs
+++ b/tests/ui/span/dropck_vec_cycle_checked.rs
@@ -16,7 +16,7 @@ pub fn next_count() -> usize {
}
mod id {
- use s;
+ use crate::s;
#[derive(Debug)]
pub struct Id {
orig_count: usize,
diff --git a/tests/ui/span/vec-must-not-hide-type-from-dropck.rs b/tests/ui/span/vec-must-not-hide-type-from-dropck.rs
index 9bfbfab..972ffef 100644
--- a/tests/ui/span/vec-must-not-hide-type-from-dropck.rs
+++ b/tests/ui/span/vec-must-not-hide-type-from-dropck.rs
@@ -31,7 +31,7 @@ pub fn next_count() -> usize {
}
mod id {
- use s;
+ use crate::s;
/// Id represents a globally unique identifier (global across the
/// current process, that is). When dropped, it automatically
diff --git a/tests/ui/span/visibility-ty-params.rs b/tests/ui/span/visibility-ty-params.rs
index 11c2cf4..05d93e5 100644
--- a/tests/ui/span/visibility-ty-params.rs
+++ b/tests/ui/span/visibility-ty-params.rs
@@ -3,11 +3,11 @@
}
struct S<T>(T);
-m!{ S<u8> } //~ ERROR unexpected generic arguments in path
- //~| ERROR failed to resolve: `S` is a struct, not a module [E0433]
+m!{ crate::S<u8> } //~ ERROR unexpected generic arguments in path
+ //~| ERROR failed to resolve: `S` is a struct, not a module [E0433]
mod m {
- m!{ m<> } //~ ERROR unexpected generic arguments in path
+ m!{ crate::m<> } //~ ERROR unexpected generic arguments in path
}
fn main() {}
diff --git a/tests/ui/span/visibility-ty-params.stderr b/tests/ui/span/visibility-ty-params.stderr
index 97d05c4..7b02d79 100644
--- a/tests/ui/span/visibility-ty-params.stderr
+++ b/tests/ui/span/visibility-ty-params.stderr
@@ -1,20 +1,20 @@
error: unexpected generic arguments in path
- --> $DIR/visibility-ty-params.rs:6:6
+ --> $DIR/visibility-ty-params.rs:6:13
|
-LL | m!{ S<u8> }
- | ^^^^
+LL | m!{ crate::S<u8> }
+ | ^^^^
error[E0433]: failed to resolve: `S` is a struct, not a module
- --> $DIR/visibility-ty-params.rs:6:5
+ --> $DIR/visibility-ty-params.rs:6:12
|
-LL | m!{ S<u8> }
- | ^ `S` is a struct, not a module
+LL | m!{ crate::S<u8> }
+ | ^ `S` is a struct, not a module
error: unexpected generic arguments in path
- --> $DIR/visibility-ty-params.rs:10:10
+ --> $DIR/visibility-ty-params.rs:10:17
|
-LL | m!{ m<> }
- | ^^
+LL | m!{ crate::m<> }
+ | ^^
error: aborting due to 3 previous errors
diff --git a/tests/ui/auxiliary/pub-and-stability.rs b/tests/ui/stability-attribute/auxiliary/pub-and-stability.rs
similarity index 100%
rename from tests/ui/auxiliary/pub-and-stability.rs
rename to tests/ui/stability-attribute/auxiliary/pub-and-stability.rs
diff --git a/tests/ui/explore-issue-38412.rs b/tests/ui/stability-attribute/stability-privacy-interaction.rs
similarity index 64%
rename from tests/ui/explore-issue-38412.rs
rename to tests/ui/stability-attribute/stability-privacy-interaction.rs
index 2008b12..e02816a 100644
--- a/tests/ui/explore-issue-38412.rs
+++ b/tests/ui/stability-attribute/stability-privacy-interaction.rs
@@ -1,28 +1,39 @@
+//! Regression test for issue #38412: interaction between stability attributes and privacy
+//!
+//! Tests that the compiler correctly handles the interaction between feature gates
+//! and privacy/visibility rules. Specifically verifies that enabled unstable features
+//! are accessible while disabled ones are properly rejected.
+
//@ aux-build:pub-and-stability.rs
-// A big point of this test is that we *enable* `unstable_declared`,
-// but do *not* enable `unstable_undeclared`. This way we can check
-// that the compiler is letting in uses of enabled feature-gated
-// stuff but still rejecting uses of disabled feature-gated stuff.
+// Enable `unstable_declared` but not `unstable_undeclared` to test
+// that the compiler allows enabled features but rejects disabled ones
#![feature(unstable_declared)]
extern crate pub_and_stability;
use pub_and_stability::{Record, Trait, Tuple};
fn main() {
- // Okay
+ // Test struct field access patterns
let Record { .. } = Record::new();
- // Okay
- let Record { a_stable_pub: _, a_unstable_declared_pub: _, .. } = Record::new();
+ let Record {
+ a_stable_pub: _,
+ a_unstable_declared_pub: _,
+ ..
+ } = Record::new();
- let Record { a_stable_pub: _, a_unstable_declared_pub: _, a_unstable_undeclared_pub: _, .. } =
- Record::new();
- //~^^ ERROR use of unstable library feature `unstable_undeclared`
+ let Record {
+ a_stable_pub: _,
+ a_unstable_declared_pub: _,
+ a_unstable_undeclared_pub: _, //~ ERROR use of unstable library feature `unstable_undeclared`
+ ..
+ } = Record::new();
let r = Record::new();
let t = Tuple::new();
+ // Test field access with different stability/privacy combinations
r.a_stable_pub;
r.a_unstable_declared_pub;
r.a_unstable_undeclared_pub; //~ ERROR use of unstable library feature
@@ -37,10 +48,12 @@ fn main() {
t.4; //~ ERROR is private
t.5; //~ ERROR is private
+ // Test trait method access
r.stable_trait_method();
r.unstable_declared_trait_method();
r.unstable_undeclared_trait_method(); //~ ERROR use of unstable library feature
+ // Test inherent method access
r.stable();
r.unstable_declared();
r.unstable_undeclared(); //~ ERROR use of unstable library feature
@@ -49,6 +62,7 @@ fn main() {
r.pub_mod(); //~ ERROR `pub_mod` is private
r.private(); //~ ERROR `private` is private
+ // Repeat tests for tuple struct
let t = Tuple::new();
t.stable_trait_method();
t.unstable_declared_trait_method();
diff --git a/tests/ui/explore-issue-38412.stderr b/tests/ui/stability-attribute/stability-privacy-interaction.stderr
similarity index 83%
rename from tests/ui/explore-issue-38412.stderr
rename to tests/ui/stability-attribute/stability-privacy-interaction.stderr
index fca5c73..991b3db 100644
--- a/tests/ui/explore-issue-38412.stderr
+++ b/tests/ui/stability-attribute/stability-privacy-interaction.stderr
@@ -1,15 +1,15 @@
error[E0658]: use of unstable library feature `unstable_undeclared`
- --> $DIR/explore-issue-38412.rs:19:63
+ --> $DIR/stability-privacy-interaction.rs:29:9
|
-LL | let Record { a_stable_pub: _, a_unstable_declared_pub: _, a_unstable_undeclared_pub: _, .. } =
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | a_unstable_undeclared_pub: _,
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #38412 <https://github.com/rust-lang/rust/issues/38412> for more information
= help: add `#![feature(unstable_undeclared)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: use of unstable library feature `unstable_undeclared`
- --> $DIR/explore-issue-38412.rs:28:5
+ --> $DIR/stability-privacy-interaction.rs:39:5
|
LL | r.a_unstable_undeclared_pub;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -19,25 +19,25 @@
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0616]: field `b_crate` of struct `Record` is private
- --> $DIR/explore-issue-38412.rs:29:7
+ --> $DIR/stability-privacy-interaction.rs:40:7
|
LL | r.b_crate;
| ^^^^^^^ private field
error[E0616]: field `c_mod` of struct `Record` is private
- --> $DIR/explore-issue-38412.rs:30:7
+ --> $DIR/stability-privacy-interaction.rs:41:7
|
LL | r.c_mod;
| ^^^^^ private field
error[E0616]: field `d_priv` of struct `Record` is private
- --> $DIR/explore-issue-38412.rs:31:7
+ --> $DIR/stability-privacy-interaction.rs:42:7
|
LL | r.d_priv;
| ^^^^^^ private field
error[E0658]: use of unstable library feature `unstable_undeclared`
- --> $DIR/explore-issue-38412.rs:35:5
+ --> $DIR/stability-privacy-interaction.rs:46:5
|
LL | t.2;
| ^^^
@@ -47,25 +47,25 @@
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0616]: field `3` of struct `pub_and_stability::Tuple` is private
- --> $DIR/explore-issue-38412.rs:36:7
+ --> $DIR/stability-privacy-interaction.rs:47:7
|
LL | t.3;
| ^ private field
error[E0616]: field `4` of struct `pub_and_stability::Tuple` is private
- --> $DIR/explore-issue-38412.rs:37:7
+ --> $DIR/stability-privacy-interaction.rs:48:7
|
LL | t.4;
| ^ private field
error[E0616]: field `5` of struct `pub_and_stability::Tuple` is private
- --> $DIR/explore-issue-38412.rs:38:7
+ --> $DIR/stability-privacy-interaction.rs:49:7
|
LL | t.5;
| ^ private field
error[E0658]: use of unstable library feature `unstable_undeclared`
- --> $DIR/explore-issue-38412.rs:42:7
+ --> $DIR/stability-privacy-interaction.rs:54:7
|
LL | r.unstable_undeclared_trait_method();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -75,7 +75,7 @@
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: use of unstable library feature `unstable_undeclared`
- --> $DIR/explore-issue-38412.rs:46:7
+ --> $DIR/stability-privacy-interaction.rs:59:7
|
LL | r.unstable_undeclared();
| ^^^^^^^^^^^^^^^^^^^
@@ -85,7 +85,7 @@
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0624]: method `pub_crate` is private
- --> $DIR/explore-issue-38412.rs:48:7
+ --> $DIR/stability-privacy-interaction.rs:61:7
|
LL | r.pub_crate();
| ^^^^^^^^^ private method
@@ -96,7 +96,7 @@
| ------------------------------------- private method defined here
error[E0624]: method `pub_mod` is private
- --> $DIR/explore-issue-38412.rs:49:7
+ --> $DIR/stability-privacy-interaction.rs:62:7
|
LL | r.pub_mod();
| ^^^^^^^ private method
@@ -107,7 +107,7 @@
| ----------------------------------------- private method defined here
error[E0624]: method `private` is private
- --> $DIR/explore-issue-38412.rs:50:7
+ --> $DIR/stability-privacy-interaction.rs:63:7
|
LL | r.private();
| ^^^^^^^ private method
@@ -118,7 +118,7 @@
| ------------------------ private method defined here
error[E0658]: use of unstable library feature `unstable_undeclared`
- --> $DIR/explore-issue-38412.rs:55:7
+ --> $DIR/stability-privacy-interaction.rs:69:7
|
LL | t.unstable_undeclared_trait_method();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -128,7 +128,7 @@
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: use of unstable library feature `unstable_undeclared`
- --> $DIR/explore-issue-38412.rs:59:7
+ --> $DIR/stability-privacy-interaction.rs:73:7
|
LL | t.unstable_undeclared();
| ^^^^^^^^^^^^^^^^^^^
@@ -138,7 +138,7 @@
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0624]: method `pub_crate` is private
- --> $DIR/explore-issue-38412.rs:61:7
+ --> $DIR/stability-privacy-interaction.rs:75:7
|
LL | t.pub_crate();
| ^^^^^^^^^ private method
@@ -149,7 +149,7 @@
| ------------------------------------- private method defined here
error[E0624]: method `pub_mod` is private
- --> $DIR/explore-issue-38412.rs:62:7
+ --> $DIR/stability-privacy-interaction.rs:76:7
|
LL | t.pub_mod();
| ^^^^^^^ private method
@@ -160,7 +160,7 @@
| ----------------------------------------- private method defined here
error[E0624]: method `private` is private
- --> $DIR/explore-issue-38412.rs:63:7
+ --> $DIR/stability-privacy-interaction.rs:77:7
|
LL | t.private();
| ^^^^^^^ private method
diff --git a/tests/ui/static/auxiliary/static_priv_by_default.rs b/tests/ui/static/auxiliary/static_priv_by_default.rs
index 39f9120..fe9aef4 100644
--- a/tests/ui/static/auxiliary/static_priv_by_default.rs
+++ b/tests/ui/static/auxiliary/static_priv_by_default.rs
@@ -31,11 +31,11 @@ pub enum reexported_d {}
}
pub mod bar {
- pub use foo::reexported_a as e;
- pub use foo::reexported_b as f;
- pub use foo::reexported_c as g;
- pub use foo::reexported_d as h;
- pub use foo::reexported_e as i;
+ pub use crate::foo::reexported_a as e;
+ pub use crate::foo::reexported_b as f;
+ pub use crate::foo::reexported_c as g;
+ pub use crate::foo::reexported_d as h;
+ pub use crate::foo::reexported_e as i;
}
pub static a: isize = 0;
diff --git a/tests/ui/static/static-extern-type.rs b/tests/ui/static/static-extern-type.rs
index 8b022a5..2597c22 100644
--- a/tests/ui/static/static-extern-type.rs
+++ b/tests/ui/static/static-extern-type.rs
@@ -10,7 +10,7 @@ pub mod a {
pub mod b {
#[repr(transparent)]
- pub struct TransparentType(::a::StartFn);
+ pub struct TransparentType(crate::a::StartFn);
extern "C" {
pub static start: TransparentType;
}
@@ -18,7 +18,7 @@ pub mod b {
pub mod c {
#[repr(C)]
- pub struct CType(u32, ::b::TransparentType);
+ pub struct CType(u32, crate::b::TransparentType);
extern "C" {
pub static start: CType;
}
diff --git a/tests/ui/statics/auxiliary/static_fn_inline_xc_aux.rs b/tests/ui/statics/auxiliary/static_fn_inline_xc_aux.rs
index 8d0f7f6..a739e8f 100644
--- a/tests/ui/statics/auxiliary/static_fn_inline_xc_aux.rs
+++ b/tests/ui/statics/auxiliary/static_fn_inline_xc_aux.rs
@@ -5,7 +5,7 @@ pub trait Num2 {
}
pub mod f64 {
- impl ::num::Num2 for f64 {
+ impl crate::num::Num2 for f64 {
#[inline]
fn from_int2(n: isize) -> f64 { return n as f64; }
}
diff --git a/tests/ui/statics/auxiliary/static_fn_trait_xc_aux.rs b/tests/ui/statics/auxiliary/static_fn_trait_xc_aux.rs
index b8aed2c..ab73bac 100644
--- a/tests/ui/statics/auxiliary/static_fn_trait_xc_aux.rs
+++ b/tests/ui/statics/auxiliary/static_fn_trait_xc_aux.rs
@@ -5,7 +5,7 @@ pub trait Num2 {
}
pub mod f64 {
- impl ::num::Num2 for f64 {
+ impl crate::num::Num2 for f64 {
fn from_int2(n: isize) -> f64 { return n as f64; }
}
}
diff --git a/tests/ui/statics/issue-14227.stderr b/tests/ui/statics/issue-14227.stderr
index 372a06a..f5ab231 100644
--- a/tests/ui/statics/issue-14227.stderr
+++ b/tests/ui/statics/issue-14227.stderr
@@ -2,7 +2,7 @@
--> $DIR/issue-14227.rs:4:21
|
LL | static CRASH: u32 = symbol;
- | ^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^ evaluation of `CRASH` failed here
error[E0133]: use of extern static is unsafe and requires unsafe function or block
--> $DIR/issue-14227.rs:4:21
diff --git a/tests/ui/statics/static-impl.rs b/tests/ui/statics/static-impl.rs
index 37f3cd1..5c8d20d 100644
--- a/tests/ui/statics/static-impl.rs
+++ b/tests/ui/statics/static-impl.rs
@@ -9,12 +9,12 @@ pub trait plus {
}
mod a {
- use plus;
+ use crate::plus;
impl plus for usize { fn plus(&self) -> isize { *self as isize + 20 } }
}
mod b {
- use plus;
+ use crate::plus;
impl plus for String { fn plus(&self) -> isize { 200 } }
}
diff --git a/tests/ui/statics/uninhabited-static.stderr b/tests/ui/statics/uninhabited-static.stderr
index 60268ad..f799a82f 100644
--- a/tests/ui/statics/uninhabited-static.stderr
+++ b/tests/ui/statics/uninhabited-static.stderr
@@ -47,13 +47,13 @@
--> $DIR/uninhabited-static.rs:12:31
|
LL | static VOID2: Void = unsafe { std::mem::transmute(()) };
- | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `VOID2` failed here
error[E0080]: constructing invalid value: encountered a value of uninhabited type `Void`
--> $DIR/uninhabited-static.rs:15:32
|
LL | static NEVER2: Void = unsafe { std::mem::transmute(()) };
- | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of static initializer failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `NEVER2` failed here
error: aborting due to 6 previous errors
diff --git a/tests/ui/structs-enums/issue-2718-a.rs b/tests/ui/structs-enums/issue-2718-a.rs
index 6c49158..f799a824 100644
--- a/tests/ui/structs-enums/issue-2718-a.rs
+++ b/tests/ui/structs-enums/issue-2718-a.rs
@@ -3,7 +3,7 @@
}
mod pingpong {
- use SendPacket;
+ use crate::SendPacket;
pub type Ping = SendPacket<Pong>;
pub struct Pong(SendPacket<Ping>);
//~^ ERROR recursive type `Pong` has infinite size
diff --git a/tests/ui/structs-enums/namespaced-enum-glob-import.rs b/tests/ui/structs-enums/namespaced-enum-glob-import.rs
index e8a709d..82742a9 100644
--- a/tests/ui/structs-enums/namespaced-enum-glob-import.rs
+++ b/tests/ui/structs-enums/namespaced-enum-glob-import.rs
@@ -14,7 +14,7 @@ pub fn foo() {}
}
mod m {
- pub use m2::Foo::*;
+ pub use crate::m2::Foo::*;
}
fn _f(f: m2::Foo) {
diff --git a/tests/ui/structs/default-field-values/invalid-const.stderr b/tests/ui/structs/default-field-values/invalid-const.stderr
index f4a74ef..545783e 100644
--- a/tests/ui/structs/default-field-values/invalid-const.stderr
+++ b/tests/ui/structs/default-field-values/invalid-const.stderr
@@ -2,7 +2,7 @@
--> $DIR/invalid-const.rs:5:19
|
LL | pub bax: u8 = panic!("asdf"),
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `Bat::bax::{constant#0}` failed here
error[E0080]: attempt to compute `130_u8 + 130_u8`, which would overflow
--> $DIR/invalid-const.rs:11:19
diff --git a/tests/ui/suggestions/abi-typo.fixed b/tests/ui/suggestions/abi-typo.fixed
index 44fa80f..ae507c3 100644
--- a/tests/ui/suggestions/abi-typo.fixed
+++ b/tests/ui/suggestions/abi-typo.fixed
@@ -1,6 +1,6 @@
//@ run-rustfix
-extern "cdecl" fn cdedl() {} //~ ERROR invalid ABI
+extern "system" fn systen() {} //~ ERROR invalid ABI
fn main() {
- cdedl();
+ systen();
}
diff --git a/tests/ui/suggestions/abi-typo.rs b/tests/ui/suggestions/abi-typo.rs
index 3d5c23e..c40bd80 100644
--- a/tests/ui/suggestions/abi-typo.rs
+++ b/tests/ui/suggestions/abi-typo.rs
@@ -1,6 +1,6 @@
//@ run-rustfix
-extern "cdedl" fn cdedl() {} //~ ERROR invalid ABI
+extern "systen" fn systen() {} //~ ERROR invalid ABI
fn main() {
- cdedl();
+ systen();
}
diff --git a/tests/ui/suggestions/abi-typo.stderr b/tests/ui/suggestions/abi-typo.stderr
index 4d89ac1..a8b4d36 100644
--- a/tests/ui/suggestions/abi-typo.stderr
+++ b/tests/ui/suggestions/abi-typo.stderr
@@ -1,14 +1,14 @@
-error[E0703]: invalid ABI: found `cdedl`
+error[E0703]: invalid ABI: found `systen`
--> $DIR/abi-typo.rs:2:8
|
-LL | extern "cdedl" fn cdedl() {}
- | ^^^^^^^ invalid ABI
+LL | extern "systen" fn systen() {}
+ | ^^^^^^^^ invalid ABI
|
= note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions
-help: there's a similarly named valid ABI `cdecl`
+help: there's a similarly named valid ABI `system`
|
-LL - extern "cdedl" fn cdedl() {}
-LL + extern "cdecl" fn cdedl() {}
+LL - extern "systen" fn systen() {}
+LL + extern "system" fn systen() {}
|
error: aborting due to 1 previous error
diff --git a/tests/ui/suggestions/double-reference-ty-in-self-ty.rs b/tests/ui/suggestions/double-reference-ty-in-self-ty.rs
new file mode 100644
index 0000000..4ac13f0
--- /dev/null
+++ b/tests/ui/suggestions/double-reference-ty-in-self-ty.rs
@@ -0,0 +1,12 @@
+// issue#135863
+
+struct A;
+
+impl A {
+ fn len(self: &&A) {}
+}
+
+fn main() {
+ A.len();
+ //~^ ERROR: no method named `len` found for struct `A` in the current scope
+}
diff --git a/tests/ui/suggestions/double-reference-ty-in-self-ty.stderr b/tests/ui/suggestions/double-reference-ty-in-self-ty.stderr
new file mode 100644
index 0000000..a718234
--- /dev/null
+++ b/tests/ui/suggestions/double-reference-ty-in-self-ty.stderr
@@ -0,0 +1,19 @@
+error[E0599]: no method named `len` found for struct `A` in the current scope
+ --> $DIR/double-reference-ty-in-self-ty.rs:10:7
+ |
+LL | struct A;
+ | -------- method `len` not found for this struct
+...
+LL | fn len(self: &&A) {}
+ | --- the method is available for `&A` here
+...
+LL | A.len();
+ | ^^^ method not found in `A`
+ |
+ = help: items from traits can only be used if the trait is implemented and in scope
+ = note: the following trait defines an item `len`, perhaps you need to implement it:
+ candidate #1: `ExactSizeIterator`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.rs b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.rs
index 2893bbc..63fe5eb 100644
--- a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.rs
+++ b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.rs
@@ -1,16 +1,15 @@
-#![allow(bare_trait_objects)]
trait A: Sized {
- fn f(a: A) -> A;
+ fn f(a: dyn A) -> dyn A;
//~^ ERROR associated item referring to unboxed trait object for its own trait
//~| ERROR the trait `A` is not dyn compatible
}
trait B {
- fn f(a: B) -> B;
+ fn f(a: dyn B) -> dyn B;
//~^ ERROR associated item referring to unboxed trait object for its own trait
//~| ERROR the trait `B` is not dyn compatible
}
trait C {
- fn f(&self, a: C) -> C;
+ fn f(&self, a: dyn C) -> dyn C;
}
fn main() {}
diff --git a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.stderr b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.stderr
index f4b669d..e8384af 100644
--- a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.stderr
+++ b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.stderr
@@ -1,26 +1,26 @@
error: associated item referring to unboxed trait object for its own trait
- --> $DIR/dyn-incompatible-trait-should-use-self.rs:3:13
+ --> $DIR/dyn-incompatible-trait-should-use-self.rs:2:13
|
LL | trait A: Sized {
| - in this trait
-LL | fn f(a: A) -> A;
- | ^ ^
+LL | fn f(a: dyn A) -> dyn A;
+ | ^^^^^ ^^^^^
|
help: you might have meant to use `Self` to refer to the implementing type
|
-LL - fn f(a: A) -> A;
+LL - fn f(a: dyn A) -> dyn A;
LL + fn f(a: Self) -> Self;
|
error[E0038]: the trait `A` is not dyn compatible
- --> $DIR/dyn-incompatible-trait-should-use-self.rs:3:13
+ --> $DIR/dyn-incompatible-trait-should-use-self.rs:2:13
|
-LL | fn f(a: A) -> A;
- | ^ `A` is not dyn compatible
+LL | fn f(a: dyn A) -> dyn A;
+ | ^^^^^ `A` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
- --> $DIR/dyn-incompatible-trait-should-use-self.rs:2:10
+ --> $DIR/dyn-incompatible-trait-should-use-self.rs:1:10
|
LL | trait A: Sized {
| - ^^^^^ ...because it requires `Self: Sized`
@@ -28,41 +28,41 @@
| this trait is not dyn compatible...
error: associated item referring to unboxed trait object for its own trait
- --> $DIR/dyn-incompatible-trait-should-use-self.rs:8:13
+ --> $DIR/dyn-incompatible-trait-should-use-self.rs:7:13
|
LL | trait B {
| - in this trait
-LL | fn f(a: B) -> B;
- | ^ ^
+LL | fn f(a: dyn B) -> dyn B;
+ | ^^^^^ ^^^^^
|
help: you might have meant to use `Self` to refer to the implementing type
|
-LL - fn f(a: B) -> B;
+LL - fn f(a: dyn B) -> dyn B;
LL + fn f(a: Self) -> Self;
|
error[E0038]: the trait `B` is not dyn compatible
- --> $DIR/dyn-incompatible-trait-should-use-self.rs:8:13
+ --> $DIR/dyn-incompatible-trait-should-use-self.rs:7:13
|
-LL | fn f(a: B) -> B;
- | ^ `B` is not dyn compatible
+LL | fn f(a: dyn B) -> dyn B;
+ | ^^^^^ `B` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
- --> $DIR/dyn-incompatible-trait-should-use-self.rs:8:8
+ --> $DIR/dyn-incompatible-trait-should-use-self.rs:7:8
|
LL | trait B {
| - this trait is not dyn compatible...
-LL | fn f(a: B) -> B;
+LL | fn f(a: dyn B) -> dyn B;
| ^ ...because associated function `f` has no `self` parameter
help: consider turning `f` into a method by giving it a `&self` argument
|
-LL | fn f(&self, a: B) -> B;
+LL | fn f(&self, a: dyn B) -> dyn B;
| ++++++
help: alternatively, consider constraining `f` so it does not apply to trait objects
|
-LL | fn f(a: B) -> B where Self: Sized;
- | +++++++++++++++++
+LL | fn f(a: dyn B) -> dyn B where Self: Sized;
+ | +++++++++++++++++
error: aborting due to 4 previous errors
diff --git a/tests/ui/suggestions/ice-unwrap-probe-many-result-125876.rs b/tests/ui/suggestions/ice-unwrap-probe-many-result-125876.rs
index efa296d..d10b3be 100644
--- a/tests/ui/suggestions/ice-unwrap-probe-many-result-125876.rs
+++ b/tests/ui/suggestions/ice-unwrap-probe-many-result-125876.rs
@@ -1,4 +1,5 @@
// Regression test for ICE #125876
+//@ edition: 2015
fn main() {
std::ptr::from_ref(num).cast_mut().as_deref();
diff --git a/tests/ui/suggestions/ice-unwrap-probe-many-result-125876.stderr b/tests/ui/suggestions/ice-unwrap-probe-many-result-125876.stderr
index f943688..696151b 100644
--- a/tests/ui/suggestions/ice-unwrap-probe-many-result-125876.stderr
+++ b/tests/ui/suggestions/ice-unwrap-probe-many-result-125876.stderr
@@ -1,11 +1,11 @@
error[E0425]: cannot find value `num` in this scope
- --> $DIR/ice-unwrap-probe-many-result-125876.rs:4:24
+ --> $DIR/ice-unwrap-probe-many-result-125876.rs:5:24
|
LL | std::ptr::from_ref(num).cast_mut().as_deref();
| ^^^ not found in this scope
warning: type annotations needed
- --> $DIR/ice-unwrap-probe-many-result-125876.rs:4:29
+ --> $DIR/ice-unwrap-probe-many-result-125876.rs:5:29
|
LL | std::ptr::from_ref(num).cast_mut().as_deref();
| ^^^^^^^^
@@ -15,7 +15,7 @@
= note: `#[warn(tyvar_behind_raw_pointer)]` on by default
warning: type annotations needed
- --> $DIR/ice-unwrap-probe-many-result-125876.rs:4:40
+ --> $DIR/ice-unwrap-probe-many-result-125876.rs:5:40
|
LL | std::ptr::from_ref(num).cast_mut().as_deref();
| ^^^^^^^^
@@ -24,7 +24,7 @@
= note: for more information, see issue #46906 <https://github.com/rust-lang/rust/issues/46906>
error[E0599]: no method named `as_deref` found for raw pointer `*mut _` in the current scope
- --> $DIR/ice-unwrap-probe-many-result-125876.rs:4:40
+ --> $DIR/ice-unwrap-probe-many-result-125876.rs:5:40
|
LL | std::ptr::from_ref(num).cast_mut().as_deref();
| ^^^^^^^^
diff --git a/tests/ui/suggestions/issue-116434-2015.rs b/tests/ui/suggestions/issue-116434-2015.rs
index 1518765..bad9d02 100644
--- a/tests/ui/suggestions/issue-116434-2015.rs
+++ b/tests/ui/suggestions/issue-116434-2015.rs
@@ -1,3 +1,5 @@
+//@ edition: 2015
+
trait Foo {
type Clone;
fn foo() -> Clone;
diff --git a/tests/ui/suggestions/issue-116434-2015.stderr b/tests/ui/suggestions/issue-116434-2015.stderr
index 07a2544..a0a99cc 100644
--- a/tests/ui/suggestions/issue-116434-2015.stderr
+++ b/tests/ui/suggestions/issue-116434-2015.stderr
@@ -1,5 +1,5 @@
warning: trait objects without an explicit `dyn` are deprecated
- --> $DIR/issue-116434-2015.rs:3:17
+ --> $DIR/issue-116434-2015.rs:5:17
|
LL | fn foo() -> Clone;
| ^^^^^
@@ -13,7 +13,7 @@
| +++
warning: trait objects without an explicit `dyn` are deprecated
- --> $DIR/issue-116434-2015.rs:3:17
+ --> $DIR/issue-116434-2015.rs:5:17
|
LL | fn foo() -> Clone;
| ^^^^^
@@ -27,7 +27,7 @@
| +++
error[E0038]: the trait `Clone` is not dyn compatible
- --> $DIR/issue-116434-2015.rs:3:17
+ --> $DIR/issue-116434-2015.rs:5:17
|
LL | fn foo() -> Clone;
| ^^^^^ `Clone` is not dyn compatible
@@ -41,7 +41,7 @@
| ++++++
warning: trait objects without an explicit `dyn` are deprecated
- --> $DIR/issue-116434-2015.rs:18:20
+ --> $DIR/issue-116434-2015.rs:20:20
|
LL | fn handle() -> DbHandle;
| ^^^^^^^^
@@ -54,7 +54,7 @@
| +++
warning: trait objects without an explicit `dyn` are deprecated
- --> $DIR/issue-116434-2015.rs:18:20
+ --> $DIR/issue-116434-2015.rs:20:20
|
LL | fn handle() -> DbHandle;
| ^^^^^^^^
@@ -68,14 +68,14 @@
| +++
error[E0038]: the trait `DbHandle` is not dyn compatible
- --> $DIR/issue-116434-2015.rs:18:20
+ --> $DIR/issue-116434-2015.rs:20:20
|
LL | fn handle() -> DbHandle;
| ^^^^^^^^ `DbHandle` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
- --> $DIR/issue-116434-2015.rs:14:17
+ --> $DIR/issue-116434-2015.rs:16:17
|
LL | trait DbHandle: Sized {}
| -------- ^^^^^ ...because it requires `Self: Sized`
diff --git a/tests/ui/suggestions/issue-61963.rs b/tests/ui/suggestions/issue-61963.rs
index 2fafe62..77e4b21 100644
--- a/tests/ui/suggestions/issue-61963.rs
+++ b/tests/ui/suggestions/issue-61963.rs
@@ -1,3 +1,4 @@
+//@ edition: 2015
//@ proc-macro: issue-61963.rs
//@ proc-macro: issue-61963-1.rs
#![deny(bare_trait_objects)]
diff --git a/tests/ui/suggestions/issue-61963.stderr b/tests/ui/suggestions/issue-61963.stderr
index 734c88f..ef11efe 100644
--- a/tests/ui/suggestions/issue-61963.stderr
+++ b/tests/ui/suggestions/issue-61963.stderr
@@ -1,5 +1,5 @@
error: trait objects without an explicit `dyn` are deprecated
- --> $DIR/issue-61963.rs:22:14
+ --> $DIR/issue-61963.rs:23:14
|
LL | bar: Box<Bar>,
| ^^^
@@ -7,7 +7,7 @@
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
note: the lint level is defined here
- --> $DIR/issue-61963.rs:3:9
+ --> $DIR/issue-61963.rs:4:9
|
LL | #![deny(bare_trait_objects)]
| ^^^^^^^^^^^^^^^^^^
@@ -17,7 +17,7 @@
| +++
error: trait objects without an explicit `dyn` are deprecated
- --> $DIR/issue-61963.rs:18:1
+ --> $DIR/issue-61963.rs:19:1
|
LL | pub struct Foo {
| ^^^
diff --git a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
index 41cb2ee..0aa33d3 100644
--- a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
+++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
@@ -101,15 +101,17 @@
error[E0621]: explicit lifetime required in the type of `dest`
--> $DIR/missing-lifetimes-in-signature.rs:73:5
|
-LL | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
- | ------ help: add explicit lifetime `'a` to the type of `dest`: `&'a mut T`
-...
LL | / move || {
LL | |
LL | |
LL | | *dest = g.get();
LL | | }
| |_____^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `dest`
+ |
+LL | fn bat<'a, G: 'a, T>(g: G, dest: &'a mut T) -> impl FnOnce() + '_ + 'a
+ | ++
error[E0309]: the parameter type `G` may not live long enough
--> $DIR/missing-lifetimes-in-signature.rs:85:5
diff --git a/tests/ui/suggestions/missing-lifetime-specifier.rs b/tests/ui/suggestions/missing-lifetime-specifier.rs
index a957477..88d9736 100644
--- a/tests/ui/suggestions/missing-lifetime-specifier.rs
+++ b/tests/ui/suggestions/missing-lifetime-specifier.rs
@@ -7,7 +7,6 @@
// Different number of duplicated diagnostics on different targets
//@ compile-flags: -Zdeduplicate-diagnostics=yes
-#![allow(bare_trait_objects)]
use std::cell::RefCell;
use std::collections::HashMap;
@@ -28,7 +27,7 @@ trait Tar<'t, 'k, I> {}
//~^ ERROR missing lifetime specifiers
}
thread_local! {
- static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
+ static b: RefCell<HashMap<i32, Vec<Vec<&dyn Bar>>>> = RefCell::new(HashMap::new());
//~^ ERROR missing lifetime specifiers
}
thread_local! {
@@ -36,7 +35,7 @@ trait Tar<'t, 'k, I> {}
//~^ ERROR missing lifetime specifiers
}
thread_local! {
- static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
+ static d: RefCell<HashMap<i32, Vec<Vec<&dyn Tar<i32>>>>> = RefCell::new(HashMap::new());
//~^ ERROR missing lifetime specifiers
}
@@ -45,8 +44,9 @@ trait Tar<'t, 'k, I> {}
//~^ ERROR union takes 2 lifetime arguments but 1 lifetime argument
}
thread_local! {
- static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
- //~^ ERROR trait takes 2 lifetime arguments but 1 lifetime argument was supplied
+ static f: RefCell<HashMap<i32, Vec<Vec<&dyn Tar<'static, i32>>>>> =
+ RefCell::new(HashMap::new());
+ //~^^ ERROR trait takes 2 lifetime arguments but 1 lifetime argument was supplied
//~| ERROR missing lifetime specifier
}
diff --git a/tests/ui/suggestions/missing-lifetime-specifier.stderr b/tests/ui/suggestions/missing-lifetime-specifier.stderr
index 1fdbf3b..b8c5815 100644
--- a/tests/ui/suggestions/missing-lifetime-specifier.stderr
+++ b/tests/ui/suggestions/missing-lifetime-specifier.stderr
@@ -1,5 +1,5 @@
error[E0106]: missing lifetime specifiers
- --> $DIR/missing-lifetime-specifier.rs:27:44
+ --> $DIR/missing-lifetime-specifier.rs:26:44
|
LL | static a: RefCell<HashMap<i32, Vec<Vec<Foo>>>> = RefCell::new(HashMap::new());
| ^^^ expected 2 lifetime parameters
@@ -11,21 +11,21 @@
| ++++++++++++++++++
error[E0106]: missing lifetime specifiers
- --> $DIR/missing-lifetime-specifier.rs:31:44
+ --> $DIR/missing-lifetime-specifier.rs:30:44
|
-LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
- | ^^^^ expected 2 lifetime parameters
+LL | static b: RefCell<HashMap<i32, Vec<Vec<&dyn Bar>>>> = RefCell::new(HashMap::new());
+ | ^ ^^^ expected 2 lifetime parameters
| |
| expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
-LL | static b: RefCell<HashMap<i32, Vec<Vec<&'static Bar<'static, 'static>>>>> = RefCell::new(HashMap::new());
- | +++++++ ++++++++++++++++++
+LL | static b: RefCell<HashMap<i32, Vec<Vec<&'static dyn Bar<'static, 'static>>>>> = RefCell::new(HashMap::new());
+ | +++++++ ++++++++++++++++++
error[E0106]: missing lifetime specifiers
- --> $DIR/missing-lifetime-specifier.rs:35:47
+ --> $DIR/missing-lifetime-specifier.rs:34:47
|
LL | static c: RefCell<HashMap<i32, Vec<Vec<Qux<i32>>>>> = RefCell::new(HashMap::new());
| ^ expected 2 lifetime parameters
@@ -37,33 +37,38 @@
| +++++++++++++++++
error[E0106]: missing lifetime specifiers
- --> $DIR/missing-lifetime-specifier.rs:39:44
+ --> $DIR/missing-lifetime-specifier.rs:38:44
|
-LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
- | ^ ^ expected 2 lifetime parameters
+LL | static d: RefCell<HashMap<i32, Vec<Vec<&dyn Tar<i32>>>>> = RefCell::new(HashMap::new());
+ | ^ ^ expected 2 lifetime parameters
| |
| expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
-LL | static d: RefCell<HashMap<i32, Vec<Vec<&'static Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
- | +++++++ +++++++++++++++++
+LL | static d: RefCell<HashMap<i32, Vec<Vec<&'static dyn Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
+ | +++++++ +++++++++++++++++
error[E0106]: missing lifetime specifier
- --> $DIR/missing-lifetime-specifier.rs:48:44
+ --> $DIR/missing-lifetime-specifier.rs:47:44
|
-LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
+LL | static f: RefCell<HashMap<i32, Vec<Vec<&dyn Tar<'static, i32>>>>> =
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
-LL | static f: RefCell<HashMap<i32, Vec<Vec<&'static Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
+LL | static f: RefCell<HashMap<i32, Vec<Vec<&'static dyn Tar<'static, i32>>>>> =
| +++++++
+help: instead, you are more likely to want to return an owned value
+ |
+LL - static f: RefCell<HashMap<i32, Vec<Vec<&dyn Tar<'static, i32>>>>> =
+LL + static f: RefCell<HashMap<i32, Vec<Vec<dyn Tar<'static, i32>>>>> =
+ |
error[E0107]: union takes 2 lifetime arguments but 1 lifetime argument was supplied
- --> $DIR/missing-lifetime-specifier.rs:44:44
+ --> $DIR/missing-lifetime-specifier.rs:43:44
|
LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new());
| ^^^ ------- supplied 1 lifetime argument
@@ -71,7 +76,7 @@
| expected 2 lifetime arguments
|
note: union defined here, with 2 lifetime parameters: `'t`, `'k`
- --> $DIR/missing-lifetime-specifier.rs:20:11
+ --> $DIR/missing-lifetime-specifier.rs:19:11
|
LL | pub union Qux<'t, 'k, I> {
| ^^^ -- --
@@ -81,22 +86,22 @@
| +++++++++
error[E0107]: trait takes 2 lifetime arguments but 1 lifetime argument was supplied
- --> $DIR/missing-lifetime-specifier.rs:48:45
+ --> $DIR/missing-lifetime-specifier.rs:47:49
|
-LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
- | ^^^ ------- supplied 1 lifetime argument
- | |
- | expected 2 lifetime arguments
+LL | static f: RefCell<HashMap<i32, Vec<Vec<&dyn Tar<'static, i32>>>>> =
+ | ^^^ ------- supplied 1 lifetime argument
+ | |
+ | expected 2 lifetime arguments
|
note: trait defined here, with 2 lifetime parameters: `'t`, `'k`
- --> $DIR/missing-lifetime-specifier.rs:24:7
+ --> $DIR/missing-lifetime-specifier.rs:23:7
|
LL | trait Tar<'t, 'k, I> {}
| ^^^ -- --
help: add missing lifetime argument
|
-LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
- | +++++++++
+LL | static f: RefCell<HashMap<i32, Vec<Vec<&dyn Tar<'static, 'static, i32>>>>> =
+ | +++++++++
error: aborting due to 7 previous errors
diff --git a/tests/ui/symbol-names/impl1.rs b/tests/ui/symbol-names/impl1.rs
index 694cd89..0fdf564 100644
--- a/tests/ui/symbol-names/impl1.rs
+++ b/tests/ui/symbol-names/impl1.rs
@@ -26,7 +26,7 @@ fn bar() { }
}
mod bar {
- use foo::Foo;
+ use crate::foo::Foo;
impl Foo {
#[rustc_symbol_name]
diff --git a/tests/ui/symbol-names/issue-53912.rs b/tests/ui/symbol-names/issue-53912.rs
index 194416c..ba28316 100644
--- a/tests/ui/symbol-names/issue-53912.rs
+++ b/tests/ui/symbol-names/issue-53912.rs
@@ -12,13 +12,13 @@ mod llvm {
mod foo {
pub(crate) struct Foo<T>(T);
- impl Foo<::llvm::Foo> {
+ impl Foo<crate::llvm::Foo> {
pub(crate) fn foo() {
for _ in 0..0 {
- for _ in &[::dummy()] {
- ::dummy();
- ::dummy();
- ::dummy();
+ for _ in &[crate::dummy()] {
+ crate::dummy();
+ crate::dummy();
+ crate::dummy();
}
}
}
diff --git a/tests/ui/symbol-names/issue-60925.rs b/tests/ui/symbol-names/issue-60925.rs
index ca0f21b..24969fc 100644
--- a/tests/ui/symbol-names/issue-60925.rs
+++ b/tests/ui/symbol-names/issue-60925.rs
@@ -17,7 +17,7 @@ mod llvm {
mod foo {
pub(crate) struct Foo<T>(T);
- impl Foo<::llvm::Foo> {
+ impl Foo<crate::llvm::Foo> {
#[rustc_symbol_name]
//[legacy]~^ ERROR symbol-name(_ZN11issue_609253foo37Foo$LT$issue_60925..llv$u6d$..Foo$GT$3foo
//[legacy]~| ERROR demangling(issue_60925::foo::Foo<issue_60925::llvm::Foo>::foo
@@ -27,10 +27,10 @@ impl Foo<::llvm::Foo> {
//[v0]~| ERROR demangling-alt(<issue_60925::foo::Foo<issue_60925::llvm::Foo>>::foo)
pub(crate) fn foo() {
for _ in 0..0 {
- for _ in &[::dummy()] {
- ::dummy();
- ::dummy();
- ::dummy();
+ for _ in &[crate::dummy()] {
+ crate::dummy();
+ crate::dummy();
+ crate::dummy();
}
}
}
diff --git a/tests/ui/custom-test-frameworks-simple.rs b/tests/ui/test-attrs/custom_test_frameworks_simple.rs
similarity index 82%
rename from tests/ui/custom-test-frameworks-simple.rs
rename to tests/ui/test-attrs/custom_test_frameworks_simple.rs
index 3fb7de6..54a4e40 100644
--- a/tests/ui/custom-test-frameworks-simple.rs
+++ b/tests/ui/test-attrs/custom_test_frameworks_simple.rs
@@ -1,3 +1,5 @@
+//! Checks run with a custom test framework and indexed test functions.
+
//@ compile-flags: --test
//@ run-pass
diff --git a/tests/ui/threads-sendsync/thread-local-syntax.rs b/tests/ui/threads-sendsync/thread-local-syntax.rs
index 2cf91f0..9492e1c 100644
--- a/tests/ui/threads-sendsync/thread-local-syntax.rs
+++ b/tests/ui/threads-sendsync/thread-local-syntax.rs
@@ -13,7 +13,7 @@ mod bar {
// look at these restrictions!!
pub(crate) static BAZ: usize = 0;
- pub(in foo) static QUUX: usize = 0;
+ pub(in crate::foo) static QUUX: usize = 0;
}
thread_local!(static SPLOK: u32 = 0);
}
diff --git a/tests/ui/track-diagnostics/track.stderr b/tests/ui/track-diagnostics/track.stderr
index d2908bb..527c0d1 100644
--- a/tests/ui/track-diagnostics/track.stderr
+++ b/tests/ui/track-diagnostics/track.stderr
@@ -10,7 +10,7 @@
|
LL | break rust
| ^^^^^^^^^^ cannot `break` outside of a loop or labeled block
--Ztrack-diagnostics: created at compiler/rustc_passes/src/loops.rs:LL:CC
+-Ztrack-diagnostics: created at compiler/rustc_hir_typeck/src/loops.rs:LL:CC
error: internal compiler error: It looks like you're trying to break rust; would you like some ICE?
--> $DIR/track.rs:LL:CC
diff --git a/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.fixed b/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.fixed
index e6aac17..6354676 100644
--- a/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.fixed
+++ b/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.fixed
@@ -1,3 +1,4 @@
+//@ edition: 2015
//@ run-rustfix
#![allow(non_snake_case)]
mod A {
diff --git a/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.rs b/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.rs
index d5c557d..c3b3a00 100644
--- a/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.rs
+++ b/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.rs
@@ -1,3 +1,4 @@
+//@ edition: 2015
//@ run-rustfix
#![allow(non_snake_case)]
mod A {
diff --git a/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.stderr b/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.stderr
index e2a7269..4fb0dcc 100644
--- a/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.stderr
+++ b/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.stderr
@@ -1,5 +1,5 @@
error[E0405]: cannot find trait `Trait` in `A`
- --> $DIR/shadowed-path-in-trait-bound-suggestion.rs:9:24
+ --> $DIR/shadowed-path-in-trait-bound-suggestion.rs:10:24
|
LL | pub struct A<H: A::Trait>(pub H);
| ^^^^^ not found in `A`
diff --git a/tests/ui/traits/auxiliary/traitimpl.rs b/tests/ui/traits/auxiliary/traitimpl.rs
index fda5314..2544a96 100644
--- a/tests/ui/traits/auxiliary/traitimpl.rs
+++ b/tests/ui/traits/auxiliary/traitimpl.rs
@@ -2,6 +2,6 @@
pub trait Bar<'a> : 'a {}
-impl<'a> Bar<'a> {
+impl<'a> dyn Bar<'a> {
pub fn bar(&self) {}
}
diff --git a/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs b/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs
index f90ff91..b563b78 100644
--- a/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs
+++ b/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs
@@ -6,6 +6,7 @@
// Regression test for issue #125877.
//@ compile-flags: -Znext-solver
+//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION"
#![feature(const_trait_impl, effects)]
//~^ ERROR feature has been removed
diff --git a/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.stderr b/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.stderr
index d45c4cb..a04f98e 100644
--- a/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.stderr
+++ b/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.stderr
@@ -1,13 +1,14 @@
error[E0557]: feature has been removed
- --> $DIR/const-trait-impl-parameter-mismatch.rs:10:30
+ --> $DIR/const-trait-impl-parameter-mismatch.rs:11:30
|
LL | #![feature(const_trait_impl, effects)]
| ^^^^^^^ feature has been removed
|
+ = note: removed in 1.84.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/132479> for more information
= note: removed, redundant with `#![feature(const_trait_impl)]`
error[E0049]: associated function `compute` has 0 type parameters but its trait declaration has 1 type parameter
- --> $DIR/const-trait-impl-parameter-mismatch.rs:19:16
+ --> $DIR/const-trait-impl-parameter-mismatch.rs:20:16
|
LL | fn compute<T: ~const Aux>() -> u32;
| - expected 1 type parameter
diff --git a/tests/ui/traits/const-traits/inherent-impl.rs b/tests/ui/traits/const-traits/inherent-impl.rs
index afd0d13..07b23ad 100644
--- a/tests/ui/traits/const-traits/inherent-impl.rs
+++ b/tests/ui/traits/const-traits/inherent-impl.rs
@@ -7,7 +7,7 @@ trait T {}
impl const S {}
//~^ ERROR inherent impls cannot be `const`
-impl const T {}
+impl const dyn T {}
//~^ ERROR inherent impls cannot be `const`
fn main() {}
diff --git a/tests/ui/traits/const-traits/inherent-impl.stderr b/tests/ui/traits/const-traits/inherent-impl.stderr
index 8c55627..e4ec1e8 100644
--- a/tests/ui/traits/const-traits/inherent-impl.stderr
+++ b/tests/ui/traits/const-traits/inherent-impl.stderr
@@ -11,8 +11,8 @@
error: inherent impls cannot be `const`
--> $DIR/inherent-impl.rs:10:12
|
-LL | impl const T {}
- | ----- ^ inherent impl for this type
+LL | impl const dyn T {}
+ | ----- ^^^^^ inherent impl for this type
| |
| `const` because of this
|
diff --git a/tests/ui/traits/const-traits/mbe-dyn-const-2015.rs b/tests/ui/traits/const-traits/mbe-dyn-const-2015.rs
index 9d65a2a..fadfbe6 100644
--- a/tests/ui/traits/const-traits/mbe-dyn-const-2015.rs
+++ b/tests/ui/traits/const-traits/mbe-dyn-const-2015.rs
@@ -1,6 +1,7 @@
// Ensure that the introduction of const trait bound didn't regress this code in Rust 2015.
// See also `mbe-const-trait-bound-theoretical-regression.rs`.
+//@ edition: 2015
//@ check-pass
macro_rules! check {
diff --git a/tests/ui/default-method-simple.rs b/tests/ui/traits/default_method_simple.rs
similarity index 75%
rename from tests/ui/default-method-simple.rs
rename to tests/ui/traits/default_method_simple.rs
index e5fbedf..96fad94 100644
--- a/tests/ui/default-method-simple.rs
+++ b/tests/ui/traits/default_method_simple.rs
@@ -1,6 +1,6 @@
-//@ run-pass
+//! Checks basic default method functionality.
-#![allow(dead_code)]
+//@ run-pass
trait Foo {
fn f(&self) {
@@ -10,9 +10,7 @@ fn f(&self) {
fn g(&self);
}
-struct A {
- x: isize
-}
+struct A;
impl Foo for A {
fn g(&self) {
@@ -21,6 +19,6 @@ fn g(&self) {
}
pub fn main() {
- let a = A { x: 1 };
+ let a = A;
a.f();
}
diff --git a/tests/ui/traits/impl-2.rs b/tests/ui/traits/impl-2.rs
index c6f60a90..41fa1cd 100644
--- a/tests/ui/traits/impl-2.rs
+++ b/tests/ui/traits/impl-2.rs
@@ -10,7 +10,7 @@ pub trait Trait {
}
mod Bar {
- impl<'a> dyn (::Foo::Trait) + 'a {
+ impl<'a> dyn (crate::Foo::Trait) + 'a {
fn bar(&self) { self.foo() }
}
}
diff --git a/tests/ui/traits/item-privacy.rs b/tests/ui/traits/item-privacy.rs
index 9f75e6e..b872439 100644
--- a/tests/ui/traits/item-privacy.rs
+++ b/tests/ui/traits/item-privacy.rs
@@ -15,9 +15,9 @@ pub trait C: A + B {
fn c(&self) { }
}
- impl A for ::S {}
- impl B for ::S {}
- impl C for ::S {}
+ impl A for crate::S {}
+ impl B for crate::S {}
+ impl C for crate::S {}
}
mod assoc_const {
@@ -33,9 +33,9 @@ pub trait C: A + B {
const C: u8 = 0;
}
- impl A for ::S {}
- impl B for ::S {}
- impl C for ::S {}
+ impl A for crate::S {}
+ impl B for crate::S {}
+ impl C for crate::S {}
}
mod assoc_ty {
@@ -51,9 +51,9 @@ pub trait C: A + B {
type C = u8;
}
- impl A for ::S {}
- impl B for ::S {}
- impl C for ::S {}
+ impl A for crate::S {}
+ impl B for crate::S {}
+ impl C for crate::S {}
}
fn check_method() {
diff --git a/tests/ui/traits/static-method-overwriting.rs b/tests/ui/traits/static-method-overwriting.rs
index 7a2a51a..28edcde 100644
--- a/tests/ui/traits/static-method-overwriting.rs
+++ b/tests/ui/traits/static-method-overwriting.rs
@@ -9,7 +9,7 @@ pub struct Foo {
dummy: (),
}
- impl ::base::HasNew for Foo {
+ impl crate::base::HasNew for Foo {
fn new() -> Foo {
println!("Foo");
Foo { dummy: () }
@@ -20,7 +20,7 @@ pub struct Bar {
dummy: (),
}
- impl ::base::HasNew for Bar {
+ impl crate::base::HasNew for Bar {
fn new() -> Bar {
println!("Bar");
Bar { dummy: () }
diff --git a/tests/ui/transmutability/references/reject_extension.stderr b/tests/ui/transmutability/references/reject_extension.stderr
index 182106a..a5f6778 100644
--- a/tests/ui/transmutability/references/reject_extension.stderr
+++ b/tests/ui/transmutability/references/reject_extension.stderr
@@ -2,7 +2,7 @@
--> $DIR/reject_extension.rs:48:37
|
LL | assert::is_transmutable::<&Src, &Dst>();
- | ^^^^ the referent size of `&Packed<Two>` (2 bytes) is smaller than that of `&Packed<Four>` (4 bytes)
+ | ^^^^ the size of `Packed<Two>` (2 bytes) is smaller than that of `Packed<Four>` (4 bytes)
|
note: required by a bound in `is_transmutable`
--> $DIR/reject_extension.rs:13:14
diff --git a/tests/ui/transmutability/references/unit-to-u8.stderr b/tests/ui/transmutability/references/unit-to-u8.stderr
index bc9f286..35d1179 100644
--- a/tests/ui/transmutability/references/unit-to-u8.stderr
+++ b/tests/ui/transmutability/references/unit-to-u8.stderr
@@ -2,7 +2,7 @@
--> $DIR/unit-to-u8.rs:22:52
|
LL | assert::is_maybe_transmutable::<&'static Unit, &'static u8>();
- | ^^^^^^^^^^^ the referent size of `&Unit` (0 bytes) is smaller than that of `&u8` (1 bytes)
+ | ^^^^^^^^^^^ the size of `Unit` (0 bytes) is smaller than that of `u8` (1 bytes)
|
note: required by a bound in `is_maybe_transmutable`
--> $DIR/unit-to-u8.rs:9:14
diff --git a/tests/ui/transmutability/references/unsafecell.rs b/tests/ui/transmutability/references/unsafecell.rs
index 4001f13..b0db4af 100644
--- a/tests/ui/transmutability/references/unsafecell.rs
+++ b/tests/ui/transmutability/references/unsafecell.rs
@@ -38,10 +38,10 @@ fn mut_to_mut() {
}
fn mut_to_ref() {
- // We don't care about `UnsafeCell` for transmutations in the form `&mut T
- // -> &U`, because downgrading a `&mut T` to a `&U` deactivates `&mut T` for
- // the lifetime of `&U`.
- assert::is_maybe_transmutable::<&'static mut u8, &'static UnsafeCell<u8>>();
- assert::is_maybe_transmutable::<&'static mut UnsafeCell<u8>, &'static u8>();
- assert::is_maybe_transmutable::<&'static mut UnsafeCell<u8>, &'static UnsafeCell<u8>>();
+ // `&mut UnsafeCell` is irrelevant in the source.
+ assert::is_maybe_transmutable::<&'static mut UnsafeCell<bool>, &'static u8>();
+ // `&UnsafeCell` in forbidden in the destination, since the destination can be used to
+ // invalidate a shadowed source reference.
+ assert::is_maybe_transmutable::<&'static mut bool, &'static UnsafeCell<u8>>(); //~ ERROR: cannot be safely transmuted
+ assert::is_maybe_transmutable::<&'static mut UnsafeCell<bool>, &'static UnsafeCell<u8>>(); //~ ERROR: cannot be safely transmuted
}
diff --git a/tests/ui/transmutability/references/unsafecell.stderr b/tests/ui/transmutability/references/unsafecell.stderr
index 6664d8a..02a0935 100644
--- a/tests/ui/transmutability/references/unsafecell.stderr
+++ b/tests/ui/transmutability/references/unsafecell.stderr
@@ -28,6 +28,36 @@
LL | Dst: TransmuteFrom<Src, { Assume::SAFETY }>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable`
-error: aborting due to 2 previous errors
+error[E0277]: `&mut bool` cannot be safely transmuted into `&UnsafeCell<u8>`
+ --> $DIR/unsafecell.rs:45:56
+ |
+LL | assert::is_maybe_transmutable::<&'static mut bool, &'static UnsafeCell<u8>>();
+ | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Freeze` is not implemented for `UnsafeCell<u8>`
+ |
+note: required by a bound in `is_maybe_transmutable`
+ --> $DIR/unsafecell.rs:12:14
+ |
+LL | pub fn is_maybe_transmutable<Src, Dst>()
+ | --------------------- required by a bound in this function
+LL | where
+LL | Dst: TransmuteFrom<Src, { Assume::SAFETY }>
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable`
+
+error[E0277]: `&mut UnsafeCell<bool>` cannot be safely transmuted into `&UnsafeCell<u8>`
+ --> $DIR/unsafecell.rs:46:68
+ |
+LL | assert::is_maybe_transmutable::<&'static mut UnsafeCell<bool>, &'static UnsafeCell<u8>>();
+ | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Freeze` is not implemented for `UnsafeCell<u8>`
+ |
+note: required by a bound in `is_maybe_transmutable`
+ --> $DIR/unsafecell.rs:12:14
+ |
+LL | pub fn is_maybe_transmutable<Src, Dst>()
+ | --------------------- required by a bound in this function
+LL | where
+LL | Dst: TransmuteFrom<Src, { Assume::SAFETY }>
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable`
+
+error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/transmutability/uninhabited.stderr b/tests/ui/transmutability/uninhabited.stderr
index 79cd75c..4757dae 100644
--- a/tests/ui/transmutability/uninhabited.stderr
+++ b/tests/ui/transmutability/uninhabited.stderr
@@ -44,7 +44,7 @@
--> $DIR/uninhabited.rs:41:9
|
LL | assert!(false);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `yawning_void_struct::_` failed here
error[E0277]: `()` cannot be safely transmuted into `yawning_void_enum::Void`
--> $DIR/uninhabited.rs:71:41
@@ -71,7 +71,7 @@
--> $DIR/uninhabited.rs:63:9
|
LL | assert!(false);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `yawning_void_enum::_` failed here
error[E0277]: `u128` cannot be safely transmuted into `DistantVoid`
--> $DIR/uninhabited.rs:92:43
@@ -98,7 +98,7 @@
--> $DIR/uninhabited.rs:87:9
|
LL | assert!(false);
- | ^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^ evaluation of `distant_void::_` failed here
error[E0277]: `Src` cannot be safely transmuted into `issue_126267::Error`
--> $DIR/uninhabited.rs:108:42
diff --git a/tests/ui/treat-err-as-bug/err.stderr b/tests/ui/treat-err-as-bug/err.stderr
index 3279392..0052dd7 100644
--- a/tests/ui/treat-err-as-bug/err.stderr
+++ b/tests/ui/treat-err-as-bug/err.stderr
@@ -2,7 +2,7 @@
--> $DIR/err.rs:9:21
|
LL | pub static C: u32 = 0 - 1;
- | ^^^^^ evaluation of static initializer failed here
+ | ^^^^^ evaluation of `C` failed here
error: the compiler unexpectedly panicked. this is a bug.
diff --git a/tests/ui/tuple/tuple-struct-fields/test.rs b/tests/ui/tuple/tuple-struct-fields/test.rs
index 0067709..29aabf4 100644
--- a/tests/ui/tuple/tuple-struct-fields/test.rs
+++ b/tests/ui/tuple/tuple-struct-fields/test.rs
@@ -1,6 +1,6 @@
mod foo {
type T = ();
- struct S1(pub(in foo) (), pub(T), pub(crate) (), pub(((), T)));
+ struct S1(pub(in crate::foo) (), pub(T), pub(crate) (), pub(((), T)));
struct S2(pub((foo)) ());
//~^ ERROR expected one of `)` or `,`, found `(`
//~| ERROR cannot find type `foo` in this scope
diff --git a/tests/ui/tuple/tuple-struct-fields/test2.rs b/tests/ui/tuple/tuple-struct-fields/test2.rs
index 2b2a2c1..544d486 100644
--- a/tests/ui/tuple/tuple-struct-fields/test2.rs
+++ b/tests/ui/tuple/tuple-struct-fields/test2.rs
@@ -1,7 +1,7 @@
macro_rules! define_struct {
($t:ty) => {
struct S1(pub $t);
- struct S2(pub (in foo) ());
+ struct S2(pub (in crate::foo) ());
struct S3(pub $t ());
//~^ ERROR expected one of `)` or `,`, found `(`
}
diff --git a/tests/ui/tuple/tuple-struct-fields/test3.rs b/tests/ui/tuple/tuple-struct-fields/test3.rs
index 98d1942..b5f98a6 100644
--- a/tests/ui/tuple/tuple-struct-fields/test3.rs
+++ b/tests/ui/tuple/tuple-struct-fields/test3.rs
@@ -1,7 +1,7 @@
macro_rules! define_struct {
($t:ty) => {
struct S1(pub($t));
- struct S2(pub (in foo) ());
+ struct S2(pub (in crate::foo) ());
struct S3(pub($t) ());
//~^ ERROR expected one of `)` or `,`, found `(`
}
diff --git a/tests/ui/type/auxiliary/crate_a1.rs b/tests/ui/type/auxiliary/crate_a1.rs
index 6164931..f8ee9ae 100644
--- a/tests/ui/type/auxiliary/crate_a1.rs
+++ b/tests/ui/type/auxiliary/crate_a1.rs
@@ -2,10 +2,10 @@
pub trait Bar {}
-pub fn bar() -> Box<Bar> {
+pub fn bar() -> Box<dyn Bar> {
unimplemented!()
}
pub fn try_foo(x: Foo){}
-pub fn try_bar(x: Box<Bar>){}
+pub fn try_bar(x: Box<dyn Bar>){}
diff --git a/tests/ui/type/auxiliary/crate_a2.rs b/tests/ui/type/auxiliary/crate_a2.rs
index 57a7685..fe22598 100644
--- a/tests/ui/type/auxiliary/crate_a2.rs
+++ b/tests/ui/type/auxiliary/crate_a2.rs
@@ -2,6 +2,6 @@
pub trait Bar {}
-pub fn bar() -> Box<Bar> {
+pub fn bar() -> Box<dyn Bar> {
unimplemented!()
}
diff --git a/tests/ui/type/issue-7607-2.rs b/tests/ui/type/issue-7607-2.rs
index ebc4fe1..53fafdf 100644
--- a/tests/ui/type/issue-7607-2.rs
+++ b/tests/ui/type/issue-7607-2.rs
@@ -6,7 +6,7 @@ pub struct Foo { a: usize }
}
pub mod b {
- use a::Foo;
+ use crate::a::Foo;
impl Foo {
fn bar(&self) { }
}
diff --git a/tests/ui/type/pattern_types/literals.stderr b/tests/ui/type/pattern_types/literals.stderr
index 72c812e..7ab7b81 100644
--- a/tests/ui/type/pattern_types/literals.stderr
+++ b/tests/ui/type/pattern_types/literals.stderr
@@ -2,31 +2,31 @@
--> $DIR/literals.rs:86:62
|
LL | fn empty_range_at_base_type_min() -> pattern_type!(u32 is 0..0) {
- | ^ evaluation of constant value failed here
+ | ^ evaluation of `empty_range_at_base_type_min::{constant#1}` failed here
error[E0080]: evaluation panicked: exclusive range end at minimum value of type
--> $DIR/literals.rs:91:63
|
LL | fn empty_range_at_base_type_min2() -> pattern_type!(u32 is 0..0) {
- | ^ evaluation of constant value failed here
+ | ^ evaluation of `empty_range_at_base_type_min2::{constant#1}` failed here
error[E0080]: evaluation panicked: exclusive range end at minimum value of type
--> $DIR/literals.rs:106:65
|
LL | fn wraparound_range_at_base_ty_end() -> pattern_type!(u32 is 1..0) {
- | ^ evaluation of constant value failed here
+ | ^ evaluation of `wraparound_range_at_base_ty_end::{constant#1}` failed here
error[E0080]: evaluation panicked: exclusive range end at minimum value of type
--> $DIR/literals.rs:111:66
|
LL | fn wraparound_range_at_base_ty_end2() -> pattern_type!(u32 is 1..0) {
- | ^ evaluation of constant value failed here
+ | ^ evaluation of `wraparound_range_at_base_ty_end2::{constant#1}` failed here
error[E0080]: evaluation panicked: exclusive range end at minimum value of type
--> $DIR/literals.rs:116:66
|
LL | fn wraparound_range_at_base_ty_end3() -> pattern_type!(u32 is 1..0) {
- | ^ evaluation of constant value failed here
+ | ^ evaluation of `wraparound_range_at_base_ty_end3::{constant#1}` failed here
error[E0308]: mismatched types
--> $DIR/literals.rs:9:5
diff --git a/tests/ui/type/pattern_types/matching.rs b/tests/ui/type/pattern_types/matching.rs
index b8463a8..21f89b3 100644
--- a/tests/ui/type/pattern_types/matching.rs
+++ b/tests/ui/type/pattern_types/matching.rs
@@ -1,6 +1,7 @@
#![feature(pattern_types, pattern_type_macro, structural_match)]
//@ check-pass
+//@ compile-flags: -Zvalidate-mir
use std::marker::StructuralPartialEq;
use std::pat::pattern_type;
diff --git a/tests/ui/type/pattern_types/or_patterns.stderr b/tests/ui/type/pattern_types/or_patterns.stderr
index 58ca585..a417e50 100644
--- a/tests/ui/type/pattern_types/or_patterns.stderr
+++ b/tests/ui/type/pattern_types/or_patterns.stderr
@@ -41,9 +41,8 @@
error: layout_of((i8) is (i8::MIN..=-1 | 1..)) = Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -80,9 +79,8 @@
error: layout_of((i8) is (i8::MIN..=-2 | 0..)) = Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
diff --git a/tests/ui/type/pattern_types/range_patterns.stderr b/tests/ui/type/pattern_types/range_patterns.stderr
index bcb602a..abd8b87 100644
--- a/tests/ui/type/pattern_types/range_patterns.stderr
+++ b/tests/ui/type/pattern_types/range_patterns.stderr
@@ -1,8 +1,7 @@
error: layout_of(NonZero<u32>) = Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -46,9 +45,8 @@
error: layout_of((u32) is 1..) = Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -85,9 +83,8 @@
error: layout_of(Option<(u32) is 1..>) = Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -125,9 +122,8 @@
variants: [
Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -147,9 +143,8 @@
},
Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -199,9 +194,8 @@
error: layout_of(Option<NonZero<u32>>) = Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -239,9 +233,8 @@
variants: [
Layout {
size: Size(0 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Memory {
sized: true,
@@ -261,9 +254,8 @@
},
Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -313,9 +305,8 @@
error: layout_of(NonZeroU32New) = Layout {
size: Size(4 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(4 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -369,7 +360,7 @@
--> $DIR/range_patterns.rs:25:37
|
LL | type WRAP = pattern_type!(u32 is 1..0);
- | ^ evaluation of constant value failed here
+ | ^ evaluation of `WRAP::{constant#1}` failed here
error: the type has an unknown layout
--> $DIR/range_patterns.rs:25:1
@@ -387,9 +378,8 @@
error: layout_of((i8) is -10..=10) = Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
@@ -426,9 +416,8 @@
error: layout_of((i8) is i8::MIN..=0) = Layout {
size: Size(1 bytes),
- align: AbiAndPrefAlign {
+ align: AbiAlign {
abi: Align(1 bytes),
- pref: $SOME_ALIGN,
},
backend_repr: Scalar(
Initialized {
diff --git a/tests/ui/type/pattern_types/reverse_range.stderr b/tests/ui/type/pattern_types/reverse_range.stderr
index 8f5b86c..6e6e344 100644
--- a/tests/ui/type/pattern_types/reverse_range.stderr
+++ b/tests/ui/type/pattern_types/reverse_range.stderr
@@ -2,7 +2,7 @@
--> $DIR/reverse_range.rs:7:36
|
LL | const NONE: pattern_type!(u8 is 1..0) = unsafe { std::mem::transmute(3_u8) };
- | ^ evaluation of constant value failed here
+ | ^ evaluation of `NONE::{constant#1}` failed here
error: aborting due to 1 previous error
diff --git a/tests/ui/type/pattern_types/validity.stderr b/tests/ui/type/pattern_types/validity.stderr
index 7ba73aa..4f4c160 100644
--- a/tests/ui/type/pattern_types/validity.stderr
+++ b/tests/ui/type/pattern_types/validity.stderr
@@ -13,13 +13,13 @@
--> $DIR/validity.rs:13:1
|
LL | const BAD_UNINIT: pattern_type!(u32 is 1..) =
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_UNINIT` failed here
error[E0080]: unable to turn pointer into integer
--> $DIR/validity.rs:17:1
|
LL | const BAD_PTR: pattern_type!(usize is 1..) = unsafe { std::mem::transmute(&42) };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `BAD_PTR` failed here
|
= help: this code performed an operation that depends on the underlying bytes representing a pointer
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
@@ -50,7 +50,7 @@
--> $DIR/validity.rs:29:1
|
LL | const CHAR_UNINIT: pattern_type!(char is 'A'..'Z') =
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of constant value failed here
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `CHAR_UNINIT` failed here
error[E0080]: constructing invalid value: encountered 97, but expected something in the range 65..=89
--> $DIR/validity.rs:33:1
diff --git a/tests/ui/type/type-mismatch-same-crate-name.stderr b/tests/ui/type/type-mismatch-same-crate-name.stderr
index 7b79154..8fafbfa 100644
--- a/tests/ui/type/type-mismatch-same-crate-name.stderr
+++ b/tests/ui/type/type-mismatch-same-crate-name.stderr
@@ -59,7 +59,7 @@
note: function defined here
--> $DIR/auxiliary/crate_a1.rs:11:8
|
-LL | pub fn try_bar(x: Box<Bar>){}
+LL | pub fn try_bar(x: Box<dyn Bar>){}
| ^^^^^^^
error: aborting due to 2 previous errors
diff --git a/tests/ui/typeck/issue-114529-illegal-break-with-value.stderr b/tests/ui/typeck/issue-114529-illegal-break-with-value.stderr
index de993df..872c506 100644
--- a/tests/ui/typeck/issue-114529-illegal-break-with-value.stderr
+++ b/tests/ui/typeck/issue-114529-illegal-break-with-value.stderr
@@ -1,4 +1,22 @@
error[E0571]: `break` with value from a `while` loop
+ --> $DIR/issue-114529-illegal-break-with-value.rs:22:9
+ |
+LL | while true {
+ | ---------- you can't `break` with a value in a `while` loop
+LL | / break (|| {
+LL | | let local = 9;
+LL | | });
+ | |__________^ can only break with a value inside `loop` or breakable block
+ |
+help: use `break` on its own without a value inside this `while` loop
+ |
+LL - break (|| {
+LL - let local = 9;
+LL - });
+LL + break;
+ |
+
+error[E0571]: `break` with value from a `while` loop
--> $DIR/issue-114529-illegal-break-with-value.rs:9:13
|
LL | while true {
@@ -26,24 +44,6 @@
LL + break;
|
-error[E0571]: `break` with value from a `while` loop
- --> $DIR/issue-114529-illegal-break-with-value.rs:22:9
- |
-LL | while true {
- | ---------- you can't `break` with a value in a `while` loop
-LL | / break (|| {
-LL | | let local = 9;
-LL | | });
- | |__________^ can only break with a value inside `loop` or breakable block
- |
-help: use `break` on its own without a value inside this `while` loop
- |
-LL - break (|| {
-LL - let local = 9;
-LL - });
-LL + break;
- |
-
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0571`.
diff --git a/tests/ui/unboxed-closures/fn-traits-hrtb-coercion.rs b/tests/ui/unboxed-closures/fn-traits-hrtb-coercion.rs
new file mode 100644
index 0000000..4a08bf2
--- /dev/null
+++ b/tests/ui/unboxed-closures/fn-traits-hrtb-coercion.rs
@@ -0,0 +1,39 @@
+//! Test for issue <github.com/rust-lang/rust/issues/30904>
+//! Related to higher-ranked lifetime inference with unboxed closures and FnOnce.
+
+#![feature(fn_traits, unboxed_closures)]
+
+fn test<F: for<'x> FnOnce<(&'x str,)>>(_: F) {}
+
+struct Compose<F, G>(F, G);
+
+impl<T, F, G> FnOnce<(T,)> for Compose<F, G>
+where
+ F: FnOnce<(T,)>,
+ G: FnOnce<(F::Output,)>,
+{
+ type Output = G::Output;
+ extern "rust-call" fn call_once(self, (x,): (T,)) -> G::Output {
+ (self.1)((self.0)(x))
+ }
+}
+
+struct Str<'a>(&'a str);
+
+fn mk_str<'a>(s: &'a str) -> Str<'a> {
+ Str(s)
+}
+
+fn main() {
+ let _: for<'a> fn(&'a str) -> Str<'a> = mk_str;
+ let _: for<'a> fn(&'a str) -> Str<'a> = Str;
+ //~^ ERROR: mismatched types
+
+ test(|_: &str| {});
+ test(mk_str);
+ test(Str);
+
+ test(Compose(|_: &str| {}, |_| {}));
+ test(Compose(mk_str, |_| {}));
+ test(Compose(Str, |_| {}));
+}
diff --git a/tests/ui/unboxed-closures/fn-traits-hrtb-coercion.stderr b/tests/ui/unboxed-closures/fn-traits-hrtb-coercion.stderr
new file mode 100644
index 0000000..a31d99f
--- /dev/null
+++ b/tests/ui/unboxed-closures/fn-traits-hrtb-coercion.stderr
@@ -0,0 +1,14 @@
+error[E0308]: mismatched types
+ --> $DIR/fn-traits-hrtb-coercion.rs:29:45
+ |
+LL | let _: for<'a> fn(&'a str) -> Str<'a> = Str;
+ | ------------------------------ ^^^ one type is more general than the other
+ | |
+ | expected due to this
+ |
+ = note: expected fn pointer `for<'a> fn(&'a _) -> Str<'a>`
+ found struct constructor `fn(&_) -> Str<'_> {Str::<'_>}`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/underscore-imports/basic.rs b/tests/ui/underscore-imports/basic.rs
index 624ecb4..8d8ff5c 100644
--- a/tests/ui/underscore-imports/basic.rs
+++ b/tests/ui/underscore-imports/basic.rs
@@ -18,25 +18,25 @@ pub trait Tr2 {
fn tr2_is_in_scope(&self) {}
}
- impl Tr1 for ::S {}
- impl Tr2 for ::S {}
+ impl Tr1 for crate::S {}
+ impl Tr2 for crate::S {}
}
mod unused {
- use m::Tr1 as _; //~ WARN unused import
- use S as _; //~ WARN unused import
+ use crate::m::Tr1 as _; //~ WARN unused import
+ use crate::S as _; //~ WARN unused import
extern crate core as _; // OK
}
mod outer {
mod middle {
- pub use m::Tr1 as _;
- pub use m::Tr2 as _; // OK, no name conflict
+ pub use crate::m::Tr1 as _;
+ pub use crate::m::Tr2 as _; // OK, no name conflict
struct Tr1; // OK, no name conflict
fn check() {
// Both traits are in scope
- ::S.tr1_is_in_scope();
- ::S.tr2_is_in_scope();
+ crate::S.tr1_is_in_scope();
+ crate::S.tr2_is_in_scope();
}
mod inner {
@@ -44,8 +44,8 @@ mod inner {
use super::*;
fn check() {
// Both traits are in scope
- ::S.tr1_is_in_scope();
- ::S.tr2_is_in_scope();
+ crate::S.tr1_is_in_scope();
+ crate::S.tr2_is_in_scope();
}
}
}
@@ -54,8 +54,8 @@ fn check() {
use self::middle::*;
fn check() {
// Both traits are in scope
- ::S.tr1_is_in_scope();
- ::S.tr2_is_in_scope();
+ crate::S.tr1_is_in_scope();
+ crate::S.tr2_is_in_scope();
}
}
diff --git a/tests/ui/underscore-imports/basic.stderr b/tests/ui/underscore-imports/basic.stderr
index c514935..666d073 100644
--- a/tests/ui/underscore-imports/basic.stderr
+++ b/tests/ui/underscore-imports/basic.stderr
@@ -1,8 +1,8 @@
-warning: unused import: `m::Tr1 as _`
+warning: unused import: `crate::m::Tr1 as _`
--> $DIR/basic.rs:26:9
|
-LL | use m::Tr1 as _;
- | ^^^^^^^^^^^
+LL | use crate::m::Tr1 as _;
+ | ^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/basic.rs:4:9
@@ -10,11 +10,11 @@
LL | #![warn(unused_imports, unused_extern_crates)]
| ^^^^^^^^^^^^^^
-warning: unused import: `S as _`
+warning: unused import: `crate::S as _`
--> $DIR/basic.rs:27:9
|
-LL | use S as _;
- | ^^^^^^
+LL | use crate::S as _;
+ | ^^^^^^^^^^^^^
warning: 2 warnings emitted
diff --git a/tests/ui/unresolved/unresolved-import-recovery.rs b/tests/ui/unresolved/unresolved-import-recovery.rs
index 0b06533..8657bb6 100644
--- a/tests/ui/unresolved/unresolved-import-recovery.rs
+++ b/tests/ui/unresolved/unresolved-import-recovery.rs
@@ -1,7 +1,7 @@
// Check that unresolved imports do not create additional errors and ICEs
mod m {
- pub use unresolved; //~ ERROR unresolved import `unresolved`
+ pub use crate::unresolved; //~ ERROR unresolved import `crate::unresolved`
fn f() {
let unresolved = 0; // OK
diff --git a/tests/ui/unresolved/unresolved-import-recovery.stderr b/tests/ui/unresolved/unresolved-import-recovery.stderr
index 1c00604..ec41c9e 100644
--- a/tests/ui/unresolved/unresolved-import-recovery.stderr
+++ b/tests/ui/unresolved/unresolved-import-recovery.stderr
@@ -1,8 +1,8 @@
-error[E0432]: unresolved import `unresolved`
+error[E0432]: unresolved import `crate::unresolved`
--> $DIR/unresolved-import-recovery.rs:4:13
|
-LL | pub use unresolved;
- | ^^^^^^^^^^ no `unresolved` in the root
+LL | pub use crate::unresolved;
+ | ^^^^^^^^^^^^^^^^^ no `unresolved` in the root
error: aborting due to 1 previous error
diff --git a/tests/ui/unsafe/break-inside-unsafe-block-issue-128604.stderr b/tests/ui/unsafe/break-inside-unsafe-block-issue-128604.stderr
index b7cbe1a..2f01331 100644
--- a/tests/ui/unsafe/break-inside-unsafe-block-issue-128604.stderr
+++ b/tests/ui/unsafe/break-inside-unsafe-block-issue-128604.stderr
@@ -1,10 +1,4 @@
error[E0268]: `break` outside of a loop or labeled block
- --> $DIR/break-inside-unsafe-block-issue-128604.rs:2:28
- |
-LL | let a = ["_"; unsafe { break; 1 + 2 }];
- | ^^^^^ cannot `break` outside of a loop or labeled block
-
-error[E0268]: `break` outside of a loop or labeled block
--> $DIR/break-inside-unsafe-block-issue-128604.rs:14:9
|
LL | break;
@@ -37,6 +31,12 @@
LL ~ break 'block;
|
+error[E0268]: `break` outside of a loop or labeled block
+ --> $DIR/break-inside-unsafe-block-issue-128604.rs:2:28
+ |
+LL | let a = ["_"; unsafe { break; 1 + 2 }];
+ | ^^^^^ cannot `break` outside of a loop or labeled block
+
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0268`.
diff --git a/tests/ui/unsized/unsized3-rpass.rs b/tests/ui/unsized/unsized3-rpass.rs
index ff35051..03aa1a5 100644
--- a/tests/ui/unsized/unsized3-rpass.rs
+++ b/tests/ui/unsized/unsized3-rpass.rs
@@ -37,7 +37,7 @@ fn foo(&self) -> usize {
}
struct Qux<'a> {
- f: Tr + 'a,
+ f: dyn Tr + 'a,
}
pub fn main() {
@@ -85,7 +85,7 @@ struct Qux_ {
}
let obj: Box<St> = Box::new(St { f: 42 });
- let obj: &Tr = &*obj;
+ let obj: &dyn Tr = &*obj;
let data: Box<_> = Box::new(Qux_ { f: St { f: 234 } });
let x: &Qux = &*ptr::from_raw_parts::<Qux>(&*data as *const _, ptr::metadata(obj));
assert_eq!(x.f.foo(), 234);
diff --git a/tests/ui/use/use-mod/use-mod-4.rs b/tests/ui/use/use-mod/use-mod-4.rs
index 46ae8dd..34ce7c7 100644
--- a/tests/ui/use/use-mod/use-mod-4.rs
+++ b/tests/ui/use/use-mod/use-mod-4.rs
@@ -1,4 +1,4 @@
-use foo::self; //~ ERROR unresolved import `foo`
+use crate::foo::self; //~ ERROR unresolved import `crate::foo`
//~^ ERROR `self` imports are only allowed within a { } list
use std::mem::self;
diff --git a/tests/ui/use/use-mod/use-mod-4.stderr b/tests/ui/use/use-mod/use-mod-4.stderr
index 0b4fbad..d462129 100644
--- a/tests/ui/use/use-mod/use-mod-4.stderr
+++ b/tests/ui/use/use-mod/use-mod-4.stderr
@@ -1,18 +1,18 @@
error[E0429]: `self` imports are only allowed within a { } list
- --> $DIR/use-mod-4.rs:1:8
+ --> $DIR/use-mod-4.rs:1:15
|
-LL | use foo::self;
- | ^^^^^^
+LL | use crate::foo::self;
+ | ^^^^^^
|
help: consider importing the module directly
|
-LL - use foo::self;
-LL + use foo;
+LL - use crate::foo::self;
+LL + use crate::foo;
|
help: alternatively, use the multi-path `use` syntax to import `self`
|
-LL | use foo::{self};
- | + +
+LL | use crate::foo::{self};
+ | + +
error[E0429]: `self` imports are only allowed within a { } list
--> $DIR/use-mod-4.rs:4:13
@@ -30,11 +30,11 @@
LL | use std::mem::{self};
| + +
-error[E0432]: unresolved import `foo`
+error[E0432]: unresolved import `crate::foo`
--> $DIR/use-mod-4.rs:1:5
|
-LL | use foo::self;
- | ^^^^^^^^^ no `foo` in the root
+LL | use crate::foo::self;
+ | ^^^^^^^^^^^^^^^^ no `foo` in the root
error: aborting due to 3 previous errors
diff --git a/tests/ui/variance/variance-trait-matching.stderr b/tests/ui/variance/variance-trait-matching.stderr
index 9c72fe2..4956696 100644
--- a/tests/ui/variance/variance-trait-matching.stderr
+++ b/tests/ui/variance/variance-trait-matching.stderr
@@ -1,11 +1,13 @@
error[E0621]: explicit lifetime required in the type of `get`
--> $DIR/variance-trait-matching.rs:24:5
|
-LL | fn get<'a, G>(get: &G) -> i32
- | -- help: add explicit lifetime `'a` to the type of `get`: `&'a G`
-...
LL | pick(get, &22)
| ^^^^^^^^^^^^^^ lifetime `'a` required
+ |
+help: add explicit lifetime `'a` to the type of `get`
+ |
+LL | fn get<'a, G>(get: &'a G) -> i32
+ | ++
error: aborting due to 1 previous error
diff --git a/tests/ui/warnings/no-explicit-path-issue-122509.rs b/tests/ui/warnings/no-explicit-path-issue-122509.rs
index 4e8eefd..5be4b17 100644
--- a/tests/ui/warnings/no-explicit-path-issue-122509.rs
+++ b/tests/ui/warnings/no-explicit-path-issue-122509.rs
@@ -7,13 +7,13 @@ fn one() -> usize {
pub mod a {
pub fn two() -> usize {
- ::one() + ::one()
+ crate::one() + crate::one()
}
}
pub mod b {
pub fn three() -> usize {
- ::one() + ::a::two()
+ crate::one() + crate::a::two()
}
}
diff --git a/tests/ui/weird-exprs.rs b/tests/ui/weird-exprs.rs
index b24e754..7db92d4 100644
--- a/tests/ui/weird-exprs.rs
+++ b/tests/ui/weird-exprs.rs
@@ -105,7 +105,7 @@ pub fn u8<'u8: 'u8 + 'u8>(u8: &'u8 u8) -> &'u8 u8 {
u8!(u8);
let &u8: &u8 = u8::u8(&8u8);
- ::u8(0u8);
+ crate::u8(0u8);
u8
});
}
diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs
index a95e10b..53f07a9 100644
--- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs
+++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs
@@ -1,17 +1,11 @@
-trait Trait<const N: Trait = bar> {
+trait Trait<const N: dyn Trait = bar> {
//~^ ERROR cannot find value `bar` in this scope
//~| ERROR cycle detected when computing type of `Trait::N`
- //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
- //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
- fn fnc<const N: Trait = u32>(&self) -> Trait {
+ fn fnc<const N: dyn Trait = u32>(&self) -> dyn Trait {
//~^ ERROR the name `N` is already used for a generic parameter in this item's generic parameters
//~| ERROR expected value, found builtin type `u32`
//~| ERROR defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
//~| ERROR associated item referring to unboxed trait object for its own trait
- //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
- //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
- //~| WARN trait objects without an explicit `dyn` are deprecated [bare_trait_objects]
- //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
bar
//~^ ERROR cannot find value `bar` in this scope
}
diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr
index 59eef0c..a085dd6 100644
--- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr
+++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr
@@ -1,106 +1,66 @@
error[E0403]: the name `N` is already used for a generic parameter in this item's generic parameters
- --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:6:18
+ --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:4:18
|
-LL | trait Trait<const N: Trait = bar> {
+LL | trait Trait<const N: dyn Trait = bar> {
| - first use of `N`
...
-LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
+LL | fn fnc<const N: dyn Trait = u32>(&self) -> dyn Trait {
| ^ already used
error[E0425]: cannot find value `bar` in this scope
- --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:30
+ --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:34
|
-LL | trait Trait<const N: Trait = bar> {
- | ^^^ not found in this scope
+LL | trait Trait<const N: dyn Trait = bar> {
+ | ^^^ not found in this scope
error[E0423]: expected value, found builtin type `u32`
- --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:6:29
+ --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:4:33
|
-LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
- | ^^^ not a value
+LL | fn fnc<const N: dyn Trait = u32>(&self) -> dyn Trait {
+ | ^^^ not a value
error[E0425]: cannot find value `bar` in this scope
- --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:15:9
+ --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:9:9
|
LL | bar
| ^^^ not found in this scope
-warning: trait objects without an explicit `dyn` are deprecated
- --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:22
- |
-LL | trait Trait<const N: Trait = bar> {
- | ^^^^^
- |
- = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
- = note: `#[warn(bare_trait_objects)]` on by default
-help: if this is a dyn-compatible trait, use `dyn`
+error[E0391]: cycle detected when computing type of `Trait::N`
+ --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:26
|
LL | trait Trait<const N: dyn Trait = bar> {
- | +++
-
-error[E0391]: cycle detected when computing type of `Trait::N`
- --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:22
- |
-LL | trait Trait<const N: Trait = bar> {
- | ^^^^^
+ | ^^^^^
|
= note: ...which immediately requires computing type of `Trait::N` again
note: cycle used when computing explicit predicates of trait `Trait`
--> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:1
|
-LL | trait Trait<const N: Trait = bar> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | trait Trait<const N: dyn Trait = bar> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
- --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:6:12
+ --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:4:12
|
-LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
- | ^^^^^^^^^^^^^^^^^^^^
-
-warning: trait objects without an explicit `dyn` are deprecated
- --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:6:44
- |
-LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
- | ^^^^^
- |
- = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
-help: if this is a dyn-compatible trait, use `dyn`
- |
-LL | fn fnc<const N: Trait = u32>(&self) -> dyn Trait {
- | +++
-
-warning: trait objects without an explicit `dyn` are deprecated
- --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:6:21
- |
-LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
- | ^^^^^
- |
- = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
- = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
-help: if this is a dyn-compatible trait, use `dyn`
- |
-LL | fn fnc<const N: dyn Trait = u32>(&self) -> Trait {
- | +++
+LL | fn fnc<const N: dyn Trait = u32>(&self) -> dyn Trait {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^
error: associated item referring to unboxed trait object for its own trait
- --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:6:44
+ --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:4:48
|
-LL | trait Trait<const N: Trait = bar> {
+LL | trait Trait<const N: dyn Trait = bar> {
| ----- in this trait
...
-LL | fn fnc<const N: Trait = u32>(&self) -> Trait {
- | ^^^^^
+LL | fn fnc<const N: dyn Trait = u32>(&self) -> dyn Trait {
+ | ^^^^^^^^^
|
help: you might have meant to use `Self` to refer to the implementing type
|
-LL - fn fnc<const N: Trait = u32>(&self) -> Trait {
-LL + fn fnc<const N: Trait = u32>(&self) -> Self {
+LL - fn fnc<const N: dyn Trait = u32>(&self) -> dyn Trait {
+LL + fn fnc<const N: dyn Trait = u32>(&self) -> Self {
|
-error: aborting due to 7 previous errors; 3 warnings emitted
+error: aborting due to 7 previous errors
Some errors have detailed explanations: E0391, E0403, E0423, E0425.
For more information about an error, try `rustc --explain E0391`.
diff --git a/triagebot.toml b/triagebot.toml
index 15c56f8..52d18d2 100644
--- a/triagebot.toml
+++ b/triagebot.toml
@@ -44,29 +44,6 @@
# Those labels are added when PR author requests a review from an assignee
add_labels = ["S-waiting-on-review"]
-[ping.icebreakers-llvm]
-message = """\
-Hey LLVM ICE-breakers! This bug has been identified as a good
-"LLVM ICE-breaking candidate". In case it's useful, here are some
-[instructions] for tackling these sorts of bugs. Maybe take a look?
-Thanks! <3
-
-[instructions]: https://rustc-dev-guide.rust-lang.org/notification-groups/llvm.html
-"""
-label = "ICEBreaker-LLVM"
-
-[ping.icebreakers-cleanup-crew]
-alias = ["cleanup", "cleanups", "cleanup-crew", "shrink", "reduce", "bisect"]
-message = """\
-Hey Cleanup Crew ICE-breakers! This bug has been identified as a good
-"Cleanup ICE-breaking candidate". In case it's useful, here are some
-[instructions] for tackling these sorts of bugs. Maybe take a look?
-Thanks! <3
-
-[instructions]: https://rustc-dev-guide.rust-lang.org/notification-groups/cleanup-crew.html
-"""
-label = "ICEBreaker-Cleanup-Crew"
-
[ping.windows]
message = """\
Hey Windows Group! This bug has been identified as a good "Windows candidate".
@@ -729,6 +706,41 @@
]
message_on_remove = "PR #{number}'s stable-nomination has been removed."
+[notify-zulip."beta-nominated".bootstrap]
+required_labels = ["T-bootstrap"]
+zulip_stream = 507486 # #t-infra/bootstrap/backports
+topic = "#{number}: beta-nominated"
+message_on_add = [
+ """\
+@*T-bootstrap* PR #{number} "{title}" has been nominated for beta backport.
+""",
+ """\
+/poll Approve beta backport of #{number}?
+approve
+decline
+don't know
+""",
+]
+message_on_remove = "PR #{number}'s beta-nomination has been removed."
+
+[notify-zulip."stable-nominated".bootstrap]
+required_labels = ["T-bootstrap"]
+zulip_stream = 507486 # #t-infra/bootstrap/backports
+topic = "#{number}: stable-nominated"
+message_on_add = [
+ """\
+@*T-bootstrap* PR #{number} "{title}" has been nominated for stable backport.
+""",
+ """\
+/poll Approve stable backport of #{number}?
+approve
+approve (but does not justify new dot release on its own)
+decline
+don't know
+""",
+]
+message_on_remove = "PR #{number}'s stable-nomination has been removed."
+
[notify-zulip."A-edition-2021"]
required_labels = ["C-bug"]
zulip_stream = 268952 # #edition
@@ -1231,7 +1243,6 @@
bootstrap = [
"@Mark-Simulacrum",
"@albertlarsan68",
- "@onur-ozkan",
"@kobzol",
"@jieyouxu",
"@clubby789",
@@ -1424,8 +1435,8 @@
"/src/tools/rustdoc-themes" = ["rustdoc"]
"/src/tools/tidy" = ["bootstrap"]
"/src/tools/x" = ["bootstrap"]
-"/src/tools/rustdoc-gui-test" = ["bootstrap", "@onur-ozkan"]
-"/src/tools/libcxx-version" = ["@onur-ozkan"]
+"/src/tools/rustdoc-gui-test" = ["bootstrap"]
+"/src/tools/libcxx-version" = ["bootstrap"]
# Enable review queue tracking
# Documentation at: https://forge.rust-lang.org/triagebot/review-queue-tracking.html