Skip to content

Commit d733f9c

Browse files
committed
Auto merge of #125278 - GuillaumeGomez:rollup-z2hluri, r=GuillaumeGomez
Rollup of 3 pull requests Successful merges: - #125261 (crashes: add more) - #125270 (Followup fixes from #123344) - #125275 (Migrate `run-make/rustdoc-scrape-examples-test` to new `rmake.rs`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7d2a95b + 7b09243 commit d733f9c

File tree

18 files changed

+150
-17
lines changed

18 files changed

+150
-17
lines changed

compiler/rustc_ast/src/ast.rs

+7
Original file line numberDiff line numberDiff line change
@@ -2733,6 +2733,13 @@ pub enum UseTreeKind {
27332733
/// `use prefix` or `use prefix as rename`
27342734
Simple(Option<Ident>),
27352735
/// `use prefix::{...}`
2736+
///
2737+
/// The span represents the braces of the nested group and all elements within:
2738+
///
2739+
/// ```text
2740+
/// use foo::{bar, baz};
2741+
/// ^^^^^^^^^^
2742+
/// ```
27362743
Nested { items: ThinVec<(UseTree, NodeId)>, span: Span },
27372744
/// `use prefix::*`
27382745
Glob,

compiler/rustc_resolve/src/check_unused.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -299,21 +299,21 @@ fn calc_unused_spans(
299299

300300
let mut unused_spans = Vec::new();
301301
let mut to_remove = Vec::new();
302-
let mut used_childs = 0;
302+
let mut used_children = 0;
303303
let mut contains_self = false;
304304
let mut previous_unused = false;
305305
for (pos, (use_tree, use_tree_id)) in nested.iter().enumerate() {
306306
let remove = match calc_unused_spans(unused_import, use_tree, *use_tree_id) {
307307
UnusedSpanResult::Used => {
308-
used_childs += 1;
308+
used_children += 1;
309309
None
310310
}
311311
UnusedSpanResult::Unused { mut spans, remove } => {
312312
unused_spans.append(&mut spans);
313313
Some(remove)
314314
}
315315
UnusedSpanResult::PartialUnused { mut spans, remove: mut to_remove_extra } => {
316-
used_childs += 1;
316+
used_children += 1;
317317
unused_spans.append(&mut spans);
318318
to_remove.append(&mut to_remove_extra);
319319
None
@@ -322,7 +322,7 @@ fn calc_unused_spans(
322322
if let Some(remove) = remove {
323323
let remove_span = if nested.len() == 1 {
324324
remove
325-
} else if pos == nested.len() - 1 || used_childs > 0 {
325+
} else if pos == nested.len() - 1 || used_children > 0 {
326326
// Delete everything from the end of the last import, to delete the
327327
// previous comma
328328
nested[pos - 1].0.span.shrink_to_hi().to(use_tree.span)
@@ -346,7 +346,7 @@ fn calc_unused_spans(
346346
}
347347
if unused_spans.is_empty() {
348348
UnusedSpanResult::Used
349-
} else if used_childs == 0 {
349+
} else if used_children == 0 {
350350
UnusedSpanResult::Unused { spans: unused_spans, remove: full_span }
351351
} else {
352352
// If there is only one remaining child that is used, the braces around the use
@@ -360,7 +360,7 @@ fn calc_unused_spans(
360360
// `self`: `use foo::{self};` is valid Rust syntax, while `use foo::self;` errors
361361
// out. We also cannot turn `use foo::{self}` into `use foo`, as the former doesn't
362362
// import types with the same name as the module.
363-
if used_childs == 1 && !contains_self {
363+
if used_children == 1 && !contains_self {
364364
// Left brace, from the start of the nested group to the first item.
365365
to_remove.push(
366366
tree_span.shrink_to_lo().to(nested.first().unwrap().0.span.shrink_to_lo()),

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ run-make/rustc-macro-dep-files/Makefile
236236
run-make/rustdoc-io-error/Makefile
237237
run-make/rustdoc-scrape-examples-macros/Makefile
238238
run-make/rustdoc-scrape-examples-multiple/Makefile
239-
run-make/rustdoc-scrape-examples-test/Makefile
240239
run-make/rustdoc-scrape-examples-whitespace/Makefile
241240
run-make/rustdoc-verify-output-files/Makefile
242241
run-make/rustdoc-with-output-option/Makefile

tests/crashes/124833.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@ known-bug: rust-lang/rust#124833
2+
#![feature(generic_const_items)]
3+
4+
trait Trait {
5+
const C<'a>: &'a str;
6+
}
7+
8+
impl Trait for () {
9+
const C<'a>: = "C";
10+
}

tests/crashes/124857.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ known-bug: rust-lang/rust#124857
2+
//@ compile-flags: -Znext-solver=coherence
3+
4+
#![feature(effects)]
5+
6+
#[const_trait]
7+
trait Foo {}
8+
9+
impl const Foo for i32 {}
10+
11+
impl<T> const Foo for T where T: ~const Foo {}

tests/crashes/124891.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@ known-bug: rust-lang/rust#124891
2+
3+
type Tait = impl FnOnce() -> ();
4+
5+
fn reify_as_tait() -> Thunk<Tait> {
6+
Thunk::new(|cont| cont)
7+
}
8+
9+
struct Thunk<F>(F);
10+
11+
impl<F> Thunk<F> {
12+
fn new(f: F)
13+
where
14+
F: ContFn,
15+
{
16+
todo!();
17+
}
18+
}
19+
20+
trait ContFn {}
21+
22+
impl<F: FnOnce(Tait) -> ()> ContFn for F {}

tests/crashes/124894.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ known-bug: rust-lang/rust#124894
2+
//@ compile-flags: -Znext-solver=coherence
3+
4+
#![feature(generic_const_exprs)]
5+
6+
pub trait IsTrue<const mem: bool> {}
7+
impl<T> IsZST for T where (): IsTrue<{ std::mem::size_of::<T>() == 0 }> {}
8+
9+
pub trait IsZST {}
10+
11+
impl IsZST for IsZST {}

tests/crashes/125081.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//@ known-bug: rust-lang/rust#125081
2+
3+
use std::cell::Cell;
4+
5+
fn main() {
6+
let _: Cell<&str, "a"> = Cell::new('β);
7+
}

tests/crashes/125099.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//@ known-bug: rust-lang/rust#125099
2+
3+
pub trait ContFn<T>: Fn(T) -> Self::Future {
4+
type Future;
5+
}
6+
impl<T, F> ContFn<T> for F
7+
where
8+
F: Fn(T),
9+
{
10+
type Future = ();
11+
}
12+
13+
pub trait SeqHandler {
14+
type Requires;
15+
fn process<F: ContFn<Self::Requires>>() -> impl Sized;
16+
}
17+
18+
pub struct ConvertToU64;
19+
impl SeqHandler for ConvertToU64 {
20+
type Requires = u64;
21+
fn process<F: ContFn<Self::Requires>>() -> impl Sized {}
22+
}
23+
24+
fn main() {}

tests/crashes/125155.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@ known-bug: rust-lang/rust#125155
2+
3+
enum NestedEnum {
4+
First,
5+
Second,
6+
Third
7+
}
8+
enum Enum {
9+
Variant2(Option<*mut &'a &'b ()>)
10+
}
11+
12+
13+
fn foo(x: Enum) -> isize {
14+
match x {
15+
Enum::Variant2(NestedEnum::Third) => 4,
16+
}
17+
}

tests/crashes/125185.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ known-bug: rust-lang/rust#125185
2+
//@ compile-flags: -Zvalidate-mir
3+
4+
type Foo = impl Send;
5+
6+
struct A;
7+
8+
const VALUE: Foo = value();
9+
10+
fn test(foo: Foo<'a>, f: impl for<'b> FnMut()) {
11+
match VALUE {
12+
0 | 0 => {}
13+
14+
_ => (),
15+
}
16+
}

tests/crashes/125249.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ known-bug: rust-lang/rust#125185
2+
#![feature(return_position_impl_trait_in_trait, return_type_notation)]
3+
4+
trait IntFactory {
5+
fn stream(&self) -> impl IntFactory<stream(): IntFactory<stream(): Send> + Send>;
6+
}
7+
8+
pub fn main() {}

tests/run-make/rustdoc-scrape-examples-invalid-expr/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
mod scrape;
33

44
fn main() {
5-
scrape::scrape();
5+
scrape::scrape(&[]);
66
}

tests/run-make/rustdoc-scrape-examples-ordering/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
mod scrape;
33

44
fn main() {
5-
scrape::scrape();
5+
scrape::scrape(&[]);
66
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mod scrape;
22

33
fn main() {
4-
scrape::scrape();
4+
scrape::scrape(&[]);
55
}

tests/run-make/rustdoc-scrape-examples-remap/scrape.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use run_make_support::{htmldocck, rustc, rustdoc, source_path, tmp_dir};
22
use std::fs::read_dir;
33
use std::path::Path;
44

5-
pub fn scrape() {
5+
pub fn scrape(extra_args: &[&str]) {
66
let lib_dir = tmp_dir();
77
let out_dir = tmp_dir().join("rustdoc");
88
let crate_name = "foobar";
@@ -29,6 +29,7 @@ pub fn scrape() {
2929
.arg(&out_example)
3030
.arg("--scrape-examples-target-crate")
3131
.arg(crate_name)
32+
.args(extra_args)
3233
.run();
3334
out_deps.push(out_example);
3435
}

tests/run-make/rustdoc-scrape-examples-test/Makefile

-6
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#[path = "../rustdoc-scrape-examples-remap/scrape.rs"]
2+
mod scrape;
3+
4+
fn main() {
5+
scrape::scrape(&["--scrape-tests"]);
6+
}

0 commit comments

Comments
 (0)