Commit Graph

79559 Commits

Author SHA1 Message Date
bors
93a161170f Auto merge of #51617 - nnethercote:nll-allocs, r=pnkfelix
Reduce number of allocations done by NLL

A couple of easy wins. Here are the NLL speedups that exceed 1%:
```
sentry-cli-check
        avg: -3.5%      min: -3.5%      max: -3.5%
inflate-check
        avg: -1.9%      min: -1.9%      max: -1.9%
inflate
        avg: -1.7%      min: -1.7%      max: -1.7%
clap-rs-check
        avg: -1.6%      min: -1.6%      max: -1.6%
cargo-check
        avg: -1.6%      min: -1.6%      max: -1.6%
ripgrep-check
        avg: -1.4%      min: -1.4%      max: -1.4%
serde-check
        avg: -1.2%      min: -1.2%      max: -1.2%
regex-check
        avg: -1.0%      min: -1.0%      max: -1.0%
sentry-cli
        avg: -1.0%      min: -1.0%      max: -1.0%
```
r? @nikomatsakis
2018-06-20 01:39:43 +00:00
Esteban Küber
28cea50a46 Update error code numbers 2018-06-19 17:33:14 -07:00
Esteban Küber
d4bfae1319 Update message for !Sized types 2018-06-19 17:32:33 -07:00
Santiago Pastorino
d3defcaf3b
Run rustfmt 2018-06-19 21:24:39 -03:00
Santiago Pastorino
f4fc43cb20
Suggest that values are dropped in the opposite order they are defined 2018-06-19 21:21:50 -03:00
bors
ac8d1f7623 Auto merge of #51639 - SimonSapin:missing-alloc, r=rkruppe
Update the error message for a missing global allocator

Don’t mention `#[default_lib_allocator]` (which is an implementation detail irrelevant to most users) and  instead suggest using `#[global_allocator]`, which is often the correct fix.
2018-06-19 23:37:09 +00:00
Esteban Küber
76a49524bd Add test for updated parser error 2018-06-19 15:52:03 -07:00
Sgeo
0b9c686b47
Remove erroneous example of main as a non-Result function. 2018-06-19 18:32:44 -04:00
Esteban Küber
317258c1ce Fix tidy and remove unused method 2018-06-19 15:19:20 -07:00
Esteban Küber
a93f176b74 Point to previous line for single expected token 2018-06-19 15:19:16 -07:00
Esteban Küber
f1dee43887 Add link to book for Sized errors 2018-06-19 15:19:15 -07:00
Esteban Küber
776544f011 Add message to rustc_on_unimplemented attributes in core 2018-06-19 15:19:13 -07:00
bors
f28c7aef7f Auto merge of #51275 - pnkfelix:nll-diagnostics-revise-check-access-permissions, r=nikomatsakis
NLL diagnostics: revise `fn check_access_permissions`

NLL: revise `fn check_access_permissions` so that its (still branchy) shares more code paths between the different cases, and also provide more diagnostics in more cases (though the added diagnostics still do not always meet the quality bar established by AST-borrowck)

----

Transcribing "checklist" suggested by Niko, except I am rendering it as a table to make it clear that I do not regard every item in the list to be a "must have" for landing this PR.

goal | does this PR do it?
-----|------------------------------
no suggestions for `ref mut` |  yes
suggestions for direct local assignment (`{ let x = 3; x = 4; }`) | yes (see commits at end)
suggestions for direct field assignment (`{ let x = (3, 4); x.0 = 5; }` | yes (see commits at end)
suggestions for upvars (`let x = 3; let c = \|\| { &mut x; }`) | yes

Note that I added support for a couple of rows via changes that are not strictly part of `fn check_access_permissions`. If desired I can remove those commits from this PR and leave them for a later PR.

Fix #51031
Fix #51032
(bug #51191 needs a little more investigation before closing.)
Fix #51578
2018-06-19 21:31:36 +00:00
bors
d692ab406e Auto merge of #51543 - SimonSapin:oom, r=SimonSapin
Rename OOM to allocation error

The acronym is not descriptive unless one has seen it before.

* Rename the `oom` function to `handle_alloc_error`. It was **stabilized in 1.28**, so if we do this at all we need to land it this cycle.
* Rename `set_oom_hook` to `set_alloc_error_hook`
* Rename `take_oom_hook` to `take_alloc_error_hook`

Bikeshed: `on` v.s. `for`, `alloc` v.s. `allocator`, `error` v.s. `failure`
2018-06-19 19:22:12 +00:00
Esteban Küber
b3a1d56ebe Add code to incorrect pub restriction error 2018-06-19 11:37:33 -07:00
Esteban Küber
09e42bcb10 Add code to invalid ABI error 2018-06-19 11:37:33 -07:00
Simon Sapin
d2fe6c4527 Update the error message for a missing global allocator
Don’t mention `#[default_lib_allocator]` (which is an implementation detail
irrelevant to most users) and instead suggest using `#[global_allocator]`,
which is often the correct fix.
2018-06-19 20:16:43 +02:00
Simon Sapin
a9a0f4cdd1 Add a UI test for the missing allocator error message 2018-06-19 20:06:28 +02:00
Felix S. Klock II
46846496ed Add unit test for case that didn't seem to be covered in existing UI tests
(since I made this mistake at first but the tests didn't catch it):
we should not suggest adding `mut` to a reassigned `ref` or `ref mut` binding.

(The Rust language, since at least 1.0, does not have `mut ref mut` or
`ref mut mut` etc.)
2018-06-19 19:41:54 +02:00
Felix S. Klock II
a32fca71ed Update the existing compile-fail tests to reflect diagnostic changes in NLL. 2018-06-19 19:41:54 +02:00
Felix S. Klock II
35971ccc41 Update the existing UI tests to reflect diagnostic changes in NLL. 2018-06-19 19:41:48 +02:00
Felix S. Klock II
0d9998cb97 Added diagnostics for suggesting mut x on repeated mutations of x.
(Follow-on commits updating the test suite show the resulting changes
to diagnostic output.)
2018-06-19 19:38:37 +02:00
Felix S. Klock II
620a8536f6 updates to compile-fail tests for changes to NLL. 2018-06-19 19:38:37 +02:00
Felix S. Klock II
2d4df5b53e NLL: Updates to diagnostic output in test/ui. 2018-06-19 19:38:37 +02:00
Felix S. Klock II
7fd4b52b1b NLL: Broad rewrite of check_access_perimssions.
Tried to unify various common code paths and also vaguely approximate
the AST-borrowck diagnostics.

The change in (subjective) quality of diagnostics is not a universal
improvement. But I think this is a better code base to work from
for future fixes.
2018-06-19 19:38:37 +02:00
Felix S. Klock II
6dfed7e813 small refactoring: replaced mutable state with return statements in control flow.
As a drive-by, removed some dead-code.
2018-06-19 19:38:37 +02:00
Felix S. Klock II
be645be660 Thread more argument info down from Hir into the mir::LocalDecls.
Namely, we thread down the `HirId` of the explicit type of the
argument.  In the case of the special `self` variable with an implicit
type, we also thread down a description of its structure (`self`/`mut
self`/`&self`/`&mut self`).
2018-06-19 19:38:37 +02:00
Felix S. Klock II
c5c4c5e938 Add fn fn_decl to Hir, for looking up the FnDecl of a body owner. 2018-06-19 19:38:37 +02:00
Felix S. Klock II
e848fe0e3a Refactor: Replace anonymous-tuple with tuple struct as prep for adding more fields in future. 2018-06-19 19:38:37 +02:00
Felix S. Klock II
cac61267a7 Thread info about form of variable bindings, including spans of arg types, down into mir::LocalDecls.
As a drive-by: the ref_for_guards created by `fn declare_binding`
should not have been tagged as user_variables in the first
place. These secret internal locals are *pointers* to user variables,
but themselves are not such (IMO. For now at least.)
2018-06-19 19:38:37 +02:00
Emerentius
000aff604e specialize StepBy<Range(Inclusive)>
the originally generated code was highly suboptimal
this brings it close to the same code or even exactly the same as a
manual while-loop by eliminating a branch and the
double stepping of n-1 + 1 steps

The intermediate trait lets us circumvent the specialization
type inference bugs
2018-06-19 19:33:54 +02:00
Adam Barth
03a40b31a7 Update zx_cprng_draw_new on Fuchsia
Fuchsia is changing the semantics for zx_cprng_draw and
zx_cprng_draw_new is a temporary name for the new semantics.
2018-06-19 09:46:51 -07:00
bors
6ec1b626ba Auto merge of #51367 - oli-obk:silence!_I_test_you, r=Mark-Simulacrum
Use quiet tests by default

r? @eddyb
2018-06-19 15:05:19 +00:00
bors
a646c912f7 Auto merge of #51081 - kornelski:examplestr, r=steveklabnik
Use String, not &str in some collection examples

Discussed in #46966

Overuse of borrowed values in data structures is a common mistake I see in Rust user forums. Users who copy&paste such examples end up fighting with the borrow checker as soon as they replace string literals with some real values.

This changes a couple of examples to use `String`, and it adds opportunity to demonstrate use of `Borrow`.
2018-06-19 13:09:04 +00:00
bors
72b0f915ba Auto merge of #51597 - Mark-Simulacrum:update-books, r=Mark-Simulacrum
Update books for next release
2018-06-19 10:53:36 +00:00
bors
1080203e97 Auto merge of #50383 - stevepentland:union-derive, r=oli-obk
Add ability to apply custom derive to union types.

The Union item type has been included in the allowed types for a custom derive.
fyi @abonander

Closes #50223
2018-06-19 08:50:41 +00:00
Wangshan Lu
f8c8701b18
Fix links in README.md 2018-06-19 16:07:14 +08:00
bors
1cfb628ead Auto merge of #51383 - Zoxc:parallel-stuff, r=nikomatsakis
Run some stuff in parallel

Requires https://github.com/rust-lang/rust/pull/50699 to actually work correctly.

r? @nikomatsakis
2018-06-19 06:51:18 +00:00
Seiichi Uchida
cafe9d0ed4 Do not consume semicolon twice while parsing local statement 2018-06-19 14:04:16 +09:00
bors
ed39523406 Auto merge of #51278 - EPashkin:fix_mod_with_multilevel_paths_on_windows, r=nikomatsakis
Fix processing mod with multi-level path on Windows

Fix error in [rustfmt](https://github.com/rust-lang-nursery/rustfmt/issues/1754) because libsyntax can not handle `mod` with multilevel path on Windows.

Alternative is do almost same in https://github.com/rust-lang/rust/blob/master/src/libstd/sys/windows/fs.rs#L717 to allow work on paths with different separators, Ex. "\\\\?\\c:\\windows/temp"
2018-06-19 02:17:52 +00:00
Steve Pentland
14abb550bf
Add ability to apply custom derive to union types.
The Union item type has been included in the allowed types for a custom
derive. Closes #50223
2018-06-18 21:34:11 -04:00
John Kåre Alsaker
fe1cb88c08 Use MTRef and MTLock to avoid a RefCell 2018-06-19 03:19:50 +02:00
John Kåre Alsaker
8368f364e3 Add MTRef and a lock_mut function to MTLock 2018-06-19 03:19:50 +02:00
John Kåre Alsaker
d86eb784d6 Parallelize trans item collection 2018-06-19 03:19:50 +02:00
John Kåre Alsaker
71c26b3171 Save query results and the dep graph in parallel 2018-06-19 03:19:49 +02:00
John Kåre Alsaker
b5650f9282 Parallel code 2018-06-19 03:19:48 +02:00
John Kåre Alsaker
6ee8e0fc11 Add par_body_owners 2018-06-19 03:19:26 +02:00
Nicholas Nethercote
ba0bb02f6f Return a SmallVec from place_elements.
These vectors are always small, so this avoids lots of allocations.
2018-06-19 09:37:31 +10:00
Nicholas Nethercote
8c7433a3cc Avoid allocations in has_any_child_of.
`has_any_child_of` is hot. It allocates a `Vec` that almost always
doesn't exceed a length of 1.

This patch peels off the first iteration of the loop, avoiding the need
for the `Vec` creation in ~99% of cases.
2018-06-19 09:37:26 +10:00
bors
fc19590297 Auto merge of #51248 - fabric-and-ink:newtype_index_debrujin, r=nikomatsakis
Declare DebruijnIndex via newtype_index macro

Part of #49887

Declare `DebruijnIndex` via the `newtype_index` macro.
2018-06-18 23:14:50 +00:00