Skip to content
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

very slow type_check_crate stage after error is already thrown #109023

Open
matthiaskrgr opened this issue Mar 11, 2023 · 1 comment
Open

very slow type_check_crate stage after error is already thrown #109023

matthiaskrgr opened this issue Mar 11, 2023 · 1 comment
Labels
I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. I-compiletime Issue: Problems and improvements with respect to compile times.

Comments

@matthiaskrgr
Copy link
Member

// check-pass

pub fn yes_vec_partial_eq_array<A, B>() -> impl
where
    A: PartialEq<B>,
{
    Vec::<A>::new()
}

pub fn yes_vec_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 32]>
where
    A: PartialEq<B>,
{
    Vec::<&'a mut [B; 32]>::new()
}

pub fn yes_array_into_vec<T>() -> Vec<T> {
    [].into()
}

pub fn yes_array_into_box<T>() -> Box<[T]> {
    []
}

use std::collections::VecDeque;

pub fn yes_vecdeque_partial_eq_array<A, B>() -> impl PartialEq<B>
where
    A: PartialEq<B>,
{
    VecDeque   ::<&'a mut [B; 32]>::new()
}

pub fn yes_vecdeque_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 32]>
where
    A: PartialEq<B>,
{
    VecDeque::<&'a mut [B; 32]>::new()
}

pub fn yes_vecdeque_partial_eq_ref_mut_array<'a, A, B>() -> impl PartialEq<&'a mut [B; 32]>
where
    A: PartialEq<[B; 32]>,
{
    VecDeque::<&'a mut [B; 32]>::new()
}

fn main() {}

Ztime-passes output

time:   0.001; rss:   45MB ->   49MB (   +4MB)	parse_crate
time:   0.004; rss:   53MB ->   69MB (  +16MB)	expand_crate
time:   0.004; rss:   53MB ->   69MB (  +16MB)	macro_expand_crate
error: at least one trait must be specified
 --> /home/matthias/vcs/github/rust6_omni/74/747e8d427cd8043eab8193a8549a36a531ad0563.rs:3:44
  |
3 | pub fn yes_vec_partial_eq_array<A, B>() -> impl
  |                                            ^^^^

time:   0.005; rss:   69MB ->   73MB (   +4MB)	AST_validation
error[E0261]: use of undeclared lifetime name `'a`
  --> /home/matthias/vcs/github/rust6_omni/74/747e8d427cd8043eab8193a8549a36a531ad0563.rs:31:20
   |
27 | pub fn yes_vecdeque_partial_eq_array<A, B>() -> impl PartialEq<B>
   |                                      - help: consider introducing lifetime `'a` here: `'a,`
...
31 |     VecDeque   ::<&'a mut [B; 32]>::new()
   |                    ^^ undeclared lifetime

time:   0.001; rss:   73MB ->   76MB (   +3MB)	late_resolve_crate
time:   0.002; rss:   73MB ->   76MB (   +3MB)	resolve_crate
time:   0.001; rss:   76MB ->   80MB (   +4MB)	misc_checking_1
time:   0.001; rss:   80MB ->   85MB (   +4MB)	wf_checking
error[E0277]: can't compare `&mut [B; 32]` with `B`
  --> /home/matthias/vcs/github/rust6_omni/74/747e8d427cd8043eab8193a8549a36a531ad0563.rs:10:52
   |
10 | pub fn yes_vec_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 32]>
   |                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `&mut [B; 32] == B`
   |
   = help: the trait `PartialEq<B>` is not implemented for `&mut [B; 32]`
   = note: required for `Vec<&mut [B; 32]>` to implement `PartialEq<&'a [B; 32]>`
help: consider extending the `where` clause, but there might be an alternative better way to express this requirement
   |
12 |     A: PartialEq<B>, &mut [B; 32]: PartialEq<B>
   |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0277]: can't compare `VecDeque<&mut [B; 32]>` with `B`
  --> /home/matthias/vcs/github/rust6_omni/74/747e8d427cd8043eab8193a8549a36a531ad0563.rs:27:49
   |
27 | pub fn yes_vecdeque_partial_eq_array<A, B>() -> impl PartialEq<B>
   |                                                 ^^^^^^^^^^^^^^^^^ no implementation for `VecDeque<&mut [B; 32]> == B`
...
31 |     VecDeque   ::<&'a mut [B; 32]>::new()
   |     ------------------------------------- return type was inferred to be `VecDeque<&mut [B; 32]>` here
   |
   = help: the trait `PartialEq<B>` is not implemented for `VecDeque<&mut [B; 32]>`
help: consider extending the `where` clause, but there might be an alternative better way to express this requirement
   |
29 |     A: PartialEq<B>, VecDeque<&mut [B; 32]>: PartialEq<B>
   |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0277]: can't compare `&mut [B; 32]` with `B`
  --> /home/matthias/vcs/github/rust6_omni/74/747e8d427cd8043eab8193a8549a36a531ad0563.rs:34:57
   |
34 | pub fn yes_vecdeque_partial_eq_ref_array<'a, A, B>() -> impl PartialEq<&'a [B; 32]>
   |                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `&mut [B; 32] == B`
   |
   = help: the trait `PartialEq<B>` is not implemented for `&mut [B; 32]`
   = note: required for `VecDeque<&mut [B; 32]>` to implement `PartialEq<&'a [B; 32]>`
help: consider extending the `where` clause, but there might be an alternative better way to express this requirement
   |
36 |     A: PartialEq<B>, &mut [B; 32]: PartialEq<B>
   |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0277]: can't compare `&mut [B; 32]` with `B`
  --> /home/matthias/vcs/github/rust6_omni/74/747e8d427cd8043eab8193a8549a36a531ad0563.rs:41:61
   |
41 | pub fn yes_vecdeque_partial_eq_ref_mut_array<'a, A, B>() -> impl PartialEq<&'a mut [B; 32]>
   |                                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `&mut [B; 32] == B`
   |
   = help: the trait `PartialEq<B>` is not implemented for `&mut [B; 32]`
   = note: required for `VecDeque<&mut [B; 32]>` to implement `PartialEq<&'a mut [B; 32]>`
help: consider extending the `where` clause, but there might be an alternative better way to express this requirement
   |
43 |     A: PartialEq<[B; 32]>, &mut [B; 32]: PartialEq<B>
   |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

time: 120.775; rss:   85MB -> 2445MB (+2360MB)	item_types_checking
error[E0308]: mismatched types
  --> /home/matthias/vcs/github/rust6_omni/74/747e8d427cd8043eab8193a8549a36a531ad0563.rs:22:5
   |
21 | pub fn yes_array_into_box<T>() -> Box<[T]> {
   |                                   -------- expected `Box<[T]>` because of return type
22 |     []
   |     ^^ expected `Box<[T]>`, found `[_; 0]`
   |
   = note: expected struct `Box<[T]>`
               found array `[_; 0]`
   = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
help: store this in the heap by calling `Box::new`
   |
22 |     Box::new([])
   |     +++++++++  +

time:   0.007; rss: 2445MB -> 2455MB (  +10MB)	item_bodies_checking
time: 120.784; rss:   80MB -> 2455MB (+2375MB)	type_check_crate
time:   0.093; rss: 2455MB ->  230MB (-2225MB)	free_global_ctxt
error: aborting due to 7 previous errors

Some errors have detailed explanations: E0261, E0277, E0308.
For more information about an error, try `rustc --explain E0261`.
time: 120.907; rss:   35MB ->   97MB (  +63MB)	total

rustc keeps crunching on it, probably to get further diagnostics. Also note the almost 2.5 gb of memory needed, probably some recursive blowup? 🤔

@matthiaskrgr matthiaskrgr added I-compiletime Issue: Problems and improvements with respect to compile times. I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. labels Mar 11, 2023
@compiler-errors
Copy link
Member

I think this is a dupe of #104225

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. I-compiletime Issue: Problems and improvements with respect to compile times.
Projects
None yet
Development

No branches or pull requests

2 participants