Auto merge of #122997 - matthiaskrgr:compiletest_ices, r=oli-obk

compiletest ice tracking

see https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/where.20to.20mass-add.20known.20ices.20.2F.20merging.20glacier.20into.20rust/near/429082963

This will allow us to sunset most of https://github.com/rust-lang/glacier
The rustc ices will be tracked directly inside the rust testsuite
There are a couple of .sh tests remaining that I have not ported over yet.

This adds `tests/crashes`, a file inside this directory MUST ice, otherwise it is considered test-fail.
This will be used to track ICEs from glacier and the bugtracker.
When someones pr accidentally fixes one of these ICEs, they can move the test from `crashes` into `ui` for example.

I also added a new tidy lint that warns when a test inside `tests/crashes` does not have a `//@ known-bug: ` line

the env var `COMPILETEST_VERBOSE_CRASHES` can be set to get exit code, stderr and stdout of a crash-test to aid debugging/adding tests.
This commit is contained in:
bors 2024-04-15 06:04:50 +00:00
commit 85b884b058
172 changed files with 3362 additions and 7 deletions

View File

@ -1400,6 +1400,8 @@ impl Step for RunMakeSupport {
default_test!(Ui { path: "tests/ui", mode: "ui", suite: "ui" });
default_test!(Crashes { path: "tests/crashes", mode: "crashes", suite: "crashes" });
default_test!(RunPassValgrind {
path: "tests/run-pass-valgrind",
mode: "run-pass-valgrind",

View File

@ -745,6 +745,7 @@ impl<'a> Builder<'a> {
test::ExpandYamlAnchors,
test::Tidy,
test::Ui,
test::Crashes,
test::RunPassValgrind,
test::Coverage,
test::CoverageMap,

View File

@ -69,6 +69,7 @@ string_enum! {
Assembly => "assembly",
CoverageMap => "coverage-map",
CoverageRun => "coverage-run",
Crashes => "crashes",
}
}

View File

@ -581,6 +581,16 @@ impl TestProps {
self.incremental = true;
}
if config.mode == Mode::Crashes {
// we don't want to pollute anything with backtrace-files
// also turn off backtraces in order to save some execution
// time on the tests; we only need to know IF it crashes
self.rustc_env = vec![
("RUST_BACKTRACE".to_string(), "0".to_string()),
("RUSTC_ICE".to_string(), "0".to_string()),
];
}
for key in &["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] {
if let Ok(val) = env::var(key) {
if self.exec_env.iter().find(|&&(ref x, _)| x == key).is_none() {
@ -596,7 +606,8 @@ impl TestProps {
fn update_fail_mode(&mut self, ln: &str, config: &Config) {
let check_ui = |mode: &str| {
if config.mode != Mode::Ui {
// Mode::Crashes may need build-fail in order to trigger llvm errors or stack overflows
if config.mode != Mode::Ui && config.mode != Mode::Crashes {
panic!("`{}-fail` header is only supported in UI tests", mode);
}
};
@ -625,6 +636,7 @@ impl TestProps {
fn update_pass_mode(&mut self, ln: &str, revision: Option<&str>, config: &Config) {
let check_no_run = |s| match (config.mode, s) {
(Mode::Ui, _) => (),
(Mode::Crashes, _) => (),
(Mode::Codegen, "build-pass") => (),
(Mode::Incremental, _) => {
if revision.is_some() && !self.revisions.iter().all(|r| r.starts_with("cfail")) {
@ -757,6 +769,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"ignore-mode-codegen-units",
"ignore-mode-coverage-map",
"ignore-mode-coverage-run",
"ignore-mode-crashes",
"ignore-mode-debuginfo",
"ignore-mode-incremental",
"ignore-mode-js-doc-test",

View File

@ -65,7 +65,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
"mode",
"which sort of compile tests to run",
"run-pass-valgrind | pretty | debug-info | codegen | rustdoc \
| rustdoc-json | codegen-units | incremental | run-make | ui | js-doc-test | mir-opt | assembly",
| rustdoc-json | codegen-units | incremental | run-make | ui \
| js-doc-test | mir-opt | assembly | crashes",
)
.reqopt(
"",
@ -82,7 +83,12 @@ pub fn parse_config(args: Vec<String>) -> Config {
.optopt("", "run", "whether to execute run-* tests", "auto | always | never")
.optflag("", "ignored", "run tests marked as ignored")
.optflag("", "with-debug-assertions", "whether to run tests with `ignore-debug` header")
.optmulti("", "skip", "skip tests matching SUBSTRING. Can be passed multiple times", "SUBSTRING")
.optmulti(
"",
"skip",
"skip tests matching SUBSTRING. Can be passed multiple times",
"SUBSTRING",
)
.optflag("", "exact", "filters match exactly")
.optopt(
"",
@ -145,7 +151,11 @@ pub fn parse_config(args: Vec<String>) -> Config {
.optflag("", "profiler-support", "is the profiler runtime enabled for this target")
.optflag("h", "help", "show this message")
.reqopt("", "channel", "current Rust channel", "CHANNEL")
.optflag("", "git-hash", "run tests which rely on commit version being compiled into the binaries")
.optflag(
"",
"git-hash",
"run tests which rely on commit version being compiled into the binaries",
)
.optopt("", "edition", "default Rust edition", "EDITION")
.reqopt("", "git-repository", "name of the git repository", "ORG/REPO")
.reqopt("", "nightly-branch", "name of the git branch for nightly", "BRANCH");

View File

@ -4,7 +4,7 @@ use crate::common::{
expected_output_path, UI_EXTENSIONS, UI_FIXED, UI_STDERR, UI_STDOUT, UI_SVG, UI_WINDOWS_SVG,
};
use crate::common::{incremental_dir, output_base_dir, output_base_name, output_testname_unique};
use crate::common::{Assembly, Incremental, JsDocTest, MirOpt, RunMake, RustdocJson, Ui};
use crate::common::{Assembly, Crashes, Incremental, JsDocTest, MirOpt, RunMake, RustdocJson, Ui};
use crate::common::{Codegen, CodegenUnits, DebugInfo, Debugger, Rustdoc};
use crate::common::{CompareMode, FailMode, PassMode};
use crate::common::{Config, TestPaths};
@ -244,7 +244,7 @@ impl<'test> TestCx<'test> {
/// Code executed for each revision in turn (or, if there are no
/// revisions, exactly once, with revision == None).
fn run_revision(&self) {
if self.props.should_ice && self.config.mode != Incremental {
if self.props.should_ice && self.config.mode != Incremental && self.config.mode != Crashes {
self.fatal("cannot use should-ice in a test that is not cfail");
}
match self.config.mode {
@ -263,6 +263,7 @@ impl<'test> TestCx<'test> {
JsDocTest => self.run_js_doc_test(),
CoverageMap => self.run_coverage_map_test(),
CoverageRun => self.run_coverage_run_test(),
Crashes => self.run_crash_test(),
}
}
@ -295,6 +296,7 @@ impl<'test> TestCx<'test> {
match self.config.mode {
JsDocTest => true,
Ui => pm.is_some() || self.props.fail_mode > Some(FailMode::Build),
Crashes => false,
Incremental => {
let revision =
self.revision.expect("incremental tests require a list of revisions");
@ -359,6 +361,27 @@ impl<'test> TestCx<'test> {
self.check_forbid_output(&output_to_check, &proc_res);
}
fn run_crash_test(&self) {
let pm = self.pass_mode();
let proc_res = self.compile_test(WillExecute::No, self.should_emit_metadata(pm));
if std::env::var("COMPILETEST_VERBOSE_CRASHES").is_ok() {
eprintln!("{}", proc_res.status);
eprintln!("{}", proc_res.stdout);
eprintln!("{}", proc_res.stderr);
eprintln!("{}", proc_res.cmdline);
}
// if a test does not crash, consider it an error
if proc_res.status.success() || matches!(proc_res.status.code(), Some(1 | 0)) {
self.fatal(&format!(
"test no longer crashes/triggers ICE! Please give it a mearningful name, \
add a doc-comment to the start of the test explaining why it exists and \
move it to tests/ui or wherever you see fit."
));
}
}
fn run_rfail_test(&self) {
let pm = self.pass_mode();
let should_run = self.run_if_enabled();
@ -2517,7 +2540,7 @@ impl<'test> TestCx<'test> {
rustc.arg("-Cdebug-assertions=no");
}
RunPassValgrind | Pretty | DebugInfo | Rustdoc | RustdocJson | RunMake
| CodegenUnits | JsDocTest => {
| CodegenUnits | JsDocTest | Crashes => {
// do not use JSON output
}
}

View File

@ -96,6 +96,7 @@ llvm-config = "{llvm_config}"
"tests/pretty",
"tests/run-pass-valgrind",
"tests/ui",
"tests/crashes",
];
for test_path in env.skipped_tests() {
args.extend(["--skip", test_path]);

View File

@ -0,0 +1,17 @@
//! Tidy check to ensure that tests inside 'tests/crashes' have a '@known-bug' directive.
use crate::walk::*;
use std::path::Path;
pub fn check(filepath: &Path, bad: &mut bool) {
walk(filepath, |path, _is_dir| filter_not_rust(path), &mut |entry, contents| {
let file = entry.path();
if !contents.lines().any(|line| line.starts_with("//@ known-bug: ")) {
tidy_error!(
bad,
"{} crash/ice test does not have a \"//@ known-bug: \" directive",
file.display()
);
}
});
}

View File

@ -67,6 +67,7 @@ pub mod features;
pub mod fluent_alphabetical;
mod fluent_used;
pub(crate) mod iter_header;
pub mod known_bug;
pub mod mir_opt_tests;
pub mod pal;
pub mod run_make_tests;

View File

@ -35,6 +35,7 @@ fn main() {
let library_path = root_path.join("library");
let compiler_path = root_path.join("compiler");
let librustdoc_path = src_path.join("librustdoc");
let crashes_path = tests_path.join("crashes");
let args: Vec<String> = env::args().skip(1).collect();
let (cfg_args, pos_args) = match args.iter().position(|arg| arg == "--") {
@ -108,6 +109,7 @@ fn main() {
check!(mir_opt_tests, &tests_path, bless);
check!(rustdoc_gui_tests, &tests_path);
check!(rustdoc_css_themes, &librustdoc_path);
check!(known_bug, &crashes_path);
// Checks that only make sense for the compiler.
check!(error_codes, &root_path, &[&compiler_path, &librustdoc_path], verbose);

17
tests/crashes/100041.rs Normal file
View File

@ -0,0 +1,17 @@
//@ known-bug: #100041
pub trait WellUnformed {
type RequestNormalize;
}
impl<T: ?Sized> WellUnformed for T {
type RequestNormalize = ();
}
pub fn latent(_: &[<[[()]] as WellUnformed>::RequestNormalize; 0]) {}
pub fn bang() {
latent(&[]);
}
fn main() {}

14
tests/crashes/101036.rs Normal file
View File

@ -0,0 +1,14 @@
//@ known-bug: #101036
#![feature(generic_const_exprs)]
const fn t<const N: usize>() -> u8 {
N as u8
}
#[repr(u8)]
enum T<const N: u8 = { T::<0>::A as u8 + T::<0>::B as u8 }>
where
[(); N as usize]:
{
A = t::<N>() as u8, B
}

42
tests/crashes/101557.rs Normal file
View File

@ -0,0 +1,42 @@
//@ known-bug: #101557
//@ compile-flags: -Copt-level=0
#![feature(generic_const_exprs)]
use std::marker::PhantomData;
trait Trait {
const CONST: usize;
}
struct A<T: Trait> {
_marker: PhantomData<T>,
}
impl<const N: usize> Trait for [i8; N] {
const CONST: usize = N;
}
impl<const N: usize> From<usize> for A<[i8; N]> {
fn from(_: usize) -> Self {
todo!()
}
}
impl<T: Trait> From<A<[i8; T::CONST]>> for A<T> {
fn from(_: A<[i8; T::CONST]>) -> Self {
todo!()
}
}
fn f<T: Trait>() -> A<T>
where
[(); T::CONST]:,
{
// Usage of `0` is arbitrary
let a = A::<[i8; T::CONST]>::from(0);
A::<T>::from(a)
}
fn main() {
// Usage of `1` is arbitrary
f::<[i8; 1]>();
}

11
tests/crashes/101962.rs Normal file
View File

@ -0,0 +1,11 @@
//@ known-bug: #101962
#![feature(core_intrinsics)]
pub fn wrapping<T: Copy>(a: T, b: T) {
let _z = core::intrinsics::wrapping_mul(a, b);
}
fn main() {
wrapping(1,2);
}

45
tests/crashes/102047.rs Normal file
View File

@ -0,0 +1,45 @@
//@ known-bug: #102047
struct Ty1;
struct Ty2;
pub trait Trait<T> {}
pub trait WithAssoc1<'a> {
type Assoc;
}
pub trait WithAssoc2<'a> {
type Assoc;
}
impl<T, U> Trait<for<'a> fn(<T as WithAssoc1<'a>>::Assoc, <U as WithAssoc2<'a>>::Assoc)> for (T, U)
where
T: for<'a> WithAssoc1<'a> + for<'a> WithAssoc2<'a, Assoc = i32>,
U: for<'a> WithAssoc2<'a>,
{
}
impl WithAssoc1<'_> for Ty1 {
type Assoc = ();
}
impl WithAssoc2<'_> for Ty1 {
type Assoc = i32;
}
impl WithAssoc1<'_> for Ty2 {
type Assoc = ();
}
impl WithAssoc2<'_> for Ty2 {
type Assoc = u32;
}
fn foo<T, U, V>()
where
T: for<'a> WithAssoc1<'a>,
U: for<'a> WithAssoc2<'a>,
(T, U): Trait<V>,
{
}
fn main() {
foo::<Ty1, Ty2, _>();
}

14
tests/crashes/102252.rs Normal file
View File

@ -0,0 +1,14 @@
//@ known-bug: #102252
#![feature(min_specialization, rustc_attrs)]
#[rustc_specialization_trait]
pub trait Trait {}
struct Struct
where
Self: Iterator<Item = <Self as Iterator>::Item>, {}
impl Trait for Struct {}
fn main() {}

27
tests/crashes/103899.rs Normal file
View File

@ -0,0 +1,27 @@
//@ known-bug: #103899
trait BaseWithAssoc {
type Assoc;
}
trait WrapperWithAssoc {
type BaseAssoc: BaseWithAssoc;
}
struct Wrapper<B> {
inner: B,
}
struct ProjectToBase<T: BaseWithAssoc> {
data_type_h: T::Assoc,
}
struct DoubleProject<L: WrapperWithAssoc> {
buffer: Wrapper<ProjectToBase<L::BaseAssoc>>,
}
fn trigger<L: WrapperWithAssoc<BaseAssoc = ()>>() -> DoubleProject<L> {
loop {}
}
fn main() {}

31
tests/crashes/105238-1.rs Normal file
View File

@ -0,0 +1,31 @@
//@ known-bug: #105238
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
trait Ret {
type R;
}
struct Cond<const PRED: bool, U, V>(std::marker::PhantomData<U>, std::marker::PhantomData<V>);
impl<U, V> Ret for Cond<true, U, V> {
type R = U;
}
impl<U, V> Ret for Cond<false, U, V> {
type R = V;
}
struct RobinHashTable<const MAX_LENGTH: usize, CellIdx = Cond<{ MAX_LENGTH < 65535 }, u16, u32>>
where
CellIdx: Ret,
{
_idx: CellIdx::R,
}
fn main() {
use std::mem::size_of;
println!("{}", size_of::<RobinHashTable<1024>>());
println!("{}", size_of::<RobinHashTable<65536>>());
}

31
tests/crashes/105238-2.rs Normal file
View File

@ -0,0 +1,31 @@
//@ known-bug: #105238
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
trait Ret {
type R;
}
struct Cond<const PRED: bool, U, V>(std::marker::PhantomData<U>, std::marker::PhantomData<V>);
impl<U, V> Ret for Cond<true, U, V> {
type R = U;
}
impl<U, V> Ret for Cond<false, U, V> {
type R = V;
}
struct RobinHashTable<
const MAX_LENGTH: usize,
CellIdx = <Cond<{ MAX_LENGTH < 65535 }, u16, u32> as Ret>::R,
> {
_idx: CellIdx,
}
fn main() {
use std::mem::size_of;
println!("{}", size_of::<RobinHashTable<1024>>());
println!("{}", size_of::<RobinHashTable<65536>>());
}

27
tests/crashes/105275.rs Normal file
View File

@ -0,0 +1,27 @@
//@ known-bug: #105275
//@ compile-flags: -Copt-level=0
pub fn encode_num<Writer: ExampleWriter>(n: u32, mut writer: Writer) -> Result<(), Writer::Error> {
if n > 15 {
encode_num(n / 16, &mut writer)?;
}
Ok(())
}
pub trait ExampleWriter {
type Error;
}
impl<'a, T: ExampleWriter> ExampleWriter for &'a mut T {
type Error = T::Error;
}
struct Error;
impl ExampleWriter for Error {
type Error = ();
}
fn main() {
encode_num(69, &mut Error).unwrap();
}

27
tests/crashes/105937.rs Normal file
View File

@ -0,0 +1,27 @@
//@ known-bug: #105937
//@ compile-flags: -Copt-level=0
pub fn encode_num<Writer: ExampleWriter>(n: u32, mut writer: Writer) -> Result<(), Writer::Error> {
if n > 15 {
encode_num(n / 16, &mut writer)?;
}
Ok(())
}
pub trait ExampleWriter {
type Error;
}
impl<'a, T: ExampleWriter> ExampleWriter for &'a mut T {
type Error = T::Error;
}
struct Error;
impl ExampleWriter for Error {
type Error = ();
}
fn main() {
encode_num(69, &mut Error).unwrap();
}

12
tests/crashes/106473.rs Normal file
View File

@ -0,0 +1,12 @@
//@ known-bug: #106473
#![feature(generic_const_exprs)]
const DEFAULT: u32 = 1;
struct V<const U: usize = DEFAULT>
where
[(); U]:;
trait Tr {}
impl Tr for V {}

9
tests/crashes/108814.rs Normal file
View File

@ -0,0 +1,9 @@
//@ known-bug: #108814
#![feature(non_lifetime_binders)]
fn take(_: impl for<T> FnOnce(T) -> T) {}
fn main() {
take(|x| x)
}

9
tests/crashes/109681.rs Normal file
View File

@ -0,0 +1,9 @@
//@ known-bug: #109681
#![crate_type="lib"]
#![feature(linkage)]
#[linkage = "common"]
pub static TEST3: bool = true;
fn main() {}

15
tests/crashes/110378.rs Normal file
View File

@ -0,0 +1,15 @@
//@ known-bug: #110378
// ignore-tidy-linelength
#![feature(generic_const_exprs)]
fn foo<const L: usize>(_a: [u8; L], _b: [u8; L]) -> [u8; L + 1] {
[0_u8; L + 1]
}
fn main() {
let baz = [[0_u8; 1]; 8];
let _: [u8; 4] = foo(foo(foo(baz[0], baz[1]), foo(baz[2], baz[3])), foo(foo(baz[4], baz[5]), foo(baz[6], baz[7])));
//let _: [u8; 3] = foo(foo(baz[0], baz[1]), foo(baz[2], baz[3]));
}

44
tests/crashes/110534.rs Normal file
View File

@ -0,0 +1,44 @@
//@ known-bug: #110534
//@ edition:2021
use core::cell::Ref;
struct System;
trait IntoSystem {
fn into_system(self) -> System;
}
impl IntoSystem for fn(Ref<'_, u32>) {
fn into_system(self) -> System { System }
}
impl<A> IntoSystem for fn(A)
where
// n.b. No `Ref<'_, u32>` can satisfy this bound
A: 'static + for<'x> MaybeBorrowed<'x, Output = A>,
{
fn into_system(self) -> System { System }
}
//---------------------------------------------------
trait MaybeBorrowed<'a> {
type Output: 'a;
}
// If you comment this out you'll see the compiler chose to look at the
// fn(A) implementation of IntoSystem above
impl<'a, 'b> MaybeBorrowed<'a> for Ref<'b, u32> {
type Output = Ref<'a, u32>;
}
// ---------------------------------------------
fn main() {
fn sys_ref(_age: Ref<u32>) {}
let _sys_c = (sys_ref as fn(_)).into_system();
// properly fails
// let _sys_c = (sys_ref as fn(Ref<'static, u32>)).into_system();
// properly succeeds
// let _sys_c = (sys_ref as fn(Ref<'_, u32>)).into_system();
}

8
tests/crashes/110627.rs Normal file
View File

@ -0,0 +1,8 @@
//@ known-bug: #110627
#![feature(non_lifetime_binders)]
fn take(id: impl for<T> Fn(T) -> T) {}
fn main() {
take(|x| x)
}

28
tests/crashes/110630.rs Normal file
View File

@ -0,0 +1,28 @@
//@ known-bug: #110630
#![feature(generic_const_exprs)]
use std::ops::Mul;
pub trait Indices<const N: usize> {
const NUM_ELEMS: usize = I::NUM_ELEMS * N;
}
pub trait Concat<J> {
type Output;
}
pub struct Tensor<I: Indices<N>, const N: usize>
where
[u8; I::NUM_ELEMS]: Sized, {}
impl<I: Indices<N>, J: Indices<N>, const N: usize> Mul<Tensor<J, N>> for Tensor<I, N>
where
I: Concat<T>,
<I as Concat<J>>::Output: Indices<N>,
[u8; I::NUM_ELEMS]: Sized,
[u8; J::NUM_ELEMS]: Sized,
[u8; <I as Concat<J>>::Output::NUM_ELEMS]: Sized,
{
type Output = Tensor<<I as Concat<J>>::Output, N>;
}

14
tests/crashes/111419.rs Normal file
View File

@ -0,0 +1,14 @@
//@ known-bug: #111419
#![allow(incomplete_features)]
#![feature(generic_const_exprs, generic_arg_infer)]
pub trait Example<const X: usize, const Y: usize, const Z: usize = { X + Y }>
where
[(); X + Y]:,
{}
impl<const X: usize, const Y: usize> Example<X, Y> for Value {}
pub struct Value;
fn main() {}

14
tests/crashes/111699.rs Normal file
View File

@ -0,0 +1,14 @@
//@ known-bug: #111699
//@ edition:2021
//@ compile-flags: -Copt-level=0
#![feature(core_intrinsics)]
use std::intrinsics::offset;
fn main() {
let a = [1u8, 2, 3];
let ptr: *const u8 = a.as_ptr();
unsafe {
assert_eq!(*offset(ptr, 0), 1);
}
}

15
tests/crashes/111709-2.rs Normal file
View File

@ -0,0 +1,15 @@
//@ known-bug: #111709
//@ edition: 2021
use core::arch::asm;
extern "C" fn test<T>() {}
fn uwu() {
unsafe {
asm!(
"/* {0} */",
sym test::<&mut ()>
);
}
}

25
tests/crashes/111709.rs Normal file
View File

@ -0,0 +1,25 @@
//@ known-bug: #111709
//@ edition:2021
use core::arch::asm;
struct TrapFrame;
unsafe extern "C" fn _rust_abi_shim1<A, R>(arg: A, f: fn(A) -> R) -> R {
f(arg)
}
unsafe extern "C" fn _start_trap() {
extern "Rust" {
fn interrupt(tf: &mut TrapFrame);
}
asm!(
"
la a1, {irq}
call {shim}
",
shim = sym crate::_rust_abi_shim1::<&mut TrapFrame, ()>,
irq = sym interrupt,
options(noreturn)
)
}

12
tests/crashes/111742.rs Normal file
View File

@ -0,0 +1,12 @@
//@ known-bug: #111742
// ignore-tidy-linelength
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
const CONST: u32 = 0;
struct Test<const N: u32, const M: u32 = { CONST/* Must be a const and not a Literal */ }> where [(); N as usize]: , ([u32; N as usize]);
fn main() {
let _: Test<1>;
}

40
tests/crashes/111883.rs Normal file
View File

@ -0,0 +1,40 @@
//@ known-bug: #111883
#![crate_type = "lib"]
#![feature(arbitrary_self_types, no_core, lang_items)]
#![no_core]
#[lang = "sized"]
trait Sized {}
#[lang = "copy"]
trait Copy {}
#[lang = "receiver"]
trait Receiver {}
#[lang = "dispatch_from_dyn"]
trait DispatchFromDyn<T> {}
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {}
#[lang = "unsize"]
trait Unsize<T: ?Sized> {}
#[lang = "coerce_unsized"]
pub trait CoerceUnsized<T: ?Sized> {}
impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
#[lang = "drop_in_place"]
fn drop_in_place_fn<T>(a: &dyn Trait2<T>) {}
pub trait Trait1 {
fn foo(&self);
}
pub struct Type1;
impl Trait1 for Type1 {
fn foo(&self) {}
}
pub trait Trait2<T> {}
pub fn bar1() {
let a = Type1;
let b = &a as &dyn Trait1;
b.foo();
}

19
tests/crashes/112201.rs Normal file
View File

@ -0,0 +1,19 @@
//@ known-bug: #112201
pub fn compose(
f1: impl FnOnce(f64) -> f64 + Clone,
f2: impl FnOnce(f64) -> f64 + Clone,
) -> impl FnOnce(f64) -> f64 + Clone {
move |x| f1(f2(x))
}
fn repeat_helper(
f: impl FnOnce(f64) -> f64 + Clone,
res: impl FnOnce(f64) -> f64 + Clone,
times: usize,
) -> impl FnOnce(f64) -> f64 + Clone {
return res;
repeat_helper(f.clone(), compose(f, res), times - 1)
}
fn main() {}

16
tests/crashes/113272.rs Normal file
View File

@ -0,0 +1,16 @@
//@ known-bug: #113272
trait Trait {
type RefTarget;
}
impl Trait for () where Missing: Trait {}
struct Other {
data: <() as Trait>::RefTarget,
}
fn main() {
unsafe {
std::mem::transmute::<Option<()>, Option<&Other>>(None);
}
}

16
tests/crashes/113280.rs Normal file
View File

@ -0,0 +1,16 @@
//@ known-bug: #113280
//@ only-x86_64
#![feature(dyn_star, pointer_like_trait)]
#![allow(incomplete_features)]
use std::fmt::Debug;
use std::marker::PointerLike;
fn make_dyn_star<'a>(t: impl PointerLike + Debug + 'a) -> dyn* Debug + 'a {
f32::from_bits(0x1) as f64
}
fn main() {
println!("{:?}", make_dyn_star(Box::new(1i32)));
}

7
tests/crashes/113379.rs Normal file
View File

@ -0,0 +1,7 @@
//@ known-bug: #113379
async fn f999() -> Vec<usize> {
'b: {
continue 'b;
}
}

32
tests/crashes/113846.rs Normal file
View File

@ -0,0 +1,32 @@
//@ known-bug: #113846
trait Www {
type W;
}
trait Xxx: Www<W = Self::X> {
type X;
}
trait Yyy: Xxx {}
trait Zzz<'a>: Yyy + Xxx<X = Self::Z> {
type Z;
}
trait Aaa {
type Y: Yyy;
}
trait Bbb: Aaa<Y = Self::B> {
type B: for<'a> Zzz<'a>;
}
impl<T> Bbb for T
where
T: Aaa,
T::Y: for<'a> Zzz<'a>,
{
type B = T::Y;
}
pub fn main() {}

16
tests/crashes/114212-2.rs Normal file
View File

@ -0,0 +1,16 @@
//@ known-bug: #114212
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
const SOME_CONST: usize = 1;
struct UwU<
// have a const generic with a default that's from another const item
// (associated consts work, a const declared in a block here, inline_const, etc)
const N: usize = SOME_CONST,
// use the previous const in a type generic
A = [(); N],
> {
// here to suppress "unused generic" error if the code stops ICEing
_x: core::marker::PhantomData<A>,
}

34
tests/crashes/114212.rs Normal file
View File

@ -0,0 +1,34 @@
//@ known-bug: #114212
#![feature(generic_const_exprs)]
use core::marker::PhantomData;
pub const DEFAULT_MAX_INPUT_LEN: usize = 256;
pub trait FooTrait {}
pub struct Foo<const MAX_INPUT_LEN: usize>;
impl<const MAX_INPUT_LEN: usize> FooTrait for Foo<MAX_INPUT_LEN> {}
pub struct Bar<
const MAX_INPUT_LEN: usize = DEFAULT_MAX_INPUT_LEN,
PB = Foo<MAX_INPUT_LEN>,
>
where
PB: FooTrait,
{
_pb: PhantomData<PB>,
}
impl<const MAX_INPUT_LEN: usize, PB> Bar<MAX_INPUT_LEN, PB>
where
PB: FooTrait,
{
pub fn new() -> Self {
Self {
_pb: PhantomData,
}
}
}

6
tests/crashes/114317.rs Normal file
View File

@ -0,0 +1,6 @@
//@ known-bug: #114317
#![feature(generic_const_exprs)]
struct A<const B: str = 1, C>;
fn main() {}

20
tests/crashes/114456-2.rs Normal file
View File

@ -0,0 +1,20 @@
//@ known-bug: #114456
#![feature(adt_const_params)]
const EMPTY_MATRIX: <Type as Trait>::Matrix = [0; 1];
pub struct Walk<const REMAINING: <Type as Trait>::Matrix> {}
impl Walk<EMPTY_MATRIX> {
pub const fn new() -> Self {
Self {}
}
}
pub enum Type {}
pub trait Trait { type Matrix; }
impl Trait for Type { type Matrix = [usize; 1]; }
fn main() {
let _ = Walk::new();
}

17
tests/crashes/114456.rs Normal file
View File

@ -0,0 +1,17 @@
//@ known-bug: #114456
#![feature(adt_const_params, lazy_type_alias)]
pub type Matrix = [usize; 1];
const EMPTY_MATRIX: Matrix = [0; 1];
pub struct Walk<const REMAINING: Matrix> {}
impl Walk<EMPTY_MATRIX> {
pub const fn new() -> Self {
Self {}
}
}
fn main() {
let _ = Walk::new();
}

67
tests/crashes/114484.rs Normal file
View File

@ -0,0 +1,67 @@
//@ known-bug: #114484
use std::marker::PhantomData;
trait MyTrait {
fn virtualize(&self) -> &dyn MyTrait;
}
struct VirtualWrapper<T, const L: u8>(T);
impl<T, const L: u8> VirtualWrapper<T, L> {
pub fn wrap(value: &T) -> &Self {
unsafe { &*(value as *const T as *const Self) }
}
}
impl<T: MyTrait + 'static, const L: u8> MyTrait for VirtualWrapper<T, L> {
fn virtualize(&self) -> &dyn MyTrait {
unsafe { virtualize_my_trait(L, self) }
// unsafe { virtualize_my_trait(L, &self.0) } // <-- this code fixes the problem
}
}
const unsafe fn virtualize_my_trait<T>(level: u8, obj: &T) -> &dyn MyTrait
where
T: MyTrait + 'static,
{
const fn gen_vtable_ptr<T, const L: u8>() -> *const ()
where
T: MyTrait + 'static,
{
let [_, vtable] = unsafe {
std::mem::transmute::<*const dyn MyTrait, [*const (); 2]>(std::ptr::null::<
VirtualWrapper<T, L>,
>())
};
vtable
}
struct Vtable<T>(PhantomData<T>);
impl<T> Vtable<T>
where
T: MyTrait + 'static,
{
const LEVELS: [*const (); 2] = [gen_vtable_ptr::<T, 1>(), gen_vtable_ptr::<T, 2>()];
}
let vtable = Vtable::<T>::LEVELS[(level != 0) as usize];
let data = obj as *const T as *const ();
let ptr: *const dyn MyTrait = std::mem::transmute([data, vtable]);
&*ptr
}
struct SomeData<const N: usize>([u8; N]);
impl<const N: usize> MyTrait for SomeData<N> {
fn virtualize(&self) -> &dyn MyTrait {
VirtualWrapper::<Self, 0>::wrap(self)
}
}
fn main() {
let test = SomeData([0; 256]);
test.virtualize();
}

17
tests/crashes/114663.rs Normal file
View File

@ -0,0 +1,17 @@
//@ known-bug: #114663
//@ edition:2021
#![feature(generic_const_exprs)]
use core::fmt::Debug;
struct Inline<T>
where
[u8; ::core::mem::size_of::<T>() + 1]:,
{
_phantom: PhantomData<T>,
}
fn main() {
let dst = Inline::<dyn Debug>::new(0); // BANG!
}

25
tests/crashes/115435.rs Normal file
View File

@ -0,0 +1,25 @@
//@ known-bug: #115435
//@ edition:2021
//@ compile-flags: -Copt-level=0
trait MyTrait {
type Target: ?Sized;
}
impl<A: ?Sized> MyTrait for A {
type Target = A;
}
fn main() {
bug_run::<dyn MyTrait<Target = u8>>();
}
fn bug_run<T: ?Sized>()
where
<T as MyTrait>::Target: Sized,
{
bug::<T>();
}
fn bug<T>() {
std::mem::size_of::<T>();
}

27
tests/crashes/115808.rs Normal file
View File

@ -0,0 +1,27 @@
//@ known-bug: #115808
#![feature(generic_const_exprs)]
use std::ops::Mul;
pub trait Indices<const N: usize> {
const NUM_ELEMS: usize;
}
pub trait Concat<J> {
type Output;
}
pub struct Tensor<I: Indices<N>, const N: usize>
where
[u8; I::NUM_ELEMS]: Sized, {}
impl<I: Indices<N>, J: Indices<N>, const N: usize> Mul<Tensor<J, N>> for Tensor<I, N>
where
I: Concat<FN>,
<I as Concat<J>>::Output: Indices<N>,
[u8; I::NUM_ELEMS]: Sized,
[u8; J::NUM_ELEMS]: Sized,
[u8; <I as Concat<J>>::Output::NUM_ELEMS]: Sized,
{
type Output = Tensor<<I as Concat<J>>::Output, N>;
}

16
tests/crashes/116308.rs Normal file
View File

@ -0,0 +1,16 @@
//@ known-bug: #116308
#![feature(adt_const_params)]
pub trait Identity {
type Identity;
}
impl<T> Identity for T {
type Identity = Self;
}
pub fn foo<const X: <i32 as Identity>::Identity>() {}
fn main() {
foo::<12>();
}

15
tests/crashes/116519-2.rs Normal file
View File

@ -0,0 +1,15 @@
//@ known-bug: #116519
#![feature(generic_const_exprs)]
trait Ret {
type R;
}
struct Cond<const PRED: bool, U, V>(std::marker::PhantomData<U>, );
struct RobinHashTable<
const MAX_LENGTH: usize,
CellIdx = <Cond<{ }, u16, u32> as Ret>::R,
> {}
impl<CellIdx> HashMapBase<CellIdx> for RobinHashTable<MAX_LENGTH, CellIdx> {}

57
tests/crashes/116519.rs Normal file
View File

@ -0,0 +1,57 @@
//@ known-bug: #116519
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
trait Ret {
type R;
}
struct Cond<const PRED: bool, U, V>(std::marker::PhantomData<U>, std::marker::PhantomData<V>);
impl<U, V> Ret for Cond<true, U, V> {
type R = U;
}
impl<U, V> Ret for Cond<false, U, V> {
type R = V;
}
struct RobinHashTable<
const MAX_LENGTH: usize,
CellIdx = <Cond<{ MAX_LENGTH < 65535 }, u16, u32> as Ret>::R,
> {
_idx: CellIdx,
}
impl<CellIdx> RobinHashTable<MAX_LENGTH, CellIdx> {
fn new() -> Self {
Self {
_idx: CellIdx { MAX_LENGTH },
}
}
}
impl<CellIdx> HashMapBase<CellIdx> {
fn new() -> Self {
Self {
_idx: CellIdx { 0 },
}
}
}
impl<CellIdx> HashMapBase<CellIdx> for RobinHashTable<MAX_LENGTH, CellIdx> {
fn hash<H: Hash + Hasher>(&self,
) -> H {
self._idx.hash()
}
fn eq(&self, other: &Self) -> bool {
self._idx.eq(other._idx)
}
}
impl<CellIdx> HashMapBase<CellIdx> for RobinHashTable<MAX_LENGTH, CellIdx> {
fn hash<H: Hash + Hasher>(&self, other: &Self) -> H {
self._idx.hash(other._idx)
}
fn eq(&self, other: &Self) -> bool {
self._idx.eq(other._idx)
}
}
#[test]
fn test_size_of_robin_hash_table() {
use std::mem::size_of;
println!("{}", size_of::<RobinHashTable<1024>>());
println!("{}", size_of::<RobinHashTable<65536>>());
}

31
tests/crashes/116554.rs Normal file
View File

@ -0,0 +1,31 @@
//@ known-bug: #116554
#![feature(generic_const_exprs)]
const fn t<const N: usize>() -> u8 {
N as u8
}
#[repr(u8)]
enum T<const N: u8 = { T::<0>::A as u8 + T::<0>::B as u8 }>
where
[(); N as usize]:,
T: ?Sized,
{
A,
}
fn main() {
A = t::<N>() as u8,
B,
}

16
tests/crashes/116947.rs Normal file
View File

@ -0,0 +1,16 @@
//@ known-bug: #116947
#![feature(min_specialization)]
trait MySpecTrait {
fn f();
}
impl<'a, T: ?Sized> MySpecTrait for T {
default fn f() {}
}
impl<'a, T: ?Sized> MySpecTrait for &'a T {
fn f() {}
}
fn main() {}

27
tests/crashes/117392-2.rs Normal file
View File

@ -0,0 +1,27 @@
//@ known-bug: #117392
pub trait BorrowComposite {
type Ref<'a>: 'a;
}
impl BorrowComposite for () {
type Ref<'a> = ();
}
pub trait Component<Args> {
type Output;
}
impl<Args> Component<Args> for () {
type Output = ();
}
pub fn delay<Args: BorrowComposite, Make: for<'a> FnMut(Args::Ref<'a>) -> C, C: Component<Args>>(
make: Make,
) -> impl Component<Args> {
}
pub fn crash() -> impl Component<()> {
delay(|()| delay(|()| ()))
}
pub fn main() {}

47
tests/crashes/117392.rs Normal file
View File

@ -0,0 +1,47 @@
//@ known-bug: #117392
pub trait BorrowComposite {
type Ref<'a>
where
Self: 'a;
}
impl BorrowComposite for () {
type Ref<'a> = ();
}
pub trait Component<Args: BorrowComposite> {
type Output;
}
impl<Args: BorrowComposite> Component<Args> for () {
type Output = ();
}
struct Delay<Make> {
_make: Make,
}
impl<
Args: BorrowComposite,
Make: for<'a> FnMut(Args::Ref<'a>) -> C,
C: Component<Args>,
> Component<Args> for Delay<Make>
{
type Output = C::Output;
}
pub fn delay<
Args: BorrowComposite,
Make: for<'a> FnMut(Args::Ref<'a>) -> C,
C: Component<Args>,
>(
make: Make,
) -> impl Component<Args, Output = C::Output> {
Delay { _make: make }
}
pub fn crash() -> impl Component<(), Output = ()> {
delay(|()| delay(|()| ()))
}
pub fn main() {}

22
tests/crashes/117496.rs Normal file
View File

@ -0,0 +1,22 @@
//@ known-bug: #117496
#![feature(adt_const_params)]
#![feature(generic_const_exprs)]
use core::marker::ConstParamTy;
#[derive(PartialEq, Copy, Clone, Eq, ConstParamTy)]
pub enum Foo {}
impl Foo {
pub const fn size(self) -> usize {
1
}
}
pub struct Bar<const F: Foo, const SIZE: usize = { F.size() }>([u64; SIZE])
where
[u64; SIZE]: Sized;
pub struct Quux<const F: Foo> {}
impl<const F: Foo> Quux<{ F }> {
pub unsafe fn nothing(&self, bar: &mut Bar<{ F }>) {}
}

11
tests/crashes/117629.rs Normal file
View File

@ -0,0 +1,11 @@
//@ known-bug: #117629
//@ edition:2021
#![feature(const_trait_impl)]
#[const_trait]
trait Tr {
async fn ft1() {}
}
fn main() {}

29
tests/crashes/117696-1.rs Normal file
View File

@ -0,0 +1,29 @@
//@ known-bug: #117696
fn main() {
let mut it = (Empty);
rec(&mut it);
}
struct Empty;
impl Iterator for Empty {
type Item = ();
fn next<'a>(&'a mut self) -> core::option::Option<()> {
None
}
}
fn identity<T>(x: T) -> T {
x
}
fn rec<T>(mut it: T)
where
T: Iterator,
{
if () == () {
T::count(it);
} else {
rec(identity(&mut it))
}
}

13
tests/crashes/117696-2.rs Normal file
View File

@ -0,0 +1,13 @@
//@ known-bug: #117696
//@ compile-flags: -Copt-level=0
fn main() {
rec(&mut None::<()>.into_iter());
}
fn rec<T: Iterator>(mut it: T) {
if true {
it.next();
} else {
rec(&mut it);
}
}

8
tests/crashes/117795.rs Normal file
View File

@ -0,0 +1,8 @@
//@ known-bug: #117795
const fn f() -> usize {
5
}
fn main() {
let _ = [0; FnMut::call_mut(&mut f, ())];
}

14
tests/crashes/117829-2.rs Normal file
View File

@ -0,0 +1,14 @@
//@ known-bug: #117829
#![feature(auto_traits)]
trait B {}
auto trait Z<T>
where
T: Z<u16>,
<T as Z<u16>>::W: B,
{
type W;
}
fn main() {}

9
tests/crashes/117829.rs Normal file
View File

@ -0,0 +1,9 @@
//@ known-bug: #117829
auto trait Z<'a, T: ?Sized>
where
T: Z<'a, u16>,
for<'b> <T as Z<'b, u16>>::W: Clone,
{
type W: ?Sized;
}

7
tests/crashes/117942.rs Normal file
View File

@ -0,0 +1,7 @@
//@ known-bug: #117942
struct Foo {
_: union {
#[rustfmt::skip]
f: String
},
}

12
tests/crashes/118038.rs Normal file
View File

@ -0,0 +1,12 @@
//@ known-bug: #118038
#![feature(non_lifetime_binders)]
fn trivial<A>()
where
for<B> dyn Fn(A, *const A): Fn(A, *const B),
{
}
fn main() {
trivial::<u8>();
}

14
tests/crashes/118320.rs Normal file
View File

@ -0,0 +1,14 @@
//@ known-bug: #118320
//@ edition:2021
#![feature(const_trait_impl, effects, const_closures)]
#[const_trait]
trait Bar {
fn foo(&self);
}
impl Bar for () {}
const FOO: () = {
(const || (()).foo())();
};

8
tests/crashes/118403.rs Normal file
View File

@ -0,0 +1,8 @@
//@ known-bug: #118403
#![feature(generic_const_exprs)]
pub struct X<const N: usize> {}
impl<const Z: usize> X<Z> {
pub fn y<'a, U: 'a>(&'a self) -> impl Iterator<Item = impl Iterator<Item = [u8; Z]> + '_> {
(0..1).map(move |_| (0..1).map(move |_| loop {}))
}
}

44
tests/crashes/118603.rs Normal file
View File

@ -0,0 +1,44 @@
//@ known-bug: #118603
//@ compile-flags: -Copt-level=0
// ignore-tidy-linelength
#![feature(generic_const_exprs)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
struct FlatTree;
#[derive(Copy, Clone)]
struct TreeLeaf;
#[derive(Copy, Clone)]
struct TreeNode<V, W>(V, W);
const fn const_concat<const A: usize, const B: usize>(_: [FlatTree; A], _: [FlatTree; B]) -> [FlatTree; A + B] {
[FlatTree; A + B]
}
struct Builder<const N: usize, I> {
ops: [FlatTree; N],
builder: I,
}
fn create_node<const N: usize, const M: usize, A, B>(a: Builder<N, A>, b: Builder<M, B>) -> Builder<{ N + M + 1 }, TreeNode<A, B>> {
Builder {
ops: const_concat(const_concat::<N, M>(a.ops, b.ops), [FlatTree]),
builder: TreeNode(a.builder, b.builder),
}
}
const LEAF: Builder<1, TreeLeaf> = Builder {
ops: [FlatTree],
builder: TreeLeaf,
};
static INTERNAL_SIMPLE_BOOLEAN_TEMPLATES: &[fn()] = &[{
fn eval() {
create_node(LEAF, create_node(LEAF, LEAF));
}
eval
}];
pub fn main() {}

10
tests/crashes/118952-2.rs Normal file
View File

@ -0,0 +1,10 @@
//@ known-bug: #118952
#![feature(generic_const_exprs)]
pub struct TinyVec<T, const N: usize = { () }>
where
[(); () - std::mem::size_of() - std::mem::size_of::<isize>()]:, {}
pub fn main() {
let t = TinyVec::<u8>::new();
}

25
tests/crashes/118952.rs Normal file
View File

@ -0,0 +1,25 @@
//@ known-bug: #118952
#![allow(non_camel_case_types)]
#![feature(generic_const_exprs)]
#![feature(specialization)]
const DEFAULT_SMALL_VEC_INLINE_CAPACITY: usize = std::mem::size_of::<usize>() * 8;
pub const fn tiny_vec_cap<T>() -> usize {
return (DEFAULT_SMALL_VEC_INLINE_CAPACITY - 1) / std::mem::size_of::<T>()
}
pub struct TinyVec<T, const N: usize = {tiny_vec_cap::<T>()}>
where [
();
(N * std::mem::size_of::<T>())
- std::mem::size_of::<std::ptr::NonNull<T>>()
- std::mem::size_of::<isize>()
]: ,
{
data: isize //TinyVecData<T, N>,
}
pub fn main() {
let t = TinyVec::<u8>::new();
}

17
tests/crashes/118987-2.rs Normal file
View File

@ -0,0 +1,17 @@
//@ known-bug: #118987
#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
trait Assoc {
type Output;
}
default impl<T: Clone> Assoc for T {
type Output = bool;
}
impl Assoc for u8 {}
trait Foo {}
impl Foo for <u8 as Assoc>::Output {}
impl Foo for <u16 as Assoc>::Output {}

17
tests/crashes/118987.rs Normal file
View File

@ -0,0 +1,17 @@
//@ known-bug: #118987
#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
trait Assoc {
type Output;
}
default impl<T: Clone> Assoc for T {
type Output = bool;
}
impl Assoc for u8 {}
trait Foo {}
impl Foo for <u8 as Assoc>::Output {}
impl Foo for <u16 as Assoc>::Output {}

27
tests/crashes/119272.rs Normal file
View File

@ -0,0 +1,27 @@
//@ known-bug: #119272
#![feature(type_alias_impl_trait)]
mod defining_scope {
use super::*;
pub type Alias<T> = impl Sized;
pub fn cast<T>(x: Container<Alias<T>, T>) -> Container<T, T> {
x
}
}
struct Container<T: Trait<U>, U> {
x: <T as Trait<U>>::Assoc,
}
trait Trait<T> {
type Assoc;
}
impl<T> Trait<T> for T {
type Assoc = Box<u32>;
}
impl<T> Trait<T> for defining_scope::Alias<T> {
type Assoc = usize;
}
fn main() {}

25
tests/crashes/119299.rs Normal file
View File

@ -0,0 +1,25 @@
//@ known-bug: #119299
#![feature(adt_const_params)]
#![allow(incomplete_features)]
use std::marker::ConstParamTy;
#[derive(Eq, PartialEq)]
struct ConstStrU(*const u8, usize);
impl ConstParamTy for &'static ConstStrU {}
impl ConstStrU {
const fn from_bytes(bytes: &'static [u8]) -> Self {
Self(bytes.as_ptr(), bytes.len())
}
}
const fn chars_s<const S: &'static ConstStrU>() -> [char; 3] {
['a','b','c']
}
fn main() {
const A: &'static ConstStrU = &ConstStrU::from_bytes(b"abc");
chars_s::<A>();
}

48
tests/crashes/119692.rs Normal file
View File

@ -0,0 +1,48 @@
//@ known-bug: #119692
//@ compile-flags: -Copt-level=0
#![allow(incomplete_features)]
#![feature(adt_const_params)]
#![feature(generic_const_exprs)]
use std::ops::Add;
#[derive(PartialEq, Eq, Clone, Debug, core::marker::ConstParamTy)]
pub struct Dimension;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Default)]
pub struct Quantity<S, const D: Dimension>(pub(crate) S);
impl<const D: Dimension, LHS, RHS> Add<Quantity<RHS, D>> for Quantity<LHS, D>
where
LHS: Add<RHS>,
{
type Output = Quantity<<LHS as Add<RHS>>::Output, D>;
fn add(self, rhs: Quantity<RHS, D>) -> Self::Output {
Quantity(self.0 + rhs.0)
}
}
impl<LHS, RHS> Add<RHS> for Quantity<LHS, { Dimension }>
where
LHS: Add<RHS>,
{
type Output = Quantity<<LHS as Add<RHS>>::Output, { Dimension }>;
fn add(self, rhs: RHS) -> Self::Output {
Quantity(self.0 + rhs)
}
}
impl Add<Quantity<f32, { Dimension }>> for f32 {
type Output = Quantity<f32, { Dimension }>;
fn add(self, rhs: Quantity<f32, { Dimension }>) -> Self::Output {
Quantity(self + rhs.0)
}
}
pub fn add<const U: Dimension>(x: Quantity<f32, U>, y: Quantity<f32, U>) -> Quantity<f32, U> {
x + y
}
fn main() {
add(Quantity::<f32, {Dimension}>(1.0), Quantity(2.0));
}

18
tests/crashes/119694.rs Normal file
View File

@ -0,0 +1,18 @@
//@ known-bug: #119694
#![feature(dyn_star)]
trait Trait {
fn foo(self);
}
impl Trait for usize {
fn foo(self) {}
}
fn bar(x: dyn* Trait) {
x.foo();
}
fn main() {
bar(0usize);
}

21
tests/crashes/119701.rs Normal file
View File

@ -0,0 +1,21 @@
//@ known-bug: #119701
#![feature(const_trait_impl, effects, generic_const_exprs)]
fn main() {
let _ = process::<()>([()]);
}
fn process<T: const Trait>() -> [(); T::make(2)] {
input
}
#[const_trait]
trait Trait {
fn make(input: u8) -> usize;
}
impl const Trait for () {
fn make(input: usize) -> usize {
input / 2
}
}

View File

@ -0,0 +1,4 @@
//@ known-bug: #119716
#![feature(non_lifetime_binders)]
trait Trait<T> {}
fn f<T>() -> impl for<T> Trait<impl Trait<T>> {}

4
tests/crashes/119716.rs Normal file
View File

@ -0,0 +1,4 @@
//@ known-bug: #119716
#![feature(non_lifetime_binders)]
trait v0<v1> {}
fn kind :(v3main impl for<v4> v0<'_, v2 = impl v0<v4> + '_>) {}

10
tests/crashes/119717.rs Normal file
View File

@ -0,0 +1,10 @@
//@ known-bug: #119717
#![feature(const_trait_impl, effects)]
use std::ops::{FromResidual, Try};
impl const FromResidual for T {
fn from_residual(t: T) -> _ {
t
}
}

12
tests/crashes/119729.rs Normal file
View File

@ -0,0 +1,12 @@
//@ known-bug: #119729
#![feature(generic_const_exprs)]
trait Size<const N: usize> {}
impl<T: Sized> Size<{ std::mem::size_of::<T>() }> for T {}
struct A<T: Size<8> + ?Sized> {
x: std::marker::PhantomData<T>,
}
fn foo(x: A<dyn Send>) {}

8
tests/crashes/119783.rs Normal file
View File

@ -0,0 +1,8 @@
//@ known-bug: #119783
#![feature(associated_const_equality)]
trait Trait { const F: fn(); }
fn take(_: impl Trait<F = { || {} }>) {}
fn main() {}

15
tests/crashes/119786.rs Normal file
View File

@ -0,0 +1,15 @@
//@ known-bug: #119786
//@ edition:2021
fn enum_upvar() {
type T = impl Copy;
let foo: T = Some((1u32, 2u32));
let x = move || {
match foo {
None => (),
Some(yield) => (),
}
};
}
pub fn main() {}

14
tests/crashes/119824.rs Normal file
View File

@ -0,0 +1,14 @@
//@ known-bug: #119824
#![feature(generic_const_exprs)]
const fn t<const N: usize>() -> u8 {
N as u8
}
#[repr(u8)]
enum T<const N: u8 = { T::<0>::A as u8 + T::<0>::B as u8 }>
where
[(); N as usize]:
{
A = t::<N>() as u8, B
}

11
tests/crashes/119830.rs Normal file
View File

@ -0,0 +1,11 @@
//@ known-bug: #119830
#![feature(effects)]
#![feature(min_specialization)]
trait Specialize {}
trait Foo {}
impl<T> const Foo for T {}
impl<T> const Foo for T where T: const Specialize {}

14
tests/crashes/119924-6.rs Normal file
View File

@ -0,0 +1,14 @@
//@ known-bug: #119924
#![feature(const_trait_impl, effects)]
struct S;
#[const_trait]
trait Trait<const N: u32> {}
const fn f<T: Trait<{
struct I<U: ~const Trait<0>>(U); // should've gotten rejected during AST validation
//~^ ICE no host param id for call in const yet no errors reported
0
}>>() {}
pub fn main() {}

10
tests/crashes/120241-2.rs Normal file
View File

@ -0,0 +1,10 @@
//@ known-bug: #120241
//@ edition:2021
#![feature(object_safe_for_dispatch)]
#![feature(unsized_fn_params)]
fn guard(_s: Copy) -> bool {
panic!()
}
fn main() {}

13
tests/crashes/120241.rs Normal file
View File

@ -0,0 +1,13 @@
//@ known-bug: #120241
//@ edition:2021
#![feature(object_safe_for_dispatch)]
trait B {
fn f(a: A) -> A;
}
trait A {
fn g(b: B) -> B;
}
fn main() {}

13
tests/crashes/120482.rs Normal file
View File

@ -0,0 +1,13 @@
//@ known-bug: #120482
//@ edition:2021
#![feature(object_safe_for_dispatch)]
trait B {
fn bar(&self, x: &Self);
}
trait A {
fn g(new: B) -> B;
}
fn main() {}

10
tests/crashes/120503.rs Normal file
View File

@ -0,0 +1,10 @@
//@ known-bug: #120503
#![feature(effects)]
trait MyTrait {}
impl MyTrait for i32 {
async const fn bar(&self) {
main8().await;
}
}

13
tests/crashes/120600-2.rs Normal file
View File

@ -0,0 +1,13 @@
//@ known-bug: #120600
#![feature(never_type, never_type_fallback)]
enum E { Bar(!) }
fn f(a: &E, b: &E) {
match (a, b) {
(E::Bar(a), E::Bar(b)) => { *a == *b; }
_ => {}
}
}
pub fn main() {}

11
tests/crashes/120600.rs Normal file
View File

@ -0,0 +1,11 @@
//@ known-bug: #120600
#![feature(never_type)]
#![feature(never_type_fallback)]
#[derive(Ord, Eq, PartialOrd, PartialEq)]
enum E {
Foo,
Bar(!, i32, i32),
}
fn main() {}

22
tests/crashes/120793-2.rs Normal file
View File

@ -0,0 +1,22 @@
//@ known-bug: #120793
// can't use build-fail, because this also fails check-fail, but
// the ICE from #120787 only reproduces on build-fail.
//@ compile-flags: --emit=mir
#![feature(effects)]
trait Dim {
fn dim() -> usize;
}
enum Dim3 {}
impl Dim for Dim3 {
fn dim(x: impl Sized) -> usize {
3
}
}
fn main() {
[0; Dim3::dim()];
}

21
tests/crashes/120793.rs Normal file
View File

@ -0,0 +1,21 @@
//@ known-bug: #120793
#![feature(effects)]
trait Dim {
fn dim() -> usize;
}
enum Dim3 {}
impl Dim for Dim3 {
fn dim(mut x: impl Iterator<Item = &'_ ()>) -> usize {
3
}
}
fn main() {
let array: [usize; Dim3::dim()]
//~^ ERROR E0015
= [0; Dim3::dim()];
//~^ ERROR E0015
}

8
tests/crashes/120873.rs Normal file
View File

@ -0,0 +1,8 @@
//@ known-bug: #120873
#[repr(packed)]
struct Dealigned<T>(u8, T);
#[derive(PartialEq)]
#[repr(C)]
struct Dealigned<T>(u8, T);

26
tests/crashes/120911.rs Normal file
View File

@ -0,0 +1,26 @@
//@ known-bug: #120911
trait Container {
type Item<'a>;
}
impl Container for () {
type Item<'a> = ();
}
struct Exchange<C, F> {
_marker: std::marker::PhantomData<(C, F)>,
}
fn exchange<C, F>(_: F) -> Exchange<C, F>
where
C: Container,
for<'a> F: FnMut(&C::Item<'a>),
{
unimplemented!()
}
trait Parallelization<C> {}
impl<C, F> Parallelization<C> for Exchange<C, F> {}
fn unary_frontier<P: Parallelization<()>>(_: P) {}
fn main() {
let exchange = exchange(|_| ());
let _ = || {
unary_frontier(exchange);
};
}

32
tests/crashes/121052.rs Normal file
View File

@ -0,0 +1,32 @@
//@ known-bug: #121052
#![feature(generic_const_exprs, with_negative_coherence)]
use std::ops::Mul;
pub trait Indices<const N: usize> {
const NUM_ELEMS: usize;
}
impl<I: Indices<N>, J: Indices<N>, const N: usize> Mul for Tensor<I, N>
where
I: Concat<J>,
<I as Concat<J>>::Output: Indices<N>,
[u8; I::NUM_ELEMS]: Sized,
[u8; J::NUM_ELEMS]: Sized,
[u8; <I as Concat<J>>::Output::NUM_ELEMS]: Sized,
{
}
pub trait Concat<J> {}
pub struct Tensor<I: Indices<N>, const N: usize> {}
impl<I: Indices<N>, J: Indices<N>, const N: usize> Mul for Tensor<I, N>
where
I: Concat<J>,
<I as Concat<J>>::Output: Indices<N>,
[u8; I::NUM_ELEMS]: Sized,
[u8; J::NUM_ELEMS]: Sized,
[u8; <I as Concat<J>>::Output::NUM_ELEMS]: Sized,
{
}

10
tests/crashes/121097.rs Normal file
View File

@ -0,0 +1,10 @@
//@ known-bug: #121097
#[repr(simd)]
enum Aligned {
Zero = 0,
One = 1,
}
fn tou8(al: Aligned) -> u8 {
al as u8
}

4
tests/crashes/121126.rs Normal file
View File

@ -0,0 +1,4 @@
//@ known-bug: #121126
fn main() {
let _n = 1i64 >> [64][4_294_967_295];
}

20
tests/crashes/121134.rs Normal file
View File

@ -0,0 +1,20 @@
//@ known-bug: #121134
trait Output<'a> {
type Type;
}
struct Wrapper;
impl Wrapper {
fn do_something_wrapper<O, F>(&mut self, do_something_wrapper: F)
where
FnOnce:,
F: for<'a> FnOnce(<F as Output<i32, _>>::Type),
{
}
}
fn main() {
let mut wrapper = Wrapper;
wrapper.do_something_wrapper::<i32, _>(|value| ());
}

12
tests/crashes/121161.rs Normal file
View File

@ -0,0 +1,12 @@
//@ known-bug: #121161
#![allow(incomplete_features)]
#![feature(unnamed_fields)]
#[derive(Eq)]
#[repr(C)]
struct Bar {
_: union {
a: u8,
},
}

Some files were not shown because too many files have changed in this diff Show More