Commit Graph

5202 Commits

Author SHA1 Message Date
Santiago Pastorino
07a706ecf5
Avoid math and use patterns to grab projection base 2019-09-13 09:29:57 -03:00
Santiago Pastorino
232a4a2881
Destructure instead of using split_at 2019-09-12 16:03:38 -03:00
Santiago Pastorino
87420cd1bc
Make Place Boxed on Statement to reduce size from 64 bytes to 32 bytes 2019-09-11 16:28:06 -03:00
Santiago Pastorino
e73d189e4e
Use slice patterns to match projection base 2019-09-09 18:16:49 -03:00
Santiago Pastorino
b04e6c7344
Make move_path_children_matching closure take a PlaceElem instead of a slice 2019-09-09 18:16:49 -03:00
Santiago Pastorino
7efee8dd05
Use rposition to find the position of an elem 2019-09-09 18:16:49 -03:00
Santiago Pastorino
e9c41148c0
Convert Place's projection to a boxed slice 2019-09-09 18:16:49 -03:00
bors
2b8116dced Auto merge of #63994 - Centril:refactor-qualify-consts, r=spastorino,oli-obk
Refactor the `MirPass for QualifyAndPromoteConstants`

This is an accumulation of drive-by commits while working on `Vec::new` as a stable `const fn`.
The PR is probably easiest read commit-by-commit.

r? @oli-obk

cc @eddyb @ecstatic-morse -- your two PRs https://github.com/rust-lang/rust/pull/63812 and https://github.com/rust-lang/rust/pull/63860 respectively will conflict with this a tiny bit but it should be trivial to reintegrate your changes atop of this.
2019-09-08 16:49:39 +00:00
Mazdak Farrokhzad
89a69fd76d
Rollup merge of #64139 - Mark-Simulacrum:strip-legacy-proc-macro, r=petrochenkov
Migrate internal diagnostic registration to macro_rules

Review is best done commit-by-commit.

Fixes #64132.
2019-09-07 20:01:44 +02:00
Mazdak Farrokhzad
afb6a7002d
Rollup merge of #64202 - alexreg:rush-pr-1, r=Centril
Fixed grammar/style in some error messages

Factored out from hacking on rustc for work on the REPL.

r? @Centril
2019-09-06 19:00:49 +02:00
Mazdak Farrokhzad
055409538d Refuse to downgrade NLL errors on Rust >= 2018. 2019-09-06 11:06:18 +02:00
Mazdak Farrokhzad
2d168fa741 mir borrowck: drive-by cleanup. 2019-09-06 10:40:06 +02:00
Alexander Regueiro
022d9c8eb5 Fixed grammar/style in error messages and reblessed tests. 2019-09-06 03:46:08 +01:00
Mark Rousskov
41b39fce98 Remove rustc_diagnostic_macros feature 2019-09-05 12:35:18 -04:00
Mark Rousskov
b437240cee Replace diagnostic plugins with macro_rules 2019-09-05 12:35:15 -04:00
bors
618768492f Auto merge of #64172 - Centril:rollup-8i8oh54, r=Centril
Rollup of 11 pull requests

Successful merges:

 - #62848 (Use unicode-xid crate instead of libcore)
 - #63774 (Fix `window.hashchange is not a function`)
 - #63930 (Account for doc comments coming from proc macros without spans)
 - #64003 (place: Passing `align` = `layout.align.abi`, when also passing `layout`)
 - #64030 (Fix unlock ordering in SGX synchronization primitives)
 - #64041 (use TokenStream rather than &[TokenTree] for built-in macros)
 - #64051 (Add x86_64-linux-kernel target)
 - #64063 (Fix const_err with `-(-0.0)`)
 - #64083 (Point at appropriate arm on type error on if/else/match with one non-! arm)
 - #64100 (Fix const eval bug breaking run-pass tests in Miri)
 - #64157 (Opaque type locations in error message for clarity.)

Failed merges:

r? @ghost
2019-09-05 12:41:41 +00:00
Mazdak Farrokhzad
23265741d3
Rollup merge of #64100 - wesleywiser:fix_miri_const_eval, r=oli-obk
Fix const eval bug breaking run-pass tests in Miri

PR #63580 broke miri's ability to run the run-pass test suite with MIR
optimizations enabled. The issue was that we weren't properly handling
the substs and DefId associated with a Promoted value. This didn't break
anything in rustc because in rustc this code runs before the Inliner
pass which is where the DefId and substs can diverge from their initial
values. It broke Miri though because it ran this code again after
running the optimization pass.

r? @oli-obk
cc @RalfJung
2019-09-05 12:11:17 +02:00
Mazdak Farrokhzad
2238d19515
Rollup merge of #64063 - JohnTitor:fix-const-err, r=oli-obk
Fix const_err with `-(-0.0)`

Fixes #64059

r? @oli-obk
2019-09-05 12:11:14 +02:00
Mazdak Farrokhzad
a8d4e4f435
Rollup merge of #62848 - matklad:xid-unicode, r=petrochenkov
Use unicode-xid crate instead of libcore

This PR proposes to remove `char::is_xid_start` and `char::is_xid_continue` functions from `libcore` and use `unicode_xid` crate from crates.io (note that this crate is already present in rust-lang/rust's Cargo.lock).

Reasons to do this:

* removing rustc-binary-specific stuff from libcore
* making sure that, across the ecosystem, there's a single definition of what rust identifier is (`unicode-xid` has almost 10 million downs, as a `proc_macro2` dependency)
* making it easier to share `rustc_lexer` crate with rust-analyzer: no need to `#[cfg]` if we are building as a part of the compiler

Reasons not to do this:

* increased maintenance burden: we'll need to upgrade unicode version both in libcore and in unicode-xid. However, this shouldn't be a too heavy burden: just running `./unicode.py` after new unicode version. I (@matklad) am ready to be a t-compiler side maintainer of unicode-xid. Moreover, given that xid-unicode is an important dependency of syn, *someone* needs to maintain it anyway.
* xid-unicode implementation is significantly slower. It uses a more compact table with binary search, instead of a trie. However, this shouldn't matter in practice, because we have fast-path for ascii anyway, and code size savings is a plus. Moreover, in #59706 not using libcore turned out to be *faster*, presumably beacause checking for whitespace with match is even faster.

<details>

<summary>old description</summary>

Followup to #59706

r? @eddyb

Note that this doesn't actually remove tables from libcore, to avoid conflict with https://github.com/rust-lang/rust/pull/62641.

cc https://github.com/unicode-rs/unicode-xid/pull/11

</details>
2019-09-05 12:11:04 +02:00
bors
9776723881 Auto merge of #62800 - albins:polonius-initialization-1, r=nikomatsakis
Extend Polonius fact generation for (some) move tracking

This PR will extend rustc to emit facts used for tracking moves and initialization in Polonius. It is most likely the final part of my master's thesis work.
2019-09-05 08:51:38 +00:00
Mazdak Farrokhzad
4dfbaba3bf
Rollup merge of #64141 - nnethercote:minimize-LocalInternedString, r=petrochenkov
Minimize uses of `LocalInternedString`

`LocalInternedString` is described as "An alternative to `Symbol` and `InternedString`, useful when the chars within the symbol need to be accessed. It is best used for temporary values."

This PR makes the code match that comment, by removing all non-local uses of `LocalInternedString`. This allows the removal of a number of operations on `LocalInternedString` and a couple of uses of `unsafe`.
2019-09-05 03:59:49 +02:00
Mazdak Farrokhzad
9718f7a09f
Rollup merge of #64005 - ecstatic-morse:is-indirect, r=oli-obk
Add a `Place::is_indirect` method to determine whether a `Place` contains a `Deref` projection

Working on #63860 requires tracking some property about each local. This requires differentiating `Place`s like `x` and `x.field[index]` from ones like `*x` and `*x.field`, since the first two will always access the same region of memory as `x` while the latter two may access any region of memory. This functionality is duplicated in various places across the compiler. This PR adds a helper method to `Place` which determines whether that `Place` has a `Deref` projection at any point and changes some existing code to use the new method.

I've not converted `qualify_consts.rs` to use the new method, since it's not a trivial conversion and it will get replaced anyway by #63860. There may be other potential uses besides the two I change in this PR.

r? @oli-obk
2019-09-05 03:59:37 +02:00
Aleksey Kladov
206fe8e1c3 flatten rustc_lexer::character_properties module
On the call site, `rustc_lexer::is_whitespace` reads much better than
`character_properties::is_whitespace`.
2019-09-04 15:13:29 +03:00
Aleksey Kladov
a0c186c34f remove XID and Pattern_White_Space unicode tables from libcore
They are only used by rustc_lexer, and are not needed elsewhere.

So we move the relevant definitions into rustc_lexer (while the actual
unicode data comes from the unicode-xid crate) and make the rest of
the compiler use it.
2019-09-04 13:11:11 +03:00
Albin Stjerna
28312b5b06 Rustfmt the files I touched 2019-09-04 10:52:03 +02:00
Albin Stjerna
560ef6d710 Polonius: emit variable access facts 2019-09-04 09:46:44 +02:00
Albin Stjerna
9cd1a11571 Polonius: don't emit region_live_at 2019-09-04 09:46:44 +02:00
Albin Stjerna
6568b086a2 Polonius: don't emit var_maybe_initialized_on_exit 2019-09-04 09:46:44 +02:00
Albin Stjerna
9f39e001df Polonius: Rename parent and var_starts_path 2019-09-04 09:46:44 +02:00
Albin Stjerna
6b09477e91 Polonius: emit initialization/move tracking facts
- var_starts_path
- parent
- initialized_at
- moved_out_at

This also switches to the intended emission of `var_drop_used` fact emission,
where that fact is always emitted on a drop-use of a variable, regardless of its
initialization status, as Polonius now handles that.
2019-09-04 09:46:44 +02:00
Albin Stjerna
996ba932cc NLL: Adapt to the new Polonius types 2019-09-04 09:44:40 +02:00
Albin Stjerna
2adb246b5c NLL: New Polonius version 2019-09-04 09:44:40 +02:00
Nicholas Nethercote
224daa64bd Remove LocalInternedString::get.
It has a single use, which is easily changed to something better.
2019-09-04 14:40:23 +10:00
Nicholas Nethercote
0ad111f8bb Remove LocalInternedString uses from librustc/ty/.
This is not a compelling change in isolation, but it is a necessary
step.
2019-09-04 14:23:30 +10:00
bors
b50520835f Auto merge of #63561 - HeroicKatora:alloc-private-bytes, r=oli-obk
Make Allocation::bytes private

Fixes #62931.

Direct immutable access to the bytes is still possible but redirected through the new method `raw_bytes_with_undef_and_ptr`, similar to `get_bytes_with_undef_and_ptr` but without requiring an interpretation context and not doing *any* relocation or bounds checks. The `size` of the allocation is stored separately which makes access as `Size` and `usize` more ergonomic.

cc: @RalfJung
2019-09-02 22:07:40 +00:00
Wesley Wiser
46877e2890 Fix const eval bug breaking run-pass tests in Miri
PR #63580 broke miri's ability to run the run-pass test suite with MIR
optimizations enabled. The issue was that we weren't properly handling
the substs and DefId associated with a Promoted value. This didn't break
anything in rustc because in rustc this code runs before the Inliner
pass which is where the DefId and substs can diverge from their initial
values. It broke Miri though because it ran this code again after
running the optimization pass.
2019-09-02 17:23:21 -04:00
Yuki Okushi
0cd9c1623f Fix condition and tests' flags 2019-09-02 03:40:35 +09:00
Yuki Okushi
8e9825aeb9 Fix overflow_check 2019-09-02 03:06:11 +09:00
Yuki Okushi
4a0872b37e Add overflow_check check 2019-09-02 02:18:16 +09:00
Yuki Okushi
3a6aadaa8c Add opt-level check 2019-09-02 01:05:38 +09:00
Yuki Okushi
35c9e5f122 Fix const_err with -(-0.0) 2019-09-01 22:05:50 +09:00
Matthew Jasper
c621919deb Kill borrows from assignments after generating new borrows 2019-08-31 15:35:20 +01:00
Mazdak Farrokhzad
0a8a3dd88a qualify_consts: move thread_local condition out. 2019-08-31 06:17:10 +02:00
Mazdak Farrokhzad
9196af0b36 qualify_consts: extract error_min_const_fn_violation. 2019-08-31 06:07:34 +02:00
Mazdak Farrokhzad
2f733aad5a qualify_consts: extract remove_drop_and_storage_dead_on_promoted_locals. 2019-08-31 06:07:34 +02:00
Mazdak Farrokhzad
8af33b3253 qualify_consts: extract check_non_thread_local_static_is_sync 2019-08-31 06:07:34 +02:00
Mazdak Farrokhzad
c1d440070e qualify_consts: fuse prompted_temps. 2019-08-31 02:45:51 +02:00
Mazdak Farrokhzad
b6360fbc4c qualify_consts: extract check_short_circuiting_in_const_local. 2019-08-31 02:45:51 +02:00
Mazdak Farrokhzad
8f184b369d qualify_consts: misc cleanup. 2019-08-31 02:45:51 +02:00
Mazdak Farrokhzad
3cc8087c48 qualify_consts: extractt 'determine_mode'. 2019-08-31 02:45:51 +02:00