about summary refs log tree commit diff
path: root/src/librustc/middle
AgeCommit message (Collapse)AuthorLines
2017-04-16rustc_const_eval: move ConstEvalErr to the rustc crate.Eduard-Mihai Burtescu-5/+159
2017-04-14Rollup merge of #40702 - mrhota:global_asm, r=nagisaCorey Farwell-2/+4
Implement global_asm!() (RFC 1548) This is a first attempt. ~~One (potential) problem I haven't solved is how to handle multiple usages of `global_asm!` in a module/crate. It looks like `LLVMSetModuleInlineAsm` overwrites module asm, and `LLVMAppendModuleInlineAsm` is not provided in LLVM C headers 😦~~ I can provide more detail as needed, but honestly, there's not a lot going on here. r? @eddyb CC @Amanieu @jackpot51 Tracking issue: #35119
2017-04-13use `tcx.crate_name(LOCAL_CRATE)` rather than `LinkMeta::crate_name`Niko Matsakis-1/+0
2017-04-13Auto merge of #40570 - nikomatsakis:inference-subtype-through-obligation, ↵bors-0/+1
r=arielb1 Handle subtyping in inference through obligations We currently store subtyping relations in the `TypeVariables` structure as a kind of special case. This branch uses normal obligations to propagate subtyping, thus converting our inference variables into normal fallback. It also does a few other things: - Removes the (unstable, outdated) support for custom type inference fallback. - It's not clear how we want this to work, but we know that we don't want it to work the way it currently does. - The existing support was also just getting in my way. - Fixes #30225, which was caused by the trait caching code pretending type variables were normal unification variables, when indeed they were not (but now are). There is one fishy part of these changes: when computing the LUB/GLB of a "bivariant" type parameter, I currently return the `a` value. Bivariant type parameters are only allowed in a very particular situation, where the type parameter is only used as an associated type output, like this: ```rust pub struct Foo<A, B> where A: Fn() -> B { data: A } ``` In principle, if one had `T=Foo<A, &'a u32>` and `U=Foo<A, &'b u32>` and (e.g.) `A: for<'a> Fn() -> &'a u32`, then I think that computing the LUB of `T` and `U` might do the wrong thing. Probably the right behavior is just to create a fresh type variable. However, that particular example would not compile (because the where-clause is illegal; `'a` does not appear in any input type). I was not able to make an example that *would* compile and demonstrate this shortcoming, and handling the LUB/GLB was mildly inconvenient, so I left it as is. I am considering whether to revisit this or what. I have started a crater run to test the impact of these changes.
2017-04-12First attempt at global_asm! macroA.J. Gardner-2/+4
2017-04-12Rollup merge of #41141 - michaelwoerister:direct-metadata-ich-final, ↵Tim Neumann-2/+25
r=nikomatsakis ICH: Replace old, transitive metadata hashing with direct hashing approach. This PR replaces the old crate metadata hashing strategy with a new one that directly (but stably) hashes all values we encode into the metadata. Previously we would track what data got accessed during metadata encoding and then hash the input nodes (HIR and upstream metadata) that were transitively reachable from the accessed data. While this strategy was sound, it had two major downsides: 1. It was susceptible to generating false positives, i.e. some input node might have changed without actually affecting the content of the metadata. That metadata entry would still show up as changed. 2. It was susceptible to quadratic blow-up when many metadata nodes shared the same input nodes, which would then get hashed over and over again. The new method does not have these disadvantages and it's also a first step towards caching more intermediate results in the compiler. Metadata hashing/cross-crate incremental compilation is still kept behind the `-Zincremental-cc` flag even after this PR. Once the new method has proven itself with more tests, we can remove the flag and enable cross-crate support by default again. r? @nikomatsakis cc @rust-lang/compiler
2017-04-12Rollup merge of #41063 - nikomatsakis:issue-40746-always-exec-loops, r=eddybTim Neumann-5/+0
remove unnecessary tasks Remove various unnecessary tasks. All of these are "always execute" tasks that don't do any writes to tracked state (or else an assert would trigger, anyhow). In some cases, they issue lints or errors, but we''ll deal with that -- and anyway side-effects outside of a task don't cause problems for anything that I can see. The one non-trivial refactoring here is the borrowck conversion, which adds the requirement to go from a `DefId` to a `BodyId`. I tried to make a useful helper here. r? @eddyb cc #40746 cc @cramertj @michaelwoerister
2017-04-12ICH: Replace old, transitive metadata hashing with direct hashing approach.Michael Woerister-2/+21
Instead of collecting all potential inputs to some metadata entry and hashing those, we directly hash the values we are storing in metadata. This is more accurate and doesn't suffer from quadratic blow-up when many entries have the same dependencies.
2017-04-12ICH: Hash everything that gets encoded into crate metadata.Michael Woerister-0/+4
2017-04-11add Subtype predicateNiko Matsakis-0/+1
2017-04-08rustc: add some abstractions to ty::layout for a more concise API.Eduard-Mihai Burtescu-1/+1
2017-04-07Rollup merge of #41061 - arielb1:parent-lock, r=eddybCorey Farwell-2/+2
cstore: return an immutable borrow from `visible_parent_map` This prevents an ICE when `visible_parent_map` is called multiple times, for example when an item referenced in an impl signature is imported from an `extern crate` statement occurs within an impl. Fixes #41053. r? @eddyb
2017-04-07Rollup merge of #41056 - michaelwoerister:central-defpath-hashes, r=nikomatsakisCorey Farwell-0/+4
Handle DefPath hashing centrally as part of DefPathTable (+ save work during SVH calculation) In almost all cases where we construct a `DefPath`, we just hash it and throw it away again immediately. With this PR, the compiler will immediately compute and store the hash for each `DefPath` as it is allocated. This way we + can get rid of any subsequent `DefPath` hash caching (e.g. the `DefPathHashes`), + don't need to allocate a transient `Vec` for holding the `DefPath` (although I'm always surprised how little these small, dynamic allocations seem to hurt performance), and + we don't hash `DefPath` prefixes over and over again. That last part is because we construct the hash for `prefix::foo` by hashing `(hash(prefix), foo)` instead of hashing every component of prefix. The last commit of this PR is pretty neat, I think: ``` The SVH (Strict Version Hash) of a crate is currently computed by hashing the ICHes (Incremental Computation Hashes) of the crate's HIR. This is fine, expect that for incr. comp. we compute two ICH values for each HIR item, one for the complete item and one that just includes the item's interface. The two hashes are are needed for dependency tracking but if we are compiling non-incrementally and just need the ICH values for the SVH, one of them is enough, giving us the opportunity to save some work in this case. ``` r? @nikomatsakis This PR depends on https://github.com/rust-lang/rust/pull/40878 to be merged first (you can ignore the first commit for reviewing, that's just https://github.com/rust-lang/rust/pull/40878).
2017-04-07ICH: Centrally compute and cache DefPath hashes as part of DefPathTable.Michael Woerister-0/+4
2017-04-07Auto merge of #40873 - cramertj:on-demandify-queries, r=nikomatsakisbors-3/+14
On demandify reachability cc https://github.com/rust-lang/rust/issues/40746 I tried following this guidance from #40746: > The following tasks currently execute before a tcx is built, but they could be easily converted into queries that are requested after tcx is built. The main reason they are the way they are was to avoid a gratuitious refcell (but using the refcell map seems fine)... but the result of moving `region_maps` out of `TyCtxt` and into a query caused a lot of churn, and seems like it could potentially result in a rather large performance hit, since it means a dep-graph lookup on every use of `region_maps` (rather than just a field access). Possibly `TyCtxt` could store a `RefCell<Option<RegionMap>>` internally and use that to prevent repeat lookups, but that feels like it's duplicating the work of the dep-graph. @nikomatsakis What did you have in mind for this?
2017-04-06don't try to blame tuple fields for immutabilityAriel Ben-Yehuda-7/+11
Tuple fields don't have an `&T` in their declaration that can be changed to `&mut T` - skip them.. Fixes #41104.
2017-04-04kill `Liveness`Niko Matsakis-2/+0
2017-04-04remove `EffectCheck`Niko Matsakis-3/+0
2017-04-04cstore: return an immutable borrow from `visible_parent_map`Ariel Ben-Yehuda-2/+2
Fixes #41053.
2017-04-04On-demandify reachabilityTaylor Cramer-3/+14
2017-03-31Rollup merge of #40928 - GAJaloyan:patch-2, r=eddybCorey Farwell-0/+2
adding debug in consume_body function When in debug_assertions=true mode, the function consume_body lacks some debug output, which makes it harder to follow the control flow. This commit adds this needed debug.
2017-03-30removing trailing whitespacesGAJaloyan-1/+1
2017-03-30adding debug in consume_body functionGAJaloyan-0/+2
When in debug_assertions=true mode, the function consume_body lacks some debug output, which makes it harder to follow the control flow. This commit adds this needed debug.
2017-03-30refactor the `targeted_by_break` fieldNiko Matsakis-2/+2
In master, this field was an arbitrary node-id (in fact, an id for something that doesn't even exist in the HIR -- the `catch` node). Breaks targeting this block used that id. In the newer system, this field is a boolean, and any breaks targeted this block will use the id of the block.
2017-03-30refactor if so that the "then type" is an expressionNiko Matsakis-3/+3
2017-03-30Auto merge of #40597 - jseyfried:improve_span_expn_info, r=jseyfriedbors-5/+4
macros: improve `Span`'s expansion information This PR improves `Span`'s expansion information. More specifically: - It refactors AST node span construction to preserve expansion information. - Today, we only use the underlying tokens' `BytePos`s, throwing away the `ExpnId`s. - This improves the accuracy of AST nodes' expansion information, fixing #30506. - It refactors `span.expn_id: ExpnId` to `span.ctxt: SyntaxContext` and removes `ExpnId`. - This gives all tokens as much hygiene information as `Ident`s. - This is groundwork for procedural macros 2.0 `TokenStream` API. - This is also groundwork for declarative macros 2.0, which will need this hygiene information for some non-`Ident` tokens. - It simplifies processing of spans' expansion information throughout the compiler. - It fixes #40649. - It fixes #39450 and fixes part of #23480. r? @nrc
2017-03-29Rollup merge of #40841 - arielb1:immutable-blame, r=pnkfelixCorey Farwell-79/+61
borrowck: consolidate `mut` suggestions This converts all of borrowck's `mut` suggestions to a new `mc::ImmutabilityBlame` API instead of the current mix of various hacks. Fixes #35937. Fixes #40823. Fixes #40859. cc @estebank r? @pnkfelix
2017-03-29Refactor how spans are combined in the parser.Jeffrey Seyfried-3/+2
2017-03-29Merge `ExpnId` and `SyntaxContext`.Jeffrey Seyfried-2/+2
2017-03-27Rollup merge of #40683 - nikomatsakis:incr-comp-coerce-unsized-info, r=eddybAlex Crichton-2/+0
on-demand-ify `custom_coerce_unsized_kind` and `inherent-impls` This "on-demand" task both checks for errors and computes the custom unsized kind, if any. This task is only defined on impls of `CoerceUnsized`; invoking it on any other kind of impl results in a bug. This is just to avoid having an `Option`, could easily be changed. r? @eddyb
2017-03-27Fix various useless derefs and slicingsOliver Schneider-1/+1
2017-03-27borrowck: consolidate `mut` suggestionsAriel Ben-Yehuda-79/+61
This converts all of borrowck's `mut` suggestions to a new `mc::ImmutabilityBlame` API instead of the current mix of various hacks. Fixes #35937. Fixes #40823.
2017-03-25Rollup merge of #40771 - nikomatsakis:issue-40746-privacy-access-levels, r=eddybCorey Farwell-14/+18
"on-demandify" privacy and access levels r? @eddyb cc @cramertj https://github.com/rust-lang/rust/issues/40746
2017-03-25Warn when using a `'static` lifetime boundAdam Ransom-2/+12
Previously a `'static` lifetime bound would result in an `undeclared lifetime` error when compiling, even though it could be considered valid. However, it is unnecessary to use it as a lifetime bound so we present the user with a warning instead and suggest using the `'static` lifetime directly, in place of the lifetime parameter.
2017-03-23convert privacy access levels into a queryNiko Matsakis-8/+12
2017-03-23move `export_map` into the tcxNiko Matsakis-6/+6
2017-03-23convert inherent-impl-related things to on-demand queriesNiko Matsakis-2/+0
There are now 3 queries: - inherent_impls(def-id): for a given type, get a `Rc<Vec<DefId>>` with all its inherent impls. This internally uses `crate_inherent_impls`, doing some hacks to keep the current deps (which, btw, are not clearly correct). - crate_inherent_impls(crate): gathers up a map from types to `Rc<Vec<DefId>>`, touching the entire krate, possibly generating errors. - crate_inherent_impls_overlap_check(crate): performs overlap checks between the inherent impls for a given type, generating errors.
2017-03-22Refactor checking if a `Lifetime` is staticAdam Ransom-2/+2
Simply move the test for `keywords::StaticLifetime` into the `Lifetime` impl, to match how elision is checked.
2017-03-20Rollup merge of #40229 - cramertj:break-to-blocks, r=nikomatsakisCorey Farwell-69/+66
Implement `?` in catch expressions Builds on #39921. Final part of #39849. r? @nikomatsakis
2017-03-20Auto merge of #39628 - arielb1:shimmir, r=eddybbors-3/+1
Translate shims using MIR This removes one large remaining part of old trans.
2017-03-19Rollup merge of #40445 - estebank:issue-18150, r=jonathandturnerCorey Farwell-0/+15
Point to let when modifying field of immutable variable Point at the immutable local variable when trying to modify one of its fields. Given a file: ```rust struct Foo { pub v: Vec<String> } fn main() { let f = Foo { v: Vec::new() }; f.v.push("cat".to_string()); } ``` present the following output: ``` error: cannot borrow immutable field `f.v` as mutable --> file.rs:7:13 | 6 | let f = Foo { v: Vec::new() }; | - this should be `mut` 7 | f.v.push("cat".to_string()); | ^^^ error: aborting due to previous error ``` Fix #27593.
2017-03-19Rollup merge of #40441 - tschottdorf:promotable-rfc, r=eddybCorey Farwell-3/+2
Add feature gate for rvalue-static-promotion Probably needs more tests (which ones?) and there may be other things that need to be done. Also not sure whether the version that introduces the flag is really `1.15.1`. See https://github.com/rust-lang/rfcs/pull/1414. Updates #38865.
2017-03-19Auto merge of #40346 - jseyfried:path_and_tokenstream_attr, r=nrcbors-2/+2
`TokenStream`-based attributes, paths in attribute and derive macro invocations This PR - refactors `Attribute` to use `Path` and `TokenStream` instead of `MetaItem`. - supports macro invocation paths for attribute procedural macros. - e.g. `#[::foo::attr_macro] struct S;`, `#[cfg_attr(all(), foo::attr_macro)] struct S;` - supports macro invocation paths for derive procedural macros. - e.g. `#[derive(foo::Bar, super::Baz)] struct S;` - supports arbitrary tokens as arguments to attribute procedural macros. - e.g. `#[foo::attr_macro arbitrary + tokens] struct S;` - supports using arbitrary tokens in "inert attributes" with derive procedural macros. - e.g. `#[derive(Foo)] struct S(#[inert arbitrary + tokens] i32);` where `#[proc_macro_derive(Foo, attributes(inert))]` r? @nrc
2017-03-17Implement ? in catch expressions and add testsTaylor Cramer-69/+66
2017-03-18translate drop glue using MIRAriel Ben-Yehuda-3/+1
Drop of arrays is now translated in trans::block in an ugly way that I should clean up in a later PR, and does not handle panics in the middle of an array drop, but this commit & PR are growing too big.
2017-03-14Use `&&` instead of `&`Tobias Schottdorf-1/+1
It does not seem valuable to always evaluate the right-hand side here.
2017-03-14Add feature toggle for rvalue-static-promotion RFCTobias Schottdorf-3/+2
See https://github.com/rust-lang/rfcs/pull/1414. Updates #38865.
2017-03-14Refactor `Attribute` to use `Path` and `TokenStream` instead of `MetaItem`.Jeffrey Seyfried-2/+2
2017-03-12Update usages of 'OSX' (and other old names) to 'macOS'.Corey Farwell-1/+1
As of last year with version 'Sierra', the Mac operating system is now called 'macOS'.
2017-03-11Point to let when modifying field of immutable variableEsteban Küber-0/+15
Point at the immutable local variable when trying to modify one of its fields. Given a file: ```rust struct Foo { pub v: Vec<String> } fn main() { let f = Foo { v: Vec::new() }; f.v.push("cat".to_string()); } ``` present the following output: ``` error: cannot borrow immutable field `f.v` as mutable --> file.rs:7:13 | 6 | let f = Foo { v: Vec::new() }; | - this should be `mut` 7 | f.v.push("cat".to_string()); | ^^^ error: aborting due to previous error ```