summary refs log tree commit diff
path: root/src/librustc_resolve/lib.rs
AgeCommit message (Collapse)AuthorLines
2017-04-12First attempt at global_asm! macroA.J. Gardner-1/+1
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-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-27Ensure that macro resolutions in trait positions get finalized.Jeffrey Seyfried-0/+4
2017-03-24Rename `builtin` => `global`.Jeffrey Seyfried-4/+4
2017-03-24Allow declarative macros 2.0 and `use` macro imports to shadow builtin macros.Jeffrey Seyfried-16/+20
2017-03-19Auto merge of #40346 - jseyfried:path_and_tokenstream_attr, r=nrcbors-2/+5
`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-14Liberalize attributes.Jeffrey Seyfried-0/+2
2017-03-14Refactor `Attribute` to use `Path` and `TokenStream` instead of `MetaItem`.Jeffrey Seyfried-2/+3
2017-03-12Rollup merge of #40369 - petrochenkov:segspan, r=eddybCorey Farwell-29/+28
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-25/+25
2017-03-10Give spans to individual path segments in ASTVadim Petrochenkov-4/+3
2017-03-10Avoid using `Mark` and `Invocation` for macro defs.Jeffrey Seyfried-21/+34
2017-03-10Refactor out `ast::ItemKind::MacroDef`.Jeffrey Seyfried-11/+4
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-03Fix missing WhileLet pattern scopeTaylor Cramer-0/+2
2017-02-25rustc: store type parameter defaults outside of ty::Generics.Eduard-Mihai Burtescu-16/+62
2017-02-25Rollup merge of #39953 - keeperofdakeys:macro-error, r=jseyfriedEduard-Mihai Burtescu-4/+7
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-3/+4
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-1/+3
2017-02-19Privatize fields of PathResolutionVadim Petrochenkov-42/+37
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-1/+4
2017-01-29Improve diagnostics for inaccessible constructorsVadim Petrochenkov-4/+14
2017-01-29Implement compatibility lint for legacy constructor visibilitiesVadim Petrochenkov-2/+22
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-21Resolve `Self` in impl headersVadim Petrochenkov-53/+61
2017-01-21Improve `unused_extern_crate` warnings.Jeffrey Seyfried-7/+4
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-18Use multiline Diagnostic for candidate in other moduleEsteban Küber-16/+17
2017-01-16Implement `#[proc_macro_attribute]`Austin Bonander-2/+44
* 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-13resolve: Levenshtein-based suggestions for non-import pathsVadim Petrochenkov-16/+65
2017-01-13Auto merge of #38890 - petrochenkov:noresolve, r=nrcbors-11/+22
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-11/+22
2017-01-11Auto merge of #38313 - jseyfried:self_imports, r=nrcbors-1/+13
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/+13
2017-01-08Fix ICE when variant is used as a part of associated typeVadim Petrochenkov-3/+5
2017-01-08Auto merge of #38679 - alexcrichton:always-deny-warnings, r=nrcbors-1/+1
Remove not(stage0) from deny(warnings) Historically this was done to accommodate bugs in lints, but there hasn't been a bug in a lint since this feature was added which the warnings affected. Let's completely purge warnings from all our stages by denying warnings in all stages. This will also assist in tracking down `stage0` code to be removed whenever we're updating the bootstrap compiler.
2017-01-04Don't `unused_qualifications`-check global paths.Jeffrey Seyfried-13/+12
2016-12-30Fix rebase falloutSimonas Kazlauskas-2/+2
This commit includes manual merge conflict resolution changes from a rebase by @est31.
2016-12-30Feature gate the 128 bit typesSimonas Kazlauskas-1/+14
Dangling a carrot in front of a donkey. This commit includes manual merge conflict resolution changes from a rebase by @est31.
2016-12-30Such large. Very 128. Much bits.Simonas Kazlauskas-1/+2
This commit introduces 128-bit integers. Stage 2 builds and produces a working compiler which understands and supports 128-bit integers throughout. The general strategy used is to have rustc_i128 module which provides aliases for iu128, equal to iu64 in stage9 and iu128 later. Since nowhere in rustc we rely on large numbers being supported, this strategy is good enough to get past the first bootstrap stages to end up with a fully working 128-bit capable compiler. In order for this strategy to work, number of locations had to be changed to use associated max_value/min_value instead of MAX/MIN constants as well as the min_value (or was it max_value?) had to be changed to use xor instead of shift so both 64-bit and 128-bit based consteval works (former not necessarily producing the right results in stage1). This commit includes manual merge conflict resolution changes from a rebase by @est31.
2016-12-29Remove not(stage0) from deny(warnings)Alex Crichton-1/+1
Historically this was done to accommodate bugs in lints, but there hasn't been a bug in a lint since this feature was added which the warnings affected. Let's completely purge warnings from all our stages by denying warnings in all stages. This will also assist in tracking down `stage0` code to be removed whenever we're updating the bootstrap compiler.
2016-12-28rustc: separate bodies for static/(associated)const and embedded constants.Eduard-Mihai Burtescu-0/+13
2016-12-28hir: lower `ImplicitSelf` to resolved `Self` TyQPath's.Eduard-Mihai Burtescu-0/+12
2016-12-26More systematic error reporting in path resolutionVadim Petrochenkov-722/+614