Skip to content

Rollup of 3 pull requests #125278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2733,6 +2733,13 @@ pub enum UseTreeKind {
/// `use prefix` or `use prefix as rename`
Simple(Option<Ident>),
/// `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,
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_resolve/src/check_unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,21 +299,21 @@ 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 } => {
unused_spans.append(&mut 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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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()),
Expand Down
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions tests/crashes/124833.rs
Original file line number Diff line number Diff line change
@@ -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";
}
11 changes: 11 additions & 0 deletions tests/crashes/124857.rs
Original file line number Diff line number Diff line change
@@ -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<T> const Foo for T where T: ~const Foo {}
22 changes: 22 additions & 0 deletions tests/crashes/124891.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//@ known-bug: rust-lang/rust#124891

type Tait = impl FnOnce() -> ();

fn reify_as_tait() -> Thunk<Tait> {
Thunk::new(|cont| cont)
}

struct Thunk<F>(F);

impl<F> Thunk<F> {
fn new(f: F)
where
F: ContFn,
{
todo!();
}
}

trait ContFn {}

impl<F: FnOnce(Tait) -> ()> ContFn for F {}
11 changes: 11 additions & 0 deletions tests/crashes/124894.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@ known-bug: rust-lang/rust#124894
//@ compile-flags: -Znext-solver=coherence

#![feature(generic_const_exprs)]

pub trait IsTrue<const mem: bool> {}
impl<T> IsZST for T where (): IsTrue<{ std::mem::size_of::<T>() == 0 }> {}

pub trait IsZST {}

impl IsZST for IsZST {}
7 changes: 7 additions & 0 deletions tests/crashes/125081.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//@ known-bug: rust-lang/rust#125081

use std::cell::Cell;

fn main() {
let _: Cell<&str, "a"> = Cell::new('β);
}
24 changes: 24 additions & 0 deletions tests/crashes/125099.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//@ known-bug: rust-lang/rust#125099

pub trait ContFn<T>: Fn(T) -> Self::Future {
type Future;
}
impl<T, F> ContFn<T> for F
where
F: Fn(T),
{
type Future = ();
}

pub trait SeqHandler {
type Requires;
fn process<F: ContFn<Self::Requires>>() -> impl Sized;
}

pub struct ConvertToU64;
impl SeqHandler for ConvertToU64 {
type Requires = u64;
fn process<F: ContFn<Self::Requires>>() -> impl Sized {}
}

fn main() {}
17 changes: 17 additions & 0 deletions tests/crashes/125155.rs
Original file line number Diff line number Diff line change
@@ -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,
}
}
16 changes: 16 additions & 0 deletions tests/crashes/125185.rs
Original file line number Diff line number Diff line change
@@ -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 => {}

_ => (),
}
}
8 changes: 8 additions & 0 deletions tests/crashes/125249.rs
Original file line number Diff line number Diff line change
@@ -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<stream(): IntFactory<stream(): Send> + Send>;
}

pub fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
mod scrape;

fn main() {
scrape::scrape();
scrape::scrape(&[]);
}
2 changes: 1 addition & 1 deletion tests/run-make/rustdoc-scrape-examples-ordering/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
mod scrape;

fn main() {
scrape::scrape();
scrape::scrape(&[]);
}
2 changes: 1 addition & 1 deletion tests/run-make/rustdoc-scrape-examples-remap/rmake.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod scrape;

fn main() {
scrape::scrape();
scrape::scrape(&[]);
}
3 changes: 2 additions & 1 deletion tests/run-make/rustdoc-scrape-examples-remap/scrape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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);
}
Expand Down
6 changes: 0 additions & 6 deletions tests/run-make/rustdoc-scrape-examples-test/Makefile

This file was deleted.

6 changes: 6 additions & 0 deletions tests/run-make/rustdoc-scrape-examples-test/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#[path = "../rustdoc-scrape-examples-remap/scrape.rs"]
mod scrape;

fn main() {
scrape::scrape(&["--scrape-tests"]);
}
Loading