Commit Graph

354 Commits

Author SHA1 Message Date
bors
247835aacb Auto merge of #47374 - topecongiro:issue-47096, r=nikomatsakis
Simplify irrefutable slice patterns

Closes #47096.
2018-01-25 03:20:54 +00:00
Seiichi Uchida
604a54f3d9 Simplify irrefutable slice patterns
Closes #47096.
2018-01-17 12:22:17 +09:00
Ariel Ben-Yehuda
98fbccee0c fix comments 2018-01-13 23:41:11 +02:00
Ariel Ben-Yehuda
c1281b41ec check_match: fix handling of privately uninhabited types
the match-checking code used to use TyErr for signaling "unknown,
inhabited" types for a long time. It had been switched to using the
exact type in #38069, to handle uninhabited types.

However, in #39980, we discovered that we still needed the "unknown
inhabited" logic, but I used `()` instead of `TyErr` to handle that.
Revert to using `TyErr` to fix that problem.
2018-01-13 21:17:19 +02:00
Seiichi Uchida
42410a96c4 Use delay_span_bug() over debug!() 2018-01-13 00:54:56 +09:00
Seiichi Uchida
142134d54f Ignore CTFE errors while lowering patterns
Closes #43105.
2018-01-12 20:50:03 +09:00
Malo Jaffré
3f073c409a Try to fix a perf regression by updating log
Upgrade `log` to `0.4` in multiple crates.
2018-01-07 16:54:05 +01:00
kennytm
b63f89783d Rollup merge of #47170 - eddyb:us-vs-usize, r=nikomatsakis
rustc: use {U,I}size instead of {U,I}s shorthands.

`Us`/`Is` come from a time when `us` and `is` were the literal suffixes that are now `usize` / `isize`.

r? @nikomatsakis
2018-01-07 02:36:02 +08:00
Alex Crichton
8c9bf663d4 rustc: Don't use relative paths for extended errors
These no longer work now that Cargo changes the cwd of rustc while it's running.
Instead use an absolute path that's set by rustbuild.
2018-01-04 07:21:22 -08:00
Eduard-Mihai Burtescu
210ac01792 rustc: use {U,I}size instead of {U,I}s shorthands. 2018-01-04 03:12:04 +02:00
Esteban Küber
eed98d55fb Various tweaks 2017-12-20 11:03:26 -08:00
Esteban Küber
8749250327 Use a label for catch-all pattern instead of note 2017-12-19 19:11:02 -08:00
Oliver Schneider
acac58502b
Move large chunks of miri from rustc::mir::interpret to rustc_mir::interpret 2017-12-12 17:27:07 +01:00
Oliver Schneider
8c2ec689c1
Put miri const eval checking behind -Zmiri 2017-12-12 08:59:25 +01:00
Eduard-Mihai Burtescu
9cb6499dde miri: don't use an associated constant for a Machine's own data. 2017-12-06 14:23:32 +02:00
Eduard-Mihai Burtescu
ff6152cdc8 miri: move param_env from Machine to EvalContext. 2017-12-06 14:12:05 +02:00
Eduard-Mihai Burtescu
42a534c20a miri: monomorphize types iff they came from MIR. 2017-12-06 13:50:31 +02:00
Oliver Schneider
acdf83f228
Update miri to rustc changes 2017-12-06 09:25:29 +01:00
Oliver Schneider
d4c442d65c
Expose miri <-> ctfe differences
miri needs to start storing everything in the TyCtxt so we can have relocations and aggregates
2017-09-29 12:55:08 +02:00
Oliver Schneider
ea35192d7c
Adjust imports to librustc::mir::interpret 2017-09-29 12:54:39 +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
Alex Burka
681e5da61e change #![feature(const_fn)] to specific gates 2017-09-16 15:53:02 +00:00
Eduard-Mihai Burtescu
74349fa288 rustc: evaluate fixed-length array length expressions lazily. 2017-09-11 08:41:16 +03:00
Eduard-Mihai Burtescu
88217618ec rustc: remove obsolete const_val::ErrKind::{Negate,Not}On. 2017-09-11 08:41:15 +03:00
Eduard-Mihai Burtescu
8a9b78f5cc rustc: use ty::Const for the length of TyArray. 2017-09-11 08:41:15 +03:00
Eduard-Mihai Burtescu
3ce31eb990 rustc: replace usize with u64 and ConstUsize. 2017-09-11 08:41:15 +03: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
Eduard-Mihai Burtescu
da0a47a081 Use NodeId/HirId instead of DefId for local variables. 2017-09-08 22:00:59 +03: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
Alex Crichton
84ae4b75be rustc: Migrate CrateStore::item_body to a query
This commit migrates the `item_body` method on `CrateStore` to a query instead
to enable better tracking of dependencies and whatnot.
2017-09-05 07:37:58 -07:00
Eduard-Mihai Burtescu
8bdfd8a003 rustc: rename CodeExtent to Scope and RegionMaps to ScopeTree. 2017-09-01 23:27:48 +03:00
Tamir Duberstein
b3f50caee0
*: remove crate_{name,type} attributes
Fixes #41701.
2017-08-25 16:18:21 -04:00
Vadim Petrochenkov
de4dbe5789 rustc: Remove some dead code 2017-08-19 13:27:16 +03: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
bors
0d12553320 Auto merge of #43740 - michaelwoerister:local-id-in-typecktables, r=arielb1
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-14 14:15:06 +00:00
Bastien Orivel
3ab86fbab2 Fix some typos 2017-08-12 14:01:11 +02:00
Michael Woerister
1f54df1101 Encapsulate sub-table access in TypeckTables and validate keys on each access. 2017-08-11 12:17:07 +02:00
Michael Woerister
e777189b4a Use ItemLocalId as key for TypeckTables::pat_binding_modes. 2017-08-11 12:11:38 +02:00
Michael Woerister
7f2423eede Use ItemLocalId as key for node_types, node_substs, and adjustments in TypeckTables. 2017-08-11 12:11:38 +02:00
Michael Woerister
783ccc443b Make TypeckTables::type_dependent_defs use ItemLocalId instead of NodeId. 2017-08-11 12:11:38 +02:00
Alex Crichton
0374e6aab7 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.
2017-08-09 09:13:51 -07:00
Eduard-Mihai Burtescu
9861df4760 rustc_const_math: use apfloat::ieee::{Single,Double} in ConstFloat. 2017-08-02 17:28:11 +03:00
Tobias Schottdorf
851c77088d default binding modes: add pat_binding_modes
This PR kicks off the implementation of the [default binding modes RFC][1] by
introducing the `pat_binding_modes` typeck table mentioned in the [mentoring
instructions][2].

`pat_binding_modes` is populated in `librustc_typeck/check/_match.rs` and
used wherever the HIR would be scraped prior to this PR. Unfortunately, one
blemish, namely a two callers to `contains_explicit_ref_binding`, remains.
This will likely have to be removed when the second part of [1], the
`pat_adjustments` table, is tackled. Appropriate comments have been added.

See #42640.

[1]: https://github.com/rust-lang/rfcs/pull/2005
[2]: https://github.com/rust-lang/rust/issues/42640#issuecomment-313535089
2017-07-30 10:19:53 -04:00
Eduard-Mihai Burtescu
60cf5428b3 rustc_const_eval: keep track of the appropriate ParamEnv. 2017-07-27 20:59:40 +03:00
Eduard-Mihai Burtescu
4c900c5248 rustc_const_eval: always require correct Substs. 2017-07-27 12:22:26 +03:00
Eduard-Mihai Burtescu
148718b4f3 Implement const fn {size,align}_of. 2017-07-19 14:46:54 +03:00
Sam Cappleman-Lynes
1b3c339560 Update function name to reflect reality 2017-07-16 18:05:03 +01:00
Sam Cappleman-Lynes
b11596867d Fix range_covered_by_constructor for exclusive ranges.
This resolves #43253
2017-07-16 17:34:09 +01:00