about summary refs log tree commit diff
path: root/src/librustc_resolve
AgeCommit message (Collapse)AuthorLines
2018-01-15Add note when trying to use `Self` as a ctorEsteban Küber-1/+5
2018-01-15Readd suggestion in enum variants with incorrect argsEsteban Küber-0/+12
2018-01-15Suggest the correct syntax for different struct typesEsteban Küber-12/+22
2018-01-15Hide suggestion to use struct ctor when it is not visibleEsteban Küber-5/+11
2018-01-15Don't include bang in macro replacement suggestionRyan Cumming-2/+1
When we suggest the replacement for a macro we include the "!" in the suggested replacement but the span only contains the name of the macro itself. Using that replacement would cause a duplicate "!" in the resulting code. I originally tried to extend the span to be replaced by 1 byte in rust-lang/rust#47424. However, @zackmdavis pointed out that there can be whitespace between the macro name and the bang. Instead, just remove the bang from the suggested replacement. Fixes #47418
2018-01-13Remove `impl Foo for ..` in favor of `auto trait Foo`leonardo.yvens-7/+1
No longer parse it. Remove AutoTrait variant from AST and HIR. Remove backwards compatibility lint. Remove coherence checks, they make no sense for the new syntax. Remove from rustdoc.
2018-01-13Auto merge of #47181 - michaelwoerister:var-len-def-index, r=eddybbors-3/+4
Use DefIndex encoding that works better with on-disk variable length integer representations. Use the least instead of the most significant bit for representing the address space. r? @eddyb
2018-01-12Auto merge of #46551 - jseyfried:improve_legacy_modern_macro_interaction, r=nrcbors-8/+17
macros: improve 1.0/2.0 interaction This PR supports using unhygienic macros from hygienic macros without breaking the latter's hygiene. ```rust // crate A: #[macro_export] macro_rules! m1 { () => { f(); // unhygienic: this macro needs `f` in its environment fn g() {} // (1) unhygienic: `g` is usable outside the macro definition } } // crate B: #![feature(decl_macro)] extern crate A; use A::m1; macro m2() { fn f() {} // (2) m1!(); // After this PR, `f()` in the expansion resolves to (2), not (3) g(); // After this PR, this resolves to `fn g() {}` from the above expansion. // Today, it is a resolution error. } fn test() { fn f() {} // (3) m2!(); // Today, `m2!()` can see (3) even though it should be hygienic. fn g() {} // Today, this conflicts with `fn g() {}` from the expansion, even though it should be hygienic. } ``` Once this PR lands, you can make an existing unhygienic macro hygienic by wrapping it in a hygienic macro. There is an [example](https://github.com/rust-lang/rust/pull/46551/commits/b766fa887dc0e4b923a38751fe4d570e35a75710) of this in the tests. r? @nrc
2018-01-08Use different DefIndex representation that is better suited for variable ↵Michael Woerister-3/+4
length integer encodings.
2018-01-07Try to fix a perf regression by updating logMalo Jaffré-1/+1
Upgrade `log` to `0.4` in multiple crates.
2018-01-07Auto merge of #47156 - petrochenkov:extpath, r=nikomatsakisbors-18/+26
Support `extern` in paths Implement the primary alternative to https://github.com/rust-lang/rust/pull/46613 + https://github.com/rust-lang/rust/pull/45771, achieving the same effect without requiring changes to other imports. Both need to be experimentally evaluated before making further progress. The PR also adds docs for all these related features into the unstable book. cc https://github.com/rust-lang/rust/issues/44660 r? @nikomatsakis
2018-01-07Rollup merge of #47170 - eddyb:us-vs-usize, r=nikomatsakiskennytm-2/+2
rustc: use {U,I}size instead of {U,I}s shorthands. `Us`/`Is` come from a time when `us` and `is` were the literal suffixes that are now `usize` / `isize`. r? @nikomatsakis
2018-01-04rustc: Don't use relative paths for extended errorsAlex Crichton-0/+1
These no longer work now that Cargo changes the cwd of rustc while it's running. Instead use an absolute path that's set by rustbuild.
2018-01-04rustc: use {U,I}size instead of {U,I}s shorthands.Eduard-Mihai Burtescu-2/+2
2018-01-03Support `extern` in pathsVadim Petrochenkov-18/+26
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-13Improve interaction between macros 2.0 and `macro_rules!`.Jeffrey Seyfried-8/+17
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