about summary refs log tree commit diff
path: root/src/librustc/middle
AgeCommit message (Collapse)AuthorLines
2017-11-20Add type checking for the lang itemScott McMurray-0/+5
As part of doing so, add more lang items instead of passing u128 to the i128 ones where it doesn't matter in twos-complement.
2017-11-19dead code lint to say "never constructed" for variantsZack M. Davis-9/+14
As reported in #19140, #44083, and #44565, some users were confused when the dead-code lint reported an enum variant to be "unused" when it was matched on (but not constructed). This wording change makes it clearer that the lint is in fact checking for construction. We continue to say "used" for all other items (it's tempting to say "called" for functions and methods, but this turns out not to be correct: functions can be passed as arguments and the dead-code lint isn't special-casing that or anything). Resolves #19140.
2017-11-18Add a MIR pass to lower 128-bit operators to lang item callsScott McMurray-0/+23
Runs only with `-Z lower_128bit_ops` since it's not hooked into targets yet.
2017-11-18rustc_mir: always downcast enums, even if univariant.Eduard-Mihai Burtescu-2/+2
2017-11-18convert the `closure_kinds` map to just store the origin informationNiko Matsakis-3/+3
The closure kinds themselves are now completely found in the `ClosureSubsts`.
2017-11-18stop using the `closure_kinds` query / table for anythingNiko Matsakis-4/+13
Closure Kind is now extracted from the closure substs exclusively.
2017-11-17Fix impl Trait Lifetime HandlingTaylor Cramer-12/+126
After this change, impl Trait existentials are desugared to a new `abstract type` definition paired with a set of lifetimes to apply. In-scope generics are included as parents of the `abstract type` generics. Parent regions are replaced with static, and parent regions referenced in the `impl Trait` type are duplicated at the end of the `abstract type`'s generics.
2017-11-17Auto merge of #46004 - michaelwoerister:cached-mir-wip-3, r=nikomatsakisbors-9/+9
incr.comp.: Implement query result cache and use it to cache type checking tables. This is a spike implementation of caching more than LLVM IR and object files when doing incremental compilation. At the moment, only the `typeck_tables_of` query is cached but MIR and borrow-check will follow shortly. The feature is activated by running with `-Zincremental-queries` in addition to `-Zincremental`, it is not yet active by default. r? @nikomatsakis
2017-11-16Auto merge of #45825 - nikomatsakis:nll-factor-region-inference, r=arielb1bors-5/+5
integrate MIR type-checker with NLL inference This branch refactors NLL type inference so that it uses the MIR type-checker to gather constraints. Along the way, it also refactors how region constraints are gathered in the normal inference context mildly. The new setup is like this: - What used to be `region_inference` is split into two parts: - `region_constraints`, which just collects up sets of constraints - `lexical_region_resolve`, which does the iterative, lexical region resolution - When `resolve_regions_and_report_errors` is invoked, the inference engine converts the constraints into final values. - In the MIR type checker, however, we do not invoke this method, but instead periodically take the region constraints and package them up for the NLL solver to use later. - This allows us to track when and where those constraints were incurred. - We also remove the central fulfillment context from the MIR type checker, instead instantiating new fulfillment contexts at each point. This allows us to capture the set of obligations that occurred at a particular point, and also to ensure that if the same obligation arises at two points, we will enforce the region constraints at both locations. - The MIR type checker is also enhanced to instantiate late-bound-regions with fresh variables and handle a few other corner cases that arose. - I also extracted some of the 'outlives' logic from the regionck, which will be needed later (see future work) to handle the type-outlives relationships. One concern I have with this branch: since the MIR type checker is used even without the `-Znll` switch, I'm not sure if it will impact performance. One simple fix here would be to only enable the MIR type-checker if debug-assertions are enabled, since it just serves to validate the MIR. Longer term I hope to address this by improving the interface to the trait solver to be more query-based (ongoing work). There is plenty of future work left. Here are two things that leap to mind: - **Type-region outlives.** Currently, the NLL solver will ICE if it is required to handle a constraint like `T: 'a`. Fixing this will require a small amount of refactoring to extract the implied bounds code. I plan to follow a file-up bug on this (hopefully with mentoring instructions). - **Testing.** It's a good idea to enumerate some of the tricky scenarios that need testing, but I think it'd be nice to try and parallelize some of the actual test writing (and resulting bug fixing): - Same obligation occurring at two points. - Well-formedness and trait obligations of various kinds (which are not all processed by the current MIR type-checker). - More tests for how subtyping and region inferencing interact. - More suggestions welcome! r? @arielb1
2017-11-16incr.comp.: Remove default serialization implementations for things in ↵Michael Woerister-2/+2
rustc::hir::def_id so that we get an ICE instead of silently doing the wrong thing.
2017-11-16Introduce LocalDefId which provides a type-level guarantee that the DefId is ↵Michael Woerister-7/+7
from the local crate.
2017-11-16integrate NLL with MIR type-checkerNiko Matsakis-1/+1
2017-11-16rename `region_inference` module to `region_constraints`Niko Matsakis-4/+4
2017-11-15Add collection of impl Trait argument lifetimesChristopher Vittal-0/+11
2017-11-15Split hir::TyImplTrait, move checks to HIR loweringChristopher Vittal-1/+1
Replace hir::TyImplTrait with TyImplTraitUniversal and TyImplTraitExistential. Add an ImplTraitContext enum to rustc::hir::lowering to track the kind and allowedness of an impl Trait. Significantly alter lowering to thread ImplTraitContext and one other boolean parameter described below throughought much of lowering. The other parameter is for tracking if lowering a function is in a trait impl, as there is not enough information to otherwise know this information during lowering otherwise. This change also removes the checks from ast_ty_to_ty for impl trait allowedness as they are now all taking place in HIR lowering.
2017-11-14rustc: split off BodyOwnerKind from MirSource.Eduard-Mihai Burtescu-2/+1
2017-11-12Auto merge of #45864 - nikomatsakis:issue-30046-infer-fn-once-in-closures, ↵bors-60/+5
r=eddyb adjust closure kind based on the guarantor's upvar note Fixes #30046. r? @eddyb
2017-11-11Auto merge of #45772 - leodasvacas:fix-auto-bounds-in-trait-objects, ↵bors-1/+0
r=nikomatsakis Fix checking of auto trait bounds in trait objects. Any auto trait is allowed in trait object bounds. Fix duplicate check of type and lifetime parameter count, which we were [emitting twice](https://play.rust-lang.org/?gist=37dbbdbbec62dec423bb8f6d92f137cc&version=stable). Note: This was the last use of `Send` in the compiler, meaning after a new `stage0` we could remove the `send` lang item.
2017-11-10Auto merge of #45707 - Ryman:deprecated-item-name, r=nikomatsakisbors-5/+7
rustc: add item name to deprecated lint warning It can sometimes be difficult to know what is actually deprecated when you have `foo.bar()` and `bar` comes from a trait in another crate.
2017-11-09Auto merge of #45736 - oli-obk:rvalue_promotable_map, r=nikomatsakisbors-6/+6
Use a `Set<T>` instead of a `Map<T, bool>` r? @nikomatsakis introduced in #44501
2017-11-08Auto merge of #45867 - michaelwoerister:check-ich-stability, r=nikomatsakisbors-3/+7
incr.comp.: Verify stability of incr. comp. hashes and clean up various other things. The main contribution of this PR is that it adds the `-Z incremental-verify-ich` functionality. Normally, when the red-green tracking system determines that a certain query result has not changed, it does not re-compute the incr. comp. hash (ICH) for that query result because that hash is already known. `-Z incremental-verify-ich` tells the compiler to re-hash the query result and compare the new hash against the cached hash. This is a rather thorough way of - testing hashing implementation stability, - finding missing `[input]` annotations on `DepNodes`, and - finding missing read-edges, since both a missed read and a missing `[input]` annotation can lead to something being marked as green instead of red and thus will have a different hash than it should have. Case in point, implementing this verification logic and activating it for all `src/test/incremental` tests has revealed several such oversights, all of which are fixed in this PR. r? @nikomatsakis
2017-11-08use the derived Debug rather than our custom written onesNiko Matsakis-60/+5
That encoding that the custom Debugs was using is rather inscrutable, and incomplete.
2017-11-07incr.comp.: Always require Session when decoding Spans (as to avoid silently ↵Michael Woerister-3/+7
wrong results).
2017-11-07Remove `send` lang item.leonardo.yvens-1/+0
It's completely unused.
2017-11-06Auto merge of #45668 - nikomatsakis:nll-free-region, r=arielb1bors-0/+13
extend NLL with preliminary support for free regions on functions This PR extends https://github.com/rust-lang/rust/pull/45538 with support for free regions. This is pretty preliminary and will no doubt want to change in various ways, particularly as we add support for closures, but it's enough to get the basic idea in place: - We now create specific regions to represent each named lifetime declared on the function. - Region values can contain references to these regions (represented for now as a `BTreeSet<RegionIndex>`). - If we wind up trying to infer that `'a: 'b` must hold, but no such relationship was declared, we report an error. It also does a number of drive-by refactorings. r? @arielb1 cc @spastorino
2017-11-05Auto merge of #44042 - LukasKalbertodt:ascii-methods-on-instrinsics, ↵bors-0/+1
r=alexcrichton Copy all `AsciiExt` methods to the primitive types directly in order to deprecate it later **EDIT:** [this PR is ready now](https://github.com/rust-lang/rust/pull/44042#issuecomment-333883548). I edited this post to reflect the current status of discussion, which is (apart from code review) pretty much settled. --- This is my current progress in order to prepare stabilization of #39658. As discussed there (and in #39659), the idea is to deprecated `AsciiExt` and copy all methods to the type directly. Apparently there isn't really a reason to have those methods in an extension trait¹. ~~This is **work in progress**: copy&pasting code while slightly modifying the documentation isn't the most exciting thing to do. Therefore I wanted to already open this WIP PR after doing basically 1/4 of the job (copying methods to `&[u8]`, `char` and `&str` is still missing) to get some feedback before I continue. Some questions possibly worth discussing:~~ 1. ~~Does everyone agree that deprecating `AsciiExt` is a good idea? Does everyone agree with the goal of this PR?~~ => apparently yes 2. ~~Are my changes OK so far? Did I do something wrong?~~ 3. ~~The issue of the unstable-attribute is currently set to 0. I would wait until you say "Ok" to the whole thing, then create a tracking issue and then insert the correct issue id. Is that ok?~~ 4. ~~I tweaked `eq_ignore_ascii_case()`: it now takes the argument `other: u8` instead of `other: &u8`. The latter was enforced by the trait. Since we're not bound to a trait anymore, we can drop the reference, ok?~~ => I reverted this, because the interface has to match the `AsciiExt` interface exactly. ¹ ~~Could it be that we can't write `impl [u8] {}`? This might be the reason for `AsciiExt`. If that is the case: is there a good reason we can't write such an impl block? What can we do instead?~~ => we couldn't at the time this PR was opened, but Simon made it possible. /cc @SimonSapin @zackw
2017-11-04Auto merge of #45605 - Nashenas88:derive-newtype, r=nikomatsakisbors-2/+2
Add derive and doc comment capabilities to newtype_index macro This moves `RustcDecodable` and `RustcEncodable` out of the macro definition and into the macro uses. They were conflicting with `CrateNum`'s impls of `serialize::UseSpecializedEncodable` and `serialize::UseSpecializedDecodable`, and now it's not :). `CrateNum` is now defined with the `newtype_index` macro. I also added support for doc comments on constant definitions and allowed a type to remove the pub specification on the tuple param (otherwise a LOT of code would refuse to compile for `CrateNum`). I was getting dozens of errors like this if `CrateNum` was defined as `pub struct CrateNum(pub u32)`: ``` error[E0530]: match bindings cannot shadow tuple structs --> src/librustc/dep_graph/dep_node.rs:624:25 | 63 | use hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX}; | -------- a tuple struct `CrateNum` is imported here ... 624 | [] MissingLangItems(CrateNum), | ^^^^^^^^ cannot be named the same as a tuple struct ``` I also cleaned up the formatting of the macro bodies as they were getting impossibly long. Should I go back and fix the matching rules to this style too? I also want to see what the test results look like because `CrateNum` used to just derive `Debug`, but the `newtype_index` macro has a custom implementation. This might require further pushes. Feel free to bikeshed on the macro language, I have no preference here.
2017-11-03Add a lang item to allow `impl [u8] {…}` in the standard librarySimon Sapin-0/+1
2017-11-03add `auto` keyword, parse `auto trait`, lower to HIRleonardo.yvens-3/+3
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-3/+3
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-03Use a `Set<T>` instead of a `Map<T, bool>`Oliver Schneider-6/+6
2017-11-02rustc: add item name to deprecated lint warningKevin Butler-5/+7
2017-11-02add `regions_that_outlive` to `FreeRegionMap`Niko Matsakis-0/+13
2017-11-01newindex_type macro: make index private by default and allow pub through configPaul Daniel Faria-1/+5
2017-11-01newtype_index: Support simpler serializable override, custom derive, and fix ↵Paul Daniel Faria-6/+1
mir_opt tests
2017-11-01Add derive and doc comment capabilities to newtype_index macroPaul Daniel Faria-1/+2
2017-11-01Auto merge of #45538 - nikomatsakis:nll-liveness, r=pnkfelixbors-1/+1
enable non-lexical lifetimes in the MIR borrow checker This PR, joint work with @spastorino, fills out the NLL infrastructure and integrates it with the borrow checker. **Don't get too excited:** it includes still a number of hacks (the subtyping code is particularly hacky). However, it *does* kinda' work. =) The final commit demonstrates this by including a test that -- with both the AST borrowck and MIR borrowck -- reports an error by default. But if you pass `-Znll`, you only get an error from the AST borrowck, demonstrating that the integration succeeds: ``` struct MyStruct { field: String } fn main() { let mut my_struct = MyStruct { field: format!("Hello") }; let value = &my_struct.field; if value.is_empty() { my_struct.field.push_str("Hello, world!"); //~^ ERROR cannot borrow (Ast) } } ```
2017-10-31change region display to `'_#Nr`, update the `newtype_index!` macroNiko Matsakis-1/+1
The macro now takes a format string. It no longer defaults to using the type name. Didn't seem worth going through contortions to maintain. I also changed most of the debug formats to be `foo[N]` instead of `fooN`.
2017-10-31Count type aliases in patternssinkuu-6/+6
2017-10-28Auto merge of #45540 - virgil-palanciuc:master, r=estebankbors-3/+25
Avoid repetition on “use of unstable library feature 'rustc_private'” This PR fixes the error by only emitting it when the span contains a real file (is not inside a macro) - and making sure it's emitted only once per span. The first check was needed because spans-within-macros seem to differ a lot and "fixing" them to the real location is not trivial (and the method that does this is private to another module). It also feels like there always will be an error on import, with the real file name, so not sure there's a point to re-emit the same error at macro use. Fix #44953.
2017-10-28implemented code reviewVirgil Palanciuc-14/+13
2017-10-27Implement RFC 1861: Extern typesPaul Lietar-0/+3
2017-10-26relax restriction - allow errors to be emmitted within macro spans, as long ↵Virgil Palanciuc-9/+8
as the same error message has not been used before (i.e. use the None as the span key, for errors that occur within macros)
2017-10-25fix #44953 - The “use of unstable library feature 'rustc_private'” error ↵Virgil Palanciuc-3/+27
is very repetitive
2017-10-25Auto merge of #45476 - Xanewok:fingerprint-disambiguator, r=michaelwoeristerbors-3/+3
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-3/+3
2017-10-24Auto merge of #44766 - sunjay:lift_generics, r=nikomatsakisbors-8/+7
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-2/+2
2017-10-19Rollup merge of #45325 - spastorino:first_statement_index_with_macro, ↵kennytm-21/+6
r=nikomatsakis Generate FirstStatementIndex using newtype_index macro
2017-10-18Auto merge of #44501 - nikomatsakis:issue-44137-non-query-data-in-tcx, r=eddybbors-9/+53
remove or encapsulate the remaining non-query data in tcx I wound up removing the existing cache around inhabitedness since it didn't seem to be adding much value. I reworked const rvalue promotion, but not that much (i.e., I did not split the computation into bits, as @eddyb had tossed out as a suggestion). But it's now demand driven, at least. cc @michaelwoerister -- see the `forbid_reads` change in last commit r? @eddyb -- since the trickiest of this PR is the work on const rvalue promotion cc #44137