about summary refs log tree commit diff
path: root/src/librustc_passes
AgeCommit message (Collapse)AuthorLines
2017-09-11rustc: introduce ty::Const { ConstVal, Ty }.Eduard-Mihai Burtescu-7/+6
2017-09-11rustc: intern ConstVal's in TyCtxt.Eduard-Mihai Burtescu-1/+1
2017-09-09Don't promote references to statics that occur in non-static locationsAaron Hill-15/+31
2017-09-08Fix regression in promotion of rvalues referencing a staticAaron Hill-1/+22
This commit makes librustc_passes::consts::CheckCrateVisitor properly mark expressions as promotable if they reference a static, as it's perfectly fine for one static to reference another. It fixes a regression that prevented a temporary rvalue from referencing a static if it was itself declared within a static. Prior to commit https://github.com/rust-lang/rust/commit/b8c05fe90bc, `region::ScopeTree` would only register a 'terminating scope' for function bodies. Thus, while rvalues in a static that referenced a static would be marked unpromotable, the lack of enclosing scope would cause mem_categorization::MemCategorizationContext::cat_rvalue_node to compute a 'temporary scope' of `ReStatic`. Since this had the same effect as explicitly selecting a scope of `ReStatic` due to the rvalue being marked by CheckCrateVisitor as promotable, no issue occurred. However, commit https://github.com/rust-lang/rust/commit/b8c05fe90bc made ScopeTree unconditionally register a 'terminating scope' Since mem_categorization would now compute a non-static 'temporary scope', the aforementioned rvalues would be erroneously marked as living for too short a time. By fixing the behavior of CheckCrateVisitor, this commit avoids changing mem_categorization's behavior, while ensuring that temporary values in statics are still allowed to reference other statics. Fixes issue #44373
2017-09-05rustc: Migrate lang items to a queryAlex Crichton-1/+1
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-2/+2
2017-08-30Auto merge of #43932 - eddyb:const-scoping, r=nikomatsakisbors-16/+21
Forward-compatibly deny drops in constants if they *could* actually run. This is part of #40036, specifically the checks for user-defined destructor invocations on locals which *may not* have been moved away, the motivating example being: ```rust const FOO: i32 = (HasDrop {...}, 0).1; ``` The evaluation of constant MIR will continue to create `'static` slots for more locals than is necessary (if `Storage{Live,Dead}` statements are ignored), but it shouldn't be misusable. r? @nikomatsakis
2017-08-28rustc: treat impl associated consts like const items for constness.Eduard-Mihai Burtescu-16/+21
2017-08-28Merge branch 'master' of https://github.com/rust-lang/rust into genJohn Kåre Alsaker-3/+0
2017-08-25*: remove crate_{name,type} attributesTamir Duberstein-3/+0
Fixes #41701.
2017-08-25Merge remote-tracking branch 'origin/master' into genAlex Crichton-8/+0
2017-08-24Auto merge of #43532 - petrochenkov:pgargs, r=nikomatsakisbors-8/+0
Desugar parenthesized generic arguments in HIR Fixes ICE in https://github.com/rust-lang/rust/issues/43431 and maybe some other similar issues. r? @eddyb
2017-08-21Merge remote-tracking branch 'origin/master' into genAlex Crichton-41/+2
2017-08-19rustc: Remove some dead codeVadim Petrochenkov-41/+2
2017-08-19Desugar parenthesized generic arguments in HIRVadim Petrochenkov-8/+0
2017-08-16Merge remote-tracking branch 'origin/master' into genAlex Crichton-4/+4
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-4/+4
Like #43008 (f668999), but _much more aggressive_.
2017-08-14Merge remote-tracking branch 'origin/master' into genAlex Crichton-14/+34
2017-08-14Auto merge of #43740 - michaelwoerister:local-id-in-typecktables, r=arielb1bors-8/+8
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-14Auto merge of #43844 - arielb1:literally-nonstandard, r=eddybbors-6/+21
ast_validation: forbid "nonstandard" literal patterns Since #42886, macros can create "nonstandard" PatKind::Lit patterns, that contain path expressions instead of the usual literal expr. These can cause trouble, including ICEs. We *could* map these nonstandard patterns to PatKind::Path patterns during HIR lowering, but that would be much effort for little gain, and I think is too risky for beta. So let's just forbid them during AST validation. Fixes #43250. beta-nominating because regression. r? @eddyb
2017-08-13ast_validation: forbid "nonstandard" literal patternsAriel Ben-Yehuda-6/+21
Since #42886, macros can create "nonstandard" PatKind::Lit patterns, that contain path expressions instead of the usual literal expr. These can cause trouble, including ICEs. We *could* map these nonstandard patterns to PatKind::Path patterns during HIR lowering, but that would be much effort for little gain, and I think is too risky for beta. So let's just forbid them during AST validation. Fixes #43250.
2017-08-12Fix `-Z hir-stats` always panics (fix #43232).kennytm-0/+5
2017-08-11Improve validation of TypeckTables keys.Michael Woerister-1/+1
2017-08-11Encapsulate sub-table access in TypeckTables and validate keys on each access.Michael Woerister-4/+2
2017-08-11Use ItemLocalId as key for TypeckTables::cast_kinds.Michael Woerister-1/+2
2017-08-11Use ItemLocalId as key for node_types, node_substs, and adjustments in ↵Michael Woerister-3/+3
TypeckTables.
2017-08-11Make TypeckTables::type_dependent_defs use ItemLocalId instead of NodeId.Michael Woerister-4/+5
2017-08-10Merge remote-tracking branch 'origin/master' into genAlex Crichton-16/+50
2017-08-10Auto merge of #43522 - alexcrichton:rewrite-lints, r=michaelwoeristerbors-15/+16
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-09Merge remote-tracking branch 'origin/master' into genAlex Crichton-1/+4
2017-08-09rustc: Rearchitect lints to be emitted more eagerlyAlex Crichton-15/+16
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-09extended information for E0571 break with value in non-`loop` loopZack M. Davis-1/+34
2017-08-06fixing doctest failures in resurfaced extended informationZack M. Davis-1/+1
After repatriating error explanations to the global registry, some lurking doctest failures surfaced and needed to be chased down. Sadly, a few doctests needed to be ignored due to a not-yet-understood regression in the doctest `compile_fail` functionality (filed #43707).
2017-08-06de-orphan extended informationZack M. Davis-0/+2
Bizarrely, librustc_passes, librustc_plugin, librustc_mir, and libsyntax weren't getting their error explanations registered. Resolves #35284.
2017-07-30add new instructions for asserting when values are valid, and to describe ↵Ralf Jung-0/+1
when we can rely on them being locked in memory
2017-07-28Merge remote-tracking branch 'origin/master' into genAlex Crichton-1/+2
2017-07-28Remove support for `gen arg`Alex Crichton-1/+0
2017-07-28Rename suspend to yieldJohn Kåre Alsaker-2/+2
2017-07-28Fix tidy warningsAlex Crichton-2/+6
2017-07-28Generator literal supportJohn Kåre Alsaker-1/+10
2017-07-28Auto merge of #43324 - Nashenas88:visit_locations, r=arielb1bors-1/+2
Provide positional information when visiting ty, substs and closure_substs in MIR This will enable the region renumbering portion of #43234 (non-lexical lifetimes). @nikomatsakis's current plan [here](https://gist.github.com/nikomatsakis/dfc27b28cd024eb25054b52bb11082f2) shows that we need spans of the original code to create new region variables, e.g. `self.infcx.next_region_var(infer::MiscVariable(span))`. The current visitor impls did not pass positional information (`Location` in some, `Span` and `SourceInfo` for others) for all types. I did not expand this to all visits, just the ones necessary for the above-mentioned plan.
2017-07-28Auto merge of #43505 - eddyb:poly-const-eval-layout-of, r=nikomatsakisbors-16/+21
rustc_const_eval: always require Substs and a ParamEnv. Fixes #43357 by tracking the `Substs` and `ParamEnv` for const-evaluation in generic contexts.
2017-07-27Give span to angle bracketed generic argumentsVadim Petrochenkov-8/+8
2017-07-27Discern between `Path` and `Path<>` in ASTVadim Petrochenkov-3/+3
2017-07-27rustc_const_eval: keep track of the appropriate ParamEnv.Eduard-Mihai Burtescu-1/+1
2017-07-27rustc_const_eval: always require correct Substs.Eduard-Mihai Burtescu-16/+21
2017-07-19Auto merge of #42859 - eddyb:const-size-and-align-of, r=nikomatsakisbors-1/+4
Implement const fn {size,align}_of. Fixes #34078. r? @nikomatsakis
2017-07-19Implement const fn {size,align}_of.Eduard-Mihai Burtescu-1/+4
2017-07-18Provide positional information when visiting ty, substs and closure_substs ↵Paul Faria-1/+2
in MIR
2017-07-18Support generic lifetime arguments in method callsVadim Petrochenkov-12/+3