summaryrefslogtreecommitdiff
path: root/src/librustc_resolve
Commit message (Collapse)AuthorAgeFilesLines
* Auto merge of #57208 - estebank:issue-57198, r=petrochenkovbors2018-12-312-2/+5
|\ | | | | | | | | | | Do not complain about missing crate named as a keyword Fix #57198.
| * Address review comments: Remove new `PathResult` variantEsteban Küber2018-12-303-15/+6
| |
| * Do not complain about missing crate named as a keywordEsteban Küber2018-12-293-5/+17
| |
* | Auto merge of #57185 - petrochenkov:impice4, r=estebankbors2018-12-301-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
| * resolve: Never override real bindings with `Def::Err`s from error recoveryVadim Petrochenkov2018-12-291-0/+4
| |
* | Auto merge of #56225 - alexreg:type_alias_enum_variants, r=petrochenkovbors2018-12-291-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.
| * | Store `Ident` rather than just `Name` in HIR types `Item` and `ForeignItem`.Alexander Regueiro2018-12-261-1/+1
| | |
* | | Auto merge of #57181 - petrochenkov:impice3, r=estebankbors2018-12-292-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
| * | | resolve: Fix another ICE in import validationVadim Petrochenkov2018-12-292-5/+5
| | |/ | |/|
* | | Auto merge of #57160 - petrochenkov:impice2, r=estebankbors2018-12-291-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
| * | resolve: Fix an ICE in import validationVadim Petrochenkov2018-12-281-6/+12
| | |
* | | Auto merge of #57155 - petrochenkov:dcrate3, r=dtolnaybors2018-12-282-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
| * | Resolve `$crate`s for pretty-printing at more appropriate timeVadim Petrochenkov2018-12-282-13/+23
| |/
* | Address review comments and CI failuresVadim Petrochenkov2018-12-271-1/+1
| |
* | Do not abort compilation if expansion produces errorsVadim Petrochenkov2018-12-272-12/+26
|/ | | | Fix a number of uncovered deficiencies in diagnostics
* Remove licensesMark Rousskov2018-12-257-71/+0
|
* Rollup merge of #57074 - Zoxc:pq-rec-limits, r=oli-obkMazdak Farrokhzad2018-12-241-0/+2
|\ | | | | | | | | | | Fix recursion limits r? @michaelwoerister
| * Fix recursion limitsJohn Kåre Alsaker2018-12-231-0/+2
| |
* | adjust enum type instead of variant suggestions for prelude enumsZack M. Davis2018-12-221-1/+11
| | | | | | | | | | The present author regrets not thinking of a more eloquent way to do this.
* | enum type instead of variant suggestion unificationZack M. Davis2018-12-221-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.
* Reintroduce special pretty-printing for `$crate` when it's necessary for ↵Vadim Petrochenkov2018-12-191-0/+11
| | | | proc macros
* Remove `eliminate_crate_var` and special pretty-printing for `$crate`Vadim Petrochenkov2018-12-192-60/+1
|
* Rollup merge of #56663 - Zoxc:resolver-lifetime, r=pnkfelixPietro Albini2018-12-196-40/+40
|\ | | | | | | Remove lifetime from Resolver
| * Remove lifetime from ResolverJohn Kåre Alsaker2018-12-106-40/+40
| |
* | Auto merge of #56572 - kevgrasso:let_self_err_dev, r=estebankbors2018-12-141-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.
| * | debug logging, added conditional error message, tests updatedKevyn Grasso2018-12-131-3/+16
| |/
* | std: Depend directly on crates.io cratesAlex Crichton2018-12-111-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
* Rollup merge of #56620 - petrochenkov:noclutter, r=estebankMazdak Farrokhzad2018-12-081-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.
| * resolve: Reduce some clutter in import ambiguity errorsVadim Petrochenkov2018-12-081-19/+23
| |
* | Various minor/cosmetic improvements to codeAlexander Regueiro2018-12-073-16/+16
|/
* Rollup merge of #56516 - frewsxcv:frewsxcv-eq, r=Mark-Simulacrumkennytm2018-12-071-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.
| * Replace usages of `..i + 1` ranges with `..=i`.Corey Farwell2018-12-041-1/+1
| |
* | Unsupport `#[derive(Trait)]` sugar for `#[derive_Trait]` legacy plugin ↵Vadim Petrochenkov2018-12-072-101/+3
| | | | | | | | attributes
* | Auto merge of #56392 - petrochenkov:regensym, r=oli-obkbors2018-12-064-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.
| * | Address review commentsVadim Petrochenkov2018-12-022-4/+15
| | |
| * | Delay gensym creation for "underscore items" until name resolutionVadim Petrochenkov2018-12-022-8/+16
| | | | | | | | | | | | | | | | | | Prohibit `static _` Fis unused import warnings for `use foo as _` Add more tests for `use foo as _`
| * | resolve: Avoid "self-confirming" resolutions in import validationVadim Petrochenkov2018-12-024-21/+43
| | |
* | | Rollup merge of #56426 - petrochenkov:syntweak, r=nikomatsakisPietro Albini2018-12-065-41/+41
|\ \ \ | | | | | | | | | | | | libsyntax_pos: A few tweaks
| * | | syntax: Rename some keywordsVadim Petrochenkov2018-12-045-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
* | | Remove redundant cloneShotaro Yamada2018-12-041-1/+1
|/ /
* | Rollup merge of #56366 - alexreg:stabilise-self_in_typedefs, r=Centrilkennytm2018-12-031-16/+4
|\ \ | |/ |/| | | | | | | | | | | Stabilize self_in_typedefs feature [**Tracking Issue**](https://github.com/rust-lang/rust/issues/49303) r? @centril
| * Removed feature gate.Alexander Regueiro2018-11-301-16/+4
| |
* | resolve: Support aliasing local crate root in extern preludeVadim Petrochenkov2018-12-011-4/+24
|/
* resolve: Fix false-positives from lint `absolute_paths_not_starting_with_crate`Vadim Petrochenkov2018-11-281-1/+1
|
* resolve: Extern prelude is for type namespace onlyVadim Petrochenkov2018-11-271-1/+3
|
* resolve: Suggest `crate::` for resolving ambiguities when appropriateVadim Petrochenkov2018-11-272-16/+31
| | | | More precise spans for ambiguities from macros
* resolve: Fallback to extern prelude in 2015 imports used from global 2018 ↵Vadim Petrochenkov2018-11-273-10/+47
| | | | edition
* resolve: Generalize `early_resolve_ident_in_lexical_scope` slightlyVadim Petrochenkov2018-11-273-82/+78
| | | | Flatten `ModuleOrUniformRoot` variants
* resolve: Fallback to uniform paths in 2015 imports used from global 2018 editionVadim Petrochenkov2018-11-273-35/+98
|
* resolve: Implement edition hygiene for imports and absolute pathsVadim Petrochenkov2018-11-274-46/+50
| | | | | Use per-span hygiene in a few other places in resolve Prefer `rust_2015`/`rust_2018` helpers to comparing editions