about summary refs log tree commit diff
path: root/src/librustc_resolve
AgeCommit message (Collapse)AuthorLines
2018-10-16#45829 when a renamed import conflict with a previous importFrançois Mockers-3/+11
2018-10-13resolve: Scale back hard-coded extern prelude additionsVadim Petrochenkov-7/+9
2018-10-13Copy extern prelude from resolver to global contextVadim Petrochenkov-1/+1
2018-10-13Revert "rustc_resolve: move extern_prelude from Resolver to Session."Vadim Petrochenkov-8/+22
This reverts commit e90985acdec9928da9f6d157cfeb64f0ee98bffe.
2018-10-05Reapply the macro_rules disambiguation changes from masterVadim Petrochenkov-2/+5
2018-10-05Reapply the derive helper changes from masterVadim Petrochenkov-37/+38
2018-10-05expansion: Remove restriction on use of macro attributes with test/benchVadim Petrochenkov-14/+9
The restrictions were introduced in https://github.com/rust-lang/rust/pull/54277 and no longer necessary now because legacy plugins are now expanded in usual left-to-right order
2018-10-05resolve: Keep more precise traces for expanded macro resolutionsVadim Petrochenkov-16/+16
`NameBinding`s instead of `Def`s
2018-10-05resolve: Merge resolution for `macro_rules` into the common early in-scope ↵Vadim Petrochenkov-235/+138
resolution function `fn resolve_legacy_scope`/`fn resolve_lexical_macro_path_segment` -> `fn early_resolve_ident_in_lexical_scope`
2018-10-05resolve: Support value namespace in `fn resolve_lexical_macro_path_segment`Vadim Petrochenkov-8/+17
2018-10-05expansion: Expand attribute macros registered by legacy plugins in usual ↵Vadim Petrochenkov-15/+3
left-to-right order
2018-10-05resolve: Integrate inert attributes registererd by legacy plugins into macro ↵Vadim Petrochenkov-11/+31
resolution
2018-10-03Auto merge of #54391 - davidtwco:issue-54230, r=petrochenkovbors-12/+177
suggest `crate::...` for "local" paths in 2018 Fixes #54230. This commit adds suggestions for unresolved imports in the cases where there could be a missing `crate::`, `super::`, `self::` or a missing external crate name before an import. r? @nikomatsakis
2018-10-03Deterministic external crate suggestion.David Wood-4/+11
This commit ensures that the external crate suggestion is deterministic by using a `BTreeMap` rather than a `FxHashMap`. This is particularly useful as `std` and `core` will often contain the same items and therefore the suggestion would previously suggest either for any given error - in this case, the suggestion will always prefer `std` now.
2018-10-03Removed hardcoded crate.David Wood-14/+14
Previously, `meta` crate was hardcoded as attempting to resolve a path with it would ICE. Now, we attempt to load each extern crate first so that resolving a path involving that crate doesn't error.
2018-10-03Add suggestions for unresolved imports.David Wood-12/+170
This commit adds suggestions for unresolved imports in the cases where there could be a missing `crate::`, `super::`, `self::` or a missing external crate name before an import.
2018-10-03resolve: Prefer `macro_rules` definitions to in-module macro definitions in ↵Vadim Petrochenkov-4/+45
some cases
2018-10-02Auto merge of #54694 - csmoe:self_this, r=estebankbors-1/+15
Suggest to use self for fake-self from other languages Closes https://github.com/rust-lang/rust/issues/54019 r? @estebank
2018-10-01Rollup merge of #54308 - dsciarra:issue-22692, r=estebankkennytm-14/+45
Better user experience when attempting to call associated functions with dot notation Closes #22692
2018-10-01mark fix as MaybeIncorrectcsmoe-1/+1
2018-10-01lint to use self for this/mycsmoe-1/+15
2018-09-30Auto merge of #54650 - eddyb:no-extern's-land, r=alexcrichtonbors-21/+7
Don't lint non-extern-prelude extern crate's in Rust 2018. Fixes #54381 by silencing the lint telling users to remove `extern crate` when `use` doesn't work. r? @alexcrichton cc @petrochenkov @nikomatsakis @Centril
2018-09-30Auto merge of #54601 - cuviper:prep-1.31, r=Mark-Simulacrumbors-1/+1
Bump to 1.31.0 and bootstrap from 1.30 beta Closes #54594.
2018-09-29Improve ux when calling associated functions with dot notationDonato Sciarra-14/+45
Issue: 22692
2018-09-28rustc_resolve: move extern_prelude from Resolver to Session.Eduard-Mihai Burtescu-21/+7
2018-09-27Bump to 1.31.0 and bootstrap from 1.30 betaJosh Stone-1/+1
2018-09-27Added help message for feature gate.Alexander Regueiro-9/+29
2018-09-26Remove OneVectorljedrz-2/+3
2018-09-25resolve: Do not block derive helper resolutions on single import resolutionsVadim Petrochenkov-10/+10
Derive helpers conflict currently conflict with anything else, so if some resolution from a single import appears later, it will result in error anyway
2018-09-23Improve error message for E0424Julian Kulesh-2/+4
2018-09-22Stabilize crate_in_paths, extern_absolute_paths and extern_prelude on all ↵Eduard-Mihai Burtescu-28/+1
editions.
2018-09-20Auto merge of #54241 - vi:suggest_with_applicability, r=estebankbors-4/+12
Remove usages of span_suggestion without Applicability Use `Applicability::Unspecified` for all of them instead. Shall deprecations for the non-`_with_applicability` functions be added? Shall clippy be addressed somehow? r? @estebank
2018-09-17Auto merge of #54277 - petrochenkov:afterder, r=alexcrichtonbors-6/+15
Temporarily prohibit proc macro attributes placed after derives ... and also proc macro attributes used together with `#[test]`/`#[bench]`. Addresses item 6 from https://github.com/rust-lang/rust/pull/50911#issuecomment-411605393. The end goal is straightforward predictable left-to-right expansion order for attributes. Right now derives are expanded last regardless of their relative ordering with macro attributes and right now it's simpler to temporarily prohibit macro attributes placed after derives than changing the expansion order. I'm not sure whether the new beta is already released or not, but if it's released, then this patch needs to be backported, so the solution needs to be minimal. How to fix broken code (derives): - Move macro attributes above derives. This won't change expansion order, they are expanded before derives anyway. Using attribute macros on same items with `#[test]` and `#[bench]` is prohibited for similar expansion order reasons, but this one is going to be reverted much sooner than restrictions on derives. How to fix broken code (test/bench): - Enable `#![feature(plugin)]` (don't ask why). r? @ghost
2018-09-17Whitespace fix again.Vitaly _Vi Shukela-7/+11
2018-09-17Fill in suggestions Applicability according to @estebankVitaly _Vi Shukela-1/+1
Also fix some formatting along the way.
2018-09-17Fix style according to review comments.Vitaly _Vi Shukela-1/+2
2018-09-16Remove usages of span_suggestion without ApplicabilityVitaly _Vi Shukela-3/+6
Use Applicability::Unspecified for all of them instead.
2018-09-16resolve: Do not error on access to proc macros imported with `#[macro_use]`Vadim Petrochenkov-81/+0
2018-09-16Temporarily prohibit proc macro attributes placed after derivesVadim Petrochenkov-6/+15
... and also proc macro attributes used together with test/bench.
2018-09-15rustc_resolve: use `continue` instead of `return` to "exit" a loop iteration.Eduard-Mihai Burtescu-2/+2
2018-09-15rustc_resolve: always include core, std and meta in the extern prelude.Eduard-Mihai Burtescu-23/+28
2018-09-15rustc_resolve: don't allow `::crate_name` to bypass `extern_prelude`.Eduard-Mihai Burtescu-2/+10
2018-09-14Auto merge of #54069 - petrochenkov:subns, r=aturonbors-11/+18
resolve: Introduce two sub-namespaces in macro namespace Two sub-namespaces are introduced in the macro namespace - one for bang macros and one for attribute-like macros (attributes, derives). "Sub-namespace" means this is not a newly introduced full namespace, the single macro namespace is still in place. I.e. you still can't define/import two macros with the same name in a single module, `use` imports still import only one name in macro namespace (from any sub-namespace) and not possibly two. However, when we are searching for a name used in a `!` macro call context (`my_macro!()`) we skip attribute names in scope, and when we are searching for a name used in attribute context (`#[my_macro]`/`#[derive(my_macro)]`) we are skipping bang macro names in scope. In other words, bang macros cannot shadow attribute macros and vice versa. For a non-macro analogy, we could e.g. skip non-traits when searching for `MyTrait` in `impl MyTrait for Type { ... }`. However we do not do it in non-macro namespaces because we don't have practical issues with e.g. non-traits shadowing traits with the same name, but with macros we do, especially after macro modularization. For `#[test]` and `#[bench]` we have a hack in the compiler right now preventing their shadowing by `macro_rules! test` and similar things. This hack was introduced after making `#[test]`/`#[bench]` built-in macros instead of built-in attributes (https://github.com/rust-lang/rust/pull/53410), something that needed to be done from the start since they are "active" attributes transforming their inputs. Now they are passed through normal name resolution and can be shadowed, but that's a breaking change, so we have a special hack basically applying this PR for `#[test]` and `#[bench]` only. Soon all potentially built-in attributes will be passed through normal name resolution (https://github.com/rust-lang/rust/pull/53913) and that uncovers even more cases where the strict "macro namespace is a single namespace" rule needs to be broken. For example, with strict rules, built-in macro `cfg!(...)` would shadow built-in attribute `#[cfg]` (they are different things), standard library macro `thread_local!(...)` would shadow built-in attribute `#[thread_local]` - both of these cases are covered by special hacks in https://github.com/rust-lang/rust/pull/53913 as well. Crater run uncovered more cases of attributes being shadowed by user-defined macros (`warn`, `doc`, `main`, even `deprecated`), we cannot add exceptions in the compiler for all of them. Regressions with user-defined attributes like https://github.com/rust-lang/rust/issues/53583 and https://github.com/rust-lang/rust/issues/53898 also appeared after enabling macro modularization. People are also usually confused (https://github.com/rust-lang/rust/issues/53205#issuecomment-411552763, https://github.com/rust-lang/rust/issues/53583#issuecomment-415447800) when they see conflicts between attributes and non-attribute macros for the first time. So my proposed solution is to solve this issue by introducing two sub-namespaces and thus skipping resolutions of the wrong kind and preventing more error-causing cases of shadowing. Fixes https://github.com/rust-lang/rust/issues/53583
2018-09-14Auto merge of #54201 - eddyb:reflexive-disambiguation, r=petrochenkovbors-73/+73
rustc_resolve: don't treat uniform_paths canaries as ambiguities unless they resolve to distinct Def's. In particular, this allows this pattern that @cramertj mentioned in https://github.com/rust-lang/rust/issues/53130#issuecomment-420848814: ```rust use log::{debug, log}; fn main() { use log::{debug, log}; debug!(...); } ``` The canaries for the inner `use log::...;`, *in the macro namespace*, see the `log` macro imported at the module scope, and the (same) `log` macro, imported in the block scope inside `main`. Previously, these two possible (macro namspace) `log` resolutions would be considered ambiguous (from a forwards-compat standpoint, where we might make imports aware of block scopes). With this PR, such a case is allowed *if and only if* all the possible resolutions refer to the same definition (more specifically, because the *same* `log` macro is being imported twice). This condition subsumes previous (weaker) checks like #54005 and the second commit of #54011. Only the last commit is the main change, the other two are cleanups. r? @petrochenkov cc @Centril @joshtriplett
2018-09-14Auto merge of #54032 - oli-obk:layout_scalar_ranges, r=eddybbors-7/+7
Add forever unstable attribute to allow specifying arbitrary scalar ranges r? @eddyb for the first commit and @nikomatsakis for the second one
2018-09-14Auto merge of #53751 - F001:tuple-struct-self-ctor, r=petrochenkov,varkorbors-68/+89
Implement RFC 2302: tuple_struct_self_ctor Tracking issue: https://github.com/rust-lang/rust/issues/51994
2018-09-13rustc_resolve: don't treat uniform_paths canaries as ambiguities unless they ↵Eduard-Mihai Burtescu-26/+16
resolve to distinct Def's.
2018-09-13rustc_resolve: ignore uniform_paths canaries with no module scopes.Eduard-Mihai Burtescu-0/+6
2018-09-13rustc_resolve: only process uniform_paths canaries in namespaces they're ↵Eduard-Mihai Burtescu-75/+79
present in.
2018-09-13resolve: Introduce two sub-namespaces in macro namespaceVadim Petrochenkov-11/+18