summary refs log tree commit diff
path: root/src/librustc_resolve
AgeCommit message (Collapse)AuthorLines
2017-04-15feature gate :vis matcherAlex Burka-2/+6
2017-04-12First attempt at global_asm! macroA.J. Gardner-1/+3
2017-04-08Auto merge of #40775 - estebank:variant-as-type, r=petrochenkovbors-0/+32
Suggest using enum when a variant is used as a type Given a file: ```rust enum Fruit { Apple(i64), Orange(i64), } fn should_return_fruit() -> Apple { Apple(5) } ``` Provide the following output: ```rust error[E0412]: cannot find type `Apple` in this scope --> file.rs:16:29 | 16 | fn should_return_fruit() -> Apple { | ^^^^^ not found in this scope | help: there is an enum variant `Fruit::Apple`, did you mean to use `Fruit`? --> file.rs:12:5 | 12 | Apple(i64), | ^^^^^^^^^^ error[E0425]: cannot find function `Apple` in this scope --> file.rs:17:5 | 17 | Apple(5) | ^^^^^ not found in this scope | = help: possible candidate is found in another module, you can import it into scope: `use Fruit::Apple;` ``` Fix #35675.
2017-04-07ICH: Centrally compute and cache DefPath hashes as part of DefPathTable.Michael Woerister-1/+3
2017-04-03Fix bug parsing `#[derive]` macro invocations.Jeffrey Seyfried-2/+4
2017-04-03Sort enum suggestionsEsteban Küber-6/+8
2017-04-02Suggest using enum when a variant is used as a typeEsteban Küber-0/+30
Given a file: ```rust enum Fruit { Apple(i64), Orange(i64), } fn should_return_fruit() -> Apple { Apple(5) } ``` Provide the following output: ```rust error[E0412]: cannot find type `Apple` in this scope --> file.rs:16:29 | 16 | fn should_return_fruit() -> Apple { | ^^^^^ not found in this scope | help: there is an enum variant `Fruit::Apple`, did you mean to use `Fruit`? --> file.rs:12:5 | 12 | Apple(i64), | ^^^^^^^^^^ error[E0425]: cannot find function `Apple` in this scope --> file.rs:17:5 | 17 | Apple(5) | ^^^^^ not found in this scope | = help: possible candidate is found in another module, you can import it into scope: `use Fruit::Apple;` ```
2017-03-29Move `syntax::ext::hygiene` to `syntax_pos::hygiene`.Jeffrey Seyfried-1/+1
2017-03-27Rollup merge of #40853 - ollie27:error-index, r=steveklabnikAlex Crichton-1/+5
Fix broken Markdown and bad links in the error index This makes sure RFC links point to the RFC text not the pull request. r? @steveklabnik
2017-03-27Fix broken Markdown and bad links in the error indexOliver Middleton-1/+5
This makes sure RFC links point to the RFC text not the pull request.
2017-03-27Ensure that macro resolutions in trait positions get finalized.Jeffrey Seyfried-3/+6
2017-03-26Auto merge of #40501 - jseyfried:shadow_builtin_macros, r=nrcbors-71/+103
Allow `use` macro imports to shadow global macros Terminology: - global scope: builtin macros, macros from the prelude, `#[macro_use]`, or `#![plugin(..)]`. - legacy scope: crate-local `macro_rules!`. - modern scope: `use` macro imports, `macro` (once implemented). Today, the legacy scope can shadow the global scope (modulo RFC 1560 expanded shadowing restrictions). However, the modern scope cannot shadow or be shadowed by either the global or legacy scopes, leading to ambiguity errors. This PR allows the modern scope to shadow the global scope (subject to some restrictions). More specifically, a name in the global scope is as shadowable as a glob import in the module `self`. In other words, we imagine a special, implicit glob import in each module item: ```rust mod foo { #[lexical_only] // Not accessible via `foo::<name>`, like pre-RFC 1560 `use` imports. #[shadowable_by_legacy_scope] // for back-compat use <global_macros>::*; } ``` r? @nrc
2017-03-24Rename `builtin` => `global`.Jeffrey Seyfried-20/+20
2017-03-24Allow declarative macros 2.0 and `use` macro imports to shadow builtin macros.Jeffrey Seyfried-59/+91
2017-03-23Remove internal liblogAlex Crichton-1/+1
This commit deletes the internal liblog in favor of the implementation that lives on crates.io. Similarly it's also setting a convention for adding crates to the compiler. The main restriction right now is that we want compiler implementation details to be unreachable from normal Rust code (e.g. requires a feature), and by default everything in the sysroot is reachable via `extern crate`. The proposal here is to require that crates pulled in have these lines in their `src/lib.rs`: #![cfg_attr(rustbuild, feature(staged_api, rustc_private))] #![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))] This'll mean that by default they're not using these attributes but when compiled as part of the compiler they do a few things: * Mark themselves as entirely unstable via the `staged_api` feature and the `#![unstable]` attribute. * Allow usage of other unstable crates via `feature(rustc_private)` which is required if the crate relies on any other crates to compile (other than std).
2017-03-22Rollup merge of #40509 - jseyfried:duplicate_check_macro_exports, r=nrcCorey Farwell-7/+18
Forbid conflicts between macros 1.0 exports and macros 2.0 exports This PR forbids for conflicts between `#[macro_export]`/`#[macro_reexport]` macro exports and `pub use` macro exports. For example, ```rust // crate A: pub use macros::foo; //^ This is allowed today, will be forbidden by this PR. // crate B: extern crate A; // This triggers a confusing error today. use A::foo; // This could refer to refer to either macro export in crate A. ``` r? @nrc
2017-03-21Fix bug in legacy `#[derive]` processing logic.Jeffrey Seyfried-4/+4
2017-03-21Check for conflicts between macros 1.0 exports (`#[macro_export]`, ↵Jeffrey Seyfried-7/+18
`#[macro_reexport]`) and macros 2.0 exports (`pub use` macro re-exports and `pub macro` (once implemented) at the crate root.
2017-03-19Rollup merge of #40583 - jseyfried:fix_include_macro_regression, r=nrcCorey Farwell-1/+4
macros: fix regression with `include!()` Fixes #40469, a regression when `include!()`ing a `macro_rules!` containing `$crate`. r? @nrc
2017-03-19Auto merge of #40346 - jseyfried:path_and_tokenstream_attr, r=nrcbors-37/+61
`TokenStream`-based attributes, paths in attribute and derive macro invocations This PR - refactors `Attribute` to use `Path` and `TokenStream` instead of `MetaItem`. - supports macro invocation paths for attribute procedural macros. - e.g. `#[::foo::attr_macro] struct S;`, `#[cfg_attr(all(), foo::attr_macro)] struct S;` - supports macro invocation paths for derive procedural macros. - e.g. `#[derive(foo::Bar, super::Baz)] struct S;` - supports arbitrary tokens as arguments to attribute procedural macros. - e.g. `#[foo::attr_macro arbitrary + tokens] struct S;` - supports using arbitrary tokens in "inert attributes" with derive procedural macros. - e.g. `#[derive(Foo)] struct S(#[inert arbitrary + tokens] i32);` where `#[proc_macro_derive(Foo, attributes(inert))]` r? @nrc
2017-03-17Fix regression when `include!()`ing a `macro_rules!` containing a `$crate::` ↵Jeffrey Seyfried-1/+4
path.
2017-03-14Liberalize attributes.Jeffrey Seyfried-16/+40
2017-03-14Refactor `Attribute` to use `Path` and `TokenStream` instead of `MetaItem`.Jeffrey Seyfried-24/+24
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.