1
Fork 0

Auto merge of #121549 - matthiaskrgr:rollup-1hvu3lb, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #121435 (Account for RPITIT in E0310 explicit lifetime constraint suggestion)
 - #121490 (Rustdoc: include crate name in links for local primitives)
 - #121520 (delay cloning of iterator items)
 - #121522 (check that simd_insert/extract indices are in-bounds)
 - #121531 (Ignore less tests in debug builds)
 - #121539 (compiler/rustc_target/src/spec/base/apple/tests.rs: Avoid unnecessary large move)
 - #121542 (update stdarch)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors 2024-02-24 21:08:39 +00:00
commit 381d69953b
76 changed files with 189 additions and 152 deletions

View file

@ -1079,7 +1079,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
.map(|(arg_idx, val)| { .map(|(arg_idx, val)| {
let idx = val.unwrap_leaf().try_to_i32().unwrap(); let idx = val.unwrap_leaf().try_to_i32().unwrap();
if idx >= i32::try_from(total_len).unwrap() { if idx >= i32::try_from(total_len).unwrap() {
bx.sess().dcx().emit_err(InvalidMonomorphization::ShuffleIndexOutOfBounds { bx.sess().dcx().emit_err(InvalidMonomorphization::SimdIndexOutOfBounds {
span, span,
name, name,
arg_idx: arg_idx as u64, arg_idx: arg_idx as u64,
@ -1138,24 +1138,15 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
let val = bx.const_get_elt(vector, i as u64); let val = bx.const_get_elt(vector, i as u64);
match bx.const_to_opt_u128(val, true) { match bx.const_to_opt_u128(val, true) {
None => { None => {
bx.sess().dcx().emit_err( bug!("typeck should have already ensured that these are const")
InvalidMonomorphization::ShuffleIndexNotConstant {
span,
name,
arg_idx,
},
);
None
} }
Some(idx) if idx >= total_len => { Some(idx) if idx >= total_len => {
bx.sess().dcx().emit_err( bx.sess().dcx().emit_err(InvalidMonomorphization::SimdIndexOutOfBounds {
InvalidMonomorphization::ShuffleIndexOutOfBounds {
span, span,
name, name,
arg_idx, arg_idx,
total_len, total_len,
}, });
);
None None
} }
Some(idx) => Some(bx.const_i32(idx as i32)), Some(idx) => Some(bx.const_i32(idx as i32)),
@ -1184,10 +1175,22 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
out_ty: arg_tys[2] out_ty: arg_tys[2]
} }
); );
let idx = bx
.const_to_opt_u128(args[1].immediate(), false)
.expect("typeck should have ensure that this is a const");
if idx >= in_len.into() {
bx.sess().dcx().emit_err(InvalidMonomorphization::SimdIndexOutOfBounds {
span,
name,
arg_idx: 1,
total_len: in_len.into(),
});
return Ok(bx.const_null(llret_ty));
}
return Ok(bx.insert_element( return Ok(bx.insert_element(
args[0].immediate(), args[0].immediate(),
args[2].immediate(), args[2].immediate(),
args[1].immediate(), bx.const_i32(idx as i32),
)); ));
} }
if name == sym::simd_extract { if name == sym::simd_extract {
@ -1195,7 +1198,19 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
ret_ty == in_elem, ret_ty == in_elem,
InvalidMonomorphization::ReturnType { span, name, in_elem, in_ty, ret_ty } InvalidMonomorphization::ReturnType { span, name, in_elem, in_ty, ret_ty }
); );
return Ok(bx.extract_element(args[0].immediate(), args[1].immediate())); let idx = bx
.const_to_opt_u128(args[1].immediate(), false)
.expect("typeck should have ensure that this is a const");
if idx >= in_len.into() {
bx.sess().dcx().emit_err(InvalidMonomorphization::SimdIndexOutOfBounds {
span,
name,
arg_idx: 1,
total_len: in_len.into(),
});
return Ok(bx.const_null(llret_ty));
}
return Ok(bx.extract_element(args[0].immediate(), bx.const_i32(idx as i32)));
} }
if name == sym::simd_select { if name == sym::simd_select {

View file

@ -106,14 +106,12 @@ codegen_ssa_invalid_monomorphization_return_type = invalid monomorphization of `
codegen_ssa_invalid_monomorphization_second_argument_length = invalid monomorphization of `{$name}` intrinsic: expected second argument with length {$in_len} (same as input type `{$in_ty}`), found `{$arg_ty}` with length {$out_len} codegen_ssa_invalid_monomorphization_second_argument_length = invalid monomorphization of `{$name}` intrinsic: expected second argument with length {$in_len} (same as input type `{$in_ty}`), found `{$arg_ty}` with length {$out_len}
codegen_ssa_invalid_monomorphization_shuffle_index_not_constant = invalid monomorphization of `{$name}` intrinsic: shuffle index #{$arg_idx} is not a constant
codegen_ssa_invalid_monomorphization_shuffle_index_out_of_bounds = invalid monomorphization of `{$name}` intrinsic: shuffle index #{$arg_idx} is out of bounds (limit {$total_len})
codegen_ssa_invalid_monomorphization_simd_argument = invalid monomorphization of `{$name}` intrinsic: expected SIMD argument type, found non-SIMD `{$ty}` codegen_ssa_invalid_monomorphization_simd_argument = invalid monomorphization of `{$name}` intrinsic: expected SIMD argument type, found non-SIMD `{$ty}`
codegen_ssa_invalid_monomorphization_simd_first = invalid monomorphization of `{$name}` intrinsic: expected SIMD first type, found non-SIMD `{$ty}` codegen_ssa_invalid_monomorphization_simd_first = invalid monomorphization of `{$name}` intrinsic: expected SIMD first type, found non-SIMD `{$ty}`
codegen_ssa_invalid_monomorphization_simd_index_out_of_bounds = invalid monomorphization of `{$name}` intrinsic: SIMD index #{$arg_idx} is out of bounds (limit {$total_len})
codegen_ssa_invalid_monomorphization_simd_input = invalid monomorphization of `{$name}` intrinsic: expected SIMD input type, found non-SIMD `{$ty}` codegen_ssa_invalid_monomorphization_simd_input = invalid monomorphization of `{$name}` intrinsic: expected SIMD input type, found non-SIMD `{$ty}`
codegen_ssa_invalid_monomorphization_simd_return = invalid monomorphization of `{$name}` intrinsic: expected SIMD return type, found non-SIMD `{$ty}` codegen_ssa_invalid_monomorphization_simd_return = invalid monomorphization of `{$name}` intrinsic: expected SIMD return type, found non-SIMD `{$ty}`

View file

@ -797,16 +797,8 @@ pub enum InvalidMonomorphization<'tcx> {
out_ty: Ty<'tcx>, out_ty: Ty<'tcx>,
}, },
#[diag(codegen_ssa_invalid_monomorphization_shuffle_index_not_constant, code = E0511)] #[diag(codegen_ssa_invalid_monomorphization_simd_index_out_of_bounds, code = E0511)]
ShuffleIndexNotConstant { SimdIndexOutOfBounds {
#[primary_span]
span: Span,
name: Symbol,
arg_idx: u64,
},
#[diag(codegen_ssa_invalid_monomorphization_shuffle_index_out_of_bounds, code = E0511)]
ShuffleIndexOutOfBounds {
#[primary_span] #[primary_span]
span: Span, span: Span,
name: Symbol, name: Symbol,

View file

@ -379,10 +379,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
let (input, input_len) = self.operand_to_simd(&args[0])?; let (input, input_len) = self.operand_to_simd(&args[0])?;
let (dest, dest_len) = self.place_to_simd(dest)?; let (dest, dest_len) = self.place_to_simd(dest)?;
assert_eq!(input_len, dest_len, "Return vector length must match input length"); assert_eq!(input_len, dest_len, "Return vector length must match input length");
assert!( // Bounds are not checked by typeck so we have to do it ourselves.
index < dest_len, if index >= input_len {
"Index `{index}` must be in bounds of vector with length {dest_len}" throw_ub_format!(
"`simd_insert` index {index} is out-of-bounds of vector with length {input_len}"
); );
}
for i in 0..dest_len { for i in 0..dest_len {
let place = self.project_index(&dest, i)?; let place = self.project_index(&dest, i)?;
@ -397,10 +399,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
sym::simd_extract => { sym::simd_extract => {
let index = u64::from(self.read_scalar(&args[1])?.to_u32()?); let index = u64::from(self.read_scalar(&args[1])?.to_u32()?);
let (input, input_len) = self.operand_to_simd(&args[0])?; let (input, input_len) = self.operand_to_simd(&args[0])?;
assert!( // Bounds are not checked by typeck so we have to do it ourselves.
index < input_len, if index >= input_len {
"index `{index}` must be in bounds of vector with length {input_len}" throw_ub_format!(
"`simd_extract` index {index} is out-of-bounds of vector with length {input_len}"
); );
}
self.copy_op(&self.project_index(&input, index)?, dest)?; self.copy_op(&self.project_index(&input, index)?, dest)?;
} }
sym::likely | sym::unlikely | sym::black_box => { sym::likely | sym::unlikely | sym::black_box => {

View file

@ -2437,6 +2437,14 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
let suggestion = let suggestion =
if has_lifetimes { format!(" + {lt_name}") } else { format!(": {lt_name}") }; if has_lifetimes { format!(" + {lt_name}") } else { format!(": {lt_name}") };
suggs.push((sp, suggestion)) suggs.push((sp, suggestion))
} else if let GenericKind::Alias(ref p) = bound_kind
&& let ty::Projection = p.kind(self.tcx)
&& let DefKind::AssocTy = self.tcx.def_kind(p.def_id)
&& let Some(ty::ImplTraitInTraitData::Trait { .. }) =
self.tcx.opt_rpitit_info(p.def_id)
{
// The lifetime found in the `impl` is longer than the one on the RPITIT.
// Do not suggest `<Type as Trait>::{opaque}: 'static`.
} else if let Some(generics) = self.tcx.hir().get_generics(suggestion_scope) { } else if let Some(generics) = self.tcx.hir().get_generics(suggestion_scope) {
let pred = format!("{bound_kind}: {lt_name}"); let pred = format!("{bound_kind}: {lt_name}");
let suggestion = format!("{} {}", generics.add_where_or_trailing_comma(), pred); let suggestion = format!("{} {}", generics.add_where_or_trailing_comma(), pred);

View file

@ -14,7 +14,7 @@ fn simulator_targets_set_abi() {
aarch64_apple_watchos_sim::target(), aarch64_apple_watchos_sim::target(),
]; ];
for target in all_sim_targets { for target in &all_sim_targets {
assert_eq!(target.abi, "sim") assert_eq!(target.abi, "sim")
} }
} }

View file

@ -320,7 +320,9 @@ fn impl_intersection_has_impossible_obligation<'a, 'cx, 'tcx>(
let mut errors = fulfill_cx.select_where_possible(infcx); let mut errors = fulfill_cx.select_where_possible(infcx);
errors.pop().map(|err| err.obligation) errors.pop().map(|err| err.obligation)
} else { } else {
obligations.iter().cloned().find(|obligation| { obligations
.iter()
.find(|obligation| {
// We use `evaluate_root_obligation` to correctly track intercrate // We use `evaluate_root_obligation` to correctly track intercrate
// ambiguity clauses. We cannot use this in the new solver. // ambiguity clauses. We cannot use this in the new solver.
let evaluation_result = selcx.evaluate_root_obligation(obligation); let evaluation_result = selcx.evaluate_root_obligation(obligation);
@ -336,6 +338,7 @@ fn impl_intersection_has_impossible_obligation<'a, 'cx, 'tcx>(
Err(_overflow) => false, Err(_overflow) => false,
} }
}) })
.cloned()
} }
} }

@ -1 +1 @@
Subproject commit d5fab978fe1c2f0043db0451e9f4857eeba17437 Subproject commit 56087ea170d878a7a57b3a5725e0c00f5f5cad70

View file

@ -879,11 +879,16 @@ fn primitive_link_fragment(
match m.primitive_locations.get(&prim) { match m.primitive_locations.get(&prim) {
Some(&def_id) if def_id.is_local() => { Some(&def_id) if def_id.is_local() => {
let len = cx.current.len(); let len = cx.current.len();
let len = if len == 0 { 0 } else { len - 1 }; let path = if len == 0 {
let cname_sym = ExternalCrate { crate_num: def_id.krate }.name(cx.tcx());
format!("{cname_sym}/")
} else {
"../".repeat(len - 1)
};
write!( write!(
f, f,
"<a class=\"primitive\" href=\"{}primitive.{}.html{fragment}\">", "<a class=\"primitive\" href=\"{}primitive.{}.html{fragment}\">",
"../".repeat(len), path,
prim.as_sym() prim.as_sym()
)?; )?;
needs_termination = true; needs_termination = true;

View file

@ -2503,8 +2503,11 @@ impl<'test> TestCx<'test> {
// overridden by `compile-flags`. // overridden by `compile-flags`.
rustc.arg("-Copt-level=2"); rustc.arg("-Copt-level=2");
} }
RunPassValgrind | Pretty | DebugInfo | Codegen | Rustdoc | RustdocJson | RunMake Assembly | Codegen => {
| CodegenUnits | JsDocTest | Assembly => { rustc.arg("-Cdebug-assertions=no");
}
RunPassValgrind | Pretty | DebugInfo | Rustdoc | RustdocJson | RunMake
| CodegenUnits | JsDocTest => {
// do not use JSON output // do not use JSON output
} }
} }

View file

@ -563,9 +563,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
let right_idx = src_index.checked_sub(left_len).unwrap(); let right_idx = src_index.checked_sub(left_len).unwrap();
this.read_immediate(&this.project_index(&right, right_idx)?)? this.read_immediate(&this.project_index(&right, right_idx)?)?
} else { } else {
span_bug!( throw_ub_format!(
this.cur_span(), "`simd_shuffle_generic` index {src_index} is out-of-bounds for 2 vectors with length {dest_len}"
"simd_shuffle index {src_index} is out of bounds for 2 vectors of size {left_len}",
); );
}; };
this.write_immediate(*val, &dest)?; this.write_immediate(*val, &dest)?;
@ -604,9 +603,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
let right_idx = src_index.checked_sub(left_len).unwrap(); let right_idx = src_index.checked_sub(left_len).unwrap();
this.read_immediate(&this.project_index(&right, right_idx)?)? this.read_immediate(&this.project_index(&right, right_idx)?)?
} else { } else {
span_bug!( throw_ub_format!(
this.cur_span(), "`simd_shuffle` index {src_index} is out-of-bounds for 2 vectors with length {dest_len}"
"simd_shuffle index {src_index} is out of bounds for 2 vectors of size {left_len}",
); );
}; };
this.write_immediate(*val, &dest)?; this.write_immediate(*val, &dest)?;

View file

@ -0,0 +1,8 @@
#![feature(portable_simd, core_intrinsics)]
use std::simd::*;
fn main() {
let v = i32x4::splat(0);
let _x: i32 = unsafe { std::intrinsics::simd::simd_extract(v, 4) };
//~^ERROR: index 4 is out-of-bounds
}

View file

@ -0,0 +1,15 @@
error: Undefined Behavior: `simd_extract` index 4 is out-of-bounds of vector with length 4
--> $DIR/simd-extract.rs:LL:CC
|
LL | let _x: i32 = unsafe { std::intrinsics::simd::simd_extract(v, 4) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `simd_extract` index 4 is out-of-bounds of vector with length 4
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE:
= note: inside `main` at $DIR/simd-extract.rs:LL:CC
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: aborting due to 1 previous error

View file

@ -5,7 +5,6 @@
//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel //@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel
//@ only-x86_64 //@ only-x86_64
//@ ignore-sgx //@ ignore-sgx
//@ ignore-debug
use std::cmp::Ordering; use std::cmp::Ordering;

View file

@ -5,7 +5,6 @@
//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel //@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel
//@ only-x86_64 //@ only-x86_64
//@ ignore-sgx //@ ignore-sgx
//@ ignore-debug
#![feature(str_internals)] #![feature(str_internals)]

View file

@ -6,7 +6,6 @@
//@ [A64] needs-llvm-components: aarch64 //@ [A64] needs-llvm-components: aarch64
//@ [ppc64le] compile-flags: --target powerpc64le-unknown-linux-gnu -Crelocation-model=static //@ [ppc64le] compile-flags: --target powerpc64le-unknown-linux-gnu -Crelocation-model=static
//@ [ppc64le] needs-llvm-components: powerpc //@ [ppc64le] needs-llvm-components: powerpc
//@ ignore-debug: alignment checks insert panics that we don't have a lang item for
#![feature(no_core, lang_items)] #![feature(no_core, lang_items)]
#![no_core] #![no_core]

View file

@ -1,5 +1,4 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug (debug assertions in `slice::from_raw_parts` block optimizations)
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,6 +1,5 @@
//@ compile-flags: -C opt-level=3 -C target-cpu=x86-64-v3 //@ compile-flags: -C opt-level=3 -C target-cpu=x86-64-v3
//@ only-x86_64 //@ only-x86_64
//@ ignore-debug (the extra assertions get in the way)
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,5 +1,4 @@
//@ compile-flags: -C opt-level=1 //@ compile-flags: -C opt-level=1
//@ ignore-debug (the extra assertions get in the way)
#![crate_type = "lib"] #![crate_type = "lib"]
#![feature(ascii_char)] #![feature(ascii_char)]

View file

@ -1,5 +1,4 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug: the debug assertions get in the way
#![crate_type = "lib"] #![crate_type = "lib"]
// Make sure no bounds checks are emitted when slicing or indexing // Make sure no bounds checks are emitted when slicing or indexing

View file

@ -1,5 +1,4 @@
//@ compile-flags: -C opt-level=z --edition=2021 //@ compile-flags: -C opt-level=z --edition=2021
//@ ignore-debug
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,5 +1,4 @@
//@ compile-flags: -C opt-level=3 //@ compile-flags: -C opt-level=3
//@ ignore-debug: the debug assertions get in the way
//@ min-llvm-version: 17.0.2 //@ min-llvm-version: 17.0.2
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,5 +1,4 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug: the debug assertions get in the way
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,5 +1,4 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug: the debug assertions get in the way
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,5 +1,4 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug (the extra assertions get in the way)
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,5 +1,4 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug: the debug assertions get in the way
#![crate_type = "lib"] #![crate_type = "lib"]
/// Make sure no bounds checks are emitted after a `get_unchecked`. /// Make sure no bounds checks are emitted after a `get_unchecked`.

View file

@ -1,6 +1,5 @@
//@ compile-flags: -O -Zmerge-functions=disabled //@ compile-flags: -O -Zmerge-functions=disabled
//@ ignore-32bit LLVM has a bug with them //@ ignore-32bit LLVM has a bug with them
//@ ignore-debug
// Check that LLVM understands that `Iter` pointer is not null. Issue #37945. // Check that LLVM understands that `Iter` pointer is not null. Issue #37945.

View file

@ -1,5 +1,4 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug: the debug assertions get in the way
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,5 +1,4 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug: the debug assertions get in the way
#![crate_type="rlib"] #![crate_type="rlib"]

View file

@ -2,7 +2,6 @@
// prevent optimizing away bounds checks // prevent optimizing away bounds checks
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug: the debug assertions get in the way
#![crate_type="rlib"] #![crate_type="rlib"]

View file

@ -1,5 +1,4 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug: the debug assertions get in the way
#![crate_type = "lib"] #![crate_type = "lib"]
// Make sure no bounds checks are emitted in the loop when upfront slicing // Make sure no bounds checks are emitted in the loop when upfront slicing

View file

@ -1,5 +1,4 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug (the extra assertions get in the way)
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,5 +1,4 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug: the debug assertions get in the way
#![crate_type = "lib"] #![crate_type = "lib"]
// Make sure no bounds checks are emitted when slicing or indexing // Make sure no bounds checks are emitted when slicing or indexing

View file

@ -1,4 +1,3 @@
//@ ignore-debug: The debug assertions get in the way
//@ compile-flags: -O //@ compile-flags: -O
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,6 +1,5 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ only-x86_64 //@ only-x86_64
//@ ignore-debug: the debug assertions get in the way
#![crate_type = "lib"] #![crate_type = "lib"]
#![feature(iter_repeat_n)] #![feature(iter_repeat_n)]

View file

@ -1,6 +1,5 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ only-x86_64 //@ only-x86_64
//@ ignore-debug: the debug assertions get in the way
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,4 +1,3 @@
//@ ignore-debug: the debug assertions get in the way
//@ compile-flags: -O //@ compile-flags: -O
//@ only-x86_64 (vectorization varies between architectures) //@ only-x86_64 (vectorization varies between architectures)
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -4,7 +4,7 @@
// known to be `1` after inlining). // known to be `1` after inlining).
//@ compile-flags: -C no-prepopulate-passes -Zinline-mir=no //@ compile-flags: -C no-prepopulate-passes -Zinline-mir=no
//@ ignore-debug: the debug assertions get in the way //@ ignore-debug: precondition checks in ptr::read make them a bad candidate for MIR inlining
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,6 +1,6 @@
//@ compile-flags: -O -C no-prepopulate-passes //@ compile-flags: -O -C no-prepopulate-passes
//@ only-x86_64 (to not worry about usize differing) //@ only-x86_64 (to not worry about usize differing)
//@ ignore-debug (the debug assertions get in the way) //@ ignore-debug: precondition checks make mem::replace not a candidate for MIR inlining
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,5 +1,4 @@
//@ compile-flags: -O -Z merge-functions=disabled //@ compile-flags: -O -Z merge-functions=disabled
//@ ignore-debug (the extra assertions get in the way)
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,5 +1,4 @@
//@ compile-flags: -O -Z merge-functions=disabled //@ compile-flags: -O -Z merge-functions=disabled
//@ ignore-debug (the extra assertions get in the way)
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,7 +1,6 @@
//@ revisions: llvm mir-opt3 //@ revisions: llvm mir-opt3
//@ compile-flags: -C opt-level=3 -Z merge-functions=disabled --edition=2021 //@ compile-flags: -C opt-level=3 -Z merge-functions=disabled --edition=2021
//@ only-x86_64 //@ only-x86_64
//@ ignore-debug: the debug assertions get in the way
//@ [mir-opt3]compile-flags: -Zmir-opt-level=3 //@ [mir-opt3]compile-flags: -Zmir-opt-level=3
//@ [mir-opt3]build-pass //@ [mir-opt3]build-pass

View file

@ -1,6 +1,5 @@
//@ compile-flags: -O -C target-feature=+avx //@ compile-flags: -O -C target-feature=+avx
//@ only-x86_64 //@ only-x86_64
//@ ignore-debug: the debug assertions get in the way
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,6 +1,5 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ only-64bit (because the LLVM type of i64 for usize shows up) //@ only-64bit (because the LLVM type of i64 for usize shows up)
//@ ignore-debug: the debug assertions get in the way
#![crate_type = "lib"] #![crate_type = "lib"]
#![feature(slice_as_chunks)] #![feature(slice_as_chunks)]

View file

@ -1,6 +1,5 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ only-64bit (because the LLVM type of i64 for usize shows up) //@ only-64bit (because the LLVM type of i64 for usize shows up)
//@ ignore-debug: the debug assertions get in the way
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,4 +1,3 @@
//@ ignore-debug: the debug assertions get in the way
//@ compile-flags: -O //@ compile-flags: -O
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,5 +1,4 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug: the debug assertions add extra comparisons
#![crate_type = "lib"] #![crate_type = "lib"]
type Demo = [u8; 3]; type Demo = [u8; 3];

View file

@ -1,5 +1,4 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug (these add extra checks that make it hard to verify)
#![crate_type = "lib"] #![crate_type = "lib"]
#![feature(exact_size_is_empty)] #![feature(exact_size_is_empty)]

View file

@ -1,5 +1,4 @@
//@ compile-flags: -O -Zmerge-functions=disabled //@ compile-flags: -O -Zmerge-functions=disabled
//@ ignore-debug (the extra assertions get in the way)
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,6 +1,6 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ only-x86_64 //@ only-x86_64
//@ ignore-debug: the debug assertions in from_raw_parts get in the way //@ ignore-debug: debug assertions prevent generating shufflevector
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,6 +1,5 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ only-64bit (because we're using [ui]size) //@ only-64bit (because we're using [ui]size)
//@ ignore-debug (because the assertions get in the way)
#![crate_type = "lib"] #![crate_type = "lib"]
#![feature(slice_from_ptr_range)] #![feature(slice_from_ptr_range)]

View file

@ -1,6 +1,5 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ only-x86_64 //@ only-x86_64
//@ ignore-debug: the debug assertions get in the way
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,6 +1,5 @@
//@ compile-flags: -O -Z merge-functions=disabled //@ compile-flags: -O -Z merge-functions=disabled
//@ only-x86_64 //@ only-x86_64
//@ ignore-debug: the debug assertions get in the way
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,5 +1,4 @@
//@ compile-flags: -O -Z merge-functions=disabled //@ compile-flags: -O -Z merge-functions=disabled
//@ ignore-debug
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,5 +1,4 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug (because unchecked is checked in debug)
#![crate_type = "lib"] #![crate_type = "lib"]
#![feature(unchecked_shifts)] #![feature(unchecked_shifts)]

View file

@ -1,6 +1,5 @@
//@ min-llvm-version: 17.0.2 //@ min-llvm-version: 17.0.2
//@ compile-flags: -Copt-level=3 //@ compile-flags: -Copt-level=3
//@ ignore-debug: the debug assertions get in the way
#![crate_type = "lib"] #![crate_type = "lib"]
// This test checks that we can inline drop_in_place in // This test checks that we can inline drop_in_place in

View file

@ -1,6 +1,5 @@
//@ compile-flags: -O -Z merge-functions=disabled //@ compile-flags: -O -Z merge-functions=disabled
//@ only-x86_64 //@ only-x86_64
//@ ignore-debug
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,4 +1,4 @@
//@ ignore-debug: the debug assertions get in the way //@ ignore-debug: FIXME: checks for call detect scoped noalias metadata
//@ compile-flags: -O -Z merge-functions=disabled //@ compile-flags: -O -Z merge-functions=disabled
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,4 +1,3 @@
//@ ignore-debug: the debug assertions get in the way
//@ compile-flags: -O //@ compile-flags: -O
#![crate_type="lib"] #![crate_type="lib"]

View file

@ -1,4 +1,3 @@
//@ ignore-debug: the debug assertions get in the way
//@ compile-flags: -O //@ compile-flags: -O
#![crate_type = "lib"] #![crate_type = "lib"]
#![feature(exact_size_is_empty)] #![feature(exact_size_is_empty)]

View file

@ -1,4 +1,3 @@
//@ ignore-debug: the debug assertions get in the way
//@ compile-flags: -O //@ compile-flags: -O
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,6 +1,4 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug
// (with debug assertions turned on, `assert_unchecked` generates a real assertion)
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -4,7 +4,7 @@
//@ [old]ignore-llvm-version: 17 - 99 //@ [old]ignore-llvm-version: 17 - 99
//@ [new]min-llvm-version: 17 //@ [new]min-llvm-version: 17
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug: the debug assertions get in the way //@ ignore-debug: plain old debug assertions
//@ needs-unwind //@ needs-unwind
#![crate_type = "lib"] #![crate_type = "lib"]
#![feature(shrink_to)] #![feature(shrink_to)]

View file

@ -1,6 +1,4 @@
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug
// (with debug assertions turned on, `assert_unchecked` generates a real assertion)
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,7 +1,7 @@
// Check that draining at the front or back doesn't copy memory. // Check that draining at the front or back doesn't copy memory.
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug: the debug assertions get in the way //@ ignore-debug: FIXME: checks for call detect scoped noalias metadata
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,7 +1,6 @@
// Guards against regression for optimization discussed in issue #80836 // Guards against regression for optimization discussed in issue #80836
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug: the debug assertions get in the way
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,7 +1,7 @@
// This test checks that `VecDeque::front[_mut]()` and `VecDeque::back[_mut]()` can't panic. // This test checks that `VecDeque::front[_mut]()` and `VecDeque::back[_mut]()` can't panic.
//@ compile-flags: -O //@ compile-flags: -O
//@ ignore-debug: the debug assertions get in the way //@ ignore-debug: plain old debug assertions
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,6 +1,5 @@
//@ compile-flags: -Zvirtual-function-elimination -Clto -O -Csymbol-mangling-version=v0 //@ compile-flags: -Zvirtual-function-elimination -Clto -O -Csymbol-mangling-version=v0
//@ ignore-32bit //@ ignore-32bit
//@ ignore-debug
// CHECK: @vtable.0 = {{.*}}, !type ![[TYPE0:[0-9]+]], !vcall_visibility ![[VCALL_VIS0:[0-9]+]] // CHECK: @vtable.0 = {{.*}}, !type ![[TYPE0:[0-9]+]], !vcall_visibility ![[VCALL_VIS0:[0-9]+]]
// CHECK: @vtable.1 = {{.*}}, !type ![[TYPE1:[0-9]+]], !vcall_visibility ![[VCALL_VIS0:[0-9]+]] // CHECK: @vtable.1 = {{.*}}, !type ![[TYPE1:[0-9]+]], !vcall_visibility ![[VCALL_VIS0:[0-9]+]]

View file

@ -1,6 +1,5 @@
// skip-filecheck // skip-filecheck
//@ compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=2 //@ compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=2
//@ ignore-debug: standard library debug assertions add a panic that breaks this optimization
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,6 +1,6 @@
// MIR for `variant_a::{closure#0}` after PreCodegen // MIR for `variant_a::{closure#0}` after PreCodegen
fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2: &&(usize, usize, usize, usize)) -> bool { fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2: &&(usize, usize, usize, usize)) -> bool {
let mut _0: bool; let mut _0: bool;
let mut _3: &(usize, usize, usize, usize); let mut _3: &(usize, usize, usize, usize);
let _4: &usize; let _4: &usize;

View file

@ -1,6 +1,6 @@
// MIR for `variant_b::{closure#0}` after PreCodegen // MIR for `variant_b::{closure#0}` after PreCodegen
fn variant_b::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:12:25: 12:41}, _2: &&(usize, usize, usize, usize)) -> bool { fn variant_b::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:11:25: 11:41}, _2: &&(usize, usize, usize, usize)) -> bool {
let mut _0: bool; let mut _0: bool;
let mut _3: &(usize, usize, usize, usize); let mut _3: &(usize, usize, usize, usize);
let _4: usize; let _4: usize;

View file

@ -6,8 +6,6 @@ LL | async fn foo() -> &'static impl T;
| | | |
| the associated type `<Self as MyTrait>::{opaque#0}` must be valid for the static lifetime... | the associated type `<Self as MyTrait>::{opaque#0}` must be valid for the static lifetime...
| ...so that the reference type `&'static impl T` does not outlive the data it points at | ...so that the reference type `&'static impl T` does not outlive the data it points at
|
= help: consider adding an explicit lifetime bound `<Self as MyTrait>::{opaque#0}: 'static`...
error: aborting due to 1 previous error error: aborting due to 1 previous error

View file

@ -0,0 +1,16 @@
trait Original {
fn f() -> impl Fn();
}
trait Erased {
fn f(&self) -> Box<dyn Fn()>;
}
impl<T: Original> Erased for T {
fn f(&self) -> Box<dyn Fn()> {
Box::new(<T as Original>::f())
//~^ ERROR the associated type `<T as Original>::{opaque#0}` may not live long enough
}
}
fn main () {}

View file

@ -0,0 +1,12 @@
error[E0310]: the associated type `<T as Original>::{opaque#0}` may not live long enough
--> $DIR/missing-static-bound-from-impl.rs:11:9
|
LL | Box::new(<T as Original>::f())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| the associated type `<T as Original>::{opaque#0}` must be valid for the static lifetime...
| ...so that the type `impl Fn()` will meet its required lifetime bounds
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0310`.

View file

@ -1,6 +1,6 @@
//@ build-fail //@ build-fail
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
#![feature(repr_simd, platform_intrinsics)] #![feature(repr_simd, core_intrinsics)]
// Test for #73542 to verify out-of-bounds shuffle vectors do not compile. // Test for #73542 to verify out-of-bounds shuffle vectors do not compile.
@ -28,9 +28,7 @@ struct u8x32([u8; 32]);
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
struct u8x64([u8; 64]); struct u8x64([u8; 64]);
extern "platform-intrinsic" { use std::intrinsics::simd::*;
pub fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U;
}
// Test vectors by lane size. Since LLVM does not distinguish between a shuffle // Test vectors by lane size. Since LLVM does not distinguish between a shuffle
// over two f32s and a shuffle over two u64s, or any other such combination, // over two f32s and a shuffle over two u64s, or any other such combination,
@ -70,13 +68,16 @@ fn main() {
test_shuffle_lanes!(32, u8x32, simd_shuffle); test_shuffle_lanes!(32, u8x32, simd_shuffle);
test_shuffle_lanes!(64, u8x64, simd_shuffle); test_shuffle_lanes!(64, u8x64, simd_shuffle);
extern "platform-intrinsic" {
fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U;
}
let v = u8x2([0, 0]); let v = u8x2([0, 0]);
const I: [u32; 2] = [4, 4]; const I: [u32; 2] = [4, 4];
unsafe { unsafe {
let _: u8x2 = simd_shuffle(v, v, I); let _: u8x2 = simd_shuffle(v, v, I);
//~^ ERROR invalid monomorphization of `simd_shuffle` intrinsic //~^ ERROR invalid monomorphization of `simd_shuffle` intrinsic
} }
// also check insert/extract
unsafe {
simd_insert(v, 2, 0); //~ ERROR invalid monomorphization of `simd_insert` intrinsic
let _val: u8 = simd_extract(v, 2); //~ ERROR invalid monomorphization of `simd_extract` intrinsic
}
} }

View file

@ -1,5 +1,5 @@
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 4) error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: SIMD index #0 is out of bounds (limit 4)
--> $DIR/shuffle-not-out-of-bounds.rs:51:21 --> $DIR/not-out-of-bounds.rs:49:21
| |
LL | $y(vec1, vec2, ARR) LL | $y(vec1, vec2, ARR)
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
@ -9,8 +9,8 @@ LL | test_shuffle_lanes!(2, u8x2, simd_shuffle);
| |
= note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 8) error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: SIMD index #0 is out of bounds (limit 8)
--> $DIR/shuffle-not-out-of-bounds.rs:51:21 --> $DIR/not-out-of-bounds.rs:49:21
| |
LL | $y(vec1, vec2, ARR) LL | $y(vec1, vec2, ARR)
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
@ -20,8 +20,8 @@ LL | test_shuffle_lanes!(4, u8x4, simd_shuffle);
| |
= note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 16) error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: SIMD index #0 is out of bounds (limit 16)
--> $DIR/shuffle-not-out-of-bounds.rs:51:21 --> $DIR/not-out-of-bounds.rs:49:21
| |
LL | $y(vec1, vec2, ARR) LL | $y(vec1, vec2, ARR)
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
@ -31,8 +31,8 @@ LL | test_shuffle_lanes!(8, u8x8, simd_shuffle);
| |
= note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 32) error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: SIMD index #0 is out of bounds (limit 32)
--> $DIR/shuffle-not-out-of-bounds.rs:51:21 --> $DIR/not-out-of-bounds.rs:49:21
| |
LL | $y(vec1, vec2, ARR) LL | $y(vec1, vec2, ARR)
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
@ -42,8 +42,8 @@ LL | test_shuffle_lanes!(16, u8x16, simd_shuffle);
| |
= note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 64) error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: SIMD index #0 is out of bounds (limit 64)
--> $DIR/shuffle-not-out-of-bounds.rs:51:21 --> $DIR/not-out-of-bounds.rs:49:21
| |
LL | $y(vec1, vec2, ARR) LL | $y(vec1, vec2, ARR)
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
@ -53,8 +53,8 @@ LL | test_shuffle_lanes!(32, u8x32, simd_shuffle);
| |
= note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 128) error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: SIMD index #0 is out of bounds (limit 128)
--> $DIR/shuffle-not-out-of-bounds.rs:51:21 --> $DIR/not-out-of-bounds.rs:49:21
| |
LL | $y(vec1, vec2, ARR) LL | $y(vec1, vec2, ARR)
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
@ -64,12 +64,24 @@ LL | test_shuffle_lanes!(64, u8x64, simd_shuffle);
| |
= note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: shuffle index #0 is out of bounds (limit 4) error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: SIMD index #0 is out of bounds (limit 4)
--> $DIR/shuffle-not-out-of-bounds.rs:79:23 --> $DIR/not-out-of-bounds.rs:74:23
| |
LL | let _: u8x2 = simd_shuffle(v, v, I); LL | let _: u8x2 = simd_shuffle(v, v, I);
| ^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 7 previous errors error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected inserted type `u8` (element of input `u8x2`), found `i32`
--> $DIR/not-out-of-bounds.rs:80:9
|
LL | simd_insert(v, 2, 0);
| ^^^^^^^^^^^^^^^^^^^^
error[E0511]: invalid monomorphization of `simd_extract` intrinsic: SIMD index #1 is out of bounds (limit 2)
--> $DIR/not-out-of-bounds.rs:81:24
|
LL | let _val: u8 = simd_extract(v, 2);
| ^^^^^^^^^^^^^^^^^^
error: aborting due to 9 previous errors
For more information about this error, try `rustc --explain E0511`. For more information about this error, try `rustc --explain E0511`.