Commit Graph

79764 Commits

Author SHA1 Message Date
Vadim Petrochenkov c6ca1e4abd Use `Ident`s in a number of structures in HIR
Namely: labels, type parameters, bindings in patterns, parameter names in functions without body.
All of these do not need hygiene after lowering to HIR, only span locations.
2018-06-28 11:04:50 +03:00
Vadim Petrochenkov e8215a4f6f Use `Ident`s for path segments in HIR 2018-06-28 11:04:50 +03:00
Vadim Petrochenkov 1fe9b4d763 Use `Ident`s for associated type bindings in HIR 2018-06-28 11:04:50 +03:00
Vadim Petrochenkov c5454c04bc Use `Ident`s for lifetimes in HIR 2018-06-28 11:04:50 +03:00
bors ba196bdcb1 Auto merge of #51444 - estebank:impl-static, r=nikomatsakis
Suggestion for 'static impl Trait return

When encountering a named or anonymous sup requirement (for example,
`&'a self`) and a `'static` impl Trait return type, suggest adding the
`'_` lifetime constraing to the return type.

Fix #43719, #51282.

```
error: cannot infer an appropriate lifetime
  --> $DIR/static-return-lifetime-infered.rs:17:16
   |
LL |     fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
   |                                   ----------------------- this return type evaluates to the `'static` lifetime...
LL |         self.x.iter().map(|a| a.0)
   |         ------ ^^^^
   |         |
   |         ...but this borrow...
   |
note: ...can't outlive the anonymous lifetime #1 defined on the method body at 16:5
  --> $DIR/static-return-lifetime-infered.rs:16:5
   |
LL | /     fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
LL | |         self.x.iter().map(|a| a.0)
LL | |     }
   | |_____^
help: you can add a constraint to the return type to make it last less than `'static` and match the anonymous lifetime #1 defined on the method body at 16:5
   |
LL |     fn iter_values_anon(&self) -> impl Iterator<Item=u32> + '_ {
   |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
2018-06-28 03:57:28 +00:00
bors 99a9d6806d Auto merge of #51538 - nikomatsakis:nll-perf-examination, r=eddyb
convert NLL ops to caches

This is a extension of <https://github.com/rust-lang/rust/pull/51460>. It uses a lot more caching than we used to do. This caching is not yet as efficient as it could be, but I'm curious to see the current perf results.

This is the high-level idea: in the MIR type checker, use [canonicalized queries](https://rust-lang-nursery.github.io/rustc-guide/traits/canonical-queries.html) for all the major operations. This is helpful because the MIR type check is operating in a context where all types are fully known (mostly, anyway) but regions are completely renumbered. This means we often wind up with duplicate queries like `Foo<'1, '2> :Bar` and `Foo<'3, '4>: Bar`. Canonicalized queries let us re-use the results. By the final commit in this PR, we can essentially just "read off" the resulting region relations and add them to the NLL type check.
2018-06-28 01:41:40 +00:00
bors 266afeb17c Auto merge of #51859 - kennytm:rollup, r=kennytm
Rollup of 7 pull requests

Successful merges:

 - #49987 (Add str::split_ascii_whitespace.)
 - #50342 (Document round-off error in `.mod_euc()`-method, see issue #50179)
 - #51658 (Only do sanity check with debug assertions on)
 - #51799 (Lower case some feature gate error messages)
 - #51800 (Add a compiletest header for edition)
 - #51824 (Fix the error reference for LocalKey::try_with)
 - #51842 (Document that Layout::from_size_align does not allow align=0)

Failed merges:

r? @ghost
2018-06-27 23:41:23 +00:00
kennytm 99a0d6bf0e
Rollup merge of #51842 - rust-lang:align-is-nonzero, r=cramertj
Document that Layout::from_size_align does not allow align=0

This was already implied since zero is not a power of two, but maybe worth pointing out.
2018-06-28 06:15:43 +08:00
kennytm 7f4347f8e2
Rollup merge of #51824 - vorner:thread-local-try-with-doc, r=kennytm
Fix the error reference for LocalKey::try_with

There's no such thing as `ThreadLocalError` and the method obviously returns `AccessError`, so adjusting (probably only outdated docs).
2018-06-28 06:15:42 +08:00
kennytm 700a2f799a
Rollup merge of #51800 - mark-i-m:edition2018compiletest, r=nikomatsakis
Add a compiletest header for edition

r? @nikomatsakis

Are the `-Zunstable-options` options needed in these tests? It looks like they aren't. If not, I can remove them.
2018-06-28 06:15:41 +08:00
kennytm 770d0fba63
Rollup merge of #51799 - mark-i-m:lower_case_feature_gate, r=mark-i-m
Lower case some feature gate error messages
2018-06-28 06:15:40 +08:00
kennytm 1ebd9adef4
Rollup merge of #51658 - oli-obk:unregress_perf, r=nikomatsakis
Only do sanity check with debug assertions on

r? @nnethercote

I'm slighty confused. These changes address code that the `unused-warnings` benchmark doesn't go through, yet I see a 5% improvement to nightly on the `check` run, and no improvement on the other runs.

Maybe this change allows unrelated code in the same function to be better optimized?
2018-06-28 06:15:39 +08:00
kennytm 63531f515d
Rollup merge of #50342 - fkjogu:euclidean, r=BurntSushi
Document round-off error in `.mod_euc()`-method, see issue #50179

Due to a round-off error the method `.mod_euc()` of both `f32` and `f64` can produce mathematical invalid outputs. If `self` in magnitude is much small than the modulus `rhs` and negative, `self + rhs` in the first branch cannot be represented in the given precision and results into `rhs`. In the mathematical strict sense, this breaks the definition. But given the limitation of floating point arithmetic it can be thought of the closest representable value to the true result, although it is not strictly in the domain `[0.0, rhs)` of the function. It is rather the left side asymptotical limit. It would be desirable that it produces the mathematical more sound approximation of `0.0`, the right side asymptotical limit. But this breaks the property, that `self == self.div_euc(rhs) * rhs + a.mod_euc(rhs)`.

The discussion in issue #50179 did not find an satisfying conclusion to which property is deemed more important. But at least we can document the behaviour. Which this pull request does.
2018-06-28 06:15:38 +08:00
kennytm e5462b82e3
Rollup merge of #49987 - clarcharr:split_ascii_whitespace, r=SimonSapin
Add str::split_ascii_whitespace.

As mentioned in #48656.

While `str::split_whitespace` now works in `libcore`, it still makes sense to offer this method, considering how it is still more performant in cases where only ASCII is necessary.
2018-06-28 06:15:37 +08:00
Clar Charr b5cee029a5 Add str::split_ascii_whitespace. 2018-06-27 17:54:27 -04:00
bors cd494c1f09 Auto merge of #51139 - vakaras:issue-50716, r=nikomatsakis
Fix NLL issue 50716 and add a regression test.

Fix for NLL issue #50716.

r? @nikomatsakis
2018-06-27 21:32:44 +00:00
Niko Matsakis 1523de34a2 rustfmt various files 2018-06-27 16:30:38 -04:00
Niko Matsakis 9b1d2229ff change the `enter_canonical_trait_query` method to give a fulfill cx 2018-06-27 16:04:32 -04:00
Niko Matsakis f0fdce31d9 update comments 2018-06-27 15:45:53 -04:00
Niko Matsakis 5fd3b26280 rename `prequery` to `try_fast_path` 2018-06-27 15:45:53 -04:00
Niko Matsakis 0a0dae0964 pull out `ParamEnvAnd` and remove `QueryKey` 2018-06-27 15:45:49 -04:00
bors 23b55161ab Auto merge of #51852 - oli-obk:miri_fix, r=Zoxc
Don't use `ParamEnv::reveal_all()` if there is a real one available

fixes #51841

r? @Zoxc
2018-06-27 19:30:14 +00:00
bors 4aff10bb1b Auto merge of #51850 - abarth:draw_again, r=cramertj
[fuchsia] Update zx_cprng_draw to target semantics

This change is the final step in improving the semantics of
zx_cprng_draw. Now the syscall always generates the requested number of
bytes. If the syscall would have failed to generate the requested number
of bytes, the syscall either terminates the entire operating system or
terminates the calling process, depending on whether the error is a
result of the kernel misbehaving or the userspace program misbehaving.
2018-06-27 17:20:27 +00:00
Oliver Schneider 89d8e0a260 Don't use `ParamEnv::reveal_all()` if there is a real one available 2018-06-27 18:24:24 +02:00
Vytautas Astrauskas 03ecd982bf Fix the error of selecting obligation by not running the borrow checker. 2018-06-27 18:14:00 +02:00
Felix S. Klock II f288b87c23 Move regression test from `compile-fail/` to `ui/` test directory. 2018-06-27 18:13:43 +02:00
Vytautas Astrauskas 8b1ea84265 Fix the regression test for issue 50716. 2018-06-27 18:13:43 +02:00
Vytautas Astrauskas 612eeb1df7 Fix NLL issue 50716 and add a regression test. 2018-06-27 18:13:43 +02:00
Adam Barth a9f7cc3b49 [fuchsia] Update zx_cprng_draw to target semantics
This change is the final step in improving the semantics of
zx_cprng_draw. Now the syscall always generates the requested number of
bytes. If the syscall would have failed to generate the requested number
of bytes, the syscall either terminates the entire operating system or
terminates the calling process, depending on whether the error is a
result of the kernel misbehaving or the userspace program misbehaving.
2018-06-27 08:56:19 -07:00
bors ed0350e945 Auto merge of #51356 - Zoxc:encode-cleanup, r=michaelwoerister
Make opaque::Encoder append-only and make it infallible
2018-06-27 14:25:52 +00:00
Niko Matsakis b2e899f843 move into `provide` methods 2018-06-27 09:42:21 -04:00
Niko Matsakis c3f7e02fb6 rename to `shrink_to_tcx_lifetime` 2018-06-27 09:27:07 -04:00
Simon Sapin 1565fc2120 Document that Layout::from_size_align does not allow align=0
This was already implied since zero is not a power of two, but maybe
worth pointing out.
2018-06-27 15:07:42 +02:00
Niko Matsakis c2f7757bc5 extend comment to note complications around lifetimes 2018-06-27 08:55:41 -04:00
Niko Matsakis 35a5065573 pacify the mercilous tidy 2018-06-27 07:28:25 -04:00
Niko Matsakis c6a7c6fc68 improve comments on `dropck_outlives` 2018-06-27 07:26:29 -04:00
bors 142c98dd5a Auto merge of #51496 - petrochenkov:mhelper2, r=nikomatsakis
Implement `#[macro_export(local_inner_macros)]` (a solution for the macro helper import problem)

Implement a solution for the macro helper issue discussed in https://github.com/rust-lang/rust/issues/35896 as described in https://github.com/rust-lang/rust/issues/35896#issuecomment-395977901.

Macros exported from libraries can be marked with `#[macro_export(local_inner_macros)]` and this annotation changes how nested macros in them are resolved.

If we have a fn-like macro call `ident!(...)` and `ident` comes from a `macro_rules!` macro marked with  `#[macro_export(local_inner_macros)]` then it's replaced with `$crate::ident!(...)` and resolved as such (`$crate` gets the same context as `ident`).
2018-06-27 11:20:16 +00:00
Niko Matsakis 1be4fffc24 improve comment on instantiate NLL query result fn 2018-06-27 07:19:17 -04:00
Niko Matsakis 5bfdb97684 remove `either` dependency we are not using 2018-06-27 07:05:40 -04:00
Niko Matsakis 59ea17ed3f rename `upcast` to `cast_to_tcx_lifetime` and improve comment 2018-06-27 07:02:37 -04:00
Niko Matsakis d695512437 fix wrong query description 2018-06-27 06:57:20 -04:00
Niko Matsakis d49d5222a9 merge all the `type_op_foo` modules into one as they are so trivial 2018-06-27 06:53:54 -04:00
Niko Matsakis 66c88392b4 use query boiler plate for `normalize_projection_ty` too 2018-06-27 06:49:43 -04:00
Niko Matsakis e6c8c632b7 use query boilerplate for prove-predicate -- slightly inefficient
This requires us to allocate a single entry vector we didn't use to
allocate. I doubt this makes a difference in practice, as this only
occurs for cache misses.
2018-06-27 06:49:20 -04:00
Niko Matsakis ac40d73c6f use query boilerplate for subtype 2018-06-27 06:48:52 -04:00
Niko Matsakis fa71af4192 use query boilerplate for `normalize` 2018-06-27 06:48:43 -04:00
Niko Matsakis 2fd8a312d9 extract out query boilerplate and use for `Eq` 2018-06-27 06:48:32 -04:00
Vadim Petrochenkov d347270e0c Implement `#[macro_export(local_inner_macros)]` 2018-06-27 13:10:16 +03:00
Niko Matsakis 188ad384a3 nit: don't import Debug directly 2018-06-27 06:01:19 -04:00
John Kåre Alsaker 14d3c6e8f4 Make opaque::Encoder append-only and make it infallible 2018-06-27 11:43:15 +02:00