summary refs log tree commit diff
path: root/src/librustc_resolve
AgeCommit message (Collapse)AuthorLines
2017-04-04Ensure that macro resolutions in trait positions get finalized.Jeffrey Seyfried-3/+6
2017-03-20Fix regression when `include!()`ing a `macro_rules!` containing a `$crate::` ↵Jeffrey Seyfried-1/+4
path.
2017-03-12Rollup merge of #40369 - petrochenkov:segspan, r=eddybCorey Farwell-31/+32
Give spans to individual path segments in AST And use these spans in path resolution diagnostics. The spans are spans of identifiers in segments, not whole segments. I'm not sure what spans are more useful in general, but identifier spans are a better fit for resolve errors. HIR still doesn't have spans. Fixes https://github.com/rust-lang/rust/pull/38927#discussion_r95336667 https://github.com/rust-lang/rust/pull/38890#issuecomment-271731008 r? @nrc @eddyb
2017-03-10resolve: Use path segment spans in smart_resolve_pathVadim Petrochenkov-26/+25
2017-03-10Give spans to individual path segments in ASTVadim Petrochenkov-5/+7
2017-03-10Avoid using `Mark` and `Invocation` for macro defs.Jeffrey Seyfried-66/+87
2017-03-10Move `resolve_invoc` from `syntax` to `resolve`.Jeffrey Seyfried-9/+67
2017-03-10Refactor out `ast::ItemKind::MacroDef`.Jeffrey Seyfried-64/+38
2017-03-08Auto merge of #39713 - estebank:issue-39698, r=jonathandturnerbors-41/+98
Clean up "pattern doesn't bind x" messages Group "missing variable bind" spans in `or` matches and clarify wording for the two possible cases: when a variable from the first pattern is not in any of the subsequent patterns, and when a variable in any of the other patterns is not in the first one. Before: ```rust error[E0408]: variable `a` from pattern #1 is not bound in pattern #2 --> file.rs:10:23 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^^^^ pattern doesn't bind `a` error[E0408]: variable `b` from pattern #2 is not bound in pattern #1 --> file.rs:10:32 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^ pattern doesn't bind `b` error[E0408]: variable `a` from pattern #1 is not bound in pattern #3 --> file.rs:10:37 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^ pattern doesn't bind `a` error[E0408]: variable `d` from pattern #1 is not bound in pattern #3 --> file.rs:10:37 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^ pattern doesn't bind `d` error[E0408]: variable `c` from pattern #3 is not bound in pattern #1 --> file.rs:10:43 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^ pattern doesn't bind `c` error[E0408]: variable `d` from pattern #1 is not bound in pattern #4 --> file.rs:10:48 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^ pattern doesn't bind `d` error: aborting due to 6 previous errors ``` After: ```rust error[E0408]: variable `d` is not bound in all patterns --> $DIR/issue-39698.rs:20:37 | 20 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | - - ^^^^^^^^ ^^^^^^^^ pattern doesn't bind `d` | | | | | | | pattern doesn't bind `d` | | variable not in all patterns | variable not in all patterns error[E0408]: variable `c` is not bound in all patterns --> $DIR/issue-39698.rs:20:48 | 20 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^^^^ ^^^^^^^^^^^ - ^^^^^^^^ pattern doesn't bind `c` | | | | | | | variable not in all patterns | | pattern doesn't bind `c` | pattern doesn't bind `c` error[E0408]: variable `a` is not bound in all patterns --> $DIR/issue-39698.rs:20:37 | 20 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | - ^^^^^^^^^^^ ^^^^^^^^ - variable not in all patterns | | | | | | | pattern doesn't bind `a` | | pattern doesn't bind `a` | variable not in all patterns error[E0408]: variable `b` is not bound in all patterns --> $DIR/issue-39698.rs:20:37 | 20 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^^^^ - ^^^^^^^^ ^^^^^^^^ pattern doesn't bind `b` | | | | | | | pattern doesn't bind `b` | | variable not in all patterns | pattern doesn't bind `b` error: aborting due to 4 previous errors ``` Fixes #39698.
2017-03-06Use `BTreeSet` instead of `FxHashSet`Esteban Küber-10/+9
2017-03-06Clean up "pattern doesn't bind x" messagesEsteban Küber-41/+99
Group "missing variable bind" spans in `or` matches and clarify wording for the two possible cases: when a variable from the first pattern is not in any of the subsequent patterns, and when a variable in any of the other patterns is not in the first one. Before: ``` error[E0408]: variable `a` from pattern #1 is not bound in pattern #2 --> file.rs:10:23 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^^^^ pattern doesn't bind `a` error[E0408]: variable `b` from pattern #2 is not bound in pattern #1 --> file.rs:10:32 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^ pattern doesn't bind `b` error[E0408]: variable `a` from pattern #1 is not bound in pattern #3 --> file.rs:10:37 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^ pattern doesn't bind `a` error[E0408]: variable `d` from pattern #1 is not bound in pattern #3 --> file.rs:10:37 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^ pattern doesn't bind `d` error[E0408]: variable `c` from pattern #3 is not bound in pattern #1 --> file.rs:10:43 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^ pattern doesn't bind `c` error[E0408]: variable `d` from pattern #1 is not bound in pattern #4 --> file.rs:10:48 | 10 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } | ^^^^^^^^ pattern doesn't bind `d` error: aborting due to 6 previous errors ``` After: ``` error[E0408]: variable `a` is not bound in all patterns --> file.rs:20:37 | 20 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { intln!("{:?}", a); } | - ^^^^^^^^^^^ ^^^^^^^^ - variable t in all patterns | | | | | | | pattern doesn't bind `a` | | pattern doesn't bind `a` | variable not in all patterns error[E0408]: variable `d` is not bound in all patterns --> file.rs:20:37 | 20 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { intln!("{:?}", a); } | - - ^^^^^^^^ ^^^^^^^^ pattern esn't bind `d` | | | | | | | pattern doesn't bind `d` | | variable not in all patterns | variable not in all patterns error[E0408]: variable `b` is not bound in all patterns --> file.rs:20:37 | 20 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { intln!("{:?}", a); } | ^^^^^^^^^^^ - ^^^^^^^^ ^^^^^^^^ pattern esn't bind `b` | | | | | | | pattern doesn't bind `b` | | variable not in all patterns | pattern doesn't bind `b` error[E0408]: variable `c` is not bound in all patterns --> file.rs:20:48 | 20 | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { intln!("{:?}", a); } | ^^^^^^^^^^^ ^^^^^^^^^^^ - ^^^^^^^^ pattern esn't bind `c` | | | | | | | variable not in all tterns | | pattern doesn't bind `c` | pattern doesn't bind `c` error: aborting due to 4 previous errors ``` * Have only one presentation for binding consistency errors * Point to same binding in multiple patterns when possible * Check inconsistent bindings in all arms * Simplify wording of diagnostic message * Sort emition and spans of binding errors for deterministic output
2017-03-05Fix const expression macro invocations.Jeffrey Seyfried-10/+10
2017-03-04Auto merge of #40242 - cramertj:fix-while-let-ribs-scope, r=petrochenkovbors-0/+2
Fix missing WhileLet pattern scope Fix #40235
2017-03-03Fix missing WhileLet pattern scopeTaylor Cramer-0/+2
2017-03-03Integrate `TokenStream`.Jeffrey Seyfried-3/+3
2017-02-25rustc: introduce a query system for type information in ty::maps.Eduard Burtescu-2/+2
2017-02-25rustc: store type parameter defaults outside of ty::Generics.Eduard-Mihai Burtescu-16/+89
2017-02-25Rollup merge of #39953 - keeperofdakeys:macro-error, r=jseyfriedEduard-Mihai Burtescu-29/+45
Provide suggestions for unknown macros imported with `use` cc https://github.com/rust-lang/rust/issues/30197 r? @jseyfried
2017-02-25Rollup merge of #39864 - cramertj:normalize-breaks, r=nikomatsakisEduard-Mihai Burtescu-12/+18
Normalize labeled and unlabeled breaks Part of #39849.
2017-02-23Add macro suggestions for macros imported with `use`Josh Driver-25/+38
This commit searchs modules for macro suggestions. It also removes imported macro_rules from macro_names, and adds more corner case checks for which macros should be suggested in specific contexts.
2017-02-23Move MacroKind into Def::MacroJosh Driver-4/+7
2017-02-22Don't assume plugin-whitelisted attributes are proc macro attributesAustin Bonander-0/+5
closes #40001
2017-02-19Privatize fields of PathResolutionVadim Petrochenkov-43/+38
Ensure Def::Err has depth == 0
2017-02-18Properly implement labeled breaks in while conditionsTaylor Cramer-12/+18
2017-02-16Refactor macro resolution errors + add derive macro suggestionsJosh Driver-53/+77
2017-02-12Allow using inert attributes from `proc_macro_derive`s with ↵Jeffrey Seyfried-16/+11
`#![feature(proc_macro)]`.
2017-02-12Move legacy custom derives collection into `resolver.find_attr_invoc()`.Jeffrey Seyfried-2/+55
2017-02-05Rollup merge of #39443 - phungleson:remove-unresolved-things, r=nikomatsakisCorey Farwell-1/+13
Don't suggest to use things which weren't found either Fixes #38054 The best code I can come up with, suggestions are welcome. Basically, removing ```. Did you mean to use `DoesntExist1`?``` in the code below, because it is useless. ```rust error[E0432]: unresolved import `DoesntExist1` --> src/lib.rs:1:5 | 1 | use DoesntExist1; | ^^^^^^^^^^^^ no `DoesntExist1` in the root error[E0432]: unresolved import `DoesntExist2` --> src/lib.rs:2:5 | 2 | use DoesntExist2; | ^^^^^^^^^^^^ no `DoesntExist2` in the root. Did you mean to use `DoesntExist1`? ```
2017-02-05Move derive macro expansion into the MacroExpanderJosh Driver-0/+26
This removes the expand_derives function, and sprinkles the functionality throughout the Invocation Collector, Expander and Resolver.
2017-02-05Rename CustomDerive to ProcMacroDerive for macros 1.1Josh Driver-1/+1
2017-02-02Suggest only if resolution was previously resolvedSon-1/+13
2017-01-29Improve diagnostics for inaccessible constructorsVadim Petrochenkov-9/+25
2017-01-29Implement compatibility lint for legacy constructor visibilitiesVadim Petrochenkov-2/+25
2017-01-29Privatize constructors of tuple structs with private fieldsVadim Petrochenkov-9/+13
2017-01-25Auto merge of #38920 - petrochenkov:selfimpl, r=eddybbors-53/+61
Partially implement RFC 1647 (`Self` in impl headers) The name resolution part is easy, but the typeck part contains an unexpected problem. It turns out that `Self` type *depends* on bounds and `where` clauses, so we need to convert them first to determine what the `Self` type is! If bounds/`where` clauses can refer to `Self` then we have a cyclic dependency. This is required to support impls like this: ``` // Found in libcollections impl<I: IntoIterator> SpecExtend<I> for LinkedList<I::Item> { .... } ^^^^^ associated type `Item` is found using information from bounds ``` I'm not yet sure how to resolve this issue. One possible solution (that feels hacky) is to make two passes over generics - first collect predicates ignoring everything involving `Self`, then determine `Self`, then collect predicates again without ignoring anything. (Some kind of lazy on-demand checking or something looks like a proper solution.) This patch in its current state doesn't solve the problem with `Self` in bounds, so the only observable things it does is improving error messages and supporting `impl Trait<Self> for Type {}`. There's also a question about feature gating. It's non-trivial to *detect* "newly resolved" `Self`s to feature gate them, but it's simple to *enable* the new resolution behavior when the feature gate is already specified. Alternatively this can be considered a bug fix and merged without a feature gate. cc https://github.com/rust-lang/rust/issues/38864 r? @nikomatsakis cc @eddyb Whitespace ignoring diff https://github.com/rust-lang/rust/pull/38920/files?w=1
2017-01-22Warn on unused `#[macro_use]` imports.Jeffrey Seyfried-8/+38
2017-01-21Resolve `Self` in impl headersVadim Petrochenkov-53/+61
2017-01-21Improve `unused_extern_crate` warnings.Jeffrey Seyfried-31/+36
2017-01-20Rollup merge of #39168 - estebank:multiline-candidate, r=petrochenkovAlex Crichton-16/+17
Use multiline Diagnostic for candidate in other module ``` error[E0574]: expected struct, variant or union type, found enum `Result` --> $DIR/issue-16058.rs:19:9 | 19 | Result { | ^^^^^^ not a struct, variant or union type | = help: possible better candidates are found in other modules, you can import them into scope: `use std::fmt::Result;` `use std::io::Result;` `use std::thread::Result;` error: aborting due to previous error ```
2017-01-20Rollup merge of #39077 - jseyfried:crate_var_imports, r=nrcAlex Crichton-1/+4
Improve the warning cycle for `use $crate;` Fixes #39049. r? @nrc
2017-01-18Use multiline Diagnostic for candidate in other moduleEsteban Küber-16/+17
2017-01-16Implement `#[proc_macro_attribute]`Austin Bonander-3/+86
* Add support for `#[proc_macro]` * Reactivate `proc_macro` feature and gate `#[proc_macro_attribute]` under it * Have `#![feature(proc_macro)]` imply `#![feature(use_extern_macros)]`, error on legacy import of proc macros via `#[macro_use]`
2017-01-15Improve the warning cycle for `use $crate;`.Jeffrey Seyfried-1/+4
2017-01-13resolve: Levenshtein-based suggestions for non-import pathsVadim Petrochenkov-16/+65
2017-01-13Auto merge of #38890 - petrochenkov:noresolve, r=nrcbors-13/+24
resolve: Do not use "resolve"/"resolution" in error messages Use less jargon-y wording instead. `cannot find <struct> <S> in <this scope>` and `cannot find <struct> <S> in <module a::b>` are used for base messages (this also harmonizes nicely with "you can import it into scope" suggestions) and `not found in <this scope>` and `not found in <a::b>` are used for short labels in fall-back case. I tweaked some other diagnostics to avoid using "resolve" (see, e.g., `librustc_resolve/macros.rs`), but haven't touched messages for imports. Closes https://github.com/rust-lang/rust/issues/38750 r? @nrc
2017-01-12resolve: Do not use "resolve"/"resolution" in error messagesVadim Petrochenkov-13/+24
2017-01-11Auto merge of #38313 - jseyfried:self_imports, r=nrcbors-11/+45
resolve: clean up the semantics of `self` in an import list Change `self` in an import list `use foo::bar::{self, ...};` to import `bar` only in the type namespace. Today, `bar` is imported in every namespace in which `foo::bar` is defined. This is a [breaking-change], see https://github.com/rust-lang/rust/issues/38293#issue-194817974 for examples of code that would break. Fixes #38293. r? @nrc
2017-01-10Start warning cycle.Jeffrey Seyfried-1/+31
2017-01-10Change `self` in an import list `use foo::{self, ...}` to only import a ↵Jeffrey Seyfried-10/+14
module or enum `foo`.
2017-01-08Fix ICE when variant is used as a part of associated typeVadim Petrochenkov-3/+5