From 65ca71815a0cc57a7b58a01eb9cfbc0551ccdd3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 24 Mar 2024 11:47:43 +0100 Subject: [PATCH 01/13] add initial ice as test --- tests/crashes/span_delayed_bug.rs | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/crashes/span_delayed_bug.rs diff --git a/tests/crashes/span_delayed_bug.rs b/tests/crashes/span_delayed_bug.rs new file mode 100644 index 0000000000000..e410f73041565 --- /dev/null +++ b/tests/crashes/span_delayed_bug.rs @@ -0,0 +1,4 @@ +#![feature(rustc_attrs)] + +#[rustc_error(delayed_bug_from_inside_query)] +fn main() {} From 7b05360a1e5aee00c99d9f8a2958984f7de0acdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 24 Mar 2024 12:57:54 +0100 Subject: [PATCH 02/13] bootstrap/compiletest: implement "crashes" tests that fail if no ice is reproduced --- src/bootstrap/src/core/build_steps/test.rs | 2 ++ src/bootstrap/src/core/builder.rs | 1 + src/tools/compiletest/src/common.rs | 1 + src/tools/compiletest/src/header.rs | 1 + src/tools/compiletest/src/lib.rs | 16 +++++++++++++--- src/tools/compiletest/src/runtest.rs | 19 ++++++++++++++++--- src/tools/opt-dist/src/tests.rs | 1 + tests/crashes/no-ice.rs | 1 + 8 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 tests/crashes/no-ice.rs diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 09763e6bf0134..eb6345ecdcc10 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -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", diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index e3b27600c5e07..224f5350e40a7 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -745,6 +745,7 @@ impl<'a> Builder<'a> { test::ExpandYamlAnchors, test::Tidy, test::Ui, + test::Crashes, test::RunPassValgrind, test::Coverage, test::CoverageMap, diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 78246136f2a1b..aa69791b3b4b4 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -69,6 +69,7 @@ string_enum! { Assembly => "assembly", CoverageMap => "coverage-map", CoverageRun => "coverage-run", + Crashes => "crashes", } } diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index e6f4accfd7b98..b6ef20ed268a9 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -625,6 +625,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, "should-ice") => (), (Mode::Codegen, "build-pass") => (), (Mode::Incremental, _) => { if revision.is_some() && !self.revisions.iter().all(|r| r.starts_with("cfail")) { diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index 1624e2a60843a..c8a8b79921e21 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -65,7 +65,8 @@ pub fn parse_config(args: Vec) -> 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) -> 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) -> 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"); diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 5212f1430d831..e542cd4914731 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -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,17 @@ 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 a test does not crash, consider it an error + match proc_res.status.code() { + Some(101) => (), + _ => self.fatal("expected ICE"), + } + } + fn run_rfail_test(&self) { let pm = self.pass_mode(); let should_run = self.run_if_enabled(); @@ -2517,7 +2530,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 } } diff --git a/src/tools/opt-dist/src/tests.rs b/src/tools/opt-dist/src/tests.rs index 8a8f98a5eda17..b5dfd2fc5afec 100644 --- a/src/tools/opt-dist/src/tests.rs +++ b/src/tools/opt-dist/src/tests.rs @@ -96,6 +96,7 @@ llvm-config = "{llvm_config}" "tests/pretty", "tests/run-pass-valgrind", "tests/ui", + "tests/crases", ]; for test_path in env.skipped_tests() { args.extend(["--skip", test_path]); diff --git a/tests/crashes/no-ice.rs b/tests/crashes/no-ice.rs new file mode 100644 index 0000000000000..da0f5d925d107 --- /dev/null +++ b/tests/crashes/no-ice.rs @@ -0,0 +1 @@ +pub fn main() {} From d6e70df1a2b1b335a52d509287534e6e94ceb9e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 24 Mar 2024 13:07:30 +0100 Subject: [PATCH 03/13] crashes: add another test showing that everything works fine when we need compile-flags to repro an ice and add README --- src/tools/opt-dist/src/tests.rs | 2 +- tests/crashes/122909.rs | 15 +++++++++++++++ tests/crashes/README.md | 13 +++++++++++++ tests/crashes/no-ice.rs | 1 - 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 tests/crashes/122909.rs create mode 100644 tests/crashes/README.md delete mode 100644 tests/crashes/no-ice.rs diff --git a/src/tools/opt-dist/src/tests.rs b/src/tools/opt-dist/src/tests.rs index b5dfd2fc5afec..46b0a54380255 100644 --- a/src/tools/opt-dist/src/tests.rs +++ b/src/tools/opt-dist/src/tests.rs @@ -96,7 +96,7 @@ llvm-config = "{llvm_config}" "tests/pretty", "tests/run-pass-valgrind", "tests/ui", - "tests/crases", + "tests/crashes", ]; for test_path in env.skipped_tests() { args.extend(["--skip", test_path]); diff --git a/tests/crashes/122909.rs b/tests/crashes/122909.rs new file mode 100644 index 0000000000000..344fcd8801096 --- /dev/null +++ b/tests/crashes/122909.rs @@ -0,0 +1,15 @@ +//@ compile-flags: -Zpolymorphize=on -Zinline-mir=yes +//@ known-bug: #12345 + + +use std::sync::{Arc, Context, Weak}; + +pub struct WeakOnce(); +impl WeakOnce { + extern "rust-call" fn try_get(&self) -> Option> {} + + pub fn get(&self) -> Arc { + self.try_get() + .unwrap_or_else(|| panic!("Singleton {} not available", std::any::type_name::())) + } +} diff --git a/tests/crashes/README.md b/tests/crashes/README.md new file mode 100644 index 0000000000000..28346b26e3735 --- /dev/null +++ b/tests/crashes/README.md @@ -0,0 +1,13 @@ +This is serves as a collection of crashes so that accidental ICE fixes are tracked. +This was formally done at https://github.com/rust-lang/glacier but doing it inside +the rustc testsuite is more convenient. + +It is imperative that a test in the suite causes an internal compiler error/panic +or makes rustc crash in some other way. +Accepted exit codes are: 101 (may be expanded later) + +When adding crashes from https://github.com/rust-lang/rust/issues, the +issue number should be noted in the file name (12345.rs should suffice) +and perhaps also inside the file via `//@ known-bug #4321` + +If you happen to fix one of the crashes, please move it to `tests/ui`! :) diff --git a/tests/crashes/no-ice.rs b/tests/crashes/no-ice.rs deleted file mode 100644 index da0f5d925d107..0000000000000 --- a/tests/crashes/no-ice.rs +++ /dev/null @@ -1 +0,0 @@ -pub fn main() {} From e09244fab28e0ec61459b3437d3c0ebc1bdb44cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 24 Mar 2024 14:33:19 +0100 Subject: [PATCH 04/13] add ignore-mode-crashes to the know list of compiletest directive names --- src/tools/compiletest/src/header.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index b6ef20ed268a9..60ac7637fced6 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -758,6 +758,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", From 7048ce7e8fa441c7686b8a316ff5a551e8eea2f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 24 Mar 2024 17:43:47 +0100 Subject: [PATCH 05/13] tidy: add tidy check agains \.rs files inside tests/crashes that are missing "//@ known-bug: " --- src/tools/compiletest/src/runtest.rs | 2 +- src/tools/tidy/src/known_bug.rs | 17 +++++++++++++++++ src/tools/tidy/src/lib.rs | 1 + src/tools/tidy/src/main.rs | 2 ++ tests/crashes/span_delayed_bug.rs | 4 ---- 5 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 src/tools/tidy/src/known_bug.rs delete mode 100644 tests/crashes/span_delayed_bug.rs diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index e542cd4914731..ae140962e402c 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -354,7 +354,7 @@ impl<'test> TestCx<'test> { if self.props.should_ice { match proc_res.status.code() { Some(101) => (), - _ => self.fatal("expected ICE"), + _ => self.fatal("test no longer crashes/triggers ICE! Please annotate it and add it as test to tests/ui or wherever you see fit"), } } diff --git a/src/tools/tidy/src/known_bug.rs b/src/tools/tidy/src/known_bug.rs new file mode 100644 index 0000000000000..a62556f762bc4 --- /dev/null +++ b/src/tools/tidy/src/known_bug.rs @@ -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() + ); + } + }); +} diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index 57436e8d7fee9..23f303276aa2d 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -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; diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index 93be4d61a9ab3..77691815830a6 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -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 = 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); diff --git a/tests/crashes/span_delayed_bug.rs b/tests/crashes/span_delayed_bug.rs deleted file mode 100644 index e410f73041565..0000000000000 --- a/tests/crashes/span_delayed_bug.rs +++ /dev/null @@ -1,4 +0,0 @@ -#![feature(rustc_attrs)] - -#[rustc_error(delayed_bug_from_inside_query)] -fn main() {} From dde3178d5851d4999a4ed40bec5024ffdc834cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Fri, 29 Mar 2024 16:40:44 +0100 Subject: [PATCH 06/13] compiletest: crashes: turn off backtraces for faster tests --- src/tools/compiletest/src/header.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 60ac7637fced6..f78e0363f55ba 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -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,7 +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, "should-ice") => (), + (Mode::Crashes, _) => (), (Mode::Codegen, "build-pass") => (), (Mode::Incremental, _) => { if revision.is_some() && !self.revisions.iter().all(|r| r.starts_with("cfail")) { From dd1e35f9c021493c203b5a8d820017b574273d8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Fri, 29 Mar 2024 20:31:37 +0100 Subject: [PATCH 07/13] run_crash_test(): better error message when we get a none-ice --- src/tools/compiletest/src/runtest.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index ae140962e402c..da305aff95318 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -368,7 +368,8 @@ impl<'test> TestCx<'test> { // if a test does not crash, consider it an error match proc_res.status.code() { Some(101) => (), - _ => self.fatal("expected ICE"), + Some(other) => self.fatal(&format!("expected exit code 101, got: {}", other)), + e => self.fatal(&format!("expected ICE, got '{:?}'", e)), } } @@ -2320,6 +2321,9 @@ impl<'test> TestCx<'test> { } let (Output { status, stdout, stderr }, truncated) = self.read2_abbreviated(child); + eprintln!("{:?}", status); + eprintln!("{}", String::from_utf8_lossy(&stdout).into_owned()); + eprintln!("{}", String::from_utf8_lossy(&stdout).into_owned()); let result = ProcRes { status, From a5932b15074ac6c526446eb60d13a0c20e438835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Fri, 29 Mar 2024 22:25:16 +0100 Subject: [PATCH 08/13] compiletest: switch crash detection logic for run_crash_test around previously we would explicitly look for exit code 101 and call it a crash, however in case of stack overflows for example, exit code could differ due to the process being killed by a signal which is not easy to detect on none-unix. So now we reject everything that exits with 0 (no error) or 1 (compiler failed to compile code) and "accept" everyhing else as an internal compiler error. --- src/tools/compiletest/src/runtest.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index da305aff95318..9b98e78b15b52 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -354,7 +354,7 @@ impl<'test> TestCx<'test> { if self.props.should_ice { match proc_res.status.code() { Some(101) => (), - _ => self.fatal("test no longer crashes/triggers ICE! Please annotate it and add it as test to tests/ui or wherever you see fit"), + _ => self.fatal("expected ICE"), } } @@ -366,10 +366,11 @@ impl<'test> TestCx<'test> { let proc_res = self.compile_test(WillExecute::No, self.should_emit_metadata(pm)); // if a test does not crash, consider it an error - match proc_res.status.code() { - Some(101) => (), - Some(other) => self.fatal(&format!("expected exit code 101, got: {}", other)), - e => self.fatal(&format!("expected ICE, got '{:?}'", e)), + if !proc_res.status.success() { + match proc_res.status.code() { + Some(1 | 0) => self.fatal(&format!("test no longer crashes/triggers ICE! Please annotate it and add it as test to tests/ui or wherever you see fit")), + _ => (), + } } } From 98dd566033a95ab641cd30e96df0fae4f4d92c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Fri, 29 Mar 2024 19:39:47 +0100 Subject: [PATCH 09/13] add .rs crashes from https://github.com/rust-lang/glacier --- tests/crashes/100041.rs | 17 ++++++++++++ tests/crashes/101962.rs | 11 ++++++++ tests/crashes/102047.rs | 45 +++++++++++++++++++++++++++++++ tests/crashes/102252.rs | 14 ++++++++++ tests/crashes/103899.rs | 27 +++++++++++++++++++ tests/crashes/105238-1.rs | 31 +++++++++++++++++++++ tests/crashes/105238-2.rs | 31 +++++++++++++++++++++ tests/crashes/105488.rs | 39 +++++++++++++++++++++++++++ tests/crashes/108814.rs | 9 +++++++ tests/crashes/109681.rs | 9 +++++++ tests/crashes/110378.rs | 15 +++++++++++ tests/crashes/110630.rs | 28 +++++++++++++++++++ tests/crashes/111742.rs | 12 +++++++++ tests/crashes/112201.rs | 19 +++++++++++++ tests/crashes/113280.rs | 15 +++++++++++ tests/crashes/113379.rs | 7 +++++ tests/crashes/122909.rs | 2 +- tests/crashes/34127.rs | 6 +++++ tests/crashes/54888.rs | 21 +++++++++++++++ tests/crashes/57276.rs | 11 ++++++++ tests/crashes/74299.rs | 24 +++++++++++++++++ tests/crashes/74451.rs | 42 +++++++++++++++++++++++++++++ tests/crashes/79409.rs | 16 +++++++++++ tests/crashes/79590.rs | 19 +++++++++++++ tests/crashes/87577.rs | 4 +++ tests/crashes/88296.rs | 27 +++++++++++++++++++ tests/crashes/90110.rs | 57 +++++++++++++++++++++++++++++++++++++++ tests/crashes/91985.rs | 42 +++++++++++++++++++++++++++++ tests/crashes/96304.rs | 6 +++++ tests/crashes/97501.rs | 22 +++++++++++++++ tests/crashes/98322.rs | 37 +++++++++++++++++++++++++ 31 files changed, 664 insertions(+), 1 deletion(-) create mode 100644 tests/crashes/100041.rs create mode 100644 tests/crashes/101962.rs create mode 100644 tests/crashes/102047.rs create mode 100644 tests/crashes/102252.rs create mode 100644 tests/crashes/103899.rs create mode 100644 tests/crashes/105238-1.rs create mode 100644 tests/crashes/105238-2.rs create mode 100644 tests/crashes/105488.rs create mode 100644 tests/crashes/108814.rs create mode 100644 tests/crashes/109681.rs create mode 100644 tests/crashes/110378.rs create mode 100644 tests/crashes/110630.rs create mode 100644 tests/crashes/111742.rs create mode 100644 tests/crashes/112201.rs create mode 100644 tests/crashes/113280.rs create mode 100644 tests/crashes/113379.rs create mode 100644 tests/crashes/34127.rs create mode 100644 tests/crashes/54888.rs create mode 100644 tests/crashes/57276.rs create mode 100644 tests/crashes/74299.rs create mode 100644 tests/crashes/74451.rs create mode 100644 tests/crashes/79409.rs create mode 100644 tests/crashes/79590.rs create mode 100644 tests/crashes/87577.rs create mode 100644 tests/crashes/88296.rs create mode 100644 tests/crashes/90110.rs create mode 100644 tests/crashes/91985.rs create mode 100644 tests/crashes/96304.rs create mode 100644 tests/crashes/97501.rs create mode 100644 tests/crashes/98322.rs diff --git a/tests/crashes/100041.rs b/tests/crashes/100041.rs new file mode 100644 index 0000000000000..4d113cbe9ed4f --- /dev/null +++ b/tests/crashes/100041.rs @@ -0,0 +1,17 @@ +//@ known-bug: #100041 + +pub trait WellUnformed { + type RequestNormalize; +} + +impl WellUnformed for T { + type RequestNormalize = (); +} + +pub fn latent(_: &[<[[()]] as WellUnformed>::RequestNormalize; 0]) {} + +pub fn bang() { + latent(&[]); +} + +fn main() {} diff --git a/tests/crashes/101962.rs b/tests/crashes/101962.rs new file mode 100644 index 0000000000000..b6a78ce053af0 --- /dev/null +++ b/tests/crashes/101962.rs @@ -0,0 +1,11 @@ +//@ known-bug: #101962 + +#![feature(core_intrinsics)] + +pub fn wrapping(a: T, b: T) { + let _z = core::intrinsics::wrapping_mul(a, b); +} + +fn main() { + wrapping(1,2); +} diff --git a/tests/crashes/102047.rs b/tests/crashes/102047.rs new file mode 100644 index 0000000000000..61976f51273fc --- /dev/null +++ b/tests/crashes/102047.rs @@ -0,0 +1,45 @@ +//@ known-bug: #102047 + +struct Ty1; +struct Ty2; + +pub trait Trait {} + +pub trait WithAssoc1<'a> { + type Assoc; +} +pub trait WithAssoc2<'a> { + type Assoc; +} + +impl Trait fn(>::Assoc, >::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() +where + T: for<'a> WithAssoc1<'a>, + U: for<'a> WithAssoc2<'a>, + (T, U): Trait, +{ +} + +fn main() { + foo::(); +} diff --git a/tests/crashes/102252.rs b/tests/crashes/102252.rs new file mode 100644 index 0000000000000..200782f95c861 --- /dev/null +++ b/tests/crashes/102252.rs @@ -0,0 +1,14 @@ +//@ known-bug: #102252 + +#![feature(min_specialization, rustc_attrs)] + +#[rustc_specialization_trait] +pub trait Trait {} + +struct Struct +where + Self: Iterator::Item>, {} + +impl Trait for Struct {} + +fn main() {} diff --git a/tests/crashes/103899.rs b/tests/crashes/103899.rs new file mode 100644 index 0000000000000..39c2d72bd357c --- /dev/null +++ b/tests/crashes/103899.rs @@ -0,0 +1,27 @@ +//@ known-bug: #103899 + +trait BaseWithAssoc { + type Assoc; +} + +trait WrapperWithAssoc { + type BaseAssoc: BaseWithAssoc; +} + +struct Wrapper { + inner: B, +} + +struct ProjectToBase { + data_type_h: T::Assoc, +} + +struct DoubleProject { + buffer: Wrapper>, +} + +fn trigger>() -> DoubleProject { + loop {} +} + +fn main() {} diff --git a/tests/crashes/105238-1.rs b/tests/crashes/105238-1.rs new file mode 100644 index 0000000000000..dd44a0f1d775c --- /dev/null +++ b/tests/crashes/105238-1.rs @@ -0,0 +1,31 @@ +//@ known-bug: #105238 + +#![allow(incomplete_features)] +#![feature(generic_const_exprs)] + +trait Ret { + type R; +} + +struct Cond(std::marker::PhantomData, std::marker::PhantomData); + +impl Ret for Cond { + type R = U; +} + +impl Ret for Cond { + type R = V; +} + +struct RobinHashTable> +where + CellIdx: Ret, +{ + _idx: CellIdx::R, +} + +fn main() { + use std::mem::size_of; + println!("{}", size_of::>()); + println!("{}", size_of::>()); +} diff --git a/tests/crashes/105238-2.rs b/tests/crashes/105238-2.rs new file mode 100644 index 0000000000000..368595c6a2acb --- /dev/null +++ b/tests/crashes/105238-2.rs @@ -0,0 +1,31 @@ +//@ known-bug: #105238 + +#![allow(incomplete_features)] +#![feature(generic_const_exprs)] + +trait Ret { + type R; +} + +struct Cond(std::marker::PhantomData, std::marker::PhantomData); + +impl Ret for Cond { + type R = U; +} + +impl Ret for Cond { + type R = V; +} + +struct RobinHashTable< + const MAX_LENGTH: usize, + CellIdx = as Ret>::R, +> { + _idx: CellIdx, +} + +fn main() { + use std::mem::size_of; + println!("{}", size_of::>()); + println!("{}", size_of::>()); +} diff --git a/tests/crashes/105488.rs b/tests/crashes/105488.rs new file mode 100644 index 0000000000000..75fe899f173b6 --- /dev/null +++ b/tests/crashes/105488.rs @@ -0,0 +1,39 @@ +//@ known-bug: #105488 + +pub trait MyFnOnce { + type Output; + + fn call_my_fn_once(self) -> Self::Output; +} + +pub struct WrapFnOnce(F); + +impl D, D: MyFnOnce> MyFnOnce for WrapFnOnce { + type Output = D::Output; + + fn call_my_fn_once(self) -> Self::Output { + D::call_my_fn_once(self.0()) + } +} + +impl D, D: MyFnOnce> MyFnOnce for F { + type Output = D::Output; + + fn call_my_fn_once(self) -> Self::Output { + D::call_my_fn_once(self()) + } +} + +pub fn my_fn_1() -> impl MyFnOnce { + my_fn_2 +} + +pub fn my_fn_2() -> impl MyFnOnce { + WrapFnOnce(my_fn_1) +} + +fn main() { + let v = my_fn_1(); + + let _ = v.call_my_fn_once(); +} diff --git a/tests/crashes/108814.rs b/tests/crashes/108814.rs new file mode 100644 index 0000000000000..c8db848f2e188 --- /dev/null +++ b/tests/crashes/108814.rs @@ -0,0 +1,9 @@ +//@ known-bug: #108814 + +#![feature(non_lifetime_binders)] + +fn take(_: impl for FnOnce(T) -> T) {} + +fn main() { + take(|x| x) +} diff --git a/tests/crashes/109681.rs b/tests/crashes/109681.rs new file mode 100644 index 0000000000000..73ff10070943f --- /dev/null +++ b/tests/crashes/109681.rs @@ -0,0 +1,9 @@ +//@ known-bug: #109681 + +#![crate_type="lib"] +#![feature(linkage)] + +#[linkage = "common"] +pub static TEST3: bool = true; + +fn main() {} diff --git a/tests/crashes/110378.rs b/tests/crashes/110378.rs new file mode 100644 index 0000000000000..93de62d413909 --- /dev/null +++ b/tests/crashes/110378.rs @@ -0,0 +1,15 @@ +//@ known-bug: #110378 +// ignore-tidy-linelength + +#![feature(generic_const_exprs)] + +fn foo(_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])); +} diff --git a/tests/crashes/110630.rs b/tests/crashes/110630.rs new file mode 100644 index 0000000000000..f17f6f0781f39 --- /dev/null +++ b/tests/crashes/110630.rs @@ -0,0 +1,28 @@ +//@ known-bug: #110630 + +#![feature(generic_const_exprs)] + +use std::ops::Mul; + +pub trait Indices { + const NUM_ELEMS: usize = I::NUM_ELEMS * N; +} + +pub trait Concat { + type Output; +} + +pub struct Tensor, const N: usize> +where + [u8; I::NUM_ELEMS]: Sized, {} + +impl, J: Indices, const N: usize> Mul> for Tensor +where + I: Concat, + >::Output: Indices, + [u8; I::NUM_ELEMS]: Sized, + [u8; J::NUM_ELEMS]: Sized, + [u8; >::Output::NUM_ELEMS]: Sized, +{ + type Output = Tensor<>::Output, N>; +} diff --git a/tests/crashes/111742.rs b/tests/crashes/111742.rs new file mode 100644 index 0000000000000..fda2a96836f68 --- /dev/null +++ b/tests/crashes/111742.rs @@ -0,0 +1,12 @@ +//@ known-bug: #111742 +// ignore-tidy-linelength + +#![allow(incomplete_features)] +#![feature(generic_const_exprs)] + +const CONST: u32 = 0; +struct Test where [(); N as usize]: , ([u32; N as usize]); + +fn main() { + let _: Test<1>; +} diff --git a/tests/crashes/112201.rs b/tests/crashes/112201.rs new file mode 100644 index 0000000000000..5d363403b8acb --- /dev/null +++ b/tests/crashes/112201.rs @@ -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() {} diff --git a/tests/crashes/113280.rs b/tests/crashes/113280.rs new file mode 100644 index 0000000000000..6a04b50c0c8d9 --- /dev/null +++ b/tests/crashes/113280.rs @@ -0,0 +1,15 @@ +//@ known-bug: #113280 + +#![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))); +} diff --git a/tests/crashes/113379.rs b/tests/crashes/113379.rs new file mode 100644 index 0000000000000..7163cbc39342d --- /dev/null +++ b/tests/crashes/113379.rs @@ -0,0 +1,7 @@ +//@ known-bug: #113379 + +async fn f999() -> Vec { + 'b: { + continue 'b; + } +} diff --git a/tests/crashes/122909.rs b/tests/crashes/122909.rs index 344fcd8801096..90bba772b915e 100644 --- a/tests/crashes/122909.rs +++ b/tests/crashes/122909.rs @@ -1,5 +1,5 @@ //@ compile-flags: -Zpolymorphize=on -Zinline-mir=yes -//@ known-bug: #12345 +//@ known-bug: #122909 use std::sync::{Arc, Context, Weak}; diff --git a/tests/crashes/34127.rs b/tests/crashes/34127.rs new file mode 100644 index 0000000000000..82504486be56c --- /dev/null +++ b/tests/crashes/34127.rs @@ -0,0 +1,6 @@ +//@ compile-flags: -g -Copt-level=0 +//@ known-bug: #34127 + +pub fn main() { +let _a = [(); 1 << 63]; +} diff --git a/tests/crashes/54888.rs b/tests/crashes/54888.rs new file mode 100644 index 0000000000000..2c87d7ee9e4c8 --- /dev/null +++ b/tests/crashes/54888.rs @@ -0,0 +1,21 @@ +//@ known-bug: #54888 + +#![feature(unsize, coerce_unsized)] + +use std::{ + ops::CoerceUnsized, + marker::Unsize, +}; + +#[repr(C)] +struct Ptr(Box); + +impl CoerceUnsized> for Ptr +where + T: Unsize, +{} + + +fn main() { + let foo = Ptr(Box::new(5)) as Ptr; +} diff --git a/tests/crashes/57276.rs b/tests/crashes/57276.rs new file mode 100644 index 0000000000000..f70be4fba6d8b --- /dev/null +++ b/tests/crashes/57276.rs @@ -0,0 +1,11 @@ +//@ known-bug: #57276 + +#![feature(arbitrary_self_types, dispatch_from_dyn)] + +use std::ops::{Deref, DispatchFromDyn}; + +trait Trait + DispatchFromDyn> { + fn foo(self: T) -> dyn Trait; +} + +fn main() {} diff --git a/tests/crashes/74299.rs b/tests/crashes/74299.rs new file mode 100644 index 0000000000000..0e2ddce1c5b11 --- /dev/null +++ b/tests/crashes/74299.rs @@ -0,0 +1,24 @@ +//@ known-bug: #74299 +#![feature(specialization)] + +trait X { + type U; + fn f(&self) -> Self::U { + loop {} + } +} + +impl X for T { + default type U = (); +} + +trait Y { + fn g(&self) {} +} + +impl Y for <() as X>::U {} +impl Y for ::U {} + +fn main() { + ().f().g(); +} diff --git a/tests/crashes/74451.rs b/tests/crashes/74451.rs new file mode 100644 index 0000000000000..8f93699467896 --- /dev/null +++ b/tests/crashes/74451.rs @@ -0,0 +1,42 @@ +//@ known-bug: #74451 +//@ compile-flags: -Copt-level=0 + +#![feature(specialization)] +#![feature(unsize, coerce_unsized)] +#![allow(incomplete_features)] +#![crate_type = "lib"] + +use std::ops::CoerceUnsized; + +pub struct SmartassPtr(A::Data); + +pub trait Smartass { + type Data; + type Data2: CoerceUnsized<*const [u8]>; +} + +pub trait MaybeObjectSafe {} + +impl MaybeObjectSafe for () {} + +impl Smartass for T { + type Data = ::Data2; + default type Data2 = *const [u8; 0]; +} + +impl Smartass for () { + type Data2 = *const [u8; 1]; +} + +impl Smartass for dyn MaybeObjectSafe { + type Data = *const [u8]; + type Data2 = *const [u8; 0]; +} + +impl CoerceUnsized> for SmartassPtr + where ::Data: std::ops::CoerceUnsized<::Data> +{} + +pub fn conv(s: SmartassPtr<()>) -> SmartassPtr { + s // This shouldn't coerce +} diff --git a/tests/crashes/79409.rs b/tests/crashes/79409.rs new file mode 100644 index 0000000000000..98b5f60633627 --- /dev/null +++ b/tests/crashes/79409.rs @@ -0,0 +1,16 @@ +//@ known-bug: #79409 + +#![feature(extern_types)] +#![feature(unsized_locals)] + +extern { + type Device; +} + +unsafe fn make_device() -> Box { + Box::from_raw(0 as *mut _) +} + +fn main() { + let d: Device = unsafe { *make_device() }; +} diff --git a/tests/crashes/79590.rs b/tests/crashes/79590.rs new file mode 100644 index 0000000000000..b73864cce2349 --- /dev/null +++ b/tests/crashes/79590.rs @@ -0,0 +1,19 @@ +//@ known-bug: #79590 + +trait Database: Restriction {} + +trait Restriction { + type Inner; +} + +struct Test {} + +impl Database for Test {} +impl Restriction for Test { + type Inner = u32; +} + +fn main() { + let t = Test {}; + let x: &dyn Database = &t; +} diff --git a/tests/crashes/87577.rs b/tests/crashes/87577.rs new file mode 100644 index 0000000000000..c632b72c1474a --- /dev/null +++ b/tests/crashes/87577.rs @@ -0,0 +1,4 @@ +//@ known-bug: #87577 + +#[derive(Debug)] +struct S<#[cfg(feature = "alloc")] N: A> {} diff --git a/tests/crashes/88296.rs b/tests/crashes/88296.rs new file mode 100644 index 0000000000000..999834f5bdecd --- /dev/null +++ b/tests/crashes/88296.rs @@ -0,0 +1,27 @@ +//@ known-bug: #88296 + +#![feature(specialization)] + +trait Foo { + type Bar; +} + +impl Foo for T { + default type Bar = u32; +} + +impl Foo for i32 { + type Bar = i32; +} + +extern "C" { + #[allow(unused)] + // OK as Foo::Bar is explicitly defined for i32 + static OK: ::Bar; + + #[allow(unused)] + // ICE in the improper_ctypes lint + // as Foo::Bar is only default implemented for () + static ICE: <() as Foo>::Bar; +} +pub fn main() {} diff --git a/tests/crashes/90110.rs b/tests/crashes/90110.rs new file mode 100644 index 0000000000000..a27a1f42b7af3 --- /dev/null +++ b/tests/crashes/90110.rs @@ -0,0 +1,57 @@ +//@ known-bug: #90110 + +use std::fs::File; +use std::io::{BufReader, BufRead}; +use std::str::Split; +use std::path::Path; + +pub trait Parser +where dyn Parser: Sized +{ + fn new(split_header: Split<&str>) -> Self where Self: Sized; + fn parse_line(&self, split_line: &Split<&str>) -> D; +} + + +pub struct CsvReader { + parser: Box>, + + reader: BufReader, + buf: String, // Buffer we will read into. Avoids re-allocation on each line. + path: String, // Record this so we can return more informative error messages. + line: usize, // Same motivation for this. +} + +impl CsvReader +where dyn Parser: Sized +{ + fn new(path: &str, make_parser: F) -> CsvReader + where F: Fn(Split) -> dyn Parser { + let file = match File::open(Path::new(path)) { + Err(err) => panic!("Couldn't read {}: {}", path, err), + Ok(file) => file, + }; + + let mut reader = BufReader::new(file); + + let mut buf = String::new(); + + let parser = Box::new(match reader.read_line(&mut buf) { + Err(err) => panic!("Failed to read the header line from {}: {}", path, err), + Ok(_) => { + let split_header = buf.split(','); + make_parser(split_header) + }, + }); + + CsvReader { + parser: parser, + reader, + buf, + path: path.to_string(), + line: 2, + } + } +} + +pub fn main() {} diff --git a/tests/crashes/91985.rs b/tests/crashes/91985.rs new file mode 100644 index 0000000000000..338550430e1f8 --- /dev/null +++ b/tests/crashes/91985.rs @@ -0,0 +1,42 @@ +//@ known-bug: #91985 + +#![feature(generic_associated_types)] + +pub trait Trait1 { + type Associated: Ord; +} + +pub trait Trait2 { + type Associated: Clone; +} + +pub trait GatTrait { + type Gat; +} + +pub struct GatStruct; + +impl GatTrait for GatStruct { + type Gat = Box; +} + +pub struct OuterStruct { + inner: InnerStruct, + t1: T1, +} + +pub struct InnerStruct { + pub gat: G::Gat, +} + +impl OuterStruct +where + T1: Trait1, + T2: Trait2, +{ + pub fn new() -> Self { + todo!() + } +} + +pub fn main() {} diff --git a/tests/crashes/96304.rs b/tests/crashes/96304.rs new file mode 100644 index 0000000000000..637012f45858f --- /dev/null +++ b/tests/crashes/96304.rs @@ -0,0 +1,6 @@ +//@ known-bug: #96304 + +#![feature(asm_sym)] +core::arch::global_asm!("/* {} */", sym<&'static ()>::clone); + +pub fn main() {} diff --git a/tests/crashes/97501.rs b/tests/crashes/97501.rs new file mode 100644 index 0000000000000..51a83d8be169d --- /dev/null +++ b/tests/crashes/97501.rs @@ -0,0 +1,22 @@ +//@ known-bug: #97501 + +#![feature(core_intrinsics)] +use std::intrinsics::wrapping_add; + +#[derive(Clone, Copy)] +struct WrapInt8 { + value: u8 +} + +impl std::ops::Add for WrapInt8 { + type Output = WrapInt8; + fn add(self, other: WrapInt8) -> WrapInt8 { + wrapping_add(self, other) + } +} + +fn main() { + let p = WrapInt8 { value: 123 }; + let q = WrapInt8 { value: 234 }; + println!("{}", (p + q).value); +} diff --git a/tests/crashes/98322.rs b/tests/crashes/98322.rs new file mode 100644 index 0000000000000..57b349160294b --- /dev/null +++ b/tests/crashes/98322.rs @@ -0,0 +1,37 @@ +//@ known-bug: #98322 + +#![feature(generic_const_exprs)] + +// Main function seems irrelevant +fn main() {} + +// Constant must be provided via an associated constant in a trait +pub trait ConstTrait { + const ASSOC_CONST: usize; +} + +// For some reason I find it's necessary to have an implementation of this trait that recurses +pub trait OtherTrait +{ + fn comm(self); +} + +// There must be a blanket impl here +impl OtherTrait for T where + T: ConstTrait, + [();T::ASSOC_CONST]: Sized, +{ + fn comm(self) { + todo!() + } +} + +// The struct must be recursive +pub struct RecursiveStruct(Box); + +// This implementation must exist, and it must recurse into its child +impl OtherTrait for RecursiveStruct { + fn comm(self) { + (self.0).comm(); + } +} From 7d826ae43eb88750bd6745d73e100965bad72520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 30 Mar 2024 00:21:25 +0100 Subject: [PATCH 10/13] tests/crashes: add ICEs from matthiaskrgr/glacier2 --- tests/crashes/101036.rs | 14 +++++ tests/crashes/101557.rs | 41 ++++++++++++++ tests/crashes/105275.rs | 27 ++++++++++ tests/crashes/105488.rs | 39 -------------- tests/crashes/105937.rs | 27 ++++++++++ tests/crashes/106473.rs | 12 +++++ tests/crashes/110534.rs | 44 +++++++++++++++ tests/crashes/110627.rs | 8 +++ tests/crashes/111419.rs | 14 +++++ tests/crashes/111699.rs | 12 +++++ tests/crashes/111709-2.rs | 15 ++++++ tests/crashes/111709.rs | 25 +++++++++ tests/crashes/111883.rs | 40 ++++++++++++++ tests/crashes/113272.rs | 16 ++++++ tests/crashes/113846.rs | 32 +++++++++++ tests/crashes/114212-2.rs | 16 ++++++ tests/crashes/114212.rs | 34 ++++++++++++ tests/crashes/114317.rs | 6 +++ tests/crashes/114456-2.rs | 20 +++++++ tests/crashes/114456.rs | 17 ++++++ tests/crashes/114484.rs | 67 +++++++++++++++++++++++ tests/crashes/114663.rs | 17 ++++++ tests/crashes/115435.rs | 23 ++++++++ tests/crashes/115808.rs | 27 ++++++++++ tests/crashes/116308.rs | 16 ++++++ tests/crashes/116519-2.rs | 15 ++++++ tests/crashes/116519.rs | 57 ++++++++++++++++++++ tests/crashes/116554.rs | 31 +++++++++++ tests/crashes/116947.rs | 16 ++++++ tests/crashes/117392-2.rs | 27 ++++++++++ tests/crashes/117392.rs | 47 ++++++++++++++++ tests/crashes/117496.rs | 22 ++++++++ tests/crashes/117629.rs | 11 ++++ tests/crashes/117696-1.rs | 29 ++++++++++ tests/crashes/117696-2.rs | 13 +++++ tests/crashes/117795.rs | 8 +++ tests/crashes/117829-2.rs | 14 +++++ tests/crashes/117829.rs | 9 ++++ tests/crashes/117942.rs | 7 +++ tests/crashes/118038.rs | 12 +++++ tests/crashes/118320.rs | 13 +++++ tests/crashes/118403.rs | 8 +++ tests/crashes/118603.rs | 44 +++++++++++++++ tests/crashes/118952-2.rs | 10 ++++ tests/crashes/118952.rs | 25 +++++++++ tests/crashes/118987-2.rs | 17 ++++++ tests/crashes/118987.rs | 17 ++++++ tests/crashes/119272.rs | 27 ++++++++++ tests/crashes/119299.rs | 25 +++++++++ tests/crashes/119692.rs | 47 ++++++++++++++++ tests/crashes/119694.rs | 18 +++++++ tests/crashes/119701.rs | 21 ++++++++ tests/crashes/119716-2.rs | 4 ++ tests/crashes/119716.rs | 4 ++ tests/crashes/119717.rs | 10 ++++ tests/crashes/119729.rs | 12 +++++ tests/crashes/119783.rs | 8 +++ tests/crashes/119786.rs | 15 ++++++ tests/crashes/119824.rs | 14 +++++ tests/crashes/119830.rs | 11 ++++ tests/crashes/119924-6.rs | 14 +++++ tests/crashes/120241-2.rs | 9 ++++ tests/crashes/120241.rs | 12 +++++ tests/crashes/120482.rs | 12 +++++ tests/crashes/120503.rs | 10 ++++ tests/crashes/120600-2.rs | 13 +++++ tests/crashes/120600.rs | 11 ++++ tests/crashes/120793-2.rs | 22 ++++++++ tests/crashes/120793.rs | 21 ++++++++ tests/crashes/120873.rs | 8 +++ tests/crashes/120911.rs | 26 +++++++++ tests/crashes/121052.rs | 32 +++++++++++ tests/crashes/121097.rs | 10 ++++ tests/crashes/121126.rs | 4 ++ tests/crashes/121134.rs | 20 +++++++ tests/crashes/121161.rs | 12 +++++ tests/crashes/121263-2.rs | 6 +++ tests/crashes/121263.rs | 9 ++++ tests/crashes/121299.rs | 6 +++ tests/crashes/121411.rs | 13 +++++ tests/crashes/121422.rs | 8 +++ tests/crashes/121429.rs | 17 ++++++ tests/crashes/121444.rs | 9 ++++ tests/crashes/121536.rs | 20 +++++++ tests/crashes/121574-2.rs | 8 +++ tests/crashes/121574.rs | 6 +++ tests/crashes/121575.rs | 107 +++++++++++++++++++++++++++++++++++++ tests/crashes/121585-1.rs | 13 +++++ tests/crashes/121585-2.rs | 30 +++++++++++ tests/crashes/121613-2.rs | 28 ++++++++++ tests/crashes/121613.rs | 24 +++++++++ tests/crashes/121623.rs | 8 +++ tests/crashes/121722.rs | 10 ++++ tests/crashes/121799.rs | 11 ++++ tests/crashes/121816.rs | 12 +++++ tests/crashes/121858-2.rs | 20 +++++++ tests/crashes/121858.rs | 14 +++++ tests/crashes/121957-1.rs | 20 +++++++ tests/crashes/121957-2.rs | 20 +++++++ tests/crashes/121963.rs | 26 +++++++++ tests/crashes/122044.rs | 38 +++++++++++++ tests/crashes/122529.rs | 8 +++ tests/crashes/122548.rs | 17 ++++++ tests/crashes/122552.rs | 10 ++++ tests/crashes/122587-1.rs | 5 ++ tests/crashes/122638.rs | 12 +++++ tests/crashes/122681.rs | 10 ++++ tests/crashes/122704.rs | 14 +++++ tests/crashes/122710.rs | 24 +++++++++ tests/crashes/122736.rs | 15 ++++++ tests/crashes/122823.rs | 69 ++++++++++++++++++++++++ tests/crashes/122903-1.rs | 8 +++ tests/crashes/122903-2.rs | 9 ++++ tests/crashes/122904-2.rs | 15 ++++++ tests/crashes/122904.rs | 11 ++++ tests/crashes/122908.rs | 4 ++ tests/crashes/122914.rs | 11 ++++ tests/crashes/122989.rs | 8 +++ tests/crashes/123077-1.rs | 9 ++++ tests/crashes/123077-2.rs | 11 ++++ tests/crashes/123134.rs | 39 ++++++++++++++ tests/crashes/123140.rs | 6 +++ tests/crashes/123141-2.rs | 23 ++++++++ tests/crashes/123141.rs | 22 ++++++++ tests/crashes/123153.rs | 17 ++++++ tests/crashes/123154.rs | 12 +++++ tests/crashes/123157.rs | 15 ++++++ tests/crashes/23707.rs | 109 ++++++++++++++++++++++++++++++++++++++ tests/crashes/92004.rs | 70 ++++++++++++++++++++++++ tests/crashes/93182.rs | 29 ++++++++++ tests/crashes/93237.rs | 18 +++++++ tests/crashes/94846.rs | 6 +++ tests/crashes/95134.rs | 27 ++++++++++ 133 files changed, 2620 insertions(+), 39 deletions(-) create mode 100644 tests/crashes/101036.rs create mode 100644 tests/crashes/101557.rs create mode 100644 tests/crashes/105275.rs delete mode 100644 tests/crashes/105488.rs create mode 100644 tests/crashes/105937.rs create mode 100644 tests/crashes/106473.rs create mode 100644 tests/crashes/110534.rs create mode 100644 tests/crashes/110627.rs create mode 100644 tests/crashes/111419.rs create mode 100644 tests/crashes/111699.rs create mode 100644 tests/crashes/111709-2.rs create mode 100644 tests/crashes/111709.rs create mode 100644 tests/crashes/111883.rs create mode 100644 tests/crashes/113272.rs create mode 100644 tests/crashes/113846.rs create mode 100644 tests/crashes/114212-2.rs create mode 100644 tests/crashes/114212.rs create mode 100644 tests/crashes/114317.rs create mode 100644 tests/crashes/114456-2.rs create mode 100644 tests/crashes/114456.rs create mode 100644 tests/crashes/114484.rs create mode 100644 tests/crashes/114663.rs create mode 100644 tests/crashes/115435.rs create mode 100644 tests/crashes/115808.rs create mode 100644 tests/crashes/116308.rs create mode 100644 tests/crashes/116519-2.rs create mode 100644 tests/crashes/116519.rs create mode 100644 tests/crashes/116554.rs create mode 100644 tests/crashes/116947.rs create mode 100644 tests/crashes/117392-2.rs create mode 100644 tests/crashes/117392.rs create mode 100644 tests/crashes/117496.rs create mode 100644 tests/crashes/117629.rs create mode 100644 tests/crashes/117696-1.rs create mode 100644 tests/crashes/117696-2.rs create mode 100644 tests/crashes/117795.rs create mode 100644 tests/crashes/117829-2.rs create mode 100644 tests/crashes/117829.rs create mode 100644 tests/crashes/117942.rs create mode 100644 tests/crashes/118038.rs create mode 100644 tests/crashes/118320.rs create mode 100644 tests/crashes/118403.rs create mode 100644 tests/crashes/118603.rs create mode 100644 tests/crashes/118952-2.rs create mode 100644 tests/crashes/118952.rs create mode 100644 tests/crashes/118987-2.rs create mode 100644 tests/crashes/118987.rs create mode 100644 tests/crashes/119272.rs create mode 100644 tests/crashes/119299.rs create mode 100644 tests/crashes/119692.rs create mode 100644 tests/crashes/119694.rs create mode 100644 tests/crashes/119701.rs create mode 100644 tests/crashes/119716-2.rs create mode 100644 tests/crashes/119716.rs create mode 100644 tests/crashes/119717.rs create mode 100644 tests/crashes/119729.rs create mode 100644 tests/crashes/119783.rs create mode 100644 tests/crashes/119786.rs create mode 100644 tests/crashes/119824.rs create mode 100644 tests/crashes/119830.rs create mode 100644 tests/crashes/119924-6.rs create mode 100644 tests/crashes/120241-2.rs create mode 100644 tests/crashes/120241.rs create mode 100644 tests/crashes/120482.rs create mode 100644 tests/crashes/120503.rs create mode 100644 tests/crashes/120600-2.rs create mode 100644 tests/crashes/120600.rs create mode 100644 tests/crashes/120793-2.rs create mode 100644 tests/crashes/120793.rs create mode 100644 tests/crashes/120873.rs create mode 100644 tests/crashes/120911.rs create mode 100644 tests/crashes/121052.rs create mode 100644 tests/crashes/121097.rs create mode 100644 tests/crashes/121126.rs create mode 100644 tests/crashes/121134.rs create mode 100644 tests/crashes/121161.rs create mode 100644 tests/crashes/121263-2.rs create mode 100644 tests/crashes/121263.rs create mode 100644 tests/crashes/121299.rs create mode 100644 tests/crashes/121411.rs create mode 100644 tests/crashes/121422.rs create mode 100644 tests/crashes/121429.rs create mode 100644 tests/crashes/121444.rs create mode 100644 tests/crashes/121536.rs create mode 100644 tests/crashes/121574-2.rs create mode 100644 tests/crashes/121574.rs create mode 100644 tests/crashes/121575.rs create mode 100644 tests/crashes/121585-1.rs create mode 100644 tests/crashes/121585-2.rs create mode 100644 tests/crashes/121613-2.rs create mode 100644 tests/crashes/121613.rs create mode 100644 tests/crashes/121623.rs create mode 100644 tests/crashes/121722.rs create mode 100644 tests/crashes/121799.rs create mode 100644 tests/crashes/121816.rs create mode 100644 tests/crashes/121858-2.rs create mode 100644 tests/crashes/121858.rs create mode 100644 tests/crashes/121957-1.rs create mode 100644 tests/crashes/121957-2.rs create mode 100644 tests/crashes/121963.rs create mode 100644 tests/crashes/122044.rs create mode 100644 tests/crashes/122529.rs create mode 100644 tests/crashes/122548.rs create mode 100644 tests/crashes/122552.rs create mode 100644 tests/crashes/122587-1.rs create mode 100644 tests/crashes/122638.rs create mode 100644 tests/crashes/122681.rs create mode 100644 tests/crashes/122704.rs create mode 100644 tests/crashes/122710.rs create mode 100644 tests/crashes/122736.rs create mode 100644 tests/crashes/122823.rs create mode 100644 tests/crashes/122903-1.rs create mode 100644 tests/crashes/122903-2.rs create mode 100644 tests/crashes/122904-2.rs create mode 100644 tests/crashes/122904.rs create mode 100644 tests/crashes/122908.rs create mode 100644 tests/crashes/122914.rs create mode 100644 tests/crashes/122989.rs create mode 100644 tests/crashes/123077-1.rs create mode 100644 tests/crashes/123077-2.rs create mode 100644 tests/crashes/123134.rs create mode 100644 tests/crashes/123140.rs create mode 100644 tests/crashes/123141-2.rs create mode 100644 tests/crashes/123141.rs create mode 100644 tests/crashes/123153.rs create mode 100644 tests/crashes/123154.rs create mode 100644 tests/crashes/123157.rs create mode 100644 tests/crashes/23707.rs create mode 100644 tests/crashes/92004.rs create mode 100644 tests/crashes/93182.rs create mode 100644 tests/crashes/93237.rs create mode 100644 tests/crashes/94846.rs create mode 100644 tests/crashes/95134.rs diff --git a/tests/crashes/101036.rs b/tests/crashes/101036.rs new file mode 100644 index 0000000000000..72334985820f8 --- /dev/null +++ b/tests/crashes/101036.rs @@ -0,0 +1,14 @@ +//@ known-bug: #101036 +#![feature(generic_const_exprs)] + +const fn t() -> u8 { + N as u8 +} + +#[repr(u8)] +enum T::A as u8 + T::<0>::B as u8 }> +where + [(); N as usize]: +{ + A = t::() as u8, B +} diff --git a/tests/crashes/101557.rs b/tests/crashes/101557.rs new file mode 100644 index 0000000000000..da32660903e9e --- /dev/null +++ b/tests/crashes/101557.rs @@ -0,0 +1,41 @@ +//@ known-bug: #101557 +#![feature(generic_const_exprs)] +use std::marker::PhantomData; + +trait Trait { + const CONST: usize; +} + +struct A { + _marker: PhantomData, +} + +impl Trait for [i8; N] { + const CONST: usize = N; +} + +impl From for A<[i8; N]> { + fn from(_: usize) -> Self { + todo!() + } +} + +impl From> for A { + fn from(_: A<[i8; T::CONST]>) -> Self { + todo!() + } +} + +fn f() -> A +where + [(); T::CONST]:, +{ + // Usage of `0` is arbitrary + let a = A::<[i8; T::CONST]>::from(0); + A::::from(a) +} + +fn main() { + // Usage of `1` is arbitrary + f::<[i8; 1]>(); +} diff --git a/tests/crashes/105275.rs b/tests/crashes/105275.rs new file mode 100644 index 0000000000000..a97f36d19872c --- /dev/null +++ b/tests/crashes/105275.rs @@ -0,0 +1,27 @@ +//@ known-bug: #105275 +//@ compile-flags: -Copt-level=0 + +pub fn encode_num(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(); +} diff --git a/tests/crashes/105488.rs b/tests/crashes/105488.rs deleted file mode 100644 index 75fe899f173b6..0000000000000 --- a/tests/crashes/105488.rs +++ /dev/null @@ -1,39 +0,0 @@ -//@ known-bug: #105488 - -pub trait MyFnOnce { - type Output; - - fn call_my_fn_once(self) -> Self::Output; -} - -pub struct WrapFnOnce(F); - -impl D, D: MyFnOnce> MyFnOnce for WrapFnOnce { - type Output = D::Output; - - fn call_my_fn_once(self) -> Self::Output { - D::call_my_fn_once(self.0()) - } -} - -impl D, D: MyFnOnce> MyFnOnce for F { - type Output = D::Output; - - fn call_my_fn_once(self) -> Self::Output { - D::call_my_fn_once(self()) - } -} - -pub fn my_fn_1() -> impl MyFnOnce { - my_fn_2 -} - -pub fn my_fn_2() -> impl MyFnOnce { - WrapFnOnce(my_fn_1) -} - -fn main() { - let v = my_fn_1(); - - let _ = v.call_my_fn_once(); -} diff --git a/tests/crashes/105937.rs b/tests/crashes/105937.rs new file mode 100644 index 0000000000000..ffd1a493e46d5 --- /dev/null +++ b/tests/crashes/105937.rs @@ -0,0 +1,27 @@ +//@ known-bug: #105937 +//@ compile-flags: -Copt-level=0 + +pub fn encode_num(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(); +} diff --git a/tests/crashes/106473.rs b/tests/crashes/106473.rs new file mode 100644 index 0000000000000..b0a129cac010a --- /dev/null +++ b/tests/crashes/106473.rs @@ -0,0 +1,12 @@ +//@ known-bug: #106473 +#![feature(generic_const_exprs)] + +const DEFAULT: u32 = 1; + +struct V +where + [(); U]:; + +trait Tr {} + +impl Tr for V {} diff --git a/tests/crashes/110534.rs b/tests/crashes/110534.rs new file mode 100644 index 0000000000000..240ff6c270413 --- /dev/null +++ b/tests/crashes/110534.rs @@ -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 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) {} + 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(); +} diff --git a/tests/crashes/110627.rs b/tests/crashes/110627.rs new file mode 100644 index 0000000000000..752682fa6059e --- /dev/null +++ b/tests/crashes/110627.rs @@ -0,0 +1,8 @@ +//@ known-bug: #110627 +#![feature(non_lifetime_binders)] + +fn take(id: impl for Fn(T) -> T) {} + +fn main() { + take(|x| x) +} diff --git a/tests/crashes/111419.rs b/tests/crashes/111419.rs new file mode 100644 index 0000000000000..3a1a13df1985a --- /dev/null +++ b/tests/crashes/111419.rs @@ -0,0 +1,14 @@ +//@ known-bug: #111419 +#![allow(incomplete_features)] +#![feature(generic_const_exprs, generic_arg_infer)] + +pub trait Example +where + [(); X + Y]:, +{} + +impl Example for Value {} + +pub struct Value; + +fn main() {} diff --git a/tests/crashes/111699.rs b/tests/crashes/111699.rs new file mode 100644 index 0000000000000..b3d12fb4a0bfd --- /dev/null +++ b/tests/crashes/111699.rs @@ -0,0 +1,12 @@ +//@ known-bug: #111699 +#![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); + } +} diff --git a/tests/crashes/111709-2.rs b/tests/crashes/111709-2.rs new file mode 100644 index 0000000000000..6c4fb9f28c7de --- /dev/null +++ b/tests/crashes/111709-2.rs @@ -0,0 +1,15 @@ +//@ known-bug: #111709 +//@ edition: 2021 + +use core::arch::asm; + +extern "C" fn test() {} + +fn uwu() { + unsafe { + asm!( + "/* {0} */", + sym test::<&mut ()> + ); + } +} diff --git a/tests/crashes/111709.rs b/tests/crashes/111709.rs new file mode 100644 index 0000000000000..eef375b8924b7 --- /dev/null +++ b/tests/crashes/111709.rs @@ -0,0 +1,25 @@ +//@ known-bug: #111709 +//@ edition:2021 + +use core::arch::asm; + +struct TrapFrame; + +unsafe extern "C" fn _rust_abi_shim1(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) + ) +} diff --git a/tests/crashes/111883.rs b/tests/crashes/111883.rs new file mode 100644 index 0000000000000..fa72b28c22870 --- /dev/null +++ b/tests/crashes/111883.rs @@ -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 {} +impl<'a, T: ?Sized + Unsize, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {} +#[lang = "unsize"] +trait Unsize {} +#[lang = "coerce_unsized"] +pub trait CoerceUnsized {} +impl<'a, 'b: 'a, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} + +#[lang = "drop_in_place"] +fn drop_in_place_fn(a: &dyn Trait2) {} + +pub trait Trait1 { + fn foo(&self); +} + +pub struct Type1; + +impl Trait1 for Type1 { + fn foo(&self) {} +} + +pub trait Trait2 {} + +pub fn bar1() { + let a = Type1; + let b = &a as &dyn Trait1; + b.foo(); +} diff --git a/tests/crashes/113272.rs b/tests/crashes/113272.rs new file mode 100644 index 0000000000000..d161575c657ec --- /dev/null +++ b/tests/crashes/113272.rs @@ -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<&Other>>(None); + } +} diff --git a/tests/crashes/113846.rs b/tests/crashes/113846.rs new file mode 100644 index 0000000000000..0e5afb4da61b8 --- /dev/null +++ b/tests/crashes/113846.rs @@ -0,0 +1,32 @@ +//@ known-bug: #113846 +trait Www { + type W; +} + +trait Xxx: Www { + type X; +} + +trait Yyy: Xxx {} + +trait Zzz<'a>: Yyy + Xxx { + type Z; +} + +trait Aaa { + type Y: Yyy; +} + +trait Bbb: Aaa { + type B: for<'a> Zzz<'a>; +} + +impl Bbb for T +where + T: Aaa, + T::Y: for<'a> Zzz<'a>, +{ + type B = T::Y; +} + +pub fn main() {} diff --git a/tests/crashes/114212-2.rs b/tests/crashes/114212-2.rs new file mode 100644 index 0000000000000..a430c1b40d37a --- /dev/null +++ b/tests/crashes/114212-2.rs @@ -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, +} diff --git a/tests/crashes/114212.rs b/tests/crashes/114212.rs new file mode 100644 index 0000000000000..8642dbe8e71f2 --- /dev/null +++ b/tests/crashes/114212.rs @@ -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; + +impl FooTrait for Foo {} + +pub struct Bar< + const MAX_INPUT_LEN: usize = DEFAULT_MAX_INPUT_LEN, + PB = Foo, +> +where + PB: FooTrait, +{ + _pb: PhantomData, +} + +impl Bar +where + PB: FooTrait, +{ + pub fn new() -> Self { + Self { + _pb: PhantomData, + } + } +} diff --git a/tests/crashes/114317.rs b/tests/crashes/114317.rs new file mode 100644 index 0000000000000..09fd2beeba8a5 --- /dev/null +++ b/tests/crashes/114317.rs @@ -0,0 +1,6 @@ +//@ known-bug: #114317 +#![feature(generic_const_exprs)] + +struct A; + +fn main() {} diff --git a/tests/crashes/114456-2.rs b/tests/crashes/114456-2.rs new file mode 100644 index 0000000000000..eca27febb968a --- /dev/null +++ b/tests/crashes/114456-2.rs @@ -0,0 +1,20 @@ +//@ known-bug: #114456 +#![feature(adt_const_params)] + +const EMPTY_MATRIX: ::Matrix = [0; 1]; + +pub struct Walk::Matrix> {} + +impl Walk { + 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(); +} diff --git a/tests/crashes/114456.rs b/tests/crashes/114456.rs new file mode 100644 index 0000000000000..e347327e73863 --- /dev/null +++ b/tests/crashes/114456.rs @@ -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 {} + +impl Walk { + pub const fn new() -> Self { + Self {} + } +} + +fn main() { + let _ = Walk::new(); +} diff --git a/tests/crashes/114484.rs b/tests/crashes/114484.rs new file mode 100644 index 0000000000000..9d90c153624cc --- /dev/null +++ b/tests/crashes/114484.rs @@ -0,0 +1,67 @@ +//@ known-bug: #114484 +use std::marker::PhantomData; + +trait MyTrait { + fn virtualize(&self) -> &dyn MyTrait; +} + +struct VirtualWrapper(T); + +impl VirtualWrapper { + pub fn wrap(value: &T) -> &Self { + unsafe { &*(value as *const T as *const Self) } + } +} + +impl MyTrait for VirtualWrapper { + 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(level: u8, obj: &T) -> &dyn MyTrait +where + T: MyTrait + 'static, +{ + const fn gen_vtable_ptr() -> *const () + where + T: MyTrait + 'static, + { + let [_, vtable] = unsafe { + std::mem::transmute::<*const dyn MyTrait, [*const (); 2]>(std::ptr::null::< + VirtualWrapper, + >()) + }; + vtable + } + + struct Vtable(PhantomData); + + impl Vtable + where + T: MyTrait + 'static, + { + const LEVELS: [*const (); 2] = [gen_vtable_ptr::(), gen_vtable_ptr::()]; + } + + let vtable = Vtable::::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([u8; N]); + +impl MyTrait for SomeData { + fn virtualize(&self) -> &dyn MyTrait { + VirtualWrapper::::wrap(self) + } +} + +fn main() { + let test = SomeData([0; 256]); + test.virtualize(); +} diff --git a/tests/crashes/114663.rs b/tests/crashes/114663.rs new file mode 100644 index 0000000000000..406371f12e460 --- /dev/null +++ b/tests/crashes/114663.rs @@ -0,0 +1,17 @@ +//@ known-bug: #114663 +//@ edition:2021 + +#![feature(generic_const_exprs)] + +use core::fmt::Debug; + +struct Inline +where + [u8; ::core::mem::size_of::() + 1]:, +{ + _phantom: PhantomData, +} + +fn main() { + let dst = Inline::::new(0); // BANG! +} diff --git a/tests/crashes/115435.rs b/tests/crashes/115435.rs new file mode 100644 index 0000000000000..c846c95961d7a --- /dev/null +++ b/tests/crashes/115435.rs @@ -0,0 +1,23 @@ +//@ known-bug: #115435 +trait MyTrait { + type Target: ?Sized; +} + +impl MyTrait for A { + type Target = A; +} + +fn main() { + bug_run::>(); +} + +fn bug_run() +where + ::Target: Sized, +{ + bug::(); +} + +fn bug() { + std::mem::size_of::(); +} diff --git a/tests/crashes/115808.rs b/tests/crashes/115808.rs new file mode 100644 index 0000000000000..79196ac9c6544 --- /dev/null +++ b/tests/crashes/115808.rs @@ -0,0 +1,27 @@ +//@ known-bug: #115808 +#![feature(generic_const_exprs)] + +use std::ops::Mul; + +pub trait Indices { + const NUM_ELEMS: usize; +} + +pub trait Concat { + type Output; +} + +pub struct Tensor, const N: usize> +where + [u8; I::NUM_ELEMS]: Sized, {} + +impl, J: Indices, const N: usize> Mul> for Tensor +where + I: Concat, + >::Output: Indices, + [u8; I::NUM_ELEMS]: Sized, + [u8; J::NUM_ELEMS]: Sized, + [u8; >::Output::NUM_ELEMS]: Sized, +{ + type Output = Tensor<>::Output, N>; +} diff --git a/tests/crashes/116308.rs b/tests/crashes/116308.rs new file mode 100644 index 0000000000000..cb96c80d79bdc --- /dev/null +++ b/tests/crashes/116308.rs @@ -0,0 +1,16 @@ +//@ known-bug: #116308 +#![feature(adt_const_params)] + +pub trait Identity { + type Identity; +} + +impl Identity for T { + type Identity = Self; +} + +pub fn foo::Identity>() {} + +fn main() { + foo::<12>(); +} diff --git a/tests/crashes/116519-2.rs b/tests/crashes/116519-2.rs new file mode 100644 index 0000000000000..e1abbbcd4c145 --- /dev/null +++ b/tests/crashes/116519-2.rs @@ -0,0 +1,15 @@ +//@ known-bug: #116519 +#![feature(generic_const_exprs)] + +trait Ret { + type R; +} + +struct Cond(std::marker::PhantomData, ); + +struct RobinHashTable< + const MAX_LENGTH: usize, + CellIdx = as Ret>::R, +> {} + +impl HashMapBase for RobinHashTable {} diff --git a/tests/crashes/116519.rs b/tests/crashes/116519.rs new file mode 100644 index 0000000000000..0824a72be1977 --- /dev/null +++ b/tests/crashes/116519.rs @@ -0,0 +1,57 @@ +//@ known-bug: #116519 +#![allow(incomplete_features)] +#![feature(generic_const_exprs)] +trait Ret { + type R; +} +struct Cond(std::marker::PhantomData, std::marker::PhantomData); +impl Ret for Cond { + type R = U; +} +impl Ret for Cond { + type R = V; +} +struct RobinHashTable< + const MAX_LENGTH: usize, + CellIdx = as Ret>::R, +> { + _idx: CellIdx, +} +impl RobinHashTable { + fn new() -> Self { + Self { + _idx: CellIdx { MAX_LENGTH }, + } + } +} +impl HashMapBase { + fn new() -> Self { + Self { + _idx: CellIdx { 0 }, + } + } +} +impl HashMapBase for RobinHashTable { + fn hash(&self, + + ) -> H { + self._idx.hash() + } + fn eq(&self, other: &Self) -> bool { + self._idx.eq(other._idx) + } +} +impl HashMapBase for RobinHashTable { + fn hash(&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::>()); + println!("{}", size_of::>()); +} diff --git a/tests/crashes/116554.rs b/tests/crashes/116554.rs new file mode 100644 index 0000000000000..b87a478e6f20c --- /dev/null +++ b/tests/crashes/116554.rs @@ -0,0 +1,31 @@ +//@ known-bug: #116554 +#![feature(generic_const_exprs)] + +const fn t() -> u8 { + + N as u8 + +} + +#[repr(u8)] + +enum T::A as u8 + T::<0>::B as u8 }> + +where + + [(); N as usize]:, + + T: ?Sized, + +{ + + A, + +} + +fn main() { + A = t::() as u8, + + B, + +} diff --git a/tests/crashes/116947.rs b/tests/crashes/116947.rs new file mode 100644 index 0000000000000..34f0522369e28 --- /dev/null +++ b/tests/crashes/116947.rs @@ -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() {} diff --git a/tests/crashes/117392-2.rs b/tests/crashes/117392-2.rs new file mode 100644 index 0000000000000..632ce8b9deece --- /dev/null +++ b/tests/crashes/117392-2.rs @@ -0,0 +1,27 @@ +//@ known-bug: #117392 +pub trait BorrowComposite { + type Ref<'a>: 'a; +} + +impl BorrowComposite for () { + type Ref<'a> = (); +} + +pub trait Component { + type Output; +} + +impl Component for () { + type Output = (); +} + +pub fn delay FnMut(Args::Ref<'a>) -> C, C: Component>( + make: Make, +) -> impl Component { +} + +pub fn crash() -> impl Component<()> { + delay(|()| delay(|()| ())) +} + +pub fn main() {} diff --git a/tests/crashes/117392.rs b/tests/crashes/117392.rs new file mode 100644 index 0000000000000..95fdf63f893ec --- /dev/null +++ b/tests/crashes/117392.rs @@ -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 { + type Output; +} + +impl Component for () { + type Output = (); +} + +struct Delay { + _make: Make, +} + +impl< + Args: BorrowComposite, + Make: for<'a> FnMut(Args::Ref<'a>) -> C, + C: Component, + > Component for Delay +{ + type Output = C::Output; +} + +pub fn delay< + Args: BorrowComposite, + Make: for<'a> FnMut(Args::Ref<'a>) -> C, + C: Component, +>( + make: Make, +) -> impl Component { + Delay { _make: make } +} + +pub fn crash() -> impl Component<(), Output = ()> { + delay(|()| delay(|()| ())) +} + +pub fn main() {} diff --git a/tests/crashes/117496.rs b/tests/crashes/117496.rs new file mode 100644 index 0000000000000..1e85646cf8313 --- /dev/null +++ b/tests/crashes/117496.rs @@ -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([u64; SIZE]) +where + [u64; SIZE]: Sized; + +pub struct Quux {} +impl Quux<{ F }> { + pub unsafe fn nothing(&self, bar: &mut Bar<{ F }>) {} +} diff --git a/tests/crashes/117629.rs b/tests/crashes/117629.rs new file mode 100644 index 0000000000000..d8b5f328545da --- /dev/null +++ b/tests/crashes/117629.rs @@ -0,0 +1,11 @@ +//@ known-bug: #117629 +//@ edition:2021 + +#![feature(const_trait_impl)] + +#[const_trait] +trait Tr { + async fn ft1() {} +} + +fn main() {} diff --git a/tests/crashes/117696-1.rs b/tests/crashes/117696-1.rs new file mode 100644 index 0000000000000..dfca39177855d --- /dev/null +++ b/tests/crashes/117696-1.rs @@ -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(x: T) -> T { + x +} + +fn rec(mut it: T) +where + T: Iterator, +{ + if () == () { + T::count(it); + } else { + rec(identity(&mut it)) + } +} diff --git a/tests/crashes/117696-2.rs b/tests/crashes/117696-2.rs new file mode 100644 index 0000000000000..9c2a68d3a915c --- /dev/null +++ b/tests/crashes/117696-2.rs @@ -0,0 +1,13 @@ +//@ known-bug: #117696 +//@ compile-flags: -Copt-level=0 +fn main() { + rec(&mut None::<()>.into_iter()); +} + +fn rec(mut it: T) { + if true { + it.next(); + } else { + rec(&mut it); + } +} diff --git a/tests/crashes/117795.rs b/tests/crashes/117795.rs new file mode 100644 index 0000000000000..3f0dd2f9bf4f9 --- /dev/null +++ b/tests/crashes/117795.rs @@ -0,0 +1,8 @@ +//@ known-bug: #117795 +const fn f() -> usize { + 5 +} + +fn main() { + let _ = [0; FnMut::call_mut(&mut f, ())]; +} diff --git a/tests/crashes/117829-2.rs b/tests/crashes/117829-2.rs new file mode 100644 index 0000000000000..ecfd3148569df --- /dev/null +++ b/tests/crashes/117829-2.rs @@ -0,0 +1,14 @@ +//@ known-bug: #117829 +#![feature(auto_traits)] + +trait B {} + +auto trait Z +where + T: Z, + >::W: B, +{ + type W; +} + +fn main() {} diff --git a/tests/crashes/117829.rs b/tests/crashes/117829.rs new file mode 100644 index 0000000000000..7544b5ec0fceb --- /dev/null +++ b/tests/crashes/117829.rs @@ -0,0 +1,9 @@ +//@ known-bug: #117829 +auto trait Z<'a, T: ?Sized> +where + T: Z<'a, u16>, + + for<'b> >::W: Clone, +{ + type W: ?Sized; +} diff --git a/tests/crashes/117942.rs b/tests/crashes/117942.rs new file mode 100644 index 0000000000000..6fdfc6892506e --- /dev/null +++ b/tests/crashes/117942.rs @@ -0,0 +1,7 @@ +//@ known-bug: #117942 +struct Foo { + _: union { + #[rustfmt::skip] + f: String + }, +} diff --git a/tests/crashes/118038.rs b/tests/crashes/118038.rs new file mode 100644 index 0000000000000..a346e84c78f49 --- /dev/null +++ b/tests/crashes/118038.rs @@ -0,0 +1,12 @@ +//@ known-bug: #118038 +#![feature(non_lifetime_binders)] + +fn trivial() +where + for dyn Fn(A, *const A): Fn(A, *const B), +{ +} + +fn main() { + trivial::(); +} diff --git a/tests/crashes/118320.rs b/tests/crashes/118320.rs new file mode 100644 index 0000000000000..0f47c923e1058 --- /dev/null +++ b/tests/crashes/118320.rs @@ -0,0 +1,13 @@ +//@ known-bug: #118320 +#![feature(const_trait_impl, effects, const_closures)] + +#[const_trait] +trait Bar { + fn foo(&self); +} + +impl Bar for () {} + +const FOO: () = { + (const || (()).foo())(); +}; diff --git a/tests/crashes/118403.rs b/tests/crashes/118403.rs new file mode 100644 index 0000000000000..21ab15f9ffd0a --- /dev/null +++ b/tests/crashes/118403.rs @@ -0,0 +1,8 @@ +//@ known-bug: #118403 +#![feature(generic_const_exprs)] +pub struct X {} +impl X { + pub fn y<'a, U: 'a>(&'a self) -> impl Iterator + '_> { + (0..1).map(move |_| (0..1).map(move |_| loop {})) + } +} diff --git a/tests/crashes/118603.rs b/tests/crashes/118603.rs new file mode 100644 index 0000000000000..cde2cf3530571 --- /dev/null +++ b/tests/crashes/118603.rs @@ -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); + +const fn const_concat(_: [FlatTree; A], _: [FlatTree; B]) -> [FlatTree; A + B] { + [FlatTree; A + B] +} + +struct Builder { + ops: [FlatTree; N], + builder: I, +} + +fn create_node(a: Builder, b: Builder) -> Builder<{ N + M + 1 }, TreeNode> { + Builder { + ops: const_concat(const_concat::(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() {} diff --git a/tests/crashes/118952-2.rs b/tests/crashes/118952-2.rs new file mode 100644 index 0000000000000..469b1e8e90599 --- /dev/null +++ b/tests/crashes/118952-2.rs @@ -0,0 +1,10 @@ +//@ known-bug: #118952 +#![feature(generic_const_exprs)] + +pub struct TinyVec +where + [(); () - std::mem::size_of() - std::mem::size_of::()]:, {} + +pub fn main() { + let t = TinyVec::::new(); +} diff --git a/tests/crashes/118952.rs b/tests/crashes/118952.rs new file mode 100644 index 0000000000000..cd873703284dd --- /dev/null +++ b/tests/crashes/118952.rs @@ -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::() * 8; + +pub const fn tiny_vec_cap() -> usize { + return (DEFAULT_SMALL_VEC_INLINE_CAPACITY - 1) / std::mem::size_of::() +} + +pub struct TinyVec()}> + where [ + (); + (N * std::mem::size_of::()) + - std::mem::size_of::>() + - std::mem::size_of::() + ]: , +{ + data: isize //TinyVecData, +} + +pub fn main() { + let t = TinyVec::::new(); +} diff --git a/tests/crashes/118987-2.rs b/tests/crashes/118987-2.rs new file mode 100644 index 0000000000000..4382a7bcb6397 --- /dev/null +++ b/tests/crashes/118987-2.rs @@ -0,0 +1,17 @@ +//@ known-bug: #118987 +#![feature(specialization)] //~ WARN the feature `specialization` is incomplete + +trait Assoc { + type Output; +} + +default impl Assoc for T { + type Output = bool; +} + +impl Assoc for u8 {} + +trait Foo {} + +impl Foo for ::Output {} +impl Foo for ::Output {} diff --git a/tests/crashes/118987.rs b/tests/crashes/118987.rs new file mode 100644 index 0000000000000..4382a7bcb6397 --- /dev/null +++ b/tests/crashes/118987.rs @@ -0,0 +1,17 @@ +//@ known-bug: #118987 +#![feature(specialization)] //~ WARN the feature `specialization` is incomplete + +trait Assoc { + type Output; +} + +default impl Assoc for T { + type Output = bool; +} + +impl Assoc for u8 {} + +trait Foo {} + +impl Foo for ::Output {} +impl Foo for ::Output {} diff --git a/tests/crashes/119272.rs b/tests/crashes/119272.rs new file mode 100644 index 0000000000000..02e2cfd09e2f8 --- /dev/null +++ b/tests/crashes/119272.rs @@ -0,0 +1,27 @@ +//@ known-bug: #119272 +#![feature(type_alias_impl_trait)] +mod defining_scope { + use super::*; + pub type Alias = impl Sized; + + pub fn cast(x: Container, T>) -> Container { + x + } +} + +struct Container, U> { + x: >::Assoc, +} + +trait Trait { + type Assoc; +} + +impl Trait for T { + type Assoc = Box; +} +impl Trait for defining_scope::Alias { + type Assoc = usize; +} + +fn main() {} diff --git a/tests/crashes/119299.rs b/tests/crashes/119299.rs new file mode 100644 index 0000000000000..c8c10546d9409 --- /dev/null +++ b/tests/crashes/119299.rs @@ -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() -> [char; 3] { + ['a','b','c'] +} + +fn main() { + const A: &'static ConstStrU = &ConstStrU::from_bytes(b"abc"); + chars_s::(); +} diff --git a/tests/crashes/119692.rs b/tests/crashes/119692.rs new file mode 100644 index 0000000000000..3b7457a7abe93 --- /dev/null +++ b/tests/crashes/119692.rs @@ -0,0 +1,47 @@ +//@ known-bug: #119692 +#![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(pub(crate) S); + +impl Add> for Quantity +where + LHS: Add, +{ + type Output = Quantity<>::Output, D>; + fn add(self, rhs: Quantity) -> Self::Output { + Quantity(self.0 + rhs.0) + } +} + +impl Add for Quantity +where + LHS: Add, +{ + type Output = Quantity<>::Output, { Dimension }>; + fn add(self, rhs: RHS) -> Self::Output { + Quantity(self.0 + rhs) + } +} + +impl Add> for f32 { + type Output = Quantity; + fn add(self, rhs: Quantity) -> Self::Output { + Quantity(self + rhs.0) + } +} + +pub fn add(x: Quantity, y: Quantity) -> Quantity { + x + y +} + +fn main() { + add(Quantity::(1.0), Quantity(2.0)); +} diff --git a/tests/crashes/119694.rs b/tests/crashes/119694.rs new file mode 100644 index 0000000000000..f655ea1cd343c --- /dev/null +++ b/tests/crashes/119694.rs @@ -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); +} diff --git a/tests/crashes/119701.rs b/tests/crashes/119701.rs new file mode 100644 index 0000000000000..5f681bb8da88a --- /dev/null +++ b/tests/crashes/119701.rs @@ -0,0 +1,21 @@ +//@ known-bug: #119701 +#![feature(const_trait_impl, effects, generic_const_exprs)] + +fn main() { + let _ = process::<()>([()]); +} + +fn process() -> [(); T::make(2)] { + input +} + +#[const_trait] +trait Trait { + fn make(input: u8) -> usize; +} + +impl const Trait for () { + fn make(input: usize) -> usize { + input / 2 + } +} diff --git a/tests/crashes/119716-2.rs b/tests/crashes/119716-2.rs new file mode 100644 index 0000000000000..9cdc4417f5ba9 --- /dev/null +++ b/tests/crashes/119716-2.rs @@ -0,0 +1,4 @@ +//@ known-bug: #119716 +#![feature(non_lifetime_binders)] +trait Trait {} +fn f() -> impl for Trait> {} diff --git a/tests/crashes/119716.rs b/tests/crashes/119716.rs new file mode 100644 index 0000000000000..d7cba0f51c4e0 --- /dev/null +++ b/tests/crashes/119716.rs @@ -0,0 +1,4 @@ +//@ known-bug: #119716 +#![feature(non_lifetime_binders)] +trait v0 {} +fn kind :(v3main impl for v0<'_, v2 = impl v0 + '_>) {} diff --git a/tests/crashes/119717.rs b/tests/crashes/119717.rs new file mode 100644 index 0000000000000..22746548e02cb --- /dev/null +++ b/tests/crashes/119717.rs @@ -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 + } +} diff --git a/tests/crashes/119729.rs b/tests/crashes/119729.rs new file mode 100644 index 0000000000000..ed07c58e89fdf --- /dev/null +++ b/tests/crashes/119729.rs @@ -0,0 +1,12 @@ +//@ known-bug: #119729 +#![feature(generic_const_exprs)] + +trait Size {} + +impl Size<{ std::mem::size_of::() }> for T {} + +struct A + ?Sized> { + x: std::marker::PhantomData, +} + +fn foo(x: A) {} diff --git a/tests/crashes/119783.rs b/tests/crashes/119783.rs new file mode 100644 index 0000000000000..9a41abe69206e --- /dev/null +++ b/tests/crashes/119783.rs @@ -0,0 +1,8 @@ +//@ known-bug: #119783 +#![feature(associated_const_equality)] + +trait Trait { const F: fn(); } + +fn take(_: impl Trait) {} + +fn main() {} diff --git a/tests/crashes/119786.rs b/tests/crashes/119786.rs new file mode 100644 index 0000000000000..ca79664d8b74c --- /dev/null +++ b/tests/crashes/119786.rs @@ -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() {} diff --git a/tests/crashes/119824.rs b/tests/crashes/119824.rs new file mode 100644 index 0000000000000..d51cd5f49a395 --- /dev/null +++ b/tests/crashes/119824.rs @@ -0,0 +1,14 @@ +//@ known-bug: #119824 +#![feature(generic_const_exprs)] + +const fn t() -> u8 { + N as u8 +} + +#[repr(u8)] +enum T::A as u8 + T::<0>::B as u8 }> +where + [(); N as usize]: +{ + A = t::() as u8, B +} diff --git a/tests/crashes/119830.rs b/tests/crashes/119830.rs new file mode 100644 index 0000000000000..71becc04e1696 --- /dev/null +++ b/tests/crashes/119830.rs @@ -0,0 +1,11 @@ +//@ known-bug: #119830 +#![feature(effects)] +#![feature(min_specialization)] + +trait Specialize {} + +trait Foo {} + +impl const Foo for T {} + +impl const Foo for T where T: const Specialize {} diff --git a/tests/crashes/119924-6.rs b/tests/crashes/119924-6.rs new file mode 100644 index 0000000000000..01c4f43e8fd43 --- /dev/null +++ b/tests/crashes/119924-6.rs @@ -0,0 +1,14 @@ +//@ known-bug: #119924 +#![feature(const_trait_impl, effects)] + +struct S; +#[const_trait] +trait Trait {} + +const fn f>(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() {} diff --git a/tests/crashes/120241-2.rs b/tests/crashes/120241-2.rs new file mode 100644 index 0000000000000..c7044950211f7 --- /dev/null +++ b/tests/crashes/120241-2.rs @@ -0,0 +1,9 @@ +//@ known-bug: #120241 +#![feature(object_safe_for_dispatch)] +#![feature(unsized_fn_params)] + +fn guard(_s: Copy) -> bool { + panic!() +} + +fn main() {} diff --git a/tests/crashes/120241.rs b/tests/crashes/120241.rs new file mode 100644 index 0000000000000..f19fdf1a902ce --- /dev/null +++ b/tests/crashes/120241.rs @@ -0,0 +1,12 @@ +//@ known-bug: #120241 +#![feature(object_safe_for_dispatch)] + +trait B { + fn f(a: A) -> A; +} + +trait A { + fn g(b: B) -> B; +} + +fn main() {} diff --git a/tests/crashes/120482.rs b/tests/crashes/120482.rs new file mode 100644 index 0000000000000..1045aeb19c8fe --- /dev/null +++ b/tests/crashes/120482.rs @@ -0,0 +1,12 @@ +//@ known-bug: #120482 +#![feature(object_safe_for_dispatch)] + +trait B { + fn bar(&self, x: &Self); +} + +trait A { + fn g(new: B) -> B; +} + +fn main() {} diff --git a/tests/crashes/120503.rs b/tests/crashes/120503.rs new file mode 100644 index 0000000000000..28f1e3dfd94c4 --- /dev/null +++ b/tests/crashes/120503.rs @@ -0,0 +1,10 @@ +//@ known-bug: #120503 +#![feature(effects)] + +trait MyTrait {} + +impl MyTrait for i32 { + async const fn bar(&self) { + main8().await; + } +} diff --git a/tests/crashes/120600-2.rs b/tests/crashes/120600-2.rs new file mode 100644 index 0000000000000..aa1785eea84c4 --- /dev/null +++ b/tests/crashes/120600-2.rs @@ -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() {} diff --git a/tests/crashes/120600.rs b/tests/crashes/120600.rs new file mode 100644 index 0000000000000..1be51a8da1602 --- /dev/null +++ b/tests/crashes/120600.rs @@ -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() {} diff --git a/tests/crashes/120793-2.rs b/tests/crashes/120793-2.rs new file mode 100644 index 0000000000000..0ce5e4df2247c --- /dev/null +++ b/tests/crashes/120793-2.rs @@ -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()]; +} diff --git a/tests/crashes/120793.rs b/tests/crashes/120793.rs new file mode 100644 index 0000000000000..7e9166a50e553 --- /dev/null +++ b/tests/crashes/120793.rs @@ -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) -> usize { + 3 + } +} + +fn main() { + let array: [usize; Dim3::dim()] + //~^ ERROR E0015 + = [0; Dim3::dim()]; + //~^ ERROR E0015 +} diff --git a/tests/crashes/120873.rs b/tests/crashes/120873.rs new file mode 100644 index 0000000000000..45bc0bd457b10 --- /dev/null +++ b/tests/crashes/120873.rs @@ -0,0 +1,8 @@ +//@ known-bug: #120873 +#[repr(packed)] + +struct Dealigned(u8, T); + +#[derive(PartialEq)] +#[repr(C)] +struct Dealigned(u8, T); diff --git a/tests/crashes/120911.rs b/tests/crashes/120911.rs new file mode 100644 index 0000000000000..9bd2bf681420e --- /dev/null +++ b/tests/crashes/120911.rs @@ -0,0 +1,26 @@ +//@ known-bug: #120911 +trait Container { + type Item<'a>; +} +impl Container for () { + type Item<'a> = (); +} +struct Exchange { + _marker: std::marker::PhantomData<(C, F)>, +} +fn exchange(_: F) -> Exchange +where + C: Container, + for<'a> F: FnMut(&C::Item<'a>), +{ + unimplemented!() +} +trait Parallelization {} +impl Parallelization for Exchange {} +fn unary_frontier>(_: P) {} +fn main() { + let exchange = exchange(|_| ()); + let _ = || { + unary_frontier(exchange); + }; +} diff --git a/tests/crashes/121052.rs b/tests/crashes/121052.rs new file mode 100644 index 0000000000000..5d16b06db237d --- /dev/null +++ b/tests/crashes/121052.rs @@ -0,0 +1,32 @@ +//@ known-bug: #121052 +#![feature(generic_const_exprs, with_negative_coherence)] + +use std::ops::Mul; + +pub trait Indices { + const NUM_ELEMS: usize; +} + +impl, J: Indices, const N: usize> Mul for Tensor +where + I: Concat, + >::Output: Indices, + [u8; I::NUM_ELEMS]: Sized, + [u8; J::NUM_ELEMS]: Sized, + [u8; >::Output::NUM_ELEMS]: Sized, +{ +} + +pub trait Concat {} + +pub struct Tensor, const N: usize> {} + +impl, J: Indices, const N: usize> Mul for Tensor +where + I: Concat, + >::Output: Indices, + [u8; I::NUM_ELEMS]: Sized, + [u8; J::NUM_ELEMS]: Sized, + [u8; >::Output::NUM_ELEMS]: Sized, +{ +} diff --git a/tests/crashes/121097.rs b/tests/crashes/121097.rs new file mode 100644 index 0000000000000..65c6028e03e36 --- /dev/null +++ b/tests/crashes/121097.rs @@ -0,0 +1,10 @@ +//@ known-bug: #121097 +#[repr(simd)] +enum Aligned { + Zero = 0, + One = 1, +} + +fn tou8(al: Aligned) -> u8 { + al as u8 +} diff --git a/tests/crashes/121126.rs b/tests/crashes/121126.rs new file mode 100644 index 0000000000000..2ebe91f02ded9 --- /dev/null +++ b/tests/crashes/121126.rs @@ -0,0 +1,4 @@ +//@ known-bug: #121126 +fn main() { + let _n = 1i64 >> [64][4_294_967_295]; +} diff --git a/tests/crashes/121134.rs b/tests/crashes/121134.rs new file mode 100644 index 0000000000000..36397d4ec3c0d --- /dev/null +++ b/tests/crashes/121134.rs @@ -0,0 +1,20 @@ +//@ known-bug: #121134 +trait Output<'a> { + type Type; +} + +struct Wrapper; + +impl Wrapper { + fn do_something_wrapper(&mut self, do_something_wrapper: F) + where + FnOnce:, + F: for<'a> FnOnce(>::Type), + { + } +} + +fn main() { + let mut wrapper = Wrapper; + wrapper.do_something_wrapper::(|value| ()); +} diff --git a/tests/crashes/121161.rs b/tests/crashes/121161.rs new file mode 100644 index 0000000000000..6da6426a86d92 --- /dev/null +++ b/tests/crashes/121161.rs @@ -0,0 +1,12 @@ +//@ known-bug: #121161 +#![allow(incomplete_features)] +#![feature(unnamed_fields)] + + +#[derive(Eq)] +#[repr(C)] +struct Bar { + _: union { + a: u8, + }, +} diff --git a/tests/crashes/121263-2.rs b/tests/crashes/121263-2.rs new file mode 100644 index 0000000000000..2c6327a8808a5 --- /dev/null +++ b/tests/crashes/121263-2.rs @@ -0,0 +1,6 @@ +//@ known-bug: #121263 +#[repr(C)] +#[derive(Debug)] +struct L { + _: MyI32, +} diff --git a/tests/crashes/121263.rs b/tests/crashes/121263.rs new file mode 100644 index 0000000000000..cd7583a7fafce --- /dev/null +++ b/tests/crashes/121263.rs @@ -0,0 +1,9 @@ +//@ known-bug: #121263 +#[repr(C)] +#[repr(C)] +#[derive(Debug)] +struct L { + _: i32, + _: MyI32, + _: BadEnum, +} diff --git a/tests/crashes/121299.rs b/tests/crashes/121299.rs new file mode 100644 index 0000000000000..be5e0c0df573e --- /dev/null +++ b/tests/crashes/121299.rs @@ -0,0 +1,6 @@ +//@ known-bug: #121299 +#[derive(Eq)] +struct D { + _: union { + }, +} diff --git a/tests/crashes/121411.rs b/tests/crashes/121411.rs new file mode 100644 index 0000000000000..ef7b16579dd58 --- /dev/null +++ b/tests/crashes/121411.rs @@ -0,0 +1,13 @@ +//@ known-bug: #121411 +#![feature(const_trait_impl, effects)] + +#[const_trait] +trait Foo { + fn into_iter(&self) {} +} + +impl const Foo for () { + fn into_iter(a: u32, b: u32) {} +} + +const _: () = Foo::into_iter(&()); diff --git a/tests/crashes/121422.rs b/tests/crashes/121422.rs new file mode 100644 index 0000000000000..5d7ef6e8ce991 --- /dev/null +++ b/tests/crashes/121422.rs @@ -0,0 +1,8 @@ +//@ known-bug: #121422 +#![feature(non_lifetime_binders)] + +trait Trait {} + +fn produce() -> impl for Trait<(), Assoc = impl Trait> { + 16 +} diff --git a/tests/crashes/121429.rs b/tests/crashes/121429.rs new file mode 100644 index 0000000000000..09bd343e0ba99 --- /dev/null +++ b/tests/crashes/121429.rs @@ -0,0 +1,17 @@ +//@ known-bug: #121429 +#![feature(generic_const_exprs)] + +pub trait True {} + +impl PartialEq> for FixedI8 where + If<{}>: True +{ +} +#![feature(generic_const_exprs)] + +pub trait True {} + +impl PartialEq> for FixedI8 where + If<{}>: True +{ +} diff --git a/tests/crashes/121444.rs b/tests/crashes/121444.rs new file mode 100644 index 0000000000000..5a4289203ddb0 --- /dev/null +++ b/tests/crashes/121444.rs @@ -0,0 +1,9 @@ +//@ known-bug: #121444 +#[repr(align(536870912))] +pub struct A(i64); + +pub extern "C" fn foo(x: A) {} + +fn main() { + foo(A(0)); +} diff --git a/tests/crashes/121536.rs b/tests/crashes/121536.rs new file mode 100644 index 0000000000000..000e7cb15eb2f --- /dev/null +++ b/tests/crashes/121536.rs @@ -0,0 +1,20 @@ +//@ known-bug: #121536 +#![feature(effects)] + +#[derive(Debug, Clone, Copy)] +pub struct Vec3 { + pub x: f32, + pub y: f32, + pub z: f32, +} + +impl std::ops::Add for Vec3 { + type Output = Vec3; + const fn add(self, b: Vec3) -> Self::Output { + Vec3 { + x: self.x + b.x, + y: self.y + b.y, + z: self.z + b.z, + } + } +} diff --git a/tests/crashes/121574-2.rs b/tests/crashes/121574-2.rs new file mode 100644 index 0000000000000..a08f3f063974b --- /dev/null +++ b/tests/crashes/121574-2.rs @@ -0,0 +1,8 @@ +//@ known-bug: #121574 +#![feature(generic_const_exprs)] +pub struct DimName {} +impl X { + pub fn y<'a, U: 'a>(&'a self) -> impl Iterator + '_> { + "0".as_bytes(move |_| (0..1).map(move |_| loop {})) + } +} diff --git a/tests/crashes/121574.rs b/tests/crashes/121574.rs new file mode 100644 index 0000000000000..53eec829c5f38 --- /dev/null +++ b/tests/crashes/121574.rs @@ -0,0 +1,6 @@ +//@ known-bug: #121574 +#![feature(generic_const_exprs)] + +impl X { + pub fn y<'a, U: 'a>(&'a self) -> impl Iterator + '_> {} +} diff --git a/tests/crashes/121575.rs b/tests/crashes/121575.rs new file mode 100644 index 0000000000000..f0ce26c6f9564 --- /dev/null +++ b/tests/crashes/121575.rs @@ -0,0 +1,107 @@ +//@ known-bug: #121575 +// ignore-tidy-linelength +#![feature(generic_const_exprs)] + +use std::array; + +trait PrimRec { + fn eval(&self, x: [usize; N]) -> [usize; O]; +} + +struct Zero; + +impl PrimRec for Zero { + fn eval(&self, _: [usize; N]) -> [usize; 1] { + [0] + } +} + +struct Const(usize); + +impl PrimRec for Const { + fn eval(&self, _: [usize; N]) -> [usize; 1] { + [self.0] + } +} + +struct S; + +impl PrimRec<1, 1> for S { + fn eval(&self, x: [usize; 1]) -> [usize; 1] { + [x[0] + 1] + } +} + +struct Proj; + +impl PrimRec for Proj { + fn eval(&self, x: [usize; N]) -> [usize; 1] { + [x[I]] + } +} + +struct Merge, B: PrimRec>( + A, + B, +); + +fn concat(a: [usize; M], b: [usize; N]) -> [usize; M + N] { + array::from_fn(|i| if i < M { a[i] } else { b[i - M] }) +} + +impl, B: PrimRec> + PrimRec for Merge +{ + fn eval(&self, x: [usize; N]) -> [usize; O1 + O2] { + concat(self.0.eval(x), self.1.eval(x)) + } +} + +struct Compose, B: PrimRec>( + A, + B, +); + +impl, B: PrimRec> + PrimRec for Compose +{ + fn eval(&self, x: [usize; N]) -> [usize; O] { + self.1.eval(self.0.eval(x)) + } +} + +struct Rec, F: PrimRec<{ O + (N + 1) }, O>>( + Base, + F, +); + +fn tail(x: [usize; N + 1]) -> [usize; N] { + array::from_fn(|i| x[i + 1]) +} + +fn cons(x: usize, xs: [usize; N]) -> [usize; N + 1] { + array::from_fn(|i| if i == 0 { x } else { xs[i - 1] }) +} + +impl, F: PrimRec<{ O + (N + 1) }, O>> + PrimRec<{ N + 1 }, O> for Rec +{ + fn eval(&self, x: [usize; N + 1]) -> [usize; O] { + match (x[0], tail(x)) { + (0, x) => self.0.eval(x), + (y, x) => { + let xy = cons(y - 1, x); + let input = concat(self.eval(xy), xy); + self.1.eval(input) + } + } + } +} + +fn main() { + let one = Compose(Zero, S); + dbg!(one.eval([])); + let add: Rec<1, 1, Proj<0>, Compose<3, 1, 1, Proj<0>, S>> = + Rec(Proj::<0>, Compose(Proj::<0>, S)); + dbg!(add.eval([3, 2])); +} diff --git a/tests/crashes/121585-1.rs b/tests/crashes/121585-1.rs new file mode 100644 index 0000000000000..2a4638efcabdd --- /dev/null +++ b/tests/crashes/121585-1.rs @@ -0,0 +1,13 @@ +//@ known-bug: #121585 +#![feature(generic_const_exprs)] + +trait Trait {} + +struct HasCastInTraitImpl; +impl Trait for HasCastInTraitImpl {} + +pub fn use_trait_impl() { + fn assert_impl() {} + + assert_impl::>(); +} diff --git a/tests/crashes/121585-2.rs b/tests/crashes/121585-2.rs new file mode 100644 index 0000000000000..99cc8f7919559 --- /dev/null +++ b/tests/crashes/121585-2.rs @@ -0,0 +1,30 @@ +//@ known-bug: #121585 +//@ check-pass +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +trait Trait {} +pub struct EvaluatableU128; + +struct HasCastInTraitImpl; +impl Trait for HasCastInTraitImpl {} + +pub fn use_trait_impl() where EvaluatableU128<{N as u128}>:, { + fn assert_impl() {} + + assert_impl::>(); + assert_impl::>(); + assert_impl::>(); + assert_impl::>(); +} +pub fn use_trait_impl_2() where EvaluatableU128<{N as _}>:, { + fn assert_impl() {} + + assert_impl::>(); + assert_impl::>(); + assert_impl::>()const NUM: u8 = xyz(); + assert_impl::>(); +} + + +fn main() {} diff --git a/tests/crashes/121613-2.rs b/tests/crashes/121613-2.rs new file mode 100644 index 0000000000000..ddc4f37c96a2f --- /dev/null +++ b/tests/crashes/121613-2.rs @@ -0,0 +1,28 @@ +//@ known-bug: #121613 +fn main() { + // destructure through a qualified path + let ::Assoc { br } = StructStruct { br: 2 }; + //~^ ERROR usage of qualified paths in this context is experimental + let _ = ::Assoc { br: 2 }; + //~^ ERROR usage of qualified paths in this context is experimental + let ::V(..) = E::V(|a, b| a.cmp(b)); + //~^ ERROR usage of qualified paths in this context is experimental +} + +struct StructStruct { + br: i8, +} + +struct Foo; + +trait A { + type Assoc; +} + +impl A for Foo { + type Assoc = StructStruct; +} + +enum E { + V(u8) +} diff --git a/tests/crashes/121613.rs b/tests/crashes/121613.rs new file mode 100644 index 0000000000000..ec9ba82a68c5f --- /dev/null +++ b/tests/crashes/121613.rs @@ -0,0 +1,24 @@ +//@ known-bug: #121613 +fn main() { + let _ = ::Assoc { br: 2 }; + + let ::V(..) = E::V(|a, b| a.cmp(b)); +} + +struct StructStruct { + br: i8, +} + +struct Foo; + +trait A { + type Assoc; +} + +impl A for Foo { + type Assoc = StructStruct; +} + +enum E { + V(u8), +} diff --git a/tests/crashes/121623.rs b/tests/crashes/121623.rs new file mode 100644 index 0000000000000..3c01a7f452ca7 --- /dev/null +++ b/tests/crashes/121623.rs @@ -0,0 +1,8 @@ +//@ known-bug: #121623 +fn main() { + match () { + _ => 'b: { + continue 'b; + } + } +} diff --git a/tests/crashes/121722.rs b/tests/crashes/121722.rs new file mode 100644 index 0000000000000..d1b8c447bf727 --- /dev/null +++ b/tests/crashes/121722.rs @@ -0,0 +1,10 @@ +//@ known-bug: #121722 +#[repr(C)] +struct Foo { + _: u8, +} + +#[repr(C)] +struct D { + _: Foo, +} diff --git a/tests/crashes/121799.rs b/tests/crashes/121799.rs new file mode 100644 index 0000000000000..6035c9d9b150d --- /dev/null +++ b/tests/crashes/121799.rs @@ -0,0 +1,11 @@ +//@ known-bug: #121799 +struct S { + _: str +} + +fn func(a: S) +{ + let _x = a.f; +} + +fn main() {} diff --git a/tests/crashes/121816.rs b/tests/crashes/121816.rs new file mode 100644 index 0000000000000..a5569ea19d3ea --- /dev/null +++ b/tests/crashes/121816.rs @@ -0,0 +1,12 @@ +//@ known-bug: #121816 +fn f<'a, T>(_: &'static &'a (), x: &'a T) -> &'static T { + x +} +trait W<'a> { + fn g(self, x: &'a T) -> &'static T; +} +impl<'a> W<'a> for &'static () { + fn g(self, x: &'a T) -> &'static T { + f(&self, x) + } +} diff --git a/tests/crashes/121858-2.rs b/tests/crashes/121858-2.rs new file mode 100644 index 0000000000000..cb80c081cffa3 --- /dev/null +++ b/tests/crashes/121858-2.rs @@ -0,0 +1,20 @@ +//@ known-bug: #121858 +#![allow(named_arguments_used_positionally)] +#![feature(generic_const_exprs)] +struct Inner; +impl Inner where [(); N + M]: { + fn i() -> Self { + Self + } +} + +struct Outer(Inner) where [(); A + (B * 2)]:; +impl Outer where [(); A + (B * 2)]: { + fn o() -> Union { + Self(Inner::i()) + } +} + +fn main() { + Outer::<1, 1>::o(); +} diff --git a/tests/crashes/121858.rs b/tests/crashes/121858.rs new file mode 100644 index 0000000000000..7d5bae37f846b --- /dev/null +++ b/tests/crashes/121858.rs @@ -0,0 +1,14 @@ +//@ known-bug: #121858 +#![feature(generic_const_exprs)] + +struct Outer(); +impl Outer +where + [(); A + (B * 2)]:, +{ + fn o() -> Union {} +} + +fn main() { + Outer::<1, 1>::o(); +} diff --git a/tests/crashes/121957-1.rs b/tests/crashes/121957-1.rs new file mode 100644 index 0000000000000..74b4649cc9d95 --- /dev/null +++ b/tests/crashes/121957-1.rs @@ -0,0 +1,20 @@ +//@ known-bug: #121957 +#![feature(const_trait_impl, effects)] + +#[const_trait] +trait Main { + fn compute() -> u32; +} + +impl const Main for () { + fn compute<'x, 'y, 'z: 'x>() -> u32 {} +} + +#[const_trait] +trait Aux {} + +impl const Aux for () {} + +fn main() { + const _: u32 = <()>::compute::<()>(); +} diff --git a/tests/crashes/121957-2.rs b/tests/crashes/121957-2.rs new file mode 100644 index 0000000000000..74b4649cc9d95 --- /dev/null +++ b/tests/crashes/121957-2.rs @@ -0,0 +1,20 @@ +//@ known-bug: #121957 +#![feature(const_trait_impl, effects)] + +#[const_trait] +trait Main { + fn compute() -> u32; +} + +impl const Main for () { + fn compute<'x, 'y, 'z: 'x>() -> u32 {} +} + +#[const_trait] +trait Aux {} + +impl const Aux for () {} + +fn main() { + const _: u32 = <()>::compute::<()>(); +} diff --git a/tests/crashes/121963.rs b/tests/crashes/121963.rs new file mode 100644 index 0000000000000..c2ee8716f53a5 --- /dev/null +++ b/tests/crashes/121963.rs @@ -0,0 +1,26 @@ +//@ known-bug: #121963 +#![feature(generic_const_exprs)] +use std::marker::PhantomData; + +trait Arch { + const CHANNEL_COUNT: usize = 2; +} + +struct Channel { + r: [u8; N], +} + +struct Dram> { + a: PhantomData, + s: PhantomData, +} + +struct C +where + Channel<{ A::CHANNEL_COUNT }, u8>: Sized, +{ + b: Dram, + // b: Dram>, // When I specified generic here, it worked +} + +fn main() {} diff --git a/tests/crashes/122044.rs b/tests/crashes/122044.rs new file mode 100644 index 0000000000000..4c1d0de5719e8 --- /dev/null +++ b/tests/crashes/122044.rs @@ -0,0 +1,38 @@ +//@ known-bug: #122044 +use std::hint::black_box; + +trait Func { + type Ret: Id; +} + +trait Id { + type Assoc; +} +impl Id for u32 {} +impl Id for u32 {} + +impl R, R: Id> Func for F { + type Ret = R; +} + +fn bar() -> impl Copy + Id { + 0u32 +} + +struct Foo { + _func: T, + value: Option<<::Ret as Id>::Assoc>, +} + +fn main() { + let mut fn_def = black_box(Foo { + _func: bar, + value: None, + }); + let fn_ptr = black_box(Foo { + _func: bar as fn() -> _, + value: None, + }); + + fn_def.value = fn_ptr.value; +} diff --git a/tests/crashes/122529.rs b/tests/crashes/122529.rs new file mode 100644 index 0000000000000..87d393a453243 --- /dev/null +++ b/tests/crashes/122529.rs @@ -0,0 +1,8 @@ +//@ known-bug: #122529 +pub trait Archive { + type Archived; +} + +impl<'a> Archive for <&'a [u8] as Archive>::Archived { + type Archived = (); +} diff --git a/tests/crashes/122548.rs b/tests/crashes/122548.rs new file mode 100644 index 0000000000000..232ce5d441313 --- /dev/null +++ b/tests/crashes/122548.rs @@ -0,0 +1,17 @@ +//@ known-bug: #122548 +#![feature(const_mut_refs)] +#![feature(const_refs_to_static)] + +use std::cell::UnsafeCell; + +struct Meh { + x: &'static UnsafeCell, +} + +const MUH: Meh = Meh { + x: &mut *(&READONLY as *const _ as *mut _), +}; + +static READONLY: i32 = 0; + +pub fn main() {} diff --git a/tests/crashes/122552.rs b/tests/crashes/122552.rs new file mode 100644 index 0000000000000..29566941e22b2 --- /dev/null +++ b/tests/crashes/122552.rs @@ -0,0 +1,10 @@ +//@ known-bug: #122552 +//@ edition:2021 + +trait X { + fn line_stream<'a, Repr>() -> Self::LineStreamFut<{ async {} }, Repr>; +} + +struct Y; + +pub fn main() {} diff --git a/tests/crashes/122587-1.rs b/tests/crashes/122587-1.rs new file mode 100644 index 0000000000000..ea0e843a10cea --- /dev/null +++ b/tests/crashes/122587-1.rs @@ -0,0 +1,5 @@ +//@ known-bug: #122587 +const b: f16 = 0.0f16; +pub fn main() { + let b = 0.0f16; +} diff --git a/tests/crashes/122638.rs b/tests/crashes/122638.rs new file mode 100644 index 0000000000000..af0fc5bbd5031 --- /dev/null +++ b/tests/crashes/122638.rs @@ -0,0 +1,12 @@ +//@ known-bug: #122638 +#![feature(min_specialization)] + +impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T, { N }> { + fn next(&mut self) -> Option {} +} + +struct ConstChunksExact<'a, T: '_, const assert: usize> {} + +impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T, {}> { + type Item = &'a [T; N]; +} diff --git a/tests/crashes/122681.rs b/tests/crashes/122681.rs new file mode 100644 index 0000000000000..7dae276950e1d --- /dev/null +++ b/tests/crashes/122681.rs @@ -0,0 +1,10 @@ +//@ known-bug: #122681 +#[rustc_layout_scalar_valid_range_start(1)] +struct UnitStruct; + +#[derive(Default)] +enum SomeEnum { + #[default] + Unit, + Tuple(UnitStruct), +} diff --git a/tests/crashes/122704.rs b/tests/crashes/122704.rs new file mode 100644 index 0000000000000..d6c07be831885 --- /dev/null +++ b/tests/crashes/122704.rs @@ -0,0 +1,14 @@ +//@ known-bug: #122704 +use std::any::Any; + +pub struct Foo { + bar: Box Fn(&'a usize) -> Box>, +} + +impl Foo { + pub fn ack(&mut self, f: impl for<'a> Fn(&'a usize) -> Box) { + self.bar = Box::new(|baz| Box::new(f(baz))); + } +} + +fn main() {} diff --git a/tests/crashes/122710.rs b/tests/crashes/122710.rs new file mode 100644 index 0000000000000..16911fd522f8e --- /dev/null +++ b/tests/crashes/122710.rs @@ -0,0 +1,24 @@ +//@ known-bug: #122710 +use std::marker::PhantomData; + +pub trait BarTrait { + fn bar(self, _: T); +} + +impl BarTrait for F { + fn bar(self, _: T) { } +} + +impl MyTrait<'a>> BarTrait for () { + fn bar(self, _: T) { } +} + +pub trait MyTrait<'a> { } + +impl<'a> MyTrait<'a> for PhantomData<&'a ()> { } + +fn foo() { + ().bar(PhantomData); +} + +pub fn main() {} diff --git a/tests/crashes/122736.rs b/tests/crashes/122736.rs new file mode 100644 index 0000000000000..83b60444c2f4d --- /dev/null +++ b/tests/crashes/122736.rs @@ -0,0 +1,15 @@ +//@ known-bug: #122736 +fn main_ref() { + let array = [(); { + let mut x = &0; + let mut n = 0; + while n < 5 { + x = &0; + } + 0 + }]; + + let mut ptrs: Vec<*const [u8]> = vec![&array[0..0], &array[0..1], &array, &array[1..]]; +} + +fn main() {} diff --git a/tests/crashes/122823.rs b/tests/crashes/122823.rs new file mode 100644 index 0000000000000..ec22b331ad929 --- /dev/null +++ b/tests/crashes/122823.rs @@ -0,0 +1,69 @@ +//@ known-bug: #122823 +//@ compile-flags: -Copt-level=0 +// ignore-tidy-linelength + +use std::vec::Vec; +use std::iter::Peekable; + +pub fn main() { + let packet = decode(vec![1,0,1,0]); +} + +pub fn decode(bitstream: Vec) -> Packet { + let mut bitstream_itr = bitstream.into_iter().peekable(); + return match decode_packet(&mut bitstream_itr) { + Some(p) => p, + None => panic!("expected outer packet"), + } +} + +pub fn decode_packets>(itr: &mut Peekable) -> Vec { + let mut res = Vec::new(); + loop { + match decode_packet(itr) { + Some(p) => { res.push(p); }, + None => break + } + } + + return res; +} + +pub fn decode_packet>(itr: &mut Peekable) -> Option { + // get version digits + let version = extend_number(0, itr, 3)?; + let type_id = extend_number(0, itr, 3)?; + return operator_packet(version, type_id, itr); +} + +pub fn operator_packet>(version: u64, type_id: u64, itr: &mut Peekable) -> Option { + let p = OperatorPacket { + version: version, + type_id: type_id, + packets: decode_packets(&mut itr.take(0).peekable()), + }; + + return Some(Packet::Operator(p)); +} + +pub fn extend_number>(num: u64, itr: &mut Peekable, take: u64) -> Option { + let mut value = num; + for _ in 0..take { + value *= 2; + value += itr.next()?; + } + + return Some(value); +} + +#[derive(Debug)] +pub enum Packet { + Operator(OperatorPacket), +} + +#[derive(Debug)] +pub struct OperatorPacket { + version: u64, + type_id: u64, + packets: Vec +} diff --git a/tests/crashes/122903-1.rs b/tests/crashes/122903-1.rs new file mode 100644 index 0000000000000..9323c435851e6 --- /dev/null +++ b/tests/crashes/122903-1.rs @@ -0,0 +1,8 @@ +//@ known-bug: #122903 +impl Struct { + async fn box_box_ref_Struct( + self: Box>)>>, + ) -> &u32 { + f + } +} diff --git a/tests/crashes/122903-2.rs b/tests/crashes/122903-2.rs new file mode 100644 index 0000000000000..0d5d93014c187 --- /dev/null +++ b/tests/crashes/122903-2.rs @@ -0,0 +1,9 @@ +//@ known-bug: #122903 + +impl Struct { + async fn box_box_ref_Struct( + self: Box>)>> + ) -> &u32 { + f + } +} diff --git a/tests/crashes/122904-2.rs b/tests/crashes/122904-2.rs new file mode 100644 index 0000000000000..85ed91c2fa486 --- /dev/null +++ b/tests/crashes/122904-2.rs @@ -0,0 +1,15 @@ +//@ known-bug: #122904 +trait T {} + +type Alias<'a> = impl T; + +struct S; +impl<'a> T for &'a S {} + +fn with_positive(fun: impl Fn(Alias<'_>)) { + with_positive(|&n| ()); +} + +fn main(Alias<'_>) { + with_positive(|&a| ()); +} diff --git a/tests/crashes/122904.rs b/tests/crashes/122904.rs new file mode 100644 index 0000000000000..8b8bb35d56c1e --- /dev/null +++ b/tests/crashes/122904.rs @@ -0,0 +1,11 @@ +//@ known-bug: #122904 +trait T {} + +type Alias<'a> = impl T; + +struct S; +impl<'a> T for &'a S {} + +fn with_positive(fun: impl Fn(Alias<'_>)) { + with_positive(|&n| ()); +} diff --git a/tests/crashes/122908.rs b/tests/crashes/122908.rs new file mode 100644 index 0000000000000..c9da1bc187918 --- /dev/null +++ b/tests/crashes/122908.rs @@ -0,0 +1,4 @@ +//@ known-bug: #122908 +trait Trait { + async fn handle(slf: &F) {} +} diff --git a/tests/crashes/122914.rs b/tests/crashes/122914.rs new file mode 100644 index 0000000000000..63a84bc8099bc --- /dev/null +++ b/tests/crashes/122914.rs @@ -0,0 +1,11 @@ +//@ known-bug: #122914 +use std::future::Future; +use std::pin::Pin; + +impl<'a, F> Poll { + fn project<'_>(self: Pin<&'pin mut Future>) -> Projection<'pin, 'a, F> { + me.local_set.with(|| { + let _ = self.poll(cx); + }) + } +} diff --git a/tests/crashes/122989.rs b/tests/crashes/122989.rs new file mode 100644 index 0000000000000..70ad7d3b65c9b --- /dev/null +++ b/tests/crashes/122989.rs @@ -0,0 +1,8 @@ +//@ known-bug: #122989 +trait Traitor = 1, const N: N<2> = N> { + fn N(&N) -> N<2> { + M + } +} + +trait N = 12> {} diff --git a/tests/crashes/123077-1.rs b/tests/crashes/123077-1.rs new file mode 100644 index 0000000000000..76e81f730f959 --- /dev/null +++ b/tests/crashes/123077-1.rs @@ -0,0 +1,9 @@ +//@ known-bug: #123077 +use std::arch::x86_64::{__m128, _mm_blend_ps}; + +pub fn sse41_blend_noinline( ) -> __m128 { + let f = { |x, y| unsafe { + _mm_blend_ps(x, y, { |x, y| unsafe }) + }}; + f(x, y) +} diff --git a/tests/crashes/123077-2.rs b/tests/crashes/123077-2.rs new file mode 100644 index 0000000000000..d425625dfd9ad --- /dev/null +++ b/tests/crashes/123077-2.rs @@ -0,0 +1,11 @@ +//@ known-bug: #123077 +use std::arch::x86_64::{__m128, _mm_blend_ps}; + +pub fn sse41_blend_noinline( ) -> __m128 { + let f = { |x, y| unsafe { + _mm_blend_ps(x, y, { |x, y| unsafe }) + }}; + f(x, y) +} + +pub fn main() {} diff --git a/tests/crashes/123134.rs b/tests/crashes/123134.rs new file mode 100644 index 0000000000000..61c043db763f5 --- /dev/null +++ b/tests/crashes/123134.rs @@ -0,0 +1,39 @@ +//@ known-bug: #123134 +trait Api: Sized { + type Device: ?Sized; +} + +struct OpenDevice +where + A::Device: Sized, +{ + device: A::Device, + queue: (), +} + +trait Adapter { + type A: Api; + + fn open() -> OpenDevice + where + ::Device: Sized; +} + +struct ApiS; + +impl Api for ApiS { + type Device = [u8]; +} + +impl Adapter for T { + type A = ApiS; + + fn open() -> OpenDevice + where + ::Device: Sized, + { + unreachable!() + } +} + +pub fn main() {} diff --git a/tests/crashes/123140.rs b/tests/crashes/123140.rs new file mode 100644 index 0000000000000..89e55baad98f1 --- /dev/null +++ b/tests/crashes/123140.rs @@ -0,0 +1,6 @@ +//@ known-bug: #123140 +trait Project { + const SELF: Self; +} + +fn take1(_: Project) {} diff --git a/tests/crashes/123141-2.rs b/tests/crashes/123141-2.rs new file mode 100644 index 0000000000000..74f961c2a3377 --- /dev/null +++ b/tests/crashes/123141-2.rs @@ -0,0 +1,23 @@ +//@ known-bug: #123141 + +trait ConstChunksExactTrait { + fn const_chunks_exact(&self) -> ConstChunksExact<'_, T, {N}>; +} + +impl ConstChunksExactTrait for [T] {} + +struct ConstChunksExact<'a, T: 'a, const N: usize> {} + +impl <'a, T: , const N: usize> Iterator for ConstChunksExact<'a, T, {rem}> { + type Item = &'a [T; N]; +} + +fn main() { + let slice = &[1i32, 2, 3, 4, 5, 6, 7, 7, 9, 1i32]; + + let mut iter = [[1, 2, 3], [4, 5, 6], [7, 8 ,9]].iter(); + + for a in slice.const_chunks_exact::<3>() { + assert_eq!(a, iter.next().unwrap()); + } +} diff --git a/tests/crashes/123141.rs b/tests/crashes/123141.rs new file mode 100644 index 0000000000000..99dfee7670ef9 --- /dev/null +++ b/tests/crashes/123141.rs @@ -0,0 +1,22 @@ +//@ known-bug: #123141 +trait ConstChunksExactTrait { + fn const_chunks_exact(&self) -> ConstChunksExact<'_, T, { N }>; +} + +impl ConstChunksExactTrait for [T] {} + +struct ConstChunksExact<'a, T: 'a, const N: usize> {} + +impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, { rem }> { + type Item = &'a [T; N]; +} + +fn main() { + let slice = &[1i32, 2, 3, 4, 5, 6, 7, 7, 9, 1i32]; + + let mut iter = [[1, 2, 3], [4, 5, 6], [7, 8, 9]].iter(); + + for a in slice.const_chunks_exact::<3>() { + assert_eq!(a, iter.next().unwrap()); + } +} diff --git a/tests/crashes/123153.rs b/tests/crashes/123153.rs new file mode 100644 index 0000000000000..d2c32ecd73e74 --- /dev/null +++ b/tests/crashes/123153.rs @@ -0,0 +1,17 @@ +//@ known-bug: #123153 +pub struct wl_interface { + pub version: str, +} + +pub struct Interface { + pub other_interfaces: &'static [&'static Interface], + pub c_ptr: Option<&'static wl_interface>, +} + +pub static mut wl_callback_interface: wl_interface = wl_interface { version: 0 }; + +pub static WL_CALLBACK_INTERFACE: Interface = + Interface { other_interfaces: &[], c_ptr: Some(unsafe { &wl_callback_interface }) }; + + +fn main() {} diff --git a/tests/crashes/123154.rs b/tests/crashes/123154.rs new file mode 100644 index 0000000000000..510ae8adf350d --- /dev/null +++ b/tests/crashes/123154.rs @@ -0,0 +1,12 @@ +//@ known-bug: #123154 +struct AA { + pub data: [&usize] +} + +impl AA { + const fn new() -> Self { } +} + +static AA = AA::new(); + +fn main() { } diff --git a/tests/crashes/123157.rs b/tests/crashes/123157.rs new file mode 100644 index 0000000000000..0c0721d02ec51 --- /dev/null +++ b/tests/crashes/123157.rs @@ -0,0 +1,15 @@ +//@ known-bug: #123157 +#![feature(type_alias_impl_trait)] + +#[derive(Copy, Clone)] +struct Foo((u32, u32)); + +fn main() { + type T = impl Copy; + let foo: T = Foo((1u32, 2u32)); + let x = move || { + let x = move || { + let Foo((a, b)) = foo; + }; + }; +} diff --git a/tests/crashes/23707.rs b/tests/crashes/23707.rs new file mode 100644 index 0000000000000..c8c373c31e24d --- /dev/null +++ b/tests/crashes/23707.rs @@ -0,0 +1,109 @@ +//@ known-bug: #23707 +//@ compile-flags: -Copt-level=0 --edition=2021 + +#![recursion_limit="2048"] + +use std::marker::PhantomData; +use std::fmt; +use std::fmt::Debug; + +pub struct Z( () ); +pub struct S (PhantomData); + + +pub trait Nat { + fn sing() -> Self; + fn get(&self) -> usize; +} + +impl Nat for Z { + fn sing() -> Z { Z( () ) } + #[inline(always)] + fn get(&self) -> usize { + 0 + } +} + +impl Nat for S { + fn sing() -> S { S::( PhantomData:: ) } + #[inline(always)] + fn get(&self) -> usize { + let prd : T = Nat::sing(); + 1 + prd.get() + } +} + +pub type N0 = Z; +pub type N1 = S; +pub type N2 = S; +pub type N3 = S; +pub type N4 = S; +pub type N5 = S; + + +pub struct Node(usize,PhantomData); + +impl Node { + pub fn push(&self, c : usize) -> Node> { + let Node(i,_) = *self; + Node(10*i+c, PhantomData::>) + } +} + +impl Node> { + pub fn pop(&self) -> (Node,usize) { + let Node(i,_) = *self; + (Node(i/10, PhantomData::), i-10*(i/10)) + } +} + +impl Debug for Node { + fn fmt(&self, f : &mut fmt::Formatter) -> fmt::Result { + let s : D = Nat::sing(); + write!(f, "Node<{}>: i= {}", + s.get(), self.0) + } +} +pub trait Step { + fn step(&self, usize) -> Self; +} + +impl Step for Node { + #[inline(always)] + fn step(&self, n : usize) -> Node { + println!("base case"); + Node(n,PhantomData::) + } +} + +impl Step for Node> + where Node : Step { + #[inline(always)] + fn step(&self, n : usize) -> Node> { + println!("rec"); + let (par,c) = self.pop(); + let cnew = c+n; + par.step(c).push(cnew) + } + +} + +fn tst(ref p : &Node, c : usize) -> usize + where Node : Step { + let Node(i,_) = p.step(c); + i +} + + + +fn main() { + let nd : Node = Node(555,PhantomData::); + + // overflow...core::marker::Size + let Node(g,_) = tst(nd,1); + + // ok + //let Node(g,_) = nd.step(1); + + println!("{:?}", g); +} diff --git a/tests/crashes/92004.rs b/tests/crashes/92004.rs new file mode 100644 index 0000000000000..bc2ca2a7ba389 --- /dev/null +++ b/tests/crashes/92004.rs @@ -0,0 +1,70 @@ +//@ known-bug: #102310 +//@ compile-flags: -Copt-level=0 +//@ edition:2021 +// ignore-tidy-linelength + +use std::vec::Vec; +use std::iter::Peekable; + +pub fn main() { + let packet = decode(vec![1,0,1,0]); +} + +pub fn decode(bitstream: Vec) -> Packet { + let mut bitstream_itr = bitstream.into_iter().peekable(); + return match decode_packet(&mut bitstream_itr) { + Some(p) => p, + None => panic!("expected outer packet"), + } +} + +pub fn decode_packets>(itr: &mut Peekable) -> Vec { + let mut res = Vec::new(); + loop { + match decode_packet(itr) { + Some(p) => { res.push(p); }, + None => break + } + } + + return res; +} + +pub fn decode_packet>(itr: &mut Peekable) -> Option { + // get version digits + let version = extend_number(0, itr, 3)?; + let type_id = extend_number(0, itr, 3)?; + return operator_packet(version, type_id, itr); +} + +pub fn operator_packet>(version: u64, type_id: u64, itr: &mut Peekable) -> Option { + let p = OperatorPacket { + version: version, + type_id: type_id, + packets: decode_packets(&mut itr.take(0).peekable()), + }; + + return Some(Packet::Operator(p)); +} + +pub fn extend_number>(num: u64, itr: &mut Peekable, take: u64) -> Option { + let mut value = num; + for _ in 0..take { + value *= 2; + value += itr.next()?; + } + + return Some(value); +} + +#[derive(Debug)] +pub enum Packet { + Operator(OperatorPacket), +} + +#[derive(Debug)] +pub struct OperatorPacket { + version: u64, + type_id: u64, + packets: Vec +} diff --git a/tests/crashes/93182.rs b/tests/crashes/93182.rs new file mode 100644 index 0000000000000..f2e77c03533fa --- /dev/null +++ b/tests/crashes/93182.rs @@ -0,0 +1,29 @@ +//@ known-bug: #93182 +#![feature(generic_const_exprs)] + +// this causes an ICE!!! +pub const CONST: usize = 64; +pub trait Tr: Foo> {} + +// no ICE +// pub trait Digest: FromH<[u8; S]> {} + +struct St (); + +struct A ([u8; S]); + +pub trait Foo { + fn foo(_: T); +} + +impl Foo> for St { + fn foo(_: A) { + todo!() + } +} + +pub trait FooBar { + type Tr: Tr; +} + +pub fn main() {} diff --git a/tests/crashes/93237.rs b/tests/crashes/93237.rs new file mode 100644 index 0000000000000..c903e79a2e300 --- /dev/null +++ b/tests/crashes/93237.rs @@ -0,0 +1,18 @@ +//@ known-bug: #93237 +trait Trait { + type Assoc; +} +impl Trait for () { + type Assoc = (); +} + +macro_rules! m { + ([#$($t:tt)*] [$($open:tt)*] [$($close:tt)*]) => { + m!{[$($t)*][$($open)*$($open)*][$($close)*$($close)*]} + }; + ([] [$($open:tt)*] [$($close:tt)*]) => { + fn _f() -> $($open)*()$($close)* {} + }; +} + +m! {[###########][impl Trait]} diff --git a/tests/crashes/94846.rs b/tests/crashes/94846.rs new file mode 100644 index 0000000000000..9a3b26621d988 --- /dev/null +++ b/tests/crashes/94846.rs @@ -0,0 +1,6 @@ +//@ known-bug: #94846 +#![feature(generic_const_exprs)] + +struct S() where S<{}>:; + +pub fn main() {} diff --git a/tests/crashes/95134.rs b/tests/crashes/95134.rs new file mode 100644 index 0000000000000..bcd88b1076fd9 --- /dev/null +++ b/tests/crashes/95134.rs @@ -0,0 +1,27 @@ +//@ known-bug: #95134 +//@ compile-flags: -Copt-level=0 + +pub fn encode_num(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 EmptyWriter; + +impl ExampleWriter for EmptyWriter { + type Error = (); +} + +fn main() { + encode_num(69, &mut EmptyWriter).unwrap(); +} From 6d9175f98e78118dd2467f285b16663842be5b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 30 Mar 2024 00:41:57 +0100 Subject: [PATCH 11/13] crashes: fix ice detection which did not trigger if code compiled without error by accident --- src/tools/compiletest/src/runtest.rs | 16 ++++++++-------- tests/crashes/101557.rs | 1 + tests/crashes/111699.rs | 2 ++ tests/crashes/115435.rs | 2 ++ tests/crashes/118320.rs | 1 + tests/crashes/119692.rs | 1 + tests/crashes/120241-2.rs | 1 + tests/crashes/120241.rs | 1 + tests/crashes/120482.rs | 1 + tests/crashes/121444.rs | 2 ++ tests/crashes/123157.rs | 1 + tests/crashes/README.md | 2 +- 12 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 9b98e78b15b52..759b07abc6e80 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -364,13 +364,16 @@ impl<'test> TestCx<'test> { fn run_crash_test(&self) { let pm = self.pass_mode(); let proc_res = self.compile_test(WillExecute::No, self.should_emit_metadata(pm)); + /* + 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() { - match proc_res.status.code() { - Some(1 | 0) => self.fatal(&format!("test no longer crashes/triggers ICE! Please annotate it and add it as test to tests/ui or wherever you see fit")), - _ => (), - } + if proc_res.status.success() || matches!(proc_res.status.code(), Some(1 | 0)) { + self.fatal(&format!("test no longer crashes/triggers ICE! Please annotate it and add it as test to tests/ui or wherever you see fit")); } } @@ -2322,9 +2325,6 @@ impl<'test> TestCx<'test> { } let (Output { status, stdout, stderr }, truncated) = self.read2_abbreviated(child); - eprintln!("{:?}", status); - eprintln!("{}", String::from_utf8_lossy(&stdout).into_owned()); - eprintln!("{}", String::from_utf8_lossy(&stdout).into_owned()); let result = ProcRes { status, diff --git a/tests/crashes/101557.rs b/tests/crashes/101557.rs index da32660903e9e..a0290361ed1fe 100644 --- a/tests/crashes/101557.rs +++ b/tests/crashes/101557.rs @@ -1,4 +1,5 @@ //@ known-bug: #101557 +//@ compile-flags: -Copt-level=0 #![feature(generic_const_exprs)] use std::marker::PhantomData; diff --git a/tests/crashes/111699.rs b/tests/crashes/111699.rs index b3d12fb4a0bfd..5ba17c2aa1afc 100644 --- a/tests/crashes/111699.rs +++ b/tests/crashes/111699.rs @@ -1,4 +1,6 @@ //@ known-bug: #111699 +//@ edition:2021 +//@ compile-flags: -Copt-level=0 #![feature(core_intrinsics)] use std::intrinsics::offset; diff --git a/tests/crashes/115435.rs b/tests/crashes/115435.rs index c846c95961d7a..c6e749867e881 100644 --- a/tests/crashes/115435.rs +++ b/tests/crashes/115435.rs @@ -1,4 +1,6 @@ //@ known-bug: #115435 +//@ edition:2021 +//@ compile-flags: -Copt-level=0 trait MyTrait { type Target: ?Sized; } diff --git a/tests/crashes/118320.rs b/tests/crashes/118320.rs index 0f47c923e1058..093c58e1c05fb 100644 --- a/tests/crashes/118320.rs +++ b/tests/crashes/118320.rs @@ -1,4 +1,5 @@ //@ known-bug: #118320 +//@ edition:2021 #![feature(const_trait_impl, effects, const_closures)] #[const_trait] diff --git a/tests/crashes/119692.rs b/tests/crashes/119692.rs index 3b7457a7abe93..2e230f98d81d8 100644 --- a/tests/crashes/119692.rs +++ b/tests/crashes/119692.rs @@ -1,4 +1,5 @@ //@ known-bug: #119692 +//@ compile-flags: -Copt-level=0 #![allow(incomplete_features)] #![feature(adt_const_params)] #![feature(generic_const_exprs)] diff --git a/tests/crashes/120241-2.rs b/tests/crashes/120241-2.rs index c7044950211f7..9c4a3a50293e3 100644 --- a/tests/crashes/120241-2.rs +++ b/tests/crashes/120241-2.rs @@ -1,4 +1,5 @@ //@ known-bug: #120241 +//@ edition:2021 #![feature(object_safe_for_dispatch)] #![feature(unsized_fn_params)] diff --git a/tests/crashes/120241.rs b/tests/crashes/120241.rs index f19fdf1a902ce..f18347a006cb6 100644 --- a/tests/crashes/120241.rs +++ b/tests/crashes/120241.rs @@ -1,4 +1,5 @@ //@ known-bug: #120241 +//@ edition:2021 #![feature(object_safe_for_dispatch)] trait B { diff --git a/tests/crashes/120482.rs b/tests/crashes/120482.rs index 1045aeb19c8fe..6cbc2009c5f63 100644 --- a/tests/crashes/120482.rs +++ b/tests/crashes/120482.rs @@ -1,4 +1,5 @@ //@ known-bug: #120482 +//@ edition:2021 #![feature(object_safe_for_dispatch)] trait B { diff --git a/tests/crashes/121444.rs b/tests/crashes/121444.rs index 5a4289203ddb0..d3e5c3851296f 100644 --- a/tests/crashes/121444.rs +++ b/tests/crashes/121444.rs @@ -1,4 +1,6 @@ //@ known-bug: #121444 +//@ compile-flags: -Copt-level=0 +//@ edition:2021 #[repr(align(536870912))] pub struct A(i64); diff --git a/tests/crashes/123157.rs b/tests/crashes/123157.rs index 0c0721d02ec51..d6cc55ba0524e 100644 --- a/tests/crashes/123157.rs +++ b/tests/crashes/123157.rs @@ -1,4 +1,5 @@ //@ known-bug: #123157 +//@ edition:2021 #![feature(type_alias_impl_trait)] #[derive(Copy, Clone)] diff --git a/tests/crashes/README.md b/tests/crashes/README.md index 28346b26e3735..de25c6c13407a 100644 --- a/tests/crashes/README.md +++ b/tests/crashes/README.md @@ -4,7 +4,7 @@ the rustc testsuite is more convenient. It is imperative that a test in the suite causes an internal compiler error/panic or makes rustc crash in some other way. -Accepted exit codes are: 101 (may be expanded later) +A test will "pass" if rustc exits with something other than 1 or 0. When adding crashes from https://github.com/rust-lang/rust/issues, the issue number should be noted in the file name (12345.rs should suffice) From 37df49059dd1ba8039f12058ef590df6519e1a8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 13 Apr 2024 23:03:27 +0200 Subject: [PATCH 12/13] update README and add COMPILETEST_VERBOSE_CRASHES env var which when set print stdout, stderr and exit code of "crashes" tests, useful for debugging or adding new tests --- src/tools/compiletest/src/runtest.rs | 19 ++++++++++++------- tests/crashes/README.md | 5 ++++- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 759b07abc6e80..38d22fef11329 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -364,16 +364,21 @@ impl<'test> TestCx<'test> { fn run_crash_test(&self) { let pm = self.pass_mode(); let proc_res = self.compile_test(WillExecute::No, self.should_emit_metadata(pm)); - /* - eprintln!("{}", proc_res.status); - eprintln!("{}", proc_res.stdout); - eprintln!("{}", proc_res.stderr); - eprintln!("{}", proc_res.cmdline); - */ + + 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 annotate it and add it as test to tests/ui or wherever you see fit")); + 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." + )); } } diff --git a/tests/crashes/README.md b/tests/crashes/README.md index de25c6c13407a..dee11e2a3dd0f 100644 --- a/tests/crashes/README.md +++ b/tests/crashes/README.md @@ -10,4 +10,7 @@ When adding crashes from https://github.com/rust-lang/rust/issues, the issue number should be noted in the file name (12345.rs should suffice) and perhaps also inside the file via `//@ known-bug #4321` -If you happen to fix one of the crashes, please move it to `tests/ui`! :) +If you happen to fix one of the crashes, please move it to a fitting +subdirectory in `tests/ui` and give it a meaningful name. +Also please add a doc comment at the top of the file explaining why +this test exists. :) From 2ce487c45c0dab4abd37d6dcf88bdfb041c5b2a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 14 Apr 2024 15:44:17 +0200 Subject: [PATCH 13/13] crashes: limit a couple tests to only run on x86_64 and/or not on windows --- tests/crashes/113280.rs | 1 + tests/crashes/121444.rs | 2 ++ tests/crashes/123077-1.rs | 9 --------- tests/crashes/123077-2.rs | 1 + tests/crashes/23707.rs | 2 +- tests/crashes/34127.rs | 1 + 6 files changed, 6 insertions(+), 10 deletions(-) delete mode 100644 tests/crashes/123077-1.rs diff --git a/tests/crashes/113280.rs b/tests/crashes/113280.rs index 6a04b50c0c8d9..86677f416fe20 100644 --- a/tests/crashes/113280.rs +++ b/tests/crashes/113280.rs @@ -1,4 +1,5 @@ //@ known-bug: #113280 +//@ only-x86_64 #![feature(dyn_star, pointer_like_trait)] #![allow(incomplete_features)] diff --git a/tests/crashes/121444.rs b/tests/crashes/121444.rs index d3e5c3851296f..a6373a58c426e 100644 --- a/tests/crashes/121444.rs +++ b/tests/crashes/121444.rs @@ -1,6 +1,8 @@ //@ known-bug: #121444 //@ compile-flags: -Copt-level=0 //@ edition:2021 +//@ only-x86_64 +//@ ignore-windows #[repr(align(536870912))] pub struct A(i64); diff --git a/tests/crashes/123077-1.rs b/tests/crashes/123077-1.rs deleted file mode 100644 index 76e81f730f959..0000000000000 --- a/tests/crashes/123077-1.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ known-bug: #123077 -use std::arch::x86_64::{__m128, _mm_blend_ps}; - -pub fn sse41_blend_noinline( ) -> __m128 { - let f = { |x, y| unsafe { - _mm_blend_ps(x, y, { |x, y| unsafe }) - }}; - f(x, y) -} diff --git a/tests/crashes/123077-2.rs b/tests/crashes/123077-2.rs index d425625dfd9ad..e086e330337ab 100644 --- a/tests/crashes/123077-2.rs +++ b/tests/crashes/123077-2.rs @@ -1,4 +1,5 @@ //@ known-bug: #123077 +//@ only-x86_64 use std::arch::x86_64::{__m128, _mm_blend_ps}; pub fn sse41_blend_noinline( ) -> __m128 { diff --git a/tests/crashes/23707.rs b/tests/crashes/23707.rs index c8c373c31e24d..4105933c60f4b 100644 --- a/tests/crashes/23707.rs +++ b/tests/crashes/23707.rs @@ -1,6 +1,6 @@ //@ known-bug: #23707 //@ compile-flags: -Copt-level=0 --edition=2021 - +//@ only-x86_64 #![recursion_limit="2048"] use std::marker::PhantomData; diff --git a/tests/crashes/34127.rs b/tests/crashes/34127.rs index 82504486be56c..88a2cf30ec5d5 100644 --- a/tests/crashes/34127.rs +++ b/tests/crashes/34127.rs @@ -1,5 +1,6 @@ //@ compile-flags: -g -Copt-level=0 //@ known-bug: #34127 +//@ only-x86_64 pub fn main() { let _a = [(); 1 << 63];