Commit graph

285 commits

Author SHA1 Message Date
Michael Woerister
f5bd1ca678 incr.comp.: Make Span decoding more consistent so it doesn't mess up -Zincremental-verify-ich 2017-12-08 10:02:26 +01:00
Michael Woerister
8fbc91cfe1 incr.comp.: Make MIR encoding fit for incr.comp. caching. 2017-11-28 12:44:45 +01:00
Niko Matsakis
5e04c66885 remove the generator_sigs map, query, and plumbing 2017-11-18 07:47:38 -05:00
Niko Matsakis
eb26e30b91 kill the closure_kind query 2017-11-18 07:47:37 -05:00
Michael Woerister
cb1ff24425 incr.comp.: Remove default serialization implementations for things in rustc::hir::def_id so that we get an ICE instead of silently doing the wrong thing. 2017-11-16 17:13:39 +01:00
Michael Woerister
723028f308 incr.comp.: Remove some code duplication around TyDecoder by factoring things into a macro. 2017-11-16 15:26:00 +01:00
Michael Woerister
9ac102645f incr.comp.: Properly use ty::codec::decode_cnum() in rustc_metadata::decoder. 2017-11-13 15:48:52 +01:00
Michael Woerister
c08e03ac46 incr.comp.: Add position() method to TyEncoder. 2017-11-13 15:25:09 +01:00
Michael Woerister
d01b89b948 incr.comp.: Provide session to some more decoding contexts. 2017-11-08 14:52:00 +01:00
Michael Woerister
102eaa5c10 incr.comp.: Always require Session when decoding Spans (as to avoid silently wrong results). 2017-11-07 15:14:32 +01:00
bors
44990e5b14 Auto merge of #45770 - spastorino:newtype_index, r=nikomatsakis
Make last structs indexes definitions use newtype_index macro

This PR makes the last two index structs not using newtype_index macro to use it and also fixes this https://github.com/rust-lang/rust/issues/45763 issue.
2017-11-05 22:06:15 +00:00
bors
12e6b53744 Auto merge of #45711 - tirr-c:unicode-span, r=estebank
Display spans correctly when there are zero-width or wide characters

Hopefully...
* fixes #45211
* fixes #8706

---

Before:
```
error: invalid width `7` for integer literal
  --> unicode_2.rs:12:25
   |
12 |     let _ = ("a̐éö̲", 0u7);
   |                         ^^^
   |
   = help: valid widths are 8, 16, 32, 64 and 128

error: invalid width `42` for integer literal
  --> unicode_2.rs:13:20
   |
13 |     let _ = ("아あ", 1i42);
   |                    ^^^^
   |
   = help: valid widths are 8, 16, 32, 64 and 128

error: aborting due to 2 previous errors
```

After:
```
error: invalid width `7` for integer literal
  --> unicode_2.rs:12:25
   |
12 |     let _ = ("a̐éö̲", 0u7);
   |                     ^^^
   |
   = help: valid widths are 8, 16, 32, 64 and 128

error: invalid width `42` for integer literal
  --> unicode_2.rs:13:20
   |
13 |     let _ = ("아あ", 1i42);
   |                      ^^^^
   |
   = help: valid widths are 8, 16, 32, 64 and 128

error: aborting due to 2 previous errors
```

Spans might display incorrectly on the browser.

r? @estebank
2017-11-04 23:09:19 +00:00
Santiago Pastorino
d19faead2d Make DefIndex use newtype_index macro 2017-11-04 19:22:37 -03:00
leonardo.yvens
06506bb751 [Syntax Breaking] Rename DefaultImpl to AutoImpl
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-03 16:13:20 -02:00
Wonwoo Choi
272c2faa1d Display spans correctly when there are non-half-width characters 2017-11-03 03:15:39 +09:00
bors
a3f990dc08 Auto merge of #45472 - michaelwoerister:incr-comp-caching-base, r=nikomatsakis
incr.comp.: Implement compiler diagnostic persistence.

This PR implements storing and loading diagnostics that the compiler generates and thus allows for emitting warnings during incremental compilation without actually re-evaluating the thing the warning originally came from. It also lays some groundwork for storing and loading type information and MIR in the incr. comp. cache.

~~It is still work in progress:~~
- ~~There's still some documentation to be added.~~
- ~~The way anonymous queries are handled might lead to duplicated emissions of warnings. Not sure if there is a better way or how frequent such duplication would be in practice.~~

Diagnostic message duplication is addressed separately in #45519.

r? @nikomatsakis
2017-11-01 14:28:11 +00:00
Paul Lietar
77f7e85d7f Implement RFC 1861: Extern types 2017-10-27 23:01:34 +02:00
Michael Woerister
686d2a7f14 incr.comp.: Factor some persistence functionality out of crate metadata code. 2017-10-24 14:01:44 +02:00
Michael Woerister
b9816c5fab incr.comp.: Already hash HIR bodies during metadata export so they don't have to be hashed in downstream crates. 2017-09-18 11:26:11 +02:00
Michael Woerister
e3f913167c Fix issues uncovered by rebasing:
- Don't hash traits in scope as part of HIR hashing any more.
- Some queries returned DefIndexes from other crates.
- Provide a generic way of stably hashing maps (not used everywhere yet).
2017-09-18 11:25:34 +02:00
Alex Crichton
afb85cfd33 rustc: Mostly remove ExportedSymbols
This is a big map that ends up inside of a `CrateContext` during translation for
all codegen units. This means that any change to the map may end up causing an
incremental recompilation of a codegen unit! In order to reduce the amount of
dependencies here between codegen units and the actual input crate this commit
refactors dealing with exported symbols and such into various queries.

The new queries are largely based on existing queries with filled out
implementations for the local crate in addition to external crates, but the main
idea is that while translating codegen untis no unit needs the entire set of
exported symbols, instead they only need queries about particulare `DefId`
instances every now and then.

The linking stage, however, still generates a full list of all exported symbols
from all crates, but that's going to always happen unconditionally anyway, so no
news there!
2017-09-17 09:41:43 -07:00
Eduard-Mihai Burtescu
932289c12d rustc: introduce ty::Const { ConstVal, Ty }. 2017-09-11 08:41:15 +03:00
Eduard-Mihai Burtescu
50076b00c2 rustc: intern ConstVal's in TyCtxt. 2017-09-11 08:41:03 +03:00
Alex Crichton
d724d03389 rustc: Remove DepGraph handling from rustc_metadata
This should now be entirely tracked through queries, so no need to have a
`DepGraph` in the `CStore` object any more!
2017-09-09 21:11:25 -07:00
Alex Crichton
0cdc58a1bc rustc: Store InternedString in DefPathData
Previously a `Symbol` was stored there, but this ended up causing hash
collisions in situations that otherwise shouldn't have a hash collision. Only
the symbol's string value was hashed, but it was possible for distinct symbols
to have the same string value, fooling various calcuations into thinking that
these paths *didn't* need disambiguating data when in fact they did!

By storing `InternedString` instead we're hopefully triggering all the exising
logic to disambiguate paths with same-name `Symbol` but actually distinct
locations.
2017-09-05 07:47:27 -07:00
Alex Crichton
0182c8bbda rustc: Rename item_body query to extern_const_body
Should hopefully more accurately reflect what's happening! This commit also
removes the cache in the cstore implementation as it's already cached through
the query infrastructure.
2017-09-05 07:37:58 -07:00
Vadim Petrochenkov
3da868dcb6 Make fields of Span private 2017-08-30 01:38:54 +03:00
Alex Crichton
c872f47276 Merge remote-tracking branch 'origin/master' into gen 2017-08-25 07:15:12 -07:00
Murarth
8e0d01b432 Implement From<&[T]> and others for Arc/Rc
Implements RFC 1845, adding implementations of:

* `From<&[T]>` for `Rc<[T]>`
* `From<&str>` for `Rc<str>`
* `From<String>` for `Rc<str>`
* `From<Box<T: ?Sized>>` for `Rc<T>`
* `From<Vec<T>>` for `Rc<[T]>`
* and likewise for `Arc<_>`

Also removes now-obsolete internal methods `Rc::__from_array` and
`Rc::__from_str`, replacing their use with `Rc::from`.
2017-08-19 11:43:31 -07:00
Alex Crichton
1210ebff43 Merge remote-tracking branch 'origin/master' into gen 2017-08-16 10:03:47 -07:00
Zack M. Davis
1b6c9605e4 use field init shorthand EVERYWHERE
Like #43008 (f668999), but _much more aggressive_.
2017-08-15 15:29:17 -07:00
John Kåre Alsaker
d861982ca6 Generator literal support 2017-07-28 15:46:23 +02:00
Alex Crichton
fd95db25b3 Merge remote-tracking branch 'origin/master' into proc_macro_api 2017-07-05 08:42:13 -07:00
Eduard-Mihai Burtescu
33ecf72e8e rustc: move the PolyFnSig out of TyFnDef. 2017-06-27 16:39:52 +03:00
Eduard-Mihai Burtescu
8e53a03d15 rustc: rename closure_type to fn_sig. 2017-06-27 16:32:48 +03:00
Jeffrey Seyfried
e42836b208 Implement quote! and other proc_macro API. 2017-06-26 02:06:26 +00:00
bors
28cc0c5a7b Auto merge of #42593 - ibabushkin:on-demand-external-source, r=eddyb
Implement lazy loading of external crates' sources. Fixes #38875

Fixes #38875. This is a follow-up to #42507. When a (now correctly translated) span from an external crate is referenced in a error, warning or info message, we still don't have the source code being referenced.
Since stuffing the source in the serialized metadata of an rlib is extremely wasteful, the following scheme has been implemented:

* File maps now contain a source hash that gets serialized as well.
* When a span is rendered in a message, the source hash in the corresponding file map(s) is used to try and load the source from the corresponding file on disk. If the file is not found or the hashes don't match, the failed attempt is recorded (and not retried).
* The machinery fetching source lines from file maps is augmented to use the lazily loaded external source as a secondary fallback for file maps belonging to external crates.

This required a small change to the expected stderr of one UI test (it now renders a span, where previously was none).

Further work can be done based on this - some of the machinery previously used to hide external spans is possibly obsolete and the hashing code can be reused in different places as well.

r? @eddyb
2017-06-18 10:41:05 +00:00
Inokentiy Babushkin
bd4fe45405
External spans: Added a test for #38875.
A bug has been discovered and fixed in the process.
2017-06-13 14:46:35 +02:00
bors
3f8b93693d Auto merge of #42537 - michaelwoerister:tcx-for-dep-node, r=nikomatsakis
incr.comp.: Make DepNode `Copy` and valid across compilation sessions

This PR moves `DepNode` to a representation that does not need retracing and thus simplifies comparing dep-graphs from different compilation sessions. The code also gets a lot simpler in many places, since we don't need the generic parameter on `DepNode` anymore.  See https://github.com/rust-lang/rust/issues/42294 for details.

~~NOTE: Only the last commit of this is new, the rest is already reviewed in https://github.com/rust-lang/rust/pull/42504.~~

This PR is almost done but there are some things I still want to do:
- [x] Add some module-level documentation to `dep_node.rs`, explaining especially what the `define_dep_nodes!()` macro is about.
- [x] Do another pass over the dep-graph loading logic. I suspect that we can get rid of building the `edges` map and also use arrays instead of hash maps in some places.

cc @rust-lang/compiler
r? @nikomatsakis
2017-06-12 11:39:35 +00:00
Inokentiy Babushkin
3d2cff0c94
Added source hashes to FileMap
We can use these to perform lazy loading of source files belonging to
external crates. That way we will be able to show the source code of
external spans that have been translated.
2017-06-10 13:39:39 +02:00
Michael Woerister
3607174909 incr.comp.: Uniformly represent DepNodes as (Kind, StableHash) pairs. 2017-06-09 15:03:34 +02:00
bors
5fe923d434 Auto merge of #42507 - ibabushkin:external-span-trans, r=eddyb
Fix translation of external spans

Previously, I noticed that spans from external crates don't generate any output. This limitation is problematic if analysis is performed on one or more external crates, as is the case with [rust-semverver](https://github.com/ibabushkin/rust-semverver). This change should address this behaviour, with the potential drawback that a minor performance hit is to be expected, as spans from potentially large crates have to be translated now.
2017-06-09 12:49:49 +00:00
Inokentiy Babushkin
9a054f2002
Fix translation of external spans. 2017-06-07 16:31:05 +02:00
Michael Woerister
8b36d3308e Allocate DefIndices for global crate metadata.
This allows for treating global crate metadata the same as regular metadata with regard to incr. comp.
2017-06-07 12:11:40 +02:00
Michael Woerister
59ebe8e115 Make a newtype for DefPathHash so they are not confused with content hashes 2017-05-31 13:54:38 +02:00
Jeffrey Seyfried
3eb235b45e Improve intercrate hygiene. 2017-05-25 05:52:11 +00:00
Michael Woerister
4549423f28 Use 128 instead of 64 bits for DefPath hashes 2017-05-18 11:10:11 +02:00
bors
4640e18572 Auto merge of #41911 - michaelwoerister:querify_trait_def, r=nikomatsakis
Remove interior mutability from TraitDef by turning fields into queries

This PR gets rid of anything `std::cell` in `TraitDef` by
- moving the global list of trait impls from `TraitDef` into a query,
- moving the list of trait impls relevent for some self-type from `TraitDef` into a query
- moving the specialization graph of trait impls into a query, and
- moving `TraitDef::object_safety` into a query.

I really like how querifying things not only helps with incremental compilation and on-demand, but also just plain makes the code cleaner `:)`

There are also some smaller fixes in the PR. Commits can be reviewed separately.

r? @eddyb or @nikomatsakis
2017-05-17 21:44:08 +00:00
Michael Woerister
8da2fe8ed7 Remove interior mutability from TraitDef by turning fields into queries. 2017-05-15 15:28:28 +02:00
Michael Woerister
c2d9b4e334 ICH: Hash lists of local trait impls as part of the HIR. 2017-05-15 15:27:49 +02:00