about summary refs log tree commit diff
path: root/src/librustc_resolve
AgeCommit message (Collapse)AuthorLines
2019-01-13Rollup merge of #57560 - petrochenkov:selfinmac, r=alexregMazdak Farrokhzad-9/+7
hygiene: Do not treat `Self` ctor as a local variable Fixes https://github.com/rust-lang/rust/issues/57523
2019-01-13Rollup merge of #57557 - petrochenkov:ecused, r=varkorMazdak Farrokhzad-0/+3
resolve: Mark extern crate items as used in more cases Fixes https://github.com/rust-lang/rust/issues/57421
2019-01-13hygiene: Do not treat `Self` ctor as a local variableVadim Petrochenkov-9/+7
2019-01-13resolve: Mark extern crate items as used in more casesVadim Petrochenkov-0/+3
2019-01-12Fix a hole in generic parameter import future-proofingVadim Petrochenkov-5/+26
Add some tests for buggy derive helpers
2019-01-12Stabilize `uniform_paths`Vadim Petrochenkov-19/+10
2019-01-12resolve: Prohibit use of imported tool modulesVadim Petrochenkov-0/+7
2019-01-12resolve: Prohibit use of imported non-macro attributesVadim Petrochenkov-1/+18
2019-01-12resolve: Prohibit use of uniform paths in macros originating from 2015 editionVadim Petrochenkov-4/+9
...while still keeping ambiguity errors future-proofing for uniform paths. This corner case is not going to be stabilized for 1.32 and needs some more general experiments about retrofitting 2018 import rules to 2015 edition
2019-01-12resolve: Assign `pub` and `pub(crate)` visibilities to `macro_rules` itemsVadim Petrochenkov-3/+7
2019-01-03Fix repeated word typosWiktor Kuchta-1/+1
Found with `git grep -P '\b([a-z]+)\s+\1\b'`
2019-01-01Auto merge of #57199 - petrochenkov:ambig, r=estebankbors-52/+50
resolve: Simplify treatment of ambiguity errors If we have a glob conflict like this ```rust mod m1 { struct S; } mod m2 { struct S; } use m1::*; use m2::*; ``` we treat it as a special "ambiguity item" that's not an error by itself, but produces an error when actually used. ```rust use m1::*; // primary use m2::*; // secondary => ambiguity S(m1::S, m2::S); ``` Ambiguity items were *sometimes* treated as their primary items for error recovery, but pretty irregularly. After this PR they are always treated as their primary items, except that - If an ambiguity item is marked as used, then it still produces an error. - Ambiguity items are still filtered away when exported to other crates (which is also a use in some sense).
2018-12-31Auto merge of #57208 - estebank:issue-57198, r=petrochenkovbors-2/+5
Do not complain about missing crate named as a keyword Fix #57198.
2018-12-30Address review comments: Remove new `PathResult` variantEsteban Küber-15/+6
2018-12-30Auto merge of #57185 - petrochenkov:impice4, r=estebankbors-0/+4
resolve: Fix one more ICE in import validation So if you have an unresolved import ```rust mod m { use foo::bar; } ``` error recovery will insert a special item with `Def::Err` definition into module `m`, so other things depending on `bar` won't produce extra errors. The issue was that erroneous `bar` was overwriting legitimate `bar`s coming from globs, e.g. ```rust mod m { use baz::*; // imports real existing `bar` use foo::bar; } ``` causing some unwanted diagnostics talking about "unresolved items", and producing inconsistent resolutions like https://github.com/rust-lang/rust/issues/57015. This PR stops overwriting real successful resolutions with `Def::Err`s. Fixes https://github.com/rust-lang/rust/issues/57015
2018-12-29Do not complain about missing crate named as a keywordEsteban Küber-5/+17
2018-12-29Auto merge of #56225 - alexreg:type_alias_enum_variants, r=petrochenkovbors-1/+1
Implement RFC 2338, "Type alias enum variants" This PR implements [RFC 2338](https://github.com/rust-lang/rfcs/pull/2338), allowing one to write code like the following. ```rust #![feature(type_alias_enum_variants)] enum Foo { Bar(i32), Baz { i: i32 }, } type Alias = Foo; fn main() { let t = Alias::Bar(0); let t = Alias::Baz { i: 0 }; match t { Alias::Bar(_i) => {} Alias::Baz { i: _i } => {} } } ``` Since `Self` can be considered a type alias in this context, it also enables using `Self::Variant` as both a constructor and pattern. Fixes issues #56199 and #56611. N.B., after discussing the syntax for type arguments on enum variants with @petrochenkov and @eddyb (there are also a few comments on the [tracking issue](https://github.com/rust-lang/rust/issues/49683)), the consensus seems to be treat the syntax as follows, which ought to be backwards-compatible. ```rust Option::<u8>::None; // OK Option::None::<u8>; // OK, but lint in near future (hard error next edition?) Alias::<u8>::None; // OK Alias::None::<u8>; // Error ``` I do not know if this will need an FCP, but let's start one if so.
2018-12-29resolve: Simplify treatment of ambiguity errorsVadim Petrochenkov-52/+50
2018-12-29Auto merge of #57181 - petrochenkov:impice3, r=estebankbors-5/+5
resolve: Fix another ICE in import validation Imports are allowed to have ambiguous resolutions as long as all of them have same `Def`. As it turned out, it's possible for different `Module`s to have same `Def` when `extern crate` items are involved. Fixes https://github.com/rust-lang/rust/issues/56596
2018-12-29Auto merge of #57160 - petrochenkov:impice2, r=estebankbors-6/+12
resolve: Fix an ICE in import validation Fixes ICE reported in the comment https://github.com/rust-lang/rust/issues/56596#issuecomment-449866807
2018-12-29resolve: Never override real bindings with `Def::Err`s from error recoveryVadim Petrochenkov-0/+4
2018-12-29resolve: Fix another ICE in import validationVadim Petrochenkov-5/+5
2018-12-28Auto merge of #57155 - petrochenkov:dcrate3, r=dtolnaybors-13/+23
Resolve `$crate`s for pretty-printing at more appropriate time Doing it in `BuildReducedGraphVisitor` wasn't a good idea, identifiers wasn't actually visited half of the time. As a result some `$crate`s weren't resolved and were therefore pretty-printed as `$crate` literally, which turns into two tokens during re-parsing of the pretty-printed text. Now we are visiting and resolving `$crate` identifiers in an item right before sending that item to a proc macro attribute or derive. Fixes https://github.com/rust-lang/rust/issues/57089
2018-12-28resolve: Fix an ICE in import validationVadim Petrochenkov-6/+12
2018-12-28Resolve `$crate`s for pretty-printing at more appropriate timeVadim Petrochenkov-13/+23
2018-12-27Address review comments and CI failuresVadim Petrochenkov-1/+1
2018-12-27Do not abort compilation if expansion produces errorsVadim Petrochenkov-12/+26
Fix a number of uncovered deficiencies in diagnostics
2018-12-26Store `Ident` rather than just `Name` in HIR types `Item` and `ForeignItem`.Alexander Regueiro-1/+1
2018-12-25Remove licensesMark Rousskov-71/+0
2018-12-24Rollup merge of #57074 - Zoxc:pq-rec-limits, r=oli-obkMazdak Farrokhzad-0/+2
Fix recursion limits r? @michaelwoerister
2018-12-23Fix recursion limitsJohn Kåre Alsaker-0/+2
2018-12-22adjust enum type instead of variant suggestions for prelude enumsZack M. Davis-1/+11
The present author regrets not thinking of a more eloquent way to do this.
2018-12-22enum type instead of variant suggestion unificationZack M. Davis-18/+28
Weirdly, we were deciding between a help note and a structured suggestion based on whether the import candidate span was a dummy—but we weren't using that span in any case! The dummy-ness of the span (which appears to be a matter of this-crate vs. other-crate definition) isn't the right criterion by which we should decide whether it's germane to mention that "there is an enum variant"; instead, let's use the someness of `def` (which is used as the `has_unexpected_resolution` argument to `error_code`). Since `import_candidate_to_paths` has no other callers, we are free to stop returning the span and rename the function. By using `span_suggestions_`, we leverage the max-suggestions output limit already built in to the emitter, thus resolving #56028. In the matter of message wording, "you can" is redundant (and perhaps too informal); prefer the imperative.
2018-12-19Reintroduce special pretty-printing for `$crate` when it's necessary for ↵Vadim Petrochenkov-0/+11
proc macros
2018-12-19Remove `eliminate_crate_var` and special pretty-printing for `$crate`Vadim Petrochenkov-60/+1
2018-12-19Rollup merge of #56663 - Zoxc:resolver-lifetime, r=pnkfelixPietro Albini-40/+40
Remove lifetime from Resolver
2018-12-14Auto merge of #56572 - kevgrasso:let_self_err_dev, r=estebankbors-3/+16
Contexually dependent error message for E0424 when value is assigned to "self" This is an improvement for pull request #54495 referencing issue #54369. If the "self" keyword is assigned a value as though it were a valid identifier, it will now report: ``` let self = "self"; ^^^^ `self` value is a keyword and may not be bound to variables or shadowed ``` instead of ``` let self = "self"; ^^^^ `self` value is a keyword only available in methods with `self` parameter ``` If anyone has a better idea for what the error should be I'd be happy to modify it appropriately.
2018-12-13debug logging, added conditional error message, tests updatedKevyn Grasso-3/+16
2018-12-11std: Depend directly on crates.io cratesAlex Crichton-4/+2
Ever since we added a Cargo-based build system for the compiler the standard library has always been a little special, it's never been able to depend on crates.io crates for runtime dependencies. This has been a result of various limitations, namely that Cargo doesn't understand that crates from crates.io depend on libcore, so Cargo tries to build crates before libcore is finished. I had an idea this afternoon, however, which lifts the strategy from #52919 to directly depend on crates.io crates from the standard library. After all is said and done this removes a whopping three submodules that we need to manage! The basic idea here is that for any crate `std` depends on it adds an *optional* dependency on an empty crate on crates.io, in this case named `rustc-std-workspace-core`. This crate is overridden via `[patch]` in this repository to point to a local crate we write, and *that* has a `path` dependency on libcore. Note that all `no_std` crates also depend on `compiler_builtins`, but if we're not using submodules we can publish `compiler_builtins` to crates.io and all crates can depend on it anyway! The basic strategy then looks like: * The standard library (or some transitive dep) decides to depend on a crate `foo`. * The standard library adds ```toml [dependencies] foo = { version = "0.1", features = ['rustc-dep-of-std'] } ``` * The crate `foo` has an optional dependency on `rustc-std-workspace-core` * The crate `foo` has an optional dependency on `compiler_builtins` * The crate `foo` has a feature `rustc-dep-of-std` which activates these crates and any other necessary infrastructure in the crate. A sample commit for `dlmalloc` [turns out to be quite simple][commit]. After that all `no_std` crates should largely build "as is" and still be publishable on crates.io! Notably they should be able to continue to use stable Rust if necessary, since the `rename-dependency` feature of Cargo is soon stabilizing. As a proof of concept, this commit removes the `dlmalloc`, `libcompiler_builtins`, and `libc` submodules from this repository. Long thorns in our side these are now gone for good and we can directly depend on crates.io! It's hoped that in the long term we can bring in other crates as necessary, but for now this is largely intended to simply make it easier to manage these crates and remove submodules. This should be a transparent non-breaking change for all users, but one possible stickler is that this almost for sure breaks out-of-tree `std`-building tools like `xargo` and `cargo-xbuild`. I think it should be relatively easy to get them working, however, as all that's needed is an entry in the `[patch]` section used to build the standard library. Hopefully we can work with these tools to solve this problem! [commit]: https://github.com/alexcrichton/dlmalloc-rs/commit/28ee12db813a3b650a7c25d1c36d2c17dcb88ae3
2018-12-10Remove lifetime from ResolverJohn Kåre Alsaker-40/+40
2018-12-08Rollup merge of #56620 - petrochenkov:noclutter, r=estebankMazdak Farrokhzad-19/+23
resolve: Reduce some clutter in import ambiguity errors Noticed in https://www.reddit.com/r/rust/comments/a3pyrw/announcing_rust_131_and_rust_2018/eb8alhi/. The first error is distracting, but unnecessary, it's a *consequence* of the ambiguity error and appears because one of the ambiguous `actix` modules (unsurprisingly) doesn't have the expected name in it.
2018-12-08resolve: Reduce some clutter in import ambiguity errorsVadim Petrochenkov-19/+23
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-16/+16
2018-12-07Rollup merge of #56516 - frewsxcv:frewsxcv-eq, r=Mark-Simulacrumkennytm-1/+1
Replace usages of `..i + 1` ranges with `..=i`. Before this change we were using old computer code techniques. After this change we use the new and improved computer code techniques.
2018-12-07Unsupport `#[derive(Trait)]` sugar for `#[derive_Trait]` legacy plugin ↵Vadim Petrochenkov-101/+3
attributes
2018-12-06Auto merge of #56392 - petrochenkov:regensym, r=oli-obkbors-27/+68
Delay gensym creation for "underscore items" (`use foo as _`/`const _`) until name resolution So they cannot be cloned by macros. See https://github.com/rust-lang/rust/pull/56303 for the discussion. Mostly fix cross-crate use of underscore items by inverting the "gensyms are lost in metadata" bug as described in https://github.com/rust-lang/rust/pull/56303#issuecomment-442464695. Fix unused import warnings for single-segment imports (first commit) and `use crate_name as _` imports (as specified in https://github.com/rust-lang/rust/pull/56303#issuecomment-442274118). Prohibit accidentally implemented `static _: TYPE = EXPR;` (cc https://github.com/rust-lang/rust/pull/55983). Add more tests for `use foo as _` imports.
2018-12-06Rollup merge of #56426 - petrochenkov:syntweak, r=nikomatsakisPietro Albini-41/+41
libsyntax_pos: A few tweaks
2018-12-04Replace usages of `..i + 1` ranges with `..=i`.Corey Farwell-1/+1
2018-12-04Remove redundant cloneShotaro Yamada-1/+1
2018-12-04syntax: Rename some keywordsVadim Petrochenkov-41/+41
`CrateRoot` -> `PathRoot`, `::` doesn't necessarily mean crate root now `SelfValue` -> `SelfLower`, `SelfType` -> `SelfUpper`, both `self` and `Self` can be used in type and value namespaces now