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

rust spent 10 minutes trying to suggest typos #110723

Open
matthiaskrgr opened this issue Apr 23, 2023 · 0 comments
Open

rust spent 10 minutes trying to suggest typos #110723

matthiaskrgr opened this issue Apr 23, 2023 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Path resolution I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

enum A<A> {
    A(A),
    A { C: A },
}

// Make sure that we aren't using `self::` in paths, since it doesn't work in
// non-module scopes.
const A: () = {
    #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
    struct A<A: A>(B)
    where
        A: A<
            {
                #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Hash)]
                struct A<A> {
                    A: A,
                }

                #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
                struct A<
                    A: A<
                        {
                            #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
                            struct A<A: A>(B)
                            where
                                A: A<
                                    {
                                        #[derive(
                                            Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash,
                                        )]
                                        struct A<
                                            A: A<
                                                {
                                                    #[derive(
                                                        Copy,
                                                        Clone,
                                                        PartialEq,
                                                        Eq,
                                                        PartialOrd,
                                                        Ord,
                                                        Debug,
                                                        Hash,
                                                    )]
                                                    struct A<A: A>(B)
                                                    where
                                                        A: A<{ continue }>;
                                                },
                                            >,
                                        >(B)
                                        where
                                            A: A<{ continue }>;
                                    },
                                >;

                            #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
                            enum A<A> {
                                A(),
                                A { A: A },
                            }
                        },
                    >,
                >(B)
                where
                    A: A<{ continue }>;
            },
        >;
};
time:   0.001; rss:   45MB ->   49MB (   +4MB)	parse_crate
time:   0.000; rss:   49MB ->   53MB (   +4MB)	setup_global_ctxt
error[E0428]: the name `A` is defined multiple times
 --> 894ADFAEF56FD5BE3968F44425D02AB0BFB037BD9F3CC014F7CF27D10A73C642.rs:5:5
  |
4 |     A(A),
  |     ---- previous definition of the type `A` here
5 |     A { C: A },
  |     ^ `A` redefined here
  |
  = note: `A` must be defined only once in the type namespace of this enum

error[E0428]: the name `A` is defined multiple times
  --> 894ADFAEF56FD5BE3968F44425D02AB0BFB037BD9F3CC014F7CF27D10A73C642.rs:22:17
   |
17 |                   struct A<A> {
   |                   ----------- previous definition of the type `A` here
...
22 | /                 struct A<
23 | |                     A: A<
24 | |                         {
25 | |                             #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
...  |
65 | |                 where
66 | |                     A: A<{ continue }>;
   | |_______________________________________^ `A` redefined here
   |
   = note: `A` must be defined only once in the type namespace of this block

error[E0428]: the name `A` is defined multiple times
  --> 894ADFAEF56FD5BE3968F44425D02AB0BFB037BD9F3CC014F7CF27D10A73C642.rs:58:29
   |
26 | / ...                   struct A<A: A>(B)
27 | | ...                   where
28 | | ...                       A: A<
29 | | ...                           {
...  |
54 | | ...                           },
55 | | ...                       >;
   | |____________________________- previous definition of the type `A` here
...
58 |   ...                   enum A<A> {
   |                         ^^^^^^^^^ `A` redefined here
   |
   = note: `A` must be defined only once in the type namespace of this block

error[E0428]: the name `A` is defined multiple times
  --> 894ADFAEF56FD5BE3968F44425D02AB0BFB037BD9F3CC014F7CF27D10A73C642.rs:60:33
   |
59 | ...                   A(),
   |                       --- previous definition of the type `A` here
60 | ...                   A { A: A },
   |                       ^ `A` redefined here
   |
   = note: `A` must be defined only once in the type namespace of this enum

time:   8.261; rss:   53MB -> 1032MB ( +978MB)	expand_crate
time:   8.261; rss:   53MB -> 1032MB ( +978MB)	macro_expand_crate
time:   1.143; rss: 1032MB -> 1028MB (   -4MB)	AST_validation
time:   0.010; rss: 1028MB -> 1028MB (   +0MB)	check_reexport_ambiguities
time:   0.585; rss: 1028MB -> 1038MB (  +10MB)	finalize_macro_resolutions

This probably generates massive amount of code hence the 50mb -> 1gb blowup.
After these lines, it looks like rustc hangs while it spends a lot of time (I killed it after 10 minutes of waiting) inside

  29,39%  librustc_driver-e9ace2a97781a33e.so             [.] <rustc_resolve::Resolver>::add_module_candidates::<&<rustc_resolve::late::LateResolutionVisitor>::suggest_typo::{closure#0}>
  27,42%  librustc_driver-e9ace2a97781a33e.so             [.] <rustc_resolve::Resolver>::add_module_candidates::<&<rustc_resolve::late::LateResolutionVisitor>::try_lookup_name_relaxed::{closure#0}>
  13,17%  librustc_driver-e9ace2a97781a33e.so             [.] <rustc_resolve::Resolver>::lookup_import_candidates_from_module::<&&<rustc_resolve::late::LateResolutionVisitor>::try_lookup_name_relaxed::{closure#0}>
   1,27%  librustc_driver-e9ace2a97781a33e.so             [.] <rustc_resolve::ModuleData>::nearest_parent_mod
   1,09%  librustc_driver-e9ace2a97781a33e.so             [.] <rustc_resolve::Resolver>::lookup_import_candidates_from_module::<&&<rustc_resolve::late::LateResolutionVisitor>::try_lookup_name_relaxed::{closure#1}>
@matthiaskrgr matthiaskrgr added I-slow Issue: Problems and improvements with respect to performance of generated code. A-diagnostics Area: Messages for errors, warnings, and lints I-compiletime Issue: Problems and improvements with respect to compile times. labels Apr 23, 2023
@WaffleLapkin WaffleLapkin added the A-resolve Area: Path resolution label Apr 23, 2023
@jyn514 jyn514 added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed I-slow Issue: Problems and improvements with respect to performance of generated code. labels Apr 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Path resolution I-compiletime Issue: Problems and improvements with respect to compile times. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants