summary refs log tree commit diff
path: root/src/librustc_resolve
AgeCommit message (Collapse)AuthorLines
2018-01-10Try to fix a perf regression by updating logMalo Jaffré-1/+1
Upgrade `log` to `0.4` in multiple crates.
2017-12-28Auto merge of #47031 - topecongiro:issue-41719, r=jseyfriedbors-1/+9
Report an error when resolving non-ident macro path failed Closes #41719. Please feel free to bikeshed on the error message.
2017-12-28Prefer to use attr::contains_name() and attr::find_by_name()Seiichi Uchida-2/+1
2017-12-28Report an error when resolving non-ident macro path failedtopecongiro-1/+9
2017-12-23Auto merge of #46864 - estebank:closure-type-err-sp, r=nikomatsakisbors-23/+21
Closure type error ui tweak Do not point at the same span on all notes/help messages, and instead show them without a span.
2017-12-21Add GenericParam, refactor Generics in ast, hir, rustdocJonas Platte-30/+39
The Generics now contain one Vec of an enum for the generic parameters, rather than two separate Vec's for lifetime and type parameters. Additionally, places that previously used Vec<LifetimeDef> now use Vec<GenericParam> instead.
2017-12-20Various tweaksEsteban Küber-23/+21
2017-12-17Point at def span on redefined name diagnosticEsteban Küber-3/+3
2017-12-14error for impl trait aliasAlex Burka-11/+21
2017-12-14stub out trait aliases in resolveAlex Burka-0/+18
2017-12-13Auto merge of #46550 - jseyfried:cleanup_builtin_hygiene, r=nrcbors-6/+16
macros: hygienize use of `core`/`std` in builtin macros Today, if a builtin macro wants to access an item from `core` or `std` (depending `#![no_std]`), it generates `::core::path::to::item` or `::std::path::to::item` respectively (c.f. `fn std_path()` in `libsyntax/ext/base.rs`). This PR refactors the builtin macros to instead always emit `$crate::path::to::item` here. That is, the def site of builtin macros is taken to be in `extern crate core;` or `extern crate std;`. Since builtin macros are macros 1.0 (i.e. mostly unhygienic), changing the def site can only effect the resolution of `$crate`. r? @nrc
2017-12-13Auto merge of #46419 - jseyfried:all_imports_in_metadata, r=nrcbors-14/+26
Record all imports (`use`, `extern crate`) in the crate metadata This PR adds non-`pub` `use` and `extern crate` imports in the crate metadata since hygienic macros invoked in other crates may use them. We already include all other non-`pub` items in the crate metadata. This improves import suggestions in some cases. Fixes #42337. r? @nrc
2017-12-12Improve pretty printing `$crate::` paths.Jeffrey Seyfried-8/+9
2017-12-13Resolve absolute paths as extern under a feature flagVadim Petrochenkov-3/+66
2017-12-09Use hygiene to access the injected crate (`core` or `std`) from builtin macros.Jeffrey Seyfried-2/+11
2017-12-09one-time diagnostic and suggestion for reëxporting private variant errorZack M. Davis-6/+54
We issue just one message for an erroneous glob private variant reëxport (using the Session's one-time-diagnostics capability), but individual (non-glob) such erroneous reëxports still get their own messages. The suggestion to make the enum public is also one-time. The enum variant reëxport error didn't have an associated error code (and remedying this here is deemed out of the scope of this commit), so we resort to the expediency of using 0 as the `DiagnosticMessageId` value. Adding Debug to NameResolution was helpful in development. This resolves #46209.
2017-12-05Add field `is_import` to `def::Export`.Jeffrey Seyfried-2/+4
2017-12-05Include non-`pub` `use` and `extern crate` items in the crate metadata for ↵Jeffrey Seyfried-14/+24
macros 2.0.
2017-12-02Auto merge of #46343 - jseyfried:fix_hygiene_bug, r=nrcbors-2/+11
Fix hygiene bug. Fixes #42708. r? @nrc
2017-12-02Auto merge of #45904 - sunjay:gat-parser, r=nikomatsakisbors-73/+70
Generic Associated Types Parsing & Name Resolution Hi! This PR adds parsing for generic associated types! :tada: :tada: :tada: Tracking Issue: #44265 ## Notes For Reviewers * [x] I still need to add the stdout and stderr files to my ui tests. It takes me a *long* time to compile the compiler locally, so I'm going to add this as soon as possible in the next day or so. * [ ] My current ui tests aren't very good or very thorough. I'm reusing the `parse_generics` and `parse_where_clause` methods from elsewhere in the parser, so my changes work without being particularly complex. I'm not sure if I should duplicate all of the generics test cases for generic associated types. It might actually be appropriate to duplicate everything here, since we don't want to rely on an implementation detail in case it changes in the future. If you think so too, I'll adapt all of the generics test cases into the generic associated types test cases. * [ ] There is still more work required to make the run-pass tests pass here. In particular, we need to make the following errors disappear: ``` error[E0110]: lifetime parameters are not allowed on this type --> ./src/test/run-pass/rfc1598-generic-associated-types/streaming_iterator.rs:23:41 | 23 | bar: <T as StreamingIterator>::Item<'static>, | ^^^^^^^ lifetime parameter not allowed on this type ``` ``` error[E0261]: use of undeclared lifetime name `'a` --> ./src/test/run-pass/rfc1598-generic-associated-types/iterable.rs:15:47 | 15 | type Iter<'a>: Iterator<Item = Self::Item<'a>>; | ^^ undeclared lifetime ``` There is a FIXME comment in streaming_iterator. If you uncomment that line, you get the following: ``` error: expected one of `!`, `+`, `,`, `::`, or `>`, found `=` --> ./src/test/run-pass/rfc1598-generic-associated-types/streaming_iterator.rs:29:45 | 29 | fn foo<T: for<'a> StreamingIterator<Item<'a>=&'a [i32]>>(iter: T) { /* ... */ } | ^ expected one of `!`, `+`, `,`, `::`, or `>` here ``` r? @nikomatsakis
2017-12-01Renaming MethodRibKind to TraitOrImplItemRibKind and removing its field ↵Sunjay Varma-80/+69
which was never used. Lifting the HasTypeParameters rib to all trait item kinds and all impl item kinds
2017-12-01Adding type paramter ribs for generic associated typesSunjay Varma-2/+10
2017-12-01Auto merge of #45997 - estebank:pub-ident, r=nikomatsakisbors-1/+1
Account for missing keyword in fn/struct definition Fix #38911.
2017-11-30Implement RFC 2128 (use_nested_groups)Pietro Albini-164/+205
This commit adds support for nested groups inside `use` declarations, such as `use foo::{bar, sub::{baz::Foo, *}};`.
2017-11-28Fix hygiene bug.Jeffrey Seyfried-2/+11
2017-11-24Do not attemt to continue parsing after `pub ident`Esteban Küber-3/+2
Try to identify the following code in order to provide better diagnostics, but return the error to bail out early during the parse.
2017-11-24Do not rewind parser and ignore following blocksEsteban Küber-2/+3
When encountering `pub ident`, attempt to identify the code that comes afterwards, wether it is a brace block (assume it is a struct), a paren list followed by a colon (assume struct) or a paren list followed by a block (assume a fn). Consume those blocks to avoid any further parser errors and return a `Placeholder` item in order to allow the parser to continue. In the case of unenclosed blocks, the behavior is the same as it is currently: no further errors are processed.
2017-11-24Auto merge of #45942 - Menschenkindlein:master, r=estebankbors-0/+82
Add hints for the case of confusing enum with its variants A solution for https://github.com/rust-lang/rust/issues/43871. When one uses an enum in a place that accepts variants (e.g., `Option(result)` instead of `Some(result)`), suggest one of this enum's variants. cc @estebank
2017-11-23Use for_each_child_stable in find_moduleMaxim Zholobak-1/+1
2017-11-23Add module population and case of enum in place of expressionMaxim Zholobak-3/+6
2017-11-22Auto merge of #46035 - oli-obk:use_suggestions, r=petrochenkovbors-12/+56
Add structured suggestions for various "use" suggestions r? @petrochenkov
2017-11-21Report special messages for path segment keywords in wrong positionsVadim Petrochenkov-8/+38
2017-11-21Support `::crate` in pathsVadim Petrochenkov-15/+13
2017-11-20Add structured suggestions for proc macro use importsOliver Schneider-5/+42
2017-11-20Add structured suggestions for trait importsOliver Schneider-7/+14
2017-11-13Add hints for the case of confusing enum with its variantsMaxim Zholobak-0/+79
2017-11-10Auto merge of #45050 - petrochenkov:ambind, r=nikomatsakisbors-13/+11
resolve: Use same rules for disambiguating fresh bindings in `match` and `let` Resolve `Unit` as a unit struct pattern in ```rust struct Unit; let Unit = x; ``` consistently with ```rust match x { Unit => {} } ``` It was previously an error. (The change also applies to unit variants and constants.) Fixes https://users.rust-lang.org/t/e0530-cannot-shadow-unit-structs-what-in-the-earthly-what/13054 (This particular change doesn't depend on a fix for the issue mentioned in https://users.rust-lang.org/t/e0530-cannot-shadow-unit-structs-what-in-the-earthly-what/13054/4) cc @rust-lang/lang r? @nikomatsakis
2017-11-10Rollup merge of #45856 - estebank:issue-45829, r=nikomatsakiskennytm-8/+18
Fix help for duplicated names: `extern crate (...) as (...)` On the case of duplicated names caused by an `extern crate` statement with a rename, don't include the inline suggestion, instead using a span label with only the text to avoid incorrect rust code output. Fix #45829.
2017-11-08Auto merge of #45452 - estebank:colon-typo, r=nikomatsakisbors-1/+1
Detect `=` -> `:` typo in let bindings When encountering a let binding type error, attempt to parse as initializer instead. If successful, it is likely just a typo: ```rust fn main() { let x: Vec::with_capacity(10); } ``` ``` error: expected type, found `10` --> file.rs:3:31 | 3 | let x: Vec::with_capacity(10, 20); | -- ^^ | || | |help: did you mean assign here?: `=` | while parsing the type for `x` ``` Fix #43703.
2017-11-08Fix help for duplicated names: `extern crate (...) as (...)`Esteban Küber-8/+18
On the case of duplicated names caused by an `extern crate` statement with a rename, don't include the inline suggestion, instead using a span label with only the text to avoid incorrect rust code output.
2017-11-05Auto merge of #45770 - spastorino:newtype_index, r=nikomatsakisbors-0/+3
Make last structs indexes definitions use newtype_index macro This PR makes the last two index structs not using newtype_index macro to use it and also fixes this https://github.com/rust-lang/rust/issues/45763 issue.
2017-11-04Make DefIndex use newtype_index macroSantiago Pastorino-0/+3
2017-11-04Auto merge of #45394 - davidtwco:rfc-2008, r=petrochenkovbors-2/+14
RFC 2008: Future-proofing enums/structs with #[non_exhaustive] attribute This work-in-progress pull request contains my changes to implement [RFC 2008](https://github.com/rust-lang/rfcs/pull/2008). The related tracking issue is #44109. As of writing, enum-related functionality is not included and there are some issues related to tuple/unit structs. Enum related tests are currently ignored. WIP PR requested by @nikomatsakis [in Gitter](https://gitter.im/rust-impl-period/WG-compiler-middle?at=59e90e6297cedeb0482ade3e).
2017-11-03Detect `=` -> `:` typo in let bindingsEsteban Küber-1/+1
When encountering a let binding type error, attempt to parse as initializer instead. If successful, it is likely just a typo: ```rust fn main() { let x: Vec::with_capacity(10); } ``` ``` error: expected type, found `10` --> file.rs:3:31 | 3 | let x: Vec::with_capacity(10, 20); | -- ^^ | || | |help: did you mean assign here?: `=` | while parsing the type for `x` ```
2017-11-04resolve: Use same rules for disambiguating fresh bindings in `match` and `let`Vadim Petrochenkov-13/+11
2017-11-03Implemented RFC 2008 for enums (not including variants) and structs.David Wood-2/+14
2017-11-03Auto merge of #45247 - leodasvacas:implement-auto-trait-syntax, r=nikomatsakisbors-3/+3
[Syntax] Implement auto trait syntax Implements `auto trait Send {}` as a substitute for `trait Send {} impl Send for .. {}`. See the [internals thread](https://internals.rust-lang.org/t/pre-rfc-renaming-oibits-and-changing-their-declaration-syntax/3086) for motivation. Part of #13231. The first commit is just a rename moving from "default trait" to "auto trait". The rest is parser->AST->HIR work and making it the same as the current syntax for everything below HIR. It's under the `optin_builtin_traits` feature gate. When can we remove the old syntax? Do we need to wait for a new `stage0`? We also need to formally decide for the new form (even if the keyword is not settled yet). Observations: - If you `auto trait Auto {}` and then `impl Auto for .. {}` that's accepted even if it's redundant. - The new syntax is simpler internally which will allow for a net removal of code, for example well-formedness checks are effectively moved to the parser. - Rustfmt and clippy are broken, need to fix those. - Rustdoc just ignores it for now. ping @petrochenkov @nikomatsakis
2017-11-03add `auto` keyword, parse `auto trait`, lower to HIRleonardo.yvens-1/+1
Adds an `IsAuto` field to `ItemTrait` which flags if the trait was declared as an `auto trait`. Auto traits cannot have generics nor super traits.
2017-11-03[Syntax Breaking] Rename DefaultImpl to AutoImplleonardo.yvens-2/+2
DefaultImpl is a highly confusing name for what we now call auto impls, as in `impl Send for ..`. The name auto impl is not formally decided but for sanity anything is better than `DefaultImpl` which refers neither to `default impl` nor to `impl Default`.
2017-11-02Make the difference between lint codes and error codes explicitOliver Schneider-4/+9