From 734e216b35e3539994e090f0c293d8610c03dc88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 18 May 2024 23:56:57 +0200 Subject: [PATCH 1/4] crashes: add more --- tests/crashes/124833.rs | 10 ++++++++++ tests/crashes/124857.rs | 11 +++++++++++ tests/crashes/124891.rs | 22 ++++++++++++++++++++++ tests/crashes/124894.rs | 11 +++++++++++ tests/crashes/125081.rs | 7 +++++++ tests/crashes/125099.rs | 24 ++++++++++++++++++++++++ tests/crashes/125155.rs | 17 +++++++++++++++++ tests/crashes/125185.rs | 16 ++++++++++++++++ tests/crashes/125249.rs | 8 ++++++++ 9 files changed, 126 insertions(+) create mode 100644 tests/crashes/124833.rs create mode 100644 tests/crashes/124857.rs create mode 100644 tests/crashes/124891.rs create mode 100644 tests/crashes/124894.rs create mode 100644 tests/crashes/125081.rs create mode 100644 tests/crashes/125099.rs create mode 100644 tests/crashes/125155.rs create mode 100644 tests/crashes/125185.rs create mode 100644 tests/crashes/125249.rs diff --git a/tests/crashes/124833.rs b/tests/crashes/124833.rs new file mode 100644 index 0000000000000..f1c4847b544a5 --- /dev/null +++ b/tests/crashes/124833.rs @@ -0,0 +1,10 @@ +//@ known-bug: rust-lang/rust#124833 +#![feature(generic_const_items)] + +trait Trait { + const C<'a>: &'a str; +} + +impl Trait for () { + const C<'a>: = "C"; +} diff --git a/tests/crashes/124857.rs b/tests/crashes/124857.rs new file mode 100644 index 0000000000000..4b952fd64ccfb --- /dev/null +++ b/tests/crashes/124857.rs @@ -0,0 +1,11 @@ +//@ known-bug: rust-lang/rust#124857 +//@ compile-flags: -Znext-solver=coherence + +#![feature(effects)] + +#[const_trait] +trait Foo {} + +impl const Foo for i32 {} + +impl const Foo for T where T: ~const Foo {} diff --git a/tests/crashes/124891.rs b/tests/crashes/124891.rs new file mode 100644 index 0000000000000..9b5892418c897 --- /dev/null +++ b/tests/crashes/124891.rs @@ -0,0 +1,22 @@ +//@ known-bug: rust-lang/rust#124891 + +type Tait = impl FnOnce() -> (); + +fn reify_as_tait() -> Thunk { + Thunk::new(|cont| cont) +} + +struct Thunk(F); + +impl Thunk { + fn new(f: F) + where + F: ContFn, + { + todo!(); + } +} + +trait ContFn {} + +impl ()> ContFn for F {} diff --git a/tests/crashes/124894.rs b/tests/crashes/124894.rs new file mode 100644 index 0000000000000..230cf4a89c151 --- /dev/null +++ b/tests/crashes/124894.rs @@ -0,0 +1,11 @@ +//@ known-bug: rust-lang/rust#124894 +//@ compile-flags: -Znext-solver=coherence + +#![feature(generic_const_exprs)] + +pub trait IsTrue {} +impl IsZST for T where (): IsTrue<{ std::mem::size_of::() == 0 }> {} + +pub trait IsZST {} + +impl IsZST for IsZST {} diff --git a/tests/crashes/125081.rs b/tests/crashes/125081.rs new file mode 100644 index 0000000000000..7139caaa00df7 --- /dev/null +++ b/tests/crashes/125081.rs @@ -0,0 +1,7 @@ +//@ known-bug: rust-lang/rust#125081 + +use std::cell::Cell; + +fn main() { + let _: Cell<&str, "a"> = Cell::new('β); +} diff --git a/tests/crashes/125099.rs b/tests/crashes/125099.rs new file mode 100644 index 0000000000000..bfc8c8fdcf683 --- /dev/null +++ b/tests/crashes/125099.rs @@ -0,0 +1,24 @@ +//@ known-bug: rust-lang/rust#125099 + +pub trait ContFn: Fn(T) -> Self::Future { + type Future; +} +impl ContFn for F +where + F: Fn(T), +{ + type Future = (); +} + +pub trait SeqHandler { + type Requires; + fn process>() -> impl Sized; +} + +pub struct ConvertToU64; +impl SeqHandler for ConvertToU64 { + type Requires = u64; + fn process>() -> impl Sized {} +} + +fn main() {} diff --git a/tests/crashes/125155.rs b/tests/crashes/125155.rs new file mode 100644 index 0000000000000..165061d4b5296 --- /dev/null +++ b/tests/crashes/125155.rs @@ -0,0 +1,17 @@ +//@ known-bug: rust-lang/rust#125155 + +enum NestedEnum { + First, + Second, + Third +} +enum Enum { + Variant2(Option<*mut &'a &'b ()>) +} + + +fn foo(x: Enum) -> isize { + match x { + Enum::Variant2(NestedEnum::Third) => 4, + } +} diff --git a/tests/crashes/125185.rs b/tests/crashes/125185.rs new file mode 100644 index 0000000000000..8693d6c7662b2 --- /dev/null +++ b/tests/crashes/125185.rs @@ -0,0 +1,16 @@ +//@ known-bug: rust-lang/rust#125185 +//@ compile-flags: -Zvalidate-mir + +type Foo = impl Send; + +struct A; + +const VALUE: Foo = value(); + +fn test(foo: Foo<'a>, f: impl for<'b> FnMut()) { + match VALUE { + 0 | 0 => {} + + _ => (), + } +} diff --git a/tests/crashes/125249.rs b/tests/crashes/125249.rs new file mode 100644 index 0000000000000..18196d7b34fe8 --- /dev/null +++ b/tests/crashes/125249.rs @@ -0,0 +1,8 @@ +//@ known-bug: rust-lang/rust#125185 +#![feature(return_position_impl_trait_in_trait, return_type_notation)] + +trait IntFactory { + fn stream(&self) -> impl IntFactory + Send>; +} + +pub fn main() {} From 3ce9b2f95be2bf2c52d404a4b092566aeca3d9c5 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Sun, 19 May 2024 10:22:19 +0200 Subject: [PATCH 2/4] document what the span of UseTreeKind::Nested is --- compiler/rustc_ast/src/ast.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 5d37bbd689fe0..1a166956075c7 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -2733,6 +2733,13 @@ pub enum UseTreeKind { /// `use prefix` or `use prefix as rename` Simple(Option), /// `use prefix::{...}` + /// + /// The span represents the braces of the nested group and all elements within: + /// + /// ```text + /// use foo::{bar, baz}; + /// ^^^^^^^^^^ + /// ``` Nested { items: ThinVec<(UseTree, NodeId)>, span: Span }, /// `use prefix::*` Glob, From 5d03c3d3a5a16526fe9db57f7f022d3266e31ed1 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Sun, 19 May 2024 10:23:31 +0200 Subject: [PATCH 3/4] fix typo --- compiler/rustc_resolve/src/check_unused.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_resolve/src/check_unused.rs b/compiler/rustc_resolve/src/check_unused.rs index 5fe68085d6537..180e7f6def3a3 100644 --- a/compiler/rustc_resolve/src/check_unused.rs +++ b/compiler/rustc_resolve/src/check_unused.rs @@ -299,13 +299,13 @@ fn calc_unused_spans( let mut unused_spans = Vec::new(); let mut to_remove = Vec::new(); - let mut used_childs = 0; + let mut used_children = 0; let mut contains_self = false; let mut previous_unused = false; for (pos, (use_tree, use_tree_id)) in nested.iter().enumerate() { let remove = match calc_unused_spans(unused_import, use_tree, *use_tree_id) { UnusedSpanResult::Used => { - used_childs += 1; + used_children += 1; None } UnusedSpanResult::Unused { mut spans, remove } => { @@ -313,7 +313,7 @@ fn calc_unused_spans( Some(remove) } UnusedSpanResult::PartialUnused { mut spans, remove: mut to_remove_extra } => { - used_childs += 1; + used_children += 1; unused_spans.append(&mut spans); to_remove.append(&mut to_remove_extra); None @@ -322,7 +322,7 @@ fn calc_unused_spans( if let Some(remove) = remove { let remove_span = if nested.len() == 1 { remove - } else if pos == nested.len() - 1 || used_childs > 0 { + } else if pos == nested.len() - 1 || used_children > 0 { // Delete everything from the end of the last import, to delete the // previous comma nested[pos - 1].0.span.shrink_to_hi().to(use_tree.span) @@ -346,7 +346,7 @@ fn calc_unused_spans( } if unused_spans.is_empty() { UnusedSpanResult::Used - } else if used_childs == 0 { + } else if used_children == 0 { UnusedSpanResult::Unused { spans: unused_spans, remove: full_span } } else { // If there is only one remaining child that is used, the braces around the use @@ -360,7 +360,7 @@ fn calc_unused_spans( // `self`: `use foo::{self};` is valid Rust syntax, while `use foo::self;` errors // out. We also cannot turn `use foo::{self}` into `use foo`, as the former doesn't // import types with the same name as the module. - if used_childs == 1 && !contains_self { + if used_children == 1 && !contains_self { // Left brace, from the start of the nested group to the first item. to_remove.push( tree_span.shrink_to_lo().to(nested.first().unwrap().0.span.shrink_to_lo()), From 2f8b98c6643c3c1ad94942d54559fbbf1dd16b78 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 19 May 2024 14:00:12 +0200 Subject: [PATCH 4/4] Migrate `run-make/rustdoc-scrape-examples-test` to new `rmake.rs` --- src/tools/tidy/src/allowed_run_make_makefiles.txt | 1 - .../run-make/rustdoc-scrape-examples-invalid-expr/rmake.rs | 2 +- tests/run-make/rustdoc-scrape-examples-ordering/rmake.rs | 2 +- tests/run-make/rustdoc-scrape-examples-remap/rmake.rs | 2 +- tests/run-make/rustdoc-scrape-examples-remap/scrape.rs | 3 ++- tests/run-make/rustdoc-scrape-examples-test/Makefile | 6 ------ tests/run-make/rustdoc-scrape-examples-test/rmake.rs | 6 ++++++ 7 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 tests/run-make/rustdoc-scrape-examples-test/Makefile create mode 100644 tests/run-make/rustdoc-scrape-examples-test/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index d1ae24007b3d8..e08d7ff046d86 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -236,7 +236,6 @@ run-make/rustc-macro-dep-files/Makefile run-make/rustdoc-io-error/Makefile run-make/rustdoc-scrape-examples-macros/Makefile run-make/rustdoc-scrape-examples-multiple/Makefile -run-make/rustdoc-scrape-examples-test/Makefile run-make/rustdoc-scrape-examples-whitespace/Makefile run-make/rustdoc-verify-output-files/Makefile run-make/rustdoc-with-output-option/Makefile diff --git a/tests/run-make/rustdoc-scrape-examples-invalid-expr/rmake.rs b/tests/run-make/rustdoc-scrape-examples-invalid-expr/rmake.rs index 537d3e2d724a5..e9c54fa392237 100644 --- a/tests/run-make/rustdoc-scrape-examples-invalid-expr/rmake.rs +++ b/tests/run-make/rustdoc-scrape-examples-invalid-expr/rmake.rs @@ -2,5 +2,5 @@ mod scrape; fn main() { - scrape::scrape(); + scrape::scrape(&[]); } diff --git a/tests/run-make/rustdoc-scrape-examples-ordering/rmake.rs b/tests/run-make/rustdoc-scrape-examples-ordering/rmake.rs index 537d3e2d724a5..e9c54fa392237 100644 --- a/tests/run-make/rustdoc-scrape-examples-ordering/rmake.rs +++ b/tests/run-make/rustdoc-scrape-examples-ordering/rmake.rs @@ -2,5 +2,5 @@ mod scrape; fn main() { - scrape::scrape(); + scrape::scrape(&[]); } diff --git a/tests/run-make/rustdoc-scrape-examples-remap/rmake.rs b/tests/run-make/rustdoc-scrape-examples-remap/rmake.rs index d9deaf279ce52..4e3b895aef0c4 100644 --- a/tests/run-make/rustdoc-scrape-examples-remap/rmake.rs +++ b/tests/run-make/rustdoc-scrape-examples-remap/rmake.rs @@ -1,5 +1,5 @@ mod scrape; fn main() { - scrape::scrape(); + scrape::scrape(&[]); } diff --git a/tests/run-make/rustdoc-scrape-examples-remap/scrape.rs b/tests/run-make/rustdoc-scrape-examples-remap/scrape.rs index 709388b549214..563e3aca9aed6 100644 --- a/tests/run-make/rustdoc-scrape-examples-remap/scrape.rs +++ b/tests/run-make/rustdoc-scrape-examples-remap/scrape.rs @@ -2,7 +2,7 @@ use run_make_support::{htmldocck, rustc, rustdoc, source_path, tmp_dir}; use std::fs::read_dir; use std::path::Path; -pub fn scrape() { +pub fn scrape(extra_args: &[&str]) { let lib_dir = tmp_dir(); let out_dir = tmp_dir().join("rustdoc"); let crate_name = "foobar"; @@ -29,6 +29,7 @@ pub fn scrape() { .arg(&out_example) .arg("--scrape-examples-target-crate") .arg(crate_name) + .args(extra_args) .run(); out_deps.push(out_example); } diff --git a/tests/run-make/rustdoc-scrape-examples-test/Makefile b/tests/run-make/rustdoc-scrape-examples-test/Makefile deleted file mode 100644 index 1235ead675156..0000000000000 --- a/tests/run-make/rustdoc-scrape-examples-test/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -extra_flags := --scrape-tests -deps := ex - -include ../rustdoc-scrape-examples-multiple/scrape.mk - -all: scrape diff --git a/tests/run-make/rustdoc-scrape-examples-test/rmake.rs b/tests/run-make/rustdoc-scrape-examples-test/rmake.rs new file mode 100644 index 0000000000000..f96ba113ff730 --- /dev/null +++ b/tests/run-make/rustdoc-scrape-examples-test/rmake.rs @@ -0,0 +1,6 @@ +#[path = "../rustdoc-scrape-examples-remap/scrape.rs"] +mod scrape; + +fn main() { + scrape::scrape(&["--scrape-tests"]); +}