summary refs log tree commit diff
path: root/src/librustc/util
AgeCommit message (Collapse)AuthorLines
2017-09-26Auto merge of #44735 - tirr-c:issue-42143, r=arielb1bors-0/+6
Friendlier error message for closure argument type mismatch Rebased #42270. Fixes #42143. --- `test.rs`: ```rust fn main() { foo(|_: i32, _: usize| ()); } fn foo<F>(_: F) where F: Fn(&str, usize) {} ``` Before: ``` error[E0281]: type mismatch: `[closure@test.rs:2:9: 2:30]` implements the trait `std::ops::Fn<(i32, usize)>`, but the trait `for<'r> std::ops::Fn<(&'r str, usize)>` is required --> test.rs:2:5 | 2 | foo(|_: i32, _: usize| ()); | ^^^ --------------------- implements `std::ops::Fn<(i32, usize)>` | | | expected &str, found i32 | requires `for<'r> std::ops::Fn<(&'r str, usize)>` | = note: required by `foo` ``` After (early): ``` error[E0631]: type mismatch in closure arguments --> test.rs:2:5 | 2 | foo(|_: i32, _: usize| ()); | ^^^ --------------------- takes arguments of type `i32` and `usize` | | | expected arguments of type `&str` and `usize` | = note: required by `foo` ``` After (current): ``` error[E0631]: type mismatch in closure arguments --> test.rs:2:5 | 2 | foo(|_: i32, _: usize| ()); | ^^^ --------------------- found signature of `fn(i32, usize) -> _` | | | expected signature of `for<'r> fn(&'r str, usize) -> _` | = note: required by `foo` ``` ~~Compiler output has been changed, and a few tests are failing. Help me writing/fixing tests!~~ r? @nikomatsakis
2017-09-25Auto merge of #44809 - arielb1:small-scope, r=eddybbors-7/+8
encode region::Scope using fewer bytes Now that region::Scope is no longer interned, its size is more important. This PR encodes region::Scope in 8 bytes instead of 12, which should speed up region inference somewhat (perf testing needed) and should improve the margins on #36799 by 64MB (that's not a lot, I did this PR mostly to speed up region inference). This is a perf-sensitive PR. Please don't roll me up. r? @eddyb This is based on #44743 so I could get more accurate measurements on #36799.
2017-09-24move Scope behind an enumAriel Ben-Yehuda-7/+8
2017-09-23Print fn signature when there is closure argument type mismatchWonwoo Choi-0/+6
Fixes #42143. E0281 is totally replaced by E0631. UI tests are updated accordingly.
2017-09-23Compress "small" spans to 32 bits and intern "large" spansVadim Petrochenkov-2/+3
2017-09-11rustc: evaluate fixed-length array length expressions lazily.Eduard-Mihai Burtescu-0/+11
2017-09-11rustc: use ty::Const for the length of TyArray.Eduard-Mihai Burtescu-1/+14
2017-09-08Use NodeId/HirId instead of DefId for local variables.Eduard-Mihai Burtescu-7/+3
2017-09-05rustc: Migrate lang items to a queryAlex Crichton-2/+2
This commit moves the calculation of the `LanguageItems` structure into a query rather than being calculated before the `TyCtxt` exists, with the eventual end goal of removing some `CrateStore` methods.
2017-09-01rustc: rename CodeExtent to Scope and RegionMaps to ScopeTree.Eduard-Mihai Burtescu-13/+13
2017-09-01rustc: use hir::ItemLocalId instead of ast::NodeId in CodeExtent.Eduard-Mihai Burtescu-10/+9
2017-08-25Merge remote-tracking branch 'origin/master' into genAlex Crichton-0/+77
2017-08-23-Z profile-queries includes dep_graph.with_task uses in outputMatthew Hammer-1/+6
2017-08-23-Z profile-queries: remove panic when channel is unsetMatthew Hammer-1/+6
2017-08-23profiling with -Z profile-queries recognizes -Z time-passesMatthew Hammer-1/+11
2017-08-23inc comp: -Z profile-queries support; see also ↵Matthew Hammer-0/+57
https://github.com/rust-lang-nursery/rust-forge/blob/master/profile-queries.md
2017-08-14Merge remote-tracking branch 'origin/master' into genAlex Crichton-3/+6
2017-08-14Auto merge of #43740 - michaelwoerister:local-id-in-typecktables, r=arielb1bors-2/+5
Use hir::ItemLocalId as keys in TypeckTables. This PR makes `TypeckTables` use `ItemLocalId` instead of `NodeId` as key. This is needed for incremental compilation -- for stable hashing and for being able to persist and reload these tables. The PR implements the most important part of https://github.com/rust-lang/rust/issues/40303. Some notes on the implementation: * The PR adds the `HirId` to HIR nodes where needed (`Expr`, `Local`, `Block`, `Pat`) which obviates the need to store a `NodeId -> HirId` mapping in crate metadata. Thanks @eddyb for the suggestion! In the future the `HirId` should completely replace the `NodeId` in HIR nodes. * Before something is read or stored in one of the various `TypeckTables` subtables, the entry's key is validated via the new `TypeckTables::validate_hir_id()` method. This makes sure that we are not mixing information from different items in a single table. That last part could be made a bit nicer by either (a) new-typing the table-key and making `validate_hir_id()` the only way to convert a `HirId` to the new-typed key, or (b) just encapsulate sub-table access a little better. This PR, however, contents itself with not making things significantly worse. Also, there's quite a bit of switching around between `NodeId`, `HirId`, and `DefIndex`. These conversions are cheap except for `HirId -> NodeId`, so if the valued reviewer finds such an instance in a performance critical place, please let me know. Ideally we convert more and more code from `NodeId` to `HirId` in the future so that there are no more `NodeId`s after HIR lowering anywhere. Then the amount of switching should be minimal again. r? @eddyb, maybe?
2017-08-12Fix some typosBastien Orivel-1/+1
2017-08-11Use DefIndex instead of NodeId in UpvarId.Michael Woerister-2/+2
2017-08-11Make TypeckTables::type_dependent_defs use ItemLocalId instead of NodeId.Michael Woerister-0/+3
2017-08-09Initial pass review commentsAlex Crichton-1/+1
2017-08-09Merge remote-tracking branch 'origin/master' into genAlex Crichton-5/+27
2017-07-31async-llvm(25): Restore -Ztime-passes output for trans and LLVM.Michael Woerister-5/+27
2017-07-28Generator literal supportJohn Kåre Alsaker-1/+42
2017-07-12integrate anon dep nodes into trait selectionNiko Matsakis-4/+2
2017-07-11Downgrade ProjectionTy's TraitRef to its substsTobias Schottdorf-3/+8
Addresses the second part of #42171 by removing the `TraitRef` from `ProjectionTy`, and directly storing its `Substs`. Closes #42171.
2017-06-27rustc: move the PolyFnSig out of TyFnDef.Eduard-Mihai Burtescu-2/+8
2017-06-19Auto merge of #39409 - pnkfelix:mir-borrowck2, r=nikomatsakisbors-1/+28
MIR EndRegion Statements (was MIR dataflow for Borrows) This PR adds an `EndRegion` statement to MIR (where the `EndRegion` statement is what terminates a borrow). An earlier version of the PR implemented a dataflow analysis on borrow expressions, but I am now factoring that into a follow-up PR so that reviewing this one is easier. (And also because there are some revisions I want to make to that dataflow code, but I want this PR to get out of WIP status...) This is a baby step towards MIR borrowck. I just want to get the review process going while I independently work on the remaining steps.
2017-06-12`-Z identify_regions` toggles rendering of (previously hidden) unnamed regions.Felix S. Klock II-0/+23
Unlike `-Z verbose`, it is succinct. It uniquely identifies regions when displaying them, and distinguishes code extents from user-specified lifetimes in the output by leveraging a syntactic restriction: you cannot write a lifetime that starts with a numeric character. For example, it prints '<num>ce for the more verbose `ReScope(CodeExtent(<num>))`.
2017-06-12Add `-Z span_free_rvalues`.Felix S. Klock II-1/+5
This is solely a hack to make comparing test output plausible; it makes closures print as [closure@node_id] instead of [closure@span-with-host-path] in debug printouts.
2017-06-09incr.comp.: Uniformly represent DepNodes as (Kind, StableHash) pairs.Michael Woerister-2/+4
2017-06-01Auto merge of #42281 - eddyb:well-adjusted, r=nikomatsakisbors-6/+0
Decompose Adjustment into smaller steps and remove the method map. The method map held method callee information for: * actual method calls (`x.f(...)`) * overloaded unary, binary, indexing and call operators * *every overloaded deref adjustment* (many can exist for each expression) That last one was a historical ~~accident~~ hack, and part of the motivation for this PR, along with: * a desire to compose adjustments more freely * containing the autoderef logic better to avoid mutation within an inference snapshot * not creating `TyFnDef` types which are incompatible with the original one * i.e. we used to take a`TyFnDef`'s `for<'a> &'a T -> &'a U` signature and instantiate `'a` using a region inference variable, *then* package the resulting `&'b T -> &'b U` signature in another `TyFnDef`, while keeping *the same* `DefId` and `Substs` * to fix #3548 by explicitly writing autorefs for the RHS of comparison operators Individual commits tell their own story, of "atomic" changes avoiding breaking semantics. Future work based on this PR could include: * removing the signature from `TyFnDef`, now that it's always "canonical" * some questions of variance remain, as subtyping *still* treats the signature differently * moving part of the typeck logic for methods, autoderef and coercion into `rustc::traits` * allowing LUB coercions (joining multiple expressions) to "stack up" many adjustments * transitive coercions (e.g. reify or unsize after multiple steps of autoderef) r? @nikomatsakis
2017-06-01rustc: remove unnecessary ItemSubsts wrapper.Eduard-Mihai Burtescu-6/+0
2017-05-31Upgrade ProjectionTy's Name to a DefIdTobias Schottdorf-4/+7
Part of #42171, in preparation for downgrading the contained `TraitRef` to only its `substs`.
2017-05-22centralize the caching for is-copy, is-sized, and is-freezeNiko Matsakis-7/+1
Use the trait-environment+type as the key. Note that these are only invoked on types that live for the entire compilation (no inference artifacts). We no longer need the various special-case bits and caches that were in place before.
2017-05-16Auto merge of #41907 - est31:macro_unused, r=jseyfriedbors-0/+1
Add lint for unused macros Addresses parts of #34938, to add a lint for unused macros. We now output warnings by default when we encounter a macro that we didn't use for expansion. Issues to be resolved before this PR is ready for merge: - [x] fix the NodeId issue described above - [x] remove all unused macros from rustc and the libraries or set `#[allow(unused_macros)]` next to them if they should be kept for some reason. This is needed for successful boostrap and bors to accept the PR. -> #41934 - [x] ~~implement the full extent of #34938, that means the macro match arm checking as well.~~ *let's not do this for now*
2017-05-16put option_try macro def under #[cfg(unix)]est31-0/+1
2017-05-13rustc: stop interning CodeExtent, it's small enough.Eduard-Mihai Burtescu-2/+2
2017-05-13rustc: treat ReEarlyBound as free without replacing it with ReFree.Eduard-Mihai Burtescu-5/+1
2017-05-13rustc: use DefId instead of CodeExtent for FreeRegion's scope.Eduard-Mihai Burtescu-3/+1
2017-04-30intern CodeExtentsNiko Matsakis-8/+8
Make a `CodeExtent<'tcx>` be something allocated in an arena instead of an index into the `RegionMaps`.
2017-04-24rustc: rename some of the queries to match tcx methods.Eduard-Mihai Burtescu-5/+5
2017-04-11add Subtype predicateNiko Matsakis-0/+14
2017-03-17Fix race condition in fs::create_dir_allDavid Roundy-20/+0
It is more robust to not fail if any directory in a path was created concurrently. This change lifts rustc internal `create_dir_racy` that was created to handle such conditions to be new `create_dir_all` implementation.
2017-03-13some style fixesTshepang Lekhonkhobe-4/+5
2017-02-25rustc_typeck: move the leaves (generics, trait_def, adt_def) to on-demand.Eduard-Mihai Burtescu-10/+1
2017-02-25rustc: combine BareFnTy and ClosureTy into FnSig.Eduard-Mihai Burtescu-27/+10
2017-02-25rustc: introduce a query system for type information in ty::maps.Eduard Burtescu-1/+1
2017-02-25rustc: consolidate dep-tracked hashmaps in tcx.maps.Eduard-Mihai Burtescu-1/+1