about summary refs log tree commit diff
path: root/src/librustc_resolve
AgeCommit message (Collapse)AuthorLines
2016-11-20Move `syntax::util::interner` -> `syntax::symbol`, cleanup.Jeffrey Seyfried-5/+5
2016-11-20Refactor `MetaItemKind` to use `Name`s instead of `InternedString`s.Jeffrey Seyfried-6/+3
2016-11-20Refactor away `ast::Attribute_`.Jeffrey Seyfried-1/+1
2016-11-17Cleanup formatting.Jeffrey Seyfried-23/+28
2016-11-17Add feature `use_extern_macros`.Jeffrey Seyfried-133/+234
2016-11-17Refactor out `PerNS`.Jeffrey Seyfried-176/+184
2016-11-17Add field `expansion: Mark` to `NameBinding`.Jeffrey Seyfried-43/+68
2016-11-17Refactor `Resolver::builtin_macros` to use `NameBinding`s instead of `DefId`s.Jeffrey Seyfried-12/+20
2016-11-17Resolve imports during expansion.Jeffrey Seyfried-20/+13
2016-11-17Add field `module.unresolved_invocations`.Jeffrey Seyfried-3/+14
2016-11-11Auto merge of #37456 - estebank:unused-imports-verbosity, r=jonathandturnerbors-12/+42
Group unused import warnings per import list Given a file ``` rust use std::collections::{BinaryHeap, BTreeMap, BTreeSet}; fn main() {} ``` Show a single warning, instead of three for each unused import: ``` nocode warning: unused imports, #[warn(unused_imports)] on by default --> file2.rs:1:24 | 1 | use std::collections::{BinaryHeap, BTreeMap, BTreeSet}; | ^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ``` Include support for lints pointing at `MultilineSpan`s, instead of just `Span`s. Fixes #16132.
2016-11-11Auto merge of #37447 - estebank:non-duplicate-definition-error, r=nrcbors-1/+13
Show one error for duplicated type definitions For the following code: ``` rustc struct Bar; struct Bar; fn main () { } ``` show ``` nocode error[E0428]: a type named `Bar` has already been defined in this module --> src/test/compile-fail/E0428.rs:12:1 | 11 | struct Bar; | ----------- previous definition of `Bar` here 12 | struct Bar; | ^^^^^^^^^^^ error: aborting due to previous error ``` instead of ``` nocode error[E0428]: a type named `Bar` has already been defined in this module --> src/test/compile-fail/E0428.rs:12:1 | 11 | struct Bar; | ----------- previous definition of `Bar` here 12 | struct Bar; | ^^^^^^^^^^^ error[E0428]: a value named `Bar` has already been defined in this module --> src/test/compile-fail/E0428.rs:12:1 | 11 | struct Bar; | ----------- previous definition of `Bar` here 12 | struct Bar; | ^^^^^^^^^^^ error: aborting due to 2 previous errors ``` Fixes #35767.
2016-11-10Auto merge of #37645 - jseyfried:fix_crate_var_in_custom_derives, r=nrcbors-1/+28
Fix regression involving custom derives on items with `$crate` The regression was introduced in #37213. I believe we cannot make the improvements from #37213 work with the current custom derive setup (c.f. https://github.com/rust-lang/rust/issues/37637#issuecomment-258959145) -- we'll have to wait for `TokenStream`'s API to improve. Fixes #37637. r? @nrc
2016-11-10Support `#[macro_reexport]`ing custom derives.Jeffrey Seyfried-73/+48
2016-11-10Elimite `$crate` before invokng custom derives.Jeffrey Seyfried-1/+28
2016-11-10Improve macro reexports.Jeffrey Seyfried-109/+109
2016-11-10Add variants `Def::Macro` and `Namespace::MacroNS`.Jeffrey Seyfried-2/+11
2016-11-10Register and stability check `#[no_link]` crates.Jeffrey Seyfried-3/+4
2016-11-10Avoid building multiple reduced graphs for a crateJeffrey Seyfried-9/+15
that is referenced by multiple `extern crate` items.
2016-11-10Treat `extern crate`s more like imports (pure refactoring).Jeffrey Seyfried-39/+52
2016-11-10nit: clean up some redundant code.Jeffrey Seyfried-9/+5
2016-11-10Rollup merge of #37412 - eddyb:lazy-6, r=nikomatsakisEduard-Mihai Burtescu-34/+35
[6/n] rustc: transition HIR function bodies from Block to Expr. _This is part of a series ([prev](https://github.com/rust-lang/rust/pull/37408) | [next](https://github.com/rust-lang/rust/pull/37676)) of patches designed to rework rustc into an out-of-order on-demand pipeline model for both better feature support (e.g. [MIR-based](https://github.com/solson/miri) early constant evaluation) and incremental execution of compiler passes (e.g. type-checking), with beneficial consequences to IDE support as well. If any motivation is unclear, please ask for additional PR description clarifications or code comments._ <hr> The main change here is that functions and closures both use `Expr` instead of `Block` for their bodies. For closures this actually allows a honest representation of brace-less closure bodies, e.g. `|x| x + 1` is now distinguishable from `|x| { x + 1 }`, therefore this PR is `[syntax-breaking]` (cc @Manishearth). Using `Expr` allows more logic to be shared between constant bodies and function bodies, with some small such changes already part of this PR, and eventually easing #35078 and per-body type tables. Incidentally, there used to be some corners cut here and there and as such I had to (re)write divergence tracking for type-checking so that it is capable of understanding basic structured control-flow: ``` rust fn a(x: bool) -> i32 { // match also works (as long as all arms diverge) if x { panic!("true") } else { return 1; } 0 // "unreachable expression" after this PR } ``` And since liveness' "not all control paths return a value" moved to type-checking we can have nice things: ``` rust // before & after: fn b() -> i32 { 0; } // help: consider removing this semicolon // only after this PR fn c() -> i32 { { 0; } } // help: consider removing this semicolon fn d() { let x: i32 = { 0; }; } // help: consider removing this semicolon fn e() { f({ 0; }); } // help: consider removing this semicolon ```
2016-11-09Show one error for duplicated type definitionsEsteban Küber-1/+13
For the following code: ```rustc struct Bar; struct Bar; fn main () { } ``` show ```nocode error[E0428]: a type named `Bar` has already been defined in this module --> src/test/compile-fail/E0428.rs:12:1 | 11 | struct Bar; | ----------- previous definition of `Bar` here 12 | struct Bar; | ^^^^^^^^^^^ error: aborting due to previous error ``` instead of ```nocode error[E0428]: a type named `Bar` has already been defined in this module --> src/test/compile-fail/E0428.rs:12:1 | 11 | struct Bar; | ----------- previous definition of `Bar` here 12 | struct Bar; | ^^^^^^^^^^^ error[E0428]: a value named `Bar` has already been defined in this module --> src/test/compile-fail/E0428.rs:12:1 | 11 | struct Bar; | ----------- previous definition of `Bar` here 12 | struct Bar; | ^^^^^^^^^^^ error: aborting due to 2 previous errors ```
2016-11-10rustc: unify and simplify managing associated items.Eduard Burtescu-1/+1
2016-11-10syntax: don't fake a block around closures' bodies during parsing.Eduard Burtescu-34/+35
2016-11-09Rollup merge of #37428 - estebank:generic-type-error-span, r=sanxiynEduard-Mihai Burtescu-11/+25
Point to type argument span when used as trait Given the following code: ``` rust struct Foo<T: Clone>(T); use std::ops::Add; impl<T: Clone, Add> Add for Foo<T> { type Output = usize; fn add(self, rhs: Self) -> Self::Output { unimplemented!(); } } ``` present the following output: ``` nocode error[E0404]: `Add` is not a trait --> file3.rs:5:21 | 5 | impl<T: Clone, Add> Add for Okok<T> { | --- ^^^ expected trait, found type parameter | | | type parameter defined here ``` Fixes #35987.
2016-11-09Rollup merge of #37229 - nnethercote:FxHasher, r=nikomatsakisEduard-Mihai Burtescu-39/+39
Replace FNV with a faster hash function. Hash table lookups are very hot in rustc profiles and the time taken within `FnvHash` itself is a big part of that. Although FNV is a simple hash, it processes its input one byte at a time. In contrast, Firefox has a homespun hash function that is also simple but works on multiple bytes at a time. So I tried it out and the results are compelling: ``` futures-rs-test 4.326s vs 4.212s --> 1.027x faster (variance: 1.001x, 1.007x) helloworld 0.233s vs 0.232s --> 1.004x faster (variance: 1.037x, 1.016x) html5ever-2016- 5.397s vs 5.210s --> 1.036x faster (variance: 1.009x, 1.006x) hyper.0.5.0 5.018s vs 4.905s --> 1.023x faster (variance: 1.007x, 1.006x) inflate-0.1.0 4.889s vs 4.872s --> 1.004x faster (variance: 1.012x, 1.007x) issue-32062-equ 0.347s vs 0.335s --> 1.035x faster (variance: 1.033x, 1.019x) issue-32278-big 1.717s vs 1.622s --> 1.059x faster (variance: 1.027x, 1.028x) jld-day15-parse 1.537s vs 1.459s --> 1.054x faster (variance: 1.005x, 1.003x) piston-image-0. 11.863s vs 11.482s --> 1.033x faster (variance: 1.060x, 1.002x) regex.0.1.30 2.517s vs 2.453s --> 1.026x faster (variance: 1.011x, 1.013x) rust-encoding-0 2.080s vs 2.047s --> 1.016x faster (variance: 1.005x, 1.005x) syntex-0.42.2 32.268s vs 31.275s --> 1.032x faster (variance: 1.014x, 1.022x) syntex-0.42.2-i 17.629s vs 16.559s --> 1.065x faster (variance: 1.013x, 1.021x) ``` (That's a stage1 compiler doing debug builds. Results for a stage2 compiler are similar.) The attached commit is not in a state suitable for landing because I changed the implementation of FnvHasher without changing its name (because that would have required touching many lines in the compiler). Nonetheless, it is a good place to start discussions. Profiles show very clearly that this new hash function is a lot faster to compute than FNV. The quality of the new hash function is less clear -- it seems to do better in some cases and worse in others (judging by the number of instructions executed in `Hash{Map,Set}::get`). CC @brson, @arthurprs
2016-11-08Group unused import warnings per path listEsteban Küber-12/+42
Given a file ```rust use std::collections::{BinaryHeap, BTreeMap, BTreeSet}; fn main() {} ``` Show a single warning, instead of three for each unused import: ```nocode warning: unused imports, #[warn(unused_imports)] on by default --> foo.rs:1:24 | 1 | use std::collections::{BinaryHeap, BTreeMap, BTreeSet}; | ^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ``` Include support for lints pointing at `MultilineSpan`s, instead of just `Span`s.
2016-11-08Point to type argument span when used as traitEsteban Küber-11/+25
Given the following code: ```rust struct Foo<T: Clone>(T); use std::ops::Add; impl<T: Clone, Add> Add for Foo<T> { type Output = usize; fn add(self, rhs: Self) -> Self::Output { unimplemented!(); } } ``` present the following output: ```nocode error[E0404]: `Add` is not a trait --> file3.rs:5:21 | 5 | impl<T: Clone, Add> Add for Okok<T> { | --- ^^^ expected trait, found type parameter | | | type parameter defined here ```
2016-11-08Auto merge of #36843 - petrochenkov:dotstab, r=nikomatsakisbors-1/+1
Stabilize `..` in tuple (struct) patterns I'd like to nominate `..` in tuple and tuple struct patterns for stabilization. This feature is a relatively small extension to existing stable functionality and doesn't have known blockers. The feature first appeared in Rust 1.10 6 months ago. An example of use: https://github.com/rust-lang/rust/pull/36203 Closes https://github.com/rust-lang/rust/issues/33627 r? @nikomatsakis
2016-11-08Replace FnvHasher use with FxHasher.Nicholas Nethercote-39/+39
This speeds up compilation by 3--6% across most of rustc-benchmarks.
2016-11-06Auto merge of #37506 - jseyfried:improve_shadowing_checks, r=nrcbors-16/+29
macros: improve shadowing checks This PR improves macro-expanded shadowing checks to work with out-of-(pre)order expansion. Out-of-order expansion became possible in #37084, so this technically a [breaking-change] for nightly. The regression test from this PR is an example of code that would break. r? @nrc
2016-11-03Stabilize `..` in tuple (struct) patternsVadim Petrochenkov-1/+1
2016-11-02Rollup merge of #37498 - sanxiyn:unused-type-alias, r=eddybJonathan Turner-3/+0
Remove unused type aliases Found by extending the dead code lint. The lint itself is work in progress because of false positives. cc #37455.
2016-11-02Fix shadowing checking.Jeffrey Seyfried-8/+21
2016-10-31Remove unused type aliasesSeo Sanghyeon-3/+0
2016-10-31Rollup merge of #37475 - AndiDog:feature/error-explanation-E0532, ↵Guillaume Gomez-1/+41
r=GuillaumeGomez Add E0532 error explanation This resolves one of the error list in https://github.com/rust-lang/rust/issues/35347 - just because I stumbled over it today. I assumed the error code should be removed from `register_diagnostics!` because it's now defined above. Since that is my first code contribution, please check that all is in order. It would be helpful to know how to run the test for the `compile_fail,E0532` part. I did `make check-stage1-cfail NO_REBUILD=1` but that doesn't test the inlined example. r? @GuillaumeGomez
2016-10-31Cleanup `Resolver::disallowed_shadowing`.Jeffrey Seyfried-11/+11
2016-10-31Add E0532 error explanationAndreas Sommer-1/+41
2016-10-28Rollup merge of #37430 - robinst:missing-crate-message-add-semicolon, r=eddybGuillaume Gomez-1/+1
Add semicolon to "Maybe a missing `extern crate foo`" message I had it a couple of times that I was missing the "extern crate" line after I introduced a new dependency. So I copied the text from the message and inserted it into the beginning of my code, only to find the compiler complaining that I was missing the semicolon. (I forgot to add it after the text that I had pasted.) There's a similar message which does include the semicolon, namely "help: you can import it into scope: `use foo::Bar;`". I think the two messages should be consistent, so this change adds it for "extern crate".
2016-10-27Preparations and cleanupVadim Petrochenkov-60/+15
Diagnostics for struct path resolution errors in resolve and typeck are unified. Self type is treated as a type alias in few places (not reachable yet). Unsafe cell is seen in constants even through type aliases. All checks for struct paths in typeck work on type level.
2016-10-27Add semicolon to "Maybe a missing `extern crate foo`" messageRobin Stocker-1/+1
I had it a couple of times that I was missing the "extern crate" line after I introduced a new dependency. So I copied the text from the message and inserted it into the beginning of my code, only to find the compiler complaining that I was missing the semicolon. (I forgot to add it after the text that I had pasted.) There's a similar message which does include the semicolon, namely "help: you can import it into scope: `use foo::Bar;`". I think the two messages should be consistent, so this change adds it for "extern crate".
2016-10-26Rollup merge of #37394 - cramertj:cramertj/unused-import-with-id, ↵Guillaume Gomez-4/+6
r=GuillaumeGomez Add identifier to unused import warnings Fix #37376. For some reason, though, I'm getting warnings with messages like "76:9: 76:16: unused import: `self::g`" instead of "unused import: `self::g`". @pnkfelix Any ideas what might be causing this?
2016-10-25Avoid false positive `unused_extern_crates`.Jeffrey Seyfried-0/+1
2016-10-25Support `use $crate;` with a future compatibility warning.Jeffrey Seyfried-10/+25
2016-10-25Fix `$crate`-related regressions.Jeffrey Seyfried-3/+7
2016-10-25Add identifier to unused import warningsTaylor Cramer-4/+6
2016-10-25Auto merge of #37360 - jseyfried:fix_label_scope, r=nrcbors-19/+13
resolve: fix label scopes Fixes #37353 (turns an ICE back into an error). r? @nrc
2016-10-24Refactor away `CrateLoader::load_macros`.Jeffrey Seyfried-4/+5
2016-10-24Refactor away fields `MacroDef::{use_locally, export}`.Jeffrey Seyfried-13/+13