summary refs log tree commit diff
path: root/src/librustc_resolve
AgeCommit message (Collapse)AuthorLines
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
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-37/+37
Like #43008 (f668999), but _much more aggressive_.
2017-08-13Rollup merge of #43814 - Eijebong:fix_typos2, r=petrochenkovGuillaume Gomez-1/+1
Fix some typos Follow up of #43794 If refined my script a little bit and found some more.
2017-08-12Fix some typosBastien Orivel-1/+1
2017-08-12syntax: #[allow_internal_unsafe] bypasses the unsafe_code lint in macros.Eduard-Mihai Burtescu-1/+1
2017-08-10Auto merge of #43522 - alexcrichton:rewrite-lints, r=michaelwoeristerbors-18/+18
rustc: Rearchitect lints to be emitted more eagerly In preparation for incremental compilation this commit refactors the lint handling infrastructure in the compiler to be more "eager" and overall more incremental-friendly. Many passes of the compiler can emit lints at various points but before this commit all lints were buffered in a table to be emitted at the very end of compilation. This commit changes these lints to be emitted immediately during compilation using pre-calculated lint level-related data structures. Linting today is split into two phases, one set of "early" lints run on the `syntax::ast` and a "late" set of lints run on the HIR. This commit moves the "early" lints to running as late as possible in compilation, just before HIR lowering. This notably means that we're catching resolve-related lints just before HIR lowering. The early linting remains a pass very similar to how it was before, maintaining context of the current lint level as it walks the tree. Post-HIR, however, linting is structured as a method on the `TyCtxt` which transitively executes a query to calculate lint levels. Each request to lint on a `TyCtxt` will query the entire crate's 'lint level data structure' and then go from there about whether the lint should be emitted or not. The query depends on the entire HIR crate but should be very quick to calculate (just a quick walk of the HIR) and the red-green system should notice that the lint level data structure rarely changes, and should hopefully preserve incrementality. Overall this resulted in a pretty big change to the test suite now that lints are emitted much earlier in compilation (on-demand vs only at the end). This in turn necessitated the addition of many `#![allow(warnings)]` directives throughout the compile-fail test suite and a number of updates to the UI test suite. Closes https://github.com/rust-lang/rust/issues/42511
2017-08-09rustc: Rearchitect lints to be emitted more eagerlyAlex Crichton-18/+18
In preparation for incremental compilation this commit refactors the lint handling infrastructure in the compiler to be more "eager" and overall more incremental-friendly. Many passes of the compiler can emit lints at various points but before this commit all lints were buffered in a table to be emitted at the very end of compilation. This commit changes these lints to be emitted immediately during compilation using pre-calculated lint level-related data structures. Linting today is split into two phases, one set of "early" lints run on the `syntax::ast` and a "late" set of lints run on the HIR. This commit moves the "early" lints to running as late as possible in compilation, just before HIR lowering. This notably means that we're catching resolve-related lints just before HIR lowering. The early linting remains a pass very similar to how it was before, maintaining context of the current lint level as it walks the tree. Post-HIR, however, linting is structured as a method on the `TyCtxt` which transitively executes a query to calculate lint levels. Each request to lint on a `TyCtxt` will query the entire crate's 'lint level data structure' and then go from there about whether the lint should be emitted or not. The query depends on the entire HIR crate but should be very quick to calculate (just a quick walk of the HIR) and the red-green system should notice that the lint level data structure rarely changes, and should hopefully preserve incrementality. Overall this resulted in a pretty big change to the test suite now that lints are emitted much earlier in compilation (on-demand vs only at the end). This in turn necessitated the addition of many `#![allow(warnings)]` directives throughout the compile-fail test suite and a number of updates to the UI test suite.
2017-08-01Fixed all unnecessary muts in language coreIsaac van Bakel-1/+1
2017-08-01Auto merge of #43552 - petrochenkov:instab, r=jseyfriedbors-3/+17
resolve: Try to fix instability in import suggestions cc https://github.com/rust-lang/rust/pull/42033 `lookup_import_candidates` walks module graph in DFS order and skips modules that were already visited (which is correct because there can be cycles). However it means that if we visited `std::prelude::v1::Result::Ok` first, we will never visit `std::result::Result::Ok` because `Result` will be skipped as already visited (note: enums are also modules here), and otherwise, if we visited `std::result::Result::Ok` first, we will never get to `std::prelude::v1::Result::Ok`. What child module of `std` (`prelude` or `result`) we will visit first, depends on randomized hashing, so we have instability in diagnostics. With this patch modules' children are visited in stable order in `lookup_import_candidates`, this should fix the issue, but let's see what Travis will say. r? @oli-obk
2017-07-30default binding modes: add pat_binding_modesTobias Schottdorf-1/+2
This PR kicks off the implementation of the [default binding modes RFC][1] by introducing the `pat_binding_modes` typeck table mentioned in the [mentoring instructions][2]. `pat_binding_modes` is populated in `librustc_typeck/check/_match.rs` and used wherever the HIR would be scraped prior to this PR. Unfortunately, one blemish, namely a two callers to `contains_explicit_ref_binding`, remains. This will likely have to be removed when the second part of [1], the `pat_adjustments` table, is tackled. Appropriate comments have been added. See #42640. [1]: https://github.com/rust-lang/rfcs/pull/2005 [2]: https://github.com/rust-lang/rust/issues/42640#issuecomment-313535089
2017-07-30resolve: Fix instability in import suggestionsVadim Petrochenkov-3/+17
2017-07-27Avoid duplicated errors for generic arguments in macro pathsVadim Petrochenkov-5/+14
2017-07-27Give span to angle bracketed generic argumentsVadim Petrochenkov-3/+4
2017-07-27Discern between `Path` and `Path<>` in ASTVadim Petrochenkov-5/+1
2017-07-26Rollup merge of #43447 - estebank:import-span, r=nikomatsakisMark Simulacrum-103/+150
Point at path segment on module not found Point at the correct path segment on a import statement where a module doesn't exist. New output: ```rust error[E0432]: unresolved import `std::bar` --> <anon>:1:10 | 1 | use std::bar::{foo1, foo2}; | ^^^ Could not find `bar` in `std` ``` instead of: ```rust error[E0432]: unresolved import `std::bar::foo1` --> <anon>:1:16 | 1 | use std::bar::{foo1, foo2}; | ^^^^ Could not find `bar` in `std` error[E0432]: unresolved import `std::bar::foo2` --> <anon>:1:22 | 1 | use std::bar::{foo1, foo2}; | ^^^^ Could not find `bar` in `std` ``` Fix #43040.
2017-07-25Point at path segment on module not foundEsteban Küber-103/+150
Point at the correct path segment on a import statement where a module doesn't exist. New output: ```rust error[E0432]: unresolved import `std::bar` --> <anon>:1:10 | 1 | use std::bar::{foo1, foo2}; | ^^^ Could not find `bar` in `std` ``` instead of: ```rust error[E0432]: unresolved import `std::bar::foo1` --> <anon>:1:16 | 1 | use std::bar::{foo1, foo2}; | ^^^^ Could not find `bar` in `std` error[E0432]: unresolved import `std::bar::foo2` --> <anon>:1:22 | 1 | use std::bar::{foo1, foo2}; | ^^^^ Could not find `bar` in `std` ```
2017-07-25Bump master to 1.21.0Alex Crichton-2/+0
This commit bumps the master branch's version to 1.21.0 and also updates the bootstrap compiler from the freshly minted beta release.
2017-07-23Auto merge of #43096 - estebank:ascription-help, r=nikomatsakisbors-14/+63
Point at `:` when using it instead of `;` When triggering type ascription in such a way that we can infer a statement end was intended, add a suggestion for the change. Always point out the reason for the expectation of a type is due to type ascription. Fix #42057, #41928.
2017-07-18Handle type ascription cases with a method call instead of a typeEsteban Küber-14/+63
2017-07-17Change some helps to suggestionsOliver Schneider-10/+15
2017-07-10Store all generic arguments for method calls in ASTVadim Petrochenkov-8/+6
2017-07-08Move public reexports of private extern crates into a separate lintVadim Petrochenkov-3/+5
This is going to be a hard error while all private-in-public errors from rustc_privacy will be reclassified into lints.
2017-07-08Remove more anonymous trait method parametersVadim Petrochenkov-1/+1
2017-07-06remove associated_consts feature gateSean McArthur-3/+2
2017-06-29Make `$crate` a keywordVadim Petrochenkov-5/+7
2017-06-23Rollup merge of #42833 - durka:non-constant-used-with-constant, ↵Mark Simulacrum-1/+1
r=Mark-Simulacrum change span label for E0435 r? @Mark-Simulacrum
2017-06-23Removed as many "```ignore" as possible.kennytm-41/+57
Replaced by adding extra imports, adding hidden code (`# ...`), modifying examples to be runnable (sorry Homura), specifying non-Rust code, and converting to should_panic, no_run, or compile_fail. Remaining "```ignore"s received an explanation why they are being ignored.
2017-06-22change span label for E0435 (fix #41871)Alex Burka-1/+1
2017-06-21Auto merge of #42076 - alex-ozdemir:master, r=nrcbors-23/+39
Clearer Error Message for Duplicate Definition Clearer use of the error message and span labels to communicate duplication definitions/imports. fixes #42061
2017-06-20Rollup merge of #42728 - jseyfried:fix_resolve_perf, r=nrcCorey Farwell-1/+4
resolve: fix perf bug Fixes #42544. r? @nrc
2017-06-19Bump version and stage0 compilerAlex Crichton-4/+0