about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2021-01-10Auto merge of #80782 - petrochenkov:viscopes, r=matthewjasperbors-18/+29
resolve: Scope visiting doesn't need an `Ident` Resolution scope visitor (`fn visit_scopes`) currently takes an `Ident` parameter, but it doesn't need a full identifier, or even its span, it only needs the `SyntaxContext` part. The `SyntaxContext` part is necessary because scope visitor has to jump to macro definition sites, so it has to be directed by macro expansion information somehow. I think it's clearer to pass only the necessary part. Yes, usually visiting happens as a part of an identifier resolution, but in cases like collecting traits in scope (#80765) or collecting typo suggestions that's not the case. r? `@matthewjasper`
2021-01-10resolve: Simplify built-in macro tableVadim Petrochenkov-2/+2
2021-01-10Rollup merge of #80850 - m-ou-se:rustc-builtin-macro-name, r=petrochenkovYuki Okushi-2/+2
Allow #[rustc_builtin_macro = "name"] This adds the option of specifying the name of a builtin macro in the `#[rustc_builtin_macro]` attribute: `#[rustc_builtin_macro = "name"]`. This makes it possible to have both `std::panic!` and `core::panic!` as a builtin macro, by using different builtin macro names for each. This is needed to implement the edition-specific behaviour of the panic macros of RFC 3007. Also removes `SyntaxExtension::is_derive_copy`, as the macro name (e.g. `sym::Copy`) is now tracked and provides that information directly. r? ``@petrochenkov``
2021-01-09Allow #[rustc_builtin_macro = "name"].Mara Bos-2/+2
This makes it possible to have both std::panic and core::panic as a builtin macro, by using different builtin macro names for each. Also removes SyntaxExtension::is_derive_copy, as the macro name (e.g. sym::Copy) is now tracked and provides that information directly.
2021-01-07Use correct span for structured suggestionEsteban Küber-8/+13
On structured suggestion for `let` -> `const` and `const` -> `let`, use a proper `Span` and update tests to check the correct application. Follow up to #80012.
2021-01-08Rollup merge of #80012 - sasurau4:feature/point-constant-identifier-E0435, ↵Yuki Okushi-8/+32
r=petrochenkov Add pointing const identifier when emitting E0435 Fix #79919
2021-01-07resolve: Scope visiting doesn't need an `Ident`Vadim Petrochenkov-18/+29
2021-01-07Add pointing const identifier when emitting E0435Daiki Ihara-8/+32
2021-01-06Rename to `nearest_parent_mod`Camelid-17/+25
* Rename `ModuleData.normal_ancestor_id` to `nearest_parent_mod` `normal_ancestor_id` is a very confusing name if you don't already understand what it means. Adding docs helps, but using a clearer and more obvious name is also important. * Rename `Resolver::nearest_mod_parent` to `nearest_parent_mod` * Add more docs
2021-01-06Document `ModuleData`Camelid-6/+14
* Convert comments on fields to doc comments so they're visible in API docs * Add new documentation * Get rid of "normal module" terminology
2021-01-01adjust const generics defaults FIXMEs to the new feature gateRémy Rakic-1/+1
2020-12-30Rollup merge of #80495 - jyn514:rename-empty, r=petrochenkovMara Bos-3/+3
Rename kw::Invalid -> kw::Empty See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20there.20a.20symbol.20for.20the.20empty.20string.3F/near/220054471 for context. r? `@petrochenkov`
2020-12-30Rename kw::Invalid -> kw::EmptyJoshua Nelson-3/+3
See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20there.20a.20symbol.20for.20the.20empty.20string.3F/near/220054471 for context.
2020-12-30remove unused return types such as empty Results or Options that would ↵Matthias Krüger-8/+7
always be Some(..) remove unused return type of dropck::check_drop_obligations() don't wrap return type in Option in get_macro_by_def_id() since we would always return Some(..) remove redundant return type of back::write::optimize() don't Option-wrap return type of compute_type_parameters() since we always return Some(..) don't return empty Result in assemble_generator_candidates() don't return empty Result in assemble_closure_candidates() don't return empty result in assemble_fn_pointer_candidates() don't return empty result in assemble_candidates_from_impls() don't return empty result in assemble_candidates_from_auto_impls() don't return emtpy result in assemble_candidates_for_trait_alias() don't return empty result in assemble_builtin_bound_candidates() don't return empty results in assemble_extension_candidates_for_traits_in_scope() and assemble_extension_candidates_for_trait() remove redundant wrapping of return type of StripItem::strip() since it always returns Some(..) remove unused return type of assemble_extension_candidates_for_all_traits()
2020-12-27rustc_span: Remove `Symbol::with`Vadim Petrochenkov-1/+4
2020-12-26stabilize min_const_genericsBastian Kauschke-2/+10
2020-12-12Resolve enum field visibility correctlyCamelid-0/+1
Previously, this code treated enum fields' visibility as if they were struct fields. However, that's not correct because the visibility of a struct field with `ast::VisibilityKind::Inherited` is private to the module it's defined in, whereas the visibility of an *enum* field with `ast::VisibilityKind::Inherited` is the visibility of the enum it belongs to.
2020-11-20const_generics: assert resolve hack causes an errorBastian Kauschke-0/+5
2020-11-14rustc_resolve: Make `macro_rules` scope chain compression lazyVadim Petrochenkov-10/+17
2020-11-13Auto merge of #78826 - petrochenkov:mrscopes2, r=eddybbors-14/+23
resolve: Collapse `macro_rules` scope chains on the fly Otherwise they grow too long and you have to endlessly walk through them when resolving macros or imports. Addresses https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/Slow.20Builtin.20Derives/near/215750815
2020-11-08rustc_resolve: Use `#![feature(format_args_capture)]`Vadim Petrochenkov-0/+1
2020-11-07resolve: Collapse `macro_rules` scope chains on the flyVadim Petrochenkov-14/+23
2020-10-30Fix even more clippy warningsJoshua Nelson-50/+30
2020-10-28[resolve] Use `unwrap_or_else` instead of `unwrap_or` in a hot pathWesley Wiser-4/+3
This improves the performance of the `resolve_crate` function by 30% for a very large single file crate with auto-generated C bindings.
2020-10-22Auto merge of #78134 - bugadani:arena-nodrop, r=lcnrbors-7/+5
Use `DroplessArena` where we know the type doesn't need drop This PR uses a single `DroplessArena` in resolve instead of three separate `TypedArena`s. `DroplessArena` checks that the type indeed doesn't need drop, so in case the types change, this will result in visible failures.
2020-10-20Resolve: Use dropless arena for types that don't need dropDániel Buga-7/+5
2020-10-19Calculate visibilities once in resolveVadim Petrochenkov-9/+16
Then use them through a query based on resolver outputs
2020-10-17resolve: Do not put nonexistent crate `meta` into preludeVadim Petrochenkov-3/+0
2020-10-11`min_const_generics` diagnostics improvementsEthan Brierley-1/+1
2 3
2020-10-03Replace "non trivial" with "non-trivial"varkor-1/+1
2020-09-23/nightly/nightly-rustcErik Hofmayer-1/+1
2020-09-23Updated html_root_url for compiler cratesErik Hofmayer-1/+1
2020-09-20use if let instead of single match arm expressions to compact code and ↵Matthias Krüger-5/+2
reduce nesting (clippy::single_match)
2020-09-15This commit introduces the following changes:Hameer Abbasi-5/+9
* Change error message for type param in a const expression when using min_const_generics * Change ParamInNonTrivialAnonConst to contain an extra bool used for distinguishing whether the passed-in symbol is a type or a value.
2020-09-13review, improve note spanBastian Kauschke-18/+16
2020-09-13allow concrete self types in constsBastian Kauschke-9/+20
2020-09-11Auto merge of #76499 - guswynn:priv_des, r=petrochenkovbors-1/+6
Give better diagnostic when using a private tuple struct constructor Fixes #75907 Some notes: 1. This required some deep changes, including removing a Copy impl for PatKind. If some tests fail, I would still appreciate review on the overall approach 2. this only works with basic patterns (no wildcards for example), and fails if there is any problems getting the visibility of the fields (i am not sure what the failure that can happen in resolve_visibility_speculative, but we check the length of our fields in both cases against each other, so if anything goes wrong, we fall back to the worse error. This could be extended to more patterns 3. this does not yet deal with #75906, but I believe it will be similar 4. let me know if you want more tests 5. doesn't yet at the suggestion that `@yoshuawuyts` suggested at the end of their issue, but that could be added relatively easily (i believe)
2020-09-11Give better diagnostic when using a private tuple struct constructorGus Wynn-1/+6
2020-09-10Attach `TokenStream` to `ast::Path`Aaron Hill-0/+2
2020-09-09Rollup merge of #75984 - kornelski:typeormodule, r=matthewjasperTyler Mandry-1/+8
Improve unresolved use error message "use of undeclared type or module `foo`" doesn't mention that it could be a crate. This error can happen when users forget to add a dependency to `Cargo.toml`, so I think it's important to mention that it could be a missing crate. I've used a heuristic based on Rust's naming conventions. It complains about an unknown type if the ident starts with an upper-case letter, and crate or module otherwise. It seems to work very well. The expanded error help covers both an unknown type and a missing crate case.
2020-09-01Clarify message about unresolved useKornel-1/+8
2020-09-01Give a better error message for duplicate built-in macrosJoshua Nelson-1/+7
Previously, this would say no such macro existed, but this was misleading, since the macro _did_ exist, it was just already seen. - Say where the macro was previously defined - Add long-form error message
2020-08-30mv compiler to compiler/mark-0/+3328