about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2021-03-27Auto merge of #83103 - petrochenkov:unilex, r=Aaron1011bors-131/+63
resolve: Partially unify early and late scope-relative identifier resolution Reuse `early_resolve_ident_in_lexical_scope` instead of a chunk of code in `resolve_ident_in_lexical_scope` doing the same job. `early_resolve_ident_in_lexical_scope`/`visit_scopes` had to be slightly extended to be able to 1) start from a specific module instead of the current parent scope and 2) report one deprecation lint. `early_resolve_ident_in_lexical_scope` still doesn't support walking through "ribs", that part is left in `resolve_ident_in_lexical_scope` (moreover, I'm pretty sure it's buggy, but that's a separate issue, cc https://github.com/rust-lang/rust/issues/52389 at least).
2021-03-27resolve: Partially unify early and late scope-relative ident resolutionVadim Petrochenkov-131/+63
2021-03-26Use iter::zip in compiler/Josh Stone-0/+1
2021-03-23progress, stuff compiles nowlcnr-2/+2
2021-03-23Some refactoringvarkor-5/+9
2021-03-19stabilize or_patternsmark-1/+1
2021-03-12Make def_key and HIR parenting consistent.Camille GILLOT-3/+10
2021-03-07diagnostics: Don't mention external crates when hitting import errors on ↵Manish Goregaokar-1/+3
crate imports in 2018
2021-03-07diagnostics: Differentiate between edition meanings of ::foo in resolve ↵Manish Goregaokar-4/+10
diagnostics (for bare `::foo`)
2021-03-02use outer_expn_data() instead of outer_expn().expn_data()klensy-1/+1
2021-02-25Add a cache for rustc_legacy_const_genericsAmanieu d'Antras-14/+29
2021-02-25Address review commentsAmanieu d'Antras-2/+46
2021-02-23Add #[rustc_legacy_const_generics]Amanieu d'Antras-0/+4
2021-02-18ast: Keep expansion status for out-of-line module itemsVadim Petrochenkov-3/+3
Also remove `ast::Mod` which is mostly redundant now
2021-02-18ast: Stop using `Mod` in `Crate`Vadim Petrochenkov-15/+23
Crate root is sufficiently different from `mod` items, at least at syntactic level. Also remove customization point for "`mod` item or crate root" from AST visitors.
2021-02-10resolve: Remove visibility hacks for enum variants and trait itemsVadim Petrochenkov-18/+3
Special treatment like this was necessary before `pub(restricted)` had been implemented and only two visibilities existed - `pub` and non-`pub`. Now it's no longer necessary and the desired behavior follows from `pub(restricted)`-style visibilities naturally assigned to enum variants and trait items.
2021-02-07expand/resolve: Turn `#[derive]` into a regular macro attributeVadim Petrochenkov-0/+3
2021-02-06Rollup merge of #81680 - camsteffen:primty, r=oli-obkJonas Schievink-43/+4
Refactor `PrimitiveTypeTable` for Clippy I removed `PrimitiveTypeTable` and added `PrimTy::ALL` and `PrimTy::from_name` in its place. This allows Clippy to use `PrimTy::from_name` for the `builtin_type_shadow` lint, and a `const` list of primitive types is deleted from Clippy code (the goal). All changes should be a little faster, if anything.
2021-02-03Refactor out PrimitiveTypeTableCameron Steffen-43/+4
2021-02-01Box the biggest ast::ItemKind variantsDániel Buga-0/+1
2021-01-21Add more self-profile info to rustc_resolveJoshua Nelson-10/+8
2021-01-21Rollup merge of #81046 - rylev:unknown-external-crate, r=estebankYuki Okushi-4/+10
Improve unknown external crate error This improves error messages when unknown items in the crate root are encountered. Fixes #63799 r? ```@estebank```
2021-01-18Improve unknown external crate errorRyan Levick-4/+10
2021-01-17Rollup merge of #80765 - petrochenkov:traitsinscope, r=matthewjasperMara Bos-64/+63
resolve: Simplify collection of traits in scope "Traits in scope" for a given location are collected by walking all scopes in type namespace, collecting traits in them and pruning traits that don't have an associated item with the given name and namespace. Previously we tried to prune traits using some kind of hygienic resolution for associated items, but that was complex and likely incorrect, e.g. in #80762 correction to visibilites of trait items caused some traits to not be in scope anymore. I previously had some comments and concerns about this in https://github.com/rust-lang/rust/pull/65351. In this PR we are doing some much simpler pruning based on `Symbol` and `Namespace` comparisons, it should be enough to throw away 99.9% of unnecessary traits. It is not necessary for pruning to be precise because for trait aliases, for example, we don't do any pruning at all, and precise hygienic resolution for associated items needs to be done in typeck anyway. The somewhat unexpected effect is that trait imports introduced by macros 2.0 now bring traits into scope due to the removed hygienic check on associated item names. I'm not sure whether it is desirable or not, but I think it's acceptable for now. The old check was certainly incorrect because macros 2.0 did bring trait aliases into scope. If doing this is not desirable, then we should come up with some other way to avoid bringing traits from macros 2.0 into scope, that would accommodate for trait aliases as well. --- The PR also contains a couple of pure refactorings - Scope walk is done by using `visit_scopes` instead of a hand-rolled version. - Code is restructured to accomodate for rustdoc that also wants to query traits in scope, but doesn't want to filter them by associated items at all. r? ```@matthewjasper```
2021-01-14Use Option::map_or instead of `.map(..).unwrap_or(..)`LingMan-2/+2
2021-01-12Rollup merge of #80870 - petrochenkov:bmactable, r=oli-obkYuki Okushi-2/+2
resolve: Simplify built-in macro table We don't use full `SyntaxExtension`s from the table, only `SyntaxExtensionKind`s, and `Ident` in `register_builtin_macro` always had dummy span. This PR removes unnecessary data from the table and related function signatures. Noticed when reviewing #80850.
2021-01-11resolve: Simplify collection of traits in scopeVadim Petrochenkov-64/+63
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