about summary refs log tree commit diff
path: root/src/librustc_resolve
AgeCommit message (Collapse)AuthorLines
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
2017-10-31Suggest renaming import if names clashCldfire-3/+23
2017-10-27Implement RFC 1861: Extern typesPaul Lietar-6/+11
2017-10-26Auto merge of #45464 - sinkuu:ice_44851, r=jseyfriedbors-1/+14
Visit attribute tokens in `DefCollector` and `BuildReducedGraphVisitor` Fixes #44851.
2017-10-25Auto merge of #45476 - Xanewok:fingerprint-disambiguator, r=michaelwoeristerbors-1/+1
Use 128 bit instead of Symbol for crate disambiguator As discussed on gitter, this changes `crate_disambiguator` from Strings to what they are represented as, a 128 bit number. There's also one bit I think also needs to change, but wasn't 100% sure how: [create_root_def](https://github.com/rust-lang/rust/blob/f338dba29705e144bad8b2a675284538dd514896/src/librustc/hir/map/definitions.rs#L468-L482). Should I change `DefKey::root_parent_stable_hash` to accept `Fingerprint` as crate_disambiguator to quickly combine the hash of `crate_name` with the new 128 bit hash instead of a string for a disambiguator? r? @michaelwoerister EDIT: Are those 3 tests `mir-opt` failing, because the hash is different, because we calculate it a little bit differently (storing directly instead of hashing the hex-string representation)? Should it be updated like in #45319?
2017-10-24Introduce CrateDisambiguator newtype and fix testsIgor Matuszewski-1/+1
2017-10-24Auto merge of #44766 - sunjay:lift_generics, r=nikomatsakisbors-5/+3
Move Generics from MethodSig to TraitItem and ImplItem As part of `rust-impl-period/WG-compiler-traits`, we want to "lift" `Generics` from `MethodSig` into `TraitItem` and `ImplItem`. This is in preparation for adding associated type generics. (https://github.com/rust-lang/rust/issues/44265#issuecomment-331172238) Currently this change is only made in the AST. In the future, it may also impact the HIR. (Still discussing) To understand this PR, it's probably best to start from the changes to `ast.rs` and then work your way to the other files to understand the far reaching effects of this change. r? @nikomatsakis
2017-10-23Use 128 bit instead of Symbol for crate disambiguatorIgor Matuszewski-1/+1
2017-10-23Fix #44851 by visiting tokens in `DefCollector` and `BuildReducedGraphVisitor`sinkuu-1/+14
2017-10-19Cleanly error for non-const expression in associated constmatthewjasper-1/+3
2017-10-17Removed Generics from FnKind::ItemFn in libsyntaxSunjay Varma-2/+1
2017-10-17Removed redundant generics visitsSunjay Varma-2/+0
2017-10-17Lifting Generics from MethodSig to TraitItem and ImplItem since we want to ↵Sunjay Varma-3/+4
support generics in each variant of TraitItem and ImplItem
2017-10-14Auto merge of #44867 - kennytm:rustdoc-md-test-title, r=alexcrichtonbors-3/+3
doc-test: In Markdown tests, Use all of `<h1>` to `<h6>` as the test name This mainly simplifies debugging error index tests, as the error codes are `<h2>`s in the huge document containing all codes.
2017-10-10Add suggestions for misspelled labelsThomas Jespersen-10/+26
Another part of #30197
2017-10-08doc-test: In Markdown tests, Use all of `<h1>` to `<h6>` as the test name.kennytm-3/+3
This mainly simplifies debugging error index tests, as the error codes are `<h2>`s in the huge document containing all codes.
2017-09-21Auto merge of #44215 - oli-obk:import_sugg, r=nrcbors-17/+37
don't suggest placing `use` statements into expanded code r? @nrc fixes #44210 ```rust #[derive(Debug)] struct Foo; type X = Path; ``` will try to place `use std::path::Path;` between `#[derive(Debug)]` and `struct Foo;` I am not sure how to obtain a span before the first attribute, because derive attributes are removed during expansion. It would be trivial to detect this case and place the `use` after the item, but that would be somewhat weird I think.
2017-09-12Remove the `cstore` reference from Session in order to prepare encapsulating ↵Michael Woerister-17/+21
CrateStore access in tcx.
2017-09-11Auto merge of #44435 - alexcrichton:in-scope, r=michaelwoeristerbors-3/+2
rustc: Remove HirId from queries This'll allow us to reconstruct query parameters purely from the `DepNode` they're associated with. Closes #44414
2017-09-11rustc: Remove HirId from queriesAlex Crichton-3/+2
This'll allow us to reconstruct query parameters purely from the `DepNode` they're associated with. Some queries could move straight to `HirId` but others that don't always have a correspondance between `HirId` and `DefId` moved to two-level maps where the query operates over a `DefIndex`, returning a map, which is then keyed off `ItemLocalId`. Closes #44414
2017-09-08Use NodeId/HirId instead of DefId for local variables.Eduard-Mihai Burtescu-6/+5
2017-09-05rustc: Store InternedString in `DefPathData`Alex Crichton-2/+3
Previously a `Symbol` was stored there, but this ended up causing hash collisions in situations that otherwise shouldn't have a hash collision. Only the symbol's string value was hashed, but it was possible for distinct symbols to have the same string value, fooling various calcuations into thinking that these paths *didn't* need disambiguating data when in fact they did! By storing `InternedString` instead we're hopefully triggering all the exising logic to disambiguate paths with same-name `Symbol` but actually distinct locations.
2017-09-05rustc: Classify two more CrateStore methods untrackedAlex Crichton-1/+1
These are only called pre-TyCtxt (e.g. lowering/resolve), so make it explicit in the name that they're untracked and therefore unsuitable to called elsewhere.
2017-09-05rustc: Flag some CrateStore methods as "untracked"Alex Crichton-12/+14
The main use of `CrateStore` *before* the `TyCtxt` is created is during resolution, but we want to be sure that any methods used before resolution are not used after the `TyCtxt` is created. This commit starts moving the methods used by resolve to all be named `{name}_untracked` where the rest of the compiler uses just `{name}` as a query. During this transition a number of new queries were added to account for post-resolve usage of these methods.
2017-09-01Prevent suggestions from being emitted if all possible locations are inside ↵Oliver Schneider-15/+23
expansions
2017-08-31WIP: don't suggest placing `use` statements into expanded codeOliver Schneider-2/+14
2017-08-30Rollup merge of #44089 - alexcrichton:trait-proc-macro, r=nrcAlex Crichton-1/+2
rustc: Fix proc_macro expansions on trait methods This commit fixes procedural macro attributes being attached to trait methods, ensuring that they get resolved and expanded as other procedural macro attributes. The bug here was that `current_module` on the resolver was accidentally set to be a trait when it's otherwise only ever expecting a `mod`/block module. The actual fix here came from @jseyfried, I'm just helping to land it in the compiler! Closes #42493
2017-08-30Make fields of `Span` privateVadim Petrochenkov-14/+10
2017-08-27Address review comments, second turnTatsuyuki Ishi-11/+9
2017-08-27Move unused-extern-crate to late passTatsuyuki Ishi-10/+12
2017-08-25rustc: Fix proc_macro expansions on trait methodsAlex Crichton-1/+2
This commit fixes procedural macro attributes being attached to trait methods, ensuring that they get resolved and expanded as other procedural macro attributes. The bug here was that `current_module` on the resolver was accidentally set to be a trait when it's otherwise only ever expecting a `mod`/block module. The actual fix here came from @jseyfried, I'm just helping to land it in the compiler! Closes #42493
2017-08-25*: remove crate_{name,type} attributesTamir Duberstein-3/+0
Fixes #41701.
2017-08-21Auto merge of #43986 - petrochenkov:pubcrate3, r=pnkfelixbors-28/+1
rustc: Remove some dead code Extracted from https://github.com/rust-lang/rust/pull/43192 r? @eddyb
2017-08-19rustc: Remove some dead codeVadim Petrochenkov-28/+1
2017-08-18Add an additional empty line between the suggested `use` and the next itemOliver Schneider-3/+14
2017-08-17Improve placement of `use` suggestionsOliver Schneider-20/+99