Auto merge of #100356 - matthiaskrgr:rollup-he0vkjc, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #99573 (Stabilize backtrace)
 - #100069 (Add error if link_ordinal used with unsupported link kind)
 - #100086 (Add more `// unit-test`s to MIR opt tests)
 - #100332 (Rename integer log* methods to ilog*)
 - #100334 (Suggest a missing semicolon before an array)
 - #100340 (Iterate generics_def_id_map in reverse order to fix P-critical issue)
 - #100345 (docs: remove repetition in `is_numeric` function docs)
 - #100352 (Update cargo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2022-08-10 06:09:10 +00:00
commit 1603a70f82
65 changed files with 508 additions and 346 deletions

View File

@ -465,6 +465,7 @@ dependencies = [
"termcolor",
"toml_edit",
"url 2.2.2",
"winapi",
]
[[package]]
@ -2655,9 +2656,9 @@ checksum = "dd20eec3dbe4376829cb7d80ae6ac45e0a766831dca50202ff2d40db46a8a024"
[[package]]
name = "os_info"
version = "3.4.0"
version = "3.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eca3ecae1481e12c3d9379ec541b238a16f0b75c9a409942daa8ec20dbfdb62"
checksum = "5209b2162b2c140df493a93689e04f8deab3a67634f5bc7a553c0a98e5b8d399"
dependencies = [
"log",
"serde",

View File

@ -220,7 +220,20 @@ impl ResolverAstLoweringExt for ResolverAstLowering {
}
fn get_remapped_def_id(&self, mut local_def_id: LocalDefId) -> LocalDefId {
for map in &self.generics_def_id_map {
// `generics_def_id_map` is a stack of mappings. As we go deeper in impl traits nesting we
// push new mappings so we need to try first the latest mappings, hence `iter().rev()`.
//
// Consider:
//
// `fn test<'a, 'b>() -> impl Trait<&'a u8, Ty = impl Sized + 'b> {}`
//
// We would end with a generics_def_id_map like:
//
// `[[fn#'b -> impl_trait#'b], [fn#'b -> impl_sized#'b]]`
//
// for the opaque type generated on `impl Sized + 'b`, We want the result to be:
// impl_sized#'b, so iterating forward is the wrong thing to do.
for map in self.generics_def_id_map.iter().rev() {
if let Some(r) = map.get(&local_def_id) {
debug!("def_id_remapper: remapping from `{local_def_id:?}` to `{r:?}`");
local_def_id = *r;

View File

@ -4,7 +4,6 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(drain_filter)]
#![feature(backtrace)]
#![feature(if_let_guard)]
#![cfg_attr(bootstrap, feature(let_chains))]
#![feature(let_else)]

View File

@ -328,7 +328,31 @@ impl<'tcx> Collector<'tcx> {
.map(|child_item| self.build_dll_import(abi, child_item))
.collect()
}
_ => Vec::new(),
_ => {
for child_item in foreign_mod_items {
if self.tcx.def_kind(child_item.id.def_id).has_codegen_attrs()
&& self
.tcx
.codegen_fn_attrs(child_item.id.def_id)
.link_ordinal
.is_some()
{
let link_ordinal_attr = self
.tcx
.hir()
.attrs(self.tcx.hir().local_def_id_to_hir_id(child_item.id.def_id))
.iter()
.find(|a| a.has_name(sym::link_ordinal))
.unwrap();
sess.span_err(
link_ordinal_attr.span,
"`#[link_ordinal]` is only supported if link kind is `raw-dylib`",
);
}
}
Vec::new()
}
};
self.libs.push(NativeLib {
name: name.map(|(name, _)| name),

View File

@ -26,7 +26,6 @@
#![feature(allocator_api)]
#![feature(array_windows)]
#![feature(assert_matches)]
#![feature(backtrace)]
#![feature(box_patterns)]
#![feature(core_intrinsics)]
#![feature(discriminant_kind)]

View File

@ -1258,8 +1258,11 @@ impl<'a> Parser<'a> {
/// Parse an indexing expression `expr[...]`.
fn parse_index_expr(&mut self, lo: Span, base: P<Expr>) -> PResult<'a, P<Expr>> {
let prev_span = self.prev_token.span;
let open_delim_span = self.token.span;
self.bump(); // `[`
let index = self.parse_expr()?;
self.suggest_missing_semicolon_before_array(prev_span, open_delim_span)?;
self.expect(&token::CloseDelim(Delimiter::Bracket))?;
Ok(self.mk_expr(lo.to(self.prev_token.span), self.mk_index(base, index), AttrVec::new()))
}
@ -2056,6 +2059,45 @@ impl<'a> Parser<'a> {
}
}
fn suggest_missing_semicolon_before_array(
&self,
prev_span: Span,
open_delim_span: Span,
) -> PResult<'a, ()> {
if self.token.kind == token::Comma {
let mut snapshot = self.create_snapshot_for_diagnostic();
snapshot.bump();
match snapshot.parse_seq_to_before_end(
&token::CloseDelim(Delimiter::Bracket),
SeqSep::trailing_allowed(token::Comma),
|p| p.parse_expr(),
) {
Ok(_)
// When the close delim is `)`, `token.kind` is expected to be `token::CloseDelim(Delimiter::Parenthesis)`,
// but the actual `token.kind` is `token::CloseDelim(Delimiter::Bracket)`.
// This is because the `token.kind` of the close delim is treated as the same as
// that of the open delim in `TokenTreesReader::parse_token_tree`, even if the delimiters of them are different.
// Therefore, `token.kind` should not be compared here.
if snapshot
.span_to_snippet(snapshot.token.span)
.map_or(false, |snippet| snippet == "]") =>
{
let mut err = self.struct_span_err(open_delim_span, "expected `;`, found `[`");
err.span_suggestion_verbose(
prev_span.shrink_to_hi(),
"consider adding `;` here",
';',
Applicability::MaybeIncorrect,
);
return Err(err);
}
Ok(_) => (),
Err(err) => err.cancel(),
}
}
Ok(())
}
/// Parses a block or unsafe block.
pub(super) fn parse_block_expr(
&mut self,

View File

@ -9,7 +9,7 @@ macro_rules! int_log_bench {
for n in 0..(<$t>::BITS / 8) {
for i in 1..=(100 as $t) {
let x = black_box(i << (n * 8));
black_box(x.log10());
black_box(x.ilog10());
}
}
});
@ -27,7 +27,7 @@ macro_rules! int_log_bench {
.collect();
bench.iter(|| {
for x in &numbers {
black_box(black_box(x).log10());
black_box(black_box(x).ilog10());
}
});
}
@ -44,7 +44,7 @@ macro_rules! int_log_bench {
.collect();
bench.iter(|| {
for x in &numbers {
black_box(black_box(x).log10());
black_box(black_box(x).ilog10());
}
});
}

View File

@ -892,8 +892,7 @@ impl char {
///
/// The general categories for numbers (`Nd` for decimal digits, `Nl` for letter-like numeric
/// characters, and `No` for other numeric characters) are specified in the [Unicode Character
/// Database][ucd] [`UnicodeData.txt`]. Note that this means ideographic numbers like '三'
/// are considered alphabetic, not numeric. Please consider to use `is_ascii_digit` or `is_digit`.
/// Database][ucd] [`UnicodeData.txt`].
///
/// This method doesn't cover everything that could be considered a number, e.g. ideographic numbers like '三'.
/// If you want everything including characters with overlapping purposes then you might want to use

View File

@ -137,7 +137,7 @@ macro_rules! define_bignum {
// Find the most significant non-zero digit.
let msd = digits.iter().rposition(|&x| x != 0);
match msd {
Some(msd) => msd * digitbits + digits[msd].log2() as usize + 1,
Some(msd) => msd * digitbits + digits[msd].ilog2() as usize + 1,
// There are no non-zero digits, i.e., the number is zero.
_ => 0,
}

View File

@ -2204,7 +2204,7 @@ macro_rules! int_impl {
/// rounded down.
///
/// This method might not be optimized owing to implementation details;
/// `log2` can produce results more efficiently for base 2, and `log10`
/// `ilog2` can produce results more efficiently for base 2, and `ilog10`
/// can produce results more efficiently for base 10.
///
/// # Panics
@ -2217,7 +2217,7 @@ macro_rules! int_impl {
///
/// ```
/// #![feature(int_log)]
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".log(5), 1);")]
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".ilog(5), 1);")]
/// ```
#[unstable(feature = "int_log", issue = "70887")]
#[must_use = "this returns the result of the operation, \
@ -2226,8 +2226,8 @@ macro_rules! int_impl {
#[track_caller]
#[rustc_inherit_overflow_checks]
#[allow(arithmetic_overflow)]
pub const fn log(self, base: Self) -> u32 {
match self.checked_log(base) {
pub const fn ilog(self, base: Self) -> u32 {
match self.checked_ilog(base) {
Some(n) => n,
None => {
// In debug builds, trigger a panic on None.
@ -2250,7 +2250,7 @@ macro_rules! int_impl {
///
/// ```
/// #![feature(int_log)]
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".log2(), 1);")]
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".ilog2(), 1);")]
/// ```
#[unstable(feature = "int_log", issue = "70887")]
#[must_use = "this returns the result of the operation, \
@ -2259,8 +2259,8 @@ macro_rules! int_impl {
#[track_caller]
#[rustc_inherit_overflow_checks]
#[allow(arithmetic_overflow)]
pub const fn log2(self) -> u32 {
match self.checked_log2() {
pub const fn ilog2(self) -> u32 {
match self.checked_ilog2() {
Some(n) => n,
None => {
// In debug builds, trigger a panic on None.
@ -2283,7 +2283,7 @@ macro_rules! int_impl {
///
/// ```
/// #![feature(int_log)]
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".log10(), 1);")]
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".ilog10(), 1);")]
/// ```
#[unstable(feature = "int_log", issue = "70887")]
#[must_use = "this returns the result of the operation, \
@ -2292,8 +2292,8 @@ macro_rules! int_impl {
#[track_caller]
#[rustc_inherit_overflow_checks]
#[allow(arithmetic_overflow)]
pub const fn log10(self) -> u32 {
match self.checked_log10() {
pub const fn ilog10(self) -> u32 {
match self.checked_ilog10() {
Some(n) => n,
None => {
// In debug builds, trigger a panic on None.
@ -2311,20 +2311,20 @@ macro_rules! int_impl {
/// Returns `None` if the number is negative or zero, or if the base is not at least 2.
///
/// This method might not be optimized owing to implementation details;
/// `checked_log2` can produce results more efficiently for base 2, and
/// `checked_log10` can produce results more efficiently for base 10.
/// `checked_ilog2` can produce results more efficiently for base 2, and
/// `checked_ilog10` can produce results more efficiently for base 10.
///
/// # Examples
///
/// ```
/// #![feature(int_log)]
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_log(5), Some(1));")]
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_ilog(5), Some(1));")]
/// ```
#[unstable(feature = "int_log", issue = "70887")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
pub const fn checked_log(self, base: Self) -> Option<u32> {
pub const fn checked_ilog(self, base: Self) -> Option<u32> {
if self <= 0 || base <= 1 {
None
} else {
@ -2333,7 +2333,7 @@ macro_rules! int_impl {
// Optimization for 128 bit wide integers.
if Self::BITS == 128 {
let b = Self::log2(self) / (Self::log2(base) + 1);
let b = Self::ilog2(self) / (Self::ilog2(base) + 1);
n += b;
r /= base.pow(b as u32);
}
@ -2354,13 +2354,13 @@ macro_rules! int_impl {
///
/// ```
/// #![feature(int_log)]
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".checked_log2(), Some(1));")]
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".checked_ilog2(), Some(1));")]
/// ```
#[unstable(feature = "int_log", issue = "70887")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
pub const fn checked_log2(self) -> Option<u32> {
pub const fn checked_ilog2(self) -> Option<u32> {
if self <= 0 {
None
} else {
@ -2378,13 +2378,13 @@ macro_rules! int_impl {
///
/// ```
/// #![feature(int_log)]
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".checked_log10(), Some(1));")]
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".checked_ilog10(), Some(1));")]
/// ```
#[unstable(feature = "int_log", issue = "70887")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
pub const fn checked_log10(self) -> Option<u32> {
pub const fn checked_ilog10(self) -> Option<u32> {
if self > 0 {
Some(int_log10::$ActualT(self as $ActualT))
} else {

View File

@ -450,7 +450,7 @@ macro_rules! nonzero_unsigned_operations {
/// Returns the base 2 logarithm of the number, rounded down.
///
/// This is the same operation as
#[doc = concat!("[`", stringify!($Int), "::log2`],")]
#[doc = concat!("[`", stringify!($Int), "::ilog2`],")]
/// except that it has no failure cases to worry about
/// since this value can never be zero.
///
@ -460,22 +460,22 @@ macro_rules! nonzero_unsigned_operations {
/// #![feature(int_log)]
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
///
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(7).unwrap().log2(), 2);")]
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(8).unwrap().log2(), 3);")]
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(9).unwrap().log2(), 3);")]
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(7).unwrap().ilog2(), 2);")]
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(8).unwrap().ilog2(), 3);")]
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(9).unwrap().ilog2(), 3);")]
/// ```
#[unstable(feature = "int_log", issue = "70887")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
pub const fn log2(self) -> u32 {
pub const fn ilog2(self) -> u32 {
Self::BITS - 1 - self.leading_zeros()
}
/// Returns the base 10 logarithm of the number, rounded down.
///
/// This is the same operation as
#[doc = concat!("[`", stringify!($Int), "::log10`],")]
#[doc = concat!("[`", stringify!($Int), "::ilog10`],")]
/// except that it has no failure cases to worry about
/// since this value can never be zero.
///
@ -485,15 +485,15 @@ macro_rules! nonzero_unsigned_operations {
/// #![feature(int_log)]
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
///
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(99).unwrap().log10(), 1);")]
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(100).unwrap().log10(), 2);")]
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(101).unwrap().log10(), 2);")]
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(99).unwrap().ilog10(), 1);")]
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(100).unwrap().ilog10(), 2);")]
#[doc = concat!("assert_eq!(", stringify!($Ty), "::new(101).unwrap().ilog10(), 2);")]
/// ```
#[unstable(feature = "int_log", issue = "70887")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
pub const fn log10(self) -> u32 {
pub const fn ilog10(self) -> u32 {
super::int_log10::$Int(self.0)
}
}

View File

@ -700,7 +700,7 @@ macro_rules! uint_impl {
///
/// ```
/// #![feature(int_log)]
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".log(5), 1);")]
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".ilog(5), 1);")]
/// ```
#[unstable(feature = "int_log", issue = "70887")]
#[must_use = "this returns the result of the operation, \
@ -709,8 +709,8 @@ macro_rules! uint_impl {
#[track_caller]
#[rustc_inherit_overflow_checks]
#[allow(arithmetic_overflow)]
pub const fn log(self, base: Self) -> u32 {
match self.checked_log(base) {
pub const fn ilog(self, base: Self) -> u32 {
match self.checked_ilog(base) {
Some(n) => n,
None => {
// In debug builds, trigger a panic on None.
@ -733,7 +733,7 @@ macro_rules! uint_impl {
///
/// ```
/// #![feature(int_log)]
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".log2(), 1);")]
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".ilog2(), 1);")]
/// ```
#[unstable(feature = "int_log", issue = "70887")]
#[must_use = "this returns the result of the operation, \
@ -742,8 +742,8 @@ macro_rules! uint_impl {
#[track_caller]
#[rustc_inherit_overflow_checks]
#[allow(arithmetic_overflow)]
pub const fn log2(self) -> u32 {
match self.checked_log2() {
pub const fn ilog2(self) -> u32 {
match self.checked_ilog2() {
Some(n) => n,
None => {
// In debug builds, trigger a panic on None.
@ -766,7 +766,7 @@ macro_rules! uint_impl {
///
/// ```
/// #![feature(int_log)]
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".log10(), 1);")]
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".ilog10(), 1);")]
/// ```
#[unstable(feature = "int_log", issue = "70887")]
#[must_use = "this returns the result of the operation, \
@ -775,8 +775,8 @@ macro_rules! uint_impl {
#[track_caller]
#[rustc_inherit_overflow_checks]
#[allow(arithmetic_overflow)]
pub const fn log10(self) -> u32 {
match self.checked_log10() {
pub const fn ilog10(self) -> u32 {
match self.checked_ilog10() {
Some(n) => n,
None => {
// In debug builds, trigger a panic on None.
@ -794,20 +794,20 @@ macro_rules! uint_impl {
/// Returns `None` if the number is zero, or if the base is not at least 2.
///
/// This method might not be optimized owing to implementation details;
/// `checked_log2` can produce results more efficiently for base 2, and
/// `checked_log10` can produce results more efficiently for base 10.
/// `checked_ilog2` can produce results more efficiently for base 2, and
/// `checked_ilog10` can produce results more efficiently for base 10.
///
/// # Examples
///
/// ```
/// #![feature(int_log)]
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_log(5), Some(1));")]
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_ilog(5), Some(1));")]
/// ```
#[unstable(feature = "int_log", issue = "70887")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
pub const fn checked_log(self, base: Self) -> Option<u32> {
pub const fn checked_ilog(self, base: Self) -> Option<u32> {
if self <= 0 || base <= 1 {
None
} else {
@ -816,7 +816,7 @@ macro_rules! uint_impl {
// Optimization for 128 bit wide integers.
if Self::BITS == 128 {
let b = Self::log2(self) / (Self::log2(base) + 1);
let b = Self::ilog2(self) / (Self::ilog2(base) + 1);
n += b;
r /= base.pow(b as u32);
}
@ -837,15 +837,15 @@ macro_rules! uint_impl {
///
/// ```
/// #![feature(int_log)]
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".checked_log2(), Some(1));")]
#[doc = concat!("assert_eq!(2", stringify!($SelfT), ".checked_ilog2(), Some(1));")]
/// ```
#[unstable(feature = "int_log", issue = "70887")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
pub const fn checked_log2(self) -> Option<u32> {
pub const fn checked_ilog2(self) -> Option<u32> {
if let Some(x) = <$NonZeroT>::new(self) {
Some(x.log2())
Some(x.ilog2())
} else {
None
}
@ -859,15 +859,15 @@ macro_rules! uint_impl {
///
/// ```
/// #![feature(int_log)]
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".checked_log10(), Some(1));")]
#[doc = concat!("assert_eq!(10", stringify!($SelfT), ".checked_ilog10(), Some(1));")]
/// ```
#[unstable(feature = "int_log", issue = "70887")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
pub const fn checked_log10(self) -> Option<u32> {
pub const fn checked_ilog10(self) -> Option<u32> {
if let Some(x) = <$NonZeroT>::new(self) {
Some(x.log10())
Some(x.ilog10())
} else {
None
}

View File

@ -1135,7 +1135,7 @@ impl fmt::Debug for Duration {
// 2. The postfix: can be "µs" so we have to count UTF8 characters.
let mut actual_w = prefix.len() + postfix.chars().count();
// 3. The integer part:
if let Some(log) = integer_part.checked_log10() {
if let Some(log) = integer_part.checked_ilog10() {
// integer_part is > 0, so has length log10(x)+1
actual_w += 1 + log as usize;
} else {

View File

@ -1,166 +1,166 @@
//! This tests the `Integer::{log,log2,log10}` methods. These tests are in a
//! This tests the `Integer::{ilog,log2,log10}` methods. These tests are in a
//! separate file because there's both a large number of them, and not all tests
//! can be run on Android. This is because in Android `log2` uses an imprecise
//! can be run on Android. This is because in Android `ilog2` uses an imprecise
//! approximation:https://github.com/rust-lang/rust/blob/4825e12fc9c79954aa0fe18f5521efa6c19c7539/src/libstd/sys/unix/android.rs#L27-L53
#[test]
fn checked_log() {
assert_eq!(999u32.checked_log(10), Some(2));
assert_eq!(1000u32.checked_log(10), Some(3));
assert_eq!(555u32.checked_log(13), Some(2));
assert_eq!(63u32.checked_log(4), Some(2));
assert_eq!(64u32.checked_log(4), Some(3));
assert_eq!(10460353203u64.checked_log(3), Some(21));
assert_eq!(10460353202u64.checked_log(3), Some(20));
assert_eq!(147808829414345923316083210206383297601u128.checked_log(3), Some(80));
assert_eq!(147808829414345923316083210206383297600u128.checked_log(3), Some(79));
assert_eq!(22528399544939174411840147874772641u128.checked_log(19683), Some(8));
assert_eq!(22528399544939174411840147874772631i128.checked_log(19683), Some(7));
fn checked_ilog() {
assert_eq!(999u32.checked_ilog(10), Some(2));
assert_eq!(1000u32.checked_ilog(10), Some(3));
assert_eq!(555u32.checked_ilog(13), Some(2));
assert_eq!(63u32.checked_ilog(4), Some(2));
assert_eq!(64u32.checked_ilog(4), Some(3));
assert_eq!(10460353203u64.checked_ilog(3), Some(21));
assert_eq!(10460353202u64.checked_ilog(3), Some(20));
assert_eq!(147808829414345923316083210206383297601u128.checked_ilog(3), Some(80));
assert_eq!(147808829414345923316083210206383297600u128.checked_ilog(3), Some(79));
assert_eq!(22528399544939174411840147874772641u128.checked_ilog(19683), Some(8));
assert_eq!(22528399544939174411840147874772631i128.checked_ilog(19683), Some(7));
assert_eq!(0u8.checked_log(4), None);
assert_eq!(0u16.checked_log(4), None);
assert_eq!(0i8.checked_log(4), None);
assert_eq!(0i16.checked_log(4), None);
assert_eq!(0u8.checked_ilog(4), None);
assert_eq!(0u16.checked_ilog(4), None);
assert_eq!(0i8.checked_ilog(4), None);
assert_eq!(0i16.checked_ilog(4), None);
#[cfg(not(miri))] // Miri is too slow
for i in i16::MIN..=0 {
assert_eq!(i.checked_log(4), None);
assert_eq!(i.checked_ilog(4), None);
}
#[cfg(not(miri))] // Miri is too slow
for i in 1..=i16::MAX {
assert_eq!(i.checked_log(13), Some((i as f32).log(13.0) as u32));
assert_eq!(i.checked_ilog(13), Some((i as f32).log(13.0) as u32));
}
#[cfg(not(miri))] // Miri is too slow
for i in 1..=u16::MAX {
assert_eq!(i.checked_log(13), Some((i as f32).log(13.0) as u32));
assert_eq!(i.checked_ilog(13), Some((i as f32).log(13.0) as u32));
}
}
#[test]
fn checked_log2() {
assert_eq!(5u32.checked_log2(), Some(2));
assert_eq!(0u64.checked_log2(), None);
assert_eq!(128i32.checked_log2(), Some(7));
assert_eq!((-55i16).checked_log2(), None);
fn checked_ilog2() {
assert_eq!(5u32.checked_ilog2(), Some(2));
assert_eq!(0u64.checked_ilog2(), None);
assert_eq!(128i32.checked_ilog2(), Some(7));
assert_eq!((-55i16).checked_ilog2(), None);
assert_eq!(0u8.checked_log2(), None);
assert_eq!(0u16.checked_log2(), None);
assert_eq!(0i8.checked_log2(), None);
assert_eq!(0i16.checked_log2(), None);
assert_eq!(0u8.checked_ilog2(), None);
assert_eq!(0u16.checked_ilog2(), None);
assert_eq!(0i8.checked_ilog2(), None);
assert_eq!(0i16.checked_ilog2(), None);
for i in 1..=u8::MAX {
assert_eq!(i.checked_log2(), Some((i as f32).log2() as u32));
assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32));
}
#[cfg(not(miri))] // Miri is too slow
for i in 1..=u16::MAX {
// Guard against Android's imprecise f32::log2 implementation.
// Guard against Android's imprecise f32::ilog2 implementation.
if i != 8192 && i != 32768 {
assert_eq!(i.checked_log2(), Some((i as f32).log2() as u32));
assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32));
}
}
for i in i8::MIN..=0 {
assert_eq!(i.checked_log2(), None);
assert_eq!(i.checked_ilog2(), None);
}
for i in 1..=i8::MAX {
assert_eq!(i.checked_log2(), Some((i as f32).log2() as u32));
assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32));
}
#[cfg(not(miri))] // Miri is too slow
for i in i16::MIN..=0 {
assert_eq!(i.checked_log2(), None);
assert_eq!(i.checked_ilog2(), None);
}
#[cfg(not(miri))] // Miri is too slow
for i in 1..=i16::MAX {
// Guard against Android's imprecise f32::log2 implementation.
// Guard against Android's imprecise f32::ilog2 implementation.
if i != 8192 {
assert_eq!(i.checked_log2(), Some((i as f32).log2() as u32));
assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32));
}
}
}
// Validate cases that fail on Android's imprecise float log2 implementation.
// Validate cases that fail on Android's imprecise float ilog2 implementation.
#[test]
#[cfg(not(target_os = "android"))]
fn checked_log2_not_android() {
assert_eq!(8192u16.checked_log2(), Some((8192f32).log2() as u32));
assert_eq!(32768u16.checked_log2(), Some((32768f32).log2() as u32));
assert_eq!(8192i16.checked_log2(), Some((8192f32).log2() as u32));
fn checked_ilog2_not_android() {
assert_eq!(8192u16.checked_ilog2(), Some((8192f32).log2() as u32));
assert_eq!(32768u16.checked_ilog2(), Some((32768f32).log2() as u32));
assert_eq!(8192i16.checked_ilog2(), Some((8192f32).log2() as u32));
}
#[test]
fn checked_log10() {
assert_eq!(0u8.checked_log10(), None);
assert_eq!(0u16.checked_log10(), None);
assert_eq!(0i8.checked_log10(), None);
assert_eq!(0i16.checked_log10(), None);
fn checked_ilog10() {
assert_eq!(0u8.checked_ilog10(), None);
assert_eq!(0u16.checked_ilog10(), None);
assert_eq!(0i8.checked_ilog10(), None);
assert_eq!(0i16.checked_ilog10(), None);
#[cfg(not(miri))] // Miri is too slow
for i in i16::MIN..=0 {
assert_eq!(i.checked_log10(), None);
assert_eq!(i.checked_ilog10(), None);
}
#[cfg(not(miri))] // Miri is too slow
for i in 1..=i16::MAX {
assert_eq!(i.checked_log10(), Some((i as f32).log10() as u32));
assert_eq!(i.checked_ilog10(), Some((i as f32).log10() as u32));
}
#[cfg(not(miri))] // Miri is too slow
for i in 1..=u16::MAX {
assert_eq!(i.checked_log10(), Some((i as f32).log10() as u32));
assert_eq!(i.checked_ilog10(), Some((i as f32).log10() as u32));
}
#[cfg(not(miri))] // Miri is too slow
for i in 1..=100_000u32 {
assert_eq!(i.checked_log10(), Some((i as f32).log10() as u32));
assert_eq!(i.checked_ilog10(), Some((i as f32).log10() as u32));
}
}
macro_rules! log10_loop {
($T:ty, $log10_max:expr) => {
assert_eq!(<$T>::MAX.log10(), $log10_max);
for i in 0..=$log10_max {
macro_rules! ilog10_loop {
($T:ty, $ilog10_max:expr) => {
assert_eq!(<$T>::MAX.ilog10(), $ilog10_max);
for i in 0..=$ilog10_max {
let p = (10 as $T).pow(i as u32);
if p >= 10 {
assert_eq!((p - 9).log10(), i - 1);
assert_eq!((p - 1).log10(), i - 1);
assert_eq!((p - 9).ilog10(), i - 1);
assert_eq!((p - 1).ilog10(), i - 1);
}
assert_eq!(p.log10(), i);
assert_eq!((p + 1).log10(), i);
assert_eq!(p.ilog10(), i);
assert_eq!((p + 1).ilog10(), i);
if p >= 10 {
assert_eq!((p + 9).log10(), i);
assert_eq!((p + 9).ilog10(), i);
}
// also check `x.log(10)`
// also check `x.ilog(10)`
if p >= 10 {
assert_eq!((p - 9).log(10), i - 1);
assert_eq!((p - 1).log(10), i - 1);
assert_eq!((p - 9).ilog(10), i - 1);
assert_eq!((p - 1).ilog(10), i - 1);
}
assert_eq!(p.log(10), i);
assert_eq!((p + 1).log(10), i);
assert_eq!(p.ilog(10), i);
assert_eq!((p + 1).ilog(10), i);
if p >= 10 {
assert_eq!((p + 9).log(10), i);
assert_eq!((p + 9).ilog(10), i);
}
}
};
}
#[test]
fn log10_u8() {
log10_loop! { u8, 2 }
fn ilog10_u8() {
ilog10_loop! { u8, 2 }
}
#[test]
fn log10_u16() {
log10_loop! { u16, 4 }
fn ilog10_u16() {
ilog10_loop! { u16, 4 }
}
#[test]
fn log10_u32() {
log10_loop! { u32, 9 }
fn ilog10_u32() {
ilog10_loop! { u32, 9 }
}
#[test]
fn log10_u64() {
log10_loop! { u64, 19 }
fn ilog10_u64() {
ilog10_loop! { u64, 19 }
}
#[test]
fn log10_u128() {
log10_loop! { u128, 38 }
fn ilog10_u128() {
ilog10_loop! { u128, 38 }
}

View File

@ -9,12 +9,6 @@
//! implementing `std::error::Error`) to get a causal chain of where an error
//! was generated.
//!
//! > **Note**: this module is unstable and is designed in [RFC 2504], and you
//! > can learn more about its status in the [tracking issue].
//!
//! [RFC 2504]: https://github.com/rust-lang/rfcs/blob/master/text/2504-fix-error.md
//! [tracking issue]: https://github.com/rust-lang/rust/issues/53487
//!
//! ## Accuracy
//!
//! Backtraces are attempted to be as accurate as possible, but no guarantees
@ -64,7 +58,7 @@
//! `RUST_LIB_BACKTRACE` or `RUST_BACKTRACE` at runtime might not actually change
//! how backtraces are captured.
#![unstable(feature = "backtrace", issue = "53487")]
#![stable(feature = "backtrace", since = "1.65.0")]
#[cfg(test)]
mod tests;
@ -110,6 +104,7 @@ use crate::vec::Vec;
/// previous point in time. In some instances the `Backtrace` type may
/// internally be empty due to configuration. For more information see
/// `Backtrace::capture`.
#[stable(feature = "backtrace", since = "1.65.0")]
#[must_use]
pub struct Backtrace {
inner: Inner,
@ -117,6 +112,7 @@ pub struct Backtrace {
/// The current status of a backtrace, indicating whether it was captured or
/// whether it is empty for some other reason.
#[stable(feature = "backtrace", since = "1.65.0")]
#[non_exhaustive]
#[derive(Debug, PartialEq, Eq)]
pub enum BacktraceStatus {
@ -174,6 +170,7 @@ enum BytesOrWide {
Wide(Vec<u16>),
}
#[stable(feature = "backtrace", since = "1.65.0")]
impl fmt::Debug for Backtrace {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
let capture = match &self.inner {
@ -200,6 +197,7 @@ impl fmt::Debug for Backtrace {
}
}
#[unstable(feature = "backtrace_frames", issue = "79676")]
impl fmt::Debug for BacktraceFrame {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut dbg = fmt.debug_list();
@ -288,6 +286,7 @@ impl Backtrace {
///
/// To forcibly capture a backtrace regardless of environment variables, use
/// the `Backtrace::force_capture` function.
#[stable(feature = "backtrace", since = "1.65.0")]
#[inline(never)] // want to make sure there's a frame here to remove
pub fn capture() -> Backtrace {
if !Backtrace::enabled() {
@ -306,6 +305,7 @@ impl Backtrace {
/// Note that capturing a backtrace can be an expensive operation on some
/// platforms, so this should be used with caution in performance-sensitive
/// parts of code.
#[stable(feature = "backtrace", since = "1.65.0")]
#[inline(never)] // want to make sure there's a frame here to remove
pub fn force_capture() -> Backtrace {
Backtrace::create(Backtrace::force_capture as usize)
@ -313,6 +313,8 @@ impl Backtrace {
/// Forcibly captures a disabled backtrace, regardless of environment
/// variable configuration.
#[stable(feature = "backtrace", since = "1.65.0")]
#[rustc_const_stable(feature = "backtrace", since = "1.65.0")]
pub const fn disabled() -> Backtrace {
Backtrace { inner: Inner::Disabled }
}
@ -356,6 +358,7 @@ impl Backtrace {
/// Returns the status of this backtrace, indicating whether this backtrace
/// request was unsupported, disabled, or a stack trace was actually
/// captured.
#[stable(feature = "backtrace", since = "1.65.0")]
#[must_use]
pub fn status(&self) -> BacktraceStatus {
match self.inner {
@ -375,6 +378,7 @@ impl<'a> Backtrace {
}
}
#[stable(feature = "backtrace", since = "1.65.0")]
impl fmt::Display for Backtrace {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
let capture = match &self.inner {

View File

@ -1454,7 +1454,6 @@ impl<E> Report<E> {
///
/// ```rust
/// #![feature(error_reporter)]
/// #![feature(backtrace)]
/// #![feature(provide_any)]
/// #![feature(error_generic_member_access)]
/// # use std::error::Error;

View File

@ -1,3 +1,5 @@
// unit-test: InstCombine
// EMIT_MIR bool_compare.opt1.InstCombine.diff
fn opt1(x: bool) -> u32 {
if x != true { 0 } else { 1 }

View File

@ -1,77 +0,0 @@
- // MIR for `norm2` before InstCombine
+ // MIR for `norm2` after InstCombine
fn norm2(_1: [f32; 2]) -> f32 {
debug x => _1; // in scope 0 at $DIR/combine_array_len.rs:+0:10: +0:11
let mut _0: f32; // return place in scope 0 at $DIR/combine_array_len.rs:+0:26: +0:29
let _2: f32; // in scope 0 at $DIR/combine_array_len.rs:+1:9: +1:10
let _3: usize; // in scope 0 at $DIR/combine_array_len.rs:+1:15: +1:16
let mut _4: usize; // in scope 0 at $DIR/combine_array_len.rs:+1:13: +1:17
let mut _5: bool; // in scope 0 at $DIR/combine_array_len.rs:+1:13: +1:17
let _7: usize; // in scope 0 at $DIR/combine_array_len.rs:+2:15: +2:16
let mut _8: usize; // in scope 0 at $DIR/combine_array_len.rs:+2:13: +2:17
let mut _9: bool; // in scope 0 at $DIR/combine_array_len.rs:+2:13: +2:17
let mut _10: f32; // in scope 0 at $DIR/combine_array_len.rs:+3:5: +3:8
let mut _11: f32; // in scope 0 at $DIR/combine_array_len.rs:+3:5: +3:6
let mut _12: f32; // in scope 0 at $DIR/combine_array_len.rs:+3:7: +3:8
let mut _13: f32; // in scope 0 at $DIR/combine_array_len.rs:+3:11: +3:14
let mut _14: f32; // in scope 0 at $DIR/combine_array_len.rs:+3:11: +3:12
let mut _15: f32; // in scope 0 at $DIR/combine_array_len.rs:+3:13: +3:14
scope 1 {
debug a => _2; // in scope 1 at $DIR/combine_array_len.rs:+1:9: +1:10
let _6: f32; // in scope 1 at $DIR/combine_array_len.rs:+2:9: +2:10
scope 2 {
debug b => _6; // in scope 2 at $DIR/combine_array_len.rs:+2:9: +2:10
}
}
bb0: {
StorageLive(_2); // scope 0 at $DIR/combine_array_len.rs:+1:9: +1:10
StorageLive(_3); // scope 0 at $DIR/combine_array_len.rs:+1:15: +1:16
_3 = const 0_usize; // scope 0 at $DIR/combine_array_len.rs:+1:15: +1:16
- _4 = Len(_1); // scope 0 at $DIR/combine_array_len.rs:+1:13: +1:17
+ _4 = const 2_usize; // scope 0 at $DIR/combine_array_len.rs:+1:13: +1:17
_5 = Lt(_3, _4); // scope 0 at $DIR/combine_array_len.rs:+1:13: +1:17
assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1; // scope 0 at $DIR/combine_array_len.rs:+1:13: +1:17
}
bb1: {
_2 = _1[_3]; // scope 0 at $DIR/combine_array_len.rs:+1:13: +1:17
StorageDead(_3); // scope 0 at $DIR/combine_array_len.rs:+1:17: +1:18
StorageLive(_6); // scope 1 at $DIR/combine_array_len.rs:+2:9: +2:10
StorageLive(_7); // scope 1 at $DIR/combine_array_len.rs:+2:15: +2:16
_7 = const 1_usize; // scope 1 at $DIR/combine_array_len.rs:+2:15: +2:16
- _8 = Len(_1); // scope 1 at $DIR/combine_array_len.rs:+2:13: +2:17
+ _8 = const 2_usize; // scope 1 at $DIR/combine_array_len.rs:+2:13: +2:17
_9 = Lt(_7, _8); // scope 1 at $DIR/combine_array_len.rs:+2:13: +2:17
assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> bb2; // scope 1 at $DIR/combine_array_len.rs:+2:13: +2:17
}
bb2: {
_6 = _1[_7]; // scope 1 at $DIR/combine_array_len.rs:+2:13: +2:17
StorageDead(_7); // scope 1 at $DIR/combine_array_len.rs:+2:17: +2:18
StorageLive(_10); // scope 2 at $DIR/combine_array_len.rs:+3:5: +3:8
StorageLive(_11); // scope 2 at $DIR/combine_array_len.rs:+3:5: +3:6
_11 = _2; // scope 2 at $DIR/combine_array_len.rs:+3:5: +3:6
StorageLive(_12); // scope 2 at $DIR/combine_array_len.rs:+3:7: +3:8
_12 = _2; // scope 2 at $DIR/combine_array_len.rs:+3:7: +3:8
_10 = Mul(move _11, move _12); // scope 2 at $DIR/combine_array_len.rs:+3:5: +3:8
StorageDead(_12); // scope 2 at $DIR/combine_array_len.rs:+3:7: +3:8
StorageDead(_11); // scope 2 at $DIR/combine_array_len.rs:+3:7: +3:8
StorageLive(_13); // scope 2 at $DIR/combine_array_len.rs:+3:11: +3:14
StorageLive(_14); // scope 2 at $DIR/combine_array_len.rs:+3:11: +3:12
_14 = _6; // scope 2 at $DIR/combine_array_len.rs:+3:11: +3:12
StorageLive(_15); // scope 2 at $DIR/combine_array_len.rs:+3:13: +3:14
_15 = _6; // scope 2 at $DIR/combine_array_len.rs:+3:13: +3:14
_13 = Mul(move _14, move _15); // scope 2 at $DIR/combine_array_len.rs:+3:11: +3:14
StorageDead(_15); // scope 2 at $DIR/combine_array_len.rs:+3:13: +3:14
StorageDead(_14); // scope 2 at $DIR/combine_array_len.rs:+3:13: +3:14
_0 = Add(move _10, move _13); // scope 2 at $DIR/combine_array_len.rs:+3:5: +3:14
StorageDead(_13); // scope 2 at $DIR/combine_array_len.rs:+3:13: +3:14
StorageDead(_10); // scope 2 at $DIR/combine_array_len.rs:+3:13: +3:14
StorageDead(_6); // scope 1 at $DIR/combine_array_len.rs:+4:1: +4:2
StorageDead(_2); // scope 0 at $DIR/combine_array_len.rs:+4:1: +4:2
return; // scope 0 at $DIR/combine_array_len.rs:+4:2: +4:2
}
}

View File

@ -1,4 +1,4 @@
// EMIT_MIR_FOR_EACH_BIT_WIDTH
// unit-test: InstCombine
// EMIT_MIR combine_array_len.norm2.InstCombine.diff
fn norm2(x: [f32; 2]) -> f32 {

View File

@ -1,3 +1,5 @@
// unit-test: ConstGoto
pub enum Foo {
A,
B,

View File

@ -17,7 +17,7 @@
bb0: {
StorageLive(_1); // scope 0 at $DIR/const_goto_storage.rs:+1:9: +1:12
- StorageLive(_2); // scope 0 at $DIR/const_goto_storage.rs:+1:21: +1:23
- nop; // scope 0 at $DIR/const_goto_storage.rs:+1:21: +1:23
- Deinit(_2); // scope 0 at $DIR/const_goto_storage.rs:+1:21: +1:23
- StorageLive(_3); // scope 0 at $DIR/const_goto_storage.rs:+2:15: +6:10
- StorageLive(_4); // scope 0 at $DIR/const_goto_storage.rs:+2:18: +2:76
- StorageLive(_5); // scope 0 at $DIR/const_goto_storage.rs:+2:21: +2:52

View File

@ -1,3 +1,5 @@
// unit-test: ConstGoto
// EMIT_MIR const_goto_storage.match_nested_if.ConstGoto.diff
fn match_nested_if() -> bool {
let val = match () {

View File

@ -1,3 +1,5 @@
// unit-test: Deaggregator
struct Baz {
x: usize,
y: f32,

View File

@ -1,3 +1,5 @@
// unit-test: Deaggregator
enum Baz {
Empty,
Foo { x: usize },

View File

@ -1,3 +1,4 @@
// unit-test: Deaggregator
// Test that deaggregate fires in more than one basic block
enum Foo {

View File

@ -1,3 +1,4 @@
// unit-test: Deaggregator
// Test that deaggregate fires more than once per block
enum Foo {

View File

@ -7,101 +7,94 @@
let mut _2: &[u8]; // in scope 0 at $DIR/deduplicate_blocks.rs:+1:11: +1:23
let mut _3: &str; // in scope 0 at $DIR/deduplicate_blocks.rs:+1:11: +1:23
let mut _4: usize; // in scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
let mut _5: bool; // in scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
let mut _6: usize; // in scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
let mut _7: bool; // in scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
scope 1 (inlined core::str::<impl str>::as_bytes) { // at $DIR/deduplicate_blocks.rs:3:11: 3:23
debug self => _3; // in scope 1 at $SRC_DIR/core/src/str/mod.rs:LL:COL
let mut _8: &str; // in scope 1 at $SRC_DIR/core/src/str/mod.rs:LL:COL
scope 2 {
}
}
let mut _5: usize; // in scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
let mut _6: bool; // in scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
let mut _7: usize; // in scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
let mut _8: usize; // in scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
let mut _9: bool; // in scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
bb0: {
StorageLive(_2); // scope 0 at $DIR/deduplicate_blocks.rs:+1:11: +1:23
StorageLive(_3); // scope 0 at $DIR/deduplicate_blocks.rs:+1:11: +1:23
_3 = _1; // scope 0 at $DIR/deduplicate_blocks.rs:+1:11: +1:23
StorageLive(_8); // scope 2 at $SRC_DIR/core/src/str/mod.rs:LL:COL
_8 = _3; // scope 2 at $SRC_DIR/core/src/str/mod.rs:LL:COL
- _2 = transmute::<&str, &[u8]>(move _8) -> bb14; // scope 2 at $SRC_DIR/core/src/str/mod.rs:LL:COL
+ _2 = transmute::<&str, &[u8]>(move _8) -> bb12; // scope 2 at $SRC_DIR/core/src/str/mod.rs:LL:COL
_3 = &(*_1); // scope 0 at $DIR/deduplicate_blocks.rs:+1:11: +1:23
_2 = core::str::<impl str>::as_bytes(move _3) -> bb1; // scope 0 at $DIR/deduplicate_blocks.rs:+1:11: +1:23
// mir::Constant
// + span: $SRC_DIR/core/src/str/mod.rs:LL:COL
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&str) -> &[u8] {transmute::<&str, &[u8]>}, val: Value(<ZST>) }
// + span: $DIR/deduplicate_blocks.rs:5:13: 5:21
// + literal: Const { ty: for<'r> fn(&'r str) -> &'r [u8] {core::str::<impl str>::as_bytes}, val: Value(<ZST>) }
}
bb1: {
switchInt((*_2)[0 of 4]) -> [47_u8: bb2, otherwise: bb5]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
StorageDead(_3); // scope 0 at $DIR/deduplicate_blocks.rs:+1:22: +1:23
_7 = Len((*_2)); // scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
_8 = const 4_usize; // scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
_9 = Ge(move _7, move _8); // scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
switchInt(move _9) -> [false: bb6, otherwise: bb2]; // scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
}
bb2: {
switchInt((*_2)[1 of 4]) -> [47_u8: bb3, otherwise: bb5]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
switchInt((*_2)[0 of 4]) -> [47_u8: bb3, otherwise: bb6]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
}
bb3: {
switchInt((*_2)[2 of 4]) -> [47_u8: bb4, otherwise: bb5]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
switchInt((*_2)[1 of 4]) -> [47_u8: bb4, otherwise: bb6]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
}
bb4: {
- switchInt((*_2)[3 of 4]) -> [47_u8: bb10, otherwise: bb5]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
+ switchInt((*_2)[3 of 4]) -> [47_u8: bb9, otherwise: bb5]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
switchInt((*_2)[2 of 4]) -> [47_u8: bb5, otherwise: bb6]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
}
bb5: {
_4 = Len((*_2)); // scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
_5 = Ge(move _4, const 3_usize); // scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
switchInt(move _5) -> [false: bb9, otherwise: bb6]; // scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
- switchInt((*_2)[3 of 4]) -> [47_u8: bb11, otherwise: bb6]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
+ switchInt((*_2)[3 of 4]) -> [47_u8: bb10, otherwise: bb6]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
}
bb6: {
switchInt((*_2)[0 of 3]) -> [47_u8: bb7, otherwise: bb9]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
_4 = Len((*_2)); // scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
_5 = const 3_usize; // scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
_6 = Ge(move _4, move _5); // scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
switchInt(move _6) -> [false: bb10, otherwise: bb7]; // scope 0 at $DIR/deduplicate_blocks.rs:+3:9: +3:31
}
bb7: {
switchInt((*_2)[1 of 3]) -> [47_u8: bb8, otherwise: bb9]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
switchInt((*_2)[0 of 3]) -> [47_u8: bb8, otherwise: bb10]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
}
bb8: {
- switchInt((*_2)[2 of 3]) -> [47_u8: bb11, 33_u8: bb12, otherwise: bb9]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
+ switchInt((*_2)[2 of 3]) -> [47_u8: bb10, 33_u8: bb10, otherwise: bb9]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
switchInt((*_2)[1 of 3]) -> [47_u8: bb9, otherwise: bb10]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
}
bb9: {
- switchInt((*_2)[2 of 3]) -> [47_u8: bb12, 33_u8: bb13, otherwise: bb10]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
+ switchInt((*_2)[2 of 3]) -> [47_u8: bb11, 33_u8: bb11, otherwise: bb10]; // scope 0 at $DIR/deduplicate_blocks.rs:+1:5: +1:23
}
bb10: {
- _0 = const false; // scope 0 at $DIR/deduplicate_blocks.rs:+5:14: +5:19
- goto -> bb13; // scope 0 at $DIR/deduplicate_blocks.rs:+5:14: +5:19
- goto -> bb14; // scope 0 at $DIR/deduplicate_blocks.rs:+5:14: +5:19
- }
-
- bb10: {
_0 = const false; // scope 0 at $DIR/deduplicate_blocks.rs:+2:41: +2:46
- goto -> bb13; // scope 0 at $DIR/deduplicate_blocks.rs:+2:41: +2:46
+ goto -> bb11; // scope 0 at $DIR/deduplicate_blocks.rs:+2:41: +2:46
}
- bb11: {
- _0 = const true; // scope 0 at $DIR/deduplicate_blocks.rs:+3:35: +3:39
- goto -> bb13; // scope 0 at $DIR/deduplicate_blocks.rs:+3:35: +3:39
- }
-
- bb12: {
+ bb10: {
_0 = const true; // scope 0 at $DIR/deduplicate_blocks.rs:+4:35: +4:39
- goto -> bb13; // scope 0 at $DIR/deduplicate_blocks.rs:+4:35: +4:39
+ goto -> bb11; // scope 0 at $DIR/deduplicate_blocks.rs:+4:35: +4:39
_0 = const false; // scope 0 at $DIR/deduplicate_blocks.rs:+2:41: +2:46
- goto -> bb14; // scope 0 at $DIR/deduplicate_blocks.rs:+2:41: +2:46
+ goto -> bb12; // scope 0 at $DIR/deduplicate_blocks.rs:+2:41: +2:46
}
- bb12: {
- _0 = const true; // scope 0 at $DIR/deduplicate_blocks.rs:+3:35: +3:39
- goto -> bb14; // scope 0 at $DIR/deduplicate_blocks.rs:+3:35: +3:39
- }
-
- bb13: {
+ bb11: {
StorageDead(_2); // scope 0 at $DIR/deduplicate_blocks.rs:+7:1: +7:2
return; // scope 0 at $DIR/deduplicate_blocks.rs:+7:2: +7:2
_0 = const true; // scope 0 at $DIR/deduplicate_blocks.rs:+4:35: +4:39
- goto -> bb14; // scope 0 at $DIR/deduplicate_blocks.rs:+4:35: +4:39
+ goto -> bb12; // scope 0 at $DIR/deduplicate_blocks.rs:+4:35: +4:39
}
- bb14: {
+ bb12: {
StorageDead(_8); // scope 2 at $SRC_DIR/core/src/str/mod.rs:LL:COL
StorageDead(_3); // scope 0 at $DIR/deduplicate_blocks.rs:+1:22: +1:23
_6 = Len((*_2)); // scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
_7 = Ge(move _6, const 4_usize); // scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
switchInt(move _7) -> [false: bb5, otherwise: bb1]; // scope 0 at $DIR/deduplicate_blocks.rs:+2:9: +2:37
StorageDead(_2); // scope 0 at $DIR/deduplicate_blocks.rs:+7:1: +7:2
return; // scope 0 at $DIR/deduplicate_blocks.rs:+7:2: +7:2
}
}

View File

@ -1,3 +1,5 @@
// unit-test: DeduplicateBlocks
// EMIT_MIR deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff
pub const fn is_line_doc_comment_2(s: &str) -> bool {
match s.as_bytes() {

View File

@ -30,12 +30,12 @@
StorageLive(_2); // scope 0 at $DIR/derefer_complex_case.rs:+1:17: +1:26
_14 = const main::promoted[0]; // scope 0 at $DIR/derefer_complex_case.rs:+1:17: +1:26
// mir::Constant
// + span: $DIR/derefer_complex_case.rs:5:17: 5:26
// + span: $DIR/derefer_complex_case.rs:6:17: 6:26
// + literal: Const { ty: &[i32; 2], val: Unevaluated(main, [], Some(promoted[0])) }
_2 = &(*_14); // scope 0 at $DIR/derefer_complex_case.rs:+1:17: +1:26
_1 = <&[i32; 2] as IntoIterator>::into_iter(move _2) -> bb1; // scope 0 at $DIR/derefer_complex_case.rs:+1:17: +1:26
// mir::Constant
// + span: $DIR/derefer_complex_case.rs:5:17: 5:26
// + span: $DIR/derefer_complex_case.rs:6:17: 6:26
// + literal: Const { ty: fn(&[i32; 2]) -> <&[i32; 2] as IntoIterator>::IntoIter {<&[i32; 2] as IntoIterator>::into_iter}, val: Value(<ZST>) }
}
@ -55,7 +55,7 @@
_8 = &mut (*_9); // scope 1 at $DIR/derefer_complex_case.rs:+1:17: +1:26
_7 = <std::slice::Iter<i32> as Iterator>::next(move _8) -> bb3; // scope 1 at $DIR/derefer_complex_case.rs:+1:17: +1:26
// mir::Constant
// + span: $DIR/derefer_complex_case.rs:5:17: 5:26
// + span: $DIR/derefer_complex_case.rs:6:17: 6:26
// + literal: Const { ty: for<'r> fn(&'r mut std::slice::Iter<i32>) -> Option<<std::slice::Iter<i32> as Iterator>::Item> {<std::slice::Iter<i32> as Iterator>::next}, val: Value(<ZST>) }
}
@ -76,7 +76,7 @@
_13 = _12; // scope 2 at $DIR/derefer_complex_case.rs:+1:34: +1:37
_6 = std::mem::drop::<i32>(move _13) -> bb7; // scope 2 at $DIR/derefer_complex_case.rs:+1:29: +1:38
// mir::Constant
// + span: $DIR/derefer_complex_case.rs:5:29: 5:33
// + span: $DIR/derefer_complex_case.rs:6:29: 6:33
// + literal: Const { ty: fn(i32) {std::mem::drop::<i32>}, val: Value(<ZST>) }
}

View File

@ -1,3 +1,4 @@
// unit-test: Derefer
// EMIT_MIR derefer_complex_case.main.Derefer.diff
// ignore-wasm32

View File

@ -17,7 +17,7 @@
_3 = AlignOf(std::boxed::Box<u32>); // scope 1 at $DIR/derefer_inline_test.rs:+1:5: +1:12
_4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 1 at $DIR/derefer_inline_test.rs:+1:5: +1:12
// mir::Constant
// + span: $DIR/derefer_inline_test.rs:10:5: 10:12
// + span: $DIR/derefer_inline_test.rs:11:5: 11:12
// + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
}
@ -26,7 +26,7 @@
_5 = ShallowInitBox(move _4, std::boxed::Box<u32>); // scope 0 at $DIR/derefer_inline_test.rs:+1:5: +1:12
(*_5) = f() -> [return: bb2, unwind: bb6]; // scope 0 at $DIR/derefer_inline_test.rs:+1:9: +1:12
// mir::Constant
// + span: $DIR/derefer_inline_test.rs:10:9: 10:10
// + span: $DIR/derefer_inline_test.rs:11:9: 11:10
// + literal: Const { ty: fn() -> Box<u32> {f}, val: Value(<ZST>) }
}

View File

@ -1,3 +1,4 @@
// unit-test: Derefer
// EMIT_MIR derefer_inline_test.main.Derefer.diff
// ignore-wasm32 compiled with panic=abort by default

View File

@ -32,7 +32,7 @@
StorageLive(_1); // scope 0 at $DIR/derefer_terminator_test.rs:+1:9: +1:10
_1 = foo() -> bb1; // scope 0 at $DIR/derefer_terminator_test.rs:+1:13: +1:18
// mir::Constant
// + span: $DIR/derefer_terminator_test.rs:5:13: 5:16
// + span: $DIR/derefer_terminator_test.rs:6:13: 6:16
// + literal: Const { ty: fn() -> bool {foo}, val: Value(<ZST>) }
}
@ -40,7 +40,7 @@
StorageLive(_2); // scope 1 at $DIR/derefer_terminator_test.rs:+2:9: +2:10
_2 = foo() -> bb2; // scope 1 at $DIR/derefer_terminator_test.rs:+2:13: +2:18
// mir::Constant
// + span: $DIR/derefer_terminator_test.rs:6:13: 6:16
// + span: $DIR/derefer_terminator_test.rs:7:13: 7:16
// + literal: Const { ty: fn() -> bool {foo}, val: Value(<ZST>) }
}

View File

@ -1,3 +1,4 @@
// unit-test: Derefer
// EMIT_MIR derefer_terminator_test.main.Derefer.diff
// ignore-wasm32

View File

@ -1,3 +1,4 @@
// unit-test: Derefer
// EMIT_MIR derefer_test.main.Derefer.diff
fn main() {
let mut a = (42,43);

View File

@ -1,3 +1,4 @@
// unit-test: Derefer
// EMIT_MIR derefer_test_multiple.main.Derefer.diff
fn main () {
let mut a = (42, 43);

View File

@ -1,3 +1,5 @@
// unit-test InstCombine
// EMIT_MIR equal_true.opt.InstCombine.diff
fn opt(x: bool) -> i32 {

View File

@ -5,7 +5,7 @@
let mut _0: bool; // return place in scope 0 at /the/src/instrument_coverage.rs:+0:13: +0:17
bb0: {
+ Coverage::Counter(1) for /the/src/instrument_coverage.rs:19:1 - 21:2; // scope 0 at /the/src/instrument_coverage.rs:+2:2: +2:2
+ Coverage::Counter(1) for /the/src/instrument_coverage.rs:20:1 - 22:2; // scope 0 at /the/src/instrument_coverage.rs:+2:2: +2:2
_0 = const true; // scope 0 at /the/src/instrument_coverage.rs:+1:5: +1:9
return; // scope 0 at /the/src/instrument_coverage.rs:+2:2: +2:2
}

View File

@ -8,12 +8,12 @@
let mut _3: !; // in scope 0 at /the/src/instrument_coverage.rs:+2:18: +4:10
bb0: {
+ Coverage::Counter(1) for /the/src/instrument_coverage.rs:10:1 - 10:11; // scope 0 at /the/src/instrument_coverage.rs:+1:5: +5:6
+ Coverage::Counter(1) for /the/src/instrument_coverage.rs:11:1 - 11:11; // scope 0 at /the/src/instrument_coverage.rs:+1:5: +5:6
goto -> bb1; // scope 0 at /the/src/instrument_coverage.rs:+1:5: +5:6
}
bb1: {
+ Coverage::Expression(4294967295) = 1 + 2 for /the/src/instrument_coverage.rs:11:5 - 12:17; // scope 0 at /the/src/instrument_coverage.rs:+1:5: +5:6
+ Coverage::Expression(4294967295) = 1 + 2 for /the/src/instrument_coverage.rs:12:5 - 13:17; // scope 0 at /the/src/instrument_coverage.rs:+1:5: +5:6
falseUnwind -> [real: bb2, cleanup: bb6]; // scope 0 at /the/src/instrument_coverage.rs:+1:5: +5:6
}
@ -21,7 +21,7 @@
StorageLive(_2); // scope 0 at /the/src/instrument_coverage.rs:+2:12: +2:17
_2 = bar() -> [return: bb3, unwind: bb6]; // scope 0 at /the/src/instrument_coverage.rs:+2:12: +2:17
// mir::Constant
// + span: /the/src/instrument_coverage.rs:12:12: 12:15
// + span: /the/src/instrument_coverage.rs:13:12: 13:15
// + literal: Const { ty: fn() -> bool {bar}, val: Value(<ZST>) }
}
@ -30,15 +30,15 @@
}
bb4: {
+ Coverage::Expression(4294967293) = 4294967294 + 0 for /the/src/instrument_coverage.rs:16:1 - 16:2; // scope 0 at /the/src/instrument_coverage.rs:+6:2: +6:2
+ Coverage::Expression(4294967294) = 4294967295 - 2 for /the/src/instrument_coverage.rs:13:13 - 13:18; // scope 0 at /the/src/instrument_coverage.rs:+6:2: +6:2
+ Coverage::Expression(4294967293) = 4294967294 + 0 for /the/src/instrument_coverage.rs:17:1 - 17:2; // scope 0 at /the/src/instrument_coverage.rs:+6:2: +6:2
+ Coverage::Expression(4294967294) = 4294967295 - 2 for /the/src/instrument_coverage.rs:14:13 - 14:18; // scope 0 at /the/src/instrument_coverage.rs:+6:2: +6:2
_0 = const (); // scope 0 at /the/src/instrument_coverage.rs:+3:13: +3:18
StorageDead(_2); // scope 0 at /the/src/instrument_coverage.rs:+4:9: +4:10
return; // scope 0 at /the/src/instrument_coverage.rs:+6:2: +6:2
}
bb5: {
+ Coverage::Counter(2) for /the/src/instrument_coverage.rs:14:10 - 14:11; // scope 0 at /the/src/instrument_coverage.rs:+1:5: +5:6
+ Coverage::Counter(2) for /the/src/instrument_coverage.rs:15:10 - 15:11; // scope 0 at /the/src/instrument_coverage.rs:+1:5: +5:6
_1 = const (); // scope 0 at /the/src/instrument_coverage.rs:+4:10: +4:10
StorageDead(_2); // scope 0 at /the/src/instrument_coverage.rs:+4:9: +4:10
goto -> bb1; // scope 0 at /the/src/instrument_coverage.rs:+1:5: +5:6

View File

@ -1,6 +1,7 @@
// Test that `-C instrument-coverage` injects Coverage statements. The Coverage Counter statements
// are later converted into LLVM instrprof.increment intrinsics, during codegen.
// unit-test: InstrumentCoverage
// needs-profiler-support
// ignore-windows
// compile-flags: -C instrument-coverage --remap-path-prefix={{src-base}}=/the/src

View File

@ -1,3 +1,4 @@
// unit-test: InstCombine
// EMIT_MIR not_equal_false.opt.InstCombine.diff
fn opt(x: bool) -> u32 {

View File

@ -23,13 +23,6 @@
scope 3 {
debug i => _12; // in scope 3 at $DIR/remove_storage_markers.rs:+2:9: +2:10
}
scope 5 (inlined iter::range::<impl Iterator for std::ops::Range<i32>>::next) { // at $DIR/remove_storage_markers.rs:8:14: 8:19
debug self => _8; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
let mut _14: &mut std::ops::Range<i32>; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
}
}
scope 4 (inlined <std::ops::Range<i32> as IntoIterator>::into_iter) { // at $DIR/remove_storage_markers.rs:8:14: 8:19
debug self => _3; // in scope 4 at $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
}
}
@ -41,29 +34,39 @@
Deinit(_3); // scope 1 at $DIR/remove_storage_markers.rs:+2:14: +2:19
(_3.0: i32) = const 0_i32; // scope 1 at $DIR/remove_storage_markers.rs:+2:14: +2:19
(_3.1: i32) = const 10_i32; // scope 1 at $DIR/remove_storage_markers.rs:+2:14: +2:19
_2 = move _3; // scope 4 at $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
- StorageDead(_3); // scope 1 at $DIR/remove_storage_markers.rs:+2:18: +2:19
- StorageLive(_4); // scope 1 at $DIR/remove_storage_markers.rs:+2:14: +2:19
_4 = move _2; // scope 1 at $DIR/remove_storage_markers.rs:+2:14: +2:19
goto -> bb1; // scope 2 at $DIR/remove_storage_markers.rs:+2:5: +4:6
_2 = <std::ops::Range<i32> as IntoIterator>::into_iter(move _3) -> bb1; // scope 1 at $DIR/remove_storage_markers.rs:+2:14: +2:19
// mir::Constant
// + span: $DIR/remove_storage_markers.rs:10:14: 10:19
// + literal: Const { ty: fn(std::ops::Range<i32>) -> <std::ops::Range<i32> as IntoIterator>::IntoIter {<std::ops::Range<i32> as IntoIterator>::into_iter}, val: Value(<ZST>) }
}
bb1: {
- StorageDead(_3); // scope 1 at $DIR/remove_storage_markers.rs:+2:18: +2:19
- StorageLive(_4); // scope 1 at $DIR/remove_storage_markers.rs:+2:14: +2:19
_4 = move _2; // scope 1 at $DIR/remove_storage_markers.rs:+2:14: +2:19
goto -> bb2; // scope 2 at $DIR/remove_storage_markers.rs:+2:5: +4:6
}
bb2: {
- StorageLive(_6); // scope 2 at $DIR/remove_storage_markers.rs:+2:14: +2:19
- StorageLive(_7); // scope 2 at $DIR/remove_storage_markers.rs:+2:14: +2:19
- StorageLive(_8); // scope 2 at $DIR/remove_storage_markers.rs:+2:14: +2:19
- StorageLive(_9); // scope 2 at $DIR/remove_storage_markers.rs:+2:14: +2:19
_9 = &mut _4; // scope 2 at $DIR/remove_storage_markers.rs:+2:14: +2:19
_8 = &mut (*_9); // scope 2 at $DIR/remove_storage_markers.rs:+2:14: +2:19
- StorageLive(_14); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
_14 = &mut (*_8); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
_7 = <std::ops::Range<i32> as iter::range::RangeIteratorImpl>::spec_next(move _14) -> bb4; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
_7 = <std::ops::Range<i32> as Iterator>::next(move _8) -> bb3; // scope 2 at $DIR/remove_storage_markers.rs:+2:14: +2:19
// mir::Constant
// + span: $SRC_DIR/core/src/iter/range.rs:LL:COL
// + literal: Const { ty: for<'r> fn(&'r mut std::ops::Range<i32>) -> Option<<std::ops::Range<i32> as iter::range::RangeIteratorImpl>::Item> {<std::ops::Range<i32> as iter::range::RangeIteratorImpl>::spec_next}, val: Value(<ZST>) }
// + span: $DIR/remove_storage_markers.rs:10:14: 10:19
// + literal: Const { ty: for<'r> fn(&'r mut std::ops::Range<i32>) -> Option<<std::ops::Range<i32> as Iterator>::Item> {<std::ops::Range<i32> as Iterator>::next}, val: Value(<ZST>) }
}
bb2: {
bb3: {
- StorageDead(_8); // scope 2 at $DIR/remove_storage_markers.rs:+2:18: +2:19
_10 = discriminant(_7); // scope 2 at $DIR/remove_storage_markers.rs:+2:14: +2:19
switchInt(move _10) -> [0_isize: bb6, 1_isize: bb4, otherwise: bb5]; // scope 2 at $DIR/remove_storage_markers.rs:+2:14: +2:19
}
bb4: {
- StorageLive(_12); // scope 2 at $DIR/remove_storage_markers.rs:+2:9: +2:10
_12 = ((_7 as Some).0: i32); // scope 2 at $DIR/remove_storage_markers.rs:+2:9: +2:10
- StorageLive(_13); // scope 3 at $DIR/remove_storage_markers.rs:+3:16: +3:17
@ -76,10 +79,14 @@
- StorageDead(_7); // scope 2 at $DIR/remove_storage_markers.rs:+4:5: +4:6
- StorageDead(_6); // scope 2 at $DIR/remove_storage_markers.rs:+4:5: +4:6
_5 = const (); // scope 2 at $DIR/remove_storage_markers.rs:+2:5: +4:6
goto -> bb1; // scope 2 at $DIR/remove_storage_markers.rs:+2:5: +4:6
goto -> bb2; // scope 2 at $DIR/remove_storage_markers.rs:+2:5: +4:6
}
bb3: {
bb5: {
unreachable; // scope 2 at $DIR/remove_storage_markers.rs:+2:14: +2:19
}
bb6: {
_0 = const (); // scope 2 at $DIR/remove_storage_markers.rs:+2:5: +4:6
- StorageDead(_9); // scope 2 at $DIR/remove_storage_markers.rs:+4:5: +4:6
- StorageDead(_7); // scope 2 at $DIR/remove_storage_markers.rs:+4:5: +4:6
@ -89,12 +96,5 @@
- StorageDead(_1); // scope 0 at $DIR/remove_storage_markers.rs:+5:1: +5:2
return; // scope 0 at $DIR/remove_storage_markers.rs:+5:2: +5:2
}
bb4: {
- StorageDead(_14); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL
- StorageDead(_8); // scope 2 at $DIR/remove_storage_markers.rs:+2:18: +2:19
_10 = discriminant(_7); // scope 2 at $DIR/remove_storage_markers.rs:+2:14: +2:19
switchInt(move _10) -> [0_isize: bb3, otherwise: bb2]; // scope 2 at $DIR/remove_storage_markers.rs:+2:14: +2:19
}
}

View File

@ -1,3 +1,5 @@
// unit-test: RemoveStorageMarkers
// Checks that storage markers are removed at opt-level=0.
//
// compile-flags: -C opt-level=0 -Coverflow-checks=off

View File

@ -1,4 +1,4 @@
// compile-flags: -Zmir-opt-level=3
// unit-test: RemoveZsts
// Ensure RemoveZsts doesn't remove ZST assignments to union fields,
// which causes problems in Miri.

View File

@ -80,7 +80,7 @@ fn array_casts() -> () {
_7 = _2; // scope 3 at $DIR/retag.rs:+3:15: +3:16
_6 = ptr::mut_ptr::<impl *mut usize>::add(move _7, const 1_usize) -> bb1; // scope 3 at $DIR/retag.rs:+3:15: +3:23
// mir::Constant
// + span: $DIR/retag.rs:60:17: 60:20
// + span: $DIR/retag.rs:61:17: 61:20
// + literal: Const { ty: unsafe fn(*mut usize, usize) -> *mut usize {ptr::mut_ptr::<impl *mut usize>::add}, val: Value(<ZST>) }
}
@ -111,7 +111,7 @@ fn array_casts() -> () {
_17 = _9; // scope 6 at $DIR/retag.rs:+7:26: +7:27
_16 = ptr::const_ptr::<impl *const usize>::add(move _17, const 1_usize) -> bb2; // scope 6 at $DIR/retag.rs:+7:26: +7:34
// mir::Constant
// + span: $DIR/retag.rs:64:28: 64:31
// + span: $DIR/retag.rs:65:28: 65:31
// + literal: Const { ty: unsafe fn(*const usize, usize) -> *const usize {ptr::const_ptr::<impl *const usize>::add}, val: Value(<ZST>) }
}

View File

@ -73,7 +73,7 @@ fn main() -> () {
Retag([2phase] _6); // scope 1 at $DIR/retag.rs:+3:29: +3:35
_3 = Test::foo(move _4, move _6) -> [return: bb1, unwind: bb8]; // scope 1 at $DIR/retag.rs:+3:17: +3:36
// mir::Constant
// + span: $DIR/retag.rs:32:25: 32:28
// + span: $DIR/retag.rs:33:25: 33:28
// + literal: Const { ty: for<'r, 'x> fn(&'r Test, &'x mut i32) -> &'x mut i32 {Test::foo}, val: Value(<ZST>) }
}
@ -149,7 +149,7 @@ fn main() -> () {
StorageLive(_23); // scope 7 at $DIR/retag.rs:+18:21: +18:23
_28 = const main::promoted[0]; // scope 7 at $DIR/retag.rs:+18:21: +18:23
// mir::Constant
// + span: $DIR/retag.rs:47:21: 47:23
// + span: $DIR/retag.rs:48:21: 48:23
// + literal: Const { ty: &i32, val: Unevaluated(main, [], Some(promoted[0])) }
Retag(_28); // scope 7 at $DIR/retag.rs:+18:21: +18:23
_23 = &(*_28); // scope 7 at $DIR/retag.rs:+18:21: +18:23
@ -158,7 +158,7 @@ fn main() -> () {
Retag(_22); // scope 7 at $DIR/retag.rs:+18:21: +18:23
_19 = Test::foo_shr(move _20, move _22) -> [return: bb4, unwind: bb7]; // scope 7 at $DIR/retag.rs:+18:5: +18:24
// mir::Constant
// + span: $DIR/retag.rs:47:13: 47:20
// + span: $DIR/retag.rs:48:13: 48:20
// + literal: Const { ty: for<'r, 'x> fn(&'r Test, &'x i32) -> &'x i32 {Test::foo_shr}, val: Value(<ZST>) }
}
@ -182,7 +182,7 @@ fn main() -> () {
StorageLive(_27); // scope 8 at $DIR/retag.rs:+23:5: +23:18
_27 = array_casts() -> bb6; // scope 8 at $DIR/retag.rs:+23:5: +23:18
// mir::Constant
// + span: $DIR/retag.rs:52:5: 52:16
// + span: $DIR/retag.rs:53:5: 53:16
// + literal: Const { ty: fn() {array_casts}, val: Value(<ZST>) }
}

View File

@ -1,3 +1,4 @@
// unit-test: AddRetag
// ignore-wasm32-bare compiled with panic=abort by default
// ignore-tidy-linelength
// compile-flags: -Z mir-emit-retag -Z mir-opt-level=0 -Z span_free_formats

View File

@ -1,6 +1,6 @@
// MIR for `<impl at $DIR/retag.rs:11:1: 11:10>::foo` after SimplifyCfg-elaborate-drops
// MIR for `<impl at $DIR/retag.rs:12:1: 12:10>::foo` after SimplifyCfg-elaborate-drops
fn <impl at $DIR/retag.rs:11:1: 11:10>::foo(_1: &Test, _2: &mut i32) -> &mut i32 {
fn <impl at $DIR/retag.rs:12:1: 12:10>::foo(_1: &Test, _2: &mut i32) -> &mut i32 {
debug self => _1; // in scope 0 at $DIR/retag.rs:+0:16: +0:21
debug x => _2; // in scope 0 at $DIR/retag.rs:+0:23: +0:24
let mut _0: &mut i32; // return place in scope 0 at $DIR/retag.rs:+0:42: +0:53

View File

@ -1,6 +1,6 @@
// MIR for `<impl at $DIR/retag.rs:11:1: 11:10>::foo_shr` after SimplifyCfg-elaborate-drops
// MIR for `<impl at $DIR/retag.rs:12:1: 12:10>::foo_shr` after SimplifyCfg-elaborate-drops
fn <impl at $DIR/retag.rs:11:1: 11:10>::foo_shr(_1: &Test, _2: &i32) -> &i32 {
fn <impl at $DIR/retag.rs:12:1: 12:10>::foo_shr(_1: &Test, _2: &i32) -> &i32 {
debug self => _1; // in scope 0 at $DIR/retag.rs:+0:20: +0:25
debug x => _2; // in scope 0 at $DIR/retag.rs:+0:27: +0:28
let mut _0: &i32; // return place in scope 0 at $DIR/retag.rs:+0:42: +0:49

View File

@ -1,3 +1,4 @@
// unit-test: SimplifyLocals
// compile-flags: -C overflow-checks=no
fn use_zst(_: ((), ())) {}

View File

@ -16,29 +16,53 @@
- let mut _11: Temp; // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:28
+ let _1: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:5: +2:22
+ let mut _2: ((), ()); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21
+ let _3: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35
+ let mut _3: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:14: +2:16
+ let mut _4: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:18: +2:20
+ let _5: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35
+ let mut _6: u8; // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:34
+ let mut _7: u8; // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:30
+ let mut _8: Temp; // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:28
scope 1 {
}
bb0: {
- StorageLive(_1); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:20: +1:28
- StorageLive(_2); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:21: +1:23
- Deinit(_2); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:21: +1:23
- StorageLive(_3); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:25: +1:27
- Deinit(_3); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:25: +1:27
- Deinit(_1); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:20: +1:28
- (_1.0: ()) = move _2; // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:20: +1:28
- (_1.1: ()) = move _3; // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:20: +1:28
- StorageDead(_3); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:27: +1:28
- StorageDead(_2); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:27: +1:28
- StorageDead(_1); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:28: +1:29
- StorageLive(_4); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:5: +2:22
- StorageLive(_5); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21
- StorageLive(_6); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:14: +2:16
- Deinit(_6); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:14: +2:16
- StorageLive(_7); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:18: +2:20
- Deinit(_7); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:18: +2:20
- Deinit(_5); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21
- (_5.0: ()) = move _6; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21
- (_5.1: ()) = move _7; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21
- StorageDead(_7); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:20: +2:21
- StorageDead(_6); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:20: +2:21
- _4 = use_zst(move _5) -> bb1; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:5: +2:22
+ StorageLive(_1); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:5: +2:22
+ StorageLive(_2); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21
+ StorageLive(_3); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:14: +2:16
+ Deinit(_3); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:14: +2:16
+ StorageLive(_4); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:18: +2:20
+ Deinit(_4); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:18: +2:20
+ Deinit(_2); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21
+ (_2.0: ()) = move _3; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21
+ (_2.1: ()) = move _4; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21
+ StorageDead(_4); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:20: +2:21
+ StorageDead(_3); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:20: +2:21
+ _1 = use_zst(move _2) -> bb1; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:5: +2:22
// mir::Constant
// + span: $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:12
// + span: $DIR/simplify-locals-removes-unused-consts.rs:15:5: 15:12
// + literal: Const { ty: fn(((), ())) {use_zst}, val: Value(<ZST>) }
}
@ -49,22 +73,36 @@
- StorageLive(_9); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:34
- StorageLive(_10); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:30
- StorageLive(_11); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:28
- Deinit(_11); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:28
- (_11.0: u8) = const 40_u8; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:28
- _10 = (_11.0: u8); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:30
- _9 = Add(move _10, const 2_u8); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:34
- StorageDead(_10); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:33: +4:34
- _8 = use_u8(const 42_u8) -> bb2; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35
- _8 = use_u8(move _9) -> bb2; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35
+ StorageDead(_2); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:21: +2:22
+ StorageDead(_1); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:22: +2:23
+ StorageLive(_3); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35
+ _3 = use_u8(const 42_u8) -> bb2; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35
+ StorageLive(_5); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35
+ StorageLive(_6); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:34
+ StorageLive(_7); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:30
+ StorageLive(_8); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:28
+ Deinit(_8); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:28
+ (_8.0: u8) = const 40_u8; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:28
+ _7 = (_8.0: u8); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:30
+ _6 = Add(move _7, const 2_u8); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:34
+ StorageDead(_7); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:33: +4:34
+ _5 = use_u8(move _6) -> bb2; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35
// mir::Constant
// + span: $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:11
// + span: $DIR/simplify-locals-removes-unused-consts.rs:17:5: 17:11
// + literal: Const { ty: fn(u8) {use_u8}, val: Value(<ZST>) }
}
bb2: {
- StorageDead(_9); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:34: +4:35
- StorageDead(_11); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:35: +4:36
- StorageDead(_8); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:35: +4:36
+ StorageDead(_3); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:35: +4:36
+ StorageDead(_6); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:34: +4:35
StorageDead(_8); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:35: +4:36
+ StorageDead(_5); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:35: +4:36
_0 = const (); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+0:11: +5:2
return; // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+5:2: +5:2
}
}

View File

@ -1,6 +1,5 @@
// run-pass
#![feature(backtrace)]
#[derive(Clone, Copy)]
struct Foo {
array: [u64; 10240],

View File

@ -7,8 +7,8 @@ mod usize {}
// @set local_crate_id = primitive.json "$.index[*][?(@.name=='primitive')].crate_id"
// @has - "$.index[*][?(@.name=='log10')]"
// @!is - "$.index[*][?(@.name=='log10')].crate_id" $local_crate_id
// @has - "$.index[*][?(@.name=='ilog10')]"
// @!is - "$.index[*][?(@.name=='ilog10')].crate_id" $local_crate_id
// @has - "$.index[*][?(@.name=='checked_add')]"
// @!is - "$.index[*][?(@.name=='checked_add')]" $local_crate_id
// @!has - "$.index[*][?(@.name=='is_ascii_uppercase')]"

View File

@ -4,8 +4,6 @@
// compile-flags:-g -Csplit-debuginfo=unpacked
// only-macos
#![feature(backtrace)]
use std::process::Command;
use std::str;

View File

@ -0,0 +1,12 @@
// check-pass
trait Trait<T> {
type Ty;
}
impl Trait<&u8> for () {
type Ty = ();
}
fn test<'a, 'b>() -> impl Trait<&'a u8, Ty = impl Sized + 'b> {}
fn main() {}

View File

@ -0,0 +1,8 @@
fn foo() {}
fn bar() -> [u8; 2] {
foo()
[1, 3) //~ ERROR expected one of `.`, `?`, `]`, or an operator, found `,`
}
fn main() {}

View File

@ -0,0 +1,10 @@
error: expected one of `.`, `?`, `]`, or an operator, found `,`
--> $DIR/do-not-suggest-suggest-semicolon-before-array.rs:5:5
|
LL | [1, 3)
| ^ ^ help: `]` may belong here
| |
| unclosed delimiter
error: aborting due to previous error

View File

@ -0,0 +1,11 @@
// run-rustfix
#![allow(dead_code)]
fn foo() {}
fn bar() -> [u8; 2] {
foo();
[1, 3] //~ ERROR expected `;`, found `[`
}
fn main() {}

View File

@ -0,0 +1,11 @@
// run-rustfix
#![allow(dead_code)]
fn foo() {}
fn bar() -> [u8; 2] {
foo()
[1, 3] //~ ERROR expected `;`, found `[`
}
fn main() {}

View File

@ -0,0 +1,13 @@
error: expected `;`, found `[`
--> $DIR/suggest-suggest-semicolon-before-array.rs:8:5
|
LL | [1, 3]
| ^
|
help: consider adding `;` here
|
LL | foo();
| +
error: aborting due to previous error

View File

@ -0,0 +1,18 @@
#![feature(raw_dylib)]
//~^ WARN the feature `raw_dylib` is incomplete
#[link(name = "foo")]
extern "C" {
#[link_ordinal(3)]
//~^ ERROR `#[link_ordinal]` is only supported if link kind is `raw-dylib`
fn foo();
}
#[link(name = "bar", kind = "static")]
extern "C" {
#[link_ordinal(3)]
//~^ ERROR `#[link_ordinal]` is only supported if link kind is `raw-dylib`
fn bar();
}
fn main() {}

View File

@ -0,0 +1,23 @@
warning: the feature `raw_dylib` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/link-ordinal-unsupported-link-kind.rs:1:12
|
LL | #![feature(raw_dylib)]
| ^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
error: `#[link_ordinal]` is only supported if link kind is `raw-dylib`
--> $DIR/link-ordinal-unsupported-link-kind.rs:6:5
|
LL | #[link_ordinal(3)]
| ^^^^^^^^^^^^^^^^^^
error: `#[link_ordinal]` is only supported if link kind is `raw-dylib`
--> $DIR/link-ordinal-unsupported-link-kind.rs:13:5
|
LL | #[link_ordinal(3)]
| ^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors; 1 warning emitted

View File

@ -7,8 +7,6 @@
// compile-flags:-g
// compile-flags:-Cstrip=none
#![feature(backtrace)]
use std::env;
use std::process::Command;
use std::str;

@ -1 +1 @@
Subproject commit 4fd148c47e733770c537efac5220744945d572ef
Subproject commit ce40690a5e4e315d3dab0aae1eae69d0252c52ac